aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lux.clj2
-rw-r--r--src/lux/analyser/lux.clj39
-rw-r--r--src/lux/analyser/module.clj82
-rw-r--r--src/lux/base.clj21
-rw-r--r--src/lux/compiler.clj89
-rw-r--r--src/lux/compiler/base.clj149
-rw-r--r--src/lux/compiler/host.clj10
-rw-r--r--src/lux/compiler/lux.clj2
8 files changed, 209 insertions, 185 deletions
diff --git a/src/lux.clj b/src/lux.clj
index 0fcb33785..7ff8fda37 100644
--- a/src/lux.clj
+++ b/src/lux.clj
@@ -14,7 +14,7 @@
:reload-all))
(defn -main [& _]
- (do (time (&compiler/compile-all (&/|list "program")))
+ (do (time (&compiler/compile-all (&/|list "lux" "program")))
;; (prn @&type/counter)
)
(System/exit 0))
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index 8be2a8924..72923c43e 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -261,12 +261,12 @@
[["lux;MacroD" macro]]
(|do [macro-expansion #(-> macro (.apply ?args) (.apply %))
:let [macro-expansion* (&/|map (partial with-cursor form-cursor) macro-expansion)]
- :let [_ (when (and ;; (= "lux/control/monad" ?module)
- (= "case" ?name))
- (->> (&/|map &/show-ast macro-expansion*)
- (&/|interpose "\n")
- (&/fold str "")
- (prn ?module "case")))]
+ ;; :let [_ (when (and ;; (= "lux/control/monad" ?module)
+ ;; (= "case" ?name))
+ ;; (->> (&/|map &/show-ast macro-expansion*)
+ ;; (&/|interpose "\n")
+ ;; (&/fold str "")
+ ;; (prn ?module "case")))]
]
(&/flat-map% (partial analyse exo-type) macro-expansion*))
@@ -388,21 +388,18 @@
(return (&/|list (&/V "declare-macro" (&/T module-name ?name))))))
(defn analyse-import [analyse compile-module ?path]
- (|do [module-name &/get-module-name]
- (if (= module-name ?path)
- (fail (str "[Analyser Error] Module can't import itself: " ?path))
- (&/save-module
- (fn [state]
- (let [already-compiled? (&/fold #(or %1 (= %2 ?path)) false (&/get$ &/$SEEN-SOURCES state))]
- (prn 'analyse-import module-name ?path already-compiled?)
- (&/run-state (|do [_ (&&module/add-import ?path)
- _ (if already-compiled?
- (return nil)
- (compile-module ?path))]
- (return (&/|list)))
- (if already-compiled?
- state
- (&/update$ &/$SEEN-SOURCES (partial &/|cons ?path) state)))))))))
+ (|do [module-name &/get-module-name
+ _ (if (= module-name ?path)
+ (fail (str "[Analyser Error] Module can't import itself: " ?path))
+ (return nil))]
+ (&/save-module
+ (|do [already-compiled? (&/source-seen? ?path)
+ :let [must-compile? (not already-compiled?)
+ _ (prn 'analyse-import module-name ?path already-compiled?)]
+ _ (&/when% must-compile? (&/see-source ?path))
+ _ (&&module/add-import ?path)
+ _ (&/when% must-compile? (compile-module ?path))]
+ (return (&/|list))))))
(defn analyse-export [analyse name]
(|do [module-name &/get-module-name
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj
index 9b68fb680..830319549 100644
--- a/src/lux/analyser/module.clj
+++ b/src/lux/analyser/module.clj
@@ -20,9 +20,7 @@
(def ^:private $DEFS 0)
(def ^:private $ALIASES 1)
(def ^:private $IMPORTS 2)
-
-;; [Exports]
-(def init-module
+(def ^:private +init+
(&/R ;; "lux;defs"
(&/|table)
;; "lux;module-aliases"
@@ -31,6 +29,7 @@
(&/|list)
))
+;; [Exports]
(defn add-import [module]
"(-> Text (Lux (,)))"
(|do [current-module &/get-module-name]
@@ -55,15 +54,7 @@
(&/update$ $DEFS
#(&/|put name (&/T false def-data) %)
m))
- ms)))
- ;; (&/set$ &/$ENVS (&/|list (&/update$ &/$LOCALS (fn [locals]
- ;; (&/update$ &/$MAPPINGS (fn [mappings]
- ;; (&/|put (str "" &/+name-separator+ name)
- ;; (&/T (&/V "lux;Global" (&/T module name)) type)
- ;; mappings))
- ;; locals))
- ;; ?env)))
- )
+ ms))))
nil)
[_]
@@ -75,18 +66,21 @@
(if-let [$module (->> state (&/get$ &/$MODULES) (&/|get module))]
(if-let [$def (->> $module (&/get$ $DEFS) (&/|get name))]
(matchv ::M/objects [$def]
- [["lux;TypeD" _]]
+ [[_ ["lux;TypeD" _]]]
(return* state &type/Type)
- [["lux;MacroD" _]]
+ [[_ ["lux;MacroD" _]]]
(return* state &type/Macro)
- [["lux;ValueD" _type]]
+ [[_ ["lux;ValueD" _type]]]
(return* state _type)
- [["lux;AliasD" [?r-module ?r-name]]]
+ [[_ ["lux;AliasD" [?r-module ?r-name]]]]
(&/run-state (def-type ?r-module ?r-name)
- state))
+ state)
+
+ [_]
+ (assert false (prn-str 'def-type (str module ";" name) (aget $def 0))))
(fail* (str "[Analyser Error] Unknown definition: " (str module ";" name))))
(fail* (str "[Analyser Error] Unknown module: " module)))))
@@ -103,16 +97,7 @@
(&/update$ $DEFS
#(&/|put a-name (&/T false (&/V "lux;AliasD" (&/T r-module r-name))) %)
m))
- ms)))
- ;; (&/set$ &/$ENVS (&/|list (&/update$ &/$LOCALS (fn [locals]
- ;; (&/update$ &/$MAPPINGS (fn [mappings]
- ;; (&/|put (str "" &/+name-separator+ a-name)
- ;; (&/T (&/V "lux;Global" (&/T r-module r-name)) type)
- ;; ;; (aget (->> state (&/get$ &/$MODULES) (&/|get r-module) (&/get$ $DEFS) (&/|get r-name)) 1)
- ;; mappings))
- ;; locals))
- ;; ?env)))
- )
+ ms))))
nil)
[_]
@@ -150,7 +135,12 @@
;; (prn 'find-def/_0 module name 'current-module current-module)
(if-let [$module (->> state (&/get$ &/$MODULES) (&/|get module))]
(do ;; (prn 'find-def/_0.1 module (&/->seq (&/|keys $module)))
- (if-let [$def (->> $module (&/get$ $DEFS) (&/|get name))]
+ (if-let [$def (try (->> $module (&/get$ $DEFS) (&/|get name))
+ (catch StackOverflowError e
+ (assert false (prn-str 'find-def
+ (str module ";" name)
+ (&/->seq (&/|keys (&/get$ $DEFS $module)))
+ (&/->seq (&/|keys (&/get$ &/$MODULES state)))))))]
(matchv ::M/objects [$def]
[[exported? $$def]]
(do ;; (prn 'find-def/_1 module name 'exported? exported? (.equals ^Object current-module module))
@@ -165,10 +155,7 @@
(return* state (&/T (&/T module name) $$def)))
(fail* (str "[Analyser Error] Can't use unexported definition: " (str module &/+name-separator+ name))))))
(fail* (str "[Analyser Error] Definition does not exist: " (str module &/+name-separator+ name)))))
- (do (prn [module name]
- (str "[Analyser Error] Module doesn't exist: " module)
- (->> state (&/get$ &/$MODULES) &/|keys &/->seq))
- (fail* (str "[Analyser Error] Module doesn't exist: " module)))))))
+ (fail* (str "[Analyser Error] Module doesn't exist: " module))))))
(defn defined? [module name]
(&/try-all% (&/|list (|do [_ (find-def module name)]
@@ -239,21 +226,32 @@
(matchv ::M/objects [v]
[[?exported? ?def]]
(do ;; (prn 'defs k ?exported?)
- (matchv ::M/objects [?def]
- [["lux;AliasD" [?r-module ?r-name]]]
- (&/T ?exported? k (str "A" ?r-module ";" ?r-name))
-
- [["lux;MacroD" _]]
- (&/T ?exported? k "M")
+ (matchv ::M/objects [?def]
+ [["lux;AliasD" [?r-module ?r-name]]]
+ (&/T ?exported? k (str "A" ?r-module ";" ?r-name))
+
+ [["lux;MacroD" _]]
+ (&/T ?exported? k "M")
- [["lux;TypeD" _]]
- (&/T ?exported? k "T")
+ [["lux;TypeD" _]]
+ (&/T ?exported? k "T")
- [_]
- (&/T ?exported? k "V"))))))
+ [_]
+ (&/T ?exported? k "V"))))))
(->> state (&/get$ &/$MODULES) (&/|get module) (&/get$ $DEFS)))))))
(def imports
(|do [module &/get-module-name]
(fn [state]
(return* state (->> state (&/get$ &/$MODULES) (&/|get module) (&/get$ $IMPORTS))))))
+
+(defn create-module [name]
+ (fn [state]
+ (return* (&/update$ &/$MODULES #(&/|put name +init+ %) state) nil)))
+
+(defn enter-module [name]
+ (fn [state]
+ (return* (->> state
+ (&/update$ &/$MODULES #(&/|put name +init+ %))
+ (&/set$ &/$ENVS (&/|list (&/env name))))
+ nil)))
diff --git a/src/lux/base.clj b/src/lux/base.clj
index 7ed21e9bd..7b1e7139e 100644
--- a/src/lux/base.clj
+++ b/src/lux/base.clj
@@ -468,7 +468,7 @@
;; (prn 'findClass class-name)
(if-let [^bytes bytecode (get @store class-name)]
(.invoke define-class this (to-array [class-name bytecode (int 0) (int (alength bytecode))]))
- (do (prn 'memory-class-loader/store (keys @store))
+ (do (prn 'memory-class-loader/store class-name (keys @store))
(throw (IllegalStateException. (str "[Class Loader] Unknown class: " class-name)))))))))
(defn host [_]
@@ -477,7 +477,6 @@
store
;; "lux;loader"
(memory-class-loader store)
- ;; (-> (java.io.File. "./output/") .toURL vector into-array java.net.URLClassLoader.)
;; "lux;writer"
(V "lux;None" nil))))
@@ -493,7 +492,7 @@
;; "lux;seed"
0
;; "lux;seen-sources"
- (|list "lux")
+ (|list)
;; "lux;source"
(V "lux;None" nil)
;; "lux;types"
@@ -711,3 +710,19 @@
(defn enumerate [xs]
(enumerate* 0 xs))
+
+(defn source-seen? [path]
+ "(-> Text (Lux Bool))"
+ (fn [state]
+ (return* state (fold #(or %1 (= %2 path)) false (get$ $SEEN-SOURCES state)))))
+
+(defn see-source [path]
+ "(-> Text (Lux (,)))"
+ (fn [state]
+ (return* (update$ $SEEN-SOURCES (partial |cons path) state) nil)))
+
+(defn when% [test body]
+ "(-> Bool (Lux (,)) (Lux (,)))"
+ (if test
+ body
+ (return nil)))
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 549f2e0a9..fbf8afb89 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -372,52 +372,53 @@
;; (prn 'compile-module name)
(if (&&/cached? name)
(do ;; (println "YOLO")
- (let [file-name (str "input/" name ".lux")
- file-content (slurp file-name)]
- (&&/load-cache name (hash file-content) compile-module)))
+ (let [file-name (str "input/" name ".lux")
+ file-content (slurp file-name)]
+ (&&/load-cache name (hash file-content) compile-module)))
(let [compiler-step (|do [analysis+ (&optimizer/optimize eval! compile-module)]
(&/map% compile-statement analysis+))]
- (fn [state]
- (if (->> state (&/get$ &/$MODULES) (&/|contains? name))
+ (|do [module-exists? (&a-module/exists? name)]
+ (if module-exists?
(if (.equals ^Object name "lux")
- (return* state nil)
- (fail* "[Compiler Error] Can't redefine a module!"))
- (let [file-name (str "input/" name ".lux")
- file-content (slurp file-name)
- =class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS)
- (.visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER)
- (str name "/_") nil "java/lang/Object" nil)
- (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_hash" "I" nil (hash file-content))
- .visitEnd)
- (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_compiler" "Ljava/lang/String;" nil &&/version)
- .visitEnd))]
- (matchv ::M/objects [((&/exhaust% compiler-step)
- (->> state
- (&/set$ &/$SOURCE (&reader/from file-name file-content))
- (&/set$ &/$ENVS (&/|list (&/env name)))
- (&/update$ &/$HOST #(&/set$ &/$WRITER (&/V "lux;Some" =class) %))
- (&/update$ &/$MODULES #(&/|put name &a-module/init-module %))))]
- [["lux;Right" [?state _]]]
- (&/run-state (|do [defs &a-module/defs
- imports &a-module/imports
- :let [_ (doto =class
- (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_defs" "Ljava/lang/String;" nil
- (->> defs
- (&/|map (fn [_def]
- (|let [[?exported ?name ?ann] _def]
- (str (if ?exported "1" "0") " " ?name " " ?ann))))
- (&/|interpose "\t")
- (&/fold str "")))
- .visitEnd)
- (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_imports" "Ljava/lang/String;" nil
- (->> imports (&/|interpose "\t") (&/fold str "")))
- .visitEnd)
- (.visitEnd))]]
- (&&/save-class! "_" (.toByteArray =class)))
- ?state)
-
- [["lux;Left" ?message]]
- (fail* ?message))))))))
+ (return nil)
+ (fail "[Compiler Error] Can't redefine a module!"))
+ (|do [_ (&a-module/enter-module name)
+ :let [file-name (str "input/" name ".lux")
+ file-content (slurp file-name)
+ =class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS)
+ (.visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER)
+ (str name "/_") nil "java/lang/Object" nil)
+ (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_hash" "I" nil (hash file-content))
+ .visitEnd)
+ (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_compiler" "Ljava/lang/String;" nil &&/version)
+ .visitEnd))]]
+ (fn [state]
+ (matchv ::M/objects [((&/exhaust% compiler-step)
+ (->> state
+ (&/set$ &/$SOURCE (&reader/from file-name file-content))
+ (&/update$ &/$HOST #(&/set$ &/$WRITER (&/V "lux;Some" =class) %))))]
+ [["lux;Right" [?state _]]]
+ (&/run-state (|do [defs &a-module/defs
+ imports &a-module/imports
+ :let [_ (doto =class
+ (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_defs" "Ljava/lang/String;" nil
+ (->> defs
+ (&/|map (fn [_def]
+ (|let [[?exported ?name ?ann] _def]
+ (str (if ?exported "1" "0") " " ?name " " ?ann))))
+ (&/|interpose "\t")
+ (&/fold str "")))
+ .visitEnd)
+ (-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_imports" "Ljava/lang/String;" nil
+ (->> imports (&/|interpose "\t") (&/fold str "")))
+ .visitEnd)
+ (.visitEnd))]]
+ (&&/save-class! "_" (.toByteArray =class)))
+ ?state)
+
+ [["lux;Left" ?message]]
+ (fail* ?message)))))))
+ ))
(defn ^:private clean-file [^java.io.File file]
(if (.isDirectory file)
@@ -437,7 +438,7 @@
;; [Resources]
(defn compile-all [modules]
(setup-dirs!)
- (matchv ::M/objects [((&/map% compile-module (&/|cons "lux" modules)) (&/init-state nil))]
+ (matchv ::M/objects [((&/map% compile-module modules) (&/init-state nil))]
[["lux;Right" [?state _]]]
(println (str "Compilation complete! " (str "[" (->> modules
(&/|interpose " ")
diff --git a/src/lux/compiler/base.clj b/src/lux/compiler/base.clj
index 68c3b7d6c..89303c48d 100644
--- a/src/lux/compiler/base.clj
+++ b/src/lux/compiler/base.clj
@@ -62,6 +62,7 @@
(def apply-signature "(Ljava/lang/Object;)Ljava/lang/Object;")
(defn load-class! [^ClassLoader loader name]
+ ;; (prn 'load-class! name)
(.loadClass loader name))
(defn save-class! [name bytecode]
@@ -123,76 +124,84 @@
cache-name))
(defn ^:private get-field [^String field-name ^Class class]
- (-> class ^Field (.getField field-name) (.get nil)))
+ (-> class ^Field (.getField field-name) (.get nil))
+ ;; (try (-> class ^Field (.getField field-name) (.get nil))
+ ;; (catch Error e
+ ;; (assert false (prn-str 'get-field field-name class))))
+ )
(defn load-cache [module module-hash compile-module]
(|do [loader &/loader
- !classes &/classes]
- (let [module-path (str "cache/jvm/" (string/replace module #"/" " "))
- module* (string/replace module #"/" ".")
- class-name (str module* "._")
- ^Class module-meta (do (swap! !classes assoc class-name (read-file (File. (str module-path "/_.class"))))
- (load-class! loader class-name))]
- (if (and (= module-hash (get-field "_hash" module-meta))
- (= version (get-field "_compiler" module-meta)))
- (let [imports (string/split (-> module-meta (.getField "_imports") (.get nil)) #"\t")
- ;; _ (prn module 'imports imports)
- ]
- (|do [loads (&/map% (fn [_import]
- (load-cache _import (-> (str "input/" _import ".lux") slurp hash) compile-module))
- (if (= [""] imports)
- (&/|list)
- (&/->list imports)))]
- (if (->> loads &/->seq (every? true?))
- (do (doseq [^File file (seq (.listFiles (File. module-path)))
- :let [file-name (.getName file)]
- :when (not= "_.class" file-name)]
- (let [real-name (second (re-find #"^(.*)\.class$" file-name))
- bytecode (read-file file)
- ;; _ (prn 'load-cache module real-name)
- ]
- ;; (swap! !classes assoc (str module* "." (replace-cache real-name)) bytecode)
- (swap! !classes assoc (str module* "." real-name) bytecode)
- ;; (swap! !classes assoc "__temp__" bytecode)
- ;; (swap! !classes assoc (-> (load-class! loader "__temp__") (.getField "_name") (.get nil)) bytecode)
- (write-output module real-name bytecode)))
- ;; (swap! !classes dissoc "__temp__")
- (let [defs (string/split (get-field "_defs" module-meta) #"\t")]
- (|do [_ (fn [state]
- (&/run-state (&/map% (fn [_def]
- (let [[_exported? _name _ann] (string/split _def #" ")
- ;; _ (prn '[_exported? _name _ann] [_exported? _name _ann])
- def-class (load-class! loader (str module* ".$" (&/normalize-ident _name)))
- def-name (get-field "_name" def-class)]
- (|do [_ (case _ann
- "T" (&a-module/define module def-name (&/V "lux;TypeD" nil) &type/Type)
- "M" (|do [_ (&a-module/define module def-name (&/V "lux;ValueD" &type/Macro) &type/Macro)]
- (&a-module/declare-macro module def-name))
- "V" (let [def-type (get-field "_meta" def-class)]
- (matchv ::M/objects [def-type]
- [["lux;ValueD" _def-type]]
- (&a-module/define module def-name def-type _def-type)))
- ;; else
- (let [[_ __module __name] (re-find #"^A(.*);(.*)$" _ann)]
- (|do [__type (&a-module/def-type __module __name)]
- (do ;; (prn '__type [__module __name] (&type/show-type __type))
- (&a-module/def-alias module def-name __module __name __type)))))]
- (if (= "1" _exported?)
- (&a-module/export module def-name)
- (return nil)))
- ))
- (if (= [""] defs)
- (&/|list)
- (&/->list defs)))
- (->> state
- (&/set$ &/$ENVS (&/|list (&/env module)))
- (&/update$ &/$MODULES #(&/|put module &a-module/init-module %)))))]
- (return true))))
- (|do [_ (delete-cache module)
- _ (compile-module module)]
- (return false)))))
-
- (|do [_ (delete-cache module)
- _ (compile-module module)]
- (return false)))
- )))
+ !classes &/classes
+ already-loaded? (&/source-seen? module)
+ :let [redo-cache (|do [_ (delete-cache module)
+ _ (compile-module module)]
+ (return false))]]
+ (if already-loaded?
+ (return true)
+ (if (cached? module)
+ (do (prn 'load-cache module module-hash)
+ (let [module-path (str "cache/jvm/" (string/replace module #"/" " "))
+ module* (string/replace module #"/" ".")
+ class-name (str module* "._")
+ ^Class module-meta (do (swap! !classes assoc class-name (read-file (File. (str module-path "/_.class"))))
+ (load-class! loader class-name))]
+ (if (and (= module-hash (get-field "_hash" module-meta))
+ (= version (get-field "_compiler" module-meta)))
+ (let [imports (string/split (-> module-meta (.getField "_imports") (.get nil)) #"\t")
+ ;; _ (prn module 'imports imports)
+ ]
+ (|do [loads (&/map% (fn [_import]
+ (load-cache _import (-> (str "input/" _import ".lux") slurp hash) compile-module))
+ (if (= [""] imports)
+ (&/|list)
+ (&/->list imports)))]
+ (if (->> loads &/->seq (every? true?))
+ (do (doseq [^File file (seq (.listFiles (File. module-path)))
+ :let [file-name (.getName file)]
+ :when (not= "_.class" file-name)]
+ (let [real-name (second (re-find #"^(.*)\.class$" file-name))
+ bytecode (read-file file)
+ ;; _ (prn 'load-cache module real-name)
+ ]
+ ;; (swap! !classes assoc (str module* "." (replace-cache real-name)) bytecode)
+ (swap! !classes assoc (str module* "." real-name) bytecode)
+ ;; (swap! !classes assoc "__temp__" bytecode)
+ ;; (swap! !classes assoc (-> (load-class! loader "__temp__") (.getField "_name") (.get nil)) bytecode)
+ (write-output module real-name bytecode)))
+ ;; (swap! !classes dissoc "__temp__")
+ (let [defs (string/split (get-field "_defs" module-meta) #"\t")]
+ ;; (prn 'load-cache module defs)
+ (|do [_ (&/see-source module)
+ _ (&a-module/enter-module module)
+ _ (&/map% (fn [_def]
+ (let [[_exported? _name _ann] (string/split _def #" ")
+ ;; _ (prn '[_exported? _name _ann] [_exported? _name _ann])
+ ]
+ (|do [_ (case _ann
+ "T" (&a-module/define module _name (&/V "lux;TypeD" nil) &type/Type)
+ "M" (|do [_ (&a-module/define module _name (&/V "lux;ValueD" &type/Macro) &type/Macro)]
+ (&a-module/declare-macro module _name))
+ "V" (let [def-class (load-class! loader (str module* ".$" (&/normalize-ident _name)))
+ ;; _ (println "Fetching _meta" module _name (str module* ".$" (&/normalize-ident _name)) def-class)
+ def-type (get-field "_meta" def-class)]
+ (matchv ::M/objects [def-type]
+ [["lux;ValueD" _def-type]]
+ (&a-module/define module _name def-type _def-type)))
+ ;; else
+ (let [[_ __module __name] (re-find #"^A(.*);(.*)$" _ann)]
+ (|do [__type (&a-module/def-type __module __name)]
+ (do ;; (prn '__type [__module __name] (&type/show-type __type))
+ (&a-module/def-alias module _name __module __name __type)))))]
+ (if (= "1" _exported?)
+ (&a-module/export module _name)
+ (return nil)))
+ ))
+ (if (= [""] defs)
+ (&/|list)
+ (&/->list defs)))]
+ (return true))))
+ redo-cache)))
+ redo-cache)
+ ))
+ redo-cache))))
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index 1dca81857..fd34a45a7 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -292,14 +292,18 @@
(defn compile-jvm-getstatic [compile *type* ?class ?field]
(|do [^MethodVisitor *writer* &/get-writer
- :let [_ (.visitFieldInsn *writer* Opcodes/GETSTATIC (&host/->class ?class) ?field (&host/->java-sig *type*))]]
+ :let [_ (doto *writer*
+ (.visitFieldInsn Opcodes/GETSTATIC (&host/->class ?class) ?field (&host/->java-sig *type*))
+ (prepare-return! *type*))]]
(return nil)))
(defn compile-jvm-getfield [compile *type* ?class ?field ?object]
(|do [^MethodVisitor *writer* &/get-writer
_ (compile ?object)
- :let [_ (.visitTypeInsn *writer* Opcodes/CHECKCAST (&host/->class ?class))]
- :let [_ (.visitFieldInsn *writer* Opcodes/GETFIELD (&host/->class ?class) ?field (&host/->java-sig *type*))]]
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/CHECKCAST (&host/->class ?class))
+ (.visitFieldInsn Opcodes/GETFIELD (&host/->class ?class) ?field (&host/->java-sig *type*))
+ (prepare-return! *type*))]]
(return nil)))
(defn compile-jvm-putstatic [compile *type* ?class ?field ?value]
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj
index ac3d6f56d..66db6923d 100644
--- a/src/lux/compiler/lux.clj
+++ b/src/lux/compiler/lux.clj
@@ -87,7 +87,7 @@
ret (compile v)
:let [_ (.visitInsn *writer* Opcodes/AASTORE)]]
(return ret))))
- (&/|range num-elems) elems*)]
+ (&/|range num-elems) elems*)]
(return nil)))
(defn compile-variant [compile *type* ?tag ?value]