Skip to content

Commit

Permalink
Fix issue #6
Browse files Browse the repository at this point in the history
#6

Field accesses were translated without a `_tmpN` variable.
  • Loading branch information
Stephan Brandauer committed Jul 18, 2014
1 parent becbd62 commit 0e31620
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/back/CodeGen/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e31620

Please sign in to comment.