aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
authorEduardo Julian2020-10-12 20:22:31 -0400
committerEduardo Julian2020-10-12 20:22:31 -0400
commit00d5ccbc043960037f644d4ff09b6a46fd0093d0 (patch)
tree9515edc59fb511fa30e68c832d669654853ff702 /luxc/src
parent5b222d040ee361dd4022e88488a6bcef3ca40a71 (diff)
Type-checking macros via the Macro' type from the standard library.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser/module.clj4
-rw-r--r--luxc/src/lux/analyser/proc/common.clj8
-rw-r--r--luxc/src/lux/base.clj3
-rw-r--r--luxc/src/lux/compiler/jvm.clj2
-rw-r--r--luxc/src/lux/lexer.clj2
-rw-r--r--luxc/src/lux/type.clj3
6 files changed, 11 insertions, 11 deletions
diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj
index 3d53155cb..d41eb73d5 100644
--- a/luxc/src/lux/analyser/module.clj
+++ b/luxc/src/lux/analyser/module.clj
@@ -126,8 +126,6 @@
(defn define [module name exported? def-type def-meta def-value]
(fn [state]
- (when (and (= "Macro'" name) (= "lux" module))
- (&type/set-macro*-type! def-value))
(|case (&/get$ &/$scopes state)
(&/$Cons ?env (&/$Nil))
(return* (->> state
@@ -264,7 +262,7 @@
(&/$Right [exported? ?type ?meta ?value])
(if (or (.equals ^Object current-module module)
(and exported?
- (or (.equals ^Object module "lux")
+ (or (.equals ^Object module &/prelude)
(imports? state module current-module))))
(return* state (&/T [(&/T [module name])
(&/T [exported? ?type ?meta ?value])]))
diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj
index 8cdcea970..267ea3465 100644
--- a/luxc/src/lux/analyser/proc/common.clj
+++ b/luxc/src/lux/analyser/proc/common.clj
@@ -4,7 +4,8 @@
clojure.core.match.array
(lux [base :as & :refer [|let |do return* return |case assert!]]
[type :as &type])
- (lux.analyser [base :as &&])))
+ (lux.analyser [base :as &&]
+ [module :as &&module])))
(defn- analyse-lux-is [analyse exo-type ?values]
(&type/with-var
@@ -31,7 +32,8 @@
(defn- analyse-lux-macro [analyse exo-type ?values]
(|do [:let [(&/$Cons macro (&/$Nil)) ?values]
- [[=macro*-type =location] =macro] (&&/analyse-1 analyse &type/Macro* macro)
+ [_real-name [_exported? _def-type _meta macro-type]] (&&module/find-def! &/prelude "Macro'")
+ [[=macro*-type =location] =macro] (&&/analyse-1 analyse macro-type macro)
_ (&type/check exo-type &type/Macro)]
(return (&/|list (&&/|meta exo-type =location
=macro)))))
@@ -257,7 +259,7 @@
(try (case proc
"lux is" (analyse-lux-is analyse exo-type ?values)
"lux try" (analyse-lux-try analyse exo-type ?values)
- "lux macro" (analyse-lux-macro analyse exo-type ?values)
+ "lux macro" (analyse-lux-macro analyse exo-type ?values)
"lux io log" (analyse-io-log analyse exo-type ?values)
"lux io error" (analyse-io-error analyse exo-type ?values)
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj
index cc109b0f7..5ef710a03 100644
--- a/luxc/src/lux/base.clj
+++ b/luxc/src/lux/base.clj
@@ -4,6 +4,9 @@
[clojure.core.match :as M :refer [matchv]]
clojure.core.match.array))
+(def prelude
+ "lux")
+
(def !log! (atom false))
(defn flag-prn! [& args]
(when @!log!
diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj
index e1a51b73a..07c28dfac 100644
--- a/luxc/src/lux/compiler/jvm.clj
+++ b/luxc/src/lux/compiler/jvm.clj
@@ -157,7 +157,7 @@
(let [compile-expression* (partial compile-expression nil)]
(&/T [(partial &&lux/compile-def compile-expression)
(partial &&lux/compile-program compile-expression*)
- (fn [macro args state] (-> macro (.apply args) (.apply state)))
+ (fn [macro args state] (.apply macro args state))
(partial &&proc-host/compile-jvm-class compile-expression*)
&&proc-host/compile-jvm-interface])))
diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj
index 962e1e9bd..49e29710a 100644
--- a/luxc/src/lux/lexer.clj
+++ b/luxc/src/lux/lexer.clj
@@ -88,7 +88,7 @@
(return (&/T [meta (&/T [module-name token])])))
(|do [[meta _ _] (&reader/read-text &/+name-separator+)
[_ _ token] (&reader/read-regex +ident-re+)]
- (return (&/T [meta (&/T ["lux" token])])))
+ (return (&/T [meta (&/T [&/prelude token])])))
)))
(def ^:private lex-identifier
diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj
index 924489a53..8853224b5 100644
--- a/luxc/src/lux/type.clj
+++ b/luxc/src/lux/type.clj
@@ -168,9 +168,6 @@
(let [w (&/$Apply Location Meta)]
(&/$Apply (&/$Apply w Code*) w))))
-(def Macro*)
-(defn set-macro*-type! [type] (def Macro* type))
-
(def Macro
(&/$Named (&/T ["lux" "Macro"])
(&/$Primitive "#Macro" &/$Nil)))