From e074e454d5f8b5bc5dc45dccab1d138c5cd4ab0c Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Tue, 15 Nov 2022 20:30:53 +0100 Subject: ok simplify the refs back --- app/Builtins.hs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'app/Builtins.hs') diff --git a/app/Builtins.hs b/app/Builtins.hs index 9e4215c..53ebe82 100644 --- a/app/Builtins.hs +++ b/app/Builtins.hs @@ -10,10 +10,14 @@ import qualified Operators as O bi = Builtin -hello = - bi $ do - liftIO $ putStrLn "hllo prlg" - return Nothing +hello :: BuiltinFn +hello = do + liftIO $ putStrLn "hllo prlg" + return Nothing + +printLocals :: BuiltinFn +printLocals = do + return Nothing addBuiltins :: PrlgEnv () addBuiltins = do @@ -21,28 +25,30 @@ addBuiltins = do a <- findAtom "a" b <- findAtom "b" c <- findAtom "c" + varX <- findAtom "X" b0 <- findStruct "b" 0 any1 <- findStruct "any" 1 eq2 <- findStruct "=" 2 hello0 <- findStruct "hello" 0 fail0 <- findStruct "fail" 0 true0 <- findStruct "true" 0 - prlgstate0 <- findStruct "prlgstate" 0 + printlocals0 <- findStruct "print_locals" 0 + debugprint0 <- findStruct "interpreter_state" 0 modify $ \s -> s { defs = M.fromList - [ (eq2, [[U (LocalRef 0 Nothing), U (LocalRef 0 Nothing), NoGoal]]) + [ (eq2, [[U (LocalRef 0 varX), U (LocalRef 0 varX), NoGoal]]) , (a1, [[U (Atom a), NoGoal], [U (Atom b), NoGoal]]) , ( b0 , [ [Goal, U (Struct a1), U (Atom c), LastCall] , [Goal, U (Struct a1), U (Atom b), LastCall] ]) - , (any1, [[U (VoidRef Nothing), NoGoal]]) - , (hello0, [[Invoke hello]]) + , (any1, [[U VoidRef, NoGoal]]) + , (hello0, [[Invoke $ bi hello]]) , (fail0, [[Invoke $ bi backtrack]]) , (true0, [[Invoke $ bi (pure Nothing)]]) - , ( prlgstate0 + , ( debugprint0 , [[Invoke $ bi (get >>= liftIO . print >> pure Nothing)]]) ] , ops = [(O.xfy "," 1000), (O.xfx "=" 700)] -- cgit v1.2.3