diff options
Diffstat (limited to 'luxc/src')
-rw-r--r-- | luxc/src/lux/analyser/base.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/analyser/case.clj | 10 | ||||
-rw-r--r-- | luxc/src/lux/analyser/proc/js.clj | 20 | ||||
-rw-r--r-- | luxc/src/lux/analyser/proc/jvm.clj | 74 | ||||
-rw-r--r-- | luxc/src/lux/base.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/compiler/cache/type.clj | 4 | ||||
-rw-r--r-- | luxc/src/lux/compiler/jvm/proc/host.clj | 18 | ||||
-rw-r--r-- | luxc/src/lux/host.clj | 6 | ||||
-rw-r--r-- | luxc/src/lux/type.clj | 36 | ||||
-rw-r--r-- | luxc/src/lux/type/host.clj | 38 |
10 files changed, 105 insertions, 105 deletions
diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index 9f44db3af..8c82fe1cf 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -74,7 +74,7 @@ (return ?module))] (return (&/T [module* ?name])))) -(let [tag-names #{"Host" "Void" "Unit" "Sum" "Product" "Function" "Bound" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"}] +(let [tag-names #{"Primitive" "Void" "Unit" "Sum" "Product" "Function" "Bound" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"}] (defn type-tag? [module name] (and (= "lux" module) (contains? tag-names name)))) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index a8fdd6f18..434a0f78a 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -68,9 +68,9 @@ (&/$Bound (+ (* 2 level) bound-idx)) type) - (&/$Host ?name ?params) - (&/$Host ?name (&/|map (partial clean! level ?tid bound-idx) - ?params)) + (&/$Primitive ?name ?params) + (&/$Primitive ?name (&/|map (partial clean! level ?tid bound-idx) + ?params)) (&/$Function ?arg ?return) (&/$Function (clean! level ?tid bound-idx ?arg) @@ -102,8 +102,8 @@ (defn beta-reduce! [level env type] (|case type - (&/$Host ?name ?params) - (&/$Host ?name (&/|map (partial beta-reduce! level env) ?params)) + (&/$Primitive ?name ?params) + (&/$Primitive ?name (&/|map (partial beta-reduce! level env) ?params)) (&/$Sum ?left ?right) (&/$Sum (beta-reduce! level env ?left) diff --git a/luxc/src/lux/analyser/proc/js.clj b/luxc/src/lux/analyser/proc/js.clj index 33fa7816d..8b218ee43 100644 --- a/luxc/src/lux/analyser/proc/js.clj +++ b/luxc/src/lux/analyser/proc/js.clj @@ -10,9 +10,9 @@ (do-template [<name> <proc>] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons ?function ?args) ?values] - =function (&&/analyse-1 analyse (&/$Host "function" &/$Nil) ?function) + =function (&&/analyse-1 analyse (&/$Primitive "function" &/$Nil) ?function) =args (&/map% (partial &&/analyse-1+ analyse) ?args) - _ (&type/check exo-type (&/$Host "object" &/$Nil)) + _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["js" <proc>]) (&/$Cons =function =args) (&/|list))))))) @@ -23,17 +23,17 @@ (defn ^:private analyse-js-object-call [analyse exo-type ?values] (|do [:let [(&/$Cons ?object (&/$Cons ?field ?args)) ?values] - =object (&&/analyse-1 analyse (&/$Host "object" &/$Nil) ?object) + =object (&&/analyse-1 analyse (&/$Primitive "object" &/$Nil) ?object) =field (&&/analyse-1 analyse &type/Text ?field) =args (&/map% (partial &&/analyse-1+ analyse) ?args) - _ (&type/check exo-type (&/$Host "object" &/$Nil)) + _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["js" "object-call"]) (&/$Cons =object (&/$Cons =field =args)) (&/|list))))))) (defn ^:private analyse-js-ref [analyse exo-type ?values] (|do [:let [(&/$Cons [_ (&/$Text ?ref-name)] (&/$Nil)) ?values] - _ (&type/check exo-type (&/$Host "object" &/$Nil)) + _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["js" "ref"]) (&/|list) (&/|list ?ref-name))))))) @@ -41,9 +41,9 @@ (do-template [<name> <proc>] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons ?object (&/$Cons ?field (&/$Nil))) ?values] - =object (&&/analyse-1 analyse (&/$Host "object" &/$Nil) ?object) + =object (&&/analyse-1 analyse (&/$Primitive "object" &/$Nil) ?object) =field (&&/analyse-1 analyse &type/Text ?field) - _ (&type/check exo-type (&/$Host "object" &/$Nil)) + _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["js" <proc>]) (&/|list =object =field) (&/|list))))))) @@ -54,10 +54,10 @@ (defn ^:private analyse-js-set-field [analyse exo-type ?values] (|do [:let [(&/$Cons ?object (&/$Cons ?field (&/$Cons ?value (&/$Nil)))) ?values] - =object (&&/analyse-1 analyse (&/$Host "object" &/$Nil) ?object) + =object (&&/analyse-1 analyse (&/$Primitive "object" &/$Nil) ?object) =field (&&/analyse-1 analyse &type/Text ?field) =value (&&/analyse-1+ analyse ?value) - _ (&type/check exo-type (&/$Host "object" &/$Nil)) + _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["js" "set-field"]) (&/|list =object =field =value) (&/|list))))))) @@ -65,7 +65,7 @@ (do-template [<name> <proc> <type>] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Nil) ?values] - :let [output-type (&/$Host <type> &/$Nil)] + :let [output-type (&/$Primitive <type> &/$Nil)] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor diff --git a/luxc/src/lux/analyser/proc/jvm.clj b/luxc/src/lux/analyser/proc/jvm.clj index dc3f8d587..cd3b8f545 100644 --- a/luxc/src/lux/analyser/proc/jvm.clj +++ b/luxc/src/lux/analyser/proc/jvm.clj @@ -21,7 +21,7 @@ (defn ^:private ensure-object [type] "(-> Type (Lux (, Text (List Type))))" (|case type - (&/$Host payload) + (&/$Primitive payload) (return payload) (&/$Var id) @@ -49,8 +49,8 @@ (defn ^:private as-object [type] "(-> Type Type)" (|case type - (&/$Host class params) - (&/$Host (&host-type/as-obj class) params) + (&/$Primitive class params) + (&/$Primitive (&host-type/as-obj class) params) _ type)) @@ -72,8 +72,8 @@ (defn ^:private as-otype+ [type] "(-> Type Type)" (|case type - (&/$Host name params) - (&/$Host (as-otype name) params) + (&/$Primitive name params) + (&/$Primitive (as-otype name) params) _ type)) @@ -104,14 +104,14 @@ _ base-type)) - (&/$Host class-name type-args) + (&/$Primitive class-name type-args) type-args)) ;; [Resources] (defn ^:private analyse-field-access-helper [obj-type gvars gtype] "(-> Type (List (^ java.lang.reflect.Type)) (^ java.lang.reflect.Type) (Lux Type))" (|case obj-type - (&/$Host class targs) + (&/$Primitive class targs) (if (= (&/|length targs) (&/|length gvars)) (|let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/$Cons (&/T [(.getName g) t]) m)) (&/|table) @@ -186,22 +186,22 @@ (&/$GenericClass name params) (case name - "boolean" (return (&/$Host "java.lang.Boolean" &/$Nil)) - "byte" (return (&/$Host "java.lang.Byte" &/$Nil)) - "short" (return (&/$Host "java.lang.Short" &/$Nil)) - "int" (return (&/$Host "java.lang.Integer" &/$Nil)) - "long" (return (&/$Host "java.lang.Long" &/$Nil)) - "float" (return (&/$Host "java.lang.Float" &/$Nil)) - "double" (return (&/$Host "java.lang.Double" &/$Nil)) - "char" (return (&/$Host "java.lang.Character" &/$Nil)) + "boolean" (return (&/$Primitive "java.lang.Boolean" &/$Nil)) + "byte" (return (&/$Primitive "java.lang.Byte" &/$Nil)) + "short" (return (&/$Primitive "java.lang.Short" &/$Nil)) + "int" (return (&/$Primitive "java.lang.Integer" &/$Nil)) + "long" (return (&/$Primitive "java.lang.Long" &/$Nil)) + "float" (return (&/$Primitive "java.lang.Float" &/$Nil)) + "double" (return (&/$Primitive "java.lang.Double" &/$Nil)) + "char" (return (&/$Primitive "java.lang.Character" &/$Nil)) "void" (return &/$Unit) ;; else (|do [=params (&/map% (partial generic-class->type env) params)] - (return (&/$Host name =params)))) + (return (&/$Primitive name =params)))) (&/$GenericArray param) (|do [=param (generic-class->type env param)] - (return (&/$Host &host-type/array-data-tag (&/|list =param)))) + (return (&/$Primitive &host-type/array-data-tag (&/|list =param)))) (&/$GenericWildcard _) (return (&/$ExQ &/$Nil (&/$Bound 1))) @@ -260,7 +260,7 @@ (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 (&/$Host ?cname (&/|map &/|second class-env))] + class-type (&/$Primitive ?cname (&/|map &/|second class-env))] (|case method (&/$ConstructorMethodSyntax =privacy-modifier ?strict ?anns ?gvars ?exceptions ?inputs ?ctor-args ?body) (|do [method-env (make-type-env ?gvars) @@ -383,10 +383,10 @@ )) (do-template [<name> <proc> <from-class> <to-class>] - (let [output-type (&/$Host <to-class> &/$Nil)] + (let [output-type (&/$Primitive <to-class> &/$Nil)] (defn <name> [analyse exo-type _?value] (|do [:let [(&/$Cons ?value (&/$Nil)) _?value] - =value (&&/analyse-1 analyse (&/$Host <from-class> &/$Nil) ?value) + =value (&&/analyse-1 analyse (&/$Primitive <from-class> &/$Nil) ?value) _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta output-type _cursor (&&/$proc (&/T ["jvm" <proc>]) (&/|list =value) (&/|list)))))))) @@ -423,11 +423,11 @@ ) (do-template [<name> <proc> <v1-class> <v2-class> <to-class>] - (let [output-type (&/$Host <to-class> &/$Nil)] + (let [output-type (&/$Primitive <to-class> &/$Nil)] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons ?value1 (&/$Cons ?value2 (&/$Nil))) ?values] - =value1 (&&/analyse-1 analyse (&/$Host <v1-class> &/$Nil) ?value1) - =value2 (&&/analyse-1 analyse (&/$Host <v2-class> &/$Nil) ?value2) + =value1 (&&/analyse-1 analyse (&/$Primitive <v1-class> &/$Nil) ?value1) + =value2 (&&/analyse-1 analyse (&/$Primitive <v2-class> &/$Nil) ?value2) _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta output-type _cursor (&&/$proc (&/T ["jvm" <proc>]) (&/|list =value1 =value2) (&/|list)))))))) @@ -448,8 +448,8 @@ ) (do-template [<name> <proc> <input-class> <output-class>] - (let [input-type (&/$Host <input-class> &/$Nil) - output-type (&/$Host <output-class> &/$Nil)] + (let [input-type (&/$Primitive <input-class> &/$Nil) + output-type (&/$Primitive <output-class> &/$Nil)] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] =x (&&/analyse-1 analyse input-type x) @@ -503,8 +503,8 @@ (let [length-type &type/Nat idx-type &type/Nat] (do-template [<elem-class> <array-class> <new-name> <new-tag> <load-name> <load-tag> <store-name> <store-tag>] - (let [elem-type (&/$Host <elem-class> &/$Nil) - array-type (&/$Host <array-class> &/$Nil)] + (let [elem-type (&/$Primitive <elem-class> &/$Nil) + array-type (&/$Primitive <array-class> &/$Nil)] (defn <new-name> [analyse exo-type ?values] (|do [:let [(&/$Cons length (&/$Nil)) ?values] =length (&&/analyse-1 analyse length-type length) @@ -558,7 +558,7 @@ &&a-parser/parse-gclass) gtype-env &/get-type-env =gclass (&host-type/instance-gtype &type/existential gtype-env gclass) - :let [array-type (&/$Host &host-type/array-data-tag (&/|list =gclass))] + :let [array-type (&/$Primitive &host-type/array-data-tag (&/|list =gclass))] =length (&&/analyse-1 analyse length-type length) _ (&type/check exo-type array-type) _cursor &/cursor] @@ -614,7 +614,7 @@ (defn ^:private analyse-jvm-null [analyse exo-type ?values] (|do [:let [(&/$Nil) ?values] - :let [output-type (&/$Host &host-type/null-data-tag &/$Nil)] + :let [output-type (&/$Primitive &host-type/null-data-tag &/$Nil)] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor @@ -632,7 +632,7 @@ (defn ^:private analyse-jvm-throw [analyse exo-type ?values] (|do [:let [(&/$Cons ?ex (&/$Nil)) ?values] =ex (&&/analyse-1+ analyse ?ex) - _ (&type/check (&/$Host "java.lang.Throwable" &/$Nil) (&&/expr-type* =ex)) + _ (&type/check (&/$Primitive "java.lang.Throwable" &/$Nil) (&&/expr-type* =ex)) [throw-class throw-params] (ensure-object (&&/expr-type* =ex)) _cursor &/cursor _ (&type/check exo-type &type/Bottom)] @@ -717,7 +717,7 @@ (return (&/T [==gret ==args]))))) )) -(let [dummy-type-param (&/$Host "java.lang.Object" &/$Nil)] +(let [dummy-type-param (&/$Primitive "java.lang.Object" &/$Nil)] (do-template [<name> <tag> <only-interface?>] (defn <name> [analyse exo-type class method classes ?values] (|do [!class! (&/de-alias-class class) @@ -735,10 +735,10 @@ (&host/lookup-virtual-method class-loader !class! method classes)) =object (&&/analyse-1+ analyse object) [sub-class sub-params] (ensure-object (&&/expr-type* =object)) - (&/$Host super-class* super-params*) (&host-type/->super-type &type/existential class-loader !class! (if (= sub-class class) - !class! - sub-class) - sub-params) + (&/$Primitive super-class* super-params*) (&host-type/->super-type &type/existential class-loader !class! (if (= sub-class class) + !class! + sub-class) + sub-params) :let [gtype-env (&/fold2 (fn [m ^TypeVariable g t] (&/$Cons (&/T [(.getName g) t]) m)) (&/|table) parent-gvars @@ -811,7 +811,7 @@ (return nil)) (catch Exception e (&/fail-with-loc (str "[Analyser Error] Unknown class: " _class-name)))) - :let [output-type (&/$Host "java.lang.Class" (&/|list (&/$Host _class-name (&/|list))))] + :let [output-type (&/$Primitive "java.lang.Class" (&/|list (&/$Primitive _class-name (&/|list))))] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta output-type _cursor @@ -866,7 +866,7 @@ :let [name (->> scope &/|reverse &/|tail &host/location) class-decl (&/T [name &/$Nil]) anon-class (str (string/replace module "/" ".") "." name) - anon-class-type (&/$Host anon-class &/$Nil)] + anon-class-type (&/$Primitive anon-class &/$Nil)] =ctor-args (&/map% (fn [ctor-arg] (|let [[arg-type arg-term] ctor-arg] (|do [=arg-term (&&/analyse-1+ analyse arg-term)] diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 1281df4e6..3bf0eaf08 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -85,7 +85,7 @@ ;; Type (defvariant - ("Host" 2) + ("Primitive" 2) ("Void" 0) ("Unit" 0) ("Sum" 2) diff --git a/luxc/src/lux/compiler/cache/type.clj b/luxc/src/lux/compiler/cache/type.clj index 04fb01540..88e1d5a03 100644 --- a/luxc/src/lux/compiler/cache/type.clj +++ b/luxc/src/lux/compiler/cache/type.clj @@ -24,7 +24,7 @@ (if (clojure.lang.Util/identical &type/Type type) "T" (|case type - (&/$Host name params) + (&/$Primitive name params) (str "^" name stop (serialize-list serialize-type params)) (&/$Void) @@ -137,7 +137,7 @@ (when (.startsWith input "^") (let [[name ^String input*] (.split (.substring input 1) stop 2)] (when-let [[params ^String input*] (deserialize-list input*)] - [(&/$Host name params) input*])))) + [(&/$Primitive name params) input*])))) (defn deserialize-type "(-> Text Type)" diff --git a/luxc/src/lux/compiler/jvm/proc/host.clj b/luxc/src/lux/compiler/jvm/proc/host.clj index 18b140176..3d68bda68 100644 --- a/luxc/src/lux/compiler/jvm/proc/host.clj +++ b/luxc/src/lux/compiler/jvm/proc/host.clj @@ -51,31 +51,31 @@ (&/$Unit) (.visitLdcInsn *writer* &/unit-tag) - (&/$Host "boolean" (&/$Nil)) + (&/$Primitive "boolean" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name boolean-class) "valueOf" (str "(Z)" (&host-generics/->type-signature boolean-class))) - (&/$Host "byte" (&/$Nil)) + (&/$Primitive "byte" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name byte-class) "valueOf" (str "(B)" (&host-generics/->type-signature byte-class))) - (&/$Host "short" (&/$Nil)) + (&/$Primitive "short" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name short-class) "valueOf" (str "(S)" (&host-generics/->type-signature short-class))) - (&/$Host "int" (&/$Nil)) + (&/$Primitive "int" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name int-class) "valueOf" (str "(I)" (&host-generics/->type-signature int-class))) - (&/$Host "long" (&/$Nil)) + (&/$Primitive "long" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name long-class) "valueOf" (str "(J)" (&host-generics/->type-signature long-class))) - (&/$Host "float" (&/$Nil)) + (&/$Primitive "float" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name float-class) "valueOf" (str "(F)" (&host-generics/->type-signature float-class))) - (&/$Host "double" (&/$Nil)) + (&/$Primitive "double" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name double-class) "valueOf" (str "(D)" (&host-generics/->type-signature double-class))) - (&/$Host "char" (&/$Nil)) + (&/$Primitive "char" (&/$Nil)) (.visitMethodInsn *writer* Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name char-class) "valueOf" (str "(C)" (&host-generics/->type-signature char-class))) - (&/$Host _ _) + (&/$Primitive _ _) nil (&/$Named ?name ?type) diff --git a/luxc/src/lux/host.clj b/luxc/src/lux/host.clj index 7ee553d53..97d2bd69d 100644 --- a/luxc/src/lux/host.clj +++ b/luxc/src/lux/host.clj @@ -30,7 +30,7 @@ (defn unfold-array [type] "(-> Type (, Int Type))" (|case type - (&/$Host "#Array" (&/$Cons param (&/$Nil))) + (&/$Primitive "#Array" (&/$Cons param (&/$Nil))) (|let [[count inner] (unfold-array param)] (&/T [(inc count) inner])) @@ -42,10 +42,10 @@ (defn ->java-sig [^objects type] "(-> Type (Lux Text))" (|case type - (&/$Host ?name params) + (&/$Primitive ?name params) (cond (= &host-type/array-data-tag ?name) (|do [:let [[level base] (unfold-array type)] base-sig (|case base - (&/$Host base-class _) + (&/$Primitive base-class _) (return (&host-generics/->type-signature base-class)) _ diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index 6de9b7086..0834db3a6 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -23,17 +23,17 @@ (def empty-env &/$Nil) -(def Bool (&/$Named (&/T ["lux" "Bool"]) (&/$Host "#Bool" &/$Nil))) -(def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Host &&host/nat-data-tag &/$Nil))) -(def Deg (&/$Named (&/T ["lux" "Deg"]) (&/$Host &&host/deg-data-tag &/$Nil))) -(def Int (&/$Named (&/T ["lux" "Int"]) (&/$Host "#Int" &/$Nil))) -(def Frac (&/$Named (&/T ["lux" "Frac"]) (&/$Host "#Frac" &/$Nil))) -(def Text (&/$Named (&/T ["lux" "Text"]) (&/$Host "#Text" &/$Nil))) +(def Bool (&/$Named (&/T ["lux" "Bool"]) (&/$Primitive "#Bool" &/$Nil))) +(def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Primitive &&host/nat-data-tag &/$Nil))) +(def Deg (&/$Named (&/T ["lux" "Deg"]) (&/$Primitive &&host/deg-data-tag &/$Nil))) +(def Int (&/$Named (&/T ["lux" "Int"]) (&/$Primitive "#Int" &/$Nil))) +(def Frac (&/$Named (&/T ["lux" "Frac"]) (&/$Primitive "#Frac" &/$Nil))) +(def Text (&/$Named (&/T ["lux" "Text"]) (&/$Primitive "#Text" &/$Nil))) (def Ident (&/$Named (&/T ["lux" "Ident"]) (&/$Product Text Text))) (do-template [<name> <tag>] (defn <name> [elem-type] - (&/$Host <tag> (&/|list elem-type))) + (&/$Primitive <tag> (&/|list elem-type))) Array "#Array" Atom "#Atom" @@ -83,7 +83,7 @@ (&/$Apply &/$Void (&/$UnivQ empty-env (&/$Sum - ;; Host + ;; Primitive (&/$Product Text TypeList) (&/$Sum ;; Void @@ -222,7 +222,7 @@ (&/$None) (return* (&/update$ &/$type-context (fn [ts] (&/update$ &/$var-bindings #(&/|put id (&/$Some type) %) - ts)) + ts)) state) nil)) ((&/fail-with-loc (str "[Type Error] Unknown type-var: " id " | " (->> state (&/get$ &/$type-context) (&/get$ &/$var-bindings) &/|length))) @@ -345,9 +345,9 @@ (return type))) ) - (&/$Host ?name ?params) + (&/$Primitive ?name ?params) (|do [=params (&/map% (partial clean* ?tid) ?params)] - (return (&/$Host ?name =params))) + (return (&/$Primitive ?name =params))) (&/$Function ?arg ?return) (|do [=arg (clean* ?tid ?arg) @@ -456,13 +456,13 @@ (defn show-type [^objects type] (|case type - (&/$Host name params) + (&/$Primitive name params) (|case params (&/$Nil) - (str "(host " name ")") + (str "(primitive " name ")") _ - (str "(host " name " " (->> params (&/|map show-type) (&/|interpose " ") (&/fold str "")) ")")) + (str "(primitive " name " " (->> params (&/|map show-type) (&/|interpose " ") (&/fold str "")) ")")) (&/$Void) "Void" @@ -514,7 +514,7 @@ (and (= ?xmodule ?ymodule) (= ?xname ?yname)) - [(&/$Host xname xparams) (&/$Host yname yparams)] + [(&/$Primitive xname xparams) (&/$Primitive yname yparams)] (and (.equals ^Object xname yname) (= (&/|length xparams) (&/|length yparams)) (&/fold2 #(and %1 (type= %2 %3)) true xparams yparams)) @@ -604,8 +604,8 @@ (defn beta-reduce [env type] (|case type - (&/$Host ?name ?params) - (&/$Host ?name (&/|map (partial beta-reduce env) ?params)) + (&/$Primitive ?name ?params) + (&/$Primitive ?name (&/|map (partial beta-reduce env) ?params)) (&/$Sum ?left ?right) (&/$Sum (beta-reduce env ?left) (beta-reduce env ?right)) @@ -841,7 +841,7 @@ actual* (apply-type actual $arg)] (check* fixpoints invariant?? expected actual*)) - [(&/$Host e!data) (&/$Host a!data)] + [(&/$Primitive e!data) (&/$Primitive a!data)] (|do [? &/jvm?] (if ? (|do [class-loader &/loader] diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 74ef262c6..c4d4ef243 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -77,18 +77,18 @@ (let [gclass-name (.getName class)] (case gclass-name ("[Z" "[B" "[S" "[I" "[J" "[F" "[D" "[C") - (&/$Host gclass-name (&/|list)) + (&/$Primitive gclass-name (&/|list)) ;; else (if-let [[_ _ arr-obrackets arr-obase simple-base arr-pbrackets arr-pbase] (re-find class-name-re gclass-name)] (let [base (or arr-obase simple-base (jprim->lprim arr-pbase))] (if (.equals "void" base) &/$Unit - (reduce (fn [inner _] (&/$Host array-data-tag (&/|list inner))) - (&/$Host base (try (-> (Class/forName base) .getTypeParameters - seq count (repeat (&/$Host "java.lang.Object" &/$Nil)) - &/->list) - (catch Exception e - (&/|list)))) + (reduce (fn [inner _] (&/$Primitive array-data-tag (&/|list inner))) + (&/$Primitive base (try (-> (Class/forName base) .getTypeParameters + seq count (repeat (&/$Primitive "java.lang.Object" &/$Nil)) + &/->list) + (catch Exception e + (&/|list)))) (range (count (or arr-obrackets arr-pbrackets ""))))) )))))) @@ -99,7 +99,7 @@ (instance? GenericArrayType refl-type) (|do [inner-type (instance-param existential matchings (.getGenericComponentType ^GenericArrayType refl-type))] - (return (&/$Host array-data-tag (&/|list inner-type)))) + (return (&/$Primitive array-data-tag (&/|list inner-type)))) (instance? ParameterizedType refl-type) (|do [:let [refl-type* ^ParameterizedType refl-type] @@ -107,8 +107,8 @@ .getActualTypeArguments seq &/->list (&/map% (partial instance-param existential matchings)))] - (return (&/$Host (->> refl-type* ^Class (.getRawType) .getName) - params*))) + (return (&/$Primitive (->> refl-type* ^Class (.getRawType) .getName) + params*))) (instance? TypeVariable refl-type) (let [gvar (.getName ^TypeVariable refl-type)] @@ -127,10 +127,10 @@ (defn principal-class [refl-type] (cond (instance? Class refl-type) (|case (class->type refl-type) - (&/$Host "#Array" (&/$Cons (&/$Host class-name _) (&/$Nil))) + (&/$Primitive "#Array" (&/$Cons (&/$Primitive class-name _) (&/$Nil))) (str "[" (&host-generics/->type-signature class-name)) - (&/$Host class-name _) + (&/$Primitive class-name _) (&host-generics/->type-signature class-name) (&/$Unit) @@ -157,7 +157,7 @@ (|case gtype (&/$GenericArray component-type) (|do [inner-type (instance-gtype existential matchings component-type)] - (return (&/$Host array-data-tag (&/|list inner-type)))) + (return (&/$Primitive array-data-tag (&/|list inner-type)))) (&/$GenericClass type-name type-params) ;; When referring to type-parameters during class or method @@ -171,7 +171,7 @@ (return m-type) (|do [params* (&/map% (partial instance-gtype existential matchings) type-params)] - (return (&/$Host type-name params*)))) + (return (&/$Primitive type-name params*)))) (&/$GenericTypeVar var-name) (if-let [m-type (&/|get var-name matchings)] @@ -232,7 +232,7 @@ (if (.isAssignableFrom super-class+ sub-class+) (let [lineage (trace-lineage sub-class+ super-class+)] (|do [[^Class sub-class* sub-params*] (raise existential lineage sub-class+ sub-params)] - (return (&/$Host (.getName sub-class*) sub-params*)))) + (return (&/$Primitive (.getName sub-class*) sub-params*)))) (&/fail-with-loc (str "[Host Error] Classes do not have a subtyping relationship: " sub-class " </= " super-class))))) (defn as-obj [class] @@ -271,7 +271,7 @@ (if (= (&/|length e!params) (&/|length a!params)) (|do [_ (&/map2% check e!params a!params)] (return fixpoints)) - (check-error "" (&/$Host e!name e!params) (&/$Host a!name a!params))) + (check-error "" (&/$Primitive e!name e!params) (&/$Primitive a!name a!params))) (or (lux-type? e!name) (lux-type? a!name)) @@ -280,14 +280,14 @@ (and (not (primitive-type? e!name)) (= null-data-tag a!name))) (return fixpoints) - (check-error "" (&/$Host e!name e!params) (&/$Host a!name a!params))) + (check-error "" (&/$Primitive e!name e!params) (&/$Primitive a!name a!params))) (not invariant??) (|do [actual* (->super-type existential class-loader e!name a!name a!params)] - (check (&/$Host e!name e!params) actual*)) + (check (&/$Primitive e!name e!params) actual*)) :else - (check-error "" (&/$Host e!name e!params) (&/$Host a!name a!params)))) + (check-error "" (&/$Primitive e!name e!params) (&/$Primitive a!name a!params)))) (catch Exception e (throw e))))) |