This commit is contained in:
Kartik K. Agaram 2014-12-14 09:50:10 -08:00
parent decedd0b1e
commit 7b2a710e32
1 changed files with 30 additions and 30 deletions

60
mu.arc
View File

@ -781,36 +781,36 @@
(pop stack)
(continue))
(let (oarg op arg) (parse-instr instr)
(trace "c{1" pc " " op " " oarg)
(case op
break
(do
(assert (is oarg nil) "break: can't take oarg in @instr")
(yield `(((jump)) ((,(close-offset pc locs (and arg (v arg.0))) offset)))))
break-if
(do
(assert (is oarg nil) "break-if: can't take oarg in @instr")
(yield `(((jump-if)) ,arg.0 ((,(close-offset pc locs (and cdr.arg (v arg.1))) offset)))))
break-unless
(do
(assert (is oarg nil) "break-unless: can't take oarg in @instr")
(yield `(((jump-unless)) ,arg.0 ((,(close-offset pc locs (and cdr.arg (v arg.1))) offset)))))
loop
(do
(assert (is oarg nil) "loop: can't take oarg in @instr")
(yield `(((jump)) ((,(open-offset pc stack (and arg (v arg.0))) offset)))))
loop-if
(do
(trace "cvt0" "loop-if: " instr " => " (- stack.0 1))
(assert (is oarg nil) "loop-if: can't take oarg in @instr")
(yield `(((jump-if)) ,arg.0 ((,(open-offset pc stack (and cdr.arg (v arg.1))) offset)))))
loop-unless
(do
(trace "cvt0" "loop-if: " instr " => " (- stack.0 1))
(assert (is oarg nil) "loop-unless: can't take oarg in @instr")
(yield `(((jump-unless)) ,arg.0 ((,(open-offset pc stack (and cdr.arg (v arg.1))) offset)))))
;else
(yield instr)))
(trace "c{1" pc " " op " " oarg)
(case op
break
(do
(assert (is oarg nil) "break: can't take oarg in @instr")
(yield `(((jump)) ((,(close-offset pc locs (and arg (v arg.0))) offset)))))
break-if
(do
(assert (is oarg nil) "break-if: can't take oarg in @instr")
(yield `(((jump-if)) ,arg.0 ((,(close-offset pc locs (and cdr.arg (v arg.1))) offset)))))
break-unless
(do
(assert (is oarg nil) "break-unless: can't take oarg in @instr")
(yield `(((jump-unless)) ,arg.0 ((,(close-offset pc locs (and cdr.arg (v arg.1))) offset)))))
loop
(do
(assert (is oarg nil) "loop: can't take oarg in @instr")
(yield `(((jump)) ((,(open-offset pc stack (and arg (v arg.0))) offset)))))
loop-if
(do
(trace "cvt0" "loop-if: " instr " => " (- stack.0 1))
(assert (is oarg nil) "loop-if: can't take oarg in @instr")
(yield `(((jump-if)) ,arg.0 ((,(open-offset pc stack (and cdr.arg (v arg.1))) offset)))))
loop-unless
(do
(trace "cvt0" "loop-if: " instr " => " (- stack.0 1))
(assert (is oarg nil) "loop-unless: can't take oarg in @instr")
(yield `(((jump-unless)) ,arg.0 ((,(open-offset pc stack (and cdr.arg (v arg.1))) offset)))))
;else
(yield instr)))
(++ pc))))))))
(def close-offset (pc locs nblocks)