aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2015-02-10 17:24:59 -0400
committerEduardo Julian2015-02-10 17:24:59 -0400
commitc53ff39359ba62b21ba6b2c9ecb0f80d8b15b438 (patch)
tree8ad3e4ed956c7f155f2d1d85b33aa292c38faa6d
parent5ee1163e99d97bca272aad32c34d662b2c27ec37 (diff)
Super refactoring that breaks the system: Part 3
## Good-bye let-expressions...
-rw-r--r--src/lux/analyser.clj20
-rw-r--r--src/lux/compiler.clj16
2 files changed, 2 insertions, 34 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index f2e589646..3183c7166 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -62,14 +62,10 @@
(defn ^:private with-env [label body]
(fn [state]
- (let [=return (body (-> state
- (update-in [::&util/local-envs] conj (fresh-env label))
- (update-in [::&util/scope] conj label)))]
+ (let [=return (body (update-in state [::&util/local-envs] conj (fresh-env label)))]
(match =return
[::&util/ok [?state ?value]]
- [::&util/ok [(-> ?state
- (update-in [::&util/local-envs] rest)
- (update-in [::&util/scope] rest))
+ [::&util/ok [(update-in ?state [::&util/local-envs] rest)
?value]]
_
@@ -504,15 +500,6 @@
(return (->decision-tree $base =branches)))]
(return (list [::Expression [::case $base =variant num-registers mappings tree] +dont-care-type+]))))
-(defn ^:private analyse-let [analyse-ast ?label ?value ?body]
- (exec [=value (analyse-1 ?value)
- =value-type (expr-type =value)
- idx next-local-idx
- =body (with-let ?label :local =value-type
- (analyse-1 ?body))
- =body-type (expr-type =body)]
- (return (list [::Expression [::let idx =value =body] =body-type]))))
-
(defn ^:private raise-tree-bindings [raise-expr arg ?tree]
(let [tree-partial-f (partial raise-tree-bindings raise-expr arg)]
(case (:type ?tree)
@@ -871,9 +858,6 @@
[::&parser/ident ?ident]
(analyse-ident analyse-ast ?ident)
- [::&parser/form ([[::&parser/ident "let'"] [::&parser/ident ?label] ?value ?body] :seq)]
- (analyse-let analyse-ast ?label ?value ?body)
-
[::&parser/form ([[::&parser/ident "case'"] ?variant & ?branches] :seq)]
(analyse-case analyse-ast ?variant ?branches)
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index daf2f1e09..1ff3a503e 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -600,19 +600,6 @@
:let [_ (.visitLabel *writer* end-label)]]
(return nil))))
-(defn ^:private compile-let [compile *type* ?idx ?value ?body]
- (exec [*writer* &util/get-writer
- _ (compile ?value)
- :let [start-label (new Label)
- end-label (new Label)
- _ (doto *writer*
- (.visitLocalVariable (str +local-prefix+ ?idx) (->java-sig (:type ?value)) nil start-label end-label ?idx)
- (.visitLabel start-label)
- (.visitVarInsn Opcodes/ASTORE ?idx))]
- _ (compile ?body)
- :let [_ (.visitLabel *writer* end-label)]]
- (return nil)))
-
(let [clo-field-sig (->type-signature "java.lang.Object")
lambda-return-sig (->type-signature "java.lang.Object")
<init>-return "V"
@@ -957,9 +944,6 @@
[::&analyser/variant ?tag ?members]
(compile-variant compile-expression (:type syntax) ?tag ?members)
- [::&analyser/let ?idx ?value ?body]
- (compile-let compile-expression (:type syntax) ?idx ?value ?body)
-
[::&analyser/case ?base-idx ?variant ?max-registers ?branch-mappings ?decision-tree]
(compile-case compile-expression (:type syntax) ?base-idx ?variant ?max-registers ?branch-mappings ?decision-tree)