summaryrefslogtreecommitdiff
path: root/DSL/Intrinsics.hs
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-02-24 23:03:33 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-02-24 23:03:33 +1300
commit1977b7ad1e86d2b922737eb04741607e9c9a991a (patch)
tree24653cb78f5411e79d1ede853115ca38ccd80aa4 /DSL/Intrinsics.hs
parentb89d46e7df8ae65786abe37b5703392e9042db83 (diff)
Better printing functionsmain
Diffstat (limited to 'DSL/Intrinsics.hs')
-rw-r--r--DSL/Intrinsics.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/DSL/Intrinsics.hs b/DSL/Intrinsics.hs
index 930a8a0..f3784a8 100644
--- a/DSL/Intrinsics.hs
+++ b/DSL/Intrinsics.hs
@@ -10,8 +10,9 @@ dump = StackModifier { smName="DUMP", smTypes=ts, smFunc=f }
f (x:xs) = putStrLn x' >> return (Right $ xs)
where
x' = case x of
- StackString s -> s
- _ -> show x
+ StackString s -> "String:" ++ show s
+ StackInt i -> "Integer:" ++ show i
+ StackBool b -> "Boolean:" ++ show b
f _ = unreachable
drop' :: StackModifier
@@ -119,3 +120,15 @@ greaterThan = StackModifier { smName="GREATERTHAN", smTypes=ts, smFunc=f }
f (StackInt x:StackInt y:xs) = return $ Right $ StackBool(x > y):xs
f _ = unreachable
+put :: StackModifier
+put = StackModifier { smName="PUT", smTypes=[tAny], smFunc=f }
+ where
+ f (x:xs) = putStr x' >> return (Right xs)
+ where
+ x' = case x of
+ StackBool True -> "true"
+ StackBool False -> "false"
+ StackInt i -> show i
+ StackString s -> s
+ f _ = unreachable
+