about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-28 17:55:45 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-28 17:55:45 -0800
commit1cb7f78fe8fd30a2b95cda06f7335f2ff20829ab (patch)
tree54f1e2549393841b1932c7f6460b19ca02c47248
parent2ca395e7ea24ff7db0bbdc51a130d7bbb586f569 (diff)
downloadmu-1cb7f78fe8fd30a2b95cda06f7335f2ff20829ab.tar.gz
365 - new primitives let us generalize 'addr'
-rw-r--r--mu.arc9
-rw-r--r--mu.arc.t3
2 files changed, 8 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc
index 693bd73c..5ca46993 100644
--- a/mu.arc
+++ b/mu.arc
@@ -310,10 +310,11 @@
   (or types*.typename!size
       (err "type @typename doesn't have a size: " (tostring:pr types*.typename))))
 
-(def addr (loc)
-  (ret result (v absolutize.loc)
-    (when (pos 'deref metadata.loc)
-      (zap memory* result))))
+(def addr (operand)
+  (let loc absolutize.operand
+    (while (pos 'deref metadata.loc)
+      (zap deref loc))
+    v.loc))
 
 (def addrs (n sz)
   (accum yield
diff --git a/mu.arc.t b/mu.arc.t
index 070d68bb..a7175d77 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -719,6 +719,9 @@
 (= memory*.4 23)
 (if (~is 23 (addr '(4 integer-address deref)))
   (prn "F - 'addr' works with indirectly-addressed 'deref'"))
+(= memory*.3 4)
+(if (~is 23 (addr '(3 integer-address-address deref deref)))
+  (prn "F - 'addr' works with multiple 'deref'"))
 
 (= routine* make-routine!foo)
 (if (~is 4 (addr '(4 integer)))