From 0e3162022bd60e8b1a52271e9a3a413eb49b17e6 Mon Sep 17 00:00:00 2001 From: Stephan Brandauer Date: Fri, 18 Jul 2014 14:45:19 +0200 Subject: [PATCH] Fix issue #6 https://github.com/parapluu/mylittlepony/issues/6 Field accesses were translated without a `_tmpN` variable. --- src/back/CodeGen/Expr.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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