diff options
Diffstat (limited to 'new-luxc/source/program.lux')
-rw-r--r-- | new-luxc/source/program.lux | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index b579b0df0..91b42c981 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -10,6 +10,8 @@ [parser [cli (#+ program:)]]] [data + [text + ["%" format (#+ format)]] [collection [array (#+ Array)] ["." dictionary]]] @@ -22,8 +24,8 @@ [compiler [phase ["." macro (#+ Expander)] - ["." extension #_ - [analysis + [extension + ["." analysis #_ ["#" jvm]]]] [default ["." platform (#+ Platform)]]]]] @@ -32,19 +34,18 @@ ["/." cli]]] [luxc [lang + ["." packager] [host ["_" jvm ["$d" def] ["$i" inst]]] - [directive - [".S" jvm]] + ["." directive #_ + ["#" jvm]] [translation ["." jvm ["." runtime] ["." expression] - [procedure - [".E" common] - [".E" host]]]]]]) + ["translation" extension]]]]]) (import: #long java/lang/reflect/Method (invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)) @@ -80,7 +81,7 @@ (host.array-write 1 (:coerce java/lang/Object lux))) apply-method)))) -(def: #export jvm +(def: #export platform (IO (Platform IO _.Anchor _.Inst _.Definition)) (do io.monad [host jvm.host] @@ -90,6 +91,8 @@ #platform.phase expression.translate #platform.runtime runtime.translate}))) +(def: program-class "LuxProgram") + (def: #export (program programI) (-> _.Inst _.Definition) (let [$Object ($t.class "java.lang.Object" (list)) @@ -134,40 +137,39 @@ $i.SWAP ($i.GOTO @loop) ($i.label @end) - $i.POP - ($i.ASTORE 0))) + $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)]) - bytecode-name "_"] - [bytecode-name + (list)])] + [..program-class ($d.class #_.V1_6 #_.Public _.finalC - bytecode-name + ..program-class (list) $Object (list) (|>> ($d.method #_.Public _.staticM "main" main-type - (|>> prepare-input-listI - programI + (|>> programI + prepare-input-listI + feed-inputsI run-ioI - $i.POP $i.RETURN))))])) -(def: #export bundle - _.Bundle - (dictionary.merge commonE.bundle - hostE.bundle)) - (program: [{service /cli.service}] - (/.compiler @.jvm - ".jvm" - ..expander - extension.bundle - ..jvm - ..bundle - jvmS.bundle - ..program - service)) + (let [(^slots [#/cli.target #/cli.module]) (case service + (#/cli.Compilation configuration) configuration + (#/cli.Interpretation configuration) configuration) + jar-path (format target (:: file.system separator) "program.jar")] + (/.compiler @.jvm + ".jvm" + ..expander + analysis.bundle + ..platform + translation.bundle + directive.bundle + ..program + service + [(packager.package ..program-class) jar-path]))) |