aboutsummaryrefslogtreecommitdiff
path: root/examples/working-compiler
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2014-02-18 18:07:19 +0100
committerDrahflow <drahflow@gmx.de>2014-02-18 18:07:19 +0100
commit676307d3cc203f3a5e583cdc96c37c7821f79452 (patch)
tree320fb1fa91ada14f46bd3b06f966bf08a52462a7 /examples/working-compiler
parentb66ee5f07c7642b3b92cf2b820823a1564b48a8e (diff)
Coroutines.
Diffstat (limited to 'examples/working-compiler')
-rw-r--r--examples/working-compiler/coroutine.test18
-rw-r--r--examples/working-compiler/coroutine2.test14
-rw-r--r--examples/working-compiler/coroutine3.test12
3 files changed, 44 insertions, 0 deletions
diff --git a/examples/working-compiler/coroutine.test b/examples/working-compiler/coroutine.test
new file mode 100644
index 0000000..9b5a6ef
--- /dev/null
+++ b/examples/working-compiler/coroutine.test
@@ -0,0 +1,18 @@
+{ ==caller ==data
+ "coroutine 1" dump data dump
+ data caller 1 ! =caller =data
+ "coroutine 2" dump data dump
+ data caller 1 ! =caller =data
+ "coroutine 3" dump data dump
+ data caller 1 !
+} !! ==cr
+
+"data"
+cr 1 ! --
+"here 1" dump
+cr 1 ! --
+"here 2" dump
+cr 1 ! --
+"here 3" dump
+
+0 sys .exit
diff --git a/examples/working-compiler/coroutine2.test b/examples/working-compiler/coroutine2.test
new file mode 100644
index 0000000..5ca0d3f
--- /dev/null
+++ b/examples/working-compiler/coroutine2.test
@@ -0,0 +1,14 @@
+0 ==?cr
+0 ==main
+
+{ =cr
+ 1 =main
+ "main routine" dump
+} {
+ ==caller
+ 0 =main
+ "coroutine" dump
+} !!'
+
+"afterwards" dump # mind = blown
+main { cr 0 ! } rep
diff --git a/examples/working-compiler/coroutine3.test b/examples/working-compiler/coroutine3.test
new file mode 100644
index 0000000..f4bc1db
--- /dev/null
+++ b/examples/working-compiler/coroutine3.test
@@ -0,0 +1,12 @@
+{
+ { } { -- restart } !!'
+} /restart deffd
+
+0 ==i
+
+restart ==checkpoint
+
+i 1 add =i
+i dump
+
+i 7 lt { checkpoint 0 ! } rep