about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-01 02:28:00 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-11-01 02:28:00 -0700
commit4da62e4ac325e45ae0dbd09e38b9dfcfcd78c1ae (patch)
tree0416ef8d69906888b5ba27e116c5d8b1b915920c /mu.arc
parent9059ccf615185182ee1e343e3087ee1fa87ff6f2 (diff)
downloadmu-4da62e4ac325e45ae0dbd09e38b9dfcfcd78c1ae.tar.gz
201
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc24
1 files changed, 9 insertions, 15 deletions
diff --git a/mu.arc b/mu.arc
index b7eeb7ab..7350bf52 100644
--- a/mu.arc
+++ b/mu.arc
@@ -203,14 +203,6 @@
                                   (rep val))
               (= (memory* dest) src)))))))
 
-(def array-len (operand)
-  (if typeinfo.operand!array
-        (m `(,v.operand integer))
-      (and typeinfo.operand!address (pos 'deref metadata.operand))
-        (m `(,v.operand integer-address ,@(cut operand 2)))
-      :else
-        (err "can't take len of non-array @operand")))
-
 ; (operand field-offset) -> (base-addr field-type)
 ; operand can be a deref address
 ; operand can be scope-based
@@ -232,23 +224,25 @@
   (with (base  addr.operand
          basetype  typeinfo.operand
          idx  (m offset))
-;?     (prn operand ": " base " " basetype)
     (when (pos 'deref metadata.operand)
       (assert basetype!address "@operand requests deref, but it's not an address of an array")
-      (= basetype (types* basetype!elem))
-;?       (prn "=> " basetype)
-      )
-;?     (prn "AAA")
+      (= basetype (types* basetype!elem)))
     (assert basetype!array "index on non-array @operand")
-;?     (prn "AAA " idx)
     (unless (< -1 idx array-len.operand)
       (die "@idx is out of bounds of array @operand"))
-;?     (prn "AAA")
     (list (+ base
              1  ; for array size
              (* idx (sz basetype!elem)))
           basetype!elem)))
 
+(def array-len (operand)
+  (if typeinfo.operand!array
+        (m `(,v.operand integer))
+      (and typeinfo.operand!address (pos 'deref metadata.operand))
+        (m `(,v.operand integer-address ,@(cut operand 2)))
+      :else
+        (err "can't take len of non-array @operand")))
+
 ; data structure: routine
 ; runtime state for a serial thread of execution