aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2019-03-14 00:10:26 -0400
committerEduardo Julian2019-03-14 00:10:26 -0400
commit55ea02ec50e350ededa3721063f03d365aa0a4df (patch)
treeca1ff504a69e431a46db563b20aeeb7b72107b9e
parentd725a365c5876c3ec377e4a113932359eab4d691 (diff)
Properly doing imports.
-rw-r--r--stdlib/source/lux/tool/compiler/default/init.lux21
-rw-r--r--stdlib/source/lux/tool/compiler/default/platform.lux33
2 files changed, 16 insertions, 38 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/init.lux b/stdlib/source/lux/tool/compiler/default/init.lux
index aebb74046..8ff684755 100644
--- a/stdlib/source/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/lux/tool/compiler/default/init.lux
@@ -1,7 +1,7 @@
(.module:
[lux (#- Module loop)
[control
- [monad (#+ do)]
+ ["." monad (#+ do)]
["ex" exception (#+ exception:)]]
[data
["." product]
@@ -115,13 +115,14 @@
(with-expansions [<Operation> (as-is (All [anchor expression statement]
(statement.Operation anchor expression statement Any)))]
- (def: (begin hash input)
- (-> Nat ///.Input <Operation>)
+ (def: (begin dependencies hash input)
+ (-> (List Module) Nat ///.Input <Operation>)
(statement.lift-analysis
(do phase.monad
[#let [module (get@ #///.module input)]
_ (module.create hash module)
- _ (analysis.set-current-module module)]
+ _ (analysis.set-current-module module)
+ _ (monad.map @ module.import dependencies)]
(analysis.set-source-code (analysis.source (get@ #///.module input) (get@ #///.code input))))))
(def: end
@@ -154,11 +155,11 @@
(#error.Success [state []])
(ex.with-stack ///.cannot-compile module (#error.Failure error))))))))
- (def: (compile expander hash input)
- (-> Expander Nat ///.Input <Operation>)
+ (def: (compile expander dependencies hash input)
+ (-> Expander (List Module) Nat ///.Input <Operation>)
(do phase.monad
[#let [module (get@ #///.module input)]
- _ (..begin hash input)
+ _ (..begin dependencies hash input)
_ (..loop expander module)]
(..end module)))
@@ -169,8 +170,8 @@
(list prelude)))
)
-(def: #export (compiler expander prelude)
- (-> Expander Module
+(def: #export (compiler expander prelude module)
+ (-> Expander Module Module
(All [anchor expression statement]
(Instancer (statement.State+ anchor expression statement) .Module)))
(function (_ key parameters input)
@@ -183,7 +184,7 @@
(: (All [anchor expression statement]
(statement.Operation anchor expression statement .Module))
(do phase.monad
- [_ (compile expander hash input)]
+ [_ (compile expander dependencies hash input)]
(statement.lift-analysis
(extension.lift
macro.current-module)))))
diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux
index 7748db721..89a02e502 100644
--- a/stdlib/source/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/lux/tool/compiler/default/platform.lux
@@ -96,18 +96,15 @@
(All [! anchor expression statement]
(-> Expander <Platform> Configuration Archive <State+> (! (Error [Archive <State+>]))))
(let [monad (get@ #&monad platform)
+ source-module (get@ #cli.module configuration)
compiler (:share [anchor expression statement]
{<State+>
state}
{(///.Compiler <State+> .Module Any)
- ((init.compiler expander syntax.prelude) init.key (list))})]
- (loop [module (get@ #cli.module configuration)
+ ((init.compiler expander syntax.prelude source-module) init.key (list))})]
+ (loop [module source-module
[archive state] [archive state]]
- (let [## [state _] (|> (analysis.set-current-module module)
- ## statement.lift-analysis
- ## (phase.run' state)
- ## error.assume)
- import! (:share [! anchor expression statement]
+ (let [import! (:share [! anchor expression statement]
{<Platform>
platform}
{(-> Module [Archive <State+>]
@@ -125,27 +122,7 @@
compilation (compiler (:coerce ///.Input input))]
(do @
[archive+state' (monad.fold @
- (function (_ dependency archive+state')
- (do @
- [archive+state'' (import! dependency archive+state')
- #let [[archive'' state''] (:share [! anchor expression statement]
- {<Platform>
- platform}
- {[Archive <State+>]
- archive+state''})]]
- (case (:share [! anchor expression statement]
- {<State+>
- state}
- {(Error [<State+> Any])
- ## TODO: Get rid of the 'let' below ASAP
- (let [lifted (statement.lift-analysis
- (module.import dependency))]
- (phase.run' state'' lifted))})
- (#error.Success [state''' _])
- (wrap [archive'' state'''])
-
- (#error.Failure error)
- (:: monad wrap (#error.Failure error)))))
+ import!
[archive state]
(list.filter (bit.complement (archive.archived? archive))
(get@ #///.dependencies compilation)))