aboutsummaryrefslogtreecommitdiff
path: root/src/Micro/Compiler.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-09-12 20:16:42 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-09-12 20:16:42 +0100
commit8fe1fc0c2b0b10f64c43498481e738221fe03bb3 (patch)
tree3a934f555abfbee3881f171377f64dd2f31107d0 /src/Micro/Compiler.hs
parentfea91d8e7e61693d8ece149bac91d7acda16453d (diff)
downloadmicro-lang-hs-8fe1fc0c2b0b10f64c43498481e738221fe03bb3.tar.gz
micro-lang-hs-8fe1fc0c2b0b10f64c43498481e738221fe03bb3.zip
Track local variables, WIP code gen
Diffstat (limited to 'src/Micro/Compiler.hs')
-rw-r--r--src/Micro/Compiler.hs12
1 files changed, 6 insertions, 6 deletions
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