From d48da794a693c00990c411b669d6412b8bf4d904 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Mon, 8 Jan 2018 22:09:12 -0400
Subject: - Re-factored initialization functions to their own module.
---
new-luxc/source/luxc/lang/host.jvm.lux | 2 +-
new-luxc/source/luxc/lang/init.lux | 45 +++++++++++++++++++++++++++++++
new-luxc/source/luxc/lang/translation.lux | 36 +++----------------------
new-luxc/source/luxc/repl.lux | 3 ++-
4 files changed, 51 insertions(+), 35 deletions(-)
create mode 100644 new-luxc/source/luxc/lang/init.lux
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]
+ [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
- [#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
[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
[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 _])
--
cgit v1.2.3