about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-05 15:10:29 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-05 15:10:29 -0700
commitdaff44a21eb533b3774b965912a9df695a25e172 (patch)
tree07c8bcff8faf29bcc386765537d376ff5b7e7203
parent2b9727b18150b40d51a13666ba8e73c33621c986 (diff)
downloadmu-daff44a21eb533b3774b965912a9df695a25e172.tar.gz
110 - 107 for 'get-address'
-rw-r--r--mu.arc3
-rw-r--r--mu.arc.t12
2 files changed, 15 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc
index 79caa881..0704d252 100644
--- a/mu.arc
+++ b/mu.arc
@@ -308,6 +308,9 @@
                 get-address
                   (with (base arg.0
                          idx (v arg.1))
+                    (when typeinfo.base!address
+                      (assert (pos 'deref metadata.base))
+                      (= base (list (memory* v.base) typeinfo.base!elem)))
                     (if typeinfo.base!array
                           (array-ref-addr base idx)
                         typeinfo.base!record
diff --git a/mu.arc.t b/mu.arc.t
index 0e82da57..15de917a 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -435,6 +435,18 @@
 (reset)
 (add-fns
   '((main
+      ((1 integer) <- literal 34)
+      ((2 integer) <- literal t)
+      ((3 integer-boolean-pair-address) <- literal 1)
+      ((4 boolean-address) <- get-address (3 integer-boolean-pair-address deref) (1 offset)))))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 1 34  2 t  3 1  4 2))
+  (prn "F - 'get-address' returns address of fields of records"))
+
+(reset)
+(add-fns
+  '((main
       ((1 integer) <- literal 2)
       ((2 integer) <- literal 23)
       ((3 boolean) <- literal nil)