From ca297162d5416a8c7b8af5f27757900d82d3ad03 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 12 Nov 2017 23:49:34 -0400 Subject: - Fixed some bugs. - Improved error reporting. - Optimized pattern-matching a bit. --- new-luxc/source/luxc/lang/translation/case.jvm.lux | 87 ++++++++++------------ 1 file changed, 40 insertions(+), 47 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/case.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/case.jvm.lux b/new-luxc/source/luxc/lang/translation/case.jvm.lux index 7821db70d..cb0aa2198 100644 --- a/new-luxc/source/luxc/lang/translation/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/case.jvm.lux @@ -108,57 +108,50 @@ ($i;IFEQ @else))) (^template [ ] - (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)] subP))]) - (do meta;Monad - [subI (translate-path' translate stack-depth @else @end subP)] - (wrap (case idx - +0 - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) - ($i;int 0) - $i;AALOAD - pushI - subI) - - _ - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) - ($i;int (nat-to-int idx)) - ($i;INVOKESTATIC hostL;runtime-class - - ($t;method (list ../runtime;$Tuple $t;int) - (#;Some $Object) - (list)) - false) - pushI - subI))))) + (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)]))]) + (meta/wrap (case idx + +0 + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) + ($i;int 0) + $i;AALOAD + pushI) + + _ + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Tuple)) + ($i;int (nat-to-int idx)) + ($i;INVOKESTATIC hostL;runtime-class + + ($t;method (list ../runtime;$Tuple $t;int) + (#;Some $Object) + (list)) + false) + pushI)))) (["lux case tuple left" "pm_left"] ["lux case tuple right" "pm_right"]) (^template [ ] - (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)] subP))]) - (do meta;Monad - [subI (translate-path' translate stack-depth @else @end subP)] - (wrap (<| $i;with-label (function [@success]) - $i;with-label (function [@fail]) - (|>. peekI - ($i;CHECKCAST ($t;descriptor ../runtime;$Variant)) - ($i;int (nat-to-int idx)) - - ($i;INVOKESTATIC hostL;runtime-class "pm_variant" - ($t;method (list ../runtime;$Variant ../runtime;$Tag ../runtime;$Flag) - (#;Some ../runtime;$Datum) - (list)) - false) - $i;DUP - ($i;IFNULL @fail) - ($i;GOTO @success) - ($i;label @fail) - $i;POP - ($i;GOTO @else) - ($i;label @success) - pushI - subI))))) + (^ [_ (#;Form (list [_ (#;Text )] [_ (#;Nat idx)]))]) + (meta/wrap (<| $i;with-label (function [@success]) + $i;with-label (function [@fail]) + (|>. peekI + ($i;CHECKCAST ($t;descriptor ../runtime;$Variant)) + ($i;int (nat-to-int idx)) + + ($i;INVOKESTATIC hostL;runtime-class "pm_variant" + ($t;method (list ../runtime;$Variant ../runtime;$Tag ../runtime;$Flag) + (#;Some ../runtime;$Datum) + (list)) + false) + $i;DUP + ($i;IFNULL @fail) + ($i;GOTO @success) + ($i;label @fail) + $i;POP + ($i;GOTO @else) + ($i;label @success) + pushI)))) (["lux case variant left" $i;NULL] ["lux case variant right" ($i;string "")]) -- cgit v1.2.3