diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 16:32:02 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 16:32:02 -0800 |
commit | 1f56c99181f31314b26757307170fca0c9808cf3 (patch) | |
tree | 9b043183ff20427c36f04cb52b651cd9452ca9b3 | |
parent | bfc5fe9e0df6aeba7dc12e9138305a2be5dc8c91 (diff) | |
download | mu-1f56c99181f31314b26757307170fca0c9808cf3.tar.gz |
359 - 'sizeof' supports 'deref' pointers
Just non-arrays for now.
-rw-r--r-- | mu.arc | 7 | ||||
-rw-r--r-- | mu.arc.t | 2 |
2 files changed, 8 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 diff --git a/mu.arc.t b/mu.arc.t index 01e130f1..0c85f4a8 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -762,6 +762,8 @@ (prn "F - 'sizeof' works on record operands")) (if (~is 3 (sizeof '(34 integer-point-pair))) (prn "F - 'sizeof' works on record operands with record fields")) +(if (~is 2 (sizeof '(34 integer-boolean-pair-address deref))) + (prn "F - 'sizeof' works on pointers to records")) (= memory*.4 23) (if (~is 24 (sizeof '(4 integer-array))) |