diff options
author | Eduardo Julian | 2017-11-12 23:49:34 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-12 23:49:34 -0400 |
commit | ca297162d5416a8c7b8af5f27757900d82d3ad03 (patch) | |
tree | ec9e664f09d6c29d91e9ae6be5d3abb6ef0e7ca4 /new-luxc/source/luxc/lang/translation | |
parent | 63624fd6b7f9f2563898655472025020483d398f (diff) |
- Fixed some bugs.
- Improved error reporting.
- Optimized pattern-matching a bit.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/case.jvm.lux | 87 |
1 files changed, 40 insertions, 47 deletions
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 [<special> <method>] - (^ [_ (#;Form (list [_ (#;Text <special>)] [_ (#;Nat idx)] subP))]) - (do meta;Monad<Meta> - [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 - <method> - ($t;method (list ../runtime;$Tuple $t;int) - (#;Some $Object) - (list)) - false) - pushI - subI))))) + (^ [_ (#;Form (list [_ (#;Text <special>)] [_ (#;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 + <method> + ($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 [<special> <flag>] - (^ [_ (#;Form (list [_ (#;Text <special>)] [_ (#;Nat idx)] subP))]) - (do meta;Monad<Meta> - [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)) - <flag> - ($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 <special>)] [_ (#;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)) + <flag> + ($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 "")]) |