From 7ee04017ee2ef5376c566b00750fd521c0ecac42 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 14 Jun 2019 23:38:53 -0400 Subject: Some fixes for the scripting languages. + Small optimizations for pattern-matching generation.--- new-luxc/source/luxc/lang/translation/jvm/case.lux | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'new-luxc/source/luxc') 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 [ ] + (^ (synthesis.path/seq + ( 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 + + ($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 -- cgit v1.2.3