diff options
author | Eduardo Julian | 2020-05-12 22:18:48 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-05-12 22:18:48 -0400 |
commit | 2ebb1cfc9d8705f9b5812d6d26788c8d3b70b5c8 (patch) | |
tree | 73399c6a47c825b8324767737fd0d3d6f3a11d3e /stdlib/source/lux/tool | |
parent | f605537d91450b347ce70eb2c5edff9674e72044 (diff) |
Now logging to a data-structure and only printing in the end.
Diffstat (limited to 'stdlib/source/lux/tool')
4 files changed, 55 insertions, 12 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux index 26a301f86..76939bb08 100644 --- a/stdlib/source/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/lux/tool/compiler/default/platform.lux @@ -16,7 +16,7 @@ ["%" format (#+ format)]] [collection [dictionary (#+ Dictionary)] - ["." row] + ["." row ("#@." fold)] ["." set] ["." list ("#@." monoid)]] [format @@ -210,6 +210,28 @@ _ (..cache-module platform host target 0 extension payload)] (wrap [state archive]))))) + (def: module-compilation-log + (All [<type-vars>] + (-> <State+> Text)) + (|>> (get@ [#extension.state + #///directive.generation + #///directive.state + #extension.state + #///generation.log]) + (row@fold (function (_ right left) + (format left text.new-line right)) + ""))) + + (def: with-reset-log + (All [<type-vars>] + (-> <State+> <State+>)) + (set@ [#extension.state + #///directive.generation + #///directive.state + #extension.state + #///generation.log] + row.empty)) + (def: #export (compile target partial-host-extension expander platform host configuration archive extension state) (All [<type-vars>] (-> Text Text Expander <Platform> Host Configuration Archive Text <State+> (Promise (Try [Archive <State+>])))) @@ -274,11 +296,13 @@ (#.Right [[descriptor document] output]) (do (try.with promise.monad) - [#let [descriptor (set@ #descriptor.references (set.from-list text.hash all-dependencies) descriptor)] + [#let [_ (log! (..module-compilation-log state)) + descriptor (set@ #descriptor.references (set.from-list text.hash all-dependencies) descriptor)] _ (..cache-module platform host target module-id extension [[descriptor document] output])] (case (archive.add module [descriptor document] archive) (#try.Success archive) - (wrap [archive state]) + (wrap [archive + (..with-reset-log state)]) (#try.Failure error) (promise@wrap (#try.Failure error))))) diff --git a/stdlib/source/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/lux/tool/compiler/language/lux/generation.lux index 336e4913a..41dcdd990 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/generation.lux @@ -1,5 +1,5 @@ (.module: - [lux (#- Module) + [lux (#- Module log!) [abstract [monad (#+ do)]] [control @@ -66,7 +66,8 @@ #buffer (Maybe (Buffer directive)) #registry artifact.Registry #counter Nat - #context (Maybe artifact.ID)}) + #context (Maybe artifact.ID) + #log (Row Text)}) (template [<special> <general>] [(type: #export (<special> anchor expression directive) @@ -90,7 +91,8 @@ #buffer #.None #registry artifact.empty #counter 0 - #context #.None}) + #context #.None + #log row.empty}) (def: #export empty-buffer Buffer row.empty) @@ -303,3 +305,11 @@ (wrap [[bundle' (set@ #context (get@ #context state) state')] [[module-id id] output]]))))) + +(def: #export (log! message) + (All [anchor expression directive a] + (-> Text (Operation anchor expression directive Any))) + (function (_ [bundle state]) + (#try.Success [[bundle + (update@ #log (row.add message) state)] + []]))) diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 4db15e8e6..cb3277591 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -44,6 +44,7 @@ [compiler ["." analysis] ["." synthesis] + ["." generation] ["." directive (#+ Handler Bundle)] ["." phase [analysis @@ -291,7 +292,8 @@ ## (list@map ..field-definition fields) ## (list) ## TODO: Add methods ## (row.row))])) - #let [_ (log! (format "Class " name))]] + _ (directive.lift-generation + (generation.log! (format "Class " name)))] (wrap directive.no-requirements)))])) (def: #export bundle diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index f7099d2c4..24d059031 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -197,6 +197,12 @@ [(///analysis.bundle eval host-analysis)])) state)]))) +(def: (announce-definition! name) + (All [anchor expression directive] + (-> Name (Operation anchor expression directive Any))) + (/////directive.lift-generation + (/////generation.log! (format "Definition " (%.name name))))) + (def: (lux::def expander host-analysis) (-> Expander /////analysis.Bundle Handler) (function (_ extension-name phase archive inputsC+) @@ -210,8 +216,8 @@ [_ annotationsT annotations] (evaluate! archive Code annotationsC) _ (/////directive.lift-analysis (module.define short-name (#.Right [exported? type (:coerce Code annotations) value]))) - #let [_ (log! (format "Definition " (%.name full-name)))] - _ (..refresh expander host-analysis)] + _ (..refresh expander host-analysis) + _ (..announce-definition! full-name)] (wrap /////directive.no-requirements)) _ @@ -233,8 +239,8 @@ (do phase.monad [_ (module.define short-name (#.Right [exported? type annotations value]))] (module.declare-tags tags exported? (:coerce Type value)))) - #let [_ (log! (format "Definition " (%.name full-name)))] - _ (..refresh expander host-analysis)] + _ (..refresh expander host-analysis) + _ (..announce-definition! full-name)] (wrap /////directive.no-requirements)))])) (def: imports @@ -317,7 +323,8 @@ handler} {<type> (:assume handlerV)})) - #let [_ (log! (format <description> " " (%.text (:coerce Text name))))]] + _ (/////directive.lift-generation + (/////generation.log! (format <description> " " (%.text (:coerce Text name)))))] (wrap /////directive.no-requirements)) _ |