From 8fe1fc0c2b0b10f64c43498481e738221fe03bb3 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 12 Sep 2022 20:16:42 +0100 Subject: Track local variables, WIP code gen --- src/Micro/Compiler.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Micro/Compiler.hs') diff --git a/src/Micro/Compiler.hs b/src/Micro/Compiler.hs index 89ba802..98fdae8 100644 --- a/src/Micro/Compiler.hs +++ b/src/Micro/Compiler.hs @@ -153,9 +153,9 @@ compileOne x = do Just err -> addError $ Error TypeError err pos Nothing -> pure rtyp _ -> addError $ Error NonCallable "non callable value in function call" pos - (A.Var ident typ val priv pos) -> do + (A.Var ident typ val priv local pos) -> do st <- get - (ev, errs) <- return $ foldlEither addSymUniq (stEnv st, stErr st) [Sym ident typ priv True pos] + (ev, errs) <- return $ foldlEither addSymUniq (stEnv st, stErr st) [Sym ident typ priv local pos] errs <- return $ if not (definedType typ) @@ -206,9 +206,9 @@ foldConstant x = fid <- foldConstant ident fargs <- traverse foldConstant args Right $ A.Call fid fargs pos - (A.Var ident typ val priv pos) -> do + (A.Var ident typ val priv local pos) -> do fv <- foldConstant val - Right $ A.Var ident typ fv priv pos + Right $ A.Var ident typ fv priv local pos (A.Return value pos) -> do fv <- traverse foldConstant value Right $ A.Return fv pos @@ -231,6 +231,6 @@ compileToAst ast = do compile :: [A.Expr] -> Either [Error] String compile ast = do - sym <- evalState (compileAll ast) startState + _ <- evalState (compileAll ast) startState fast <- left (\e -> [e]) $ traverse foldConstant ast - return $ generate version sym fast + return $ generate version fast -- cgit v1.2.3