diff options
Diffstat (limited to '')
-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)] |