diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux | 28 |
1 files changed, 16 insertions, 12 deletions
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))) ))) |