about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-07-31 01:53:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-07-31 01:53:14 -0700
commit73978d2f828570f8bc6ff0c80deeed277eddac0d (patch)
tree29cb8689ab54199569c9cf3b2537f5477a2d283d
parentb90a10d2654d8e8610114750ba95ef543101ef0b (diff)
downloadmu-73978d2f828570f8bc6ff0c80deeed277eddac0d.tar.gz
10 - slightly more DRY
-rw-r--r--mu.arc18
1 files changed, 12 insertions, 6 deletions
diff --git a/mu.arc b/mu.arc
index 6c93e237..842f12f9 100644
--- a/mu.arc
+++ b/mu.arc
@@ -17,8 +17,14 @@
   (each (name . body) fns
     (= function*.name body)))
 
-(mac m (loc)
-  `(memory* (,loc 0)))
+(mac v (operand)  ; for value
+  `(,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))
   (ret result nil
@@ -92,21 +98,21 @@
                      (m fn-args.idx)))
               otype
                 (= (m oarg.0)
-                   ((fn-oargs arg.0) 1))
+                   (ty (fn-oargs arg.0)))
               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)
                     (continue))
               jif
                 (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)
                   (continue))
               copy
                 (= (m oarg.0) (m arg.0))
               deref
                 (= (m oarg.0)
-                   (m (memory* arg.0)))
+                   (m (memory* arg.0)))  ; TODO
               reply
                 (do (= result arg)
                     (break))