aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source
diff options
context:
space:
mode:
authorEduardo Julian2019-04-07 18:20:33 -0400
committerEduardo Julian2019-04-07 18:20:33 -0400
commita42c2004388ca204cae7bd1b3f4ef21d208f72b2 (patch)
tree3878f8cef31c1e96bf635142696dd1786e49b2ec /new-luxc/source
parenta4e0eb58480a05e4c23a07d33965022125c539f2 (diff)
Updated JVM compiler's tuple left-access mechanism to the new style.
Diffstat (limited to 'new-luxc/source')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/case.jvm.lux4
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux28
3 files changed, 19 insertions, 15 deletions
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)))
)))