about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-14 18:24:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-14 18:24:46 -0700
commit554ac51249633f529860ffd902af6969ef73b209 (patch)
tree05c043126fd2790a83a21f11e9b9e333255a2728 /mu.arc
parentb9a05206d6927c2238a666ae798285fee6b50e41 (diff)
downloadmu-554ac51249633f529860ffd902af6969ef73b209.tar.gz
148 - better idiom for generic functions
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc19
1 files changed, 17 insertions, 2 deletions
diff --git a/mu.arc b/mu.arc
index f540e776..fc6f3747 100644
--- a/mu.arc
+++ b/mu.arc
@@ -292,12 +292,17 @@
                 ; control flow
                 jump
                   (do (= pc.context (+ 1 pc.context (v arg.0)))
-;?                       (prn "jumping to " pc.context)
+;?                       (trace "jump" "jumping to " pc.context)
                       (continue))
                 jump-if
                   (when (is t (m arg.0))
                     (= pc.context (+ 1 pc.context (v arg.1)))
-;?                     (prn "jumping to " pc.context)
+;?                     (trace "jump-if" "jumping to " pc.context)
+                    (continue))
+                jump-unless  ; convenient helper
+                  (unless (is t (m arg.0))
+                    (= pc.context (+ 1 pc.context (v arg.1)))
+;?                     (trace "jump-unless" "jumping to " pc.context)
                     (continue))
 
                 ; data management: scalars, arrays, records
@@ -517,6 +522,11 @@
 ;?                       (prn "break-if: " instr)
                       (assert:is oarg nil)
                       (yield `(jump-if ,arg.0 (,(close-offset pc locs) offset))))
+                  break-unless
+                    (do
+;?                       (prn "break-if: " instr)
+                      (assert:is oarg nil)
+                      (yield `(jump-unless ,arg.0 (,(close-offset pc locs) offset))))
                   continue
                     (do
                       (assert:is oarg nil)
@@ -527,6 +537,11 @@
                       (trace "cvt0" "continue-if: " instr " => " (- stack.0 1))
                       (assert:is oarg nil)
                       (yield `(jump-if ,arg.0 (,(- stack.0 1 pc) offset))))
+                  continue-unless
+                    (do
+                      (trace "cvt0" "continue-if: " instr " => " (- stack.0 1))
+                      (assert:is oarg nil)
+                      (yield `(jump-unless ,arg.0 (,(- stack.0 1 pc) offset))))
                   ;else
                     (yield instr))))
             (++ pc))))))))