diff options
Diffstat (limited to '')
-rw-r--r-- | src/lux/analyser.clj | 10 | ||||
-rw-r--r-- | src/lux/analyser/base.clj | 118 | ||||
-rw-r--r-- | src/lux/analyser/host.clj | 180 | ||||
-rw-r--r-- | src/lux/analyser/lambda.clj | 6 | ||||
-rw-r--r-- | src/lux/analyser/lux.clj | 24 | ||||
-rw-r--r-- | src/lux/compiler.clj | 208 | ||||
-rw-r--r-- | src/lux/compiler/lambda.clj | 6 | ||||
-rw-r--r-- | src/lux/compiler/lux.clj | 2 | ||||
-rw-r--r-- | src/lux/compiler/type.clj | 9 |
9 files changed, 340 insertions, 223 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj index f8dd13bd6..0e58f530b 100644 --- a/src/lux/analyser.clj +++ b/src/lux/analyser.clj @@ -467,23 +467,23 @@ ;; Standard special forms (&/$BoolS ?value) (|do [_ (&type/check exo-type &type/Bool)] - (return (&/|list (&/T (&/V "bool" ?value) exo-type)))) + (return (&/|list (&/T (&/V &&/$bool ?value) exo-type)))) (&/$IntS ?value) (|do [_ (&type/check exo-type &type/Int)] - (return (&/|list (&/T (&/V "int" ?value) exo-type)))) + (return (&/|list (&/T (&/V &&/$int ?value) exo-type)))) (&/$RealS ?value) (|do [_ (&type/check exo-type &type/Real)] - (return (&/|list (&/T (&/V "real" ?value) exo-type)))) + (return (&/|list (&/T (&/V &&/$real ?value) exo-type)))) (&/$CharS ?value) (|do [_ (&type/check exo-type &type/Char)] - (return (&/|list (&/T (&/V "char" ?value) exo-type)))) + (return (&/|list (&/T (&/V &&/$char ?value) exo-type)))) (&/$TextS ?value) (|do [_ (&type/check exo-type &type/Text)] - (return (&/|list (&/T (&/V "text" ?value) exo-type)))) + (return (&/|list (&/T (&/V &&/$text ?value) exo-type)))) (&/$TupleS ?elems) (&&lux/analyse-tuple analyse exo-type ?elems) diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj index ed81aa9bc..3484e869d 100644 --- a/src/lux/analyser/base.clj +++ b/src/lux/analyser/base.clj @@ -9,9 +9,125 @@ (ns lux.analyser.base (:require clojure.core.match clojure.core.match.array - (lux [base :as & :refer [|let |do return fail |case]] + (lux [base :as & :refer [deftags |let |do return fail |case]] [type :as &type]))) +;; [Tags] +(deftags "" + "bool" + "int" + "real" + "char" + "text" + "variant" + "tuple" + "record" + "apply" + "case" + "lambda" + "ann" + "def" + "declare-macro" + "captured" + + "jvm-getstatic" + "jvm-getfield" + "jvm-putstatic" + "jvm-putfield" + "jvm-invokestatic" + "jvm-instanceof" + "jvm-invokevirtual" + "jvm-invokeinterface" + "jvm-invokespecial" + "jvm-null?" + "jvm-null" + "jvm-new" + "jvm-new-array" + "jvm-aastore" + "jvm-aaload" + "jvm-class" + "jvm-interface" + "jvm-try" + "jvm-throw" + "jvm-monitorenter" + "jvm-monitorexit" + "jvm-program" + + "jvm-iadd" + "jvm-isub" + "jvm-imul" + "jvm-idiv" + "jvm-irem" + "jvm-ieq" + "jvm-ilt" + "jvm-igt" + + "jvm-ceq" + "jvm-clt" + "jvm-cgt" + + "jvm-ladd" + "jvm-lsub" + "jvm-lmul" + "jvm-ldiv" + "jvm-lrem" + "jvm-leq" + "jvm-llt" + "jvm-lgt" + + "jvm-fadd" + "jvm-fsub" + "jvm-fmul" + "jvm-fdiv" + "jvm-frem" + "jvm-feq" + "jvm-flt" + "jvm-fgt" + + "jvm-dadd" + "jvm-dsub" + "jvm-dmul" + "jvm-ddiv" + "jvm-drem" + "jvm-deq" + "jvm-dlt" + "jvm-dgt" + + "jvm-d2f" + "jvm-d2i" + "jvm-d2l" + + "jvm-f2d" + "jvm-f2i" + "jvm-f2l" + + "jvm-i2b" + "jvm-i2c" + "jvm-i2d" + "jvm-i2f" + "jvm-i2l" + "jvm-i2s" + + "jvm-l2d" + "jvm-l2f" + "jvm-l2i" + + "jvm-iand" + "jvm-ior" + "jvm-ixor" + "jvm-ishl" + "jvm-ishr" + "jvm-iushr" + + "jvm-land" + "jvm-lor" + "jvm-lxor" + "jvm-lshl" + "jvm-lshr" + "jvm-lushr" + + ) + ;; [Exports] (defn expr-type [syntax+] (|let [[_ type] syntax+] diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index ec8b8b5db..64f297994 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -62,45 +62,45 @@ _ (&type/check exo-type output-type)] (return (&/|list (&/T (&/V <output-tag> (&/T =x =y)) output-type)))))) - analyse-jvm-iadd "jvm-iadd" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-isub "jvm-isub" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-imul "jvm-imul" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-idiv "jvm-idiv" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-irem "jvm-irem" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-ieq "jvm-ieq" "java.lang.Integer" "java.lang.Boolean" - analyse-jvm-ilt "jvm-ilt" "java.lang.Integer" "java.lang.Boolean" - analyse-jvm-igt "jvm-igt" "java.lang.Integer" "java.lang.Boolean" - - analyse-jvm-ceq "jvm-ceq" "java.lang.Character" "java.lang.Boolean" - analyse-jvm-clt "jvm-clt" "java.lang.Character" "java.lang.Boolean" - analyse-jvm-cgt "jvm-cgt" "java.lang.Character" "java.lang.Boolean" - - analyse-jvm-ladd "jvm-ladd" "java.lang.Long" "java.lang.Long" - analyse-jvm-lsub "jvm-lsub" "java.lang.Long" "java.lang.Long" - analyse-jvm-lmul "jvm-lmul" "java.lang.Long" "java.lang.Long" - analyse-jvm-ldiv "jvm-ldiv" "java.lang.Long" "java.lang.Long" - analyse-jvm-lrem "jvm-lrem" "java.lang.Long" "java.lang.Long" - analyse-jvm-leq "jvm-leq" "java.lang.Long" "java.lang.Boolean" - analyse-jvm-llt "jvm-llt" "java.lang.Long" "java.lang.Boolean" - analyse-jvm-lgt "jvm-lgt" "java.lang.Long" "java.lang.Boolean" - - analyse-jvm-fadd "jvm-fadd" "java.lang.Float" "java.lang.Float" - analyse-jvm-fsub "jvm-fsub" "java.lang.Float" "java.lang.Float" - analyse-jvm-fmul "jvm-fmul" "java.lang.Float" "java.lang.Float" - analyse-jvm-fdiv "jvm-fdiv" "java.lang.Float" "java.lang.Float" - analyse-jvm-frem "jvm-frem" "java.lang.Float" "java.lang.Float" - analyse-jvm-feq "jvm-feq" "java.lang.Float" "java.lang.Boolean" - analyse-jvm-flt "jvm-flt" "java.lang.Float" "java.lang.Boolean" - analyse-jvm-fgt "jvm-fgt" "java.lang.Float" "java.lang.Boolean" - - analyse-jvm-dadd "jvm-dadd" "java.lang.Double" "java.lang.Double" - analyse-jvm-dsub "jvm-dsub" "java.lang.Double" "java.lang.Double" - analyse-jvm-dmul "jvm-dmul" "java.lang.Double" "java.lang.Double" - analyse-jvm-ddiv "jvm-ddiv" "java.lang.Double" "java.lang.Double" - analyse-jvm-drem "jvm-drem" "java.lang.Double" "java.lang.Double" - analyse-jvm-deq "jvm-deq" "java.lang.Double" "java.lang.Boolean" - analyse-jvm-dlt "jvm-dlt" "java.lang.Double" "java.lang.Boolean" - analyse-jvm-dgt "jvm-dgt" "java.lang.Double" "java.lang.Boolean" + analyse-jvm-iadd &&/$jvm-iadd "java.lang.Integer" "java.lang.Integer" + analyse-jvm-isub &&/$jvm-isub "java.lang.Integer" "java.lang.Integer" + analyse-jvm-imul &&/$jvm-imul "java.lang.Integer" "java.lang.Integer" + analyse-jvm-idiv &&/$jvm-idiv "java.lang.Integer" "java.lang.Integer" + analyse-jvm-irem &&/$jvm-irem "java.lang.Integer" "java.lang.Integer" + analyse-jvm-ieq &&/$jvm-ieq "java.lang.Integer" "java.lang.Boolean" + analyse-jvm-ilt &&/$jvm-ilt "java.lang.Integer" "java.lang.Boolean" + analyse-jvm-igt &&/$jvm-igt "java.lang.Integer" "java.lang.Boolean" + + analyse-jvm-ceq &&/$jvm-ceq "java.lang.Character" "java.lang.Boolean" + analyse-jvm-clt &&/$jvm-clt "java.lang.Character" "java.lang.Boolean" + analyse-jvm-cgt &&/$jvm-cgt "java.lang.Character" "java.lang.Boolean" + + analyse-jvm-ladd &&/$jvm-ladd "java.lang.Long" "java.lang.Long" + analyse-jvm-lsub &&/$jvm-lsub "java.lang.Long" "java.lang.Long" + analyse-jvm-lmul &&/$jvm-lmul "java.lang.Long" "java.lang.Long" + analyse-jvm-ldiv &&/$jvm-ldiv "java.lang.Long" "java.lang.Long" + analyse-jvm-lrem &&/$jvm-lrem "java.lang.Long" "java.lang.Long" + analyse-jvm-leq &&/$jvm-leq "java.lang.Long" "java.lang.Boolean" + analyse-jvm-llt &&/$jvm-llt "java.lang.Long" "java.lang.Boolean" + analyse-jvm-lgt &&/$jvm-lgt "java.lang.Long" "java.lang.Boolean" + + analyse-jvm-fadd &&/$jvm-fadd "java.lang.Float" "java.lang.Float" + analyse-jvm-fsub &&/$jvm-fsub "java.lang.Float" "java.lang.Float" + analyse-jvm-fmul &&/$jvm-fmul "java.lang.Float" "java.lang.Float" + analyse-jvm-fdiv &&/$jvm-fdiv "java.lang.Float" "java.lang.Float" + analyse-jvm-frem &&/$jvm-frem "java.lang.Float" "java.lang.Float" + analyse-jvm-feq &&/$jvm-feq "java.lang.Float" "java.lang.Boolean" + analyse-jvm-flt &&/$jvm-flt "java.lang.Float" "java.lang.Boolean" + analyse-jvm-fgt &&/$jvm-fgt "java.lang.Float" "java.lang.Boolean" + + analyse-jvm-dadd &&/$jvm-dadd "java.lang.Double" "java.lang.Double" + analyse-jvm-dsub &&/$jvm-dsub "java.lang.Double" "java.lang.Double" + analyse-jvm-dmul &&/$jvm-dmul "java.lang.Double" "java.lang.Double" + analyse-jvm-ddiv &&/$jvm-ddiv "java.lang.Double" "java.lang.Double" + analyse-jvm-drem &&/$jvm-drem "java.lang.Double" "java.lang.Double" + analyse-jvm-deq &&/$jvm-deq "java.lang.Double" "java.lang.Boolean" + analyse-jvm-dlt &&/$jvm-dlt "java.lang.Double" "java.lang.Boolean" + analyse-jvm-dgt &&/$jvm-dgt "java.lang.Double" "java.lang.Boolean" ) (defn analyse-jvm-getstatic [analyse exo-type ?class ?field] @@ -108,7 +108,7 @@ =type (&host/lookup-static-field class-loader ?class ?field) :let [output-type =type] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-getstatic" (&/T ?class ?field)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-getstatic (&/T ?class ?field)) output-type))))) (defn analyse-jvm-getfield [analyse exo-type ?class ?field ?object] (|do [class-loader &/loader @@ -116,7 +116,7 @@ =object (&&/analyse-1 analyse ?object) :let [output-type =type] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-getfield" (&/T ?class ?field =object)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-getfield (&/T ?class ?field =object)) output-type))))) (defn analyse-jvm-putstatic [analyse exo-type ?class ?field ?value] (|do [class-loader &/loader @@ -124,7 +124,7 @@ =value (&&/analyse-1 analyse =type ?value) :let [output-type &type/Unit] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-putstatic" (&/T ?class ?field =value)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-putstatic (&/T ?class ?field =value)) output-type))))) (defn analyse-jvm-putfield [analyse exo-type ?class ?field ?object ?value] (|do [class-loader &/loader @@ -133,7 +133,7 @@ =value (&&/analyse-1 analyse =type ?value) :let [output-type &type/Unit] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-putfield" (&/T ?class ?field =object =value)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-putfield (&/T ?class ?field =object =value)) output-type))))) (defn analyse-jvm-invokestatic [analyse exo-type ?class ?method ?classes ?args] (|do [class-loader &/loader @@ -148,14 +148,14 @@ ?args) :let [output-type =return] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-invokestatic" (&/T ?class ?method =classes =args)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-invokestatic (&/T ?class ?method =classes =args)) output-type))))) (defn analyse-jvm-instanceof [analyse exo-type ?class ?object] (|do [=object (analyse-1+ analyse ?object) _ (ensure-object =object) :let [output-type &type/Bool] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-instanceof" (&/T ?class =object)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-instanceof (&/T ?class =object)) output-type))))) (do-template [<name> <tag>] (defn <name> [analyse exo-type ?class ?method ?classes ?object ?args] @@ -169,8 +169,8 @@ _ (&type/check exo-type output-type)] (return (&/|list (&/T (&/V <tag> (&/T ?class ?method =classes =object =args)) output-type))))) - analyse-jvm-invokevirtual "jvm-invokevirtual" - analyse-jvm-invokeinterface "jvm-invokeinterface" + analyse-jvm-invokevirtual &&/$jvm-invokevirtual + analyse-jvm-invokeinterface &&/$jvm-invokeinterface ) (defn analyse-jvm-invokespecial [analyse exo-type ?class ?method ?classes ?object ?args] @@ -185,41 +185,41 @@ =classes ?args) :let [output-type =return] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-invokespecial" (&/T ?class ?method =classes =object =args)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-invokespecial (&/T ?class ?method =classes =object =args)) output-type))))) (defn analyse-jvm-null? [analyse exo-type ?object] (|do [=object (analyse-1+ analyse ?object) _ (ensure-object =object) :let [output-type &type/Bool] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-null?" =object) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-null? =object) output-type))))) (defn analyse-jvm-null [analyse exo-type] (|do [:let [output-type (&/V &/$DataT "null")] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-null" nil) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-null nil) output-type))))) (defn analyse-jvm-new [analyse exo-type ?class ?classes ?args] (|do [=classes (&/map% extract-text ?classes) =args (&/map% (partial analyse-1+ analyse) ?args) :let [output-type (&/V &/$DataT ?class)] _ (&type/check exo-type output-type)] - (return (&/|list (&/T (&/V "jvm-new" (&/T ?class =classes =args)) output-type))))) + (return (&/|list (&/T (&/V &&/$jvm-new (&/T ?class =classes =args)) output-type))))) (defn analyse-jvm-new-array [analyse ?class ?length] - (return (&/|list (&/T (&/V "jvm-new-array" (&/T ?class ?length)) (&/V "array" (&/T (&/V &/$DataT ?class) - (&/V &/$Nil nil))))))) + (return (&/|list (&/T (&/V &&/$jvm-new-array (&/T ?class ?length)) (&/V "array" (&/T (&/V &/$DataT ?class) + (&/V &/$Nil nil))))))) (defn analyse-jvm-aastore [analyse ?array ?idx ?elem] (|do [=array (analyse-1+ analyse ?array) =elem (analyse-1+ analyse ?elem) =array-type (&&/expr-type =array)] - (return (&/|list (&/T (&/V "jvm-aastore" (&/T =array ?idx =elem)) =array-type))))) + (return (&/|list (&/T (&/V &&/$jvm-aastore (&/T =array ?idx =elem)) =array-type))))) (defn analyse-jvm-aaload [analyse ?array ?idx] (|do [=array (analyse-1+ analyse ?array) =array-type (&&/expr-type =array)] - (return (&/|list (&/T (&/V "jvm-aaload" (&/T =array ?idx)) =array-type))))) + (return (&/|list (&/T (&/V &&/$jvm-aaload (&/T =array ?idx)) =array-type))))) (defn ^:private analyse-modifiers [modifiers] (&/fold% (fn [so-far modif] @@ -327,7 +327,7 @@ _ (fail "[Analyser Error] Wrong syntax for method."))) (&/enumerate ?methods)) - _ (compile-token (&/V "jvm-class" (&/T ?name ?super-class =interfaces =fields =methods)))] + _ (compile-token (&/V &&/$jvm-class (&/T ?name ?super-class =interfaces =fields =methods)))] (return (&/|list)))) (defn analyse-jvm-interface [analyse compile-token ?name ?supers ?methods] @@ -349,7 +349,7 @@ _ (fail (str "[Analyser Error] Invalid method signature: " (&/show-ast method))))) ?methods) - _ (compile-token (&/V "jvm-interface" (&/T ?name =supers =methods)))] + _ (compile-token (&/V &&/$jvm-interface (&/T ?name =supers =methods)))] (return (&/|list)))) (defn analyse-jvm-try [analyse exo-type ?body ?catches+?finally] @@ -365,13 +365,13 @@ (&/$None) (return (&/V &/$None nil)) (&/$Some ?finally*) (|do [=finally (analyse-1+ analyse ?finally*)] (return (&/V &/$Some =finally))))] - (return (&/|list (&/T (&/V "jvm-try" (&/T =body =catches =finally)) exo-type))))) + (return (&/|list (&/T (&/V &&/$jvm-try (&/T =body =catches =finally)) exo-type))))) (defn analyse-jvm-throw [analyse exo-type ?ex] (|do [=ex (analyse-1+ analyse ?ex) :let [[_obj _type] =ex] _ (&type/check (&/V &/$DataT "java.lang.Throwable") _type)] - (return (&/|list (&/T (&/V "jvm-throw" =ex) &type/$Void))))) + (return (&/|list (&/T (&/V &&/$jvm-throw =ex) &type/$Void))))) (do-template [<name> <tag>] (defn <name> [analyse exo-type ?monitor] @@ -381,8 +381,8 @@ _ (&type/check exo-type output-type)] (return (&/|list (&/T (&/V <tag> =monitor) output-type))))) - analyse-jvm-monitorenter "jvm-monitorenter" - analyse-jvm-monitorexit "jvm-monitorexit" + analyse-jvm-monitorenter &&/$jvm-monitorenter + analyse-jvm-monitorexit &&/$jvm-monitorexit ) (do-template [<name> <tag> <from-class> <to-class>] @@ -392,24 +392,24 @@ _ (&type/check exo-type output-type)] (return (&/|list (&/T (&/V <tag> =value) output-type)))))) - analyse-jvm-d2f "jvm-d2f" "java.lang.Double" "java.lang.Float" - analyse-jvm-d2i "jvm-d2i" "java.lang.Double" "java.lang.Integer" - analyse-jvm-d2l "jvm-d2l" "java.lang.Double" "java.lang.Long" + analyse-jvm-d2f &&/$jvm-d2f "java.lang.Double" "java.lang.Float" + analyse-jvm-d2i &&/$jvm-d2i "java.lang.Double" "java.lang.Integer" + analyse-jvm-d2l &&/$jvm-d2l "java.lang.Double" "java.lang.Long" - analyse-jvm-f2d "jvm-f2d" "java.lang.Float" "java.lang.Double" - analyse-jvm-f2i "jvm-f2i" "java.lang.Float" "java.lang.Integer" - analyse-jvm-f2l "jvm-f2l" "java.lang.Float" "java.lang.Long" + analyse-jvm-f2d &&/$jvm-f2d "java.lang.Float" "java.lang.Double" + analyse-jvm-f2i &&/$jvm-f2i "java.lang.Float" "java.lang.Integer" + analyse-jvm-f2l &&/$jvm-f2l "java.lang.Float" "java.lang.Long" - analyse-jvm-i2b "jvm-i2b" "java.lang.Integer" "java.lang.Byte" - analyse-jvm-i2c "jvm-i2c" "java.lang.Integer" "java.lang.Character" - analyse-jvm-i2d "jvm-i2d" "java.lang.Integer" "java.lang.Double" - analyse-jvm-i2f "jvm-i2f" "java.lang.Integer" "java.lang.Float" - analyse-jvm-i2l "jvm-i2l" "java.lang.Integer" "java.lang.Long" - analyse-jvm-i2s "jvm-i2s" "java.lang.Integer" "java.lang.Short" + analyse-jvm-i2b &&/$jvm-i2b "java.lang.Integer" "java.lang.Byte" + analyse-jvm-i2c &&/$jvm-i2c "java.lang.Integer" "java.lang.Character" + analyse-jvm-i2d &&/$jvm-i2d "java.lang.Integer" "java.lang.Double" + analyse-jvm-i2f &&/$jvm-i2f "java.lang.Integer" "java.lang.Float" + analyse-jvm-i2l &&/$jvm-i2l "java.lang.Integer" "java.lang.Long" + analyse-jvm-i2s &&/$jvm-i2s "java.lang.Integer" "java.lang.Short" - analyse-jvm-l2d "jvm-l2d" "java.lang.Long" "java.lang.Double" - analyse-jvm-l2f "jvm-l2f" "java.lang.Long" "java.lang.Float" - analyse-jvm-l2i "jvm-l2i" "java.lang.Long" "java.lang.Integer" + analyse-jvm-l2d &&/$jvm-l2d "java.lang.Long" "java.lang.Double" + analyse-jvm-l2f &&/$jvm-l2f "java.lang.Long" "java.lang.Float" + analyse-jvm-l2i &&/$jvm-l2i "java.lang.Long" "java.lang.Integer" ) (do-template [<name> <tag> <from-class> <to-class>] @@ -419,24 +419,24 @@ _ (&type/check exo-type output-type)] (return (&/|list (&/T (&/V <tag> =value) output-type)))))) - analyse-jvm-iand "jvm-iand" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-ior "jvm-ior" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-ixor "jvm-ixor" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-ishl "jvm-ishl" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-ishr "jvm-ishr" "java.lang.Integer" "java.lang.Integer" - analyse-jvm-iushr "jvm-iushr" "java.lang.Integer" "java.lang.Integer" - - analyse-jvm-land "jvm-land" "java.lang.Long" "java.lang.Long" - analyse-jvm-lor "jvm-lor" "java.lang.Long" "java.lang.Long" - analyse-jvm-lxor "jvm-lxor" "java.lang.Long" "java.lang.Long" - analyse-jvm-lshl "jvm-lshl" "java.lang.Long" "java.lang.Integer" - analyse-jvm-lshr "jvm-lshr" "java.lang.Long" "java.lang.Integer" - analyse-jvm-lushr "jvm-lushr" "java.lang.Long" "java.lang.Integer" + analyse-jvm-iand &&/$jvm-iand "java.lang.Integer" "java.lang.Integer" + analyse-jvm-ior &&/$jvm-ior "java.lang.Integer" "java.lang.Integer" + analyse-jvm-ixor &&/$jvm-ixor "java.lang.Integer" "java.lang.Integer" + analyse-jvm-ishl &&/$jvm-ishl "java.lang.Integer" "java.lang.Integer" + analyse-jvm-ishr &&/$jvm-ishr "java.lang.Integer" "java.lang.Integer" + analyse-jvm-iushr &&/$jvm-iushr "java.lang.Integer" "java.lang.Integer" + + analyse-jvm-land &&/$jvm-land "java.lang.Long" "java.lang.Long" + analyse-jvm-lor &&/$jvm-lor "java.lang.Long" "java.lang.Long" + analyse-jvm-lxor &&/$jvm-lxor "java.lang.Long" "java.lang.Long" + analyse-jvm-lshl &&/$jvm-lshl "java.lang.Long" "java.lang.Integer" + analyse-jvm-lshr &&/$jvm-lshr "java.lang.Long" "java.lang.Integer" + analyse-jvm-lushr &&/$jvm-lushr "java.lang.Long" "java.lang.Integer" ) (defn analyse-jvm-program [analyse compile-token ?args ?body] (|do [=body (&/with-scope "" (&&env/with-local ?args (&/V &/$AppT (&/T &type/List &type/Text)) (&&/analyse-1 analyse (&/V &/$AppT (&/T &type/IO &type/Unit)) ?body))) - _ (compile-token (&/V "jvm-program" =body))] + _ (compile-token (&/V &&/$jvm-program =body))] (return (&/|list)))) diff --git a/src/lux/analyser/lambda.clj b/src/lux/analyser/lambda.clj index a230c8642..91cf3443b 100644 --- a/src/lux/analyser/lambda.clj +++ b/src/lux/analyser/lambda.clj @@ -26,9 +26,9 @@ (defn close-over [scope name register frame] (|let [[_ register-type] register - register* (&/T (&/V "captured" (&/T scope - (->> frame (&/get$ &/$CLOSURE) (&/get$ &/$COUNTER)) - register)) + register* (&/T (&/V &&/$captured (&/T scope + (->> frame (&/get$ &/$CLOSURE) (&/get$ &/$COUNTER)) + register)) register-type)] (&/T register* (&/update$ &/$CLOSURE #(->> % (&/update$ &/$COUNTER inc) diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index e0f00a0a2..45177ce46 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -41,7 +41,7 @@ (|do [=elems (&/map2% (fn [elem-t elem] (&&/analyse-1 analyse elem-t elem)) ?members ?elems)] - (return (&/|list (&/T (&/V "tuple" =elems) + (return (&/|list (&/T (&/V &&/$tuple =elems) exo-type)))) (&/$AllT _) @@ -86,7 +86,7 @@ (|do [?tag (&&/resolved-ident ident)] (if-let [vtype (&/|get ?tag ?cases)] (|do [=value (analyse-variant-body analyse vtype ?values)] - (return (&/|list (&/T (&/V "variant" (&/T ?tag =value)) + (return (&/|list (&/T (&/V &&/$variant (&/T ?tag =value)) exo-type)))) (fail (str "[Analyser Error] There is no case " ?tag " for variant type " (&type/show-type exo-type*))))) @@ -139,7 +139,7 @@ _ (fail "[Analyser Error] Wrong syntax for records. Odd elements must be tags."))) ?elems)] - (return (&/|list (&/T (&/V "record" =slots) (&/V &/$RecordT exo-type)))))) + (return (&/|list (&/T (&/V &&/$record =slots) (&/V &/$RecordT exo-type)))))) (defn ^:private analyse-global [analyse exo-type module name] (|do [[[r-module r-name] $def] (&&module/find-def module name) @@ -282,7 +282,7 @@ ;; :let [_ (prn 'MACRO-EXPAND|POST (str r-module ";" r-name))] :let [macro-expansion* (&/|map (partial with-cursor form-cursor) macro-expansion)] ;; :let [_ (when (or (= "<>" r-name) - ;; ;; (= "struct" r-name) + ;; ;; (= &&/$struct r-name) ;; ) ;; (->> (&/|map &/show-ast macro-expansion*) ;; (&/|interpose "\n") @@ -293,12 +293,12 @@ _ (|do [[=output-t =args] (analyse-apply* analyse exo-type =fn-type ?args)] - (return (&/|list (&/T (&/V "apply" (&/T =fn =args)) + (return (&/|list (&/T (&/V &&/$apply (&/T =fn =args)) =output-t)))))) _ (|do [[=output-t =args] (analyse-apply* analyse exo-type =fn-type ?args)] - (return (&/|list (&/T (&/V "apply" (&/T =fn =args)) + (return (&/|list (&/T (&/V &&/$apply (&/T =fn =args)) =output-t))))) ))) @@ -309,7 +309,7 @@ =value (analyse-1+ analyse ?value) =value-type (&&/expr-type =value) =match (&&case/analyse-branches analyse exo-type =value-type (&/|as-pairs ?branches))] - (return (&/|list (&/T (&/V "case" (&/T =value =match)) + (return (&/|list (&/T (&/V &&/$case (&/T =value =match)) exo-type))))) (defn analyse-lambda* [analyse exo-type ?self ?arg ?body] @@ -328,7 +328,7 @@ (|do [[=scope =captured =body] (&&lambda/with-lambda ?self exo-type* ?arg ?arg-t (&&/analyse-1 analyse ?return-t ?body))] - (return (&/T (&/V "lambda" (&/T =scope =captured =body)) exo-type*))) + (return (&/T (&/V &&/$lambda (&/T =scope =captured =body)) exo-type*))) _ (fail (str "[Analyser Error] Functions require function types: " @@ -397,13 +397,13 @@ _ (do (println 'DEF (str module-name ";" ?name)) - (|do [_ (compile-token (&/V "def" (&/T ?name =value)))] + (|do [_ (compile-token (&/V &&/$def (&/T ?name =value)))] (return (&/|list))))) )))) (defn analyse-declare-macro [analyse compile-token ?name] (|do [module-name &/get-module-name] - (|do [_ (compile-token (&/V "declare-macro" (&/T module-name ?name)))] + (|do [_ (compile-token (&/V &&/$declare-macro (&/T module-name ?name)))] (return (&/|list))))) (defn analyse-import [analyse compile-module compile-token ?path] @@ -433,7 +433,7 @@ ==type (eval! =type) _ (&type/check exo-type ==type) =value (&&/analyse-1 analyse ==type ?value)] - (return (&/|list (&/T (&/V "ann" (&/T =value =type)) + (return (&/|list (&/T (&/V &&/$ann (&/T =value =type)) ==type))))) (defn analyse-coerce [analyse eval! exo-type ?type ?value] @@ -441,5 +441,5 @@ ==type (eval! =type) _ (&type/check exo-type ==type) =value (&&/analyse-1 analyse ==type ?value)] - (return (&/|list (&/T (&/V "ann" (&/T =value =type)) + (return (&/|list (&/T (&/V &&/$ann (&/T =value =type)) ==type))))) diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj index 2565c3b20..490491bd0 100644 --- a/src/lux/compiler.clj +++ b/src/lux/compiler.clj @@ -40,333 +40,333 @@ (defn ^:private compile-expression [syntax] (|let [[?form ?type] syntax] (|case ?form - ("bool" ?value) + (&a/$bool ?value) (&&lux/compile-bool compile-expression ?type ?value) - ("int" ?value) + (&a/$int ?value) (&&lux/compile-int compile-expression ?type ?value) - ("real" ?value) + (&a/$real ?value) (&&lux/compile-real compile-expression ?type ?value) - ("char" ?value) + (&a/$char ?value) (&&lux/compile-char compile-expression ?type ?value) - ("text" ?value) + (&a/$text ?value) (&&lux/compile-text compile-expression ?type ?value) - ("tuple" ?elems) + (&a/$tuple ?elems) (&&lux/compile-tuple compile-expression ?type ?elems) - ("record" ?elems) + (&a/$record ?elems) (&&lux/compile-record compile-expression ?type ?elems) (&/$Local ?idx) (&&lux/compile-local compile-expression ?type ?idx) - ("captured" ?scope ?captured-id ?source) + (&a/$captured ?scope ?captured-id ?source) (&&lux/compile-captured compile-expression ?type ?scope ?captured-id ?source) (&/$Global ?owner-class ?name) (&&lux/compile-global compile-expression ?type ?owner-class ?name) - ("apply" ?fn ?args) + (&a/$apply ?fn ?args) (&&lux/compile-apply compile-expression ?type ?fn ?args) - ("variant" ?tag ?members) + (&a/$variant ?tag ?members) (&&lux/compile-variant compile-expression ?type ?tag ?members) - ("case" ?value ?match) + (&a/$case ?value ?match) (&&case/compile-case compile-expression ?type ?value ?match) - ("lambda" ?scope ?env ?body) + (&a/$lambda ?scope ?env ?body) (&&lambda/compile-lambda compile-expression ?scope ?env ?body) - ("ann" ?value-ex ?type-ex) + (&a/$ann ?value-ex ?type-ex) (&&lux/compile-ann compile-expression ?type ?value-ex ?type-ex) ;; Characters - ("jvm-ceq" ?x ?y) + (&a/$jvm-ceq ?x ?y) (&&host/compile-jvm-ceq compile-expression ?type ?x ?y) - ("jvm-clt" ?x ?y) + (&a/$jvm-clt ?x ?y) (&&host/compile-jvm-clt compile-expression ?type ?x ?y) - ("jvm-cgt" ?x ?y) + (&a/$jvm-cgt ?x ?y) (&&host/compile-jvm-cgt compile-expression ?type ?x ?y) ;; Integer arithmetic - ("jvm-iadd" ?x ?y) + (&a/$jvm-iadd ?x ?y) (&&host/compile-jvm-iadd compile-expression ?type ?x ?y) - ("jvm-isub" ?x ?y) + (&a/$jvm-isub ?x ?y) (&&host/compile-jvm-isub compile-expression ?type ?x ?y) - ("jvm-imul" ?x ?y) + (&a/$jvm-imul ?x ?y) (&&host/compile-jvm-imul compile-expression ?type ?x ?y) - ("jvm-idiv" ?x ?y) + (&a/$jvm-idiv ?x ?y) (&&host/compile-jvm-idiv compile-expression ?type ?x ?y) - ("jvm-irem" ?x ?y) + (&a/$jvm-irem ?x ?y) (&&host/compile-jvm-irem compile-expression ?type ?x ?y) - ("jvm-ieq" ?x ?y) + (&a/$jvm-ieq ?x ?y) (&&host/compile-jvm-ieq compile-expression ?type ?x ?y) - ("jvm-ilt" ?x ?y) + (&a/$jvm-ilt ?x ?y) (&&host/compile-jvm-ilt compile-expression ?type ?x ?y) - ("jvm-igt" ?x ?y) + (&a/$jvm-igt ?x ?y) (&&host/compile-jvm-igt compile-expression ?type ?x ?y) ;; Long arithmetic - ("jvm-ladd" ?x ?y) + (&a/$jvm-ladd ?x ?y) (&&host/compile-jvm-ladd compile-expression ?type ?x ?y) - ("jvm-lsub" ?x ?y) + (&a/$jvm-lsub ?x ?y) (&&host/compile-jvm-lsub compile-expression ?type ?x ?y) - ("jvm-lmul" ?x ?y) + (&a/$jvm-lmul ?x ?y) (&&host/compile-jvm-lmul compile-expression ?type ?x ?y) - ("jvm-ldiv" ?x ?y) + (&a/$jvm-ldiv ?x ?y) (&&host/compile-jvm-ldiv compile-expression ?type ?x ?y) - ("jvm-lrem" ?x ?y) + (&a/$jvm-lrem ?x ?y) (&&host/compile-jvm-lrem compile-expression ?type ?x ?y) - ("jvm-leq" ?x ?y) + (&a/$jvm-leq ?x ?y) (&&host/compile-jvm-leq compile-expression ?type ?x ?y) - ("jvm-llt" ?x ?y) + (&a/$jvm-llt ?x ?y) (&&host/compile-jvm-llt compile-expression ?type ?x ?y) - ("jvm-lgt" ?x ?y) + (&a/$jvm-lgt ?x ?y) (&&host/compile-jvm-lgt compile-expression ?type ?x ?y) ;; Float arithmetic - ("jvm-fadd" ?x ?y) + (&a/$jvm-fadd ?x ?y) (&&host/compile-jvm-fadd compile-expression ?type ?x ?y) - ("jvm-fsub" ?x ?y) + (&a/$jvm-fsub ?x ?y) (&&host/compile-jvm-fsub compile-expression ?type ?x ?y) - ("jvm-fmul" ?x ?y) + (&a/$jvm-fmul ?x ?y) (&&host/compile-jvm-fmul compile-expression ?type ?x ?y) - ("jvm-fdiv" ?x ?y) + (&a/$jvm-fdiv ?x ?y) (&&host/compile-jvm-fdiv compile-expression ?type ?x ?y) - ("jvm-frem" ?x ?y) + (&a/$jvm-frem ?x ?y) (&&host/compile-jvm-frem compile-expression ?type ?x ?y) - ("jvm-feq" ?x ?y) + (&a/$jvm-feq ?x ?y) (&&host/compile-jvm-feq compile-expression ?type ?x ?y) - ("jvm-flt" ?x ?y) + (&a/$jvm-flt ?x ?y) (&&host/compile-jvm-flt compile-expression ?type ?x ?y) - ("jvm-fgt" ?x ?y) + (&a/$jvm-fgt ?x ?y) (&&host/compile-jvm-fgt compile-expression ?type ?x ?y) ;; Double arithmetic - ("jvm-dadd" ?x ?y) + (&a/$jvm-dadd ?x ?y) (&&host/compile-jvm-dadd compile-expression ?type ?x ?y) - ("jvm-dsub" ?x ?y) + (&a/$jvm-dsub ?x ?y) (&&host/compile-jvm-dsub compile-expression ?type ?x ?y) - ("jvm-dmul" ?x ?y) + (&a/$jvm-dmul ?x ?y) (&&host/compile-jvm-dmul compile-expression ?type ?x ?y) - ("jvm-ddiv" ?x ?y) + (&a/$jvm-ddiv ?x ?y) (&&host/compile-jvm-ddiv compile-expression ?type ?x ?y) - ("jvm-drem" ?x ?y) + (&a/$jvm-drem ?x ?y) (&&host/compile-jvm-drem compile-expression ?type ?x ?y) - ("jvm-deq" ?x ?y) + (&a/$jvm-deq ?x ?y) (&&host/compile-jvm-deq compile-expression ?type ?x ?y) - ("jvm-dlt" ?x ?y) + (&a/$jvm-dlt ?x ?y) (&&host/compile-jvm-dlt compile-expression ?type ?x ?y) - ("jvm-dgt" ?x ?y) + (&a/$jvm-dgt ?x ?y) (&&host/compile-jvm-dgt compile-expression ?type ?x ?y) - ("jvm-null" _) + (&a/$jvm-null _) (&&host/compile-jvm-null compile-expression ?type) - ("jvm-null?" ?object) + (&a/$jvm-null? ?object) (&&host/compile-jvm-null? compile-expression ?type ?object) - ("jvm-new" ?class ?classes ?args) + (&a/$jvm-new ?class ?classes ?args) (&&host/compile-jvm-new compile-expression ?type ?class ?classes ?args) - ("jvm-getstatic" ?class ?field) + (&a/$jvm-getstatic ?class ?field) (&&host/compile-jvm-getstatic compile-expression ?type ?class ?field) - ("jvm-getfield" ?class ?field ?object) + (&a/$jvm-getfield ?class ?field ?object) (&&host/compile-jvm-getfield compile-expression ?type ?class ?field ?object) - ("jvm-putstatic" ?class ?field ?value) + (&a/$jvm-putstatic ?class ?field ?value) (&&host/compile-jvm-putstatic compile-expression ?type ?class ?field ?value) - ("jvm-putfield" ?class ?field ?object ?value) + (&a/$jvm-putfield ?class ?field ?object ?value) (&&host/compile-jvm-putfield compile-expression ?type ?class ?field ?object ?value) - ("jvm-invokestatic" ?class ?method ?classes ?args) + (&a/$jvm-invokestatic ?class ?method ?classes ?args) (&&host/compile-jvm-invokestatic compile-expression ?type ?class ?method ?classes ?args) - ("jvm-invokevirtual" ?class ?method ?classes ?object ?args) + (&a/$jvm-invokevirtual ?class ?method ?classes ?object ?args) (&&host/compile-jvm-invokevirtual compile-expression ?type ?class ?method ?classes ?object ?args) - ("jvm-invokeinterface" ?class ?method ?classes ?object ?args) + (&a/$jvm-invokeinterface ?class ?method ?classes ?object ?args) (&&host/compile-jvm-invokeinterface compile-expression ?type ?class ?method ?classes ?object ?args) - ("jvm-invokespecial" ?class ?method ?classes ?object ?args) + (&a/$jvm-invokespecial ?class ?method ?classes ?object ?args) (&&host/compile-jvm-invokespecial compile-expression ?type ?class ?method ?classes ?object ?args) - ("jvm-new-array" ?class ?length) + (&a/$jvm-new-array ?class ?length) (&&host/compile-jvm-new-array compile-expression ?type ?class ?length) - ("jvm-aastore" ?array ?idx ?elem) + (&a/$jvm-aastore ?array ?idx ?elem) (&&host/compile-jvm-aastore compile-expression ?type ?array ?idx ?elem) - ("jvm-aaload" ?array ?idx) + (&a/$jvm-aaload ?array ?idx) (&&host/compile-jvm-aaload compile-expression ?type ?array ?idx) - ("jvm-try" ?body ?catches ?finally) + (&a/$jvm-try ?body ?catches ?finally) (&&host/compile-jvm-try compile-expression ?type ?body ?catches ?finally) - ("jvm-throw" ?ex) + (&a/$jvm-throw ?ex) (&&host/compile-jvm-throw compile-expression ?type ?ex) - ("jvm-monitorenter" ?monitor) + (&a/$jvm-monitorenter ?monitor) (&&host/compile-jvm-monitorenter compile-expression ?type ?monitor) - ("jvm-monitorexit" ?monitor) + (&a/$jvm-monitorexit ?monitor) (&&host/compile-jvm-monitorexit compile-expression ?type ?monitor) - ("jvm-d2f" ?value) + (&a/$jvm-d2f ?value) (&&host/compile-jvm-d2f compile-expression ?type ?value) - ("jvm-d2i" ?value) + (&a/$jvm-d2i ?value) (&&host/compile-jvm-d2i compile-expression ?type ?value) - ("jvm-d2l" ?value) + (&a/$jvm-d2l ?value) (&&host/compile-jvm-d2l compile-expression ?type ?value) - ("jvm-f2d" ?value) + (&a/$jvm-f2d ?value) (&&host/compile-jvm-f2d compile-expression ?type ?value) - ("jvm-f2i" ?value) + (&a/$jvm-f2i ?value) (&&host/compile-jvm-f2i compile-expression ?type ?value) - ("jvm-f2l" ?value) + (&a/$jvm-f2l ?value) (&&host/compile-jvm-f2l compile-expression ?type ?value) - ("jvm-i2b" ?value) + (&a/$jvm-i2b ?value) (&&host/compile-jvm-i2b compile-expression ?type ?value) - ("jvm-i2c" ?value) + (&a/$jvm-i2c ?value) (&&host/compile-jvm-i2c compile-expression ?type ?value) - ("jvm-i2d" ?value) + (&a/$jvm-i2d ?value) (&&host/compile-jvm-i2d compile-expression ?type ?value) - ("jvm-i2f" ?value) + (&a/$jvm-i2f ?value) (&&host/compile-jvm-i2f compile-expression ?type ?value) - ("jvm-i2l" ?value) + (&a/$jvm-i2l ?value) (&&host/compile-jvm-i2l compile-expression ?type ?value) - ("jvm-i2s" ?value) + (&a/$jvm-i2s ?value) (&&host/compile-jvm-i2s compile-expression ?type ?value) - ("jvm-l2d" ?value) + (&a/$jvm-l2d ?value) (&&host/compile-jvm-l2d compile-expression ?type ?value) - ("jvm-l2f" ?value) + (&a/$jvm-l2f ?value) (&&host/compile-jvm-l2f compile-expression ?type ?value) - ("jvm-l2i" ?value) + (&a/$jvm-l2i ?value) (&&host/compile-jvm-l2i compile-expression ?type ?value) - ("jvm-iand" ?x ?y) + (&a/$jvm-iand ?x ?y) (&&host/compile-jvm-iand compile-expression ?type ?x ?y) - ("jvm-ior" ?x ?y) + (&a/$jvm-ior ?x ?y) (&&host/compile-jvm-ior compile-expression ?type ?x ?y) - ("jvm-ixor" ?x ?y) + (&a/$jvm-ixor ?x ?y) (&&host/compile-jvm-ixor compile-expression ?type ?x ?y) - ("jvm-ishl" ?x ?y) + (&a/$jvm-ishl ?x ?y) (&&host/compile-jvm-ishl compile-expression ?type ?x ?y) - ("jvm-ishr" ?x ?y) + (&a/$jvm-ishr ?x ?y) (&&host/compile-jvm-ishr compile-expression ?type ?x ?y) - ("jvm-iushr" ?x ?y) + (&a/$jvm-iushr ?x ?y) (&&host/compile-jvm-iushr compile-expression ?type ?x ?y) - ("jvm-land" ?x ?y) + (&a/$jvm-land ?x ?y) (&&host/compile-jvm-land compile-expression ?type ?x ?y) - ("jvm-lor" ?x ?y) + (&a/$jvm-lor ?x ?y) (&&host/compile-jvm-lor compile-expression ?type ?x ?y) - ("jvm-lxor" ?x ?y) + (&a/$jvm-lxor ?x ?y) (&&host/compile-jvm-lxor compile-expression ?type ?x ?y) - ("jvm-lshl" ?x ?y) + (&a/$jvm-lshl ?x ?y) (&&host/compile-jvm-lshl compile-expression ?type ?x ?y) - ("jvm-lshr" ?x ?y) + (&a/$jvm-lshr ?x ?y) (&&host/compile-jvm-lshr compile-expression ?type ?x ?y) - ("jvm-lushr" ?x ?y) + (&a/$jvm-lushr ?x ?y) (&&host/compile-jvm-lushr compile-expression ?type ?x ?y) - ("jvm-instanceof" ?class ?object) + (&a/$jvm-instanceof ?class ?object) (&&host/compile-jvm-instanceof compile-expression ?type ?class ?object) ) )) (defn ^:private compile-statement [syntax] (|case syntax - ("def" ?name ?body) + (&a/$def ?name ?body) (&&lux/compile-def compile-expression ?name ?body) - ("declare-macro" ?module ?name) + (&a/$declare-macro ?module ?name) (&&lux/compile-declare-macro compile-expression ?module ?name) - ("jvm-program" ?body) + (&a/$jvm-program ?body) (&&host/compile-jvm-program compile-expression ?body) - ("jvm-interface" ?name ?supers ?methods) + (&a/$jvm-interface ?name ?supers ?methods) (&&host/compile-jvm-interface compile-expression ?name ?supers ?methods) - ("jvm-class" ?name ?super-class ?interfaces ?fields ?methods) + (&a/$jvm-class ?name ?super-class ?interfaces ?fields ?methods) (&&host/compile-jvm-class compile-expression ?name ?super-class ?interfaces ?fields ?methods))) (defn ^:private compile-token [syntax] (|case syntax - ("def" ?name ?body) + (&a/$def ?name ?body) (&&lux/compile-def compile-expression ?name ?body) - ("declare-macro" ?module ?name) + (&a/$declare-macro ?module ?name) (&&lux/compile-declare-macro compile-expression ?module ?name) - ("jvm-program" ?body) + (&a/$jvm-program ?body) (&&host/compile-jvm-program compile-expression ?body) - ("jvm-interface" ?name ?supers ?methods) + (&a/$jvm-interface ?name ?supers ?methods) (&&host/compile-jvm-interface compile-expression ?name ?supers ?methods) - ("jvm-class" ?name ?super-class ?interfaces ?fields ?methods) + (&a/$jvm-class ?name ?super-class ?interfaces ?fields ?methods) (&&host/compile-jvm-class compile-expression ?name ?super-class ?interfaces ?fields ?methods) _ diff --git a/src/lux/compiler/lambda.clj b/src/lux/compiler/lambda.clj index 0d1ea4844..136ec0cfc 100644 --- a/src/lux/compiler/lambda.clj +++ b/src/lux/compiler/lambda.clj @@ -47,7 +47,7 @@ (.visitFieldInsn Opcodes/PUTFIELD class-name captured-name clo-field-sig)) (->> (let [captured-name (str &&/closure-prefix ?captured-id)]) (|case ?name+?captured - [?name [("captured" _ ?captured-id ?source) _]]) + [?name [(&a/$captured _ ?captured-id ?source) _]]) (doseq [?name+?captured (&/->seq env)]))) (.visitInsn Opcodes/RETURN) (.visitMaxs 0 0) @@ -84,7 +84,7 @@ (.visitInsn Opcodes/DUP))] _ (&/map% (fn [?name+?captured] (|case ?name+?captured - [?name [("captured" _ _ ?source) _]] + [?name [(&a/$captured _ _ ?source) _]] (compile ?source))) closed-over) :let [_ (.visitMethodInsn *writer* Opcodes/INVOKESPECIAL lambda-class "<init>" init-signature)]] @@ -102,7 +102,7 @@ (.visitEnd)) (->> (let [captured-name (str &&/closure-prefix ?captured-id)]) (|case ?name+?captured - [?name [("captured" _ ?captured-id ?source) _]]) + [?name [(&a/$captured _ ?captured-id ?source) _]]) (doseq [?name+?captured (&/->seq ?env)]))) (add-lambda-apply class-name ?env) (add-lambda-<init> class-name ?env) diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index 2d28f8b3f..87327311c 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -163,7 +163,7 @@ "value" (|let [;; _ (prn '?body (aget ?body 0) (aget ?body 1 0)) ?def-type (|case ?body - [("ann" ?def-value ?type-expr) ?def-type] + [(&a/$ann ?def-value ?type-expr) ?def-type] ?type-expr [?def-value ?def-type] diff --git a/src/lux/compiler/type.clj b/src/lux/compiler/type.clj index 46e6ec2d9..e9d3014db 100644 --- a/src/lux/compiler/type.clj +++ b/src/lux/compiler/type.clj @@ -10,22 +10,23 @@ (:require clojure.core.match clojure.core.match.array (lux [base :as & :refer [|do return* return fail fail* |let |case]] - [type :as &type]))) + [type :as &type]) + [lux.analyser.base :as &a])) ;; [Utils] (defn ^:private variant$ [tag body] "(-> Text Analysis Analysis)" - (&/T (&/V "variant" (&/T tag body)) + (&/T (&/V &a/$variant (&/T tag body)) &type/$Void)) (defn ^:private tuple$ [members] "(-> (List Analysis) Analysis)" - (&/T (&/V "tuple" members) + (&/T (&/V &a/$tuple members) &type/$Void)) (defn ^:private text$ [text] "(-> Text Analysis)" - (&/T (&/V "text" text) + (&/T (&/V &a/$text text) &type/$Void)) (def ^:private $Nil |