about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 18:04:29 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-14 10:02:18 -0700
commit93ddcc744b91cf1bf3550024e9b8c9fd80c2571b (patch)
treee01304f0795c41b6652ec1861a832d75bf7ab34c
parent1bfb7c1090f96b6d5bf8ac1a13aee0af7f34bfa1 (diff)
downloadmu-93ddcc744b91cf1bf3550024e9b8c9fd80c2571b.tar.gz
144
-rw-r--r--mu.arc15
-rw-r--r--mu.arc.t7
2 files changed, 17 insertions, 5 deletions
diff --git a/mu.arc b/mu.arc
index 975c23f8..8b7dd768 100644
--- a/mu.arc
+++ b/mu.arc
@@ -129,7 +129,7 @@
 (def setm (loc val)  ; set memory, respecting metadata
   (trace "setm" loc " <= " val)
   (let n sz.loc
-    (trace "size of " loc " is " n)
+    (trace "setm" "size of " loc " is " n)
     (assert n)
     (if (is 1 n)
       (do (assert (~isa val 'record))
@@ -414,14 +414,14 @@
                   (do (pop-stack context)
                       (if empty.context (return ninstrs))
                       (let (caller-oargs _ _)  (parse-instr (body.context pc.context))
-;?                         (prn arg " " caller-oargs)
+                        (trace "reply" arg " " caller-oargs)
                         (each (dest src)  (zip caller-oargs arg)
-;?                           (prn src " => " dest)
+                          (trace "reply" src " => " dest)
                           (setm dest  (m src))))
                       (++ pc.context)
                       (while (>= pc.context (len body.context))
                         (pop-stack context)
-                        (if empty.context (return ninstrs))
+                        (when empty.context (return ninstrs))
                         (++ pc.context))
                       (continue))
                 ; else try to call as a user-defined function
@@ -583,7 +583,12 @@
   ((locaddr location deref) <- arg)
   (reply (result tagged-value-address)))
 
-(init-fn list-value-address
+(init-fn list-next  ; list-address -> list-address
+  ((base list-address) <- arg)
+  ((result list-address) <- get (base list-address deref) (1 offset))
+  (reply (result list-address)))
+
+(init-fn list-value-address  ; list-address -> tagged-value-address
   ((base list-address) <- arg)
   ((result tagged-value-address) <- get-address (base list-address deref) (0 offset))
   (reply (result tagged-value-address)))
diff --git a/mu.arc.t b/mu.arc.t
index 68759fe2..09f851a6 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -718,6 +718,13 @@
             (~is memory*.9 (+ second 1))
             (~is (memory* (+ second 1)) t)))
     (prn "F - 'list' constructs a heterogeneous list, which can contain elements of different types")))
+(add-fns
+  '((test2
+      ((10 list-address) <- list-next (1 list-address)))))
+(run 'test2)
+;? (prn memory*)
+(if (~is memory*.10 memory*.6)
+  (prn "F - 'list-next can move a list pointer to the next node"))
 
 ; Just like the table of types is centralized, functions are conceptualized as
 ; a centralized table of operations just like the 'primitives' we've seen so