diff options
author | Eduardo Julian | 2015-04-26 12:00:23 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-04-26 12:00:23 -0400 |
commit | 50d36ed6fb12545c429f981ae4b382dc0913697d (patch) | |
tree | 5fc1d96538f57d5673fe8820776e5ccaa163223f | |
parent | 411543f0c331bdfa23dc11988a326ba4a9c44a20 (diff) |
Made a small change in regards to how global defs are resolved.
-rw-r--r-- | src/lux/analyser.clj | 1 | ||||
-rw-r--r-- | src/lux/analyser/def.clj | 2 | ||||
-rw-r--r-- | src/lux/analyser/lux.clj | 17 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj index 2704f77ce..6976f47f0 100644 --- a/src/lux/analyser.clj +++ b/src/lux/analyser.clj @@ -442,6 +442,7 @@ [_] (do ;; (prn 'analyse-ast/token (aget token 0) (&/show-state state)) + ;; (prn 'NOT_A_FUNCTION (&/show-ast ?fn)) ((analyse-basic-ast (partial analyse-ast eval!) eval! exo-type token) state)))) [_] diff --git a/src/lux/analyser/def.clj b/src/lux/analyser/def.clj index 779afb683..c44a7ea36 100644 --- a/src/lux/analyser/def.clj +++ b/src/lux/analyser/def.clj @@ -44,7 +44,7 @@ ms))) (&/set$ &/$ENVS (&/|list (&/update$ &/$LOCALS (fn [locals] (&/update$ &/$MAPPINGS (fn [mappings] - (&/|put full-name bound mappings)) + (&/|put (str "" &/+name-separator+ name) bound mappings)) locals)) ?env)))) nil) diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index 3bba07b39..c9244a91e 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -115,16 +115,23 @@ global-ident (str (if (= "" ?module) module-name ?module) ";" ?name) stack (&/get$ &/$ENVS state) no-binding? #(and (->> % (&/get$ &/$LOCALS) (&/get$ &/$MAPPINGS) (&/|contains? local-ident) not) - (->> % (&/get$ &/$CLOSURE) (&/get$ &/$MAPPINGS) (&/|contains? local-ident) not) - (->> % (&/get$ &/$LOCALS) (&/get$ &/$MAPPINGS) (&/|contains? global-ident) not) - (->> % (&/get$ &/$CLOSURE) (&/get$ &/$MAPPINGS) (&/|contains? global-ident) not)) + (->> % (&/get$ &/$CLOSURE) (&/get$ &/$MAPPINGS) (&/|contains? local-ident) not)) [inner outer] (&/|split-with no-binding? stack)] (matchv ::M/objects [outer] [["lux;Nil" _]] - (fail* (str "[Analyser Error] Unrecognized identifier: " local-ident)) + (if-let [module-env (->> state + (&/get$ &/$MODULES) + (&/|get (if (= "" ?module) module-name ?module)))] + (if-let [def-type (do ;; (->> module-env (&/get$ &&def/$DEFS) &/|keys &/->seq (prn 'module-env global-ident)) + (->> module-env (&/get$ &&def/$DEFS) (&/|get global-ident)))] + (do ;; (prn 'GOT_DEF-TYPE global-ident) + (return* state (&/|list (&/V "Expression" (&/T (&/V "global" (&/T (if (= "" ?module) module-name ?module) ?name)) + def-type))))) + (fail* (str "[Analyser Error] Unknown module: " (if (= "" ?module) module-name ?module)))) + (fail* (str "[Analyser Error] Unrecognized identifier: " local-ident))) [["lux;Cons" [?genv ["lux;Nil" _]]]] - (if-let [global (->> ?genv (&/get$ &/$LOCALS) (&/get$ &/$MAPPINGS) (&/|get global-ident))] + (if-let [global (->> ?genv (&/get$ &/$LOCALS) (&/get$ &/$MAPPINGS) (&/|get local-ident))] (&/run-state (type-test exo-type global) ;; (|do [btype (&&/expr-type global) ;; _ (&type/check exo-type btype)] |