diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 15:51:17 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 15:51:17 -0800 |
commit | 124996992988ecd2c41ce0cbc35470a0b89ed954 (patch) | |
tree | 9412d7f10def0c08b3683ed5382006d96b03c3a7 | |
parent | 571dd7a57aa1c4d162d8f28d2495f802ba630cd1 (diff) | |
download | mu-124996992988ecd2c41ce0cbc35470a0b89ed954.tar.gz |
354 - stepping back, test-driving 'addr' helper again
-rw-r--r-- | mu.arc | 3 | ||||
-rw-r--r-- | mu.arc.t | 27 |
2 files changed, 29 insertions, 1 deletions
diff --git a/mu.arc b/mu.arc index d2486df7..8ff33f5c 100644 --- a/mu.arc +++ b/mu.arc @@ -312,7 +312,8 @@ (trace "addr" loc) (ret result v.loc (trace "addr" "initial result: " result) - (unless (pos 'global metadata.loc) + (unless (or (pos 'global metadata.loc) + (no routine*)) ;? (tr "aa " routine*) (whenlet base rep.routine*!call-stack.0!default-scope (if (< result memory*.base) diff --git a/mu.arc.t b/mu.arc.t index 32cd2f26..564dd1f8 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -705,6 +705,33 @@ (prn "F - 'sizeof' is different from number of elems")) ; Regardless of a type's length, you can move it around just like a primitive. +; Various primitives need to support this. + +; unit tests for 'addr' helper +(reset) +(= routine* nil) +(if (~is 4 (addr '(4 integer))) + (prn "F - directly addressed operands are their own address")) +(if (~is 4 (addr '(4 integer-address))) + (prn "F - directly addressed operands are their own address - 2")) +(if (~is 4 (addr '(4 literal))) + (prn "F - 'addr' doesn't understand literals")) +(= memory*.4 23) +(if (~is 23 (addr '(4 integer-address deref))) + (prn "F - 'addr' works with indirectly-addressed 'deref'")) + +(= routine* make-routine!foo) +(= rep.routine*!call-stack.0!default-scope 10) +(= memory*.10 5) ; bounds check for default-scope +(if (~is 14 (addr '(4 integer))) + (prn "F - directly addressed operands in routines add default-scope")) +(if (~is 14 (addr '(4 integer-address))) + (prn "F - directly addressed operands in routines add default-scope - 2")) +(if (~is 14 (addr '(4 literal))) + (prn "F - 'addr' doesn't understand literals")) +(= memory*.14 23) +(if (~is 23 (addr '(4 integer-address deref))) + (prn "F - 'addr' adds default-scope before 'deref', not after")) (reset) (new-trace "copy-record") |