aboutsummaryrefslogtreecommitdiff
path: root/ABC/IO.icl
diff options
context:
space:
mode:
authorCamil Staps2016-07-01 19:37:38 +0200
committerCamil Staps2016-07-01 19:37:38 +0200
commitb3f1e3ff0404a5182b6eed2d88014b4b4fbd69c2 (patch)
treec2dbd5b0a43fffc6119510bdc2f5324aa3a0e3b5 /ABC/IO.icl
parentAssembler (diff)
Moved to directory, added test program
Diffstat (limited to 'ABC/IO.icl')
-rw-r--r--ABC/IO.icl30
1 files changed, 30 insertions, 0 deletions
diff --git a/ABC/IO.icl b/ABC/IO.icl
new file mode 100644
index 0000000..a7cda49
--- /dev/null
+++ b/ABC/IO.icl
@@ -0,0 +1,30 @@
+implementation module ABC.IO
+
+import StdEnv
+
+import ABC.Machine
+import ABC.Misc
+
+:: IO :== [Char]
+
+instance toString IO where toString io = {c \\ c <- io}
+
+io_init :: IO
+io_init = []
+
+io_print :: a IO -> IO | toString a
+io_print x io = io ++ fromString (toString x)
+
+show_node :: Node Desc -> String
+show_node (Basic _ _ b) _ = toString b
+show_node (Node _ _ _) (Desc _ _ n) = n
+
+instance toString State
+where
+ toString {astack,bstack,cstack,graphstore,descstore,pc,program,io}
+ = "output : " <+ io <+ "\n" <+
+ "pc : " <+ pc <+ "\n" <+
+ "A-stack : " <+ astack <+ "\n" <+
+ "B-stack : " <+ bstack <+ "\n" <+
+ "C-stack : " <+ cstack <+ "\n" <+
+ "Graph :\n" <+ show_graphstore graphstore descstore