diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-12-27 18:27:54 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-12-27 18:27:54 -0800 |
commit | 38e1f0bd01bae18cd8809a99ee42f46441161c87 (patch) | |
tree | 70fed8c28abbb96e72376ff01ebb050397a7d23f | |
parent | 1f32d0e9cc663d3e0c0f77fcac03451b73ddae6c (diff) | |
download | mu-38e1f0bd01bae18cd8809a99ee42f46441161c87.tar.gz |
451 - start of support for per-routine globals
-rw-r--r-- | mu.arc | 10 | ||||
-rw-r--r-- | mu.arc.t | 23 |
2 files changed, 33 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc index 1cc77d43..f99b5d3a 100644 --- a/mu.arc +++ b/mu.arc @@ -731,6 +731,12 @@ operand (pos '(raw) metadata.operand) operand + (is 'global (alref operand 'space)) + (aif rep.routine*!globals + `((,(+ v.operand it) ,@(cdr operand.0)) + ,@(rem [caris _ 'space] metadata.operand) + (raw)) + (die "routine has no globals: @operand")) :else (iflet base rep.routine*!call-stack.0!default-scope ;? (do (prn 313 " " operand " " base) @@ -742,6 +748,10 @@ ;? ) operand))) +(def space (operand) + (or (alref operand 'space) + 0)) + (def deref (operand) (assert (pos '(deref) metadata.operand)) (assert address?.operand) diff --git a/mu.arc.t b/mu.arc.t index 02c77535..0c40d069 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -3683,6 +3683,16 @@ (a:b <- op c:d e:f) }))) +; space +(prn "== space") +(reset) +(if (~iso 0 (space '((4 integer)))) + (prn "F - 'space' is 0 by default")) +(if (~iso 1 (space '((4 integer) (space 1)))) + (prn "F - 'space' picks up space when available")) +(if (~iso 'global (space '((4 integer) (space global)))) + (prn "F - 'space' understands routine-global space")) + ; absolutize (prn "== absolutize") (reset) @@ -3702,6 +3712,12 @@ (if (~iso '((_ integer)) (absolutize '((_ integer)))) (prn "F - 'absolutize' passes dummy args right through")) +(= memory*.20 5) ; pretend array +(= rep.routine*!globals 20) ; provide it to routine global +(if (~iso '((21 integer) (raw)) + (absolutize '((1 integer) (space global)))) + (prn "F - 'absolutize' handles variables in the global space")) + ; deref (prn "== deref") (reset) @@ -3874,6 +3890,13 @@ (if (~iso (annotate 'record '(2 35 36)) (m '((3 integer-array-address) (deref)))) (prn "F - 'm' supports indirect access to arrays")) +(= routine* make-routine!foo) +(= memory*.10 5) ; fake array +(= memory*.11 34) +(= rep.routine*!globals 10) +(if (~iso 34 (m '((1 integer) (space global)))) + (prn "F - 'm' supports access to per-routine globals")) + ; setm (prn "== setm") (reset) |