diff options
Diffstat (limited to '')
9 files changed, 172 insertions, 235 deletions
diff --git a/stdlib/source/library/lux/meta/compiler.lux b/stdlib/source/library/lux/meta/compiler.lux index 5f2d00605..0bac9c1be 100644 --- a/stdlib/source/library/lux/meta/compiler.lux +++ b/stdlib/source/library/lux/meta/compiler.lux @@ -33,26 +33,26 @@ #hash Nat #code Code])) -(type .public (Compilation s d o) +(type .public (Compilation s d) (Record [#dependencies (List Module) #process (-> s Archive - (Try [s (Either (Compilation s d o) + (Try [s (Either (Compilation s d) (archive.Entry d))]))])) -(type .public (Compiler s d o) - (-> Input (Compilation s d o))) +(type .public (Compiler s d) + (-> Input (Compilation s d))) (type .public Custom - (Ex (_ state document object) + (Ex (_ state document) [state (Key document) (Format document) (Parser document) - (-> Input (Try (Compilation state document object)))])) + (-> Input (Try (Compilation state document)))])) -(type .public (Instancer s d o) - (-> (Key d) (List Parameter) (Compiler s d o))) +(type .public (Instancer s d) + (-> (Key d) (List Parameter) (Compiler s d))) (exception.def .public (cannot_compile module) (Exception Module) diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index bebc4619d..6de9ff2d9 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -34,7 +34,6 @@ ["[1][0]" generation] ["[1][0]" analysis (.only) [macro (.only Expander)] - ["[1]/[0]" evaluation] ["[0]A" module]] [phase ["[0]P" analysis] @@ -42,57 +41,37 @@ ["[0]P" declaration] ["[0]" extension (.only) ["[0]E" analysis] - ["[0]E" synthesis] [declaration ["[0]D" lux]]]]]] [meta ["[0]" archive (.only Archive) + [key (.only Key)] ["[0]" unit] ["[0]" registry (.only Registry)] ["[0]" module (.only) ["[0]" descriptor] ["[0]" document]]]]]]) -(def .public (state target module configuration extender expander host_analysis host generate generation_bundle) +(def .public (state target module configuration extender expander host generate) (All (_ anchor expression declaration) (-> Target descriptor.Module Configuration extension.Extender Expander - ///analysis.Bundle (///generation.Host expression declaration) (-> extension.Extender Lux (///generation.Phase anchor expression declaration)) - (///generation.Bundle anchor expression declaration) (///declaration.State+ anchor expression declaration))) - (let [synthesis_state [extension.#bundle synthesisE.bundle - extension.#state ///synthesis.init] - generation_state [extension.#bundle generation_bundle - extension.#state (///generation.state host module)] - lux (///analysis.state (///analysis.info version.latest target configuration)) - analysis_phase (analysisP.phase extender expander) - eval (///analysis/evaluation.evaluator analysis_phase - [synthesis_state (synthesisP.phase extender)] - [generation_state (generate extender)]) - analysis_state [(analysisE.bundle eval host_analysis) - lux]] + (let [lux (///analysis.state (///analysis.info version.latest target configuration))] [extension.empty - [///declaration.#analysis [///declaration.#state analysis_state - ///declaration.#phase analysis_phase] - ///declaration.#synthesis [///declaration.#state synthesis_state + [///declaration.#analysis [///declaration.#state [extension.empty lux] + ///declaration.#phase (analysisP.phase extender expander)] + ///declaration.#synthesis [///declaration.#state [extension.#bundle extension.empty + extension.#state ///synthesis.init] ///declaration.#phase (synthesisP.phase extender)] - ///declaration.#generation [///declaration.#state generation_state + ///declaration.#generation [///declaration.#state [extension.#bundle extension.empty + extension.#state (///generation.state host module)] ///declaration.#phase (generate extender)]]])) -(def .public (with_default_declarations host_analysis) - (All (_ anchor expression declaration) - (-> ///analysis.Bundle - (-> (///declaration.State+ anchor expression declaration) - (///declaration.State+ anchor expression declaration)))) - (function (_ [declaration_extensions sub_state]) - [(dictionary.composite declaration_extensions - (luxD.bundle host_analysis)) - sub_state])) - (type Reader (-> Source (Either [Source Text] [Source Code]))) @@ -124,12 +103,11 @@ [(///generation.Buffer declaration) Registry]) -(def with_analysis_defaults - (Operation Any) +(def (with_analysis_defaults bundle) + (-> ///analysis.Bundle + (Operation Any)) (do [! ///phase.monad] - [state ///phase.state - _ (|> state - (the [extension.#state ///declaration.#analysis ///declaration.#state extension.#bundle]) + [_ (|> bundle dictionary.entries (monad.each ! (function (_ [name handler]) @@ -137,12 +115,12 @@ (moduleA.define name {.#Default [true .Analysis handler]})))))] (in []))) -(def with_generation_defaults - (Operation Any) +(def (with_generation_defaults bundle) + (All (_ anchor expression declaration) + (-> (///generation.Bundle anchor expression declaration) + (///declaration.Operation anchor expression declaration Any))) (do [! ///phase.monad] - [state ///phase.state - _ (|> state - (the [extension.#state ///declaration.#generation ///declaration.#state extension.#bundle]) + [_ (|> bundle dictionary.entries (monad.each ! (function (_ [name handler]) @@ -150,12 +128,12 @@ (moduleA.define name {.#Default [true .Generation handler]})))))] (in []))) -(def with_declaration_defaults - (Operation Any) +(def (with_declaration_defaults bundle) + (All (_ anchor expression declaration) + (-> (///declaration.Bundle anchor expression declaration) + (///declaration.Operation anchor expression declaration Any))) (do [! ///phase.monad] - [state ///phase.state - _ (|> state - (the extension.#bundle) + [_ (|> bundle dictionary.entries (monad.each ! (function (_ [name handler]) @@ -163,23 +141,31 @@ (moduleA.define name {.#Default [true .Declaration handler]})))))] (in []))) -(def (with_defaults module) - (-> Text - (Operation Any)) +(type .public (Extensions anchor expression declaration) + [///analysis.Bundle + (///generation.Bundle anchor expression declaration) + (///declaration.Bundle anchor expression declaration)]) + +(def (with_defaults module [analysis_bundle generation_bundle host_declaration_bundle]) + (All (_ anchor expression declaration) + (-> Text (Extensions anchor expression declaration) + (///declaration.Operation anchor expression declaration Any))) (when module .prelude (do ///phase.monad - [_ with_analysis_defaults - _ with_generation_defaults] - with_declaration_defaults) + [_ (with_analysis_defaults analysis_bundle) + _ (with_generation_defaults generation_bundle)] + (with_declaration_defaults (dictionary.composite host_declaration_bundle + luxD.bundle))) _ (with ///phase.monad (in [])))) -(def (begin dependencies hash input) - (-> (List descriptor.Module) Nat ///.Input - (All (_ anchor expression declaration) +(def (begin dependencies hash input all_extensions) + (All (_ anchor expression declaration) + (-> (List descriptor.Module) Nat ///.Input + (Extensions anchor expression declaration) (///declaration.Operation anchor expression declaration [Source (Payload declaration)]))) (do ///phase.monad @@ -187,7 +173,7 @@ _ (///declaration.set_current_module module) _ (///declaration.lifted_analysis (moduleA.create hash module)) - _ (with_defaults module)] + _ (with_defaults module all_extensions)] (///declaration.lifted_analysis (do [! ///phase.monad] [_ (monad.each ! moduleA.import dependencies) @@ -299,11 +285,13 @@ @module (///phase.lifted (archive.id program_module archive))] (///generation.save! @self {.#None} (program [@module @self] |program|)))) - (def .public (compiler program global wrapper extender expander prelude write_declaration program_module program_definition) + (def .public (compiler program global wrapper extender expander prelude write_declaration program_module program_definition + extensions) (All (_ <parameters>) (-> (Program expression declaration) (-> Archive Symbol (///generation.Operation <parameters> expression)) ///phase.Wrapper (Extender <parameters>) Expander descriptor.Module (-> declaration Binary) descriptor.Module (Maybe Text) + (Extensions <parameters>) (Instancer (///declaration.State+ <parameters>) .Module))) (let [execute! (declarationP.phase wrapper extender expander)] (function (_ key parameters input) @@ -313,7 +301,7 @@ (do [! try.monad] [.let [hash (text#hash (the ///.#code input))] [state [source buffer]] (<| (///phase.result' state) - (..begin dependencies hash input)) + (..begin dependencies hash input extensions)) .let [module (the ///.#module input)]] (loop (again [iteration (<| (///phase.result' state) (..iteration wrapper archive extender expander module source buffer ///syntax.no_aliases))]) @@ -335,7 +323,6 @@ (in [])) (in []))] (..end module))) - .let [descriptor [descriptor.#hash hash descriptor.#name module descriptor.#file (the ///.#file input) diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index aa0f1d2eb..9488ab8a3 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -93,8 +93,7 @@ (try.with async.monad))) (with_expansions [<Platform> (these (Platform <type_vars>)) - <State+> (these (///declaration.State+ <type_vars>)) - <Bundle> (these (///generation.Bundle <type_vars>))] + <State+> (these (///declaration.State+ <type_vars>))] (def (format //) (All (_ a) @@ -189,21 +188,9 @@ (archive.has descriptor.runtime entry archive))))] (in [archive entry]))) - (def (initialize_state extender - [analysers - synthesizers - generators - declarations] - analysis_state - state) + (def (initialize_state analysis_state state) (All (_ <type_vars>) - (-> extension.Extender - [(Dictionary Text ///analysis.Handler) - (Dictionary Text ///synthesis.Handler) - (Dictionary Text (///generation.Handler <type_vars>)) - (Dictionary Text (///declaration.Handler <type_vars>))] - .Lux - <State+> + (-> .Lux <State+> (Try <State+>))) (|> (sharing [<type_vars>] (is <State+> @@ -211,44 +198,18 @@ (is (///declaration.Operation <type_vars> Any) (do [! ///phase.monad] [_ (///declaration.lifted_analysis - (do ! - [_ (///analysis.set_state analysis_state)] - (extension.with extender analysers))) - _ (///declaration.lifted_synthesis - (extension.with extender synthesizers)) - _ (///declaration.lifted_generation - (extension.with extender (as_expected generators))) - _ (extension.with extender (as_expected declarations))] + (///analysis.set_state analysis_state))] (in [])))) (///phase.result' state) (at try.monad each product.left))) - (def (complete_extensions host_declaration_bundle [analysers synthesizers generators declarations]) - (All (_ <type_vars>) - (-> (///declaration.Bundle <type_vars>) - [(Dictionary Text ///analysis.Handler) - (Dictionary Text ///synthesis.Handler) - (Dictionary Text (///generation.Handler <type_vars>)) - (Dictionary Text (///declaration.Handler <type_vars>))] - [(Dictionary Text ///analysis.Handler) - (Dictionary Text ///synthesis.Handler) - (Dictionary Text (///generation.Handler <type_vars>)) - (Dictionary Text (///declaration.Handler <type_vars>))])) - [analysers - synthesizers - generators - (dictionary.composite declarations host_declaration_bundle)]) - - (def .public (initialize context module expander host_analysis platform generation_bundle host_declaration_bundle program extender + (def .public (initialize context module expander platform program extender import compilation_sources compilation_configuration) (All (_ <type_vars>) (-> context.Context descriptor.Module Expander - ///analysis.Bundle <Platform> - <Bundle> - (///declaration.Bundle <type_vars>) (Program expression declaration) extension.Extender Import (List _io.Context) Configuration @@ -260,27 +221,21 @@ compilation_configuration extender expander - host_analysis (the #host platform) - (the #phase platform) - generation_bundle)] + (the #phase platform))] _ (is (Async (Try Any)) (cache.enable! async.monad (the #file_system platform) context)) [archive analysis_state bundles] (ioW.thaw (list) compilation_configuration (the #host platform) (the #file_system platform) context import compilation_sources) .let [with_missing_extensions (is (All (_ <type_vars>) - (-> <Platform> (Program expression declaration) <State+> - (Async (Try <State+>)))) - (function (_ platform program state) + (-> <State+> (Async (Try <State+>)))) + (function (_ state) (|> state - (initialize_state extender - (as_expected (..complete_extensions host_declaration_bundle (as_expected bundles))) - analysis_state) - (try#each (//init.with_default_declarations host_analysis)) + (initialize_state analysis_state) async#in)))]] (if (archive.archived? archive descriptor.runtime) (do ! - [state (with_missing_extensions platform program state)] + [state (with_missing_extensions state)] (in [state archive phase_wrapper])) (do ! [[state [archive payload]] (|> (..process_runtime archive platform) @@ -288,7 +243,7 @@ async#in) _ (..cache_module context platform 0 $.key $.format payload) - state (with_missing_extensions platform program state)] + state (with_missing_extensions state)] (in [state archive phase_wrapper]))))) (def compilation_log_separator @@ -639,7 +594,7 @@ (def (after_imports customs import! module duplicates new_dependencies archive) (All (_ <type_vars> - state document object) + state) (-> (List ///.Custom) (..Importer state) descriptor.Module (Set descriptor.Module) (List descriptor.Module) Archive (Async (Try [Archive (List state) (List Text)])))) (if (set.empty? duplicates) @@ -682,8 +637,8 @@ (def (next_compilation module [archive state] compilation) (All (_ <type_vars>) - (-> descriptor.Module Lux_Context (///.Compilation <State+> .Module Any) - (Try [<State+> (Either (///.Compilation <State+> .Module Any) + (-> descriptor.Module Lux_Context (///.Compilation <State+> .Module) + (Try [<State+> (Either (///.Compilation <State+> .Module) (archive.Entry Any))]))) ((the ///.#process compilation) ... TODO: The "///declaration.set_current_module" below shouldn't be necessary. Remove it ASAP. @@ -694,20 +649,23 @@ product.left) archive)) - (def (compiler program global phase_wrapper extender expander platform program_module program_definition) + (def (compiler program global phase_wrapper extender expander platform program_module program_definition + all_extensions) (All (_ <type_vars>) (-> (Program expression declaration) (-> Archive Symbol (///generation.Operation <type_vars> expression)) ///phase.Wrapper (Extender <type_vars>) Expander <Platform> Text (Maybe Module) - (///.Compiler <State+> .Module Any))) - (let [instancer (//init.compiler program global phase_wrapper extender expander syntax.prelude (the #write platform) program_module program_definition)] + (//init.Extensions <type_vars>) + (///.Compiler <State+> .Module))) + (let [instancer (//init.compiler program global phase_wrapper extender expander syntax.prelude (the #write platform) program_module program_definition + all_extensions)] (instancer $.key (list)))) (def (custom_compiler import context platform compilation_sources configuration compiler custom_key custom_format custom_compilation) (All (_ <type_vars> - state document object) - (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module Any) - (Key document) (Format document) (///.Compilation state document object) + state document) + (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module) + (Key document) (Format document) (///.Compilation state document) (-> (List ///.Custom) descriptor.Module Lux_Importer module.ID (..Context state) descriptor.Module (..Return state)))) (function (_ customs importer import! @module [archive state] module) (loop (again [[archive state] [archive state] @@ -773,8 +731,8 @@ (def (lux_compiler import context platform compilation_sources configuration compiler compilation) (All (_ <type_vars>) - (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module Any) - (///.Compilation <State+> .Module Any) + (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module) + (///.Compilation <State+> .Module) Lux_Compiler)) (function (_ customs importer import! @module [archive state] module) (loop (again [[archive state] [archive (..set_current_module module state)] @@ -814,16 +772,12 @@ (def Fake_Document Type - {.#Primitive (%.nat (static.random_nat)) (list)}) - - (def Fake_Object - Type {.#Primitive (%.nat (static.random_nat)) (list)})) (these)) (def (serial_compiler import context platform compilation_sources configuration compiler) (All (_ <type_vars>) - (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module Any) + (-> Import context.Context <Platform> (List _io.Context) Configuration (///.Compiler <State+> .Module) Lux_Compiler)) (function (_ all_customs importer import! @module [archive lux_state] module) (do [! ..monad] @@ -833,7 +787,7 @@ compilation_sources (the context.#host_module_extension context) module)] - (loop (again [customs (for @.old (as (List (///.Custom Fake_State Fake_Document Fake_Object)) + (loop (again [customs (for @.old (as (List (///.Custom Fake_State Fake_Document)) all_customs) all_customs)]) (when customs @@ -885,23 +839,26 @@ {try.#Success [context (the compiler.#parameters it) /#value]} (exception.except ..invalid_custom_compiler [/#definition /#type])))))) - (def .public (compile program global lux_compiler phase_wrapper import file_context extender expander platform compilation context) + (def .public (compile program global lux_compiler phase_wrapper import file_context extender expander platform compilation context + all_extensions) (All (_ <type_vars>) (-> (Program expression declaration) (-> Archive Symbol (///generation.Operation <type_vars> expression)) (-> Any ..Custom) ///phase.Wrapper Import context.Context (Extender <type_vars>) Expander <Platform> Compilation Lux_Context + (//init.Extensions <type_vars>) Lux_Return)) - (let [[host_dependencies libraries compilers sources target program_module program_definition configuration] compilation - import! (|> (..compiler program global phase_wrapper extender expander platform program_module program_definition) - (serial_compiler import file_context platform sources configuration) - (..parallel context))] - (do [! ..monad] - [customs (|> compilers - (list#each (function (_ it) - (do ! - [[context parameters custom] (..custom import! it)] - (async#in (|> custom - lux_compiler - (function.on parameters)))))) - (monad.all !))] - (import! customs descriptor.runtime program_module)))) + (do [! ..monad] + [.let [[host_dependencies libraries compilers sources target program_module program_definition configuration] compilation + import! (|> (..compiler program global phase_wrapper extender expander platform program_module program_definition + all_extensions) + (serial_compiler import file_context platform sources configuration) + (..parallel context))] + customs (|> compilers + (list#each (function (_ it) + (do ! + [[context parameters custom] (..custom import! it)] + (async#in (|> custom + lux_compiler + (function.on parameters)))))) + (monad.all !))] + (import! customs descriptor.runtime program_module))) ))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux index f4056c535..8637d6b38 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux @@ -4,6 +4,7 @@ [abstract [monad (.only do)]] [control + ["[0]" maybe] ["[0]" try] ["[0]" exception (.only Exception)]] [data @@ -15,7 +16,6 @@ [number ["n" nat]]] ["[0]" meta (.only) - ["[0]" symbol (.use "[1]#[0]" equivalence)] ["[0]" location] ["[0]" code] [macro @@ -78,39 +78,38 @@ {.#None} (//.except ..invalid [code]))])) -(exception.def .public (not_an_extension [name expected actual]) - (Exception [Symbol Type Type]) - (exception.report - (list ["Name" (%.symbol name)] - ["Expected" (%.type expected)] - ["Actual" (%.type actual)]))) - (type Value (Variant {#Normal Any} {#Special Any})) (def (global_value name) - (-> Symbol (Meta [Type Value])) + (-> Symbol (Meta (Maybe [Type Value]))) (do meta.monad - [global (meta.local name)] + [global (meta.try (meta.local name))] (when global - {.#Definition [exported? type value]} - (in [type {#Normal value}]) - - {.#Default [exported? type value]} - (in [type {#Special value}]) + {try.#Success global} + (in (when global + {.#Definition [exported? type value]} + {.#Some [type {#Normal value}]} + + {.#Default [exported? type value]} + {.#Some [type {#Special value}]} + + {.#Alias _} + {.#None})) - {.#Alias _} - (undefined)))) + {try.#Failure error} + (in {.#None})))) (def (global_analysis name) - (-> Symbol (Meta Value)) + (-> Symbol (Meta (Maybe Value))) (do meta.monad - [[type value] (global_value name)] - (if (check.subsumes? .Analysis type) - (in value) - (meta.failure (exception.error ..not_an_extension [name .Analysis type]))))) + [type,value (global_value name)] + (in (do maybe.monad + [[type value] type,value + maybe.when (check.subsumes? .Analysis type)] + (in value))))) (def (extension_application extender phase archive @@ -118,16 +117,23 @@ (-> Extender Phase Archive Symbol (List Code) - (Operation Analysis)) - (do //.monad + (Operation (Maybe Analysis))) + (do [! //.monad] [value (//extension.lifted (global_analysis name)) .let [[module short] name]] (when value - {#Normal definition} - ((extender definition) short phase archive parameters) + {.#Some value} + (do ! + [it (when value + {#Normal definition} + ((extender definition) short phase archive parameters) + + {#Special default} + ((as Handler default) short phase archive parameters))] + (in {.#Some it})) - {#Special default} - ((as Handler default) short phase archive parameters)))) + {.#None} + (in {.#None})))) ... TODO: Replace with an inline function. (exception.def .public (not_a_macro name) @@ -151,10 +157,12 @@ ... TODO: Replace with an inline function. (def (global_application extender expander analysis archive function_type function_analysis def_name functionC argsC+) (-> Extender Expander Phase Archive Type Analysis Symbol Code (List Code) (Operation Analysis)) - (<| (if (check.subsumes? .Analysis function_type) - (extension_application extender analysis archive def_name argsC+)) - (if (check.subsumes? .Macro function_type) + (<| (if (check.subsumes? .Macro function_type) (macro_application extender expander analysis archive def_name argsC+)) + (if (check.subsumes? .Analysis function_type) + (do //.monad + [it (extension_application extender analysis archive def_name argsC+)] + (in (maybe.trusted it)))) (/function.apply analysis argsC+ function_type function_analysis archive functionC))) ... TODO: Replace with an inline function. @@ -177,12 +185,12 @@ [(when functionC [_ {.#Symbol global}] (do //.monad - [it (//.try (extension_application extender analysis archive global argsC+))] + [it (extension_application extender analysis archive global argsC+)] (when it - {try.#Success it} + {.#Some it} (in it) - {try.#Failure error} + {.#None} (term_application extender expander analysis archive functionC argsC+))) _ diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux index 668ee5376..730131ef1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux @@ -84,9 +84,9 @@ (def .public (reference quoted_module it) (-> Text Symbol (Operation Analysis)) (when it - ["" simple_name] + ["" short] (do [! ///.monad] - [?var (variable simple_name)] + [?var (variable short)] (when ?var {.#Some varA} (in varA) @@ -94,7 +94,7 @@ {.#None} (do ! [this_module (///extension.lifted meta.current_module_name)] - (definition quoted_module [this_module simple_name])))) + (definition quoted_module [this_module short])))) _ (definition quoted_module it))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux index a7ef77615..13141b51a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux @@ -5,12 +5,11 @@ [collection ["[0]" dictionary]]]]] [//// - [analysis (.only Bundle) - [evaluation (.only Eval)]]] + [analysis (.only Bundle)]] ["[0]" / ["[1][0]" lux]]) -(def .public (bundle eval host_specific) - (-> Eval Bundle Bundle) - (|> (/lux.bundle eval) +(def .public (bundle host_specific) + (-> Bundle Bundle) + (|> /lux.bundle (dictionary.composite host_specific))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux index 238711a4f..f7e4393d9 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux @@ -166,7 +166,7 @@ _ (analysis.except ///.invalid_syntax [extension_name %.code argsC+])))) -(def (lux::is eval) +(def .public (is#_extension eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (when args @@ -181,7 +181,7 @@ _ (analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def (lux::as eval) +(def .public (as#_extension eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (when args @@ -207,11 +207,9 @@ (<| (typeA.expecting input) (phase archive valueC))))])) -(def (with_basic_extensions eval) - (-> Eval (-> Bundle Bundle)) - (|>> (///bundle.install "is#" (lux::is eval)) - (///bundle.install "as#" (lux::as eval)) - (///bundle.install "is_type#" (..caster .Type .Type)) +(def with_basic_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "is_type#" (..caster .Type .Type)) (///bundle.install "is?#" lux::is?) (///bundle.install "try#" lux::try) (///bundle.install "in_module#" lux::in_module) @@ -272,10 +270,9 @@ (///bundle.install "text_clip#" (trinary Nat Nat Text Text)) )) -(def .public (bundle eval) - (-> Eval Bundle) +(def .public bundle (|> ///bundle.empty - (with_basic_extensions eval) + with_basic_extensions with_io_extensions with_text_extensions with_i64_extensions diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux index 72c337e78..a5300258e 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux @@ -44,6 +44,10 @@ ["[1][0]" synthesis (.only Synthesis)] ["[1][0]" generation] ["[1][0]" declaration (.only Import Requirements Phase Operation Handler Extender Bundle)] + [phase + [extension + ["[0]E" analysis + ["[1]" lux]]]] ["[1][0]" program (.only Program)] [/// ["[0]" phase] @@ -221,34 +225,21 @@ ) ... TODO: Get rid of this function ASAP. -(def (refresh host_analysis) +(def refresh (All (_ anchor expression declaration) - (-> /////analysis.Bundle (Operation anchor expression declaration Any))) + (Operation anchor expression declaration Any)) (do [! phase.monad] [[bundle state] phase.state .let [eval (/////analysis/evaluation.evaluator (the [/////declaration.#analysis /////declaration.#phase] state) [(the [/////declaration.#synthesis /////declaration.#state] state) (the [/////declaration.#synthesis /////declaration.#phase] state)] [(the [/////declaration.#generation /////declaration.#state] state) - (the [/////declaration.#generation /////declaration.#phase] state)]) - previous_analysis_extensions (the [/////declaration.#analysis /////declaration.#state ///.#bundle] state) - - new_analysis_extensions (///analysis.bundle eval host_analysis) - new_is# (|> new_analysis_extensions (dictionary.value "is#") maybe.trusted) - new_as# (|> new_analysis_extensions (dictionary.value "as#") maybe.trusted)] - _ (phase.with [bundle - (revised [/////declaration.#analysis /////declaration.#state] - (is (-> /////analysis.State+ /////analysis.State+) - (|>> product.right - [(|> previous_analysis_extensions - (dictionary.composite new_analysis_extensions))])) - state)]) - current_module (/////declaration.lifted_analysis - (///.lifted meta.current_module_name)) + (the [/////declaration.#generation /////declaration.#phase] state)])] _ (/////declaration.lifted_analysis (do ! - [_ (moduleA.override_definition [.prelude "is#"] {.#Default [true .Analysis new_is#]})] - (moduleA.override_definition [.prelude "as#"] {.#Default [true .Analysis new_as#]})))] + [_ (moduleA.override_definition [.prelude "is#"] {.#Default [true .Analysis (analysisE.is#_extension eval)]}) + _ (moduleA.override_definition [.prelude "as#"] {.#Default [true .Analysis (analysisE.as#_extension eval)]})] + (in [])))] (in []))) (def (announce_definition! short type) @@ -257,20 +248,20 @@ (/////declaration.lifted_generation (/////generation.log! (format short " : " (%.type type))))) -(def (lux::def host_analysis) - (-> /////analysis.Bundle Handler) +(def lux::def + Handler (function (_ extension_name phase archive inputsC+) (when inputsC+ (list [_ {.#Symbol ["" short_name]}] valueC exported?C) (do phase.monad - [current_module (/////declaration.lifted_analysis + [_ ..refresh + current_module (/////declaration.lifted_analysis (///.lifted meta.current_module_name)) .let [full_name [current_module short_name]] [type valueT value] (..definition archive full_name {.#None} valueC) [_ _ exported?] (evaluate! archive Bit exported?C) _ (/////declaration.lifted_analysis (moduleA.define short_name {.#Definition [(as Bit exported?) type value]})) - _ (..refresh host_analysis) _ (..announce_definition! short_name type)] (in /////declaration.no_requirements)) @@ -375,11 +366,9 @@ {.#Named name anonymous} {.#Named name (again anonymous)})))) -(def .public (bundle host_analysis) - (All (_ anchor expression declaration) - (-> /////analysis.Bundle - (Bundle anchor expression declaration))) +(def .public bundle + Bundle (|> ///bundle.empty - (dictionary.has "def#" (lux::def host_analysis)) + (dictionary.has "def#" lux::def) (dictionary.has "module#" def_module) (dictionary.has "alias#" def_alias))) diff --git a/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux b/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux index 71f055c64..e419e99aa 100644 --- a/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux @@ -262,7 +262,7 @@ (def (cache_parser customs) (-> (List Custom) (Parser [(module.Module Any) Registry])) - (when (for @.old (as (List (Custom Any Any Any)) + (when (for @.old (as (List (Custom Any Any)) customs) customs) {.#End} |