aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/compiler/jvm/case.clj4
-rw-r--r--luxc/src/lux/compiler/jvm/proc/common.clj67
-rw-r--r--luxc/src/lux/compiler/jvm/rt.clj10
3 files changed, 38 insertions, 43 deletions
diff --git a/luxc/src/lux/compiler/jvm/case.clj b/luxc/src/lux/compiler/jvm/case.clj
index 4c195ba36..32ca72ae3 100644
--- a/luxc/src/lux/compiler/jvm/case.clj
+++ b/luxc/src/lux/compiler/jvm/case.clj
@@ -196,10 +196,10 @@
(|do [^MethodVisitor *writer* &/get-writer
:let [$end (new Label)
bodies-labels (&/|map (fn [_] (new Label)) ?bodies)]
+ :let [_ (doto *writer*
+ (.visitInsn Opcodes/ACONST_NULL))]
_ (compile ?value)
:let [_ (doto *writer*
- (.visitInsn Opcodes/ACONST_NULL)
- (.visitInsn Opcodes/SWAP)
(.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))
_ (compile-pattern *writer* bodies-labels ?pm $end)]
_ (compile-bodies *writer* compile bodies-labels ?bodies $end)
diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj
index 444db63e3..36f23263d 100644
--- a/luxc/src/lux/compiler/jvm/proc/common.clj
+++ b/luxc/src/lux/compiler/jvm/proc/common.clj
@@ -227,8 +227,7 @@
$end (new Label)
_ (doto *writer*
(.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "compareTo" "(Ljava/lang/String;)I")
- (.visitLdcInsn (int -1))
- (.visitJumpInsn Opcodes/IF_ICMPEQ $then)
+ (.visitJumpInsn Opcodes/IFLT $then)
(.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "FALSE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitJumpInsn Opcodes/GOTO $end)
(.visitLabel $then)
@@ -267,40 +266,36 @@
(.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "text_clip" "(Ljava/lang/String;II)[Ljava/lang/Object;"))]]
(return nil)))
-(do-template [<name> <method>]
- (defn <name> [compile ?values special-args]
- (|do [:let [(&/$Cons ?text (&/$Cons ?part (&/$Cons ?start (&/$Nil)))) ?values]
- ^MethodVisitor *writer* &/get-writer
- _ (compile ?text)
- :let [_ (doto *writer*
- (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String"))]
- _ (compile ?part)
- :let [_ (doto *writer*
- (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String"))]
- _ (compile ?start)
- :let [_ (doto *writer*
- &&/unwrap-long
- (.visitInsn Opcodes/L2I))]
- :let [_ (doto *writer*
- (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" <method> "(Ljava/lang/String;I)I"))]
- :let [$not-found (new Label)
- $end (new Label)
- _ (doto *writer*
- (.visitInsn Opcodes/DUP)
- (.visitLdcInsn (int -1))
- (.visitJumpInsn Opcodes/IF_ICMPEQ $not-found)
- (.visitInsn Opcodes/I2L)
- &&/wrap-long
- (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;")
- (.visitJumpInsn Opcodes/GOTO $end)
- (.visitLabel $not-found)
- (.visitInsn Opcodes/POP)
- (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_none" "()[Ljava/lang/Object;")
- (.visitLabel $end))]]
- (return nil)))
-
- ^:private compile-text-index "indexOf"
- )
+(defn ^:private compile-text-index [compile ?values special-args]
+ (|do [:let [(&/$Cons ?text (&/$Cons ?part (&/$Cons ?start (&/$Nil)))) ?values]
+ ^MethodVisitor *writer* &/get-writer
+ _ (compile ?text)
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String"))]
+ _ (compile ?part)
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String"))]
+ _ (compile ?start)
+ :let [_ (doto *writer*
+ &&/unwrap-long
+ (.visitInsn Opcodes/L2I))]
+ :let [_ (doto *writer*
+ (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "indexOf" "(Ljava/lang/String;I)I"))]
+ :let [$not-found (new Label)
+ $end (new Label)
+ _ (doto *writer*
+ (.visitInsn Opcodes/DUP)
+ (.visitLdcInsn (int -1))
+ (.visitJumpInsn Opcodes/IF_ICMPEQ $not-found)
+ (.visitInsn Opcodes/I2L)
+ &&/wrap-long
+ (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;")
+ (.visitJumpInsn Opcodes/GOTO $end)
+ (.visitLabel $not-found)
+ (.visitInsn Opcodes/POP)
+ (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_none" "()[Ljava/lang/Object;")
+ (.visitLabel $end))]]
+ (return nil)))
(do-template [<name> <class> <method>]
(defn <name> [compile ?values special-args]
diff --git a/luxc/src/lux/compiler/jvm/rt.clj b/luxc/src/lux/compiler/jvm/rt.clj
index 7dd08dc62..6b9aeb680 100644
--- a/luxc/src/lux/compiler/jvm/rt.clj
+++ b/luxc/src/lux/compiler/jvm/rt.clj
@@ -93,7 +93,7 @@
(.visitVarInsn Opcodes/ISTORE 1) ;;
(.visitJumpInsn Opcodes/GOTO $begin)
(.visitLabel $not-rec) ;; tuple-size, index-last-elem
- (.visitInsn Opcodes/POP2) ;;
+ ;; (.visitInsn Opcodes/POP2) ;;
(.visitVarInsn Opcodes/ALOAD 0) ;; tuple
(.visitVarInsn Opcodes/ILOAD 1) ;; tuple, index
(.visitInsn Opcodes/AALOAD) ;; elem
@@ -139,7 +139,7 @@
(.visitMethodInsn Opcodes/INVOKESTATIC "java/util/Arrays" "copyOfRange" "([Ljava/lang/Object;II)[Ljava/lang/Object;")
(.visitInsn Opcodes/ARETURN)
(.visitLabel $is-last) ;; tuple-size, index-last-elem
- (.visitInsn Opcodes/POP2) ;;
+ ;; (.visitInsn Opcodes/POP2) ;;
(.visitVarInsn Opcodes/ALOAD 0) ;; tuple
(.visitVarInsn Opcodes/ILOAD 1) ;; tuple, index
(.visitInsn Opcodes/AALOAD) ;; elem
@@ -154,7 +154,7 @@
$not-right (new Label)
failure (fn [^MethodVisitor writer]
(doto writer
- (.visitInsn Opcodes/POP2)
+ ;; (.visitInsn Opcodes/POP2)
(.visitInsn Opcodes/ACONST_NULL)
(.visitInsn Opcodes/ARETURN)))
shortened (fn [^MethodVisitor writer]
@@ -192,7 +192,7 @@
(.visitJumpInsn Opcodes/IF_ACMPEQ $just-return)
(.visitJumpInsn Opcodes/GOTO $further)
(.visitLabel $just-return)
- (.visitInsn Opcodes/POP2)
+ ;; (.visitInsn Opcodes/POP2)
(.visitVarInsn Opcodes/ALOAD 0)
(.visitLdcInsn (int 2))
(.visitInsn Opcodes/AALOAD)
@@ -200,7 +200,7 @@
(.visitLabel $shorten)
(.visitVarInsn Opcodes/ALOAD 2)
(.visitJumpInsn Opcodes/IFNULL $not-right)
- (.visitInsn Opcodes/POP2)
+ ;; (.visitInsn Opcodes/POP2)
shortened
(.visitInsn Opcodes/ARETURN)
(.visitLabel $further) ;; tag, sum-tag