From 38e1f0bd01bae18cd8809a99ee42f46441161c87 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 27 Dec 2014 18:27:54 -0800 Subject: 451 - start of support for per-routine globals --- mu.arc | 10 ++++++++++ mu.arc.t | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) 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) -- cgit 1.4.1-2-gfad0