diff --git a/src/back/CodeGen/Expr.hs b/src/back/CodeGen/Expr.hs index c80598feb..06d8a1927 100644 --- a/src/back/CodeGen/Expr.hs +++ b/src/back/CodeGen/Expr.hs @@ -134,11 +134,14 @@ instance Translatable A.Expr (State Ctx.Context (CCode Lval, CCode Stat)) where Nothing -> return (Var $ show name, Skip) - translate (A.FieldAccess {A.target = exp, A.name = name}) = do + translate acc@(A.FieldAccess {A.target = exp, A.name = name}) = do (nexp,texp) <- translate exp tmp <- Ctx.gen_sym - return (EmbedC $ Deref nexp `Dot` (Nam $ show name), - texp) + return (Var tmp, Seq [texp, + (Assign (Decl (translate (A.getType acc), Var tmp)) (Deref nexp `Dot` (Nam $ show name)))]) + --- (Decl (Ptr $ Typ "future_t", Var the_fut_name)) +-- return (EmbedC $ Deref nexp `Dot` (Nam $ show name), +-- texp) translate l@(A.Let {A.name = name, A.val = e1, A.body = e2}) = do (ne1,te1) <- translate e1