From 62cfd42fad011880491c937e3cb33c19febd3af4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 12 Mar 2019 23:17:48 -0400 Subject: WIP: Some tweaks to handle imports at the compiler-state level. --- .../source/lux/tool/compiler/default/platform.lux | 35 ++++++++++++++++++++-- .../lux/tool/compiler/phase/analysis/reference.lux | 1 - stdlib/source/lux/tool/compiler/program.lux | 13 ++++---- 3 files changed, 40 insertions(+), 9 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux index 73ee068bb..ced79a306 100644 --- a/stdlib/source/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/lux/tool/compiler/default/platform.lux @@ -15,10 +15,15 @@ ["." init] ["." syntax] ["/." // + ["." analysis] ["." statement] ["." phase [macro (#+ Expander)] - ["." translation]] + ## TODO: Get rid of this import ASAP + [extension (#+)] + ["." translation] + [analysis + ["." module]]] ["." cli (#+ Configuration)] [meta ["." archive (#+ Archive) @@ -96,7 +101,11 @@ ((init.compiler expander syntax.prelude) init.key (list))})] (loop [module (get@ #cli.module configuration) [archive state] [archive state]] - (let [import! (:share [! anchor expression statement] + (let [## [state _] (|> (analysis.set-current-module module) + ## statement.lift-analysis + ## (phase.run' state) + ## error.assume) + import! (:share [! anchor expression statement] { platform} {(-> Module [Archive ] @@ -114,7 +123,27 @@ compilation (compiler (:coerce ///.Input input))] (do @ [archive+state' (monad.fold @ - import! + (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))))) [archive state] (list.filter (bit.complement (archive.archived? archive)) (get@ #///.dependencies compilation))) diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/reference.lux b/stdlib/source/lux/tool/compiler/phase/analysis/reference.lux index ee3767797..507441427 100644 --- a/stdlib/source/lux/tool/compiler/phase/analysis/reference.lux +++ b/stdlib/source/lux/tool/compiler/phase/analysis/reference.lux @@ -23,7 +23,6 @@ (exception: #export (definition-has-not-been-expored {definition Name}) (ex.report ["Definition" (%name definition)])) -## [Analysers] (def: (definition def-name) (-> Name (Operation Analysis)) (with-expansions [ (wrap (|> def-name reference.constant #/.Reference))] diff --git a/stdlib/source/lux/tool/compiler/program.lux b/stdlib/source/lux/tool/compiler/program.lux index 265277ac7..9de17b5df 100644 --- a/stdlib/source/lux/tool/compiler/program.lux +++ b/stdlib/source/lux/tool/compiler/program.lux @@ -21,7 +21,9 @@ ["." translation]] [default ["." platform (#+ Platform)] - ["." syntax]]] + ["." syntax]] + [meta + ["." archive (#+ Archive)]]] ## ["." interpreter] ]] [// @@ -77,10 +79,11 @@ platform} {(IO (Error (statement.State+ anchor expression statement))) (platform.initialize expander platform bundle)}) - _ (: (IO (Error Any)) - (platform.compile expander platform (set@ #cli.module syntax.prelude configuration) state)) - ## _ (: (IO (Error Any)) - ## (platform.compile expander platform configuration state)) + _ (:share [anchor expression statement] + {(Platform IO anchor expression statement) + platform} + {(IO (Error [Archive (statement.State+ anchor expression statement)])) + (platform.compile expander platform configuration archive.empty state)}) ## _ (cache/io.clean target ...) ] (wrap (log! "Compilation complete!"))))) -- cgit v1.2.3