Skip to content

Commit

Permalink
Fix LL for DeclVar (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
AzimMuradov committed Jun 23, 2024
1 parent 25ee47d commit 4b1417d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Transformations/Ll/Ll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ data FunDeclaration = FunDecl Common.Identifier' [Common.Identifier'] Lfr.Expres
llGDecl :: Ast.Declaration -> LlState [Lfr.GlobalDeclaration]
llGDecl = \case
Ast.DeclVar ident value -> do
varDecl <- ll1 (Lfr.VarDecl ident) value
return [Lfr.GlobVarDecl varDecl]
var <- ll1 (Lfr.VarDecl ident) value
genFuns <- gets genFunDecls
modify $ \env -> env {genFunDecls = []}
return $ reverse (Lfr.GlobVarDecl var : (convertFunDecl <$> genFuns))
Ast.DeclFun ident _ (Ast.Fun params body) -> do
fun <- ll1 (FunDecl ident (NE.toList params)) body
genFuns <- gets genFunDecls
modify $ \env -> env {genFunDecls = []}
let convertFunDecl (FunDecl i ps b) = Lfr.GlobFunDecl i ps b
return $ convertFunDecl <$> reverse (fun : genFuns)
where
convertFunDecl (FunDecl i ps b) = Lfr.GlobFunDecl i ps b

llExpr :: Ast.Expression -> LlState Lfr.Expression
llExpr = \case
Expand Down

0 comments on commit 4b1417d

Please sign in to comment.