From b794da7fe9b79f4e49ca5a5390f3e7f9b3bb7acb Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 17 Jul 2014 09:21:27 -0700 Subject: 28 - support 'continue' We still haven't verified that the generated code is correct. Also, time to fix that bug in arc's continue. --- mu.arc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mu.arc') diff --git a/mu.arc b/mu.arc index 0d0ea21b..c01bcdde 100644 --- a/mu.arc +++ b/mu.arc @@ -127,6 +127,10 @@ (do ;? (prn pc " " instr) (++ pc)) + ; hack: racket replaces curlies with parens, so we need the + ; keyword begin to delimit blocks. + ; ultimately there'll be no nesting and curlies will just be in a + ; line by themselves. (do ;? (prn `(open ,pc)) (push `(open ,pc) locs) @@ -153,10 +157,26 @@ (assert:is oarg nil) (recur arg) (pop stack)) + break + (do + (assert:is oarg nil) + (assert:is arg nil) + (yield `(jmp (offset ,(close-offset pc locs))))) breakif (do ;? (prn "breakif: " instr) + (assert:is oarg nil) (yield `(jif ,arg.0 (offset ,(close-offset pc locs))))) + continue + (do + (assert:is oarg nil) + (assert:is arg nil) + (yield `(jmp (offset ,(- stack.0 pc))))) + continueif + (do +;? (prn "continueif: " instr) + (assert:is oarg nil) + (yield `(jif ,arg.0 (offset ,(- stack.0 pc))))) ;else (yield instr)))) (++ pc))))))) -- cgit 1.4.1-2-gfad0