aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/case.lux
diff options
context:
space:
mode:
authorEduardo Julian2019-06-14 23:38:53 -0400
committerEduardo Julian2019-06-14 23:38:53 -0400
commit7ee04017ee2ef5376c566b00750fd521c0ecac42 (patch)
treefd7bac69714079cfc9bd44bb56fad0321350f534 /new-luxc/source/luxc/lang/translation/jvm/case.lux
parentfcb8ce8340f4226a38d08f9e2f108e5ec0a95018 (diff)
Some fixes for the scripting languages.
+ Small optimizations for pattern-matching generation.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm/case.lux')
-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