diff options
author | Araq <rumpf_a@web.de> | 2013-08-13 11:21:02 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-08-13 11:21:02 +0200 |
commit | d53f313599111576c9eb290d679d6ed518582530 (patch) | |
tree | f7dda2b11adf60c5df295a13dec96b90c3181a0b /tests | |
parent | 1633e22aec7a4a932a72469d6728d7f5e25d1805 (diff) | |
download | Nim-d53f313599111576c9eb290d679d6ed518582530.tar.gz |
implemented computed goto support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compile/tcomputedgoto.nim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/compile/tcomputedgoto.nim b/tests/compile/tcomputedgoto.nim new file mode 100644 index 000000000..661f70743 --- /dev/null +++ b/tests/compile/tcomputedgoto.nim @@ -0,0 +1,45 @@ +discard """ + output: '''yeah A +yeah A +yeah CD +yeah CD +yeah A +yeah CD +yeah CD +yeah A +yeah B +yeah A +yeah A +yeah A''' +""" + +type + MyEnum = enum + enumA, enumB, enumC, enumD, enumE + +proc vm() = + var instructions: array [0..100, MyEnum] + instructions[2] = enumC + instructions[3] = enumD + instructions[4] = enumA + instructions[5] = enumD + instructions[6] = enumC + instructions[7] = enumA + instructions[8] = enumB + + instructions[12] = enumE + var pc = 0 + while true: + {.computedGoto.} + case instructions[pc] + of enumA: + echo "yeah A" + of enumC, enumD: + echo "yeah CD" + of enumB: + echo "yeah B" + of enumE: + return + inc(pc) + +vm() |