aboutsummaryrefslogtreecommitdiff
path: root/luxc/src/lux/analyser/proc
diff options
context:
space:
mode:
Diffstat (limited to 'luxc/src/lux/analyser/proc')
-rw-r--r--luxc/src/lux/analyser/proc/common.clj22
-rw-r--r--luxc/src/lux/analyser/proc/js.clj93
-rw-r--r--luxc/src/lux/analyser/proc/jvm.clj16
3 files changed, 19 insertions, 112 deletions
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]