diff options
author | Eduardo Julian | 2018-08-04 10:05:26 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-08-04 10:05:26 -0400 |
commit | 221cf3ea1bd48a8c678d3447558ea94631114ebc (patch) | |
tree | d5b7315718f9ec75576f5026783db5a5c752a6a3 /new-luxc/source | |
parent | c1f900baea30dbca55489c6afaf80dcfcda8813b (diff) |
Made some adjustments to fit stdlib's compiler infrastructure to new-luxc.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/host/jvm/def.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/program.lux | 108 |
2 files changed, 71 insertions, 39 deletions
diff --git a/new-luxc/source/luxc/lang/host/jvm/def.lux b/new-luxc/source/luxc/lang/host/jvm/def.lux index 33ded893b..ff31157b0 100644 --- a/new-luxc/source/luxc/lang/host/jvm/def.lux +++ b/new-luxc/source/luxc/lang/host/jvm/def.lux @@ -5,7 +5,7 @@ format] ["." product] [collection - ["a" array] + ["." array (#+ Array)] ["." list ("list/." Functor<List>)]]] ["." host (#+ import: do-to)] ["." function]] diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index 62c3ad03d..7cb10b457 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -5,48 +5,59 @@ ["p" parser]] [concurrency ["." promise (#+ Promise)] - [task (#+ Task)]] + ["." task (#+ Task)]] [data ["e" error] [text format]] - ["." io (#- run)] + ["." io (#+ IO Process io)] [time ["." instant]] ["." cli (#+ CLI program:)] [world - [file (#+ File)]]] + ["." file (#+ File)]] + [compiler + ["." default (#+ Configuration Platform)]]] [luxc - ["." repl] + ## ["." repl] [lang - [".L" translation]]]) + ["." host/jvm] + [translation + ["." jvm + ["." runtime] + ["." expression]]]]]) (type: Build - {#build-sources (List File) - #build-target File - #build-program Text}) + [Configuration Text]) (type: REPL - {#repl-sources (List File) - #repl-target File}) + Configuration) -(def: (param [short long]) - (-> [Text Text] (CLI Text)) - (cli.somewhere (p.after (p.either (cli.this short) (cli.this long)) - cli.any))) +(do-template [<name> <short> <long>] + [(def: <name> + (CLI Text) + (cli.parameter [<short> <long>]))] + + [source "-s" "--source"] + [target "-t" "--target"] + [program "-p" "--program"] + ) + +(def: configuration + (CLI Configuration) + ($_ p.and + (p.some ..source) + ..target)) (def: build (CLI Build) - ($_ p.seq - (p.some (param ["-s" "--source"])) - (param ["-t" "--target"]) - (param ["-p" "--program"]))) + ($_ p.and + configuration + ..program)) (def: repl (CLI REPL) - ($_ p.seq - (p.some (param ["-s" "--source"])) - (param ["-t" "--target"]))) + ..configuration) (type: Service (#Build Build) @@ -58,7 +69,8 @@ (p.after (cli.this "repl") repl))) (def: (or-crash! failure-describer action) - (All [a] (-> Text (Task a) (Promise a))) + (All [a] + (-> Text (Task a) (Promise a))) (do promise.Monad<Promise> [?output action] (case ?output @@ -66,24 +78,44 @@ (exec (log! (format "\n" failure-describer "\n" error "\n")) - ("lux io exit" 1)) + (io.run (io.exit +1))) (#e.Success output) (wrap output)))) +(def: (timed action) + (All [a] + (-> (Process a) (Process a))) + (do io.Monad<Process> + [start (io.from-io instant.now) + result action + finish (io.from-io instant.now) + #let [elapsed-time (instant.span start finish) + _ (log! (format "\n" "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<IO> + [host jvm.init] + (wrap {#default.host host + #default.phase expression.translate + #default.runtime runtime.translate + #default.file-system file.JVM@System}))) + (program: [{service ..service}] - (exec (case service - (#Build [sources target program]) - (<| (or-crash! "Compilation failed:") - (promise.future - (do io.Monad<Process> - [#let [start (io.run instant.now)] - result (translationL.translate-program sources target program) - #let [end (io.run instant.now) - _ (log! (format "\n" "Elapsed time: " (%duration (instant.span start end))))]] - (wrap result)))) - - (#REPL [sources target]) - (<| (or-crash! "REPL failed:") - (repl.run sources target))) - (io []))) + (do io.Monad<IO> + [platform ..jvm-platform] + (wrap (: (Promise Any) + (case service + (#Build [configuration program]) + (<| (or-crash! "Compilation failed:") + promise.future + ..timed + (default.compile platform configuration program)) + + (#REPL configuration) + (undefined) + ## (<| (or-crash! "REPL failed:") + ## (repl.run sources target)) + ))))) |