diff options
author | Eduardo Julian | 2017-10-26 21:41:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-26 21:41:41 -0400 |
commit | 3439602c2b356eaef3359b6496a0237f1af55e33 (patch) | |
tree | 90c3c1d0f97fc30b1a991de50977d8a075564724 /luxc | |
parent | e2621632653ad1252744eecff6da143faaf90787 (diff) |
- Added a new piece of compiler state, just for storing the current-module.
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/analyser/module.clj | 3 | ||||
-rw-r--r-- | luxc/src/lux/base.clj | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj index 8c5a2d286..c8a263030 100644 --- a/luxc/src/lux/analyser/module.clj +++ b/luxc/src/lux/analyser/module.clj @@ -279,7 +279,8 @@ (fn [state] (return* (->> state (&/update$ &/$modules #(&/|put name (new-module hash) %)) - (&/set$ &/$scopes (&/|list (&/env name &/$Nil)))) + (&/set$ &/$scopes (&/|list (&/env name &/$Nil))) + (&/set$ &/$current-module (&/$Some name))) nil))) (do-template [<name> <tag> <type>] diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 3bf0eaf08..910bdfadf 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -151,6 +151,7 @@ ["info" "source" "cursor" + "current-module" "modules" "scopes" "type-context" @@ -819,6 +820,8 @@ $Nil ;; "lux;cursor" (T ["" -1 -1]) + ;; "current-module" + $None ;; "lux;modules" (|table) ;; "lux;scopes" @@ -910,13 +913,13 @@ (def get-module-name (fn [state] - (|case (|reverse (get$ $scopes state)) - ($Nil) + (|case (get$ $current-module state) + ($None) ((fail-with-loc "[Analyser Error] Cannot get the module-name without a module.") state) - ($Cons ?global _) - (return* state (|head (get$ $name ?global)))))) + ($Some module-name) + (return* state module-name)))) (defn find-module [name] "(-> Text (Lux (Module Compiler)))" |