diff options
author | Eduardo Julian | 2019-12-27 00:51:00 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-12-27 00:51:00 -0400 |
commit | 581ccee156457b0f84696def59fc324c1cbbdaba (patch) | |
tree | 0202c9a26d65920eeaabecffb810b5be0bc8a15d /new-luxc/source/luxc/lang/translation/jvm | |
parent | 9e6725e3fd45ad0b8faf54ec00ca9dcb8b603e32 (diff) |
Falling back to using the old method of JVM generation while I properly debug and optimize the new one.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/common.lux | 39 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/function.lux | 6 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/program.lux | 82 |
3 files changed, 103 insertions, 24 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/common.lux b/new-luxc/source/luxc/lang/translation/jvm/common.lux index 8b2a83526..6cd7f4f2f 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/common.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/common.lux @@ -1,24 +1,25 @@ (.module: [lux #* - [abstract - [monad (#+ do)]] - [control - ["." try (#+ Try)] - ["ex" exception (#+ exception:)] - ["." io]] - [data - [binary (#+ Binary)] - ["." text ("#/." hash) - format] - [collection - ["." dictionary (#+ Dictionary)]]] - ["." macro] - [host (#+ import:)] - [tool - [compiler - [reference (#+ Register)] - ["." name] - ["." phase]]]] + ## [abstract + ## [monad (#+ do)]] + ## [control + ## ["." try (#+ Try)] + ## ["ex" exception (#+ exception:)] + ## ["." io]] + ## [data + ## [binary (#+ Binary)] + ## ["." text ("#/." hash) + ## format] + ## [collection + ## ["." dictionary (#+ Dictionary)]]] + ## ["." macro] + ## [host (#+ import:)] + ## [tool + ## [compiler + ## [reference (#+ Register)] + ## ["." name] + ## ["." phase]]] + ] ## [luxc ## [lang ## [host diff --git a/new-luxc/source/luxc/lang/translation/jvm/function.lux b/new-luxc/source/luxc/lang/translation/jvm/function.lux index 34a4c890e..7a4bbef4e 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/function.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/function.lux @@ -240,16 +240,12 @@ (_.INVOKESPECIAL class "<init>" (init-method env function-arity)) _.ARETURN)) )))) - _.fuse) - failureI (|>> (_.INVOKESTATIC //.$Runtime "apply_fail" (type.method [(list) type.void (list)])) - _.NULL - _.ARETURN)] + _.fuse)] (def.method #$.Public $.noneM runtime.apply-method (runtime.apply-signature apply-arity) (|>> get-amount-of-partialsI (_.TABLESWITCH +0 (|> num-partials dec .int) @default @labels) casesI - failureI )))) (def: #export with-environment diff --git a/new-luxc/source/luxc/lang/translation/jvm/program.lux b/new-luxc/source/luxc/lang/translation/jvm/program.lux new file mode 100644 index 000000000..7ac897009 --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/jvm/program.lux @@ -0,0 +1,82 @@ +(.module: + [lux #* + [target + [jvm + ["$t" type]]]] + [luxc + [lang + [host + ["_" jvm + ["$d" def] + ["$i" inst]]] + [translation + ["." jvm + ["." runtime]]]]]) + +(def: #export class "LuxProgram") + +(def: ^Object ($t.class "java.lang.Object" (list))) + +(def: #export (program programI) + (-> _.Inst _.Definition) + (let [nilI runtime.noneI + num-inputsI (|>> ($i.ALOAD 0) $i.ARRAYLENGTH) + decI (|>> ($i.int +1) $i.ISUB) + headI (|>> $i.DUP + ($i.ALOAD 0) + $i.SWAP + $i.AALOAD + $i.SWAP + $i.DUP_X2 + $i.POP) + pairI (|>> ($i.int +2) + ($i.ANEWARRAY ..^Object) + $i.DUP_X1 + $i.SWAP + ($i.int +0) + $i.SWAP + $i.AASTORE + $i.DUP_X1 + $i.SWAP + ($i.int +1) + $i.SWAP + $i.AASTORE) + consI (|>> ($i.int +1) + ($i.string "") + $i.DUP2_X1 + $i.POP2 + runtime.variantI) + prepare-input-listI (<| $i.with-label (function (_ @loop)) + $i.with-label (function (_ @end)) + (|>> nilI + num-inputsI + ($i.label @loop) + decI + $i.DUP + ($i.IFLT @end) + headI + pairI + consI + $i.SWAP + ($i.GOTO @loop) + ($i.label @end) + $i.POP)) + feed-inputsI ($i.INVOKEVIRTUAL jvm.$Function runtime.apply-method (runtime.apply-signature 1)) + run-ioI (|>> ($i.CHECKCAST jvm.$Function) + $i.NULL + ($i.INVOKEVIRTUAL jvm.$Function runtime.apply-method (runtime.apply-signature 1))) + main-type ($t.method [(list ($t.array ($t.class "java.lang.String" (list)))) + $t.void + (list)])] + [..class + ($d.class #_.V1_6 + #_.Public _.finalC + ..class + (list) ..^Object + (list) + (|>> ($d.method #_.Public _.staticM "main" main-type + (|>> programI + prepare-input-listI + feed-inputsI + run-ioI + $i.RETURN))))])) |