diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-12-30 14:52:58 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-12-30 14:52:58 -0800 |
commit | 2858b4364758ce42edd99a522b40555dad41d420 (patch) | |
tree | 6163866c700caadba3d43ced54f2dcd939ad7be7 /mu.arc.t | |
parent | 92d239247f1bbc6a93602daf9b854a2b5c0c9623 (diff) | |
download | mu-2858b4364758ce42edd99a522b40555dad41d420.tar.gz |
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.
Diffstat (limited to 'mu.arc.t')
-rw-r--r-- | mu.arc.t | 32 |
1 files changed, 32 insertions, 0 deletions
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))) |