From d5a85a1ad3dea72e36e39149ee557c19d9860ad5 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 1 Dec 2016 09:50:11 -0400 Subject: Renamed Compiler::envs to 'scopes'. --- src/lux/analyser/env.clj | 34 +++++++++++++++++----------------- src/lux/analyser/lux.clj | 4 ++-- src/lux/analyser/module.clj | 4 ++-- src/lux/base.clj | 24 ++++++++++++------------ 4 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/lux/analyser/env.clj b/src/lux/analyser/env.clj index bea4c8308..75e066e34 100644 --- a/src/lux/analyser/env.clj +++ b/src/lux/analyser/env.clj @@ -12,12 +12,12 @@ ;; [Exports] (def next-local-idx (fn [state] - (return* state (->> state (&/get$ &/$envs) &/|head (&/get$ &/$locals) (&/get$ &/$counter))))) + (return* state (->> state (&/get$ &/$scopes) &/|head (&/get$ &/$locals) (&/get$ &/$counter))))) (defn with-local [name type body] (fn [state] - (let [old-mappings (->> state (&/get$ &/$envs) &/|head (&/get$ &/$locals) (&/get$ &/$mappings)) - =return (body (&/update$ &/$envs + (let [old-mappings (->> state (&/get$ &/$scopes) &/|head (&/get$ &/$locals) (&/get$ &/$mappings)) + =return (body (&/update$ &/$scopes (fn [stack] (let [var-analysis (&&/|meta type &/empty-cursor (&&/$var (&/$Local (->> (&/|head stack) (&/get$ &/$locals) (&/get$ &/$counter)))))] (&/$Cons (&/update$ &/$locals #(->> % @@ -28,12 +28,12 @@ state))] (|case =return (&/$Right ?state ?value) - (return* (&/update$ &/$envs (fn [stack*] - (&/$Cons (&/update$ &/$locals #(->> % - (&/update$ &/$counter dec) - (&/set$ &/$mappings old-mappings)) - (&/|head stack*)) - (&/|tail stack*))) + (return* (&/update$ &/$scopes (fn [stack*] + (&/$Cons (&/update$ &/$locals #(->> % + (&/update$ &/$counter dec) + (&/set$ &/$mappings old-mappings)) + (&/|head stack*)) + (&/|tail stack*))) ?state) ?value) @@ -42,8 +42,8 @@ (defn with-alias [name var-analysis body] (fn [state] - (let [old-mappings (->> state (&/get$ &/$envs) &/|head (&/get$ &/$locals) (&/get$ &/$mappings)) - =return (body (&/update$ &/$envs + (let [old-mappings (->> state (&/get$ &/$scopes) &/|head (&/get$ &/$locals) (&/get$ &/$mappings)) + =return (body (&/update$ &/$scopes (fn [stack] (&/$Cons (&/update$ &/$locals #(->> % (&/update$ &/$mappings (fn [m] (&/|put name var-analysis m)))) @@ -52,11 +52,11 @@ state))] (|case =return (&/$Right ?state ?value) - (return* (&/update$ &/$envs (fn [stack*] - (&/$Cons (&/update$ &/$locals #(->> % - (&/set$ &/$mappings old-mappings)) - (&/|head stack*)) - (&/|tail stack*))) + (return* (&/update$ &/$scopes (fn [stack*] + (&/$Cons (&/update$ &/$locals #(->> % + (&/set$ &/$mappings old-mappings)) + (&/|head stack*)) + (&/|tail stack*))) ?state) ?value) @@ -65,7 +65,7 @@ (def captured-vars (fn [state] - (|case (&/get$ &/$envs state) + (|case (&/get$ &/$scopes state) (&/$Nil) (fail* "[Analyser Error] Can't obtain captured vars without environments.") diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index e907f8aa3..1d46c2b60 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -280,7 +280,7 @@ (defn ^:private analyse-local [analyse exo-type name] (fn [state] - (|let [stack (&/get$ &/$envs state) + (|let [stack (&/get$ &/$scopes state) no-binding? #(and (->> % (&/get$ &/$locals) (&/get$ &/$mappings) (&/|contains? name) not) (->> % (&/get$ &/$closure) (&/get$ &/$mappings) (&/|contains? name) not)) [inner outer] (&/|split-with no-binding? stack)] @@ -313,7 +313,7 @@ (&/|reverse inner) scopes)] ((|do [_ (&type/check exo-type (&&/expr-type* =local))] (return (&/|list =local))) - (&/set$ &/$envs (&/|++ inner* outer) state))) + (&/set$ &/$scopes (&/|++ inner* outer) state))) )))) (defn analyse-symbol [analyse exo-type ident] diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj index 61b11b596..62948bf0d 100644 --- a/src/lux/analyser/module.clj +++ b/src/lux/analyser/module.clj @@ -76,7 +76,7 @@ (fn [state] (when (and (= "Macro" name) (= "lux" module)) (&type/set-macro-type! def-value)) - (|case (&/get$ &/$envs state) + (|case (&/get$ &/$scopes state) (&/$Cons ?env (&/$Nil)) (return* (->> state (&/update$ &/$modules @@ -247,7 +247,7 @@ (fn [state] (return* (->> state (&/update$ &/$modules #(&/|put name (new-module hash) %)) - (&/set$ &/$envs (&/|list (&/env name &/$Nil)))) + (&/set$ &/$scopes (&/|list (&/env name &/$Nil)))) nil))) (do-template [ ] diff --git a/src/lux/base.clj b/src/lux/base.clj index fd8cc2423..5697415f8 100644 --- a/src/lux/base.clj +++ b/src/lux/base.clj @@ -151,7 +151,7 @@ "source" "cursor" "modules" - "envs" + "scopes" "type-vars" "expected" "seed" @@ -787,7 +787,7 @@ (T ["" -1 -1]) ;; "lux;modules" (|table) - ;; "lux;envs" + ;; "lux;scopes" $Nil ;; "lux;types" +init-bindings+ @@ -806,7 +806,7 @@ (|case (body state) ($Right state* output) (return* (->> state* - (set$ $envs (get$ $envs state)) + (set$ $scopes (get$ $scopes state)) (set$ $source (get$ $source state))) output) @@ -855,7 +855,7 @@ (def get-top-local-env (fn [state] - (try (let [top (|head (get$ $envs state))] + (try (let [top (|head (get$ $scopes state))] (return* state top)) (catch Throwable _ ((fail-with-loc "No local environment.") state))))) @@ -885,7 +885,7 @@ (def get-module-name (fn [state] - (|case (|reverse (get$ $envs state)) + (|case (|reverse (get$ $scopes state)) ($Nil) ((fail-with-loc "[Analyser Error] Can't get the module-name without a module.") state) @@ -906,11 +906,11 @@ (defn with-scope [name body] (fn [state] - (let [old-name (->> state (get$ $envs) |head (get$ $name)) - output (body (update$ $envs #($Cons (env name old-name) %) state))] + (let [old-name (->> state (get$ $scopes) |head (get$ $name)) + output (body (update$ $scopes #($Cons (env name old-name) %) state))] (|case output ($Right state* datum) - (return* (update$ $envs |tail state*) datum) + (return* (update$ $scopes |tail state*) datum) _ output)))) @@ -923,7 +923,7 @@ (return (->> top (get$ $inner-closures) str)))] (fn [state] (let [body* (with-scope closure-name body)] - (run-state body* (update$ $envs #($Cons (update$ $inner-closures inc (|head %)) + (run-state body* (update$ $scopes #($Cons (update$ $inner-closures inc (|head %)) (|tail %)) state)))))) @@ -931,11 +931,11 @@ (|do [_mode get-mode] (fn [state] (let [output (body (if (in-repl? _mode) - (update$ $envs |tail state) + (update$ $scopes |tail state) state))] (|case output ($Right state* datum) - (return* (set$ $envs (get$ $envs state) state*) datum) + (return* (set$ $scopes (get$ $scopes state) state*) datum) _ output))))) @@ -955,7 +955,7 @@ (def get-scope-name (fn [state] - (return* state (->> state (get$ $envs) |head (get$ $name))))) + (return* state (->> state (get$ $scopes) |head (get$ $name))))) (defn with-writer [writer body] (fn [state] -- cgit v1.2.3