diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-01-14 23:10:52 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-01-14 23:10:52 +0100 |
| commit | ab86f0f21f09230aaa2225b0355907446038f819 (patch) | |
| tree | 6c05c8b63b762b3e21740a010d27bb76fadd7d69 /app/Builtins.hs | |
| parent | dab150976d9a9bf705b03d32ce553d176cdef9e1 (diff) | |
| download | prlg-ab86f0f21f09230aaa2225b0355907446038f819.tar.gz prlg-ab86f0f21f09230aaa2225b0355907446038f819.tar.bz2 | |
macros macro
macron edition
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 |
