10 - slightly more DRY
This commit is contained in:
parent
b90a10d265
commit
73978d2f82
18
mu.arc
18
mu.arc
|
@ -17,8 +17,14 @@
|
||||||
(each (name . body) fns
|
(each (name . body) fns
|
||||||
(= function*.name body)))
|
(= function*.name body)))
|
||||||
|
|
||||||
(mac m (loc)
|
(mac v (operand) ; for value
|
||||||
`(memory* (,loc 0)))
|
`(,operand 0))
|
||||||
|
|
||||||
|
(mac ty (operand)
|
||||||
|
`(,operand 1)) ; assume type is always first bit of metadata, and it's always present
|
||||||
|
|
||||||
|
(mac m (loc) ; for memory
|
||||||
|
`(memory* (v ,loc)))
|
||||||
|
|
||||||
(def run (instrs (o fn-args) (o fn-oargs))
|
(def run (instrs (o fn-args) (o fn-oargs))
|
||||||
(ret result nil
|
(ret result nil
|
||||||
|
@ -92,21 +98,21 @@
|
||||||
(m fn-args.idx)))
|
(m fn-args.idx)))
|
||||||
otype
|
otype
|
||||||
(= (m oarg.0)
|
(= (m oarg.0)
|
||||||
((fn-oargs arg.0) 1))
|
(ty (fn-oargs arg.0)))
|
||||||
jmp
|
jmp
|
||||||
(do (= pc (+ pc arg.0.0)) ; relies on continue still incrementing (bug)
|
(do (= pc (+ pc (v arg.0))) ; relies on continue still incrementing (bug)
|
||||||
;? (prn "jumping to " pc)
|
;? (prn "jumping to " pc)
|
||||||
(continue))
|
(continue))
|
||||||
jif
|
jif
|
||||||
(when (is t (m arg.0))
|
(when (is t (m arg.0))
|
||||||
(= pc (+ pc arg.1.0)) ; relies on continue still incrementing (bug)
|
(= pc (+ pc (v arg.1))) ; relies on continue still incrementing (bug)
|
||||||
;? (prn "jumping to " pc)
|
;? (prn "jumping to " pc)
|
||||||
(continue))
|
(continue))
|
||||||
copy
|
copy
|
||||||
(= (m oarg.0) (m arg.0))
|
(= (m oarg.0) (m arg.0))
|
||||||
deref
|
deref
|
||||||
(= (m oarg.0)
|
(= (m oarg.0)
|
||||||
(m (memory* arg.0)))
|
(m (memory* arg.0))) ; TODO
|
||||||
reply
|
reply
|
||||||
(do (= result arg)
|
(do (= result arg)
|
||||||
(break))
|
(break))
|
||||||
|
|
Loading…
Reference in New Issue