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-12 12:01:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 12:01:04 -0700
commitb21fa585342ec479c48a2e1c4f8c071af25d27ca (patch)
tree4229565f974ec405e18114e57b9412463741d854 /mu.arc.t
parentbb63c4191f03aa8b7acdc8aa5a9269f84007d942 (diff)
downloadmu-b21fa585342ec479c48a2e1c4f8c071af25d27ca.tar.gz
140
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t19
1 files changed, 16 insertions, 3 deletions
diff --git a/mu.arc.t b/mu.arc.t
index a4eab61a..17795d95 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -120,7 +120,7 @@
               type (obj size 1)  ; implicitly scalar and primitive
               type-array (obj array t  elem 'type)
               type-array-address (obj size 1  address t  elem 'type-array)
-              location (obj size 1)
+              location (obj size 1  address t  elem 'location)  ; assume it points to an atom
               integer (obj size 1)
               boolean (obj size 1)
               boolean-address (obj size 1  address t)
@@ -570,7 +570,7 @@
 (new-trace "sizeof-record")
 (add-fns
   '((test1
-      ((1 integer) <- sizeof (integer-boolean-pair type)))))
+      ((1 integer) <- sizeof (integer-boolean-pair literal)))))
 (run 'test1)
 ;? (prn memory*)
 (if (~is memory*.1 2)
@@ -580,7 +580,7 @@
 (new-trace "sizeof-record-not-len")
 (add-fns
   '((test1
-      ((1 integer) <- sizeof (integer-point-pair type)))))
+      ((1 integer) <- sizeof (integer-point-pair literal)))))
 (run 'test1)
 ;? (prn memory*)
 (if (~is memory*.1 3)
@@ -661,6 +661,19 @@
 (if (or (~is memory*.3 0) (~is memory*.4 nil))
   (prn "F - 'maybe-coerce' doesn't copy value when type tag doesn't match"))
 
+(reset)
+(new-trace "new-tagged-value")
+;? (set dump-trace*)
+(add-fns
+  '((test1
+      ((1 integer-address) <- copy (34 literal))  ; pointer to nowhere
+      ((2 tagged-value-address) <- new-tagged-value (integer-address literal) (1 integer-address))
+      ((3 integer-address) (4 boolean) <- maybe-coerce (2 tagged-value-address deref) (integer-address literal)))))
+(run 'test1)
+;? (prn memory*)
+(if (or (~is memory*.3 34) (~is memory*.4 t))
+  (prn "F - 'new-tagged-value' is the converse of 'maybe-coerce'"))
+
 ; 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
 ; far. If you create a function you can call it like any other op.