diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 19:52:50 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 19:52:50 -0800 |
commit | dc97016a7fd9c2c5fe4d4dd014cc018f8b69b00b (patch) | |
tree | aab5b104b69718f5dd47d3abacce2feb47607719 /mu.arc | |
parent | 29754636a6fd7406be0380c491fc155ca91c1b49 (diff) | |
download | mu-dc97016a7fd9c2c5fe4d4dd014cc018f8b69b00b.tar.gz |
376 - similarly simplify record helpers
Diffstat (limited to 'mu.arc')
-rw-r--r-- | mu.arc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/mu.arc b/mu.arc index b632b479..42e4ccfe 100644 --- a/mu.arc +++ b/mu.arc @@ -614,17 +614,16 @@ (def record-info (operand field-offset) (trace "record-info" operand " " field-offset) (assert (is 'offset (ty field-offset)) "record index @field-offset must have type 'offset'") - (with (base addr.operand + (zap absolutize operand) + (while (pos 'deref metadata.operand) + (zap deref operand)) + (assert typeinfo.operand!record "get on non-record @operand") + (with (base v.operand basetype typeinfo.operand idx (v field-offset)) (trace "record-info" "initial base " base " type " canon.basetype) - (when (pos 'deref metadata.operand) - (assert basetype!address "@operand requests deref, but it's not an address of a record") - (= basetype (types* basetype!elem)) - (trace "record-info" operand " requests deref => " canon.basetype)) - (assert basetype!record "get on non-record @operand") (assert (< -1 idx (len basetype!elems)) "@idx is out of bounds of record @operand") - (list (+ base (apply + (map sizeof (firstn idx basetype!elems)))) + (list (apply + base (map sizeof (firstn idx basetype!elems))) basetype!elems.idx))) ; (operand idx) -> (base-addr elem-type) @@ -637,7 +636,7 @@ (unless (< -1 idx array-len.operand) (die "@idx is out of bounds of array @operand")) (let elemtype typeinfo.operand!elem - (list (+ addr.operand + (list (+ v.operand 1 ; for array siz (* idx sizeof.elemtype)) elemtype))) |