about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 14:27:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 14:27:26 -0700
commit0c9f837918fd40395cda3efe6965ed7c9d980511 (patch)
treec2b35407e659a077dcc90e74e04925a828492a55
parenta28ca9a7ad6c13c38a07ca121789e77ffc8c8969 (diff)
downloadmu-0c9f837918fd40395cda3efe6965ed7c9d980511.tar.gz
142 - helper for lists
Amazing how easy it was to just dump the trace and diff, compared to my old approach
of adding new traces and rerunning.
-rw-r--r--mu.arc7
-rw-r--r--mu.arc.t2
2 files changed, 8 insertions, 1 deletions
diff --git a/mu.arc b/mu.arc
index 0e80fff7..975c23f8 100644
--- a/mu.arc
+++ b/mu.arc
@@ -321,9 +321,11 @@
                 get-address
                   (with (base arg.0
                          idx (v arg.1))
+                    (trace "get-address" base "." idx)
                     (when typeinfo.base!address
                       (assert (pos 'deref metadata.base))
                       (= base (list (memory* v.base) typeinfo.base!elem)))
+                    (trace "get-address" "after: " base)
                     (if typeinfo.base!record
                       (do (assert (< -1 idx (len typeinfo.base!elems)))
                           (+ v.base
@@ -581,6 +583,11 @@
   ((locaddr location deref) <- arg)
   (reply (result tagged-value-address)))
 
+(init-fn list-value-address
+  ((base list-address) <- arg)
+  ((result tagged-value-address) <- get-address (base list-address deref) (0 offset))
+  (reply (result tagged-value-address)))
+
 ; drop all traces while processing above functions
 (on-init
   (= traces* (queue)))
diff --git a/mu.arc.t b/mu.arc.t
index 4aff9b4f..b4f9cf3f 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -689,7 +689,7 @@
   '((test1
       ; 1 points at first node: tagged-value (int 34)
       ((1 list-address) <- new (list type))
-      ((2 tagged-value-address) <- get-address (1 list-address deref) (0 offset))
+      ((2 tagged-value-address) <- list-value-address (1 list-address))
       ((3 type-address) <- get-address (2 tagged-value-address deref) (0 offset))
       ((3 type-address deref) <- copy (integer literal))
       ((4 location) <- get-address (2 tagged-value-address deref) (1 offset))