about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-11 11:17:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-11 11:17:04 -0700
commit1714bd1d50048ae177df6f8c2859ebe2cfd32f30 (patch)
tree8ba68d40d25f07c4a54a36636070112abc13a60f /mu.arc.t
parent639fd2fb54fde7dae2444678b1ecec6c8b376e07 (diff)
downloadmu-1714bd1d50048ae177df6f8c2859ebe2cfd32f30.tar.gz
131 - maybe-coerce now allocates new space each call
(Doesn't reclaim yet. Need to build free soon. Then lexical scopes..)

This commit showed the benefits of my persisting traces. I realized I
needed 'sz' to handle 'deref' args. But I vaguely remembered some
earlier instance when some primitive needed to recognize 'deref'
at some times but not others. Was it 'sz'? Just added a trace on
operands, reran all tests, grepped for deref.

  $ grep sz .traces -r |grep deref

Nothing would fail. Ok, add 'deref' support. Boom, 3 layers of tests
passed.

Still concerned I'm not using traces enough. Keep vigilant.

Mixing print and trace seems like a bad idea. From now on whenever I use
any existing commented-out prn's I'm going to turn them into trace
calls. That should put pressure on comprehending traces, and tools for
doing that, like segmenting by dynamic and static layers.
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t34
1 files changed, 32 insertions, 2 deletions
diff --git a/mu.arc.t b/mu.arc.t
index a6ced345..14e5dfc5 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -139,6 +139,7 @@
               integer-point-pair (obj size 2  record t  elems '(integer integer-integer-pair))
               ; tagged-values are the foundation of dynamic types
               tagged-value (obj size 2  record t  elems '(type location))
+              tagged-value-address (obj size 1  address t  elem 'tagged-value)
               )))
 
 ; Our language is assembly-like in that functions consist of series of
@@ -584,10 +585,10 @@
 (if (~is memory*.1 3)
   (prn "F - 'sizeof' is different from number of elems"))
 
-; Regardless of a type's length, you can move it around with 'copy'.
+; Regardless of a type's length, you can move it around just like a primitive.
 
 (reset)
-(new-trace "compound-operand")
+(new-trace "compound-operand-copy")
 (add-fns
   '((test1
       ((1 integer) <- copy (34 literal))
@@ -599,6 +600,35 @@
 (if (~iso memory* (obj 1 34  2 nil  3 34  4 nil))
   (prn "F - ops can operate on records spanning multiple locations"))
 
+(reset)
+(new-trace "compound-arg")
+(add-fns
+  '((test1
+      ((4 integer-boolean-pair) <- arg))
+    (main
+      ((1 integer) <- copy (34 literal))
+      ((2 boolean) <- copy (nil literal))
+      (test1 (1 integer-boolean-pair)))))
+(run 'main)
+(if (~iso memory* (obj 1 34  2 nil  4 34  5 nil))
+  (prn "F - 'arg' can copy records spanning multiple locations"))
+
+(reset)
+(new-trace "compound-arg")
+;? (set dump-trace*)
+(add-fns
+  '((test1
+      ((4 integer-boolean-pair) <- arg))
+    (main
+      ((1 integer) <- copy (34 literal))
+      ((2 boolean) <- copy (nil literal))
+      ((3 integer-boolean-pair-address) <- copy (1 literal))
+      (test1 (3 integer-boolean-pair-address deref)))))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 1 34  2 nil  3 1  4 34  5 nil))
+  (prn "F - 'arg' can copy records spanning multiple locations in indirect mode"))
+
 ; A special kind of record is the 'tagged type'. It lets us represent
 ; dynamically typed values, which save type information in memory rather than
 ; in the code to use them. This will let us do things like create heterogenous