From 057295d1521d4af54cf9ec97f1503f6ee5f010be Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 1 May 2016 12:52:09 -0400 Subject: - Simplified the language by eliminating coercion and macro-declaration from the analysis type. --- src/lux/analyser.clj | 2 +- src/lux/analyser/base.clj | 2 -- src/lux/analyser/lux.clj | 16 ++++++++++------ src/lux/compiler.clj | 3 --- src/lux/compiler/lux.clj | 3 --- src/lux/optimizer.clj | 8 -------- 6 files changed, 11 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj index 3256f6902..23cf19061 100644 --- a/src/lux/analyser.clj +++ b/src/lux/analyser.clj @@ -256,7 +256,7 @@ (&/$Cons ?type (&/$Cons ?value (&/$Nil))))) - (&&lux/analyse-check analyse eval! exo-type ?type ?value) + (&&lux/analyse-ann analyse eval! exo-type ?type ?value) (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_lux_:!")] (&/$Cons ?type diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj index c76274e76..933af3301 100644 --- a/src/lux/analyser/base.clj +++ b/src/lux/analyser/base.clj @@ -22,9 +22,7 @@ ("case" 2) ("lambda" 3) ("ann" 3) - ("coerce" 3) ("def" 3) - ("declare-macro" 1) ("var" 1) ("captured" 1) ("host" 2) diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index c0aefed35..9813e5497 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -578,22 +578,26 @@ _ (&&module/alias module-name ex-alias ex-module)] (return &/$Nil))) -(defn analyse-check [analyse eval! exo-type ?type ?value] +(defn analyse-ann [analyse eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) ==type (eval! =type) _ (&type/check exo-type ==type) =value (&&/analyse-1 analyse ==type ?value) _cursor &/cursor] + ;; (analyse ==type ?value) (return (&/|list (&&/|meta ==type _cursor (&&/$ann =value =type ==type) ))))) +(defn ^:private coerce [new-type analysis] + "(-> Type Analysis Analysis)" + (|let [[[_type _cursor] _analysis] analysis] + (&&/|meta new-type _cursor + _analysis))) + (defn analyse-coerce [analyse eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) ==type (eval! =type) _ (&type/check exo-type ==type) - =value (&&/analyse-1+ analyse ?value) - _cursor &/cursor] - (return (&/|list (&&/|meta ==type _cursor - (&&/$coerce =value =type ==type) - ))))) + =value (&&/analyse-1+ analyse ?value)] + (return (&/|list (coerce ==type =value))))) diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj index e42f58f3f..2752d4f42 100644 --- a/src/lux/compiler.clj +++ b/src/lux/compiler.clj @@ -91,9 +91,6 @@ (&o/$ann ?value-ex ?type-ex ?value-type) (&&lux/compile-ann compile-expression ?value-ex ?type-ex ?value-type) - (&o/$coerce ?value-ex ?type-ex ?value-type) - (&&lux/compile-coerce compile-expression ?value-ex ?type-ex ?value-type) - (&o/$host [?proc-category ?proc-name] ?args) (&&host/compile-host compile-expression ?proc-category ?proc-name ?args) diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index 3b0ae5b29..ae6c2cdf5 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -237,6 +237,3 @@ (defn compile-ann [compile ?value-ex ?type-ex ?value-type] (compile ?value-ex)) - -(defn compile-coerce [compile ?value-ex ?type-ex ?value-type] - (compile ?value-ex)) diff --git a/src/lux/optimizer.clj b/src/lux/optimizer.clj index 09faa73fb..044a89ed6 100644 --- a/src/lux/optimizer.clj +++ b/src/lux/optimizer.clj @@ -21,9 +21,7 @@ ("case" 1) ("lambda" 1) ("ann" 1) - ("coerce" 1) ("def" 1) - ("declare-macro" 1) ("var" 1) ("captured" 1) ("host" 2) @@ -86,15 +84,9 @@ (&-base/$ann value) (return ($ann value)) - (&-base/$coerce value) - (return ($coerce value)) - (&-base/$def value) (return ($def value)) - (&-base/$declare-macro value) - (return ($declare-macro value)) - (&-base/$var value) (return ($var value)) -- cgit v1.2.3