From a42c2004388ca204cae7bd1b3f4ef21d208f72b2 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 7 Apr 2019 18:20:33 -0400 Subject: Updated JVM compiler's tuple left-access mechanism to the new style. --- new-luxc/source/luxc/lang/translation/jvm.lux | 2 +- .../source/luxc/lang/translation/jvm/case.jvm.lux | 4 ++-- .../luxc/lang/translation/jvm/runtime.jvm.lux | 28 ++++++++++++---------- 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'new-luxc/source/luxc') diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux index 4d2031d12..61c86ae10 100644 --- a/new-luxc/source/luxc/lang/translation/jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm.lux @@ -114,7 +114,7 @@ (:: io.monad map (dictionary.contains? class-name)) (error.lift io.monad) (: (IO (Error Bit)))) - _ (if ?existing-class + _ (if existing-class? (wrap []) (loader.store class-name class-bytecode library))] (loader.load class-name loader)))) diff --git a/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux index 32b002b91..22817e8eb 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux @@ -153,8 +153,8 @@ (list)) #0) pushI)))) - ([synthesis.member/left "pm_left" function.identity] - [synthesis.member/right "pm_right" inc]) + ([synthesis.member/left "tuple_left" <|] + [synthesis.member/right "pm_right" inc]) (#synthesis.Alt leftP rightP) (do phase.monad diff --git a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux index 78e613076..6ea00df21 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux @@ -133,9 +133,14 @@ (def: pm-methods Def (let [tuple-sizeI (|>> (_.ALOAD 0) _.ARRAYLENGTH) - tuple-elemI (|>> (_.ALOAD 0) (_.ILOAD 1) _.AALOAD) - expected-last-sizeI (|>> (_.ILOAD 1) (_.int +1) _.IADD) - tuple-tailI (|>> (_.ALOAD 0) tuple-sizeI (_.int +1) _.ISUB _.AALOAD (_.CHECKCAST ($t.descriptor $Tuple)))] + last-right-indexI (|>> tuple-sizeI (_.int +1) _.ISUB) + leftsI (_.ILOAD 1) + left-indexI leftsI + accessI (|>> (_.ALOAD 0) left-indexI _.AALOAD) + sub-leftsI (|>> _.SWAP _.ISUB) + sub-tupleI (|>> (_.ALOAD 0) last-right-indexI _.AALOAD (_.CHECKCAST ($t.descriptor $Tuple))) + + expected-last-sizeI (|>> (_.ILOAD 1) (_.int +1) _.IADD)] (|>> ($d.method #$.Public $.staticM "pm_fail" ($t.method (list) #.None (list)) (|>> (_.NEW "java.lang.IllegalStateException") _.DUP @@ -223,21 +228,20 @@ (_.label @wrong) ## tag, sumT ## _.POP2 failureI))) - ($d.method #$.Public $.staticM "pm_left" ($t.method (list $Tuple $t.int) (#.Some $Object) (list)) + ($d.method #$.Public $.staticM "tuple_left" ($t.method (list $Tuple $t.int) (#.Some $Object) (list)) (<| _.with-label (function (_ @begin)) _.with-label (function (_ @not-recursive)) - (let [updated-idxI (|>> _.SWAP _.ISUB)]) (|>> (_.label @begin) - tuple-sizeI - expected-last-sizeI + last-right-indexI + leftsI _.DUP2 (_.IF_ICMPGT @not-recursive) ## Recursive - updated-idxI (_.ISTORE 1) - tuple-tailI (_.ASTORE 0) + sub-leftsI (_.ISTORE 1) + sub-tupleI (_.ASTORE 0) (_.GOTO @begin) (_.label @not-recursive) ## _.POP2 - tuple-elemI + accessI _.ARETURN))) ($d.method #$.Public $.staticM "pm_right" ($t.method (list $Tuple $t.int) (#.Some $Object) (list)) (<| _.with-label (function (_ @begin)) @@ -256,7 +260,7 @@ _.DUP2 (_.IF_ICMPEQ @tail) (_.IF_ICMPGT @slice) ## Must recurse - tuple-tailI (_.ASTORE 0) + sub-tupleI (_.ASTORE 0) updated-idxI (_.ISTORE 1) (_.GOTO @begin) (_.label @slice) @@ -264,7 +268,7 @@ _.ARETURN (_.label @tail) ## _.POP2 - tuple-elemI + accessI _.ARETURN))) ))) -- cgit v1.2.3