diff options
author | Eduardo Julian | 2018-05-20 21:04:03 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-20 21:04:03 -0400 |
commit | 14e96f5e5dad439383d63e60a52169cc2e7aaa5c (patch) | |
tree | 606398bbf6742a476a2599d9b25c184c71eae5c7 /luxc/src | |
parent | 19d38211c33faf6d5fe01665982d696643f60051 (diff) |
- Re-named "Top" to "Any", and "Bottom" to "Nothing".
- Removed some modules that should have been deleted before.
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/analyser.clj | 9 | ||||
-rw-r--r-- | luxc/src/lux/analyser/case.clj | 6 | ||||
-rw-r--r-- | luxc/src/lux/analyser/lux.clj | 4 | ||||
-rw-r--r-- | luxc/src/lux/analyser/module.clj | 4 | ||||
-rw-r--r-- | luxc/src/lux/analyser/proc/common.clj | 22 | ||||
-rw-r--r-- | luxc/src/lux/analyser/proc/js.clj | 93 | ||||
-rw-r--r-- | luxc/src/lux/analyser/proc/jvm.clj | 16 | ||||
-rw-r--r-- | luxc/src/lux/analyser/record.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/base.clj | 4 | ||||
-rw-r--r-- | luxc/src/lux/compiler/jvm/proc/host.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/host.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/type.clj | 24 | ||||
-rw-r--r-- | luxc/src/lux/type/host.clj | 8 |
13 files changed, 49 insertions, 147 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index 29c9e7588..641dfa947 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -12,8 +12,7 @@ [module :as &&module] [parser :as &&a-parser]) (lux.analyser.proc [common :as &&common] - [jvm :as &&jvm] - [js :as &&js]))) + [jvm :as &&jvm]))) ;; [Utils] (defn analyse-variant+ [analyse exo-type ident values] @@ -172,10 +171,6 @@ (|do [_ &/jvm-host] (&&jvm/analyse-host analyse exo-type compilers ?procedure parameters)) - (.startsWith ^String ?procedure "js") - (|do [_ &/js-host] - (&&js/analyse-host analyse exo-type ?procedure parameters)) - :else (&&common/analyse-proc analyse exo-type ?procedure parameters)))) @@ -199,7 +194,7 @@ ;; [Resources] (defn analyse [optimize eval! compile-module compilers] (|do [asts &parser/parse] - (&/flat-map% (partial analyse-ast optimize eval! compile-module compilers &type/Bottom) asts))) + (&/flat-map% (partial analyse-ast optimize eval! compile-module compilers &type/Nothing) asts))) (defn clean-output [?var analysis] (|do [:let [[[?output-type ?output-cursor] ?output-term] analysis] diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index ff00f1aa8..2694c9447 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -38,7 +38,7 @@ (&/T [(&/T ["" -1 -1]) (&/$Tuple &/$Nil)])) (defn ^:private resolve-type [type] - (if (&type/type= &type/Top type) + (if (&type/type= &type/Any type) (return type) (|case type (&/$Var ?id) @@ -301,7 +301,7 @@ (&/$Tuple ?members) (|case ?members (&/$Nil) - (|do [_ (&type/check value-type &type/Top) + (|do [_ (&type/check value-type &type/Any) =kont kont] (return (&/T [($TupleTestAC (&/|list)) =kont]))) @@ -579,7 +579,7 @@ (|case ?structs (&/$Nil) (|do [value-type* (resolve-type value-type)] - (if (&type/type= &type/Top value-type*) + (if (&type/type= &type/Any value-type*) (return true) (&/fail-with-loc "[Pattern-maching Error] Unit is not total."))) diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index 639d71cb6..781f9854b 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -45,7 +45,7 @@ ;; [Exports] (defn analyse-unit [analyse ?exo-type] (|do [_cursor &/cursor - _ (&type/check ?exo-type &type/Top)] + _ (&type/check ?exo-type &type/Any)] (return (&/|list (&&/|meta ?exo-type _cursor (&&/$tuple (&/|list))))))) @@ -689,7 +689,7 @@ (return (&/|list (coerce ==type =value))))) (let [program-type (&/$Function (&/$Apply &type/Text &type/List) - (&/$Apply &type/Top &type/IO))] + (&/$Apply &type/Any &type/IO))] (defn analyse-program [analyse optimize compile-program ?program] (|do [_ &/ensure-statement =program (&&/analyse-1 analyse program-type ?program) diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj index fca407c4b..130004701 100644 --- a/luxc/src/lux/analyser/module.clj +++ b/luxc/src/lux/analyser/module.clj @@ -49,7 +49,7 @@ (do-template [<flagger> <asker> <tag>] (do (defn <flagger> - "(-> Text (Lux Top))" + "(-> Text (Lux Any))" [module-name] (fn [state] (let [state* (&/update$ &/$modules @@ -382,7 +382,7 @@ state))))) (defn ensure-can-see-tag - "(-> Text Text (Lux Top))" + "(-> Text Text (Lux Any))" [module tag-name] (|do [current-module &/get-module-name] (fn [state] diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 19d833cc2..ac5900634 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -122,7 +122,7 @@ (&/|list))))))) (do-template [<name> <op>] - (let [inputT (&/$Apply &type/Top &type/I64) + (let [inputT (&/$Apply &type/Any &type/I64) outputT &type/I64] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons mask (&/$Cons input (&/$Nil))) ?values] @@ -139,7 +139,7 @@ ) (do-template [<name> <op>] - (let [inputT (&/$Apply &type/Top &type/I64) + (let [inputT (&/$Apply &type/Any &type/I64) outputT &type/I64] (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons shift (&/$Cons input (&/$Nil))) ?values] @@ -167,9 +167,9 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T <proc>) (&/|list subjectA paramA) (&/|list)))))))) - ^:private analyse-i64-eq ["i64" "="] (&/$Apply &type/Top &type/I64) &type/Bool - ^:private analyse-i64-add ["i64" "+"] (&/$Apply &type/Top &type/I64) &type/I64 - ^:private analyse-i64-sub ["i64" "-"] (&/$Apply &type/Top &type/I64) &type/I64 + ^:private analyse-i64-eq ["i64" "="] (&/$Apply &type/Any &type/I64) &type/Bool + ^:private analyse-i64-add ["i64" "+"] (&/$Apply &type/Any &type/I64) &type/I64 + ^:private analyse-i64-sub ["i64" "-"] (&/$Apply &type/Any &type/I64) &type/I64 ) (do-template [<name> <proc> <input-type> <output-type>] @@ -248,9 +248,9 @@ ^:private analyse-int-frac &type/Int &type/Frac ["int" "frac"] ^:private analyse-frac-int &type/Frac &type/Int ["frac" "int"] - ^:private analyse-io-log &type/Text &type/Top ["io" "log"] - ^:private analyse-io-error &type/Text &type/Bottom ["io" "error"] - ^:private analyse-io-exit &type/Int &type/Bottom ["io" "exit"] + ^:private analyse-io-log &type/Text &type/Any ["io" "log"] + ^:private analyse-io-error &type/Text &type/Nothing ["io" "error"] + ^:private analyse-io-exit &type/Int &type/Nothing ["io" "exit"] ) (defn ^:private analyse-io-current-time [analyse exo-type ?values] @@ -410,7 +410,7 @@ (|do [:let [(&/$Cons valueC (&/$Cons boxC (&/$Nil))) ?values] boxA (&&/analyse-1 analyse (&type/Box threadT valueT) boxC) valueA (&&/analyse-1 analyse valueT valueC) - _ (&type/check exo-type &type/Top) + _ (&type/check exo-type &type/Any) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["box" "write"]) (&/|list valueA boxA) (&/|list))))))))))) @@ -425,8 +425,8 @@ (defn ^:private analyse-process-schedule [analyse exo-type ?values] (|do [:let [(&/$Cons ?milliseconds (&/$Cons ?procedure (&/$Nil))) ?values] =milliseconds (&&/analyse-1 analyse &type/Nat ?milliseconds) - =procedure (&&/analyse-1 analyse (&/$Apply &type/Top &type/IO) ?procedure) - _ (&type/check exo-type &type/Top) + =procedure (&&/analyse-1 analyse (&/$Apply &type/Any &type/IO) ?procedure) + _ (&type/check exo-type &type/Any) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["process" "schedule"]) (&/|list =milliseconds =procedure) (&/|list))))))) diff --git a/luxc/src/lux/analyser/proc/js.clj b/luxc/src/lux/analyser/proc/js.clj deleted file mode 100644 index 8b218ee43..000000000 --- a/luxc/src/lux/analyser/proc/js.clj +++ /dev/null @@ -1,93 +0,0 @@ -(ns lux.analyser.proc.js - (:require (clojure [template :refer [do-template]] - [string :as string]) - clojure.core.match - clojure.core.match.array - (lux [base :as & :refer [|let |do return* return |case assert!]] - [type :as &type]) - (lux.analyser [base :as &&]))) - -(do-template [<name> <proc>] - (defn <name> [analyse exo-type ?values] - (|do [:let [(&/$Cons ?function ?args) ?values] - =function (&&/analyse-1 analyse (&/$Primitive "function" &/$Nil) ?function) - =args (&/map% (partial &&/analyse-1+ analyse) ?args) - _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["js" <proc>]) (&/$Cons =function =args) (&/|list))))))) - - ^:private analyse-js-new "new" - ^:private analyse-js-call "call" - ) - -(defn ^:private analyse-js-object-call [analyse exo-type ?values] - (|do [:let [(&/$Cons ?object (&/$Cons ?field ?args)) ?values] - =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 (&/$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 (&/$Primitive "object" &/$Nil)) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["js" "ref"]) (&/|list) (&/|list ?ref-name))))))) - -(do-template [<name> <proc>] - (defn <name> [analyse exo-type ?values] - (|do [:let [(&/$Cons ?object (&/$Cons ?field (&/$Nil))) ?values] - =object (&&/analyse-1 analyse (&/$Primitive "object" &/$Nil) ?object) - =field (&&/analyse-1 analyse &type/Text ?field) - _ (&type/check exo-type (&/$Primitive "object" &/$Nil)) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["js" <proc>]) (&/|list =object =field) (&/|list))))))) - - ^:private analyse-js-get-field "get-field" - ^:private analyse-js-delete-field "delete-field" - ) - -(defn ^:private analyse-js-set-field [analyse exo-type ?values] - (|do [:let [(&/$Cons ?object (&/$Cons ?field (&/$Cons ?value (&/$Nil)))) ?values] - =object (&&/analyse-1 analyse (&/$Primitive "object" &/$Nil) ?object) - =field (&&/analyse-1 analyse &type/Text ?field) - =value (&&/analyse-1+ analyse ?value) - _ (&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))))))) - -(do-template [<name> <proc> <type>] - (defn <name> [analyse exo-type ?values] - (|do [:let [(&/$Nil) ?values] - :let [output-type (&/$Primitive <type> &/$Nil)] - _ (&type/check exo-type output-type) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["js" <proc>]) (&/|list) (&/|list))))))) - - ^:private analyse-js-object "object" "object" - ^:private analyse-js-null "null" "object" - ^:private analyse-js-undefined "undefined" "undefined" - ) - -(defn analyse-host [analyse exo-type proc ?values] - (case proc - "new" (analyse-js-new analyse exo-type ?values) - "call" (analyse-js-call analyse exo-type ?values) - "object-call" (analyse-js-object-call analyse exo-type ?values) - "ref" (analyse-js-ref analyse exo-type ?values) - "object" (analyse-js-object analyse exo-type ?values) - "get-field" (analyse-js-get-field analyse exo-type ?values) - "set-field" (analyse-js-set-field analyse exo-type ?values) - "delete-field" (analyse-js-delete-field analyse exo-type ?values) - "null" (analyse-js-null analyse exo-type ?values) - "undefined" (analyse-js-undefined analyse exo-type ?values) - ;; else - (&/fail-with-loc (str "[Analyser Error] Unknown host procedure: " ["js" proc]))) - ) diff --git a/luxc/src/lux/analyser/proc/jvm.clj b/luxc/src/lux/analyser/proc/jvm.clj index 2eef1082c..8ad13c74b 100644 --- a/luxc/src/lux/analyser/proc/jvm.clj +++ b/luxc/src/lux/analyser/proc/jvm.clj @@ -194,7 +194,7 @@ "float" (return (&/$Primitive "java.lang.Float" &/$Nil)) "double" (return (&/$Primitive "java.lang.Double" &/$Nil)) "char" (return (&/$Primitive "java.lang.Character" &/$Nil)) - "void" (return &type/Top) + "void" (return &type/Any) ;; else (|do [=params (&/map% (partial generic-class->type env) params)] (return (&/$Primitive name =params)))) @@ -252,7 +252,7 @@ itype (generic-class->type full-env itype*)] (if (double-register-gclass? itype*) (&&env/with-local iname itype - (&&env/with-local "" &type/Bottom + (&&env/with-local "" &type/Nothing body*)) (&&env/with-local iname itype body*))))) @@ -265,7 +265,7 @@ (&/$ConstructorMethodSyntax =privacy-modifier ?strict ?anns ?gvars ?exceptions ?inputs ?ctor-args ?body) (|do [method-env (make-type-env ?gvars) :let [full-env (&/|++ class-env method-env)] - :let [output-type &type/Top] + :let [output-type &type/Any] =ctor-args (&/map% (fn [ctor-arg] (|do [:let [[ca-type ca-term] ctor-arg] =ca-type (generic-class->type full-env ca-type) @@ -635,7 +635,7 @@ _ (&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)] + _ (&type/check exo-type &type/Nothing)] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["jvm" "throw"]) (&/|list =ex) (&/|list))))))) @@ -673,7 +673,7 @@ :let [gclass (&host-type/gtype->gclass gtype)] =type (&host-type/instance-param &type/existential &/$Nil gtype) =value (&&/analyse-1 analyse =type value) - :let [output-type &type/Top] + :let [output-type &type/Any] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor @@ -690,7 +690,7 @@ :let [gclass (&host-type/gtype->gclass gtype)] =type (analyse-field-access-helper obj-type gvars gtype) =value (&&/analyse-1 analyse =type value) - :let [output-type &type/Top] + :let [output-type &type/Any] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor @@ -829,7 +829,7 @@ _ (compile-interface interface-decl supers =anns =methods) :let [_ (println 'INTERFACE (str module "." (&/|first interface-decl)))] _cursor &/cursor] - (return (&/|list (&&/|meta &type/Top _cursor + (return (&/|list (&&/|meta &type/Any _cursor (&&/$tuple (&/|list))))))) (defn ^:private analyse-jvm-class [analyse compile-class class-decl super-class interfaces =inheritance-modifier =anns ?fields methods] @@ -848,7 +848,7 @@ _ &/pop-dummy-name :let [_ (println 'CLASS full-name)] _cursor &/cursor] - (return (&/|list (&&/|meta &type/Top _cursor + (return (&/|list (&&/|meta &type/Any _cursor (&&/$tuple (&/|list)))))))) (defn ^:private captured-source [env-entry] diff --git a/luxc/src/lux/analyser/record.clj b/luxc/src/lux/analyser/record.clj index 595858873..3d3d8169f 100644 --- a/luxc/src/lux/analyser/record.clj +++ b/luxc/src/lux/analyser/record.clj @@ -11,7 +11,7 @@ "(-> (List (, Syntax Syntax)) (Lux (List Syntax)))" (|do [[tag-group tag-type] (|case pairs (&/$Nil) - (return (&/T [&/$Nil &type/Top])) + (return (&/T [&/$Nil &type/Any])) (&/$Cons [[_ (&/$Tag tag1)] _] _) (|do [[module name] (&&/resolved-ident tag1) diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 8867d0b1e..e1f48d23b 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -1070,7 +1070,7 @@ _ output)))))) -(def ^{:doc "(Meta Top)"} +(def ^{:doc "(Meta Any)"} ensure-statement (fn [state] (|case (get$ $expected state) @@ -1325,7 +1325,7 @@ (return* state (|keys (get$ $modules state))))) (defn when% - "(-> Bool (Meta Top) (Meta Top))" + "(-> Bool (Meta Any) (Meta Any))" [test body] (if test body diff --git a/luxc/src/lux/compiler/jvm/proc/host.clj b/luxc/src/lux/compiler/jvm/proc/host.clj index da2c5ccde..91c39effb 100644 --- a/luxc/src/lux/compiler/jvm/proc/host.clj +++ b/luxc/src/lux/compiler/jvm/proc/host.clj @@ -47,7 +47,7 @@ double-class "java.lang.Double" char-class "java.lang.Character"] (defn prepare-return! [^MethodVisitor *writer* *type*] - (if (&type/type= &type/Top *type*) + (if (&type/type= &type/Any *type*) (.visitLdcInsn *writer* &/unit-tag) (|case *type* (&/$Primitive "boolean" (&/$Nil)) diff --git a/luxc/src/lux/host.clj b/luxc/src/lux/host.clj index 3f0181c99..5b93f5b49 100644 --- a/luxc/src/lux/host.clj +++ b/luxc/src/lux/host.clj @@ -75,7 +75,7 @@ (return ex-type-class) _ - (if (&type/type= &type/Top type) + (if (&type/type= &type/Any type) (return "V") (assert false (str '->java-sig " " (&type/show-type type)))) ))) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index c2650c5b8..3a7b7cc9b 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -53,27 +53,27 @@ Box "#Box" ) -(def Bottom - (&/$Named (&/T ["lux" "Bottom"]) +(def Nothing + (&/$Named (&/T ["lux" "Nothing"]) (&/$UnivQ empty-env (&/$Bound 1)))) -(def Top - (&/$Named (&/T ["lux" "Top"]) +(def Any + (&/$Named (&/T ["lux" "Any"]) (&/$ExQ empty-env (&/$Bound 1)))) (def IO (&/$Named (&/T ["lux/codata" "IO"]) (&/$UnivQ empty-env - (&/$Function Bottom (&/$Bound 1))))) + (&/$Function Nothing (&/$Bound 1))))) (def List (&/$Named (&/T ["lux" "List"]) (&/$UnivQ empty-env (&/$Sum ;; lux;Nil - Top + Any ;; lux;Cons (&/$Product (&/$Bound 1) (&/$Apply (&/$Bound 1) @@ -84,7 +84,7 @@ (&/$UnivQ empty-env (&/$Sum ;; lux;None - Top + Any ;; lux;Some (&/$Bound 1)) ))) @@ -94,7 +94,7 @@ (let [Type (&/$Apply (&/$Bound 1) (&/$Bound 0)) TypeList (&/$Apply Type List) TypePair (&/$Product Type Type)] - (&/$Apply Bottom + (&/$Apply Nothing (&/$UnivQ empty-env (&/$Sum ;; Primitive @@ -424,8 +424,8 @@ (&/$Nil) <unit>)) - Variant$ &/$Sum Bottom - Tuple$ &/$Product Top + Variant$ &/$Sum Nothing + Tuple$ &/$Product Any ) (defn show-type [^objects type] @@ -930,8 +930,8 @@ (&/$Cons last prevs) (&/fold (fn [r l] (<plus> l r)) last prevs))) - fold-prod Top &/$Product - fold-sum Bottom &/$Sum + fold-prod Any &/$Product + fold-sum Nothing &/$Sum ) (def create-var+ diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index d56e85fd7..bb7459c48 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -58,8 +58,8 @@ )] output))) -(def ^:private Top - (&/$Named (&/T ["lux" "Top"]) +(def ^:private Any + (&/$Named (&/T ["lux" "Any"]) (&/$ExQ (&/|list) (&/$Bound 1)))) @@ -139,7 +139,7 @@ (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) - Top + Any (reduce (fn [inner _] (&/$Primitive array-data-tag (&/|list inner))) (&/$Primitive base (try (-> (Class/forName base) .getTypeParameters seq count (repeat (&/$Primitive "java.lang.Object" &/$Nil)) @@ -184,7 +184,7 @@ (defn principal-class [refl-type] (cond (instance? Class refl-type) (let [class-type (class->type refl-type)] - (if (type= Top class-type) + (if (type= Any class-type) "V" (|case class-type (&/$Primitive "#Array" (&/$Cons (&/$Primitive class-name _) (&/$Nil))) |