From fa37f5d17184db1ed95949352e71542af8fb4ce1 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 24 Dec 2019 23:05:30 -0400 Subject: Ported program generation, host environment and packaging machinery to stdlib. --- new-luxc/source/program.lux | 112 ++++++++------------------------------------ 1 file changed, 20 insertions(+), 92 deletions(-) (limited to 'new-luxc/source/program.lux') diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index f975d2a87..2b2278cec 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -1,5 +1,5 @@ (.module: - [lux #* + [lux (#- Definition) ["@" target] ["." host (#+ import:)] [abstract @@ -19,33 +19,28 @@ ["." file]] [target [jvm - ["$t" type]]] + [bytecode (#+ Bytecode)]]] [tool [compiler [phase ["." macro (#+ Expander)] [extension (#+ Phase Bundle Operation Handler Extender) ["." analysis #_ - ["#" jvm]]]] + ["#" jvm]] + ["." directive #_ + ["#" jvm]]] + ["." generation #_ + ["#" jvm/extension] + ["." jvm + ["." runtime (#+ Anchor Definition)] + ["#/." program] + ["." packager] + ["#/." host]]]] [default ["." platform (#+ Platform)]]]]] [program ["/" compositor - ["/." cli]]] - [luxc - [lang - ["." packager] - [host - ["_" jvm - ["$d" def] - ["$i" inst]]] - ["." directive #_ - ["#" jvm]] - [translation - ["." jvm - ["." runtime] - ["." expression] - ["translation" extension]]]]]) + ["/." cli]]]) (import: #long java/lang/reflect/Method (invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)) @@ -90,81 +85,14 @@ apply-method)))) (def: #export platform - (IO (Platform IO _.Anchor _.Inst _.Definition)) + (IO (Platform IO Anchor (Bytecode Any) Definition)) (do io.monad - [host jvm.host] + [host jvm/host.host] (wrap {#platform.&monad io.monad #platform.&file-system file.system #platform.host host - #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)) - 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)])] - [..program-class - ($d.class #_.V1_6 - #_.Public _.finalC - ..program-class - (list) $Object - (list) - (|>> ($d.method #_.Public _.staticM "main" main-type - (|>> programI - prepare-input-listI - feed-inputsI - run-ioI - $i.RETURN))))])) + #platform.phase jvm.generate + #platform.runtime runtime.generate}))) (def: extender Extender @@ -204,9 +132,9 @@ ..expander analysis.bundle ..platform - translation.bundle + generation.bundle directive.bundle - ..program + jvm/program.program ..extender service - [(packager.package ..program-class) jar-path]))) + [(packager.package jvm/program.class) jar-path]))) -- cgit v1.2.3