aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser/base.clj1
-rw-r--r--luxc/src/lux/analyser/lux.clj17
-rw-r--r--luxc/src/lux/base.clj2
-rw-r--r--luxc/src/lux/compiler/js.clj2
-rw-r--r--luxc/src/lux/compiler/jvm.clj2
-rw-r--r--luxc/src/lux/compiler/jvm/lux.clj2
-rw-r--r--luxc/src/lux/optimizer.clj9
7 files changed, 12 insertions, 23 deletions
diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj
index cbcb71933..e1678fb2b 100644
--- a/luxc/src/lux/analyser/base.clj
+++ b/luxc/src/lux/analyser/base.clj
@@ -19,6 +19,7 @@
("case" 2)
("function" 4)
("ann" 2)
+ ("def" 1)
("var" 1)
("captured" 1)
("proc" 3)
diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj
index 16ba17583..e10810475 100644
--- a/luxc/src/lux/analyser/lux.clj
+++ b/luxc/src/lux/analyser/lux.clj
@@ -271,7 +271,7 @@
(&type/check exo-type endo-type))
_cursor &/cursor]
(return (&/|list (&&/|meta endo-type _cursor
- (&&/$var (&/$Global (&/T [r-module r-name]))))))))
+ (&&/$def (&/T [r-module r-name])))))))
(defn ^:private analyse-local [analyse exo-type name]
(fn [state]
@@ -285,19 +285,6 @@
(analyse-global analyse exo-type module-name name))
state)
- (&/$Cons ?genv (&/$Nil))
- (if-let [global (->> ?genv (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name))]
- (|case global
- [(&/$Global ?module* name*) _]
- (&/run-state (analyse-global analyse exo-type ?module* name*)
- state)
-
- _
- ((&/fail-with-loc "[Analyser Error] Cannot have anything other than a global def in the global environment.")
- state))
- ((&/fail-with-loc (str "[Analyser Error] Unknown global definition: " name))
- state))
-
(&/$Cons bottom-outer _)
(|let [scopes (&/|map #(&/get$ &/$name %) (&/|reverse inner))
[=local inner*] (&/fold2 (fn [register+new-inner frame in-scope]
@@ -377,7 +364,7 @@
(defn analyse-apply [analyse cursor exo-type macro-caller =fn ?args]
(|case =fn
- [_ (&&/$var (&/$Global ?module ?name))]
+ [_ (&&/$def ?module ?name)]
(|do [[real-name [?type ?meta ?value]] (&&module/find-def ?module ?name)]
(|case (&&meta/meta-get &&meta/macro?-tag ?meta)
(&/$Some _)
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj
index bdbffdf35..95c78bc02 100644
--- a/luxc/src/lux/base.clj
+++ b/luxc/src/lux/base.clj
@@ -103,7 +103,7 @@
;; Vars
(defvariant
("Local" 1)
- ("Global" 1))
+ ("Captured" 1))
;; Binding
(deftuple
diff --git a/luxc/src/lux/compiler/js.clj b/luxc/src/lux/compiler/js.clj
index 68d4e0997..0f87050f6 100644
--- a/luxc/src/lux/compiler/js.clj
+++ b/luxc/src/lux/compiler/js.clj
@@ -66,7 +66,7 @@
(&o/$captured ?scope ?captured-id ?source)
(&&lux/compile-captured compile-expression ?scope ?captured-id ?source)
- (&o/$var (&/$Global ?module ?name))
+ (&o/$def ?module ?name)
(&&lux/compile-global ?module ?name)
(&o/$apply ?fn ?args)
diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj
index b612c9f35..972fdfb6d 100644
--- a/luxc/src/lux/compiler/jvm.clj
+++ b/luxc/src/lux/compiler/jvm.clj
@@ -77,7 +77,7 @@
(&o/$captured ?scope ?captured-id ?source)
(&&lux/compile-captured (partial compile-expression $begin) ?scope ?captured-id ?source)
- (&o/$var (&/$Global ?owner-class ?name))
+ (&o/$def ?owner-class ?name)
(&&lux/compile-global (partial compile-expression $begin) ?owner-class ?name)
(&o/$apply ?fn ?args)
diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/luxc/src/lux/compiler/jvm/lux.clj
index 882c9b74c..bb7dda339 100644
--- a/luxc/src/lux/compiler/jvm/lux.clj
+++ b/luxc/src/lux/compiler/jvm/lux.clj
@@ -117,7 +117,7 @@
(defn compile-apply [compile ?fn ?args]
(|case ?fn
- [_ (&o/$var (&/$Global ?module ?name))]
+ [_ (&o/$def ?module ?name)]
(|do [[_ [_ _ func-obj]] (&a-module/find-def ?module ?name)
class-loader &/loader
:let [func-class (class func-obj)
diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj
index 36caf3362..d83ac3014 100644
--- a/luxc/src/lux/optimizer.clj
+++ b/luxc/src/lux/optimizer.clj
@@ -19,6 +19,7 @@
("case" 2)
("function" 5)
("ann" 2)
+ ("def" 1)
("var" 1)
("captured" 3)
("proc" 3)
@@ -734,10 +735,7 @@
(&/|list [meta ($var (&/$Local 1))]))])
(&/$Local idx)
- (&/T [meta ($var (&/$Local (inc idx)))])
-
- (&/$Global ?module ?name)
- body)
+ (&/T [meta ($var (&/$Local (inc idx)))]))
body)
;; This special "apply" rule is for handling recursive calls better.
@@ -1177,6 +1175,9 @@
(&a/$ann value-expr type-expr)
(&/T [meta ($ann (pass-0 top-level-func? value-expr) type-expr)])
+ (&a/$def def-name)
+ (&/T [meta ($def def-name)])
+
(&a/$var var-kind)
(&/T [meta ($var var-kind)])