diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/base.lux | 15 | ||||
-rw-r--r-- | new-luxc/source/luxc/generator.lux | 1 | ||||
-rw-r--r-- | new-luxc/source/luxc/module.lux | 3 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/common.lux | 35 |
4 files changed, 21 insertions, 33 deletions
diff --git a/new-luxc/source/luxc/base.lux b/new-luxc/source/luxc/base.lux index 28b5437e9..bac16fd79 100644 --- a/new-luxc/source/luxc/base.lux +++ b/new-luxc/source/luxc/base.lux @@ -145,7 +145,7 @@ (def: fresh-scope Scope - {#;name (list "lux") + {#;name (list) #;inner +0 #;locals fresh-bindings #;captured fresh-bindings}) @@ -166,6 +166,19 @@ (#e;Error error) (#e;Error error)))) +(def: #export (with-current-module name action) + (All [a] (-> Text (Meta a) (Meta a))) + (function [compiler] + (case (action (set@ #;current-module (#;Some name) compiler)) + (#e;Success [compiler' output]) + (#e;Success [(set@ #;current-module + (get@ #;current-module compiler) + compiler') + output]) + + (#e;Error error) + (#e;Error error)))) + (def: #export (with-cursor cursor action) (All [a] (-> Cursor (Meta a) (Meta a))) (if (text/= "" (product;left cursor)) diff --git a/new-luxc/source/luxc/generator.lux b/new-luxc/source/luxc/generator.lux index f64ca333e..4ac937402 100644 --- a/new-luxc/source/luxc/generator.lux +++ b/new-luxc/source/luxc/generator.lux @@ -158,6 +158,7 @@ {#;info init-info #;source [init-cursor +0 ""] #;cursor init-cursor + #;current-module #;None #;modules (list) #;scopes (list) #;type-context init-type-context diff --git a/new-luxc/source/luxc/module.lux b/new-luxc/source/luxc/module.lux index 39d3679e6..2bb7eedcd 100644 --- a/new-luxc/source/luxc/module.lux +++ b/new-luxc/source/luxc/module.lux @@ -56,7 +56,8 @@ (All [a] (-> Nat Text (Meta a) (Meta [Module a]))) (do Monad<Meta> [_ (create hash name) - output (&scope;with-scope name action) + output (&;with-current-module name + (&scope;with-scope name action)) module (meta;find-module name)] (wrap [module output]))) diff --git a/new-luxc/test/test/luxc/common.lux b/new-luxc/test/test/luxc/common.lux index 2e725be5d..5b6fed8ec 100644 --- a/new-luxc/test/test/luxc/common.lux +++ b/new-luxc/test/test/luxc/common.lux @@ -1,36 +1,9 @@ (;module: lux - (lux (control pipe) - ["r" math/random "r/" Monad<Random>] - (data ["R" error]) - [meta] - (meta [code]) - [io]) - (luxc ["&" base] - [analyser] - ["&;" host])) - -(def: init-info - Info - {#;target "JVM" - #;version &;version - #;mode #;Build}) - -(def: init-type-context - Type-Context - {#;ex-counter +0 - #;var-counter +0 - #;var-bindings (list)}) + (lux [io]) + (luxc ["&;" host] + [";G" generator])) (def: #export (init-compiler _) (-> Top Compiler) - {#;info init-info - #;source [dummy-cursor +0 ""] - #;cursor dummy-cursor - #;modules (list) - #;scopes (list) - #;type-context init-type-context - #;expected #;None - #;seed +0 - #;scope-type-vars (list) - #;host (:! Void (io;run &host;init-host))}) + (generatorG;init-compiler (io;run &host;init-host))) |