From 2858b4364758ce42edd99a522b40555dad41d420 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 30 Dec 2014 14:52:58 -0800 Subject: 467 - 'convert-names' now supports space metadata To inform it about space metadata you have to tag environments with the function that generated them. Every function can only ever be called with environments generated by a single function. As an assembly-like language, mu requires closures to be called with an explicit environment, but it warns when the environment might not be what the function expects. --- mu.arc.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'mu.arc.t') diff --git a/mu.arc.t b/mu.arc.t index b6f11a1e..df1a3477 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -2058,6 +2058,38 @@ (2:integer <- increment-counter 1:scope-address) (3:integer <- increment-counter 1:scope-address) ]))) +;? (set dump-trace*) +(run 'main) +(each routine completed-routines* + (aif rep.routine!error (prn "error - " it))) +;? (prn memory*) +(if (or (~is memory*.2 4) + (~is memory*.3 5)) + (prn "F - multiple calls to a function can share locals")) +;? (quit) + +(reset) +(new-trace "default-scope-closure-with-names") +(add-code + '((function init-counter [ + (default-scope:scope-address <- new scope:literal 30:literal) + (x:integer <- copy 23:literal) + (y:integer <- copy 3:literal) ; correct copy of y + (reply default-scope:scope-address) + ]) + (function increment-counter [ + (default-scope:scope-address <- new scope:literal 30:literal) + (0:scope-address/names:init-counter <- next-input) ; outer scope must be created by 'init-counter' above + (y:integer/space:1 <- add y:integer/space:1 1:literal) ; increment + (y:integer <- copy 34:literal) ; dummy + (reply y:integer/space:1) + ]) + (function main [ + (1:scope-address/names:init-counter <- init-counter) + (2:integer <- increment-counter 1:scope-address/names:init-counter) + (3:integer <- increment-counter 1:scope-address/names:init-counter) + ]))) +;? (set dump-trace*) (run 'main) (each routine completed-routines* (aif rep.routine!error (prn "error - " it))) -- cgit 1.4.1-2-gfad0