summaryrefslogtreecommitdiff
path: root/hs/ding.txt
diff options
context:
space:
mode:
Diffstat (limited to 'hs/ding.txt')
-rw-r--r--hs/ding.txt237
1 files changed, 237 insertions, 0 deletions
diff --git a/hs/ding.txt b/hs/ding.txt
new file mode 100644
index 0000000..72ecd45
--- /dev/null
+++ b/hs/ding.txt
@@ -0,0 +1,237 @@
+VM
+{ scopeStack =
+ [ fromList
+ [ ( "list_get"
+ , VBlock
+ BT2
+ ["list", "idx"]
+ (Block
+ [ Condition
+ (EBin BOLess (ELit (LVar "idx")) (ELit (LNum 0.0)))
+ (Block
+ [ Dive
+ "throw_error"
+ [ELit (LStr "Negative index in 'list_get'")]
+ (Block [])
+ ])
+ (Block [])
+ , Declaration "y" (ELit LNil)
+ , Dive
+ "list"
+ []
+ (Block
+ [ Dive
+ "get_helper"
+ [ELit (LVar "front"), ELit (LVar "idx")]
+ (Block [Assignment "y" (ELit (LVar "x"))])
+ ])
+ , Declaration "x" (ELit (LVar "y"))
+ ]))
+ , ( "list_new"
+ , VBlock
+ BT2
+ []
+ (Block
+ [ Declaration
+ "x"
+ (ELit
+ (LBlock
+ BT0
+ []
+ (Block
+ [ Declaration "front" (ELit LNil)
+ , Declaration "back" (ELit LNil)
+ ])))
+ ]))
+ , ( "list_pop_back"
+ , VBlock
+ BT2
+ ["list"]
+ (Block
+ [ Declaration "x" (ELit LNil)
+ , Dive
+ "list"
+ []
+ (Block
+ [ Condition
+ (EBin BOEqual (ELit (LVar "back")) (ELit LNil))
+ (Block
+ [ Dive
+ "throw_error"
+ [ ELit
+ (LStr
+ "Call to 'list_pop_back' on empty list")
+ ]
+ (Block [])
+ ])
+ (Block [])
+ , Dive
+ "back"
+ []
+ (Block
+ [ Assignment "x" (ELit (LVar "value"))
+ , Assignment "back" (ELit (LVar "prev"))
+ ])
+ , Condition
+ (EBin BOEqual (ELit (LVar "back")) (ELit LNil))
+ (Block [Assignment "front" (ELit LNil)])
+ (Block [])
+ ])
+ ]))
+ , ( "list_pop_front"
+ , VBlock
+ BT2
+ ["list"]
+ (Block
+ [ Declaration "x" (ELit LNil)
+ , Dive
+ "list"
+ []
+ (Block
+ [ Condition
+ (EBin BOEqual (ELit (LVar "front")) (ELit LNil))
+ (Block
+ [ Dive
+ "throw_error"
+ [ ELit
+ (LStr
+ "Call to 'list_pop_front' on empty list")
+ ]
+ (Block [])
+ ])
+ (Block [])
+ , Dive
+ "front"
+ []
+ (Block
+ [ Assignment "x" (ELit (LVar "value"))
+ , Assignment "front" (ELit (LVar "next"))
+ ])
+ , Condition
+ (EBin BOEqual (ELit (LVar "front")) (ELit LNil))
+ (Block [Assignment "back" (ELit LNil)])
+ (Block [])
+ ])
+ ]))
+ , ( "list_push_back"
+ , VBlock
+ BT2
+ ["list", "item"]
+ (Block
+ [ Dive
+ "list"
+ []
+ (Block
+ [ Condition
+ (EBin BOEqual (ELit (LVar "back")) (ELit LNil))
+ (Block
+ [ Assignment
+ "front"
+ (ELit
+ (LBlock
+ BT0
+ []
+ (Block
+ [ Declaration
+ "value"
+ (ELit (LVar "item"))
+ , Declaration "next" (ELit LNil)
+ , Declaration "prev" (ELit LNil)
+ ])))
+ , Assignment "back" (ELit (LVar "front"))
+ ])
+ (Block
+ [ Assignment
+ "back"
+ (ELit
+ (LBlock
+ BT0
+ []
+ (Block
+ [ Declaration
+ "value"
+ (ELit (LVar "item"))
+ , Declaration "next" (ELit LNil)
+ , Declaration
+ "prev"
+ (ELit (LVar "back"))
+ ])))
+ ])
+ ])
+ ]))
+ , ( "list_push_front"
+ , VBlock
+ BT2
+ ["list", "item"]
+ (Block
+ [ Dive
+ "list"
+ []
+ (Block
+ [ Condition
+ (EBin BOEqual (ELit (LVar "front")) (ELit LNil))
+ (Block
+ [ Assignment
+ "front"
+ (ELit
+ (LBlock
+ BT0
+ []
+ (Block
+ [ Declaration
+ "value"
+ (ELit (LVar "item"))
+ , Declaration "next" (ELit LNil)
+ , Declaration "prev" (ELit LNil)
+ ])))
+ , Assignment "back" (ELit (LVar "front"))
+ ])
+ (Block
+ [ Assignment
+ "front"
+ (ELit
+ (LBlock
+ BT0
+ []
+ (Block
+ [ Declaration
+ "value"
+ (ELit (LVar "item"))
+ , Declaration
+ "next"
+ (ELit (LVar "front"))
+ , Declaration "prev" (ELit LNil)
+ ])))
+ ])
+ ])
+ ]))
+ , ( "list_set"
+ , VBlock
+ BT2
+ ["list", "idx", "val"]
+ (Block
+ [ Condition
+ (EBin BOLess (ELit (LVar "idx")) (ELit (LNum 0.0)))
+ (Block
+ [ Dive
+ "throw_error"
+ [ELit (LStr "Negative index in 'list_set'")]
+ (Block [])
+ ])
+ (Block [])
+ , Dive
+ "list"
+ []
+ (Block
+ [ Dive
+ "set_helper"
+ [ ELit (LVar "front")
+ , ELit (LVar "idx")
+ , ELit (LVar "val")
+ ]
+ (Block [])
+ ])
+ ]))
+ ]
+ ]
+}