aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/case.lux34
1 files changed, 34 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/case.lux b/new-luxc/source/luxc/lang/translation/jvm/case.lux
index 63d440c72..898c211f4 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/case.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/case.lux
@@ -150,6 +150,40 @@
#0)
pushI))
+ ## Extra optimization
+ (^ (synthesis.path/seq
+ (synthesis.member/left 0)
+ (synthesis.!bind-top register thenP)))
+ (do phase.monad
+ [then! (path' phase stack-depth @else @end thenP)]
+ (wrap (|>> peekI
+ (_.CHECKCAST ($t.descriptor runtime.$Tuple))
+ (_.int +0)
+ _.AALOAD
+ (_.ASTORE register)
+ then!)))
+
+ ## Extra optimization
+ (^template [<pm> <getter>]
+ (^ (synthesis.path/seq
+ (<pm> lefts)
+ (synthesis.!bind-top register thenP)))
+ (do phase.monad
+ [then! (path' phase stack-depth @else @end thenP)]
+ (wrap (|>> peekI
+ (_.CHECKCAST ($t.descriptor runtime.$Tuple))
+ (_.int (.int lefts))
+ (_.INVOKESTATIC //.runtime-class
+ <getter>
+ ($t.method (list runtime.$Tuple $t.int)
+ (#.Some $Object)
+ (list))
+ #0)
+ (_.ASTORE register)
+ then!))))
+ ([synthesis.member/left "tuple_left"]
+ [synthesis.member/right "tuple_right"])
+
(#synthesis.Alt leftP rightP)
(do phase.monad
[@alt-else _.make-label