aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source
diff options
context:
space:
mode:
authorEduardo Julian2018-01-08 22:09:12 -0400
committerEduardo Julian2018-01-08 22:09:12 -0400
commitd48da794a693c00990c411b669d6412b8bf4d904 (patch)
treea1442427fdd9852ec0199a65b4b9999b35261137 /new-luxc/source
parent9eaaaf953ba7ce1eeb805603f4e113aa15f5178f (diff)
- Re-factored initialization functions to their own module.
Diffstat (limited to 'new-luxc/source')
-rw-r--r--new-luxc/source/luxc/lang/host.jvm.lux2
-rw-r--r--new-luxc/source/luxc/lang/init.lux45
-rw-r--r--new-luxc/source/luxc/lang/translation.lux36
-rw-r--r--new-luxc/source/luxc/repl.lux3
4 files changed, 51 insertions, 35 deletions
diff --git a/new-luxc/source/luxc/lang/host.jvm.lux b/new-luxc/source/luxc/lang/host.jvm.lux
index 7ec0df535..4b2dced82 100644
--- a/new-luxc/source/luxc/lang/host.jvm.lux
+++ b/new-luxc/source/luxc/lang/host.jvm.lux
@@ -9,7 +9,7 @@
text/format
(coll [dict]
[array]))
- [macro #+ Monad<Meta>]
+ [macro]
[host #+ do-to object]
[io])
(luxc ["&" lang]
diff --git a/new-luxc/source/luxc/lang/init.lux b/new-luxc/source/luxc/lang/init.lux
new file mode 100644
index 000000000..80968d7cd
--- /dev/null
+++ b/new-luxc/source/luxc/lang/init.lux
@@ -0,0 +1,45 @@
+(.module:
+ lux
+ [//]
+ (// [".L" extension]
+ (translation (jvm [".T" common]))))
+
+(def: #export (cursor file)
+ (-> Text Cursor)
+ [file +1 +0])
+
+(def: #export (source file code)
+ (-> Text Text Source)
+ [(cursor file) +0 code])
+
+(def: dummy-source
+ Source
+ [.dummy-cursor +0 ""])
+
+(def: #export type-context
+ Type-Context
+ {#.ex-counter +0
+ #.var-counter +0
+ #.var-bindings (list)})
+
+(def: #export info
+ Info
+ {#.target (for {"JVM" "JVM"
+ "JS" "JS"})
+ #.version //.version
+ #.mode #.Build})
+
+(def: #export (compiler host)
+ (-> commonT.Host Compiler)
+ {#.info ..info
+ #.source dummy-source
+ #.cursor .dummy-cursor
+ #.current-module #.None
+ #.modules (list)
+ #.scopes (list)
+ #.type-context ..type-context
+ #.expected #.None
+ #.seed +0
+ #.scope-type-vars (list)
+ #.extensions (:! Void extensionL.fresh)
+ #.host (:! Void host)})
diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux
index cbd63b998..da465a804 100644
--- a/new-luxc/source/luxc/lang/translation.lux
+++ b/new-luxc/source/luxc/lang/translation.lux
@@ -26,6 +26,7 @@
[".L" host]
[".L" macro]
[".L" extension]
+ [".L" init]
(extension [".E" analysis]
[".E" synthesis]
[".E" translation]
@@ -142,8 +143,7 @@
(def: (with-active-compilation [module-name file-name source-code] action)
(All [a] (-> [Text Text Text] (Meta a) (Meta a)))
(do macro.Monad<Meta>
- [#let [init-cursor [file-name +1 +0]]
- output (&.with-source-code [init-cursor +0 source-code]
+ [output (&.with-source-code (initL.source file-name source-code)
action)
_ (moduleL.flag-compiled! module-name)]
(wrap output)))
@@ -211,41 +211,11 @@
(#e.Error error)
(io.fail error))))
-(def: init-cursor Cursor ["" +1 +0])
-
-(def: #export init-type-context
- Type-Context
- {#.ex-counter +0
- #.var-counter +0
- #.var-bindings (list)})
-
-(def: #export init-info
- Info
- {#.target (for {"JVM" "JVM"
- "JS" "JS"})
- #.version &.version
- #.mode #.Build})
-
-(def: #export (init-compiler host)
- (-> commonT.Host Compiler)
- {#.info init-info
- #.source [init-cursor +0 ""]
- #.cursor .dummy-cursor
- #.current-module #.None
- #.modules (list)
- #.scopes (list)
- #.type-context init-type-context
- #.expected #.None
- #.seed +0
- #.scope-type-vars (list)
- #.extensions (:! Void extensionL.fresh)
- #.host (:! Void host)})
-
(def: (initialize sources target)
(-> (List File) File (Process Compiler))
(do io.Monad<Process>
[compiler (: (Process Compiler)
- (case (runtimeT.translate (init-compiler (io.run hostL.init-host)))
+ (case (runtimeT.translate (initL.compiler (io.run hostL.init-host)))
(#e.Error error)
(io.fail error)
diff --git a/new-luxc/source/luxc/repl.lux b/new-luxc/source/luxc/repl.lux
index 16f4de5db..99d635975 100644
--- a/new-luxc/source/luxc/repl.lux
+++ b/new-luxc/source/luxc/repl.lux
@@ -34,6 +34,7 @@
[".L" host]
[".L" translation]
[".L" eval]
+ [".L" init]
(translation (jvm [".T" runtime]))
[".L" extension]
(extension [".E" analysis]
@@ -54,7 +55,7 @@
[output (promise.future
(do io.Monad<IO>
[host hostL.init-host]
- (case (macro.run' (translationL.init-compiler host)
+ (case (macro.run' (initL.compiler host)
(moduleL.with-module +0 repl-module
runtimeT.translate))
(#e.Success [compiler _])