From c6ef4826d6e6f7cac8108167209a3c65977986a7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 3 Nov 2014 23:58:06 -0800 Subject: 219 --- mu.arc | 9 ++++++--- 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 -- cgit 1.4.1-2-gfad0