diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-08-21 20:08:22 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-08-21 20:08:22 -0700 |
commit | 7b6e5972d6371a7eb6ade62ee868fbe23906df30 (patch) | |
tree | 701ff0b107dceb9900723d5d9f871baad9d1e14c | |
parent | baf61345bfa68d6457a9300e0d3e3aefe5196c30 (diff) | |
download | mu-7b6e5972d6371a7eb6ade62ee868fbe23906df30.tar.gz |
63
-rw-r--r-- | mu.arc | 9 | ||||
-rw-r--r-- | mu.arc.t | 18 |
2 files changed, 21 insertions, 6 deletions
diff --git a/mu.arc b/mu.arc index 4d39ab33..69ad5007 100644 --- a/mu.arc +++ b/mu.arc @@ -19,6 +19,8 @@ integer-boolean-pair (obj size 2 record t elems '(integer boolean)) integer-boolean-pair-address (obj size 1 address t elem 'integer-boolean-pair) integer-boolean-pair-array (obj vector t elem 'integer-boolean-pair) + integer-integer-pair (obj size 2 record t elems '(integer integer)) + integer-point-pair (obj size 2 record t elems '(integer integer-integer-pair)) )) (= memory* (table)) (= function* (table))) @@ -169,9 +171,10 @@ (m `(,v.base integer)) (array-ref base (- idx 1))) ; field index - (memory* (+ v.base - (apply + (map sz - (firstn idx typeinfo.base!elems))))))) + (m `(,(+ v.base + (apply + (map sz + (firstn idx typeinfo.base!elems)))) + ,typeinfo.base!elems.idx)))) reply (do (= result arg) (break)) diff --git a/mu.arc.t b/mu.arc.t index a385164a..a626bcda 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -332,7 +332,7 @@ (run function*!main) ;? (prn memory*) (if (~iso memory* (obj 1 2 2 36 3 2)) - (prn "F - instructions can performs indirect addressing on output arg")) + (prn "F - instructions can perform indirect addressing on output arg")) (reset) (add-fns @@ -349,6 +349,18 @@ (reset) (add-fns '((main + ((1 integer) <- literal 34) + ((2 integer) <- literal 35) + ((3 integer) <- literal 36) + ((4 integer-integer-pair) <- get (1 integer-point-pair) (1 offset))))) +(run function*!main) +;? (prn memory*) +(if (~iso memory* (obj 1 34 2 35 3 36 4 35 5 36)) + (prn "F - 'get' accesses fields spanning multiple locations")) + +(reset) +(add-fns + '((main ((1 integer) <- literal 2) ((2 integer) <- literal 23) ((3 boolean) <- literal nil) @@ -359,7 +371,7 @@ (run function*!main) ;? (prn memory*) (if (~iso memory* (obj 1 2 2 23 3 nil 4 24 5 t 6 2 7 23 8 nil)) - (prn "F - 'get' accesses fields of arrays")) + (prn "F - 'get' accesses fields of arrays, with length at index 0")) ; todo: test that out-of-bounds access throws an error @@ -373,7 +385,7 @@ (run function*!main) ;? (prn memory*) (if (~iso memory* (obj 1 34 2 nil 3 34 4 nil)) - (prn "F - ops can operate on multi-field records")) + (prn "F - ops can operate on records spanning multiple locations")) (reset) (add-fns |