diff options
Diffstat (limited to 'app/Builtins.hs')
| -rw-r--r-- | app/Builtins.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/Builtins.hs b/app/Builtins.hs index a273660..9e72caa 100644 --- a/app/Builtins.hs +++ b/app/Builtins.hs @@ -133,8 +133,8 @@ retractall = BoundRef _ (Struct id) -> dropProcedure id >> continue _ -> prlgError "retractall needs a struct" -call :: InterpFn -call = +call' :: InterpFn +call' = withArgs [0] $ \[arg] -> do heap@(Heap _ hmap) <- gets (heap . cur) let exec base struct arity = do @@ -156,8 +156,8 @@ call = exec addr (Struct IR.Id {IR.arity = 0, IR.str = a}) 0 _ -> prlgError "not callable" -exec :: InterpFn -exec = +exec' :: (Code -> Code) -> InterpFn +exec' fgol = withArgs [0] $ \[arg] -> do heap <- gets (heap . cur) case Co.squashVars <$> Co.heapStructPrlgInt Nothing heap arg of @@ -171,11 +171,17 @@ exec = cur { hvar = M.empty , hed = Co.seqGoals (Co.compileGoals comma cut gs) - , gol = [LastCall] + , gol = fgol (gol cur) } } continue - _ -> prlgError "goal exec failure" + _ -> prlgError "bad goal" + +call :: InterpFn +call = exec' id + +exec :: InterpFn +exec = exec' (const [LastCall]) {- struct assembly/disassembly -} struct :: InterpFn |
