From 4c9ceb74d14e3f2956b3be2aa91b5cfc289b87be Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Tue, 13 Feb 2024 12:52:06 -0700 Subject: [PATCH] ready? --- examples/rlp/SumList.rl | 2 +- src/Compiler/JustRun.hs | 2 +- src/GM.hs | 7 +++++-- tst/Arith.hs | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/rlp/SumList.rl b/examples/rlp/SumList.rl index 4f9a49e..92cd410 100644 --- a/examples/rlp/SumList.rl +++ b/examples/rlp/SumList.rl @@ -7,5 +7,5 @@ foldr f z l = case l of list = Cons 1 (Cons 2 (Cons 3 Nil)) -main = foldr (+#) 0 list +main = print# (foldr (+#) 0 list) diff --git a/src/Compiler/JustRun.hs b/src/Compiler/JustRun.hs index 8046603..055062a 100644 --- a/src/Compiler/JustRun.hs +++ b/src/Compiler/JustRun.hs @@ -32,7 +32,7 @@ import Rlp.Parse import Rlp2Core ---------------------------------------------------------------------------------- -justHdbg :: String -> IO (Node, Stats) +justHdbg :: String -> IO GmState justHdbg s = do p <- evalRLPCIO def (parseRlpProgR >=> desugarRlpProgR $ T.pack s) withFile "/tmp/t.log" WriteMode $ hdbgProg p diff --git a/src/GM.hs b/src/GM.hs index 5809f16..d4493cf 100644 --- a/src/GM.hs +++ b/src/GM.hs @@ -9,7 +9,10 @@ module GM ( hdbgProg , evalProg , evalProgR + , GmState(..) + , gmCode, gmStack, gmDump, gmHeap, gmEnv, gmStats , Node(..) + , showState , gmEvalProg , Stats(..) , finalStateOf @@ -153,7 +156,7 @@ evalProg p = res <&> (,sts) resAddr = final ^. gmStack ^? _head res = resAddr >>= flip hLookup h -hdbgProg :: Program' -> Handle -> IO (Node, Stats) +hdbgProg :: Program' -> Handle -> IO GmState hdbgProg p hio = do (renderOut . showState) `traverse_` states -- TODO: i'd like the statistics to be at the top of the file, but `sts` @@ -161,7 +164,7 @@ hdbgProg p hio = do -- *can't* get partial logs in the case of a crash. this is in opposition to -- the above traversal which *will* produce partial logs. i love laziness :3 renderOut . showStats $ sts - pure (res, sts) + pure final where renderOut r = hPutStrLn hio $ render r ++ "\n" diff --git a/tst/Arith.hs b/tst/Arith.hs index 2c168c4..2bfb7ed 100644 --- a/tst/Arith.hs +++ b/tst/Arith.hs @@ -41,6 +41,7 @@ evalArith (a ::* b) = evalArith a * evalArith b evalArith (a ::- b) = evalArith a - evalArith b instance Arbitrary ArithExpr where + -- TODO: implement shrink arbitrary = gen 4 where gen :: Int -> Gen ArithExpr