aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lux/analyser/lux.clj15
-rw-r--r--src/lux/analyser/module.clj24
-rw-r--r--src/lux/base.clj9
-rw-r--r--src/lux/compiler/cache.clj6
-rw-r--r--src/lux/compiler/lux.clj4
5 files changed, 33 insertions, 25 deletions
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index 843cfef96..e0f00a0a2 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -144,14 +144,15 @@
(defn ^:private analyse-global [analyse exo-type module name]
(|do [[[r-module r-name] $def] (&&module/find-def module name)
;; :let [_ (prn 'analyse-symbol/_1.1 r-module r-name)]
+ ;; :let [_ (prn 'analyse-global/$def (aget $def 0))]
endo-type (|case $def
- ("lux;ValueD" ?type _)
+ (&/$ValueD ?type _)
(return ?type)
- ("lux;MacroD" _)
+ (&/$MacroD _)
(return &type/Macro)
- ("lux;TypeD" _)
+ (&/$TypeD _)
(return &type/Type))
_ (if (and (clojure.lang.Util/identical &type/Type endo-type)
(clojure.lang.Util/identical &type/Type exo-type))
@@ -181,13 +182,13 @@
((|do [[[r-module r-name] $def] (&&module/find-def ?module* name*)
;; :let [_ (prn 'analyse-symbol/_2.1.1 r-module r-name)]
endo-type (|case $def
- ("lux;ValueD" ?type _)
+ (&/$ValueD ?type _)
(return ?type)
- ("lux;MacroD" _)
+ (&/$MacroD _)
(return &type/Macro)
- ("lux;TypeD" _)
+ (&/$TypeD _)
(return &type/Type))
_ (if (and (clojure.lang.Util/identical &type/Type endo-type)
(clojure.lang.Util/identical &type/Type exo-type))
@@ -275,7 +276,7 @@
(&/$Global ?module ?name)
(|do [[[r-module r-name] $def] (&&module/find-def ?module ?name)]
(|case $def
- ("lux;MacroD" macro)
+ (&/$MacroD macro)
(|do [;; :let [_ (prn 'MACRO-EXPAND|PRE (str r-module ";" r-name))]
macro-expansion #(-> macro (.apply ?args) (.apply %))
;; :let [_ (prn 'MACRO-EXPAND|POST (str r-module ";" r-name))]
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 78f5c675d..35ae7e5b7 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -66,16 +66,16 @@
(if-let [$module (->> state (&/get$ &/$MODULES) (&/|get module))]
(if-let [$def (->> $module (&/get$ $DEFS) (&/|get name))]
(|case $def
- [_ ("lux;TypeD" _)]
+ [_ (&/$TypeD _)]
(return* state &type/Type)
- [_ ("lux;MacroD" _)]
+ [_ (&/$MacroD _)]
(return* state &type/Macro)
- [_ ("lux;ValueD" _type _)]
+ [_ (&/$ValueD _type _)]
(return* state _type)
- [_ ("lux;AliasD" ?r-module ?r-name)]
+ [_ (&/$AliasD ?r-module ?r-name)]
(&/run-state (def-type ?r-module ?r-name)
state))
(fail* (str "[Analyser Error] Unknown definition: " (str module ";" name))))
@@ -92,7 +92,7 @@
(&/|update a-module
(fn [m]
(&/update$ $DEFS
- #(&/|put a-name (&/T false (&/V "lux;AliasD" (&/T r-module r-name))) %)
+ #(&/|put a-name (&/T false (&/V &/$AliasD (&/T r-module r-name))) %)
m))
ms))))
nil)
@@ -137,7 +137,7 @@
(do ;; (prn 'find-def/_1 module name 'exported? exported? (.equals ^Object current-module module))
(if (or exported? (.equals ^Object current-module module))
(|case $$def
- ("lux;AliasD" ?r-module ?r-name)
+ (&/$AliasD ?r-module ?r-name)
(do ;; (prn 'find-def/_2 [module name] [?r-module ?r-name])
((find-def ?r-module ?r-name)
state))
@@ -158,7 +158,7 @@
(if-let [$module (->> state (&/get$ &/$MODULES) (&/|get module) (&/get$ $DEFS))]
(if-let [$def (&/|get name $module)]
(|case $def
- [exported? ("lux;ValueD" ?type _)]
+ [exported? (&/$ValueD ?type _)]
((|do [_ (&type/check &type/Macro ?type)
^ClassLoader loader &/loader
:let [macro (-> (.loadClass loader (str (&host/->module-class module) "." (&/normalize-name name)))
@@ -170,14 +170,14 @@
(&/|update module
(fn [m]
(&/update$ $DEFS
- #(&/|put name (&/T exported? (&/V "lux;MacroD" macro)) %)
+ #(&/|put name (&/T exported? (&/V &/$MacroD macro)) %)
m))
$modules))
state*)
nil)))
state)
- [_ ("lux;MacroD" _)]
+ [_ (&/$MacroD _)]
(fail* (str "[Analyser Error] Can't re-declare a macro: " (str module &/+name-separator+ name)))
[_ _]
@@ -216,13 +216,13 @@
(|let [[k [?exported? ?def]] kv]
(do ;; (prn 'defs k ?exported?)
(|case ?def
- ("lux;AliasD" ?r-module ?r-name)
+ (&/$AliasD ?r-module ?r-name)
(&/T ?exported? k (str "A" ?r-module ";" ?r-name))
- ("lux;MacroD" _)
+ (&/$MacroD _)
(&/T ?exported? k "M")
- ("lux;TypeD" _)
+ (&/$TypeD _)
(&/T ?exported? k "T")
_
diff --git a/src/lux/base.clj b/src/lux/base.clj
index b496be449..f690ef65f 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -14,7 +14,7 @@
;; [Tags]
(defmacro deftags [prefix & names]
`(do ~@(for [name names]
- `(def ~(symbol (str "$" name)) ~name))))
+ `(def ~(symbol (str "$" name)) ~(str prefix name)))))
;; List
(def $Nil "lux;Nil")
@@ -87,6 +87,13 @@
"Local"
"Global")
+;; Definitions
+(deftags "lux;"
+ "ValueD"
+ "TypeD"
+ "MacroD"
+ "AliasD")
+
;; [Exports]
(def +name-separator+ ";")
diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index 2b6f2e919..742ac69d8 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -118,16 +118,16 @@
(|do [_ (case _ann
"T" (let [def-class (&&/load-class! loader (str module* "." (&/normalize-name _name)))
def-value (get-field "_datum" def-class)]
- (&a-module/define module _name (&/V "lux;TypeD" def-value) &type/Type))
+ (&a-module/define module _name (&/V &/$TypeD def-value) &type/Type))
"M" (let [def-class (&&/load-class! loader (str module* "." (&/normalize-name _name)))
def-value (get-field "_datum" def-class)]
- (|do [_ (&a-module/define module _name (&/V "lux;ValueD" (&/T &type/Macro def-value)) &type/Macro)]
+ (|do [_ (&a-module/define module _name (&/V &/$ValueD (&/T &type/Macro def-value)) &type/Macro)]
(&a-module/declare-macro module _name)))
"V" (let [def-class (&&/load-class! loader (str module* "." (&/normalize-name _name)))
;; _ (println "Fetching _meta" module _name (str module* "." (&/normalize-name _name)) def-class)
def-meta (get-field "_meta" def-class)]
(|case def-meta
- ("lux;ValueD" def-type _)
+ (&/$ValueD def-type _)
(&a-module/define module _name def-meta def-type)))
;; else
(let [[_ __module __name] (re-find #"^A(.*);(.*)$" _ann)]
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj
index 9a3a7a6f2..2d28f8b3f 100644
--- a/src/lux/compiler/lux.clj
+++ b/src/lux/compiler/lux.clj
@@ -147,7 +147,7 @@
(.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object") ;; V
(.visitInsn Opcodes/DUP) ;; VV
(.visitLdcInsn (int 0)) ;; VVI
- (.visitLdcInsn "lux;TypeD") ;; VVIT
+ (.visitLdcInsn &/$TypeD) ;; VVIT
(.visitInsn Opcodes/AASTORE) ;; V
(.visitInsn Opcodes/DUP) ;; VV
(.visitLdcInsn (int 1)) ;; VVI
@@ -173,7 +173,7 @@
(.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object") ;; V
(.visitInsn Opcodes/DUP) ;; VV
(.visitLdcInsn (int 0)) ;; VVI
- (.visitLdcInsn "lux;ValueD") ;; VVIT
+ (.visitLdcInsn &/$ValueD) ;; VVIT
(.visitInsn Opcodes/AASTORE) ;; V
(.visitInsn Opcodes/DUP) ;; VV
(.visitLdcInsn (int 1)) ;; VVI