diff options
author | Eduardo Julian | 2016-01-17 19:13:20 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-01-17 19:13:20 -0400 |
commit | d8e0bfe09206ec9a8368266fc67523f761666d40 (patch) | |
tree | 0390b09fee4407684f36204cdd98eb06c44a9e95 | |
parent | 89169382b9ade7d4692315ce02d5fbb747965d0d (diff) |
- Removed the tags off tuples/products & variants/sums, as they were no longer necessary.
Diffstat (limited to '')
-rw-r--r-- | src/lux/base.clj | 11 | ||||
-rw-r--r-- | src/lux/compiler/host.clj | 28 | ||||
-rw-r--r-- | src/lux/compiler/lux.clj | 9 |
3 files changed, 16 insertions, 32 deletions
diff --git a/src/lux/base.clj b/src/lux/base.clj index 05668a245..3544c88ec 100644 --- a/src/lux/base.clj +++ b/src/lux/base.clj @@ -145,8 +145,6 @@ (def module-class-name "_") (def +name-separator+ ";") (def unit-tag (.intern (str (char 0) "unit" (char 0)))) -(def sum-tag (.intern (str (char 0) "sum" (char 0)))) -(def product-tag (.intern (str (char 0) "product" (char 0)))) (defn T [elems] (case (count elems) @@ -157,10 +155,10 @@ (first elems) ;; else - (to-array (conj elems product-tag)))) + (to-array elems))) (defn V [^Long tag value] - (to-array [sum-tag (int tag) nil value])) + (to-array [(int tag) nil value])) ;; Constructors (def None$ (V $None unit-tag)) @@ -198,9 +196,8 @@ (transform-pattern (first pattern)) ;; else - (conj (mapv transform-pattern pattern) '_)) - (seq? pattern) ['_ - (eval (first pattern)) + (mapv transform-pattern pattern)) + (seq? pattern) [(eval (first pattern)) '_ (transform-pattern (vec (rest pattern)))] :else pattern diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj index 2514dfaa5..95fb2ff34 100644 --- a/src/lux/compiler/host.clj +++ b/src/lux/compiler/host.clj @@ -701,10 +701,6 @@ full-name nil super-class (into-array String []))) =unit-tag (doto (.visitField =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) &&/unit-tag-field tag-sig nil &/unit-tag) (.visitEnd)) - =sum-tag (doto (.visitField =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) &&/sum-tag-field tag-sig nil &/sum-tag) - (.visitEnd)) - =product-tag (doto (.visitField =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) &&/product-tag-field tag-sig nil &/product-tag) - (.visitEnd)) =init-method (doto (.visitMethod =class Opcodes/ACC_PRIVATE init-method "()V" nil nil) (.visitCode) (.visitVarInsn Opcodes/ALOAD 0) @@ -720,7 +716,7 @@ (.visitVarInsn Opcodes/ALOAD 0) ;; tuple (.visitInsn Opcodes/ARRAYLENGTH) ;; tuple-size (.visitVarInsn Opcodes/ILOAD 1) ;; tuple-size, index - (.visitLdcInsn (int 2)) ;; tuple-size, index, offset-last-elem + (.visitLdcInsn (int 1)) ;; tuple-size, index, offset-last-elem (.visitInsn Opcodes/IADD) ;; tuple-size, index-last-elem (.visitInsn Opcodes/DUP2) ;; tuple-size, index-last-elem, tuple-size, index-last-elem (.visitJumpInsn Opcodes/IF_ICMPGT $not-rec) @@ -729,7 +725,7 @@ (.visitVarInsn Opcodes/ALOAD 0) ;; sub-index, tuple (.visitInsn Opcodes/DUP) ;; sub-index, tuple, tuple (.visitInsn Opcodes/ARRAYLENGTH) ;; sub-index, tuple, tuple-size - (.visitLdcInsn (int 2)) ;; sub-index, tuple, tuple-size, offset-last-elem + (.visitLdcInsn (int 1)) ;; sub-index, tuple, tuple-size, offset-last-elem (.visitInsn Opcodes/ISUB) ;; sub-index, tuple, index-last-elem (.visitInsn Opcodes/AALOAD) ;; sub-index, sub-tuple (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") @@ -751,7 +747,7 @@ (.visitVarInsn Opcodes/ALOAD 0) ;; tuple (.visitInsn Opcodes/ARRAYLENGTH) ;; tuple-size (.visitVarInsn Opcodes/ILOAD 1) ;; tuple-size, index - (.visitLdcInsn (int 2)) ;; tuple-size, index, offset-last-elem + (.visitLdcInsn (int 1)) ;; tuple-size, index, offset-last-elem (.visitInsn Opcodes/IADD) ;; tuple-size, index-last-elem (.visitInsn Opcodes/DUP2) ;; tuple-size, index-last-elem, tuple-size, index-last-elem (.visitJumpInsn Opcodes/IF_ICMPEQ $is-last) ;; tuple-size, index-last-elem @@ -781,7 +777,7 @@ (.visitLabel $begin) (.visitVarInsn Opcodes/ILOAD 1) ;; tag (.visitVarInsn Opcodes/ALOAD 0) ;; tag, sum - (.visitLdcInsn (int 1)) ;; tag, sum, sum-tag-idx + (.visitLdcInsn (int 0)) ;; tag, sum, sum-tag-idx (.visitInsn Opcodes/AALOAD) ;; tag, sum-tag' &&/unwrap-int ;; tag, sum-tag (.visitInsn Opcodes/DUP2) ;; tag, sum-tag, tag, sum-tag @@ -795,18 +791,18 @@ (.visitFrame Opcodes/F_NEW (int 2) (to-array ["[Ljava/lang/Object;" Opcodes/INTEGER]) (int 2) (to-array [Opcodes/INTEGER Opcodes/INTEGER])) (.visitInsn Opcodes/POP2) (.visitVarInsn Opcodes/ALOAD 0) - (.visitLdcInsn (int 3)) + (.visitLdcInsn (int 2)) (.visitInsn Opcodes/AALOAD) (.visitInsn Opcodes/ARETURN) (.visitLabel $further) ;; tag, sum-tag (.visitFrame Opcodes/F_NEW (int 2) (to-array ["[Ljava/lang/Object;" Opcodes/INTEGER]) (int 2) (to-array [Opcodes/INTEGER Opcodes/INTEGER])) (.visitVarInsn Opcodes/ALOAD 0) ;; tag, sum-tag, sum - (.visitLdcInsn (int 2)) ;; tag, sum-tag, sum, last-index? + (.visitLdcInsn (int 1)) ;; tag, sum-tag, sum, last-index? (.visitInsn Opcodes/AALOAD) ;; tag, sum-tag, last? (.visitJumpInsn Opcodes/IFNULL $not-right) ;; tag, sum-tag (.visitInsn Opcodes/ISUB) ;; sub-tag (.visitVarInsn Opcodes/ALOAD 0) ;; sub-tag, sum - (.visitLdcInsn (int 3)) ;; sub-tag, sum, sub-sum-idx + (.visitLdcInsn (int 2)) ;; sub-tag, sum, sub-sum-idx (.visitInsn Opcodes/AALOAD) ;; sub-tag, sub-sum (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") (.visitVarInsn Opcodes/ASTORE 0) ;; sub-tag @@ -824,23 +820,19 @@ (.visitCode) (.visitVarInsn Opcodes/ALOAD 2) (.visitJumpInsn Opcodes/IFNULL $is-null) - (.visitLdcInsn (int 4)) + (.visitLdcInsn (int 3)) (.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object") (.visitInsn Opcodes/DUP) (.visitLdcInsn (int 0)) - (.visitLdcInsn &/sum-tag) - (.visitInsn Opcodes/AASTORE) - (.visitInsn Opcodes/DUP) - (.visitLdcInsn (int 1)) (.visitVarInsn Opcodes/ILOAD 0) (&&/wrap-int) (.visitInsn Opcodes/AASTORE) (.visitInsn Opcodes/DUP) - (.visitLdcInsn (int 2)) + (.visitLdcInsn (int 1)) (.visitVarInsn Opcodes/ALOAD 1) (.visitInsn Opcodes/AASTORE) (.visitInsn Opcodes/DUP) - (.visitLdcInsn (int 3)) + (.visitLdcInsn (int 2)) (.visitVarInsn Opcodes/ALOAD 2) (.visitInsn Opcodes/AASTORE) (.visitInsn Opcodes/ARETURN) diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index 87de12497..80bf065da 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -66,7 +66,7 @@ _ (|do [:let [_ (doto *writer* - (.visitLdcInsn (int (inc num-elems))) + (.visitLdcInsn (int num-elems)) (.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object"))] _ (&/map2% (fn [idx elem] (|do [:let [_ (doto *writer* @@ -75,12 +75,7 @@ ret (compile elem) :let [_ (.visitInsn *writer* Opcodes/AASTORE)]] (return ret))) - (&/|range num-elems) ?elems) - :let [_ (doto *writer* - (.visitInsn Opcodes/DUP) - (.visitLdcInsn (int num-elems)) - (.visitLdcInsn &/product-tag) - (.visitInsn Opcodes/AASTORE))]] + (&/|range num-elems) ?elems)] (return nil))))) (defn compile-variant [compile tag tail? value] |