aboutsummaryrefslogtreecommitdiff
path: root/new-luxc
diff options
context:
space:
mode:
authorEduardo Julian2018-08-04 10:05:26 -0400
committerEduardo Julian2018-08-04 10:05:26 -0400
commit221cf3ea1bd48a8c678d3447558ea94631114ebc (patch)
treed5b7315718f9ec75576f5026783db5a5c752a6a3 /new-luxc
parentc1f900baea30dbca55489c6afaf80dcfcda8813b (diff)
Made some adjustments to fit stdlib's compiler infrastructure to new-luxc.
Diffstat (limited to 'new-luxc')
-rw-r--r--new-luxc/source/luxc/lang/host/jvm/def.lux2
-rw-r--r--new-luxc/source/program.lux108
-rw-r--r--new-luxc/test/test/luxc/lang/translation/primitive.lux3
-rw-r--r--new-luxc/test/test/luxc/lang/translation/structure.lux2
4 files changed, 74 insertions, 41 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))
+ )))))
diff --git a/new-luxc/test/test/luxc/lang/translation/primitive.lux b/new-luxc/test/test/luxc/lang/translation/primitive.lux
index 12292e08c..08fab78aa 100644
--- a/new-luxc/test/test/luxc/lang/translation/primitive.lux
+++ b/new-luxc/test/test/luxc/lang/translation/primitive.lux
@@ -43,7 +43,8 @@
))))
(context: "[JVM] Primitives."
- (<| (times 100)
+ (<| (seed 7147645721729046766)
+ ## (times 100)
(spec run-jvm)))
## (context: "[JS] Primitives."
diff --git a/new-luxc/test/test/luxc/lang/translation/structure.lux b/new-luxc/test/test/luxc/lang/translation/structure.lux
index cd1b88c9d..c92b132e2 100644
--- a/new-luxc/test/test/luxc/lang/translation/structure.lux
+++ b/new-luxc/test/test/luxc/lang/translation/structure.lux
@@ -9,7 +9,7 @@
[text ("text/." Equivalence<Text>)
format]
[collection
- ["." array]
+ ["." array (#+ Array)]
["." list ("list/." Functor<List>)]]]
[math
["r" random]]