From 5a1ea36c5ae4ccc990c77ff9a984468473384c0c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 27 Oct 2018 20:02:08 -0400 Subject: Some refactoring. --- new-luxc/source/program.lux | 53 +++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'new-luxc') diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index ebc94cacb..0362d14b0 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -1,8 +1,7 @@ (.module: [lux #* [control - [monad (#+ do)] - ["p" parser]] + [monad (#+ do)]] [data ["." error] ["." text @@ -14,10 +13,21 @@ [world ["." file (#+ File)] ["." console]] - [compiler - ["." cli] - ["." default (#+ Platform)]] - ["." interpreter]] + ["." compiler + ["." cli (#+ Configuration)] + [meta + ["." archive] + [io + ["." context]]] + [default + ["." platform (#+ Platform)] + ["." init] + ["." syntax] + ["." phase + ["." translation] + ["." statement]]]] + ## ["." interpreter] + ] [luxc [lang ["." host/jvm] @@ -45,23 +55,24 @@ (def: (timed action) (All [a] - (-> (Process a) (Process a))) + (-> (-> Any (Process a)) (Process a))) (do io.Monad [start (io.from-io instant.now) - result action + result (action []) finish (io.from-io instant.now) #let [elapsed-time (instant.span start finish) - _ (log! (format text.new-line "Elapsed time: " (%duration elapsed-time)))]] + _ (log! (format text.new-line + "Elapsed time: " (%duration elapsed-time)))]] (wrap result))) (def: jvm-platform (IO (Platform Process host/jvm.Anchor host/jvm.Inst host/jvm.Definition)) (do io.Monad [host jvm.init] - (wrap {#default.host host - #default.phase expression.translate - #default.runtime runtime.translate - #default.file-system file.JVM@System}))) + (wrap {#platform.host host + #platform.phase expression.translate + #platform.runtime runtime.translate + #platform.file-system file.JVM@System}))) (program: [{service cli.service}] (do io.Monad @@ -71,8 +82,18 @@ (#cli.Compilation configuration) (<| (or-crash! "Compilation failed:") ..timed - (default.compile platform configuration common.bundle)) + (function (_ _) + (do (:: (get@ #platform.file-system platform) &monad) + [state (platform.initialize platform common.bundle) + _ (platform.compile platform (set@ #cli.module syntax.prelude configuration) state) + ## _ (compile platform configuration state) + ## _ (cache/io.clean target ...) + ] + (wrap (log! "Compilation complete!"))))) (#cli.Interpretation configuration) - (<| (or-crash! "Interpretation failed:") - (interpreter.run io.Monad console platform configuration))))) + ## TODO: Fix the interpreter... + (undefined) + ## (<| (or-crash! "Interpretation failed:") + ## (interpreter.run io.Monad console platform configuration common.bundle)) + ))) -- cgit v1.2.3