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-28 16:32:02 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-28 16:32:02 -0800
commit1f56c99181f31314b26757307170fca0c9808cf3 (patch)
tree9b043183ff20427c36f04cb52b651cd9452ca9b3 /mu.arc
parentbfc5fe9e0df6aeba7dc12e9138305a2be5dc8c91 (diff)
downloadmu-1f56c99181f31314b26757307170fca0c9808cf3.tar.gz
359 - 'sizeof' supports 'deref' pointers
Just non-arrays for now.
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc7
1 files changed, 6 insertions, 1 deletions
diff --git a/mu.arc b/mu.arc
index 6e59ed1a..5c1b0455 100644
--- a/mu.arc
+++ b/mu.arc
@@ -686,7 +686,12 @@
              typeinfo.x!array)
     (return (+ 1 (* (m `(,v.x integer))
                     (sizeof typeinfo.x!elem)))))
-  (let type (if acons.x ty.x x)
+  (let type (if (and acons.x (pos 'deref metadata.x))
+                  typeinfo.x!elem  ; deref pointer
+                acons.x
+                  ty.x
+                :else  ; naked type
+                  x)
     (assert types*.type "sizeof: no such type @type")
     (if (~or types*.type!record types*.type!array)
           types*.type!size