aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lux/compiler.clj4
-rw-r--r--src/lux/compiler/host.clj33
-rw-r--r--src/lux/compiler/lux.clj93
3 files changed, 66 insertions, 64 deletions
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 0f019bcb1..39e475aaa 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -146,7 +146,7 @@
(-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) &/eval-field "Ljava/lang/Object;" nil nil)
(doto (.visitEnd)))
(.visitSource file-name nil))]
- _ (&/with-writer (.visitMethod =class Opcodes/ACC_PUBLIC "<clinit>" "()V" nil nil)
+ _ (&/with-writer (.visitMethod =class Opcodes/ACC_STATIC "<clinit>" "()V" nil nil)
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitCode *writer*)]
_ (compile-expression nil expr)
@@ -246,7 +246,7 @@
(&/fold str "")))
.visitEnd)
)]
- _ (&/with-writer (.visitMethod =class Opcodes/ACC_PUBLIC "<clinit>" "()V" nil nil)
+ _ (&/with-writer (.visitMethod =class Opcodes/ACC_STATIC "<clinit>" "()V" nil nil)
(|do [^MethodVisitor **writer** &/get-writer
:let [_ (.visitCode **writer**)]
_ (&&/compile-meta compile-expression ==anns)
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index 211ed018c..4990fbf87 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -130,9 +130,7 @@
(defn ^:private compile-method-return [^MethodVisitor writer output]
(|case output
(&/$GenericClass "void" (&/$Nil))
- (doto writer
- (.visitInsn Opcodes/POP)
- (.visitInsn Opcodes/RETURN))
+ (.visitInsn writer Opcodes/RETURN)
(&/$GenericClass "boolean" (&/$Nil))
(doto writer
@@ -486,22 +484,19 @@
_
(return nil))
- _ (|let [field-inits (constant-inits ?fields)]
- (if (&/|empty? field-inits)
- (return nil)
- (&/with-writer (.visitMethod =class Opcodes/ACC_PUBLIC "<clinit>" "()V" nil nil)
- (|do [^MethodVisitor =method &/get-writer
- :let [_ (doto =method
- (.visitCode))]
- _ (&/map% (fn [ftriple]
- (|let [[fname fgclass fvalue] ftriple]
- (compile-jvm-putstatic compile (&/|list (&o/optimize fvalue)) (&/|list ?name fname fgclass))))
- field-inits)
- :let [_ (doto =method
- (.visitInsn Opcodes/RETURN)
- (.visitMaxs 0 0)
- (.visitEnd))]]
- (return nil)))))]
+ _ (&/with-writer (.visitMethod =class Opcodes/ACC_STATIC "<clinit>" "()V" nil nil)
+ (|do [^MethodVisitor =method &/get-writer
+ :let [_ (doto =method
+ (.visitCode))]
+ _ (&/map% (fn [ftriple]
+ (|let [[fname fgclass fvalue] ftriple]
+ (compile-jvm-putstatic compile (&/|list (&o/optimize fvalue)) (&/|list ?name fname fgclass))))
+ (constant-inits ?fields))
+ :let [_ (doto =method
+ (.visitInsn Opcodes/RETURN)
+ (.visitMaxs 0 0)
+ (.visitEnd))]]
+ (return nil)))]
(&&/save-class! ?name (.toByteArray (doto =class .visitEnd)))))
(defn compile-jvm-interface [interface-decl ?supers ?anns ?methods]
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj
index f44375e97..a6b636107 100644
--- a/src/lux/compiler/lux.clj
+++ b/src/lux/compiler/lux.clj
@@ -266,7 +266,8 @@
(if (= 1 (&/|length ?meta))
(|do [:let [current-class (&host-generics/->class-name (str (&host/->module-class r-module) "/" (&host/def-name r-name)))
def-class (&&/load-class! class-loader current-class)
- def-type (-> def-class (.getField &/type-field) (.get nil))
+ def-type (&a-module/def-type r-module r-name)
+ ;; def-type (-> def-class (.getField &/type-field) (.get nil))
def-meta ?meta
def-value (-> def-class (.getField &/value-field) (.get nil))]
_ (&/without-repl-closure
@@ -294,23 +295,24 @@
current-class nil &&/function-class (into-array String []))
(-> (.visitField field-flags &/name-field "Ljava/lang/String;" nil ?name)
(doto (.visitEnd)))
- (-> (.visitField field-flags &/type-field datum-sig nil nil)
- (doto (.visitEnd)))
- (-> (.visitField field-flags &/anns-field datum-sig nil nil)
- (doto (.visitEnd)))
+ ;; (-> (.visitField field-flags &/type-field datum-sig nil nil)
+ ;; (doto (.visitEnd)))
+ ;; (-> (.visitField field-flags &/anns-field datum-sig nil nil)
+ ;; (doto (.visitEnd)))
(-> (.visitField field-flags &/value-field datum-sig nil nil)
(doto (.visitEnd)))
(.visitSource file-name nil))]
instancer (&&lambda/compile-function compile (&/$Some =class) _arity _scope _captured ?body+)
- _ (&/with-writer (.visitMethod =class Opcodes/ACC_PUBLIC "<clinit>" "()V" nil nil)
+ _ (&/with-writer (.visitMethod =class Opcodes/ACC_STATIC "<clinit>" "()V" nil nil)
(|do [^MethodVisitor **writer** &/get-writer
:let [_ (.visitCode **writer**)]
- _ (compile-def-type compile ?body)
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/type-field datum-sig)]
- _ (&&/compile-meta compile ?meta)
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/anns-field datum-sig)]
+ ;; _ (compile-def-type compile ?body)
+ ;; :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/type-field datum-sig)]
+ ;; _ (&&/compile-meta compile ?meta)
+ ;; :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/anns-field datum-sig)]
_ instancer
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/value-field datum-sig)]
+ :let [_ (.visitTypeInsn **writer** Opcodes/CHECKCAST "java/lang/Object")
+ _ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/value-field datum-sig)]
:let [_ (doto **writer**
(.visitInsn Opcodes/RETURN)
(.visitMaxs 0 0)
@@ -320,17 +322,19 @@
:let [_ (.visitEnd =class)]
_ (&&/save-class! def-name (.toByteArray =class))
:let [def-class (&&/load-class! class-loader (&host-generics/->class-name current-class))
- [def-type is-type?] (|case (&a-meta/meta-get &a-meta/type?-tag ?meta)
- (&/$Some (&/$BoolM true))
- (&/T [&type/Type
- true])
-
- _
- (if (&type/type= &type/Type =value-type)
- (&/T [&type/Type
- false])
- (&/T [(-> def-class (.getField &/type-field) (.get nil))
- false])))
+ def-type (&a/expr-type* ?body)
+ [;; def-type
+ is-type?] (|case (&a-meta/meta-get &a-meta/type?-tag ?meta)
+ (&/$Some (&/$BoolM true))
+ (&/T [;; &type/Type
+ true])
+
+ _
+ (if (&type/type= &type/Type =value-type)
+ (&/T [;; &type/Type
+ false])
+ (&/T [;; (-> def-class (.getField &/type-field) (.get nil))
+ false])))
def-meta ?meta
def-value (-> def-class (.getField &/value-field) (.get nil))]
_ (&/without-repl-closure
@@ -377,22 +381,23 @@
current-class nil "java/lang/Object" (into-array String []))
(-> (.visitField field-flags &/name-field "Ljava/lang/String;" nil ?name)
(doto (.visitEnd)))
- (-> (.visitField field-flags &/type-field datum-sig nil nil)
- (doto (.visitEnd)))
- (-> (.visitField field-flags &/anns-field datum-sig nil nil)
- (doto (.visitEnd)))
+ ;; (-> (.visitField field-flags &/type-field datum-sig nil nil)
+ ;; (doto (.visitEnd)))
+ ;; (-> (.visitField field-flags &/anns-field datum-sig nil nil)
+ ;; (doto (.visitEnd)))
(-> (.visitField field-flags &/value-field datum-sig nil nil)
(doto (.visitEnd)))
(.visitSource file-name nil))]
- _ (&/with-writer (.visitMethod =class Opcodes/ACC_PUBLIC "<clinit>" "()V" nil nil)
+ _ (&/with-writer (.visitMethod =class Opcodes/ACC_STATIC "<clinit>" "()V" nil nil)
(|do [^MethodVisitor **writer** &/get-writer
:let [_ (.visitCode **writer**)]
- _ (compile-def-type compile ?body)
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/type-field datum-sig)]
- _ (&&/compile-meta compile ?meta)
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/anns-field datum-sig)]
+ ;; _ (compile-def-type compile ?body)
+ ;; :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/type-field datum-sig)]
+ ;; _ (&&/compile-meta compile ?meta)
+ ;; :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/anns-field datum-sig)]
_ (compile nil ?body)
- :let [_ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/value-field datum-sig)]
+ :let [_ (.visitTypeInsn **writer** Opcodes/CHECKCAST "java/lang/Object")
+ _ (.visitFieldInsn **writer** Opcodes/PUTSTATIC current-class &/value-field datum-sig)]
:let [_ (doto **writer**
(.visitInsn Opcodes/RETURN)
(.visitMaxs 0 0)
@@ -402,17 +407,19 @@
:let [_ (.visitEnd =class)]
_ (&&/save-class! def-name (.toByteArray =class))
:let [def-class (&&/load-class! class-loader (&host-generics/->class-name current-class))
- [def-type is-type?] (|case (&a-meta/meta-get &a-meta/type?-tag ?meta)
- (&/$Some (&/$BoolM true))
- (&/T [&type/Type
- true])
-
- _
- (if (&type/type= &type/Type =value-type)
- (&/T [&type/Type
- false])
- (&/T [(-> def-class (.getField &/type-field) (.get nil))
- false])))
+ def-type (&a/expr-type* ?body)
+ [;; def-type
+ is-type?] (|case (&a-meta/meta-get &a-meta/type?-tag ?meta)
+ (&/$Some (&/$BoolM true))
+ (&/T [;; &type/Type
+ true])
+
+ _
+ (if (&type/type= &type/Type =value-type)
+ (&/T [;; &type/Type
+ false])
+ (&/T [;; (-> def-class (.getField &/type-field) (.get nil))
+ false])))
def-meta ?meta
def-value (-> def-class (.getField &/value-field) (.get nil))]
_ (&/without-repl-closure