diff options
author | Eduardo Julian | 2017-05-01 00:07:09 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-01 00:07:09 -0400 |
commit | 94cca1d49c0d3f6d328a81eaf6ce9660a6f149c1 (patch) | |
tree | ae87be56f16bba552c2a50c69125db725347b4b4 /luxc/src | |
parent | f77acc12df0076c65122385846caf46e75b575de (diff) |
- Changed the way Scope works, to make it independent from the notion of Analysis, and make it easier to port to the new re-written compiler.
- Fixed a type-bug when asserting whether a def is being re-defined.
Diffstat (limited to 'luxc/src')
-rw-r--r-- | luxc/src/lux/analyser/env.clj | 16 | ||||
-rw-r--r-- | luxc/src/lux/analyser/function.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/analyser/lux.clj | 6 |
3 files changed, 16 insertions, 8 deletions
diff --git a/luxc/src/lux/analyser/env.clj b/luxc/src/lux/analyser/env.clj index 6f6e9f986..a6be49f98 100644 --- a/luxc/src/lux/analyser/env.clj +++ b/luxc/src/lux/analyser/env.clj @@ -1,7 +1,7 @@ (ns lux.analyser.env (:require clojure.core.match clojure.core.match.array - (lux [base :as & :refer [|do return return* |case]]) + (lux [base :as & :refer [|do return return* |case |let]]) [lux.analyser.base :as &&])) ;; [Exports] @@ -17,7 +17,7 @@ (let [var-analysis (&&/|meta type &/empty-cursor (&&/$var (&/$Local (->> (&/|head stack) (&/get$ &/$locals) (&/get$ &/$counter)))))] (&/$Cons (&/update$ &/$locals #(->> % (&/update$ &/$counter inc) - (&/update$ &/$mappings (fn [m] (&/|put name var-analysis m)))) + (&/update$ &/$mappings (fn [m] (&/|put name (&/T [type var-analysis]) m)))) (&/|head stack)) (&/|tail stack)))) state))] @@ -41,7 +41,10 @@ =return (body (&/update$ &/$scopes (fn [stack] (&/$Cons (&/update$ &/$locals #(->> % - (&/update$ &/$mappings (fn [m] (&/|put name var-analysis m)))) + (&/update$ &/$mappings (fn [m] (&/|put name + (&/T [(&&/expr-type* var-analysis) + var-analysis]) + m)))) (&/|head stack)) (&/|tail stack))) state))] @@ -66,5 +69,10 @@ state) (&/$Cons env _) - (return* state (->> env (&/get$ &/$captured) (&/get$ &/$mappings)))) + (return* state (->> env + (&/get$ &/$captured) + (&/get$ &/$mappings) + (&/|map (fn [mapping] + (|let [[k v] mapping] + (&/T [k (&/|second v)]))))))) )) diff --git a/luxc/src/lux/analyser/function.clj b/luxc/src/lux/analyser/function.clj index 7d199ba30..68f5e89fe 100644 --- a/luxc/src/lux/analyser/function.clj +++ b/luxc/src/lux/analyser/function.clj @@ -24,5 +24,5 @@ register])))] (&/T [register* (&/update$ &/$captured #(->> % (&/update$ &/$counter inc) - (&/update$ &/$mappings (fn [mps] (&/|put name register* mps)))) + (&/update$ &/$mappings (fn [mps] (&/|put name (&/T [register-type register*]) mps)))) frame)]))) diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index 6649628c7..95dc9af59 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -291,8 +291,8 @@ (|let [[register new-inner] register+new-inner [register* frame*] (&&function/close-over in-scope name register frame)] (&/T [register* (&/$Cons frame* new-inner)]))) - (&/T [(or (->> bottom-outer (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name)) - (->> bottom-outer (&/get$ &/$captured) (&/get$ &/$mappings) (&/|get name))) + (&/T [(&/|second (or (->> bottom-outer (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name)) + (->> bottom-outer (&/get$ &/$captured) (&/get$ &/$mappings) (&/|get name)))) &/$Nil]) (&/|reverse inner) scopes)] ((|do [_ (&type/check exo-type (&&/expr-type* =local))] @@ -538,7 +538,7 @@ module-name &/get-module-name ? (&&module/defined? module-name ?name) _ (&/assert! (not ?) - (&/fail-with-loc (str "[Analyser Error] Cannot re-define " (str module-name ";" ?name)))) + (str "[Analyser Error] Cannot re-define " (str module-name ";" ?name))) =value (&/without-repl-closure (&/with-scope ?name (&&/analyse-1+ analyse ?value))) |