From 55ea02ec50e350ededa3721063f03d365aa0a4df Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 14 Mar 2019 00:10:26 -0400 Subject: Properly doing imports. --- stdlib/source/lux/tool/compiler/default/init.lux | 21 +++++++------- .../source/lux/tool/compiler/default/platform.lux | 33 ++++------------------ 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 [ (as-is (All [anchor expression statement] (statement.Operation anchor expression statement Any)))] - (def: (begin hash input) - (-> Nat ///.Input ) + (def: (begin dependencies hash input) + (-> (List Module) Nat ///.Input ) (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 ) + (def: (compile expander dependencies hash input) + (-> Expander (List Module) Nat ///.Input ) (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 Configuration Archive (! (Error [Archive ])))) (let [monad (get@ #&monad platform) + source-module (get@ #cli.module configuration) compiler (:share [anchor expression statement] { state} {(///.Compiler .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} {(-> Module [Archive ] @@ -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} - {[Archive ] - archive+state''})]] - (case (:share [! anchor expression statement] - { - state} - {(Error [ 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))) -- cgit v1.2.3