diff options
author | Eduardo Julian | 2017-02-01 20:35:58 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-02-01 20:35:58 -0400 |
commit | 856948baa67c60059a4ffdc65c563d1dfa350363 (patch) | |
tree | fa07e36c2ef820c1aa72a2b52fc8ff3779655e3a /luxc/src | |
parent | 3fa825d4ef98f2bdd9a31202bf04b06b9a1d9daa (diff) |
- Now wrapping macros to make sure all macros can be invoked, regardless of whether it's JVM code or any other kind of code.
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/analyser.clj | 7 | ||||
-rw-r--r-- | luxc/src/lux/analyser/jvm.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/analyser/lux.clj | 4 | ||||
-rw-r--r-- | luxc/src/lux/compiler/jvm.clj | 1 |
4 files changed, 8 insertions, 6 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index 50edefac4..d895b1aaa 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -60,7 +60,8 @@ (|let [analyse (partial analyse-ast optimize eval! compile-module compilers) [cursor token] ?token compile-def (aget compilers 0) - compile-program (aget compilers 1)] + compile-program (aget compilers 1) + macro-wrapper (aget compilers 2)] (|case token ;; Standard special forms (&/$BoolS ?value) @@ -171,7 +172,7 @@ ;; else (&/with-cursor cursor (|do [=fn (just-analyse analyse (&/T [command-meta command]))] - (&&lux/analyse-apply analyse cursor exo-type =fn parameters)))) + (&&lux/analyse-apply analyse cursor exo-type macro-wrapper =fn parameters)))) (&/$NatS idx) (&/with-analysis-meta cursor exo-type @@ -184,7 +185,7 @@ _ (&/with-cursor cursor (|do [=fn (just-analyse analyse (&/T [command-meta command]))] - (&&lux/analyse-apply analyse cursor exo-type =fn parameters)))) + (&&lux/analyse-apply analyse cursor exo-type macro-wrapper =fn parameters)))) _ (&/fail-with-loc (str "[Analyser Error] Unknown syntax: " (prn-str (&/show-ast (&/T [(&/T ["" -1 -1]) token]))))) diff --git a/luxc/src/lux/analyser/jvm.clj b/luxc/src/lux/analyser/jvm.clj index 5ea64d41a..b82c634d6 100644 --- a/luxc/src/lux/analyser/jvm.clj +++ b/luxc/src/lux/analyser/jvm.clj @@ -1142,7 +1142,7 @@ ) (defn analyse-host [analyse exo-type compilers category proc ?values] - (|let [[_ _ compile-class compile-interface] compilers] + (|let [[_ _ _ compile-class compile-interface] compilers] (case category "lux" (case proc diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index 27f4ee11e..b990b738c 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -375,7 +375,7 @@ (&&/$apply =fn =args) ))))) -(defn analyse-apply [analyse cursor exo-type =fn ?args] +(defn analyse-apply [analyse cursor exo-type macro-wrapper =fn ?args] (|do [loader &/loader :let [[[=fn-type =fn-cursor] =fn-form] =fn]] (|case =fn-form @@ -384,7 +384,7 @@ (|case (&&meta/meta-get &&meta/macro?-tag ?meta) (&/$Some _) (|do [macro-expansion (fn [state] - (|case (-> ?value (.apply ?args) (.apply state)) + (|case ((macro-wrapper ?value) ?args state) (&/$Right state* output) (&/$Right (&/T [state* output])) diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj index 809c03022..a5c5ee210 100644 --- a/luxc/src/lux/compiler/jvm.clj +++ b/luxc/src/lux/compiler/jvm.clj @@ -161,6 +161,7 @@ (let [compile-expression* (partial compile-expression nil)] (&/T [(partial &&lux/compile-def compile-expression) (partial &&lux/compile-program compile-expression*) + (fn [macro] (fn [args state] (-> macro (.apply args) (.apply state)))) (partial &&host/compile-jvm-class compile-expression*) &&host/compile-jvm-interface]))) |