summaryrefslogtreecommitdiff
path: root/app/Builtins.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:10:52 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:10:52 +0100
commitab86f0f21f09230aaa2225b0355907446038f819 (patch)
tree6c05c8b63b762b3e21740a010d27bb76fadd7d69 /app/Builtins.hs
parentdab150976d9a9bf705b03d32ce553d176cdef9e1 (diff)
downloadprlg-ab86f0f21f09230aaa2225b0355907446038f819.tar.gz
prlg-ab86f0f21f09230aaa2225b0355907446038f819.tar.bz2
macros macro
macron edition
Diffstat (limited to 'app/Builtins.hs')
-rw-r--r--app/Builtins.hs18
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