diff options
author | Eduardo Julian | 2015-03-01 12:43:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-03-01 12:43:52 -0400 |
commit | 83a1a1510ca2e83711a80ff2eb961c5694306b9e (patch) | |
tree | 5ce5a13a61b771d27a64bd26c915fd54c75fa0a6 /src/lux/compiler/lux.clj | |
parent | b0d7e67b72fae763050b050d3452514db57ac682 (diff) |
Almost done with the super refactoring.
Codebase still needs to be simplified further, though.
Also, an explicit optimization phase, between analysis and compilation, must be established.
Diffstat (limited to '')
-rw-r--r-- | src/lux/compiler/lux.clj | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index 4635bfa1a..81d68c31c 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -93,22 +93,19 @@ (range num-elems))] (return nil))) -(defn compile-variant [compile *type* ?tag ?members] +(defn compile-variant [compile *type* ?tag ?value] (exec [*writer* &/get-writer - :let [variant-class* (str (&host/->class &host/variant-class) (count ?members)) + :let [variant-class* (&host/->class &host/variant-class) _ (doto *writer* (.visitTypeInsn Opcodes/NEW variant-class*) (.visitInsn Opcodes/DUP) (.visitMethodInsn Opcodes/INVOKESPECIAL variant-class* "<init>" "()V") (.visitInsn Opcodes/DUP) (.visitLdcInsn ?tag) - (.visitFieldInsn Opcodes/PUTFIELD variant-class* "tag" (&host/->type-signature "java.lang.String")))] - _ (map-m (fn [[?tfield ?member]] - (exec [:let [_ (.visitInsn *writer* Opcodes/DUP)] - ret (compile ?member) - :let [_ (.visitFieldInsn *writer* Opcodes/PUTFIELD variant-class* (str &&/partial-prefix ?tfield) "Ljava/lang/Object;")]] - (return ret))) - (map vector (range (count ?members)) ?members))] + (.visitFieldInsn Opcodes/PUTFIELD variant-class* "tag" (&host/->type-signature "java.lang.String")) + (.visitInsn Opcodes/DUP))] + _ (compile ?value) + :let [_ (.visitFieldInsn *writer* Opcodes/PUTFIELD variant-class* "value" (&host/->type-signature "java.lang.Object"))]] (return nil))) (defn compile-local [compile *type* ?idx] |