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