@@ -110,9 +110,8 @@ convertLambda bs m = do
|
||||
|
||||
convertProgram :: forall es. (GenSym :> es) => Scm.Program -> Eff es Program
|
||||
convertProgram p = do
|
||||
let nothalt = ExpContinue (ValVar "main-ktail")
|
||||
e <- telescope (convert @es) (p ^.. each . _Left) (pure . nothalt)
|
||||
_
|
||||
MkProgram <$> telescope (convert @es) (p ^.. each . _Left) (pure . nothalt)
|
||||
where nothalt = ExpContinue (ValVar "main-ktail")
|
||||
|
||||
convertExp :: forall es. (GenSym :> es) => Scm.Exp -> Eff es Exp
|
||||
convertExp e = convert e (pure . Halt1)
|
||||
|
||||
@@ -120,8 +120,9 @@ emptyEnv = MkEnv mempty mempty ["halt"]
|
||||
|
||||
stackifyExp :: GenSym :> es => Name -> Exp -> Eff es Stk.Program
|
||||
stackifyExp lbl e = do
|
||||
(code,p) <- runStackify $ stackify emptyEnv e
|
||||
pure $ p <> [ Stk.MkRoutine lbl [] (buildBlock code) ]
|
||||
let g = emptyEnv & #bound . at "main-ktail" ?~ Stk.ValReg "main-ktail"
|
||||
(code,p) <- runStackify $ stackify g e
|
||||
pure $ p <> [ Stk.MkRoutine lbl ["main-ktail"] (buildBlock code) ]
|
||||
|
||||
stackifyProgram :: GenSym :> es => Program -> Eff es Stk.Program
|
||||
stackifyProgram (MkProgram e) = stackifyExp "main" e
|
||||
|
||||
@@ -112,7 +112,7 @@ initialVM :: VM
|
||||
initialVM = MkVM
|
||||
{ stack = []
|
||||
, code = []
|
||||
, tail = TailCall (ValLabel "main") [ValLabel "ktail"]
|
||||
, tail = TailCall (ValLabel "main") [ValLabel "halt"]
|
||||
, registers = mempty
|
||||
, stdout = ""
|
||||
, result = Nothing
|
||||
|
||||
Reference in New Issue
Block a user