aboutsummaryrefslogtreecommitdiff
path: root/src/lux/compiler/case.clj
diff options
context:
space:
mode:
authorEduardo Julian2016-11-19 02:01:21 -0400
committerEduardo Julian2016-11-19 02:01:21 -0400
commit6e44438a3c67de97a542eca05c2a21015288da28 (patch)
treee1781c865c3921a6f62ba2dc3735a10eb455eabb /src/lux/compiler/case.clj
parent0a11fd59e47438af8a8999eb5f749f4b9f5d4cf0 (diff)
- Tuple/record access on index 0 gets compiled to direct array access.
Diffstat (limited to '')
-rw-r--r--src/lux/compiler/case.clj21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lux/compiler/case.clj b/src/lux/compiler/case.clj
index 9acf3854d..afdcd3eed 100644
--- a/src/lux/compiler/case.clj
+++ b/src/lux/compiler/case.clj
@@ -127,13 +127,20 @@
(&/$Right _idx)
(&/T [_idx true]))]
- (doto writer
- stack-peek
- (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;")
- (.visitLdcInsn (int _idx))
- (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" (if is-tail? "product_getRight" "product_getLeft") "([Ljava/lang/Object;I)Ljava/lang/Object;")
- (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")
- ))
+ (if (= 0 _idx)
+ (doto writer
+ stack-peek
+ (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;")
+ (.visitLdcInsn (int 0))
+ (.visitInsn Opcodes/AALOAD)
+ (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))
+ (doto writer
+ stack-peek
+ (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;")
+ (.visitLdcInsn (int _idx))
+ (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" (if is-tail? "product_getRight" "product_getLeft") "([Ljava/lang/Object;I)Ljava/lang/Object;")
+ (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")
+ )))
(&o/$VariantPM _idx+)
(|let [$success (new Label)