From 55b73f0ff106c20ccc8496dbe79aba4fb52073f6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 30 Oct 2014 17:39:41 -0700 Subject: 183 - global variables If an operand has metadata 'global', it isn't offset off default-scope. --- mu.arc | 9 +++++---- mu.arc.t | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mu.arc b/mu.arc index df6aff2a..723925c6 100644 --- a/mu.arc +++ b/mu.arc @@ -150,10 +150,11 @@ (def addr (loc) (ret result v.loc - (whenlet base rep.routine*!default-scope - (if (< result memory*.base) - (++ result base) - (die "addr: no room for var @result"))) + (unless (pos 'global metadata.loc) + (whenlet base rep.routine*!default-scope + (if (< result memory*.base) + (++ result base) + (die "addr: no room for var @result")))) (when (pos 'deref metadata.loc) (zap memory* result)))) diff --git a/mu.arc.t b/mu.arc.t index 6e8a0ad7..57e806d9 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1443,4 +1443,18 @@ ((default-scope integer) <- add (1 integer) (2 integer)))) (prn "F - convert-names never renames default-scope")) +(reset) +(new-trace "suppress-default-scope") +(add-fns + '((main + ((default-scope scope-address) <- new (scope literal) (2 literal)) + ((1 integer global) <- copy (23 literal))))) +(let before Memory-in-use-until +;? (set dump-trace*) + (run 'main) +;? (prn memory*) + (if (~and (is 23 memory*.1) + (~is 23 (memory* (+ before 1)))) + (prn "F - default-scope skipped for locations with metadata 'global'"))) + (reset) ; end file with this to persist the trace for the final test -- cgit 1.4.1-2-gfad0