diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-03 23:58:06 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-03 23:58:06 -0800 |
commit | c6ef4826d6e6f7cac8108167209a3c65977986a7 (patch) | |
tree | 01b4451d1cae4ba85aa36ed95d57d1eaf0f0ca9e | |
parent | f9dd5af5c0613501c2a38e8a859af1153e985a52 (diff) | |
download | mu-c6ef4826d6e6f7cac8108167209a3c65977986a7.tar.gz |
219
-rw-r--r-- | mu.arc | 9 | ||||
-rw-r--r-- | mu.arc.t | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/mu.arc b/mu.arc index 5a830d35..33622255 100644 --- a/mu.arc +++ b/mu.arc @@ -653,12 +653,15 @@ (each instr instrs (let (oargs op args) (parse-instr instr) (if (in op 'get 'get-address) - (with (fields ((typeinfo args.0) 'fields) + (with (basetype (typeinfo args.0) field (v args.1)) + (when (pos 'deref (metadata args.0)) + (assert basetype!address "@args.0 requests deref, but it's not an address of a record") + (= basetype (types* basetype!elem))) (when (isa field 'sym) (assert (~offset field) "field @args.1 is also a variable") - (assert fields "no field names available for @instr") - (iflet idx (pos field fields) + (assert basetype!fields "no field names available for @instr") + (iflet idx (pos field basetype!fields) (do (set isa-field.field) (= offset.field idx)) (assert nil "couldn't find field in @instr")))) diff --git a/mu.arc.t b/mu.arc.t index 8789e208..c28e1d6c 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1330,6 +1330,13 @@ ((bool boolean) <- copy (t literal))))) (prn "F - convert-names doesn't allow offsets and variables with the same name in a function - 2")) +(reset) +(new-trace "convert-names-record-fields-indirect") +(if (~iso (convert-names + '(((x integer) <- get (34 integer-boolean-pair-address deref) (bool offset)))) + '(((1 integer) <- get (34 integer-boolean-pair-address deref) (1 offset)))) + (prn "F - convert-names replaces field offsets for record addresses")) + ; A rudimentary memory allocator. Eventually we want to write this in mu. ; ; No deallocation yet; let's see how much code we can build in mu before we |