diff options
Diffstat (limited to 'DSL/Intrinsics.hs')
| -rw-r--r-- | DSL/Intrinsics.hs | 17 |
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 + |
