about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-07-31 02:27:41 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-07-31 02:27:41 -0700
commitb20165a89034e3ff6bf3959529c4dec4bab11f40 (patch)
treedfab8fa8cec8a02bc31146a467dca39e2683d74e /mu.arc
parent52c3822e0870942112a7d180d81d2caedd6aea4e (diff)
downloadmu-b20165a89034e3ff6bf3959529c4dec4bab11f40.tar.gz
44 - now 'deref' is a bit of metadata on any operand rather than a special op
Still only works in read, and only in a single instruction. But these are details.
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc13
1 files changed, 9 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc
index c44e1269..ae59da7c 100644
--- a/mu.arc
+++ b/mu.arc
@@ -20,12 +20,20 @@
 (mac v (operand)  ; for value
   `(,operand 0))
 
+(mac metadata (operand)
+  `(cdr ,operand))
+
 (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)))
 
+(mac m2 (loc)  ; for memory
+  `(if (pos 'deref (metadata ,loc))
+     (memory* (memory* (v ,loc)))
+     (memory* (v ,loc))))
+
 (def run (instrs (o fn-args) (o fn-oargs))
   (ret result nil
     (let fn-arg-idx 0
@@ -109,10 +117,7 @@
 ;?                   (prn "jumping to " pc)
                   (continue))
               copy
-                (= (m oarg.0) (m arg.0))
-              deref
-                (= (m oarg.0)
-                   (memory* (m arg.0)))
+                (= (m oarg.0) (m2 arg.0))
               reply
                 (do (= result arg)
                     (break))