aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser
diff options
context:
space:
mode:
authorEduardo Julian2016-01-05 22:22:54 -0400
committerEduardo Julian2016-01-05 22:22:54 -0400
commit3855f395e7cdd8e49086f2d0d82ed231e8896b69 (patch)
tree173c7b9f3aa5c8f86a44210074634da11b5b9a40 /src/lux/analyser
parentc52036b75a692a0def3fedb7f175134d8dfb0f5b (diff)
- Optimized the new "product" implementation to improve performance & memory consumption.
Diffstat (limited to 'src/lux/analyser')
-rw-r--r--src/lux/analyser/base.clj6
-rw-r--r--src/lux/analyser/case.clj92
-rw-r--r--src/lux/analyser/host.clj114
-rw-r--r--src/lux/analyser/lambda.clj16
-rw-r--r--src/lux/analyser/lux.clj30
-rw-r--r--src/lux/analyser/meta.clj8
-rw-r--r--src/lux/analyser/module.clj48
-rw-r--r--src/lux/analyser/parser.clj34
-rw-r--r--src/lux/analyser/record.clj8
9 files changed, 180 insertions, 176 deletions
diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj
index bbbe18a89..5149456aa 100644
--- a/src/lux/analyser/base.clj
+++ b/src/lux/analyser/base.clj
@@ -176,14 +176,14 @@
(|do [=expr (analyse-1 analyse $var ?token)
:let [[[?type ?cursor] ?item] =expr]
=type (&type/clean $var ?type)]
- (return (&/T (&/T =type ?cursor) ?item))))))
+ (return (&/T [(&/T [=type ?cursor]) ?item]))))))
(defn resolved-ident [ident]
(|do [:let [[?module ?name] ident]
module* (if (.equals "" ?module)
&/get-module-name
(return ?module))]
- (return (&/T module* ?name))))
+ (return (&/T [module* ?name]))))
(let [tag-names #{"DataT" "VoidT" "UnitT" "SumT" "ProdT" "LambdaT" "BoundT" "VarT" "ExT" "UnivQ" "ExQ" "AppT" "NamedT"}]
(defn type-tag? [module name]
@@ -191,4 +191,4 @@
(contains? tag-names name))))
(defn |meta [type cursor analysis]
- (&/T (&/T type cursor) analysis))
+ (&/T [(&/T [type cursor]) analysis]))
diff --git a/src/lux/analyser/case.clj b/src/lux/analyser/case.clj
index 517a58ab7..85d4dbb1a 100644
--- a/src/lux/analyser/case.clj
+++ b/src/lux/analyser/case.clj
@@ -39,7 +39,7 @@
;; [Utils]
(def ^:private unit
- (&/T (&/T "" -1 -1) (&/V &/$TupleS &/Nil$)))
+ (&/T [(&/T ["" -1 -1]) (&/V &/$TupleS &/Nil$)]))
(defn ^:private resolve-type [type]
(|case type
@@ -58,7 +58,7 @@
(defn update-up-frame [frame]
(|let [[_env _idx _var] frame]
- (&/T _env (+ 2 _idx) _var)))
+ (&/T [_env (+ 2 _idx) _var])))
(defn adjust-type* [up type]
"(-> (List (, (Maybe (List Type)) Int Type)) Type (Lux Type))"
@@ -67,7 +67,7 @@
(&type/with-var
(fn [$var]
(|do [=type (&type/apply-type type $var)]
- (adjust-type* (&/Cons$ (&/T _aenv 1 $var) (&/|map update-up-frame up)) =type))))
+ (adjust-type* (&/Cons$ (&/T [_aenv 1 $var]) (&/|map update-up-frame up)) =type))))
(&/$ExQ _aenv _abody)
(|do [$var &type/existential
@@ -84,7 +84,7 @@
:let [distributor (fn [v]
(&/fold (fn [_abody ena]
(|let [[_aenv _aidx _avar] ena]
- (&/V &/$UnivQ (&/T _aenv _abody))))
+ (&/V &/$UnivQ (&/T [_aenv _abody]))))
v
up))]]
(return (&type/Prod$ (distributor =left) (distributor =right))))
@@ -99,7 +99,7 @@
:let [distributor (fn [v]
(&/fold (fn [_abody ena]
(|let [[_aenv _aidx _avar] ena]
- (&/V &/$UnivQ (&/T _aenv _abody))))
+ (&/V &/$UnivQ (&/T [_aenv _abody]))))
v
up))]]
(return (&type/Sum$ (distributor =left) (distributor =right))))
@@ -135,13 +135,13 @@
(&/$Some var-analysis)
(|do [=kont (&env/with-alias name var-analysis
kont)]
- (return (&/T (&/V $StoreTestAC -1) =kont)))
+ (return (&/T [(&/V $StoreTestAC -1) =kont])))
_
(|do [=kont (&env/with-local name value-type
kont)
idx &env/next-local-idx]
- (return (&/T (&/V $StoreTestAC idx) =kont))))
+ (return (&/T [(&/V $StoreTestAC idx) =kont]))))
(&/$SymbolS ident)
(fail (str "[Pattern-matching Error] Symbols must be unqualified: " (&/ident->text ident)))
@@ -149,34 +149,34 @@
(&/$BoolS ?value)
(|do [_ (&type/check value-type &type/Bool)
=kont kont]
- (return (&/T (&/V $BoolTestAC ?value) =kont)))
+ (return (&/T [(&/V $BoolTestAC ?value) =kont])))
(&/$IntS ?value)
(|do [_ (&type/check value-type &type/Int)
=kont kont]
- (return (&/T (&/V $IntTestAC ?value) =kont)))
+ (return (&/T [(&/V $IntTestAC ?value) =kont])))
(&/$RealS ?value)
(|do [_ (&type/check value-type &type/Real)
=kont kont]
- (return (&/T (&/V $RealTestAC ?value) =kont)))
+ (return (&/T [(&/V $RealTestAC ?value) =kont])))
(&/$CharS ?value)
(|do [_ (&type/check value-type &type/Char)
=kont kont]
- (return (&/T (&/V $CharTestAC ?value) =kont)))
+ (return (&/T [(&/V $CharTestAC ?value) =kont])))
(&/$TextS ?value)
(|do [_ (&type/check value-type &type/Text)
=kont kont]
- (return (&/T (&/V $TextTestAC ?value) =kont)))
+ (return (&/T [(&/V $TextTestAC ?value) =kont])))
(&/$TupleS ?members)
(|case ?members
(&/$Nil)
(|do [_ (&type/check value-type &type/Unit)
=kont kont]
- (return (&/T (&/V $TupleTestAC (&/|list)) =kont)))
+ (return (&/T [(&/V $TupleTestAC (&/|list)) =kont])))
(&/$Cons ?member (&/$Nil))
(analyse-pattern var?? value-type ?member kont)
@@ -193,18 +193,18 @@
(|do [[=tests =kont] (&/fold (fn [kont* vm]
(|let [[v m] vm]
(|do [[=test [=tests =kont]] (analyse-pattern &/None$ v m kont*)]
- (return (&/T (&/Cons$ =test =tests) =kont)))))
+ (return (&/T [(&/Cons$ =test =tests) =kont])))))
(|do [=kont kont]
- (return (&/T &/Nil$ =kont)))
+ (return (&/T [&/Nil$ =kont])))
(&/|reverse (&/zip2 ?member-types* ?members)))]
- (return (&/T (&/V $TupleTestAC =tests) =kont))))
+ (return (&/T [(&/V $TupleTestAC =tests) =kont]))))
_
(fail (str "[Pattern-matching Error] Tuples require tuple-types: " (&type/show-type value-type))))))
(&/$RecordS pairs)
(|do [[rec-members rec-type] (&&record/order-record pairs)]
- (analyse-pattern &/None$ value-type (&/T meta (&/V &/$TupleS rec-members)) kont))
+ (analyse-pattern &/None$ value-type (&/T [meta (&/V &/$TupleS rec-members)]) kont))
(&/$TagS ?ident)
(|do [[=module =name] (&&/resolved-ident ?ident)
@@ -213,7 +213,7 @@
group (&module/tag-group =module =name)
case-type (&type/sum-at idx value-type*)
[=test =kont] (analyse-pattern &/None$ case-type unit kont)]
- (return (&/T (&/V $VariantTestAC (&/T idx (&/|length group) =test)) =kont)))
+ (return (&/T [(&/V $VariantTestAC (&/T [idx (&/|length group) =test])) =kont])))
(&/$FormS (&/$Cons [_ (&/$TagS ?ident)]
?values))
@@ -226,8 +226,8 @@
0 (analyse-pattern &/None$ case-type unit kont)
1 (analyse-pattern &/None$ case-type (&/|head ?values) kont)
;; 1+
- (analyse-pattern &/None$ case-type (&/T (&/T "" -1 -1) (&/V &/$TupleS ?values)) kont))]
- (return (&/T (&/V $VariantTestAC (&/T idx (&/|length group) =test)) =kont)))
+ (analyse-pattern &/None$ case-type (&/T [(&/T ["" -1 -1]) (&/V &/$TupleS ?values)]) kont))]
+ (return (&/T [(&/V $VariantTestAC (&/T [idx (&/|length group) =test])) =kont])))
_
(fail (str "[Pattern-matching Error] Unrecognized pattern syntax: " (&/show-ast pattern)))
@@ -245,80 +245,80 @@
(return (&/V $DefaultTotal true))
[($BoolTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $BoolTotal (&/T true ?values)))
+ (return (&/V $BoolTotal (&/T [true ?values])))
[($IntTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $IntTotal (&/T true ?values)))
+ (return (&/V $IntTotal (&/T [true ?values])))
[($RealTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $RealTotal (&/T true ?values)))
+ (return (&/V $RealTotal (&/T [true ?values])))
[($CharTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $CharTotal (&/T true ?values)))
+ (return (&/V $CharTotal (&/T [true ?values])))
[($TextTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $TextTotal (&/T true ?values)))
+ (return (&/V $TextTotal (&/T [true ?values])))
[($TupleTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $TupleTotal (&/T true ?values)))
+ (return (&/V $TupleTotal (&/T [true ?values])))
[($VariantTotal total? ?values) ($StoreTestAC ?idx)]
- (return (&/V $VariantTotal (&/T true ?values)))
+ (return (&/V $VariantTotal (&/T [true ?values])))
[($DefaultTotal total?) ($BoolTestAC ?value)]
- (return (&/V $BoolTotal (&/T total? (&/|list ?value))))
+ (return (&/V $BoolTotal (&/T [total? (&/|list ?value)])))
[($BoolTotal total? ?values) ($BoolTestAC ?value)]
- (return (&/V $BoolTotal (&/T total? (&/Cons$ ?value ?values))))
+ (return (&/V $BoolTotal (&/T [total? (&/Cons$ ?value ?values)])))
[($DefaultTotal total?) ($IntTestAC ?value)]
- (return (&/V $IntTotal (&/T total? (&/|list ?value))))
+ (return (&/V $IntTotal (&/T [total? (&/|list ?value)])))
[($IntTotal total? ?values) ($IntTestAC ?value)]
- (return (&/V $IntTotal (&/T total? (&/Cons$ ?value ?values))))
+ (return (&/V $IntTotal (&/T [total? (&/Cons$ ?value ?values)])))
[($DefaultTotal total?) ($RealTestAC ?value)]
- (return (&/V $RealTotal (&/T total? (&/|list ?value))))
+ (return (&/V $RealTotal (&/T [total? (&/|list ?value)])))
[($RealTotal total? ?values) ($RealTestAC ?value)]
- (return (&/V $RealTotal (&/T total? (&/Cons$ ?value ?values))))
+ (return (&/V $RealTotal (&/T [total? (&/Cons$ ?value ?values)])))
[($DefaultTotal total?) ($CharTestAC ?value)]
- (return (&/V $CharTotal (&/T total? (&/|list ?value))))
+ (return (&/V $CharTotal (&/T [total? (&/|list ?value)])))
[($CharTotal total? ?values) ($CharTestAC ?value)]
- (return (&/V $CharTotal (&/T total? (&/Cons$ ?value ?values))))
+ (return (&/V $CharTotal (&/T [total? (&/Cons$ ?value ?values)])))
[($DefaultTotal total?) ($TextTestAC ?value)]
- (return (&/V $TextTotal (&/T total? (&/|list ?value))))
+ (return (&/V $TextTotal (&/T [total? (&/|list ?value)])))
[($TextTotal total? ?values) ($TextTestAC ?value)]
- (return (&/V $TextTotal (&/T total? (&/Cons$ ?value ?values))))
+ (return (&/V $TextTotal (&/T [total? (&/Cons$ ?value ?values)])))
[($DefaultTotal total?) ($TupleTestAC ?tests)]
(|do [structs (&/map% (fn [t]
- (merge-total (&/V $DefaultTotal total?) (&/T t ?body)))
+ (merge-total (&/V $DefaultTotal total?) (&/T [t ?body])))
?tests)]
- (return (&/V $TupleTotal (&/T total? structs))))
+ (return (&/V $TupleTotal (&/T [total? structs]))))
[($TupleTotal total? ?values) ($TupleTestAC ?tests)]
(if (.equals ^Object (&/|length ?values) (&/|length ?tests))
(|do [structs (&/map2% (fn [v t]
- (merge-total v (&/T t ?body)))
+ (merge-total v (&/T [t ?body])))
?values ?tests)]
- (return (&/V $TupleTotal (&/T total? structs))))
+ (return (&/V $TupleTotal (&/T [total? structs]))))
(fail "[Pattern-matching Error] Inconsistent tuple-size."))
[($DefaultTotal total?) ($VariantTestAC ?tag ?count ?test)]
(|do [sub-struct (merge-total (&/V $DefaultTotal total?)
- (&/T ?test ?body))
+ (&/T [?test ?body]))
structs (|case (&/|list-put ?tag sub-struct (&/|repeat ?count (&/V $DefaultTotal total?)))
(&/$Some list)
(return list)
(&/$None)
(fail "[Pattern-matching Error] YOLO"))]
- (return (&/V $VariantTotal (&/T total? structs))))
+ (return (&/V $VariantTotal (&/T [total? structs]))))
[($VariantTotal total? ?branches) ($VariantTestAC ?tag ?count ?test)]
(|do [sub-struct (merge-total (|case (&/|at ?tag ?branches)
@@ -327,14 +327,14 @@
(&/$None)
(&/V $DefaultTotal total?))
- (&/T ?test ?body))
+ (&/T [?test ?body]))
structs (|case (&/|list-put ?tag sub-struct ?branches)
(&/$Some list)
(return list)
(&/$None)
(fail "[Pattern-matching Error] YOLO"))]
- (return (&/V $VariantTotal (&/T total? structs))))
+ (return (&/V $VariantTotal (&/T [total? structs]))))
)))
(defn check-totality+ [check-totality]
@@ -344,7 +344,7 @@
(|do [=output (check-totality $var ?token)
?type (&type/deref+ $var)
=type (&type/clean $var ?type)]
- (return (&/T =output =type)))))))
+ (return (&/T [=output =type])))))))
(defn ^:private check-totality [value-type struct]
(|case struct
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 25f7852dc..86e73723d 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -51,8 +51,8 @@
(&/V &/$Left msg)
(&/$Right state** output)
- (&/V &/$Right (&/T (->> state** (&/update$ &/$host #(&/set$ &/$catching old-catches %)))
- output))))
+ (&/V &/$Right (&/T [(->> state** (&/update$ &/$host #(&/set$ &/$catching old-catches %)))
+ output]))))
))
(defn ^:private ensure-object [type]
@@ -114,15 +114,15 @@
(|do [? (&type/bound? id)]
(if ?
(|do [real-type (&type/deref id)]
- (return (&/T idx real-type)))
- (return (&/T (+ 2 idx) (&type/Bound$ idx)))))))
+ (return (&/T [idx real-type])))
+ (return (&/T [(+ 2 idx) (&type/Bound$ idx)]))))))
(defn ^:private clean-gtype-vars [gtype-vars]
(|do [[_ clean-types] (&/fold% (fn [idx+types gtype-var]
(|do [:let [[idx types] idx+types]
[idx* real-type] (clean-gtype-var idx gtype-var)]
- (return (&/T idx* (&/Cons$ real-type types)))))
- (&/T 1 (&/|list))
+ (return (&/T [idx* (&/Cons$ real-type types)]))))
+ (&/T [1 (&/|list)])
gtype-vars)]
(return clean-types)))
@@ -148,7 +148,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta output-type _cursor
- (&/V <output-tag> (&/T =x =y))))))))
+ (&/V <output-tag> (&/T [=x =y]))))))))
analyse-jvm-iadd &&/$jvm-iadd "java.lang.Integer" "java.lang.Integer"
analyse-jvm-isub &&/$jvm-isub "java.lang.Integer" "java.lang.Integer"
@@ -196,7 +196,7 @@
(|case obj-type
(&/$DataT class targs)
(if (= (&/|length targs) (&/|length gvars))
- (|let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/Cons$ (&/T (.getName g) t) m))
+ (|let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/Cons$ (&/T [(.getName g) t]) m))
(&/|table)
gvars
targs)]
@@ -214,7 +214,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-getstatic (&/T class field output-type)))))))
+ (&/V &&/$jvm-getstatic (&/T [class field output-type])))))))
(defn analyse-jvm-getfield [analyse exo-type class field object]
(|do [class-loader &/loader
@@ -226,7 +226,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-getfield (&/T class field =object output-type)))))))
+ (&/V &&/$jvm-getfield (&/T [class field =object output-type])))))))
(defn analyse-jvm-putstatic [analyse exo-type class field value]
(|do [class-loader &/loader
@@ -238,7 +238,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-putstatic (&/T class field =value gclass =type)))))))
+ (&/V &&/$jvm-putstatic (&/T [class field =value gclass =type])))))))
(defn analyse-jvm-putfield [analyse exo-type class field value object]
(|do [class-loader &/loader
@@ -253,7 +253,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-putfield (&/T class field =value gclass =object =type)))))))
+ (&/V &&/$jvm-putfield (&/T [class field =value gclass =object =type])))))))
(defn analyse-jvm-instanceof [analyse exo-type class object]
(|do [=object (&&/analyse-1+ analyse object)
@@ -262,7 +262,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta output-type _cursor
- (&/V &&/$jvm-instanceof (&/T class =object)))))))
+ (&/V &&/$jvm-instanceof (&/T [class =object])))))))
(defn ^:private analyse-method-call-helper [analyse gret gtype-env gtype-vars gtype-args args]
(|case gtype-vars
@@ -270,12 +270,12 @@
(|do [arg-types (&/map% (partial &host-type/instance-param &type/existential gtype-env) gtype-args)
=args (&/map2% (partial &&/analyse-1 analyse) arg-types args)
=gret (&host-type/instance-param &type/existential gtype-env gret)]
- (return (&/T =gret =args)))
+ (return (&/T [=gret =args])))
(&/$Cons ^TypeVariable gtv gtype-vars*)
(&type/with-var
(fn [$var]
- (|let [gtype-env* (&/Cons$ (&/T (.getName gtv) $var) gtype-env)]
+ (|let [gtype-env* (&/Cons$ (&/T [(.getName gtv) $var]) gtype-env)]
(analyse-method-call-helper analyse gret gtype-env* gtype-vars* gtype-args args))))
))
@@ -291,13 +291,13 @@
(catch Exception e
(fail (str "[Analyser Error] Unknown class: " class))))
[gret exceptions parent-gvars gvars gargs] (if (= "<init>" method)
- (return (&/T Void/TYPE &/Nil$ &/Nil$ &/Nil$ &/Nil$))
+ (return (&/T [Void/TYPE &/Nil$ &/Nil$ &/Nil$ &/Nil$]))
(&host/lookup-virtual-method class-loader class method classes))
_ (ensure-catching exceptions)
=object (&&/analyse-1+ analyse object)
[sub-class sub-params] (ensure-object (&&/expr-type* =object))
(&/$DataT super-class* super-params*) (&host-type/->super-type &type/existential class-loader class sub-class sub-params)
- :let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/Cons$ (&/T (.getName g) t) m))
+ :let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/Cons$ (&/T [(.getName g) t]) m))
(&/|table)
parent-gvars
super-params*)]
@@ -305,7 +305,7 @@
_ (&type/check exo-type (as-otype+ output-type))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V <tag> (&/T class method classes =object =args output-type)))))))
+ (&/V <tag> (&/T [class method classes =object =args output-type])))))))
analyse-jvm-invokevirtual &&/$jvm-invokevirtual false
analyse-jvm-invokespecial &&/$jvm-invokespecial false
@@ -318,14 +318,14 @@
_ (ensure-catching exceptions)
gtype-env (&/fold% (fn [m ^TypeVariable g]
(|do [=var-type &type/existential]
- (return (&/Cons$ (&/T (.getName g) =var-type) m))))
+ (return (&/Cons$ (&/T [(.getName g) =var-type]) m))))
(&/|table)
parent-gvars)
[output-type =args] (analyse-method-call-helper analyse gret gtype-env gvars gargs args)
_ (&type/check exo-type (as-otype+ output-type))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-invokestatic (&/T class method classes =args output-type)))))))
+ (&/V &&/$jvm-invokestatic (&/T [class method classes =args output-type])))))))
(defn analyse-jvm-null? [analyse exo-type object]
(|do [=object (&&/analyse-1+ analyse object)
@@ -349,13 +349,13 @@
(|do [arg-types (&/map% (partial &host-type/instance-param &type/existential gtype-env) gtype-args)
=args (&/map2% (partial &&/analyse-1 analyse) arg-types args)
gtype-vars* (->> gtype-env (&/|map &/|second) (clean-gtype-vars))]
- (return (&/T (make-gtype gtype gtype-vars*)
- =args)))
+ (return (&/T [(make-gtype gtype gtype-vars*)
+ =args])))
(&/$Cons ^TypeVariable gtv gtype-vars*)
(&type/with-var
(fn [$var]
- (|let [gtype-env* (&/Cons$ (&/T (.getName gtv) $var) gtype-env)]
+ (|let [gtype-env* (&/Cons$ (&/T [(.getName gtv) $var]) gtype-env)]
(analyse-jvm-new-helper analyse gtype gtype-env* gtype-vars* gtype-args args))))
))
@@ -367,7 +367,7 @@
_ (&type/check exo-type output-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-new (&/T class classes =args)))))))
+ (&/V &&/$jvm-new (&/T [class classes =args])))))))
(let [length-type &type/Int
idx-type &type/Int]
@@ -387,7 +387,7 @@
_ (&type/check exo-type elem-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V <load-tag> (&/T =array =idx)))))))
+ (&/V <load-tag> (&/T [=array =idx])))))))
(defn <store-name> [analyse exo-type array idx elem]
(|do [=array (&&/analyse-1 analyse array-type array)
@@ -396,7 +396,7 @@
_ (&type/check exo-type array-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V <store-tag> (&/T =array =idx =elem)))))))
+ (&/V <store-tag> (&/T [=array =idx =elem])))))))
)
"java.lang.Boolean" analyse-jvm-znewarray &&/$jvm-znewarray analyse-jvm-zaload &&/$jvm-zaload analyse-jvm-zastore &&/$jvm-zastore
@@ -419,7 +419,7 @@
_ (&type/check exo-type array-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-anewarray (&/T gclass =length gtype-env)))))))
+ (&/V &&/$jvm-anewarray (&/T [gclass =length gtype-env])))))))
(defn analyse-jvm-aaload [analyse exo-type array idx]
(|do [=array (&&/analyse-1+ analyse array)
@@ -430,7 +430,7 @@
_ (&type/check exo-type inner-arr-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-aaload (&/T =array =idx)))))))
+ (&/V &&/$jvm-aaload (&/T [=array =idx])))))))
(defn analyse-jvm-aastore [analyse exo-type array idx elem]
(|do [=array (&&/analyse-1+ analyse array)
@@ -443,7 +443,7 @@
_ (&type/check exo-type array-type)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-aastore (&/T =array =idx =elem))))))))
+ (&/V &&/$jvm-aastore (&/T [=array =idx =elem]))))))))
(defn analyse-jvm-arraylength [analyse exo-type array]
(|do [=array (&&/analyse-1+ analyse array)
@@ -553,19 +553,19 @@
(&/map% (fn [var+gtype]
(|do [:let [[var gtype] var+gtype]
=gtype (generic-class->type class-env gtype)]
- (return (&/T var =gtype))))
+ (return (&/T [var =gtype]))))
vars+gtypes)
)))
(defn ^:private analyse-method [analyse class-decl class-env all-supers method]
"(-> Analyser ClassDecl (List (, TypeVar Type)) (List SuperClassDecl) MethodSyntax (Lux MethodAnalysis))"
(|let [[?cname ?cparams] class-decl
- class-type (&/V &/$DataT (&/T ?cname (&/|map &/|second class-env)))]
+ class-type (&/V &/$DataT (&/T [?cname (&/|map &/|second class-env)]))]
(|case method
(&/$ConstructorMethodSyntax ?anns ?gvars ?exceptions ?inputs ?ctor-args ?body)
(|do [method-env (&/map% (fn [gvar]
(|do [ex &type/existential]
- (return (&/T gvar ex))))
+ (return (&/T [gvar ex]))))
?gvars)
:let [full-env (&/|++ class-env method-env)]
:let [output-type &type/Unit]
@@ -573,7 +573,7 @@
(|do [:let [[ca-type ca-term] ctor-arg]
=ca-type (generic-class->type full-env ca-type)
=ca-term (&&/analyse-1 analyse =ca-type ca-term)]
- (return (&/T ca-type =ca-term))))
+ (return (&/T [ca-type =ca-term]))))
?ctor-args)
=body (&/with-type-env full-env
(&&env/with-local &&/jvm-this class-type
@@ -584,12 +584,12 @@
body*)))
(&&/analyse-1 analyse output-type ?body)
(&/|reverse ?inputs))))]
- (return (&/V &/$ConstructorMethodAnalysis (&/T ?anns ?gvars ?exceptions ?inputs =ctor-args =body))))
+ (return (&/V &/$ConstructorMethodAnalysis (&/T [?anns ?gvars ?exceptions ?inputs =ctor-args =body]))))
(&/$VirtualMethodSyntax ?name ?anns ?gvars ?exceptions ?inputs ?output ?body)
(|do [method-env (&/map% (fn [gvar]
(|do [ex &type/existential]
- (return (&/T gvar ex))))
+ (return (&/T [gvar ex]))))
?gvars)
:let [full-env (&/|++ class-env method-env)]
output-type (generic-class->type full-env ?output)
@@ -602,13 +602,13 @@
body*)))
(&&/analyse-1 analyse output-type ?body)
(&/|reverse ?inputs))))]
- (return (&/V &/$VirtualMethodAnalysis (&/T ?name ?anns ?gvars ?exceptions ?inputs ?output =body))))
+ (return (&/V &/$VirtualMethodAnalysis (&/T [?name ?anns ?gvars ?exceptions ?inputs ?output =body]))))
(&/$OverridenMethodSyntax ?class-decl ?name ?anns ?gvars ?exceptions ?inputs ?output ?body)
(|do [super-env (gen-super-env class-env all-supers ?class-decl)
method-env (&/map% (fn [gvar]
(|do [ex &type/existential]
- (return (&/T gvar ex))))
+ (return (&/T [gvar ex]))))
?gvars)
:let [full-env (&/|++ super-env method-env)]
output-type (generic-class->type full-env ?output)
@@ -621,7 +621,7 @@
body*)))
(&&/analyse-1 analyse output-type ?body)
(&/|reverse ?inputs))))]
- (return (&/V &/$OverridenMethodAnalysis (&/T ?class-decl ?name ?anns ?gvars ?exceptions ?inputs ?output =body))))
+ (return (&/V &/$OverridenMethodAnalysis (&/T [?class-decl ?name ?anns ?gvars ?exceptions ?inputs ?output =body]))))
)))
(defn ^:private mandatory-methods [supers]
@@ -673,18 +673,18 @@
all-supers (&/Cons$ super-class interfaces)]
class-env (&/map% (fn [gvar]
(|do [ex &type/existential]
- (return (&/T gvar ex))))
+ (return (&/T [gvar ex]))))
?params)
_ (&host/use-dummy-class class-decl super-class interfaces &/None$ =fields methods)
=methods (&/map% (partial analyse-method analyse class-decl class-env all-supers) methods)
_ (check-method-completion all-supers =methods)
- _ (compile-token (&/V &&/$jvm-class (&/T class-decl super-class interfaces =anns =fields =methods (&/|list) &/None$)))
+ _ (compile-token (&/V &&/$jvm-class (&/T [class-decl super-class interfaces =anns =fields =methods (&/|list) &/None$])))
:let [_ (println 'DEF full-name)]]
(return &/Nil$))))
(defn analyse-jvm-interface [analyse compile-token interface-decl supers =anns =methods]
(|do [module &/get-module-name
- _ (compile-token (&/V &&/$jvm-interface (&/T interface-decl supers =anns =methods)))
+ _ (compile-token (&/V &&/$jvm-interface (&/T [interface-decl supers =anns =methods])))
:let [_ (println 'DEF (str module "." (&/|first interface-decl)))]]
(return &/Nil$)))
@@ -693,26 +693,26 @@
[name [_ (&&/$captured _ _ source)]]
source))
-(let [default-<init> (&/V &/$ConstructorMethodSyntax (&/T (&/|list)
- (&/|list)
- (&/|list)
- (&/|list)
- (&/|list)
- (&/V &/$TupleS (&/|list))))
+(let [default-<init> (&/V &/$ConstructorMethodSyntax (&/T [(&/|list)
+ (&/|list)
+ (&/|list)
+ (&/|list)
+ (&/|list)
+ (&/V &/$TupleS (&/|list))]))
captured-slot-class "java.lang.Object"
- captured-slot-type (&/V &/$GenericClass (&/T captured-slot-class (&/|list)))]
+ captured-slot-type (&/V &/$GenericClass (&/T [captured-slot-class (&/|list)]))]
(defn analyse-jvm-anon-class [analyse compile-token exo-type super-class interfaces ctor-args methods]
(&/with-closure
(|do [module &/get-module-name
scope &/get-scope-name
:let [name (&host/location (&/|tail scope))
- class-decl (&/T name (&/|list))
+ class-decl (&/T [name (&/|list)])
anon-class (str module "." name)
anon-class-type (&type/Data$ anon-class (&/|list))]
=ctor-args (&/map% (fn [ctor-arg]
(|let [[arg-type arg-term] ctor-arg]
(|do [=arg-term (&&/analyse-1+ analyse arg-term)]
- (return (&/T arg-type =arg-term)))))
+ (return (&/T [arg-type =arg-term])))))
ctor-args)
_ (->> methods
(&/Cons$ default-<init>)
@@ -724,15 +724,15 @@
=captured &&env/captured-vars
:let [=fields (&/|map (fn [^objects idx+capt]
(|let [[idx _] idx+capt]
- (&/T (str &c!base/closure-prefix idx)
- (&/|list)
- captured-slot-type)))
+ (&/T [(str &c!base/closure-prefix idx)
+ (&/|list)
+ captured-slot-type])))
(&/enumerate =captured))]
:let [sources (&/|map captured-source =captured)]
- _ (compile-token (&/V &&/$jvm-class (&/T class-decl super-class interfaces (&/|list) =fields =methods =captured (&/Some$ =ctor-args))))
+ _ (compile-token (&/V &&/$jvm-class (&/T [class-decl super-class interfaces (&/|list) =fields =methods =captured (&/Some$ =ctor-args)])))
_cursor &/cursor]
(return (&/|list (&&/|meta anon-class-type _cursor
- (&/V &&/$jvm-new (&/T anon-class (&/|repeat (&/|length sources) captured-slot-class) sources))
+ (&/V &&/$jvm-new (&/T [anon-class (&/|repeat (&/|length sources) captured-slot-class) sources]))
)))
))))
@@ -743,7 +743,7 @@
=catch-body (&&env/with-local ?ex-arg (&type/Data$ ?ex-class &/Nil$)
(&&/analyse-1 analyse exo-type ?catch-body))
idx &&env/next-local-idx]
- (return (&/T ?ex-class idx =catch-body))))
+ (return (&/T [?ex-class idx =catch-body]))))
?catches)
:let [catched-exceptions (&/|map (fn [=catch]
(|let [[_c-class _ _] =catch]
@@ -757,7 +757,7 @@
(return (&/V &/$Some =finally))))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$jvm-try (&/T =body =catches =finally)))))))
+ (&/V &&/$jvm-try (&/T [=body =catches =finally])))))))
(defn analyse-jvm-throw [analyse exo-type ?ex]
(|do [=ex (&&/analyse-1 analyse (&type/Data$ "java.lang.Throwable" &/Nil$) ?ex)
diff --git a/src/lux/analyser/lambda.clj b/src/lux/analyser/lambda.clj
index bbb5d2dc7..8d94d4ab6 100644
--- a/src/lux/analyser/lambda.clj
+++ b/src/lux/analyser/lambda.clj
@@ -19,15 +19,15 @@
(&env/with-local arg arg-type
(|do [=return body
=captured &env/captured-vars]
- (return (&/T scope-name =captured =return))))))))
+ (return (&/T [scope-name =captured =return]))))))))
(defn close-over [scope name register frame]
(|let [[[register-type register-cursor] _] register
register* (&&/|meta register-type register-cursor
- (&/V &&/$captured (&/T scope
- (->> frame (&/get$ &/$closure) (&/get$ &/$counter))
- register)))]
- (&/T register* (&/update$ &/$closure #(->> %
- (&/update$ &/$counter inc)
- (&/update$ &/$mappings (fn [mps] (&/|put name register* mps))))
- frame))))
+ (&/V &&/$captured (&/T [scope
+ (->> frame (&/get$ &/$closure) (&/get$ &/$counter))
+ register])))]
+ (&/T [register* (&/update$ &/$closure #(->> %
+ (&/update$ &/$counter inc)
+ (&/update$ &/$mappings (fn [mps] (&/|put name register* mps))))
+ frame)])))
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index 4bfe10873..68e329af2 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -212,7 +212,7 @@
" " (->> ?values (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))))))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$variant (&/T idx =value))
+ (&/V &&/$variant (&/T [idx =value]))
))))
(&/$UnivQ _)
@@ -262,7 +262,7 @@
(&type/check exo-type endo-type))
_cursor &/cursor]
(return (&/|list (&&/|meta endo-type _cursor
- (&/V &&/$var (&/V &/$Global (&/T r-module r-name)))
+ (&/V &&/$var (&/V &/$Global (&/T [r-module r-name])))
)))))
(defn ^:private analyse-local [analyse exo-type name]
@@ -295,10 +295,10 @@
[=local inner*] (&/fold2 (fn [register+new-inner frame in-scope]
(|let [[register new-inner] register+new-inner
[register* frame*] (&&lambda/close-over (&/|reverse in-scope) name register frame)]
- (&/T register* (&/Cons$ frame* new-inner))))
- (&/T (or (->> top-outer (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name))
- (->> top-outer (&/get$ &/$closure) (&/get$ &/$mappings) (&/|get name)))
- &/Nil$)
+ (&/T [register* (&/Cons$ frame* new-inner)])))
+ (&/T [(or (->> top-outer (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name))
+ (->> top-outer (&/get$ &/$closure) (&/get$ &/$mappings) (&/|get name)))
+ &/Nil$])
(&/|reverse inner) scopes)]
((|do [_ (&type/check exo-type (&&/expr-type* =local))]
(return (&/|list =local)))
@@ -316,7 +316,7 @@
(|case ?args
(&/$Nil)
(|do [_ (&type/check exo-type fun-type)]
- (return (&/T fun-type &/Nil$)))
+ (return (&/T [fun-type &/Nil$])))
(&/$Cons ?arg ?args*)
(|do [?fun-type* (&type/actual-type fun-type)]
@@ -334,7 +334,7 @@
(&type/clean $var =output-t)
(|do [_ (&type/set-var ?id (&/V &/$BoundT 1))]
(&type/clean $var =output-t)))]
- (return (&/T type** =args)))
+ (return (&/T [type** =args])))
))))
(&/$ExQ _)
@@ -348,7 +348,7 @@
(&&/analyse-1 analyse ?input-t ?arg)
(fn [err]
(fail (str err "\n" "[Analyser Error] Function expected: " (&type/show-type ?input-t)))))]
- (return (&/T =output-t (&/Cons$ =arg =args))))
+ (return (&/T [=output-t (&/Cons$ =arg =args)])))
_
(fail (str "[Analyser Error] Can't apply a non-function: " (&type/show-type ?fun-type*))))
@@ -360,7 +360,7 @@
(|do [:let [[[=fn-type =fn-cursor] =fn-form] =fn]
[=output-t =args] (analyse-apply* analyse exo-type =fn-type ?args)]
(return (&/|list (&&/|meta =output-t =fn-cursor
- (&/V &&/$apply (&/T =fn =args))
+ (&/V &&/$apply (&/T [=fn =args]))
)))))
(defn analyse-apply [analyse exo-type =fn ?args]
@@ -404,7 +404,7 @@
=match (&&case/analyse-branches analyse exo-type var?? (&&/expr-type* =value) (&/|as-pairs ?branches))
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
- (&/V &&/$case (&/T =value =match))
+ (&/V &&/$case (&/T [=value =match]))
)))))
(defn analyse-lambda* [analyse exo-type ?self ?arg ?body]
@@ -460,7 +460,7 @@
(&&/analyse-1 analyse ?return-t ?body))
_cursor &/cursor]
(return (&&/|meta exo-type* _cursor
- (&/V &&/$lambda (&/T =scope =captured =body)))))
+ (&/V &&/$lambda (&/T [=scope =captured =body])))))
@@ -507,7 +507,7 @@
==meta (eval! =meta)
_ (&&module/test-type module-name ?name ==meta (&&/expr-type* =value))
_ (&&module/test-macro module-name ?name ==meta (&&/expr-type* =value))
- _ (compile-token (&/V &&/$def (&/T ?name =value ==meta)))]
+ _ (compile-token (&/V &&/$def (&/T [?name =value ==meta])))]
(return &/Nil$))
)))
@@ -538,7 +538,7 @@
=value (&&/analyse-1 analyse ==type ?value)
_cursor &/cursor]
(return (&/|list (&&/|meta ==type _cursor
- (&/V &&/$ann (&/T =value =type ==type))
+ (&/V &&/$ann (&/T [=value =type ==type]))
)))))
(defn analyse-coerce [analyse eval! exo-type ?type ?value]
@@ -548,5 +548,5 @@
=value (&&/analyse-1+ analyse ?value)
_cursor &/cursor]
(return (&/|list (&&/|meta ==type _cursor
- (&/V &&/$coerce (&/T =value =type ==type))
+ (&/V &&/$coerce (&/T [=value =type ==type]))
)))))
diff --git a/src/lux/analyser/meta.clj b/src/lux/analyser/meta.clj
index fb75003e8..185391678 100644
--- a/src/lux/analyser/meta.clj
+++ b/src/lux/analyser/meta.clj
@@ -28,10 +28,14 @@
(meta-get ident dict*))
(&/$Nil)
- &/None$))
+ &/None$
+
+ _
+ (assert false (prn-str (&/adt->text ident)
+ (&/adt->text dict)))))
(do-template [<name> <tag-name>]
- (def <name> (&/T tag-prefix <tag-name>))
+ (def <name> (&/T [tag-prefix <tag-name>]))
type?-tag "type?"
alias-tag "alias"
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 158fd7487..16c020670 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -24,17 +24,17 @@
"types"])
(def ^:private +init+
- (&/T ;; "lux;module-aliases"
- (&/|table)
- ;; "lux;defs"
- (&/|table)
- ;; "lux;imports"
- &/Nil$
- ;; "lux;tags"
- (&/|table)
- ;; "lux;types"
- (&/|table)
- ))
+ (&/T [;; "lux;module-aliases"
+ (&/|table)
+ ;; "lux;defs"
+ (&/|table)
+ ;; "lux;imports"
+ &/Nil$
+ ;; "lux;tags"
+ (&/|table)
+ ;; "lux;types"
+ (&/|table)]
+ ))
;; [Exports]
(defn add-import [module]
@@ -73,7 +73,7 @@
(&/|update module
(fn [m]
(&/update$ $defs
- #(&/|put name (&/T def-type def-meta def-value) %)
+ #(&/|put name (&/T [def-type def-meta def-value]) %)
m))
ms))))
nil)
@@ -102,8 +102,8 @@
(return* state ?value)
_
- (fail* (str "[Analyser Error] Not a type: " (&/ident->text (&/T module name))))))
- (fail* (str "[Analyser Error] Unknown definition: " (&/ident->text (&/T module name)))))
+ (fail* (str "[Analyser Error] Not a type: " (&/ident->text (&/T [module name]))))))
+ (fail* (str "[Analyser Error] Unknown definition: " (&/ident->text (&/T [module name])))))
(fail* (str "[Analyser Error] Unknown module: " module)))))
(defn exists? [name]
@@ -147,10 +147,10 @@
state)
_
- (return* state (&/T (&/T module name) $def)))
+ (return* state (&/T [(&/T [module name]) $def])))
(|case (&meta/meta-get &meta/export?-tag ?meta)
(&/$Some (&/$BoolM true))
- (return* state (&/T (&/T module name) $def))
+ (return* state (&/T [(&/T [module name]) $def]))
_
(fail* (str "[Analyser Error] Can't use unexported definition: " (str module &/+name-separator+ name))))))
@@ -207,7 +207,7 @@
(|do [tags-table (tags-by-module module)
_ (&/map% (fn [tag]
(if (&/|get tag tags-table)
- (fail (str "[Analyser Error] Can't re-declare tag: " (&/ident->text (&/T module tag))))
+ (fail (str "[Analyser Error] Can't re-declare tag: " (&/ident->text (&/T [module tag]))))
(return nil)))
tags)]
(return nil)))
@@ -215,7 +215,7 @@
(defn ensure-undeclared-type [module name]
(|do [types-table (types-by-module module)
_ (&/assert! (nil? (&/|get name types-table))
- (str "[Analyser Error] Can't re-declare type: " (&/ident->text (&/T module name))))]
+ (str "[Analyser Error] Can't re-declare type: " (&/ident->text (&/T [module name]))))]
(return nil)))
(defn declare-tags [module tag-names type]
@@ -228,17 +228,17 @@
_ (ensure-undeclared-type _module _name)]
(fn [state]
(if-let [=module (->> state (&/get$ &/$modules) (&/|get module))]
- (let [tags (&/|map (fn [tag-name] (&/T module tag-name)) tag-names)]
+ (let [tags (&/|map (fn [tag-name] (&/T [module tag-name])) tag-names)]
(return* (&/update$ &/$modules
(fn [=modules]
(&/|update module
#(->> %
(&/set$ $tags (&/fold (fn [table idx+tag-name]
(|let [[idx tag-name] idx+tag-name]
- (&/|put tag-name (&/T idx tags type) table)))
+ (&/|put tag-name (&/T [idx tags type]) table)))
(&/get$ $tags %)
(&/enumerate tag-names)))
- (&/update$ $types (partial &/|put _name (&/T tags type))))
+ (&/update$ $types (partial &/|put _name (&/T [tags type]))))
=modules))
state)
nil))
@@ -252,7 +252,7 @@
(if-let [^objects idx+tags+type (&/|get tag-name (&/get$ $tags =module))]
(|let [[?idx ?tags ?type] idx+tags+type]
(return* state <part>))
- (fail* (str "[Module Error] Unknown tag: " (&/ident->text (&/T module tag-name)))))
+ (fail* (str "[Module Error] Unknown tag: " (&/ident->text (&/T [module tag-name])))))
(fail* (str "[Module Error] Unknown module: " module)))))
tag-index ?idx "(-> Text Text (Lux Int))"
@@ -269,10 +269,10 @@
(|let [[k [?def-type ?def-meta ?def-value]] kv]
(|case (&meta/meta-get &meta/alias-tag ?def-meta)
(&/$Some (&/$IdentM [?r-module ?r-name]))
- (&/T k (str ?r-module ";" ?r-name))
+ (&/T [k (str ?r-module ";" ?r-name)])
_
- (&/T k "")
+ (&/T [k ""])
)))))))))
(do-template [<name> <type> <tag> <desc>]
diff --git a/src/lux/analyser/parser.clj b/src/lux/analyser/parser.clj
index 8a843dc59..611d65a83 100644
--- a/src/lux/analyser/parser.clj
+++ b/src/lux/analyser/parser.clj
@@ -30,7 +30,7 @@
(|case ast
[_ (&/$FormS (&/$Cons [_ (&/$TextS class-name)] (&/$Cons [_ (&/$TupleS args)] (&/$Nil))))]
(|do [=args (&/map% parse-text args)]
- (return (&/T class-name =args)))
+ (return (&/T [class-name =args])))
_
(fail (str "[Analyser Error] Not generic class declaration: " (&/show-ast ast)))))
@@ -45,7 +45,7 @@
[_ (&/$FormS (&/$Cons [_ (&/$TextS class-name)] (&/$Cons [_ (&/$TupleS params)] (&/$Nil))))]
(|do [=params (&/map% parse-gclass params)]
- (return (&/V &/$GenericClass (&/T class-name =params))))
+ (return (&/V &/$GenericClass (&/T [class-name =params]))))
[_ (&/$FormS (&/$Cons [_ (&/$TextS "Array")] (&/$Cons param (&/$Nil))))]
(|do [=param (parse-gclass param)]
@@ -58,7 +58,7 @@
(|case ast
[_ (&/$FormS (&/$Cons [_ (&/$TextS class-name)] (&/$Cons [_ (&/$TupleS params)] (&/$Nil))))]
(|do [=params (&/map% parse-gclass params)]
- (return (&/T class-name =params)))
+ (return (&/T [class-name =params])))
_
(fail (str "[Analyser Error] Not generic super-class: " (&/show-ast ast)))))
@@ -67,7 +67,7 @@
(|case ast
[_ (&/$TupleS (&/$Cons ?class (&/$Cons ?term (&/$Nil))))]
(|do [=class (parse-gclass ?class)]
- (return (&/T =class ?term)))
+ (return (&/T [=class ?term])))
_
(fail (str "[Analyser Error] Not constructor argument: " (&/show-ast ast)))))
@@ -80,12 +80,12 @@
(&/$Cons [_ (&/$SymbolS "" ?ex-arg)]
(&/$Cons ?catch-body
(&/$Nil))))))]
- (return (&/T (&/|++ catch+ (&/|list (&/T ?ex-class ?ex-arg ?catch-body))) finally+))
+ (return (&/T [(&/|++ catch+ (&/|list (&/T [?ex-class ?ex-arg ?catch-body]))) finally+]))
[meta (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_finally")]
(&/$Cons ?finally-body
(&/$Nil))))]
- (return (&/T catch+ (&/V &/$Some ?finally-body)))
+ (return (&/T [catch+ (&/V &/$Some ?finally-body)]))
_
(fail (str "[Analyser Error] Wrong syntax for exception handler: " (&/show-ast token))))))
@@ -95,11 +95,11 @@
(|case param
[[_ (&/$TextS param-name)] param-value]
(|case param-value
- [_ (&/$BoolS param-value*)] (return (&/T param-name (boolean param-value*)))
- [_ (&/$IntS param-value*)] (return (&/T param-name (int param-value*)))
- [_ (&/$RealS param-value*)] (return (&/T param-name (float param-value*)))
- [_ (&/$CharS param-value*)] (return (&/T param-name (char param-value*)))
- [_ (&/$TextS param-value*)] (return (&/T param-name param-value*))
+ [_ (&/$BoolS param-value*)] (return (&/T [param-name (boolean param-value*)]))
+ [_ (&/$IntS param-value*)] (return (&/T [param-name (int param-value*)]))
+ [_ (&/$RealS param-value*)] (return (&/T [param-name (float param-value*)]))
+ [_ (&/$CharS param-value*)] (return (&/T [param-name (char param-value*)]))
+ [_ (&/$TextS param-value*)] (return (&/T [param-name param-value*]))
_
failure)
@@ -123,7 +123,7 @@
(&/$Cons gclass
(&/$Nil))))]
(|do [=gclass (parse-gclass gclass)]
- (return (&/T arg-name =gclass)))
+ (return (&/T [arg-name =gclass])))
_
(fail (str "[Analyser Error] Invalid argument declaration: " (&/show-ast ast)))))
@@ -141,7 +141,7 @@
=exceptions (&/map% parse-gclass exceptions)
=inputs (&/map% parse-gclass inputs)
=output (parse-gclass output)]
- (return (&/T method-name =anns =gvars =exceptions =inputs =output)))
+ (return (&/T [method-name =anns =gvars =exceptions =inputs =output])))
_
(fail (str "[Analyser Error] Invalid method declaration: " (&/show-ast ast)))))
@@ -160,7 +160,7 @@
=exceptions (&/map% parse-gclass exceptions)
=inputs (&/map% parse-arg-decl inputs)
=ctor-args (&/map% parse-ctor-arg ?ctor-args)]
- (return (&/V &/$ConstructorMethodSyntax (&/T =anns =gvars =exceptions =inputs =ctor-args body))))
+ (return (&/V &/$ConstructorMethodSyntax (&/T [=anns =gvars =exceptions =inputs =ctor-args body]))))
_
(fail "")))
@@ -180,7 +180,7 @@
=exceptions (&/map% parse-gclass exceptions)
=inputs (&/map% parse-arg-decl inputs)
=output (parse-gclass output)]
- (return (&/V &/$VirtualMethodSyntax (&/T ?name =anns =gvars =exceptions =inputs =output body))))
+ (return (&/V &/$VirtualMethodSyntax (&/T [?name =anns =gvars =exceptions =inputs =output body]))))
_
(fail "")))
@@ -203,7 +203,7 @@
=exceptions (&/map% parse-gclass exceptions)
=inputs (&/map% parse-arg-decl inputs)
=output (parse-gclass output)]
- (return (&/V &/$OverridenMethodSyntax (&/T =class-decl =name =anns =gvars =exceptions =inputs =output body))))
+ (return (&/V &/$OverridenMethodSyntax (&/T [=class-decl =name =anns =gvars =exceptions =inputs =output body]))))
_
(fail "")))
@@ -223,7 +223,7 @@
(&/$Nil)))))]
(|do [=anns (&/map% parse-ann ?anns)
=type (parse-gclass ?type)]
- (return (&/T ?name =anns =type)))
+ (return (&/T [?name =anns =type])))
_
(fail (str "[Analyser Error] Invalid field declaration: " (&/show-ast ast)))))
diff --git a/src/lux/analyser/record.clj b/src/lux/analyser/record.clj
index ddc9616fd..67cc78c0c 100644
--- a/src/lux/analyser/record.clj
+++ b/src/lux/analyser/record.clj
@@ -16,13 +16,13 @@
"(-> (List (, Syntax Syntax)) (Lux (List Syntax)))"
(|do [[tag-group tag-type] (|case pairs
(&/$Nil)
- (return (&/T &/Nil$ &type/Unit))
+ (return (&/T [&/Nil$ &type/Unit]))
(&/$Cons [[_ (&/$TagS tag1)] _] _)
(|do [[module name] (&&/resolved-ident tag1)
tags (&&module/tag-group module name)
type (&&module/tag-type module name)]
- (return (&/T tags type)))
+ (return (&/T [tags type])))
_
(fail "[Analyser Error] Wrong syntax for records. Odd elements must be tags."))
@@ -30,7 +30,7 @@
(|case kv
[[_ (&/$TagS k)] v]
(|do [=k (&&/resolved-ident k)]
- (return (&/T (&/ident->text =k) v)))
+ (return (&/T [(&/ident->text =k) v])))
_
(fail "[Analyser Error] Wrong syntax for records. Odd elements must be tags.")))
@@ -40,4 +40,4 @@
(return member)
(fail (str "[Analyser Error] Unknown tag: " tag))))
(&/|map &/ident->text tag-group))]
- (return (&/T =members tag-type))))
+ (return (&/T [=members tag-type]))))