diff options
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/compiler/jvm/case.clj | 13 | ||||
-rw-r--r-- | luxc/src/lux/compiler/jvm/rt.clj | 28 |
2 files changed, 18 insertions, 23 deletions
diff --git a/luxc/src/lux/compiler/jvm/case.clj b/luxc/src/lux/compiler/jvm/case.clj index aa262a102..01b5b924c 100644 --- a/luxc/src/lux/compiler/jvm/case.clj +++ b/luxc/src/lux/compiler/jvm/case.clj @@ -11,7 +11,8 @@ [host :as &host] [optimizer :as &o]) [lux.analyser.case :as &a-case] - [lux.compiler.jvm.base :as &&]) + [lux.compiler.jvm.base :as &&] + [lux.compiler.jvm.rt :as &rt]) (:import (org.objectweb.asm Opcodes Label ClassWriter @@ -38,10 +39,11 @@ (defn ^:private stack-peek [^MethodVisitor writer] (doto writer (.visitInsn Opcodes/DUP) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_peek" "([Ljava/lang/Object;)Ljava/lang/Object;"))) + &rt/peekI)) -(defn ^:private compile-pattern* [^MethodVisitor writer bodies stack-depth $else pm] +(defn ^:private compile-pattern* "(-> MethodVisitor Case-Pattern (List Label) Int Label MethodVisitor)" + [^MethodVisitor writer bodies stack-depth $else pm] (|case pm (&o/$ExecPM _body-idx) (|case (&/|at _body-idx bodies) @@ -54,14 +56,13 @@ (assert false)) (&o/$PopPM) - (doto writer - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_pop" "([Ljava/lang/Object;)[Ljava/lang/Object;")) + (&rt/popI writer) (&o/$BindPM _var-id) (doto writer stack-peek (.visitVarInsn Opcodes/ASTORE _var-id) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_pop" "([Ljava/lang/Object;)[Ljava/lang/Object;")) + &rt/popI) (&o/$BitPM _value) (doto writer diff --git a/luxc/src/lux/compiler/jvm/rt.clj b/luxc/src/lux/compiler/jvm/rt.clj index b64d7312b..4a8b470ac 100644 --- a/luxc/src/lux/compiler/jvm/rt.clj +++ b/luxc/src/lux/compiler/jvm/rt.clj @@ -289,6 +289,17 @@ ^:private compile-LuxRT-frac-methods "decode_frac" "java/lang/Double" "parseDouble" "(Ljava/lang/String;)D" &&/wrap-double ) +(defn popI [writer] + (doto writer + (.visitLdcInsn (int 0)) + (.visitInsn Opcodes/AALOAD) + (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;"))) + +(defn peekI [writer] + (doto writer + (.visitLdcInsn (int 1)) + (.visitInsn Opcodes/AALOAD))) + (defn ^:private compile-LuxRT-pm-methods [^ClassWriter =class] (|let [_ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "pm_fail" "()V" nil nil) (.visitCode) @@ -313,23 +324,6 @@ (.visitInsn Opcodes/AASTORE) (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) - (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "pm_stack_pop" "([Ljava/lang/Object;)[Ljava/lang/Object;" nil nil) - (.visitCode) - (.visitVarInsn Opcodes/ALOAD 0) - (.visitLdcInsn (int 0)) - (.visitInsn Opcodes/AALOAD) - (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") - (.visitInsn Opcodes/ARETURN) - (.visitMaxs 0 0) - (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "pm_stack_peek" "([Ljava/lang/Object;)Ljava/lang/Object;" nil nil) - (.visitCode) - (.visitVarInsn Opcodes/ALOAD 0) - (.visitLdcInsn (int 1)) - (.visitInsn Opcodes/AALOAD) - (.visitInsn Opcodes/ARETURN) - (.visitMaxs 0 0) (.visitEnd))] nil)) |