From b25eec45fa9aabdc252d59afad3e0c7e73a18fd9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 22 Oct 2022 02:49:30 -0400 Subject: Clean-up after format change for extensions [part 3] --- .../library/lux/meta/compiler/default/init.lux | 12 +- .../library/lux/meta/compiler/default/platform.lux | 109 +++--- .../lux/meta/compiler/language/lux/analysis.lux | 6 +- .../meta/compiler/language/lux/phase/analysis.lux | 99 ++---- .../compiler/language/lux/phase/declaration.lux | 100 +----- .../meta/compiler/language/lux/phase/extension.lux | 142 ++++++-- .../language/lux/phase/extension/analysis/jvm.lux | 376 +++++++++------------ .../language/lux/phase/extension/analysis/lux.lux | 110 +++--- .../language/lux/phase/extension/bundle.lux | 18 - .../lux/phase/extension/declaration/jvm.lux | 5 +- .../lux/phase/extension/declaration/lux.lux | 16 +- .../extension/generation/common_lisp/common.lux | 13 - .../lux/phase/extension/generation/js/common.lux | 13 - .../lux/phase/extension/generation/jvm/common.lux | 88 +++-- .../lux/phase/extension/generation/jvm/host.lux | 287 ++++++++-------- .../lux/phase/extension/generation/lua/common.lux | 13 - .../lux/phase/extension/generation/php/common.lux | 13 - .../phase/extension/generation/python/common.lux | 13 - .../lux/phase/extension/generation/r/common.lux | 13 - .../lux/phase/extension/generation/ruby/common.lux | 13 - .../phase/extension/generation/scheme/common.lux | 13 - .../language/lux/phase/generation/extension.lux | 24 +- .../compiler/language/lux/phase/generation/jvm.lux | 47 +-- .../meta/compiler/language/lux/phase/synthesis.lux | 83 ++--- .../lux/meta/compiler/language/lux/synthesis.lux | 19 +- .../library/lux/meta/compiler/meta/archive.lux | 14 + stdlib/source/library/lux/world/net/http.lux | 15 +- stdlib/source/library/lux/world/net/uri/scheme.lux | 141 ++++++++ stdlib/source/library/lux/world/time.lux | 3 +- stdlib/source/program/compositor.lux | 10 +- .../meta/compiler/language/lux/phase/extension.lux | 30 -- stdlib/source/test/lux/world/net.lux | 6 +- stdlib/source/test/lux/world/net/uri/scheme.lux | 163 +++++++++ stdlib/source/test/lux/world/time.lux | 25 +- 34 files changed, 1023 insertions(+), 1029 deletions(-) delete mode 100644 stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/bundle.lux create mode 100644 stdlib/source/library/lux/world/net/uri/scheme.lux create mode 100644 stdlib/source/test/lux/world/net/uri/scheme.lux (limited to 'stdlib/source') diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index 6f9051947..0daa166c6 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -108,7 +108,7 @@ (monad.each ! (function (_ [name handler]) (///declaration.lifted_analysis - (moduleA.define name {.#Default [true .Analysis handler]})))))] + (moduleA.override_definition [.prelude name] {.#Default [true .Analysis handler]})))))] (in []))) (def (with_generation_defaults bundle) @@ -121,7 +121,7 @@ (monad.each ! (function (_ [name handler]) (///declaration.lifted_analysis - (moduleA.define name {.#Default [true .Generation handler]})))))] + (moduleA.override_definition [.prelude name] {.#Default [true .Generation handler]})))))] (in []))) (def (with_declaration_defaults bundle) @@ -133,8 +133,10 @@ dictionary.entries (monad.each ! (function (_ [name handler]) - (///declaration.lifted_analysis - (moduleA.define name {.#Default [true .Declaration handler]})))))] + (do ! + [_ (///declaration.lifted_analysis + (moduleA.override_definition [.prelude name] {.#Default [true .Declaration handler]}))] + (in [])))))] (in []))) (type .public (Extensions anchor expression declaration) @@ -142,7 +144,7 @@ (///generation.Bundle anchor expression declaration) (///declaration.Bundle anchor expression declaration)]) -(def (with_defaults module [analysis_bundle generation_bundle host_declaration_bundle]) +(def .public (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))) diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index a9a8aaee0..6d1974ab8 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -37,7 +37,7 @@ ["[0]" // ["[1][0]" init] ["/[1]" // (.only) - ["[1][0]" phase (.only Phase)] + ["[0]" phase (.only Phase) (.use "[1]#[0]" monad)] [language [lux [program (.only Program)] @@ -80,7 +80,7 @@ #host (///generation.Host expression declaration) #phase (-> extension.Extender Lux (///generation.Phase )) #runtime ( [Registry Output]) - #phase_wrapper ///phase.Wrapper + #phase_wrapper phase.Wrapper #write (-> declaration Binary)])) ... TODO: Get rid of this @@ -150,7 +150,7 @@ (def (compile_runtime! platform) (All (_ ) (-> (///generation.Operation [Registry Output]))) - (do ///phase.monad + (do phase.monad [_ ..initialize_buffer!] (the #runtime platform))) @@ -177,34 +177,40 @@ (-> Archive (///declaration.Operation [Archive (archive.Entry .Module)]))) - (do ///phase.monad + (do phase.monad [[registry payload] (///declaration.lifted_generation (..compile_runtime! platform)) .let [entry [..runtime_module payload registry]] - archive (///phase.lifted (if (archive.reserved? archive descriptor.runtime) - (archive.has descriptor.runtime entry archive) - (do try.monad - [[_ archive] (archive.reserve descriptor.runtime archive)] - (archive.has descriptor.runtime entry archive))))] + archive (phase.lifted (if (archive.reserved? archive descriptor.runtime) + (archive.has descriptor.runtime entry archive) + (do try.monad + [[_ archive] (archive.reserve descriptor.runtime archive)] + (archive.has descriptor.runtime entry archive))))] (in [archive entry]))) - (def (initialize_state analysis_state state) + (def (initialize_state analysis_state all_extensions) (All (_ ) - (-> .Lux - (Try ))) - (|> (sharing [] - (is - state) - (is (///declaration.Operation Any) - (do [! ///phase.monad] - [_ (///declaration.lifted_analysis - (///analysis.set_state analysis_state))] - (in [])))) - (///phase.result' state) - (at try.monad each product.left))) + (-> .Lux (//init.Extensions ) + (///declaration.Operation Any))) + (do [! phase.monad] + [_ (///declaration.lifted_analysis + (///analysis.set_state analysis_state))] + (//init.with_defaults .prelude all_extensions))) + + (def (with_extended_prelude state archive) + (-> Lux Archive Archive) + (|> (do try.monad + [prelude (meta.result state (meta.module .prelude)) + entry (archive.find .prelude archive) + .let [entry (has [archive.#module module.#document] + (document.document $.key prelude) + entry)]] + (archive.has! .prelude entry archive)) + (try.else archive))) (def .public (initialize context module expander platform program extender - import compilation_sources compilation_configuration) + import compilation_sources compilation_configuration + all_extensions) (All (_ ) (-> context.Context descriptor.Module @@ -213,7 +219,8 @@ (Program expression declaration) extension.Extender Import (List _io.Context) Configuration - (Async (Try [ Archive ///phase.Wrapper])))) + (//init.Extensions ) + (Async (Try [ Archive phase.Wrapper])))) (do [! ..monad] [.let [phase_wrapper (the #phase_wrapper platform) state (//init.state (the context.#host context) @@ -228,22 +235,22 @@ [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 (_ ) - (-> (Async (Try )))) - (function (_ state) - (|> state - (initialize_state analysis_state) + (-> (//init.Extensions ) (Async (Try )))) + (function (_ all_extensions state) + (|> (initialize_state analysis_state all_extensions) + (phase.result' state) + (try#each product.left) async#in)))]] - (if (archive.archived? archive descriptor.runtime) + (if (archive.archived? archive .prelude) (do ! - [state (with_missing_extensions state)] + [state (with_missing_extensions all_extensions state) + .let [archive (with_extended_prelude (the [///declaration.#analysis ///declaration.#state] state) archive)]] (in [state archive phase_wrapper])) (do ! [[state [archive payload]] (|> (..process_runtime archive platform) - (///phase.result' state) + (phase.result' state) async#in) - _ (..cache_module context platform 0 $.key $.format payload) - - state (with_missing_extensions state)] + _ (..cache_module context platform 0 $.key $.format payload)] (in [state archive phase_wrapper]))))) (def compilation_log_separator @@ -357,32 +364,6 @@ ... else {try.#Success []})) - (exception.def .public (cannot_overwrite_extension extension) - (Exception extension.Name) - (exception.report - (list ["Extension" (%.text extension)]))) - - (def (with_extensions from to) - (All (_ state input output) - (-> (extension.Bundle state input output) - (extension.Bundle state input output) - (Try (extension.Bundle state input output)))) - (monad.mix try.monad - (function (_ [extension expected] output) - (with_expansions [ (dictionary.has extension expected output)] - (when (dictionary.value extension output) - {.#None} - {try.#Success } - - {.#Some actual} - (if (same? expected actual) - {try.#Success } - (exception.except ..cannot_overwrite_extension [extension]))))) - to - ... TODO: Come up with something better. This is not an ideal solution because it can mask overwrites happening across multiple imported modules. - (list.only (|>> product.left (dictionary.key? to) not) - (dictionary.entries from)))) - (type (Context state) [Archive state]) @@ -539,7 +520,7 @@ (All (_ ) (-> descriptor.Module )) (|> (///declaration.set_current_module module) - (///phase.result' state) + (phase.result' state) try.trusted product.left)) @@ -614,7 +595,7 @@ ... TODO: The "///declaration.set_current_module" below shouldn't be necessary. Remove it ASAP. ... TODO: The context shouldn't need to be re-set either. (|> (///declaration.set_current_module module) - (///phase.result' state) + (phase.result' state) try.trusted product.left) archive)) @@ -623,7 +604,7 @@ all_extensions) (All (_ ) (-> (Program expression declaration) (-> Archive Symbol (///generation.Operation expression)) - ///phase.Wrapper (Extender ) Expander Text (Maybe Module) + phase.Wrapper (Extender ) Expander Text (Maybe Module) (//init.Extensions ) (///.Compiler .Module))) (let [instancer (//init.compiler program global phase_wrapper extender expander syntax.prelude (the #write platform) program_module program_definition @@ -811,7 +792,7 @@ all_extensions) (All (_ ) (-> (Program expression declaration) (-> Archive Symbol (///generation.Operation expression)) - (-> Any ..Custom) ///phase.Wrapper Import context.Context (Extender ) Expander Compilation Lux_Context + (-> Any ..Custom) phase.Wrapper Import context.Context (Extender ) Expander Compilation Lux_Context (//init.Extensions ) Lux_Return)) (do [! ..monad] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux index 406af1954..0145f2162 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux @@ -24,7 +24,6 @@ ["r" rev] ["f" frac]]] [meta - ["[0]" symbol] ["[0]" location] ["[0]" configuration (.only Configuration)] ["[0]" code @@ -65,7 +64,7 @@ {#When Analysis (Match' Analysis)} {#Function (Environment Analysis) Analysis} {#Apply Analysis Analysis} - {#Extension [Symbol (List Analysis)]}))) + {#Extension (Extension Analysis)}))) (type .public Branch (Branch' Analysis)) @@ -110,8 +109,7 @@ (= reference_abstraction sample_abstraction)) [{#Extension reference} {#Extension sample}] - ... (at (extension.equivalence =) = reference sample) - (at (product.equivalence symbol.equivalence (list.equivalence =)) = reference sample) + (at (extension.equivalence =) = reference sample) _ false)))) 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 3354d05fe..4c50af1f4 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 @@ -28,15 +28,17 @@ ["[1][0]" reference] ["[1][0]" when] ["[1][0]" function] - ["//[1]" /// - ["/" analysis (.only Analysis Operation Phase Handler Extender) - ["[1][0]" macro (.only Expander)] - ["[1][0]" type]] - [/// - ["//" phase] - ["[0]" reference] - [meta - [archive (.only Archive)]]]]]) + ["/[1]" // + ["[0]" extension] + ["/[1]" // + ["/" analysis (.only Analysis Operation Phase Handler Extender) + ["[1][0]" macro (.only Expander)] + ["[1][0]" type]] + [/// + ["//" phase] + ["[0]" reference] + [meta + [archive (.only Archive)]]]]]]) (exception.def .public (invalid syntax) (Exception Code) @@ -76,63 +78,6 @@ {.#None} (//.except ..invalid [code]))])) -(type Value - (Variant - {#Normal Any} - {#Special Any})) - -(def (global_value name) - (-> Symbol (Meta (Maybe [Type Value]))) - (do meta.monad - [global (meta.try (meta.local name))] - (when global - {try.#Success global} - (in (when global - {.#Definition [exported? type value]} - {.#Some [type {#Normal value}]} - - {.#Default [exported? type value]} - {.#Some [type {#Special value}]} - - {.#Alias _} - {.#None})) - - {try.#Failure error} - (in {.#None})))) - -(def (global_analysis name) - (-> Symbol (Meta (Maybe Value))) - (do meta.monad - [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 - name parameters) - (-> Extender - Phase Archive - Symbol (List Code) - (Operation (Maybe Analysis))) - (do [! //.monad] - [value (global_analysis name) - .let [[module short] name]] - (when value - {.#Some value} - (do ! - [it (when value - {#Normal definition} - ((extender definition) phase archive parameters) - - {#Special default} - ((as Handler default) phase archive parameters))] - (in {.#Some it})) - - {.#None} - (in {.#None})))) - ... TODO: Replace with an inline function. (exception.def .public (not_a_macro name) (Exception Symbol) @@ -159,8 +104,12 @@ (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)))) + [lux meta.compiler_state] + (extension.application extender + lux analysis archive + .Analysis def_name argsC+ + (|>>) + (function (_ _) {.#None})))) (/function.apply analysis argsC+ function_type function_analysis archive functionC))) ... TODO: Replace with an inline function. @@ -183,13 +132,13 @@ [(when functionC [_ {.#Symbol global}] (do //.monad - [it (extension_application extender analysis archive global argsC+)] - (when it - {.#Some it} - (in it) - - {.#None} - (term_application extender expander analysis archive functionC argsC+))) + [lux meta.compiler_state] + (extension.application extender + lux analysis archive + .Analysis global argsC+ + (|>>) + (function (_ _) + {.#Some (term_application extender expander analysis archive functionC argsC+)}))) _ (term_application extender expander analysis archive functionC argsC+))])) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux index 4cd82397c..8d9e85ac5 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux @@ -15,6 +15,7 @@ [type (.only sharing) ["[0]" check]]]]] ["[0]" // + ["[0]" extension] ["[1][0]" analysis] ["/[1]" // ["/" declaration (.only Operation Phase Handler Extender)] @@ -56,62 +57,6 @@ tail' (requiring phase archive tail)] (in (/.merge_requirements head' tail'))))) -(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])) - (do meta.monad - [global (meta.local name)] - (when global - {.#Definition [exported? type value]} - (in [type {#Normal value}]) - - {.#Default [exported? type value]} - (in [type {#Special value}]) - - {.#Alias _} - (undefined)))) - -(def (global_declaration name) - (-> Symbol (Meta Value)) - (do meta.monad - [[type value] (global_value name)] - (if (check.subsumes? .Declaration type) - (in value) - (meta.failure (exception.error ..not_an_extension [name .Declaration type]))))) - -(def (extension_application extender - phase archive - name parameters) - (All (_ anchor expression declaration) - (-> (Extender anchor expression declaration) - (Phase anchor expression declaration) Archive - Symbol (List Code) - (Operation anchor expression declaration /.Requirements))) - (do //.monad - [value (/.lifted_analysis (global_declaration name))] - (when value - {#Normal definition} - ((extender definition) phase archive parameters) - - {#Special default} - (let [default (sharing [anchor expression declaration] - (is (Extender anchor expression declaration) - extender) - (is (Handler anchor expression declaration) - (as_expected default)))] - (default phase archive parameters))))) - (type Outcome (Variant {#More (List Code)} @@ -124,8 +69,7 @@ (function (again archive code) (do [! //.monad] [state //.state - .let [analysis (the [/.#analysis /.#phase] state) - compiler_eval ((evaluation.evaluator analysis + .let [compiler_eval ((evaluation.evaluator (the [/.#analysis /.#phase] state) [(the [/.#synthesis /.#state] state) (the [/.#synthesis /.#phase] state)] [(the [/.#generation /.#state] state) @@ -136,30 +80,22 @@ (when code [_ {.#Form (list.partial [_ {.#Symbol macro|extension}] inputs)}] (do ! - [expansion|requirements (do ! - [[def_type def_value] (/.lifted_analysis (global_value macro|extension))] - (when def_value - {#Normal def_value} - (cond (check.subsumes? Macro def_type) - (/.lifted_analysis - (do ! - [expansion (///analysis/macro.expansion expander macro|extension (as Macro def_value) inputs)] - (in {#More expansion}))) - - (check.subsumes? .Declaration def_type) - (do ! - [requirements (extension_application extender again archive macro|extension inputs)] - (in {#Done requirements})) - - ... else - (//.except ..invalid_macro_call [code])) - - {#Special def_value} - (if (check.subsumes? .Declaration def_type) - (do ! - [requirements (extension_application extender again archive macro|extension inputs)] - (in {#Done requirements})) - (//.except ..invalid_macro_call [code]))))] + [expansion|requirements (extension.application extender + (the [/.#analysis /.#state] state) again archive + .Declaration macro|extension inputs + (|>> {#Done}) + (function (_ _) + {.#Some (do ! + [macro (/.lifted_analysis (meta.macro macro|extension))] + (when macro + {.#Some macro} + (/.lifted_analysis + (do ! + [expansion (///analysis/macro.expansion expander macro|extension macro inputs)] + (in {#More expansion}))) + + {.#None} + (//.except ..invalid_macro_call [code])))}))] (when expansion|requirements {.#Left expansion} (when expansion diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux index adf9d20a0..7de2dbea9 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux @@ -3,8 +3,10 @@ [lux (.except) [abstract [equivalence (.only Equivalence)] - [hash (.only Hash)]] + [hash (.only Hash)] + [monad (.only do)]] [control + ["[0]" try] ["[0]" exception (.only Exception)]] [data ["[0]" product] @@ -12,53 +14,121 @@ ["%" \\format (.only Format)]] [collection ["[0]" list] - ["[0]" dictionary (.only Dictionary)]]]]] + ["[0]" dictionary (.only Dictionary)]]] + ["[0]" meta (.only) + ["[0]" symbol] + [type (.only sharing) + ["[0]" check]]]]] [///// - ["[0]" phase]]) + ["[0]" phase (.only Operation Phase) (.use "[1]#[0]" functor)] + [meta + [archive (.only Archive)]]]) -(type .public Name - Text) - -(type .public (Extension a) +(type .public (Extension of) (Record - [#name Name - #parameters (List a)])) + [#name Symbol + #parameters (List of)])) (def .public equivalence - (All (_ a) - (-> (Equivalence a) - (Equivalence (Extension a)))) + (All (_ of) + (-> (Equivalence of) + (Equivalence (Extension of)))) (|>> list.equivalence - (product.equivalence text.equivalence))) + (product.equivalence symbol.equivalence))) (def .public hash - (All (_ a) - (-> (Hash a) - (Hash (Extension a)))) + (All (_ of) + (-> (Hash of) + (Hash (Extension of)))) (|>> list.hash - (product.hash text.hash))) + (product.hash symbol.hash))) -(type .public (Handler s i o) - (-> (phase.Phase s i o) - (phase.Phase s (List i) o))) +(type .public (Handler state input output) + (-> (Phase state input output) + (Phase state (List input) output))) -(type .public (Bundle s i o) - (Dictionary Name (Handler s i o))) +(type .public (Bundle state input output) + (Dictionary Text (Handler state input output))) -(exception.def .public (incorrect_arity [name arity args]) - (Exception [Name Nat Nat]) - (exception.report - (list ["Extension" (%.text name)] - ["Expected" (%.nat arity)] - ["Actual" (%.nat args)]))) +(def .public empty + Bundle + (dictionary.empty text.hash)) + +(type .public (Extender state input output) + (-> Any + (Handler state input output))) -(exception.def .public (invalid_syntax [name %format inputs]) - (All (_ a) - (Exception [Name (Format a) (List a)])) +(exception.def .public (invalid [global expected actual]) + (Exception [Symbol Type Type]) (exception.report - (list ["Extension" (%.text name)] - ["Inputs" (exception.listing %format inputs)]))) + (list ["Definition" (%.symbol global)] + ["Expected" (%.type expected)] + ["Actual" (%.type actual)]))) -(type .public (Extender s i o) - (-> Any - (Handler s i o))) +(exception.def .public (error error) + (Exception Text) + error) + +(type Value + (Variant + {#Normal Any} + {#Special Any})) + +(def (global_value name) + (-> Symbol (Meta [Type Value])) + (do meta.monad + [global (meta.local name)] + (when global + {.#Definition [exported? type value]} + (in [type {#Normal value}]) + + {.#Default [exported? type value]} + (in [type {#Special value}]) + + {.#Alias _} + (undefined)))) + +(def (global_extension expected_type name) + (-> Type Symbol (Meta Value)) + (do meta.monad + [[actual_type value] (global_value name)] + (if (check.subsumes? expected_type actual_type) + (in value) + (meta.failure (exception.error ..invalid [name expected_type actual_type]))))) + +(def .public (application extender + lux phase archive + expected_type global parameters + when_valid + when_invalid) + (All (_ state input raw_output processed_output) + (-> (Extender state input raw_output) + Lux (Phase state input raw_output) Archive + Type Symbol (List input) + (-> raw_output processed_output) + (-> Text (Maybe (Operation state processed_output))) + (Operation state processed_output))) + (when (|> (do [! meta.monad] + [value (global_extension expected_type global)] + (in ((when value + {#Normal definition} + (extender definition) + + {#Special default} + (sharing [state input raw_output] + (is (Extender state input raw_output) + extender) + (is (Handler state input raw_output) + (as_expected default)))) + phase archive parameters))) + (meta.result lux)) + {try.#Success operation} + (phase#each when_valid operation) + + {try.#Failure error} + (when (when_invalid error) + {.#Some when_invalid} + when_invalid + + {.#None} + (phase.except ..error [error])))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux index 89b18beb8..796647b7b 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -60,9 +60,8 @@ ["[0]" type (.use "[1]#[0]" equivalence) ["[0]" check (.only Check) (.use "[1]#[0]" monad)]]]]] ["[0]" // - ["[1][0]" lux (.only custom)] + ["[1][0]" lux (.only custom install)] ["/[1]" // (.only) - ["[1][0]" bundle] ["/[1]" // [generation [jvm @@ -300,48 +299,48 @@ (def with_conversion_extensions (-> Bundle Bundle) - (|>> (///bundle.install "jvm_conversion_double_to_float#" (//lux.unary ..double ..float)) - (///bundle.install "jvm_conversion_double_to_int#" (//lux.unary ..double ..int)) - (///bundle.install "jvm_conversion_double_to_long#" (//lux.unary ..double ..long)) - (///bundle.install "jvm_conversion_float_to_double#" (//lux.unary ..float ..double)) - (///bundle.install "jvm_conversion_float_to_int#" (//lux.unary ..float ..int)) - (///bundle.install "jvm_conversion_float_to_long#" (//lux.unary ..float ..long)) - (///bundle.install "jvm_conversion_int_to_byte#" (//lux.unary ..int ..byte)) - (///bundle.install "jvm_conversion_int_to_char#" (//lux.unary ..int ..char)) - (///bundle.install "jvm_conversion_int_to_double#" (//lux.unary ..int ..double)) - (///bundle.install "jvm_conversion_int_to_float#" (//lux.unary ..int ..float)) - (///bundle.install "jvm_conversion_int_to_long#" (//lux.unary ..int ..long)) - (///bundle.install "jvm_conversion_int_to_short#" (//lux.unary ..int ..short)) - (///bundle.install "jvm_conversion_long_to_double#" (//lux.unary ..long ..double)) - (///bundle.install "jvm_conversion_long_to_float#" (//lux.unary ..long ..float)) - (///bundle.install "jvm_conversion_long_to_int#" (//lux.unary ..long ..int)) - (///bundle.install "jvm_conversion_long_to_short#" (//lux.unary ..long ..short)) - (///bundle.install "jvm_conversion_long_to_byte#" (//lux.unary ..long ..byte)) - (///bundle.install "jvm_conversion_char_to_byte#" (//lux.unary ..char ..byte)) - (///bundle.install "jvm_conversion_char_to_short#" (//lux.unary ..char ..short)) - (///bundle.install "jvm_conversion_char_to_int#" (//lux.unary ..char ..int)) - (///bundle.install "jvm_conversion_char_to_long#" (//lux.unary ..char ..long)) - (///bundle.install "jvm_conversion_byte_to_long#" (//lux.unary ..byte ..long)) - (///bundle.install "jvm_conversion_short_to_long#" (//lux.unary ..short ..long)) + (|>> (install "jvm_conversion_double_to_float#" (//lux.unary ..double ..float)) + (install "jvm_conversion_double_to_int#" (//lux.unary ..double ..int)) + (install "jvm_conversion_double_to_long#" (//lux.unary ..double ..long)) + (install "jvm_conversion_float_to_double#" (//lux.unary ..float ..double)) + (install "jvm_conversion_float_to_int#" (//lux.unary ..float ..int)) + (install "jvm_conversion_float_to_long#" (//lux.unary ..float ..long)) + (install "jvm_conversion_int_to_byte#" (//lux.unary ..int ..byte)) + (install "jvm_conversion_int_to_char#" (//lux.unary ..int ..char)) + (install "jvm_conversion_int_to_double#" (//lux.unary ..int ..double)) + (install "jvm_conversion_int_to_float#" (//lux.unary ..int ..float)) + (install "jvm_conversion_int_to_long#" (//lux.unary ..int ..long)) + (install "jvm_conversion_int_to_short#" (//lux.unary ..int ..short)) + (install "jvm_conversion_long_to_double#" (//lux.unary ..long ..double)) + (install "jvm_conversion_long_to_float#" (//lux.unary ..long ..float)) + (install "jvm_conversion_long_to_int#" (//lux.unary ..long ..int)) + (install "jvm_conversion_long_to_short#" (//lux.unary ..long ..short)) + (install "jvm_conversion_long_to_byte#" (//lux.unary ..long ..byte)) + (install "jvm_conversion_char_to_byte#" (//lux.unary ..char ..byte)) + (install "jvm_conversion_char_to_short#" (//lux.unary ..char ..short)) + (install "jvm_conversion_char_to_int#" (//lux.unary ..char ..int)) + (install "jvm_conversion_char_to_long#" (//lux.unary ..char ..long)) + (install "jvm_conversion_byte_to_long#" (//lux.unary ..byte ..long)) + (install "jvm_conversion_short_to_long#" (//lux.unary ..short ..long)) )) (with_template [ ] [(def (-> Bundle Bundle) (let [type (reflection.reflection )] - (|>> (///bundle.install (%.format "jvm_" type "_" "+" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "-" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "*" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "/" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "%" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "=" "#") (//lux.binary Bit)) - (///bundle.install (%.format "jvm_" type "_" "<" "#") (//lux.binary Bit)) - (///bundle.install (%.format "jvm_" type "_" "and" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "or" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "xor" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "shl" "#") (//lux.binary ..int )) - (///bundle.install (%.format "jvm_" type "_" "shr" "#") (//lux.binary ..int )) - (///bundle.install (%.format "jvm_" type "_" "ushr" "#") (//lux.binary ..int )) + (|>> (install (%.format "jvm_" type "_" "+" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "-" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "*" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "/" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "%" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "=" "#") (//lux.binary Bit)) + (install (%.format "jvm_" type "_" "<" "#") (//lux.binary Bit)) + (install (%.format "jvm_" type "_" "and" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "or" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "xor" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "shl" "#") (//lux.binary ..int )) + (install (%.format "jvm_" type "_" "shr" "#") (//lux.binary ..int )) + (install (%.format "jvm_" type "_" "ushr" "#") (//lux.binary ..int )) )))] [with_int_extensions reflection.int ..int] @@ -352,13 +351,13 @@ [(def (-> Bundle Bundle) (let [type (reflection.reflection )] - (|>> (///bundle.install (%.format "jvm_" type "_" "+" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "-" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "*" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "/" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "%" "#") (//lux.binary )) - (///bundle.install (%.format "jvm_" type "_" "=" "#") (//lux.binary Bit)) - (///bundle.install (%.format "jvm_" type "_" "<" "#") (//lux.binary Bit)) + (|>> (install (%.format "jvm_" type "_" "+" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "-" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "*" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "/" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "%" "#") (//lux.binary )) + (install (%.format "jvm_" type "_" "=" "#") (//lux.binary Bit)) + (install (%.format "jvm_" type "_" "<" "#") (//lux.binary Bit)) )))] [with_float_extensions reflection.float ..float] @@ -368,8 +367,8 @@ (def with_char_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.char)] - (|>> (///bundle.install (%.format "jvm_" type "_" "=" "#") (//lux.binary ..char ..char Bit)) - (///bundle.install (%.format "jvm_" type "_" "<" "#") (//lux.binary ..char ..char Bit)) + (|>> (install (%.format "jvm_" type "_" "=" "#") (//lux.binary ..char ..char Bit)) + (install (%.format "jvm_" type "_" "<" "#") (//lux.binary ..char ..char Bit)) ))) (def .public boxes @@ -451,9 +450,9 @@ (def (primitive_array_length_handler primitive_type) (-> (Type Primitive) (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list arrayC) + (..custom + [.any + (function (_ extension_name analyse archive [arrayC]) (do phase.monad [_ (typeA.inference ..int) arrayA (<| (typeA.expecting {.#Primitive (|> (jvm.array primitive_type) @@ -461,16 +460,13 @@ (list)}) (analyse archive arrayC))] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list arrayA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + (list arrayA)})))])) (def array::length::object (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list arrayC) + (..custom + [.any + (function (_ extension_name analyse archive [arrayC]) (<| typeA.with_var (function (_ [@read :read:])) typeA.with_var @@ -484,32 +480,26 @@ arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (list (/////analysis.text (..signature arrayJT)) - arrayA)}))) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + arrayA)}))))])) (def (new_primitive_array_handler primitive_type) (-> (Type Primitive) (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list lengthC) + (..custom + [.any + (function (_ extension_name analyse archive [lengthC]) (do phase.monad [lengthA (<| (typeA.expecting ..int) (analyse archive lengthC)) _ (typeA.inference {.#Primitive (|> (jvm.array primitive_type) ..reflection) (list)})] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list lengthA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + (list lengthA)})))])) (def array::new::object (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list lengthC) + (..custom + [.any + (function (_ extension_name analyse archive [lengthC]) (do phase.monad [lengthA (<| (typeA.expecting ..int) (analyse archive lengthC)) @@ -523,10 +513,7 @@ (/////analysis.except ..non_array expectedT))] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (list (/////analysis.text (..signature elementJT)) - lengthA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + lengthA)})))])) (def (check_parameter objectT) (-> .Type (Operation (Type Parameter))) @@ -692,9 +679,9 @@ (def (read_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list idxC arrayC) + (..custom + [(<>.and .any .any) + (function (_ extension_name analyse archive [idxC arrayC]) (do phase.monad [_ (typeA.inference lux_type) idxA (<| (typeA.expecting ..int) @@ -703,16 +690,13 @@ (list)}) (analyse archive arrayC))] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list idxA arrayA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) + (list idxA arrayA)})))])) (def array::read::object (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list idxC arrayC) + (..custom + [(<>.and .any .any) + (function (_ extension_name analyse archive [idxC arrayC]) (<| typeA.with_var (function (_ [@read :read:])) typeA.with_var @@ -729,18 +713,15 @@ (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (list (/////analysis.text (..signature arrayJT)) idxA - arrayA)}))) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) + arrayA)}))))])) (def (write_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) (-> Text Handler)) (let [array_type {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)}] - (function (_ extension_name analyse archive args) - (when args - (list idxC valueC arrayC) + (..custom + [(all <>.and .any .any .any) + (function (_ extension_name analyse archive [idxC valueC arrayC]) (do phase.monad [_ (typeA.inference array_type) idxA (<| (typeA.expecting ..int) @@ -752,16 +733,13 @@ (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (list idxA valueA - arrayA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))) + arrayA)})))]))) (def array::write::object (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list idxC valueC arrayC) + (..custom + [(all <>.and .any .any .any) + (function (_ extension_name analyse archive [idxC valueC arrayC]) (<| typeA.with_var (function (_ [@read :read:])) typeA.with_var @@ -781,106 +759,94 @@ (list (/////analysis.text (..signature arrayJT)) idxA valueA - arrayA)}))) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))) + arrayA)}))))])) (def with_array_extensions (-> Bundle Bundle) - (|>> (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#") (primitive_array_length_handler jvm.boolean)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#") (primitive_array_length_handler jvm.byte)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#") (primitive_array_length_handler jvm.short)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#") (primitive_array_length_handler jvm.int)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#") (primitive_array_length_handler jvm.long)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#") (primitive_array_length_handler jvm.float)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#") (primitive_array_length_handler jvm.double)) - (///bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#") (primitive_array_length_handler jvm.char)) - (///bundle.install (%.format "jvm_" "array_" "length_" "object" "#") array::length::object) - - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#") (new_primitive_array_handler jvm.boolean)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#") (new_primitive_array_handler jvm.byte)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#") (new_primitive_array_handler jvm.short)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#") (new_primitive_array_handler jvm.int)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#") (new_primitive_array_handler jvm.long)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#") (new_primitive_array_handler jvm.float)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#") (new_primitive_array_handler jvm.double)) - (///bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#") (new_primitive_array_handler jvm.char)) - (///bundle.install (%.format "jvm_" "array_" "new_" "object" "#") array::new::object) - - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#") (read_primitive_array_handler ..boolean jvm.boolean)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#") (read_primitive_array_handler ..byte jvm.byte)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#") (read_primitive_array_handler ..short jvm.short)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#") (read_primitive_array_handler ..int jvm.int)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#") (read_primitive_array_handler ..long jvm.long)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#") (read_primitive_array_handler ..float jvm.float)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#") (read_primitive_array_handler ..double jvm.double)) - (///bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#") (read_primitive_array_handler ..char jvm.char)) - (///bundle.install (%.format "jvm_" "array_" "read_" "object" "#") array::read::object) - - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#") (write_primitive_array_handler ..boolean jvm.boolean)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#") (write_primitive_array_handler ..byte jvm.byte)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#") (write_primitive_array_handler ..short jvm.short)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#") (write_primitive_array_handler ..int jvm.int)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#") (write_primitive_array_handler ..long jvm.long)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#") (write_primitive_array_handler ..float jvm.float)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#") (write_primitive_array_handler ..double jvm.double)) - (///bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#") (write_primitive_array_handler ..char jvm.char)) - (///bundle.install (%.format "jvm_" "array_" "write_" "object" "#") array::write::object) + (|>> (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#") (primitive_array_length_handler jvm.boolean)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#") (primitive_array_length_handler jvm.byte)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#") (primitive_array_length_handler jvm.short)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#") (primitive_array_length_handler jvm.int)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#") (primitive_array_length_handler jvm.long)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#") (primitive_array_length_handler jvm.float)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#") (primitive_array_length_handler jvm.double)) + (install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#") (primitive_array_length_handler jvm.char)) + (install (%.format "jvm_" "array_" "length_" "object" "#") array::length::object) + + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#") (new_primitive_array_handler jvm.boolean)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#") (new_primitive_array_handler jvm.byte)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#") (new_primitive_array_handler jvm.short)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#") (new_primitive_array_handler jvm.int)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#") (new_primitive_array_handler jvm.long)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#") (new_primitive_array_handler jvm.float)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#") (new_primitive_array_handler jvm.double)) + (install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#") (new_primitive_array_handler jvm.char)) + (install (%.format "jvm_" "array_" "new_" "object" "#") array::new::object) + + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#") (read_primitive_array_handler ..boolean jvm.boolean)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#") (read_primitive_array_handler ..byte jvm.byte)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#") (read_primitive_array_handler ..short jvm.short)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#") (read_primitive_array_handler ..int jvm.int)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#") (read_primitive_array_handler ..long jvm.long)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#") (read_primitive_array_handler ..float jvm.float)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#") (read_primitive_array_handler ..double jvm.double)) + (install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#") (read_primitive_array_handler ..char jvm.char)) + (install (%.format "jvm_" "array_" "read_" "object" "#") array::read::object) + + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#") (write_primitive_array_handler ..boolean jvm.boolean)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#") (write_primitive_array_handler ..byte jvm.byte)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#") (write_primitive_array_handler ..short jvm.short)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#") (write_primitive_array_handler ..int jvm.int)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#") (write_primitive_array_handler ..long jvm.long)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#") (write_primitive_array_handler ..float jvm.float)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#") (write_primitive_array_handler ..double jvm.double)) + (install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#") (write_primitive_array_handler ..char jvm.char)) + (install (%.format "jvm_" "array_" "write_" "object" "#") array::write::object) )) (def object::null (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list) + (..custom + [.end + (function (_ extension_name analyse archive []) (do phase.monad [expectedT meta.expected_type [_ :object:] (check_object expectedT) _ (typeA.inference :object:)] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) + (list)})))])) (def object::null? (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list objectC) + (..custom + [.any + (function (_ extension_name analyse archive [objectC]) (do phase.monad [_ (typeA.inference .Bit) [objectT objectA] (typeA.inferring (analyse archive objectC)) _ (check_object objectT)] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list objectA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + (list objectA)})))])) (def object::synchronized (-> Text Handler) - (function (_ extension_name analyse archive args) - (when args - (list monitorC exprC) + (..custom + [(<>.and .any .any) + (function (_ extension_name analyse archive [monitorC exprC]) (do phase.monad [[monitorT monitorA] (typeA.inferring (analyse archive monitorC)) _ (check_object monitorT) exprA (analyse archive exprC)] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list monitorA exprA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) + (list monitorA exprA)})))])) (def (object::throw class_loader) (-> java/lang/ClassLoader (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list exceptionC) + (..custom + [.any + (function (_ extension_name analyse archive [exceptionC]) (do phase.monad [_ (typeA.inference Nothing) [exceptionT exceptionA] (typeA.inferring @@ -892,30 +858,19 @@ (in []) (/////analysis.except non_throwable exception_class)))] (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list exceptionA)})) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + (list exceptionA)})))])) (def (object::class class_loader) (-> java/lang/ClassLoader (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list classC) - (when classC - [_ {.#Text class}] - (do phase.monad - [_ (..ensure_fresh_class! class_loader class) - _ (typeA.inference {.#Primitive "java.lang.Class" (list {.#Primitive class (list)})}) - _ (phase.lifted (reflection!.load class_loader class))] - (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] - (list (/////analysis.text class))})) - - _ - (/////analysis.except ///.invalid_syntax [extension_name %.code args])) - - _ - (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) + (..custom + [.text + (function (_ extension_name analyse archive [class]) + (do phase.monad + [_ (..ensure_fresh_class! class_loader class) + _ (typeA.inference {.#Primitive "java.lang.Class" (list {.#Primitive class (list)})}) + _ (phase.lifted (reflection!.load class_loader class))] + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text class))})))])) (def (object::instance? class_loader) (-> java/lang/ClassLoader (-> Text Handler)) @@ -959,9 +914,9 @@ (def (object::cast class_loader) (-> java/lang/ClassLoader (-> Text Handler)) - (function (_ extension_name analyse archive args) - (when args - (list fromC) + (..custom + [.any + (function (_ extension_name analyse archive [fromC]) (do [! phase.monad] [toT meta.expected_type toJT (check_jvm toT) @@ -1024,20 +979,17 @@ (list (/////analysis.text from_name) (/////analysis.text to_name) fromA)}) - (/////analysis.except ..cannot_cast [fromJT toJT fromC]))) - - _ - (/////analysis.except ///.invalid_syntax [extension_name %.code args])))) + (/////analysis.except ..cannot_cast [fromJT toJT fromC]))))])) (def (with_object_extensions class_loader) (-> java/lang/ClassLoader (-> Bundle Bundle)) - (|>> (///bundle.install (%.format "jvm_" "object_" "null" "#") object::null) - (///bundle.install (%.format "jvm_" "object_" "null?" "#") object::null?) - (///bundle.install (%.format "jvm_" "object_" "synchronized" "#") object::synchronized) - (///bundle.install (%.format "jvm_" "object_" "throw" "#") (object::throw class_loader)) - (///bundle.install (%.format "jvm_" "object_" "class" "#") (object::class class_loader)) - (///bundle.install (%.format "jvm_" "object_" "instance?" "#") (object::instance? class_loader)) - (///bundle.install (%.format "jvm_" "object_" "cast" "#") (object::cast class_loader)) + (|>> (install (%.format "jvm_" "object_" "null" "#") object::null) + (install (%.format "jvm_" "object_" "null?" "#") object::null?) + (install (%.format "jvm_" "object_" "synchronized" "#") object::synchronized) + (install (%.format "jvm_" "object_" "throw" "#") (object::throw class_loader)) + (install (%.format "jvm_" "object_" "class" "#") (object::class class_loader)) + (install (%.format "jvm_" "object_" "instance?" "#") (object::instance? class_loader)) + (install (%.format "jvm_" "object_" "cast" "#") (object::cast class_loader)) )) (def (get::static class_loader) @@ -1624,17 +1576,17 @@ (def (with_member_extensions class_loader) (-> java/lang/ClassLoader (-> Bundle Bundle)) - (|>> (///bundle.install "jvm_member_get_static#" (get::static class_loader)) - (///bundle.install "jvm_member_get_virtual#" (get::virtual class_loader)) + (|>> (install "jvm_member_get_static#" (get::static class_loader)) + (install "jvm_member_get_virtual#" (get::virtual class_loader)) - (///bundle.install "jvm_member_put_static#" (put::static class_loader)) - (///bundle.install "jvm_member_put_virtual#" (put::virtual class_loader)) + (install "jvm_member_put_static#" (put::static class_loader)) + (install "jvm_member_put_virtual#" (put::virtual class_loader)) - (///bundle.install "jvm_member_invoke_static#" (invoke::static class_loader)) - (///bundle.install "jvm_member_invoke_virtual#" (invoke::virtual class_loader)) - (///bundle.install "jvm_member_invoke_special#" (invoke::special class_loader)) - (///bundle.install "jvm_member_invoke_interface#" (invoke::interface class_loader)) - (///bundle.install "jvm_member_invoke_constructor#" (invoke::constructor class_loader)) + (install "jvm_member_invoke_static#" (invoke::static class_loader)) + (install "jvm_member_invoke_virtual#" (invoke::virtual class_loader)) + (install "jvm_member_invoke_special#" (invoke::special class_loader)) + (install "jvm_member_invoke_interface#" (invoke::interface class_loader)) + (install "jvm_member_invoke_constructor#" (invoke::constructor class_loader)) )) (.type .public (Annotation_Parameter a) @@ -2715,7 +2667,7 @@ (def (with_class_extensions class_loader host) (-> java/lang/ClassLoader runtime.Host (-> Bundle Bundle)) - (///bundle.install (%.format "jvm_" "class_" "anonymous" "#") (class::anonymous class_loader host))) + (install (%.format "jvm_" "class_" "anonymous" "#") (class::anonymous class_loader host))) (def .public (bundle class_loader host) (-> java/lang/ClassLoader runtime.Host Bundle) @@ -2729,4 +2681,4 @@ (with_object_extensions class_loader) (with_member_extensions class_loader) (with_class_extensions class_loader host) - ///bundle.empty)) + ///.empty)) 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 c8b1a5d50..dee8675be 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 @@ -25,7 +25,6 @@ [type ["[0]" check]]]]] ["[0]" /// (.only) - ["[1][0]" bundle] ["/[1]" // [// ["[0]" analysis (.only Analysis Operation Phase Handler Bundle) @@ -35,7 +34,7 @@ ["[0]" generation] ["[0]" declaration] [/// - ["[1]" phase] + ["[0]" phase] [meta [archive (.only Archive)]]]]]]) @@ -49,8 +48,19 @@ {try.#Success inputs} (handler extension_name analyse archive inputs) - {try.#Failure _} - (analysis.except ///.invalid_syntax [extension_name %.code args])))) + {try.#Failure error} + (phase.failure error)))) + +(def .public (install name anonymous) + (-> Text (-> Text Handler) + (-> Bundle Bundle)) + (dictionary.has name (anonymous name))) + +(exception.def .public (incorrect_arity [expected actual]) + (Exception [Nat Nat]) + (exception.report + (list ["Expected" (%.nat expected)] + ["Actual" (%.nat actual)]))) (def (simple inputsT+ outputT extension_name) (-> (List Type) Type (-> Text Handler)) @@ -58,7 +68,7 @@ (function (_ analyse archive args) (let [num_actual (list.size args)] (if (n.= num_expected num_actual) - (do [! ////.monad] + (do [! phase.monad] [_ (typeA.inference outputT) argsA (monad.each ! (function (_ [argT argC]) @@ -66,7 +76,7 @@ (analyse archive argC))) (list.zipped_2 inputsT+ args))] (in {analysis.#Extension [.prelude (format extension_name "|generation")] argsA})) - (analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) + (analysis.except ..incorrect_arity [num_expected num_actual])))))) (def .public (nullary valueT) (-> Type (-> Text Handler)) @@ -108,7 +118,7 @@ .any))) .any) (function (_ extension_name phase archive [input conditionals else]) - (do [! ////.monad] + (do [! phase.monad] [input (<| (typeA.expecting text.Char) (phase archive input)) expectedT meta.expected_type @@ -145,7 +155,7 @@ (function (_ extension_name analyse archive opC) (<| typeA.with_var (function (_ [@var :var:])) - (do [! ////.monad] + (do [! phase.monad] [_ (typeA.inference (type_literal (Either Text :var:)))] (|> opC (analyse archive) @@ -165,7 +175,7 @@ (..custom [(<>.and .any .any) (function (_ extension_name analyse archive [typeC valueC]) - (do [! ////.monad] + (do [! phase.monad] [actualT (at ! each (|>> (as Type)) (eval archive Type typeC)) _ (typeA.inference actualT)] @@ -177,7 +187,7 @@ (..custom [(<>.and .any .any) (function (_ extension_name analyse archive [typeC valueC]) - (do [! ////.monad] + (do [! phase.monad] [actualT (at ! each (|>> (as Type)) (eval archive Type typeC)) _ (typeA.inference actualT) @@ -190,76 +200,76 @@ (..custom [.any (function (_ extension_name phase archive valueC) - (do [! ////.monad] + (do [! phase.monad] [_ (typeA.inference output)] (<| (typeA.expecting input) (phase archive valueC))))])) (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) - (///bundle.install "when_char#" lux::syntax_char_case!))) + (|>> (install "is_type#" (..caster .Type .Type)) + (install "is?#" lux::is?) + (install "try#" lux::try) + (install "in_module#" lux::in_module) + (install "when_char#" lux::syntax_char_case!))) (def with_io_extensions (-> Bundle Bundle) - (|>> (///bundle.install "log#" (unary Text Any)) - (///bundle.install "error#" (unary Text Nothing)))) + (|>> (install "log#" (unary Text Any)) + (install "error#" (unary Text Nothing)))) (def I64* (type_literal (I64 Any))) (def with_i64_extensions (-> Bundle Bundle) - (|>> (///bundle.install "i64_and#" (binary I64* I64* I64)) - (///bundle.install "i64_or#" (binary I64* I64* I64)) - (///bundle.install "i64_xor#" (binary I64* I64* I64)) - (///bundle.install "i64_left#" (binary Nat I64* I64)) - (///bundle.install "i64_right#" (binary Nat I64* I64)) + (|>> (install "i64_and#" (binary I64* I64* I64)) + (install "i64_or#" (binary I64* I64* I64)) + (install "i64_xor#" (binary I64* I64* I64)) + (install "i64_left#" (binary Nat I64* I64)) + (install "i64_right#" (binary Nat I64* I64)) - (///bundle.install "i64_=#" (binary I64* I64* Bit)) - (///bundle.install "i64_+#" (binary I64* I64* I64)) - (///bundle.install "i64_-#" (binary I64* I64* I64)))) + (install "i64_=#" (binary I64* I64* Bit)) + (install "i64_+#" (binary I64* I64* I64)) + (install "i64_-#" (binary I64* I64* I64)))) (def with_int_extensions (-> Bundle Bundle) - (|>> (///bundle.install "int_<#" (binary Int Int Bit)) - (///bundle.install "int_*#" (binary Int Int Int)) - (///bundle.install "int_/#" (binary Int Int Int)) - (///bundle.install "int_%#" (binary Int Int Int)) + (|>> (install "int_<#" (binary Int Int Bit)) + (install "int_*#" (binary Int Int Int)) + (install "int_/#" (binary Int Int Int)) + (install "int_%#" (binary Int Int Int)) - (///bundle.install "int_f64#" (unary Int Frac)) - (///bundle.install "int_char#" (unary Int Text)))) + (install "int_f64#" (unary Int Frac)) + (install "int_char#" (unary Int Text)))) (def with_frac_extensions (-> Bundle Bundle) - (|>> (///bundle.install "f64_+#" (binary Frac Frac Frac)) - (///bundle.install "f64_-#" (binary Frac Frac Frac)) - (///bundle.install "f64_*#" (binary Frac Frac Frac)) - (///bundle.install "f64_/#" (binary Frac Frac Frac)) - (///bundle.install "f64_%#" (binary Frac Frac Frac)) - (///bundle.install "f64_=#" (binary Frac Frac Bit)) - (///bundle.install "f64_<#" (binary Frac Frac Bit)) + (|>> (install "f64_+#" (binary Frac Frac Frac)) + (install "f64_-#" (binary Frac Frac Frac)) + (install "f64_*#" (binary Frac Frac Frac)) + (install "f64_/#" (binary Frac Frac Frac)) + (install "f64_%#" (binary Frac Frac Frac)) + (install "f64_=#" (binary Frac Frac Bit)) + (install "f64_<#" (binary Frac Frac Bit)) - (///bundle.install "f64_int#" (unary Frac Int)) - (///bundle.install "f64_encoded#" (unary Frac Text)) - (///bundle.install "f64_decoded#" (unary Text (type_literal (Maybe Frac)))))) + (install "f64_int#" (unary Frac Int)) + (install "f64_encoded#" (unary Frac Text)) + (install "f64_decoded#" (unary Text (type_literal (Maybe Frac)))))) (def with_text_extensions (-> Bundle Bundle) - (|>> (///bundle.install "text_=#" (binary Text Text Bit)) - (///bundle.install "text_<#" (binary Text Text Bit)) - (///bundle.install "text_composite#" (binary Text Text Text)) - (///bundle.install "text_index#" (trinary Nat Text Text (type_literal (Maybe Nat)))) - (///bundle.install "text_size#" (unary Text Nat)) - (///bundle.install "text_char#" (binary Nat Text Nat)) - (///bundle.install "text_clip#" (trinary Nat Nat Text Text)) + (|>> (install "text_=#" (binary Text Text Bit)) + (install "text_<#" (binary Text Text Bit)) + (install "text_composite#" (binary Text Text Text)) + (install "text_index#" (trinary Nat Text Text (type_literal (Maybe Nat)))) + (install "text_size#" (unary Text Nat)) + (install "text_char#" (binary Nat Text Nat)) + (install "text_clip#" (trinary Nat Nat Text Text)) )) (def .public bundle - (|> ///bundle.empty + (|> ///.empty with_basic_extensions with_io_extensions with_text_extensions diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/bundle.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/bundle.lux deleted file mode 100644 index d9b0fb4d2..000000000 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/bundle.lux +++ /dev/null @@ -1,18 +0,0 @@ -(.require - [library - [lux (.except) - [data - ["[0]" text] - [collection - ["[0]" dictionary]]]]] - [// (.only Handler Bundle)]) - -(def .public empty - Bundle - (dictionary.empty text.hash)) - -(def .public (install name anonymous) - (All (_ s i o) - (-> Text (-> Text (Handler s i o)) - (-> (Bundle s i o) (Bundle s i o)))) - (dictionary.has name (anonymous name))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux index 6028be070..6d67ae206 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux @@ -78,8 +78,7 @@ [jvm ["[0]" runtime (.only Anchor Definition Extender)] ["[0]" value]]] - [extension - ["[0]" bundle] + ["[0]" extension (.only) [analysis ["[0]" jvm]] [generation @@ -970,7 +969,7 @@ (def .public (bundle class_loader extender) (-> java/lang/ClassLoader Extender (Bundle Anchor (Bytecode Any) Definition)) - (|> bundle.empty + (|> extension.empty (dictionary.has (%.format "jvm_" "class" "#") jvm::class) (dictionary.has (%.format "jvm_" "class_" "interface" "#") ..jvm::class::interface) )) 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 9052c2384..d75f24433 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 @@ -31,7 +31,6 @@ ["[0]" type (.only sharing) (.use "[1]#[0]" equivalence) ["[0]" check]]]]] ["[0]" /// (.only) - ["[1][0]" bundle] ["[1][0]" analysis] ["/[1]" // ["/[1]" // @@ -74,7 +73,7 @@ (handler phase archive inputs) {try.#Failure error} - (phase.except ///.invalid_syntax ["" %.code inputs])))) + (phase.failure error)))) (def (context [@module @artifact]) (-> unit.ID unit.ID) @@ -248,9 +247,9 @@ (def lux::def Handler - (function (_ phase archive inputsC+) - (when inputsC+ - (list [_ {.#Symbol ["" short_name]}] valueC exported?C) + (..custom + [(all <>.and .local .any .any) + (function (_ phase archive [short_name valueC exported?C]) (do phase.monad [_ ..refresh current_module (/////declaration.lifted_analysis meta.current_module_name) @@ -260,10 +259,7 @@ _ (/////declaration.lifted_analysis (moduleA.define short_name {.#Definition [(as Bit exported?) type value]})) _ (..announce_definition! short_name type)] - (in /////declaration.no_requirements)) - - _ - (phase.except ///.invalid_syntax ["" %.code inputsC+])))) + (in /////declaration.no_requirements)))])) (def imports (Parser (List Import)) @@ -364,7 +360,7 @@ (def .public bundle Bundle - (|> ///bundle.empty + (|> ///.empty (dictionary.has "def#" lux::def) (dictionary.has "module#" def_module) (dictionary.has "alias#" def_alias))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index cda183698..06008de15 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -39,19 +39,6 @@ [/// ["[1]" phase]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - (def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux index e4920339b..7f7f3be33 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux @@ -40,19 +40,6 @@ [/// ["[1]" phase (.use "[1]#[0]" monad)]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - ... [Procedures] ... [[Bits]] (with_template [ ] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux index a598e96c5..a776e83e6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -24,6 +24,7 @@ ["[0]" type (.only Type) [category (.only Primitive Class)]]]]]]] ["[0]" ///// + ["[0]" extension] [generation [extension (.only Nullary Unary Binary Trinary Variadic nullary unary binary trinary variadic)] @@ -32,14 +33,11 @@ ["[1][0]" runtime (.only Operation Phase Bundle Handler)] ["[1][0]" function ["[1]" abstract]]]] - [extension - ["[1]extension" /] - ["[1][0]" bundle]] [// ["[0]" synthesis (.only Synthesis %synthesis) ["<[1]>" \\parser (.only Parser)]] [/// - ["[1]" phase] + ["[0]" phase] [meta [archive (.only Archive)]]]]]) @@ -47,14 +45,14 @@ (All (_ s) (-> [(Parser s) (-> Phase Archive s (Operation (Bytecode Any)))] - (-> Text Handler))) - (function (_ extension_name phase archive input) + Handler)) + (function (_ phase archive input) (when (.result parser input) {try.#Success input'} (handler phase archive input') {try.#Failure error} - (/////.except /////extension.invalid_syntax [extension_name synthesis.%synthesis input])))) + (phase.failure error)))) (def $Boolean (type.class "java.lang.Boolean" (list))) (def $Double (type.class "java.lang.Double" (list))) @@ -102,7 +100,7 @@ (.tuple (<>.many .i64)) .any)))) (function (_ phase archive [inputS elseS conditionalsS]) - (do [! /////.monad] + (do [! phase.monad] [@end ///runtime.forge_label inputG (phase archive inputS) elseG (phase archive elseS) @@ -154,9 +152,9 @@ (def with_basic_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "when_char#|generation" ..lux::syntax_char_case!) - (/////bundle.install "is?#|generation" (binary ..lux::is)) - (/////bundle.install "try#|generation" (unary ..lux::try)))) + (|>> (dictionary.has "when_char#|generation" ..lux::syntax_char_case!) + (dictionary.has "is?#|generation" (binary ..lux::is)) + (dictionary.has "try#|generation" (unary ..lux::try)))) (with_template [ ] [(def ( [maskG inputG]) @@ -264,38 +262,38 @@ (def with_i64_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "i64_and#|generation" (binary ..i64::and)) - (/////bundle.install "i64_or#|generation" (binary ..i64::or)) - (/////bundle.install "i64_xor#|generation" (binary ..i64::xor)) - (/////bundle.install "i64_left#|generation" (binary ..i64::left_shifted)) - (/////bundle.install "i64_right#|generation" (binary ..i64::right_shifted)) + (|>> (dictionary.has "i64_and#|generation" (binary ..i64::and)) + (dictionary.has "i64_or#|generation" (binary ..i64::or)) + (dictionary.has "i64_xor#|generation" (binary ..i64::xor)) + (dictionary.has "i64_left#|generation" (binary ..i64::left_shifted)) + (dictionary.has "i64_right#|generation" (binary ..i64::right_shifted)) - (/////bundle.install "i64_=#|generation" (binary ..i64::=)) - (/////bundle.install "i64_+#|generation" (binary ..i64::+)) - (/////bundle.install "i64_-#|generation" (binary ..i64::-)))) + (dictionary.has "i64_=#|generation" (binary ..i64::=)) + (dictionary.has "i64_+#|generation" (binary ..i64::+)) + (dictionary.has "i64_-#|generation" (binary ..i64::-)))) (def with_int_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "int_<#|generation" (binary ..i64::<)) - (/////bundle.install "int_*#|generation" (binary ..i64::*)) - (/////bundle.install "int_/#|generation" (binary ..i64::/)) - (/////bundle.install "int_%#|generation" (binary ..i64::%)) + (|>> (dictionary.has "int_<#|generation" (binary ..i64::<)) + (dictionary.has "int_*#|generation" (binary ..i64::*)) + (dictionary.has "int_/#|generation" (binary ..i64::/)) + (dictionary.has "int_%#|generation" (binary ..i64::%)) - (/////bundle.install "int_f64#|generation" (unary ..i64::f64)) - (/////bundle.install "int_char#|generation" (unary ..i64::char)))) + (dictionary.has "int_f64#|generation" (unary ..i64::f64)) + (dictionary.has "int_char#|generation" (unary ..i64::char)))) (def with_frac_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "f64_+#|generation" (binary ..f64::+)) - (/////bundle.install "f64_-#|generation" (binary ..f64::-)) - (/////bundle.install "f64_*#|generation" (binary ..f64::*)) - (/////bundle.install "f64_/#|generation" (binary ..f64::/)) - (/////bundle.install "f64_%#|generation" (binary ..f64::%)) - (/////bundle.install "f64_=#|generation" (binary ..f64::=)) - (/////bundle.install "f64_<#|generation" (binary ..f64::<)) - (/////bundle.install "f64_int#|generation" (unary ..f64::i64)) - (/////bundle.install "f64_encoded#|generation" (unary ..f64::encode)) - (/////bundle.install "f64_decoded#|generation" (unary ..f64::decode)))) + (|>> (dictionary.has "f64_+#|generation" (binary ..f64::+)) + (dictionary.has "f64_-#|generation" (binary ..f64::-)) + (dictionary.has "f64_*#|generation" (binary ..f64::*)) + (dictionary.has "f64_/#|generation" (binary ..f64::/)) + (dictionary.has "f64_%#|generation" (binary ..f64::%)) + (dictionary.has "f64_=#|generation" (binary ..f64::=)) + (dictionary.has "f64_<#|generation" (binary ..f64::<)) + (dictionary.has "f64_int#|generation" (unary ..f64::i64)) + (dictionary.has "f64_encoded#|generation" (unary ..f64::encode)) + (dictionary.has "f64_decoded#|generation" (unary ..f64::decode)))) (def (text::size inputG) (Unary (Bytecode Any)) @@ -367,13 +365,13 @@ (def with_text_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "text_=#|generation" (binary ..text::=)) - (/////bundle.install "text_<#|generation" (binary ..text::<)) - (/////bundle.install "text_composite#|generation" (binary ..text::concat)) - (/////bundle.install "text_index#|generation" (trinary ..text::index)) - (/////bundle.install "text_size#|generation" (unary ..text::size)) - (/////bundle.install "text_char#|generation" (binary ..text::char)) - (/////bundle.install "text_clip#|generation" (trinary ..text::clip)))) + (|>> (dictionary.has "text_=#|generation" (binary ..text::=)) + (dictionary.has "text_<#|generation" (binary ..text::<)) + (dictionary.has "text_composite#|generation" (binary ..text::concat)) + (dictionary.has "text_index#|generation" (trinary ..text::index)) + (dictionary.has "text_size#|generation" (unary ..text::size)) + (dictionary.has "text_char#|generation" (binary ..text::char)) + (dictionary.has "text_clip#|generation" (trinary ..text::clip)))) (def string_method (type.method [(list) (list ..$String) type.void (list)])) (def (io::log messageG) @@ -397,12 +395,12 @@ (def with_io_extensions (-> Bundle Bundle) - (|>> (/////bundle.install "log#|generation" (unary ..io::log)) - (/////bundle.install "error#|generation" (unary ..io::error)))) + (|>> (dictionary.has "log#|generation" (unary ..io::log)) + (dictionary.has "error#|generation" (unary ..io::error)))) (def .public bundle Bundle - (|> /////bundle.empty + (|> extension.empty with_basic_extensions with_io_extensions with_text_extensions diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux index b72d1754a..cbd08f066 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -59,8 +59,7 @@ [field [variable ["[0]" foreign]]]]]] - [extension - ["[1][0]" bundle] + ["[0]" extension (.only) [analysis ["/" jvm]]] ["/[1]" // @@ -136,36 +135,36 @@ (def with_conversion_extensions (-> Bundle Bundle) - (|>> (/////bundle.install (%.format "jvm_" "conversion_" "double_to_float" "#" "|generation") (unary conversion::double_to_float)) - (/////bundle.install (%.format "jvm_" "conversion_" "double_to_int" "#" "|generation") (unary conversion::double_to_int)) - (/////bundle.install (%.format "jvm_" "conversion_" "double_to_long" "#" "|generation") (unary conversion::double_to_long)) + (|>> (dictionary.has (%.format "jvm_" "conversion_" "double_to_float" "#" "|generation") (unary conversion::double_to_float)) + (dictionary.has (%.format "jvm_" "conversion_" "double_to_int" "#" "|generation") (unary conversion::double_to_int)) + (dictionary.has (%.format "jvm_" "conversion_" "double_to_long" "#" "|generation") (unary conversion::double_to_long)) - (/////bundle.install (%.format "jvm_" "conversion_" "float_to_double" "#" "|generation") (unary conversion::float_to_double)) - (/////bundle.install (%.format "jvm_" "conversion_" "float_to_int" "#" "|generation") (unary conversion::float_to_int)) - (/////bundle.install (%.format "jvm_" "conversion_" "float_to_long" "#" "|generation") (unary conversion::float_to_long)) + (dictionary.has (%.format "jvm_" "conversion_" "float_to_double" "#" "|generation") (unary conversion::float_to_double)) + (dictionary.has (%.format "jvm_" "conversion_" "float_to_int" "#" "|generation") (unary conversion::float_to_int)) + (dictionary.has (%.format "jvm_" "conversion_" "float_to_long" "#" "|generation") (unary conversion::float_to_long)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_byte" "#" "|generation") (unary conversion::int_to_byte)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_char" "#" "|generation") (unary conversion::int_to_char)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_double" "#" "|generation") (unary conversion::int_to_double)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_float" "#" "|generation") (unary conversion::int_to_float)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_long" "#" "|generation") (unary conversion::int_to_long)) - (/////bundle.install (%.format "jvm_" "conversion_" "int_to_short" "#" "|generation") (unary conversion::int_to_short)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_byte" "#" "|generation") (unary conversion::int_to_byte)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_char" "#" "|generation") (unary conversion::int_to_char)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_double" "#" "|generation") (unary conversion::int_to_double)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_float" "#" "|generation") (unary conversion::int_to_float)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_long" "#" "|generation") (unary conversion::int_to_long)) + (dictionary.has (%.format "jvm_" "conversion_" "int_to_short" "#" "|generation") (unary conversion::int_to_short)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_double" "#" "|generation") (unary conversion::long_to_double)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_float" "#" "|generation") (unary conversion::long_to_float)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_int" "#" "|generation") (unary conversion::long_to_int)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_short" "#" "|generation") (unary conversion::long_to_short)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_byte" "#" "|generation") (unary conversion::long_to_byte)) - (/////bundle.install (%.format "jvm_" "conversion_" "long_to_char" "#" "|generation") (unary conversion::long_to_char)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_double" "#" "|generation") (unary conversion::long_to_double)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_float" "#" "|generation") (unary conversion::long_to_float)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_int" "#" "|generation") (unary conversion::long_to_int)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_short" "#" "|generation") (unary conversion::long_to_short)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_byte" "#" "|generation") (unary conversion::long_to_byte)) + (dictionary.has (%.format "jvm_" "conversion_" "long_to_char" "#" "|generation") (unary conversion::long_to_char)) - (/////bundle.install (%.format "jvm_" "conversion_" "char_to_byte" "#" "|generation") (unary conversion::char_to_byte)) - (/////bundle.install (%.format "jvm_" "conversion_" "char_to_short" "#" "|generation") (unary conversion::char_to_short)) - (/////bundle.install (%.format "jvm_" "conversion_" "char_to_int" "#" "|generation") (unary conversion::char_to_int)) - (/////bundle.install (%.format "jvm_" "conversion_" "char_to_long" "#" "|generation") (unary conversion::char_to_long)) + (dictionary.has (%.format "jvm_" "conversion_" "char_to_byte" "#" "|generation") (unary conversion::char_to_byte)) + (dictionary.has (%.format "jvm_" "conversion_" "char_to_short" "#" "|generation") (unary conversion::char_to_short)) + (dictionary.has (%.format "jvm_" "conversion_" "char_to_int" "#" "|generation") (unary conversion::char_to_int)) + (dictionary.has (%.format "jvm_" "conversion_" "char_to_long" "#" "|generation") (unary conversion::char_to_long)) - (/////bundle.install (%.format "jvm_" "conversion_" "byte_to_long" "#" "|generation") (unary conversion::byte_to_long)) + (dictionary.has (%.format "jvm_" "conversion_" "byte_to_long" "#" "|generation") (unary conversion::byte_to_long)) - (/////bundle.install (%.format "jvm_" "conversion_" "short_to_long" "#" "|generation") (unary conversion::short_to_long)) + (dictionary.has (%.format "jvm_" "conversion_" "short_to_long" "#" "|generation") (unary conversion::short_to_long)) )) (with_template [ ] @@ -271,68 +270,68 @@ (def with_int_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.int)] - (|>> (/////bundle.install (%.format "jvm_" type "_" "+" "#" "|generation") (binary int::+)) - (/////bundle.install (%.format "jvm_" type "_" "-" "#" "|generation") (binary int::-)) - (/////bundle.install (%.format "jvm_" type "_" "*" "#" "|generation") (binary int::*)) - (/////bundle.install (%.format "jvm_" type "_" "/" "#" "|generation") (binary int::/)) - (/////bundle.install (%.format "jvm_" type "_" "%" "#" "|generation") (binary int::%)) - (/////bundle.install (%.format "jvm_" type "_" "=" "#" "|generation") (binary int::=)) - (/////bundle.install (%.format "jvm_" type "_" "<" "#" "|generation") (binary int::<)) - (/////bundle.install (%.format "jvm_" type "_" "and" "#" "|generation") (binary int::and)) - (/////bundle.install (%.format "jvm_" type "_" "or" "#" "|generation") (binary int::or)) - (/////bundle.install (%.format "jvm_" type "_" "xor" "#" "|generation") (binary int::xor)) - (/////bundle.install (%.format "jvm_" type "_" "shl" "#" "|generation") (binary int::shl)) - (/////bundle.install (%.format "jvm_" type "_" "shr" "#" "|generation") (binary int::shr)) - (/////bundle.install (%.format "jvm_" type "_" "ushr" "#" "|generation") (binary int::ushr)) + (|>> (dictionary.has (%.format "jvm_" type "_" "+" "#" "|generation") (binary int::+)) + (dictionary.has (%.format "jvm_" type "_" "-" "#" "|generation") (binary int::-)) + (dictionary.has (%.format "jvm_" type "_" "*" "#" "|generation") (binary int::*)) + (dictionary.has (%.format "jvm_" type "_" "/" "#" "|generation") (binary int::/)) + (dictionary.has (%.format "jvm_" type "_" "%" "#" "|generation") (binary int::%)) + (dictionary.has (%.format "jvm_" type "_" "=" "#" "|generation") (binary int::=)) + (dictionary.has (%.format "jvm_" type "_" "<" "#" "|generation") (binary int::<)) + (dictionary.has (%.format "jvm_" type "_" "and" "#" "|generation") (binary int::and)) + (dictionary.has (%.format "jvm_" type "_" "or" "#" "|generation") (binary int::or)) + (dictionary.has (%.format "jvm_" type "_" "xor" "#" "|generation") (binary int::xor)) + (dictionary.has (%.format "jvm_" type "_" "shl" "#" "|generation") (binary int::shl)) + (dictionary.has (%.format "jvm_" type "_" "shr" "#" "|generation") (binary int::shr)) + (dictionary.has (%.format "jvm_" type "_" "ushr" "#" "|generation") (binary int::ushr)) ))) (def with_long_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.long)] - (|>> (/////bundle.install (%.format "jvm_" type "_" "+" "#" "|generation") (binary long::+)) - (/////bundle.install (%.format "jvm_" type "_" "-" "#" "|generation") (binary long::-)) - (/////bundle.install (%.format "jvm_" type "_" "*" "#" "|generation") (binary long::*)) - (/////bundle.install (%.format "jvm_" type "_" "/" "#" "|generation") (binary long::/)) - (/////bundle.install (%.format "jvm_" type "_" "%" "#" "|generation") (binary long::%)) - (/////bundle.install (%.format "jvm_" type "_" "=" "#" "|generation") (binary long::=)) - (/////bundle.install (%.format "jvm_" type "_" "<" "#" "|generation") (binary long::<)) - (/////bundle.install (%.format "jvm_" type "_" "and" "#" "|generation") (binary long::and)) - (/////bundle.install (%.format "jvm_" type "_" "or" "#" "|generation") (binary long::or)) - (/////bundle.install (%.format "jvm_" type "_" "xor" "#" "|generation") (binary long::xor)) - (/////bundle.install (%.format "jvm_" type "_" "shl" "#" "|generation") (binary long::shl)) - (/////bundle.install (%.format "jvm_" type "_" "shr" "#" "|generation") (binary long::shr)) - (/////bundle.install (%.format "jvm_" type "_" "ushr" "#" "|generation") (binary long::ushr)) + (|>> (dictionary.has (%.format "jvm_" type "_" "+" "#" "|generation") (binary long::+)) + (dictionary.has (%.format "jvm_" type "_" "-" "#" "|generation") (binary long::-)) + (dictionary.has (%.format "jvm_" type "_" "*" "#" "|generation") (binary long::*)) + (dictionary.has (%.format "jvm_" type "_" "/" "#" "|generation") (binary long::/)) + (dictionary.has (%.format "jvm_" type "_" "%" "#" "|generation") (binary long::%)) + (dictionary.has (%.format "jvm_" type "_" "=" "#" "|generation") (binary long::=)) + (dictionary.has (%.format "jvm_" type "_" "<" "#" "|generation") (binary long::<)) + (dictionary.has (%.format "jvm_" type "_" "and" "#" "|generation") (binary long::and)) + (dictionary.has (%.format "jvm_" type "_" "or" "#" "|generation") (binary long::or)) + (dictionary.has (%.format "jvm_" type "_" "xor" "#" "|generation") (binary long::xor)) + (dictionary.has (%.format "jvm_" type "_" "shl" "#" "|generation") (binary long::shl)) + (dictionary.has (%.format "jvm_" type "_" "shr" "#" "|generation") (binary long::shr)) + (dictionary.has (%.format "jvm_" type "_" "ushr" "#" "|generation") (binary long::ushr)) ))) (def with_float_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.float)] - (|>> (/////bundle.install (%.format "jvm_" type "_" "+" "#" "|generation") (binary float::+)) - (/////bundle.install (%.format "jvm_" type "_" "-" "#" "|generation") (binary float::-)) - (/////bundle.install (%.format "jvm_" type "_" "*" "#" "|generation") (binary float::*)) - (/////bundle.install (%.format "jvm_" type "_" "/" "#" "|generation") (binary float::/)) - (/////bundle.install (%.format "jvm_" type "_" "%" "#" "|generation") (binary float::%)) - (/////bundle.install (%.format "jvm_" type "_" "=" "#" "|generation") (binary float::=)) - (/////bundle.install (%.format "jvm_" type "_" "<" "#" "|generation") (binary float::<)) + (|>> (dictionary.has (%.format "jvm_" type "_" "+" "#" "|generation") (binary float::+)) + (dictionary.has (%.format "jvm_" type "_" "-" "#" "|generation") (binary float::-)) + (dictionary.has (%.format "jvm_" type "_" "*" "#" "|generation") (binary float::*)) + (dictionary.has (%.format "jvm_" type "_" "/" "#" "|generation") (binary float::/)) + (dictionary.has (%.format "jvm_" type "_" "%" "#" "|generation") (binary float::%)) + (dictionary.has (%.format "jvm_" type "_" "=" "#" "|generation") (binary float::=)) + (dictionary.has (%.format "jvm_" type "_" "<" "#" "|generation") (binary float::<)) ))) (def with_double_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.float)] - (|>> (/////bundle.install (%.format "jvm_" type "_" "+" "#" "|generation") (binary double::+)) - (/////bundle.install (%.format "jvm_" type "_" "-" "#" "|generation") (binary double::-)) - (/////bundle.install (%.format "jvm_" type "_" "*" "#" "|generation") (binary double::*)) - (/////bundle.install (%.format "jvm_" type "_" "/" "#" "|generation") (binary double::/)) - (/////bundle.install (%.format "jvm_" type "_" "%" "#" "|generation") (binary double::%)) - (/////bundle.install (%.format "jvm_" type "_" "=" "#" "|generation") (binary double::=)) - (/////bundle.install (%.format "jvm_" type "_" "<" "#" "|generation") (binary double::<)) + (|>> (dictionary.has (%.format "jvm_" type "_" "+" "#" "|generation") (binary double::+)) + (dictionary.has (%.format "jvm_" type "_" "-" "#" "|generation") (binary double::-)) + (dictionary.has (%.format "jvm_" type "_" "*" "#" "|generation") (binary double::*)) + (dictionary.has (%.format "jvm_" type "_" "/" "#" "|generation") (binary double::/)) + (dictionary.has (%.format "jvm_" type "_" "%" "#" "|generation") (binary double::%)) + (dictionary.has (%.format "jvm_" type "_" "=" "#" "|generation") (binary double::=)) + (dictionary.has (%.format "jvm_" type "_" "<" "#" "|generation") (binary double::<)) ))) (def with_char_extensions (-> Bundle Bundle) (let [type (reflection.reflection reflection.char)] - (|>> (/////bundle.install (%.format "jvm_" type "_" "=" "#" "|generation") (binary char::=)) - (/////bundle.install (%.format "jvm_" type "_" "<" "#" "|generation") (binary char::<)) + (|>> (dictionary.has (%.format "jvm_" type "_" "=" "#" "|generation") (binary char::=)) + (dictionary.has (%.format "jvm_" type "_" "<" "#" "|generation") (binary char::<)) ))) (with_template [ ] @@ -379,7 +378,7 @@ (undefined)))) (def (primitive_array_length_handler jvm_primitive) - (-> (Type Primitive) (-> Text Handler)) + (-> (Type Primitive) Handler) (..custom [.any (function (_ generate archive arrayS) @@ -391,7 +390,7 @@ _.arraylength))))])) (def array::length::object - (-> Text Handler) + Handler (..custom [(all <>.and ..object_array .any) (function (_ generate archive [elementJT arrayS]) @@ -403,7 +402,7 @@ _.arraylength))))])) (def (new_primitive_array_handler jvm_primitive) - (-> Primitive_Array_Type (-> Text Handler)) + (-> Primitive_Array_Type Handler) (..custom [.any (function (_ generate archive [lengthS]) @@ -414,7 +413,7 @@ (_.newarray jvm_primitive)))))])) (def array::new::object - (-> Text Handler) + Handler (..custom [(all <>.and ..object .any) (function (_ generate archive [objectJT lengthS]) @@ -425,7 +424,7 @@ (_.anewarray objectJT)))))])) (def (read_primitive_array_handler jvm_primitive loadG) - (-> (Type Primitive) (Bytecode Any) (-> Text Handler)) + (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and .any .any) (function (_ generate archive [idxS arrayS]) @@ -439,7 +438,7 @@ loadG))))])) (def array::read::object - (-> Text Handler) + Handler (..custom [(all <>.and ..object_array .any .any) (function (_ generate archive [elementJT idxS arrayS]) @@ -453,7 +452,7 @@ _.aaload))))])) (def (write_primitive_array_handler jvm_primitive storeG) - (-> (Type Primitive) (Bytecode Any) (-> Text Handler)) + (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and .any .any .any) (function (_ generate archive [idxS valueS arrayS]) @@ -470,7 +469,7 @@ storeG))))])) (def array::write::object - (-> Text Handler) + Handler (..custom [(all <>.and ..object_array .any .any .any) (function (_ generate archive [elementJT idxS valueS arrayS]) @@ -488,45 +487,45 @@ (def with_array_extensions (-> Bundle Bundle) - (|>> (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#" "|generation") (primitive_array_length_handler type.boolean)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#" "|generation") (primitive_array_length_handler type.byte)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#" "|generation") (primitive_array_length_handler type.short)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#" "|generation") (primitive_array_length_handler type.int)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#" "|generation") (primitive_array_length_handler type.long)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#" "|generation") (primitive_array_length_handler type.float)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#" "|generation") (primitive_array_length_handler type.double)) - (/////bundle.install (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#" "|generation") (primitive_array_length_handler type.char)) - (/////bundle.install (%.format "jvm_" "array_" "length_" "object" "#" "|generation") array::length::object) - - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#" "|generation") (new_primitive_array_handler __.t_boolean)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#" "|generation") (new_primitive_array_handler __.t_byte)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#" "|generation") (new_primitive_array_handler __.t_short)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#" "|generation") (new_primitive_array_handler __.t_int)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#" "|generation") (new_primitive_array_handler __.t_long)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#" "|generation") (new_primitive_array_handler __.t_float)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#" "|generation") (new_primitive_array_handler __.t_double)) - (/////bundle.install (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#" "|generation") (new_primitive_array_handler __.t_char)) - (/////bundle.install (%.format "jvm_" "array_" "new_" "object" "#" "|generation") array::new::object) - - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#" "|generation") (read_primitive_array_handler type.boolean _.baload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#" "|generation") (read_primitive_array_handler type.byte _.baload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#" "|generation") (read_primitive_array_handler type.short _.saload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#" "|generation") (read_primitive_array_handler type.int _.iaload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#" "|generation") (read_primitive_array_handler type.long _.laload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#" "|generation") (read_primitive_array_handler type.float _.faload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#" "|generation") (read_primitive_array_handler type.double _.daload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#" "|generation") (read_primitive_array_handler type.char _.caload)) - (/////bundle.install (%.format "jvm_" "array_" "read_" "object" "#" "|generation") array::read::object) - - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#" "|generation") (write_primitive_array_handler type.boolean _.bastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#" "|generation") (write_primitive_array_handler type.byte _.bastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#" "|generation") (write_primitive_array_handler type.short _.sastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#" "|generation") (write_primitive_array_handler type.int _.iastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#" "|generation") (write_primitive_array_handler type.long _.lastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#" "|generation") (write_primitive_array_handler type.float _.fastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#" "|generation") (write_primitive_array_handler type.double _.dastore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#" "|generation") (write_primitive_array_handler type.char _.castore)) - (/////bundle.install (%.format "jvm_" "array_" "write_" "object" "#" "|generation") array::write::object) + (|>> (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.boolean) "#" "|generation") (primitive_array_length_handler type.boolean)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.byte) "#" "|generation") (primitive_array_length_handler type.byte)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.short) "#" "|generation") (primitive_array_length_handler type.short)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.int) "#" "|generation") (primitive_array_length_handler type.int)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.long) "#" "|generation") (primitive_array_length_handler type.long)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.float) "#" "|generation") (primitive_array_length_handler type.float)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.double) "#" "|generation") (primitive_array_length_handler type.double)) + (dictionary.has (%.format "jvm_" "array_" "length_" (reflection.reflection reflection.char) "#" "|generation") (primitive_array_length_handler type.char)) + (dictionary.has (%.format "jvm_" "array_" "length_" "object" "#" "|generation") array::length::object) + + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.boolean) "#" "|generation") (new_primitive_array_handler __.t_boolean)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.byte) "#" "|generation") (new_primitive_array_handler __.t_byte)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.short) "#" "|generation") (new_primitive_array_handler __.t_short)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.int) "#" "|generation") (new_primitive_array_handler __.t_int)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.long) "#" "|generation") (new_primitive_array_handler __.t_long)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.float) "#" "|generation") (new_primitive_array_handler __.t_float)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.double) "#" "|generation") (new_primitive_array_handler __.t_double)) + (dictionary.has (%.format "jvm_" "array_" "new_" (reflection.reflection reflection.char) "#" "|generation") (new_primitive_array_handler __.t_char)) + (dictionary.has (%.format "jvm_" "array_" "new_" "object" "#" "|generation") array::new::object) + + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.boolean) "#" "|generation") (read_primitive_array_handler type.boolean _.baload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.byte) "#" "|generation") (read_primitive_array_handler type.byte _.baload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.short) "#" "|generation") (read_primitive_array_handler type.short _.saload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.int) "#" "|generation") (read_primitive_array_handler type.int _.iaload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.long) "#" "|generation") (read_primitive_array_handler type.long _.laload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.float) "#" "|generation") (read_primitive_array_handler type.float _.faload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.double) "#" "|generation") (read_primitive_array_handler type.double _.daload)) + (dictionary.has (%.format "jvm_" "array_" "read_" (reflection.reflection reflection.char) "#" "|generation") (read_primitive_array_handler type.char _.caload)) + (dictionary.has (%.format "jvm_" "array_" "read_" "object" "#" "|generation") array::read::object) + + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.boolean) "#" "|generation") (write_primitive_array_handler type.boolean _.bastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.byte) "#" "|generation") (write_primitive_array_handler type.byte _.bastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.short) "#" "|generation") (write_primitive_array_handler type.short _.sastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.int) "#" "|generation") (write_primitive_array_handler type.int _.iastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.long) "#" "|generation") (write_primitive_array_handler type.long _.lastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.float) "#" "|generation") (write_primitive_array_handler type.float _.fastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.double) "#" "|generation") (write_primitive_array_handler type.double _.dastore)) + (dictionary.has (%.format "jvm_" "array_" "write_" (reflection.reflection reflection.char) "#" "|generation") (write_primitive_array_handler type.char _.castore)) + (dictionary.has (%.format "jvm_" "array_" "write_" "object" "#" "|generation") array::write::object) )) (def (object::null _) @@ -572,7 +571,7 @@ (def $String (type.class "java.lang.String" (list))) (def object::class - (-> Text Handler) + Handler (..custom [.text (function (_ generate archive [class]) @@ -583,7 +582,7 @@ (_.invokestatic ..$Class "forName" (type.method [(list) (list ..$String) ..$Class (list)]))))))])) (def object::instance? - (-> Text Handler) + Handler (..custom [(all <>.and .text .any) (function (_ generate archive [class objectS]) @@ -595,7 +594,7 @@ (///value.wrap type.boolean)))))])) (def object::cast - (-> Text Handler) + Handler (..custom [(all <>.and .text .text .any) (function (_ generate archive [from to valueS]) @@ -627,24 +626,24 @@ (def with_object_extensions (-> Bundle Bundle) - (|>> (/////bundle.install (%.format "jvm_" "object_" "null" "#" "|generation") (nullary object::null)) - (/////bundle.install (%.format "jvm_" "object_" "null?" "#" "|generation") (unary object::null?)) - (/////bundle.install (%.format "jvm_" "object_" "synchronized" "#" "|generation") (binary object::synchronized)) - (/////bundle.install (%.format "jvm_" "object_" "throw" "#" "|generation") (unary object::throw)) - (/////bundle.install (%.format "jvm_" "object_" "class" "#" "|generation") object::class) - (/////bundle.install (%.format "jvm_" "object_" "instance?" "#" "|generation") object::instance?) - (/////bundle.install (%.format "jvm_" "object_" "cast" "#" "|generation") object::cast) + (|>> (dictionary.has (%.format "jvm_" "object_" "null" "#" "|generation") (nullary object::null)) + (dictionary.has (%.format "jvm_" "object_" "null?" "#" "|generation") (unary object::null?)) + (dictionary.has (%.format "jvm_" "object_" "synchronized" "#" "|generation") (binary object::synchronized)) + (dictionary.has (%.format "jvm_" "object_" "throw" "#" "|generation") (unary object::throw)) + (dictionary.has (%.format "jvm_" "object_" "class" "#" "|generation") object::class) + (dictionary.has (%.format "jvm_" "object_" "instance?" "#" "|generation") object::instance?) + (dictionary.has (%.format "jvm_" "object_" "cast" "#" "|generation") object::cast) )) (def get::static - (-> Text Handler) + Handler (..custom [(all <>.and .text .text ..value) (function (_ generate archive [class field :unboxed:]) (at //////.monad in (_.getstatic (type.class class (list)) field :unboxed:)))])) (def put::static - (-> Text Handler) + Handler (..custom [(all <>.and .text .text ..value .any) (function (_ generate archive [class field :unboxed: valueS]) @@ -662,7 +661,7 @@ ..unitG))))])) (def get::virtual - (-> Text Handler) + Handler (..custom [(all <>.and .text .text ..value .any) (function (_ generate archive [class field :unboxed: objectS]) @@ -676,7 +675,7 @@ getG))))])) (def put::virtual - (-> Text Handler) + Handler (..custom [(all <>.and .text .text ..value .any .any) (function (_ generate archive [class field :unboxed: valueS objectS]) @@ -729,7 +728,7 @@ (_#in []))) (def invoke::static - (-> Text Handler) + Handler (..custom [(all <>.and ..class .text ..return (<>.some ..input)) (function (_ generate archive [class method outputT inputsTS]) @@ -742,7 +741,7 @@ (with_template [ ] [(def - (-> Text Handler) + Handler (..custom [(all <>.and ..class .text ..return .any (<>.some ..input)) (function (_ generate archive [class method outputT objectS inputsTS]) @@ -764,7 +763,7 @@ ) (def invoke::constructor - (-> Text Handler) + Handler (..custom [(all <>.and ..class (<>.some ..input)) (function (_ generate archive [class inputsTS]) @@ -778,17 +777,17 @@ (def with_member_extensions (-> Bundle Bundle) - (|>> (/////bundle.install (%.format "jvm_" "member_" "get_" "static" "#" "|generation") get::static) - (/////bundle.install (%.format "jvm_" "member_" "get_" "virtual" "#" "|generation") get::virtual) + (|>> (dictionary.has (%.format "jvm_" "member_" "get_" "static" "#" "|generation") get::static) + (dictionary.has (%.format "jvm_" "member_" "get_" "virtual" "#" "|generation") get::virtual) - (/////bundle.install (%.format "jvm_" "member_" "put_" "static" "#" "|generation") put::static) - (/////bundle.install (%.format "jvm_" "member_" "put_" "virtual" "#" "|generation") put::virtual) + (dictionary.has (%.format "jvm_" "member_" "put_" "static" "#" "|generation") put::static) + (dictionary.has (%.format "jvm_" "member_" "put_" "virtual" "#" "|generation") put::virtual) - (/////bundle.install (%.format "jvm_" "member_" "invoke_" "static" "#" "|generation") invoke::static) - (/////bundle.install (%.format "jvm_" "member_" "invoke_" "virtual" "#" "|generation") invoke::virtual) - (/////bundle.install (%.format "jvm_" "member_" "invoke_" "special" "#" "|generation") invoke::special) - (/////bundle.install (%.format "jvm_" "member_" "invoke_" "interface" "#" "|generation") invoke::interface) - (/////bundle.install (%.format "jvm_" "member_" "invoke_" "constructor" "#" "|generation") invoke::constructor) + (dictionary.has (%.format "jvm_" "member_" "invoke_" "static" "#" "|generation") invoke::static) + (dictionary.has (%.format "jvm_" "member_" "invoke_" "virtual" "#" "|generation") invoke::virtual) + (dictionary.has (%.format "jvm_" "member_" "invoke_" "special" "#" "|generation") invoke::special) + (dictionary.has (%.format "jvm_" "member_" "invoke_" "interface" "#" "|generation") invoke::interface) + (dictionary.has (%.format "jvm_" "member_" "invoke_" "constructor" "#" "|generation") invoke::constructor) )) (def annotation_parameter @@ -1309,7 +1308,7 @@ (returnG returnT))}))))) (def class::anonymous - (-> Text Handler) + Handler (..custom [(all <>.and ..class @@ -1350,7 +1349,7 @@ (def with_class_extensions (-> Bundle Bundle) - (/////bundle.install (%.format "jvm_" "class_" "anonymous" "#" "|generation") class::anonymous)) + (dictionary.has (%.format "jvm_" "class_" "anonymous" "#" "|generation") class::anonymous)) (def .public bundle Bundle @@ -1364,4 +1363,4 @@ with_object_extensions with_member_extensions with_class_extensions - /////bundle.empty)) + extension.empty)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux index b71adedaa..4038262df 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -44,19 +44,6 @@ [/// ["[1]" phase (.use "[1]#[0]" monad)]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - (def !unary (template (_ function) [(|>> list _.apply (|> (_.var function)))])) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/common.lux index 00c99a594..0fb91a5d3 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/php/common.lux @@ -39,19 +39,6 @@ [/// ["[1]" phase]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - (def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux index f68373416..c03a52bc2 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux @@ -89,19 +89,6 @@ (/////#each _.return (//function.function statement expression archive abstraction)) )) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - ... TODO: Get rid of this ASAP (def lux::syntax_char_case! (..custom [(all <>.and diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/r/common.lux index faab4946a..0705afd3c 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/r/common.lux @@ -39,19 +39,6 @@ [/// ["[1]" phase]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - ... (def !unary ... (template (_ function) ... (|>> list _.apply (|> (_.constant function))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux index be7b33267..6d2087640 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -44,19 +44,6 @@ [/// ["[1]" phase (.use "[1]#[0]" monad)]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - (def .public (statement expression archive synthesis) Phase! (when synthesis diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/scheme/common.lux index 9eec19a4a..894906ea0 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -39,19 +39,6 @@ [/// ["[1]" phase]]]]]) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Text (Generator s))] - Handler)) - (function (_ extension_name phase archive input) - (when (.result parser input) - {try.#Success input'} - (handler extension_name phase archive input') - - {try.#Failure error} - (/////.except extension.invalid_syntax [extension_name %synthesis input])))) - (def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/extension.lux index fde10a521..9c8dbf379 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/extension.lux @@ -3,7 +3,11 @@ [lux (.except Synthesis) [abstract ["[0]" monad (.only do)]] + [control + ["[0]" exception (.only Exception)]] [data + [text + ["%" \\format]] [collection ["[0]" list (.use "[1]#[0]" functor)]]] ["[0]" meta (.only) @@ -29,16 +33,22 @@ [(All (_ of) (-> (Vector arity of) of))])) +(exception.def .public (incorrect_arity [expected actual]) + (Exception [Nat Nat]) + (exception.report + (list ["Expected" (%.nat expected)] + ["Actual" (%.nat actual)]))) + (def arity (syntax (_ [arity .nat]) - (with_symbols [g!_ g!name g!extension g!phase g!archive g!inputs g!anchor g!expression g!declaration] + (with_symbols [g!_ g!extension g!phase g!archive g!inputs g!anchor g!expression g!declaration] (do [! meta.monad] [g!input+ (monad.all ! (list.repeated arity (macro.symbol "input")))] (in (list (` (is (All ((, g!_) (, g!anchor) (, g!expression) (, g!declaration)) (-> ((Arity (, (code.nat arity))) (, g!expression)) - (-> Text (generation.Handler (, g!anchor) (, g!expression) (, g!declaration))))) + (generation.Handler (, g!anchor) (, g!expression) (, g!declaration)))) (function ((, g!_) (, g!extension)) - (function ((, g!_) (, g!name) (, g!phase) (, g!archive) (, g!inputs)) + (function ((, g!_) (, g!phase) (, g!archive) (, g!inputs)) (when (, g!inputs) (list (,* g!input+)) (do ///.monad @@ -49,9 +59,7 @@ ((,' in) ((, g!extension) [(,* g!input+)]))) (, g!_) - (///.except ///extension.incorrect_arity ["" - (, (code.nat arity)) - (list.size (, g!inputs))])) + (///.except ..incorrect_arity [(, (code.nat arity)) (list.size (, g!inputs))])) )))))))))) (with_template [ ] @@ -69,8 +77,8 @@ (def .public (variadic extension) (All (_ anchor expression declaration) - (-> (Variadic expression) (-> Text (generation.Handler anchor expression declaration)))) - (function (_ extension_name phase archive inputsS) + (-> (Variadic expression) (generation.Handler anchor expression declaration))) + (function (_ phase archive inputsS) (let [! ///.monad] (|> inputsS (monad.each ! (phase archive)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux index d25fe3fcf..d8c4eb180 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux @@ -39,49 +39,6 @@ ["[0]" reference] ["[1]" phase (.use "[1]#[0]" monad)]]]]]) -(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)]))) - -(exception.def .public (extension_error error) - (Exception Text) - error) - -(def (extension_application extender lux - phase archive - name parameters) - (-> extension.Extender Lux - Phase Archive - Symbol (List Synthesis) - (Operation (Bytecode Any))) - (when (|> (do [! meta.monad] - [definition (meta.try (meta.export name))] - (when definition - {try.#Success [exported? type definition]} - (in [type {.#Left definition}]) - - {try.#Failure error} - (do ! - [[exported? type default] (meta.default name)] - (in [type {.#Right default}])))) - (is (Meta [Type (Either Any Any)])) - (meta.result lux)) - {try.#Success [type value]} - (if (check.subsumes? .Generation type) - (when value - {.#Left definition} - ((extender definition) phase archive parameters) - - {.#Right default} - ((as Handler default) phase archive parameters)) - (///.except ..not_an_extension [name .Generation type])) - - {try.#Failure error} - (///.except ..extension_error [error]))) - (def .public (generate extender lux) (-> extension.Extender Lux Phase) (function (phase archive synthesis) @@ -136,5 +93,7 @@ (/function.apply phase archive application) {synthesis.#Extension [name parameters]} - (extension_application extender lux phase archive name parameters) + (extension.application extender lux phase archive .Generation name parameters + (|>>) + (function (_ _) {.#None})) ))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux index 3f6d6cb65..9e632c9a1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux @@ -4,9 +4,7 @@ [abstract ["[0]" monad (.only do)]] [control - ["[0]" pipe] - ["[0]" try] - ["[0]" exception (.only Exception)]] + ["[0]" pipe]] [data [text ["%" \\format]] @@ -22,18 +20,20 @@ ["[1][0]" function] ["[1][0]" when] ["[1][0]" variable] - ["//[1]" /// - ["/" synthesis (.only Synthesis Operation Phase Extender Handler) - ["[1][0]" simple]] - ["[1][0]" analysis (.only Analysis) - ["[2][0]" simple] - ["[2][0]" complex]] - [/// - ["[0]" phase (.use "[1]#[0]" monad)] - [reference (.only) - [variable (.only)]] - [meta - [archive (.only Archive)]]]]]) + ["/[1]" // + ["[0]" extension] + ["/[1]" // + ["/" synthesis (.only Synthesis Operation Phase Extender Handler) + ["[1][0]" simple]] + ["[1][0]" analysis (.only Analysis) + ["[2][0]" simple] + ["[2][0]" complex]] + [/// + ["[0]" phase (.use "[1]#[0]" monad)] + [reference (.only) + [variable (.only)]] + [meta + [archive (.only Archive)]]]]]]) (def (simple analysis) (-> ///simple.Simple /simple.Simple) @@ -55,50 +55,6 @@ [///simple.#Int /simple.#I64] [///simple.#Rev /simple.#I64]))) -(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)]))) - -(def (extension_application extender lux - phase archive - name parameters) - (-> Extender Lux - Phase Archive - Symbol (List Analysis) - (Operation Synthesis)) - (when (|> (do [! meta.monad] - [definition (meta.try (meta.export name))] - (when definition - {try.#Success [exported? type definition]} - (in [type {.#Left definition}]) - - {try.#Failure error} - (do ! - [[exported? type default] (meta.default name)] - (in [type {.#Right default}])))) - (is (Meta [Type (Either Any Any)])) - (meta.result lux)) - {try.#Success [type value]} - (if (check.subsumes? .Synthesis type) - (when value - {.#Left definition} - ((extender definition) phase archive parameters) - - {.#Right default} - ((as Handler default) phase archive parameters)) - ... (phase.except ..not_an_extension [name .Synthesis type]) - (|> parameters - (monad.each phase.monad (phase archive)) - (phase#each (|>> [name] {/.#Extension})))) - - {try.#Failure error} - (|> parameters - (monad.each phase.monad (phase archive)) - (phase#each (|>> [name] {/.#Extension}))))) - (def (optimization extender lux) (-> Extender Lux Phase) (function (phase archive analysis) @@ -138,9 +94,12 @@ (/function.abstraction phase environmentA archive bodyA) {///analysis.#Extension name parameters} - (extension_application extender lux - phase archive - name parameters) + (extension.application extender lux phase archive .Synthesis name parameters + (|>>) + (function (_ _) + {.#Some (|> parameters + (monad.each phase.monad (phase archive)) + (phase#each (|>> [name] {/.#Extension})))})) ))) (def .public (phase extender lux archive analysis) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux index 80182d03d..ac6c959bc 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux @@ -23,7 +23,6 @@ ["i" int] ["f" frac]]] [meta - ["[0]" symbol] [macro ["^" pattern]]]]] ["[0]" / @@ -130,7 +129,7 @@ {#Structure (Complex Synthesis)} {#Reference Reference} {#Control (Control Synthesis)} - {#Extension [Symbol (List Synthesis)]}))) + {#Extension (Extension Synthesis)}))) (type .public Operation (phase.Operation State)) @@ -700,9 +699,7 @@ [#Structure (analysis/complex.equivalence =)] [#Reference reference.equivalence] [#Control (control_equivalence =)] - [#Extension (product.equivalence symbol.equivalence (list.equivalence =)) - ... (extension.equivalence =) - ]) + [#Extension (extension.equivalence =)]) _ false)))) @@ -722,13 +719,11 @@ (^.with_template [ ] [{ value} (n.* (at hash value))]) - ([2 #Simple /simple.hash] - [3 #Structure (analysis/complex.hash again_hash)] - [5 #Reference reference.hash] - [7 #Control (..control_hash again_hash)] - [11 #Extension (product.hash symbol.hash (list.hash again_hash)) - ... (extension.hash again_hash) - ])))))) + ([02 #Simple /simple.hash] + [03 #Structure (analysis/complex.hash again_hash)] + [05 #Reference reference.hash] + [07 #Control (..control_hash again_hash)] + [11 #Extension (extension.hash again_hash)])))))) (def .public !bind_top (template (!bind_top register thenP) diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive.lux b/stdlib/source/library/lux/meta/compiler/meta/archive.lux index 46ede92f0..fd16fb8f3 100644 --- a/stdlib/source/library/lux/meta/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/meta/compiler/meta/archive.lux @@ -133,6 +133,20 @@ {.#None} (exception.except ..module_must_be_reserved_before_it_can_be_added [module])))) + ... TODO: Eliminate the need for this hack... + (def .public (has! module entry archive) + (-> descriptor.Module (Entry Any) Archive (Try Archive)) + (let [(open "/[0]") (representation archive)] + (when (dictionary.value module /#resolver) + {.#Some [id _]} + {try.#Success (|> archive + representation + (revised ..#resolver (dictionary.has module [id {.#Some entry}])) + abstraction)} + + {.#None} + (exception.except ..module_must_be_reserved_before_it_can_be_added [module])))) + (def .public entries (-> Archive (List [descriptor.Module [module.ID (Entry Any)]])) (|>> representation diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index 15044efec..3c95a1c03 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -10,7 +10,8 @@ [/ [version (.only Version)]] [// (.only Address) - [uri (.only URI)] + [uri (.only URI) + [scheme (.only Scheme)]] [// ["[0]" environment ["[1]" \\parser (.only Environment)]]]]) @@ -41,13 +42,8 @@ (-> Headers Headers)) (type .public (Body !) - (-> (Maybe Nat) (! (Try [Nat Binary])))) - -... https://en.wikipedia.org/wiki/List_of_URI_schemes -(type .public Scheme - (Variant - {#HTTP} - {#HTTPS})) + (-> (Maybe Nat) + (! (Try [Nat Binary])))) (type .public Identification (Record @@ -76,4 +72,5 @@ [Status (Message !)]) (type .public (Server !) - (-> (Request !) (! (Response !)))) + (-> (Request !) + (! (Response !)))) diff --git a/stdlib/source/library/lux/world/net/uri/scheme.lux b/stdlib/source/library/lux/world/net/uri/scheme.lux new file mode 100644 index 000000000..7db4b9583 --- /dev/null +++ b/stdlib/source/library/lux/world/net/uri/scheme.lux @@ -0,0 +1,141 @@ +(.require + [library + [lux (.except) + [abstract + ["[0]" equivalence (.only Equivalence)] + ["[0]" hash (.only Hash)]] + [data + ["[0]" text]] + [meta + [type + ["[0]" primitive (.only primitive)]]]]]) + +... https://en.wikipedia.org/wiki/List_of_URI_schemes +(primitive .public Scheme + Text + + (with_template [ ] + [(def .public + Scheme + (primitive.abstraction ))] + + ["about" about] + ["acap" acap] + ["acct" user_account] + ["acr" anonymous_customer_reference] + ["attachment" attachment] + + ["bitcoin" bitcoin] + ["blob" blob] + + ["cap" calendar_access_protocol] + + ["data" data] + ["dns" dns] + ["dntp" dntp] + ["doi" digital_object_identifier] + ["drm" drm] + + ["feed" feed] + ["file" file] + ["finger" finger] + ["fish" fish] + ["fm" fm] + ["ftp" ftp] + + ["geo" geo] + ["git" git] + + ["http" http] + ["https" https] + + ["imap" imap] + ["ipp" ipp] + ["ipps" ipps] + ["irc" irc] + ["irc6" irc6] + ["ircs" ircs] + + ["jar" jar] + + ["ldap" ldap] + ["ldaps" ldaps] + + ["magnet" magnet] + ["mailto" mail_to] + ["mvn" apache_maven] + + ["pop" pop] + + ["sip" sip] + ["sips" sips] + ["sms" sms] + ["snmp" snmp] + ["ssh" ssh] + ["stun" stun] + ["stuns" stuns] + + ["tel" telephone_number] + ["turn" turn] + ["turns" turns] + + ["xmpp" xmpp] + ) + + (with_template [ ] + [(def .public + Scheme + )] + + [acap application_configuration_access_protocol] + + [dns domain_name_system] + [dntp direct_network_transfer_protocol] + + [ftp file_transfer_protocol] + + [http hypertext_transfer_protocol] + [https secure_hypertext_transfer_protocol] + + [imap internet_message_access_protocol] + [ipp internet_printing_protocol] + [ipps secure_internet_printing_protocol] + [irc internet_relay_chat] + [ircs secure_internet_relay_chat] + + [ldap lightweight_directory_access_protocol] + [ldaps secure_lightweight_directory_access_protocol] + + [pop post_office_protocol] + + [sip session_initiation_protocol] + [sips secure_session_initiation_protocol] + [sms short_message_service] + [snmp simple_network_management_protocol] + [ssh secure_shell_protocol] + + [stun session_traversal_utilities_for_nat] + [stuns secure_session_traversal_utilities_for_nat] + + [turn traversal_using_relays_around_nat] + [turns secure_traversal_using_relays_around_nat] + + [xmpp extensible_messaging_and_presence_protocol] + ) + + (def .public scheme + (-> Text Scheme) + (|>> primitive.abstraction)) + + (def .public name + (-> Scheme Text) + (|>> primitive.representation)) + + (def .public equivalence + (Equivalence Scheme) + (at equivalence.functor each ..name text.equivalence)) + + (def .public hash + (Hash Scheme) + (at hash.functor each ..name text.hash)) + ) diff --git a/stdlib/source/library/lux/world/time.lux b/stdlib/source/library/lux/world/time.lux index 853b0429f..b855ea4af 100644 --- a/stdlib/source/library/lux/world/time.lux +++ b/stdlib/source/library/lux/world/time.lux @@ -208,7 +208,8 @@ (..padded _#hour) ..separator (..padded _#minute) ..separator (..padded _#second) - (..millis_format _#milli_second)))) + (..millis_format _#milli_second) + ))) (def .public codec (Codec Text Time) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index f3723c1c0..77802d3cc 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -158,6 +158,9 @@ ..timed (do (try.with async.monad) [import (import.import (the platform.#file_system platform) (the cli.#libraries compilation)) + .let [all_extensions [(analysisE.bundle host_analysis) + generation_bundle + host_declaration_bundle]] [state archive phase_wrapper] (sharing [] (is (Platform ) platform) @@ -172,7 +175,8 @@ extender import (the cli.#sources compilation) - (the cli.#configuration compilation))))) + (the cli.#configuration compilation) + all_extensions)))) [archive state] (sharing [] (is (Platform ) platform) @@ -188,9 +192,7 @@ platform compilation [archive state] - [(analysisE.bundle host_analysis) - generation_bundle - host_declaration_bundle])))) + all_extensions)))) _ (cache.cache! (the platform.#file_system platform) (the cli.#configuration compilation) file_context archive) host_dependencies (..load_host_dependencies (the platform.#file_system platform) (the cli.#host_dependencies compilation)) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux index c9953642d..755487cce 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension.lux @@ -183,36 +183,6 @@ (phase.result [/.#bundle /.empty /.#state state]) (try.else false))) - (_.coverage [/.incorrect_arity] - (let [handler (is (/.Handler Int Nat Nat) - (function (_ @self phase archive inputs) - (phase.except /.incorrect_arity [@self 2 (list.size inputs)])))] - (|> (do phase.monad - [_ (/.install extender extension handler)] - (/.apply archive.empty phase [extension (list)])) - (phase.result [/.#bundle /.empty - /.#state state]) - (pipe.when - {try.#Failure error} - (exception.match? /.incorrect_arity error) - - _ - false)))) - (_.coverage [/.invalid_syntax] - (let [handler (is (/.Handler Int Nat Nat) - (function (_ @self phase archive inputs) - (phase.except /.invalid_syntax [@self %.nat inputs])))] - (|> (do phase.monad - [_ (/.install extender extension handler)] - (/.apply archive.empty phase [extension (list left right)])) - (phase.result [/.#bundle /.empty - /.#state state]) - (pipe.when - {try.#Failure error} - (exception.match? /.invalid_syntax error) - - _ - false)))) (_.for [/.Name] ..test|name) )) diff --git a/stdlib/source/test/lux/world/net.lux b/stdlib/source/test/lux/world/net.lux index 29427d6c3..f0c4acb39 100644 --- a/stdlib/source/test/lux/world/net.lux +++ b/stdlib/source/test/lux/world/net.lux @@ -13,7 +13,9 @@ ["[1][0]" http ["[1]/[0]" client] ["[1]/[0]" status] - ["[1]/[0]" version]]]) + ["[1]/[0]" version]] + ["[1][0]" uri + ["[1]/[0]" scheme]]]) (def .public test Test @@ -33,4 +35,6 @@ /http/client.test /http/status.test /http/version.test + + /uri/scheme.test ))) diff --git a/stdlib/source/test/lux/world/net/uri/scheme.lux b/stdlib/source/test/lux/world/net/uri/scheme.lux new file mode 100644 index 000000000..c91c49fbf --- /dev/null +++ b/stdlib/source/test/lux/world/net/uri/scheme.lux @@ -0,0 +1,163 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence] + ["$[0]" hash]]] + [data + [collection + ["[0]" list] + ["[0]" set]]] + [math + ["[0]" random (.only Random) (.use "[1]#[0]" monad)] + [number + ["n" nat]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def .public random + (Random /.Scheme) + (all random.either + (random#in /.about) + (random#in /.acap) + (random#in /.user_account) + (random#in /.anonymous_customer_reference) + (random#in /.attachment) + + (random#in /.bitcoin) + (random#in /.blob) + + (random#in /.calendar_access_protocol) + + (random#in /.data) + (random#in /.dns) + (random#in /.dntp) + (random#in /.digital_object_identifier) + (random#in /.drm) + + (random#in /.feed) + (random#in /.file) + (random#in /.finger) + (random#in /.fish) + (random#in /.fm) + (random#in /.ftp) + + (random#in /.geo) + (random#in /.git) + + (random#in /.http) + (random#in /.https) + + (random#in /.imap) + (random#in /.ipp) + (random#in /.ipps) + (random#in /.irc) + (random#in /.irc6) + (random#in /.ircs) + + (random#in /.jar) + + (random#in /.ldap) + (random#in /.ldaps) + + (random#in /.magnet) + (random#in /.mail_to) + (random#in /.apache_maven) + + (random#in /.pop) + + (random#in /.sip) + (random#in /.sips) + (random#in /.sms) + (random#in /.snmp) + (random#in /.ssh) + (random#in /.stun) + (random#in /.stuns) + + (random#in /.telephone_number) + (random#in /.turn) + (random#in /.turns) + + (random#in /.xmpp) + )) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [expected ..random]) + (_.for [/.Scheme]) + (`` (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.hash] + ($hash.spec /.hash ..random)) + + (_.coverage [/.name /.scheme] + (|> expected + /.name + /.scheme + (at /.equivalence = expected))) + (with_expansions [ (these /.about /.acap /.user_account /.anonymous_customer_reference /.attachment + /.bitcoin /.blob + /.calendar_access_protocol + /.data /.dns /.dntp /.digital_object_identifier /.drm + /.feed /.file /.finger /.fish /.fm /.ftp + /.geo /.git + /.http /.https + /.imap /.ipp /.ipps /.irc /.irc6 /.ircs + /.jar + /.ldap /.ldaps + /.magnet /.mail_to /.apache_maven + /.pop + /.sip /.sips /.sms /.snmp /.ssh /.stun /.stuns + /.telephone_number /.turn /.turns + /.xmpp)] + (_.coverage [] + (let [options (list ) + uniques (set.of_list /.hash options)] + (n.= (list.size options) + (set.size uniques))))) + (,, (with_template [ ] + [(_.coverage [] + (at /.equivalence = ))] + + [/.acap /.application_configuration_access_protocol] + + [/.dns /.domain_name_system] + [/.dntp /.direct_network_transfer_protocol] + + [/.ftp /.file_transfer_protocol] + + [/.http /.hypertext_transfer_protocol] + [/.https /.secure_hypertext_transfer_protocol] + + [/.imap /.internet_message_access_protocol] + [/.ipp /.internet_printing_protocol] + [/.ipps /.secure_internet_printing_protocol] + [/.irc /.internet_relay_chat] + [/.ircs /.secure_internet_relay_chat] + + [/.ldap /.lightweight_directory_access_protocol] + [/.ldaps /.secure_lightweight_directory_access_protocol] + + [/.pop /.post_office_protocol] + + [/.sip /.session_initiation_protocol] + [/.sips /.secure_session_initiation_protocol] + [/.sms /.short_message_service] + [/.snmp /.simple_network_management_protocol] + [/.ssh /.secure_shell_protocol] + + [/.stun /.session_traversal_utilities_for_nat] + [/.stuns /.secure_session_traversal_utilities_for_nat] + + [/.turn /.traversal_using_relays_around_nat] + [/.turns /.secure_traversal_using_relays_around_nat] + + [/.xmpp /.extensible_messaging_and_presence_protocol])) + )))) diff --git a/stdlib/source/test/lux/world/time.lux b/stdlib/source/test/lux/world/time.lux index 68e6e478c..d6ee9b953 100644 --- a/stdlib/source/test/lux/world/time.lux +++ b/stdlib/source/test/lux/world/time.lux @@ -50,12 +50,25 @@ Test (do [! random.monad] [expected random.time] - (_.coverage [/.clock /.time] - (|> expected - /.clock - /.time - (try#each (at /.equivalence = expected)) - (try.else false))))) + (all _.and + (_.coverage [/.clock /.time] + (|> expected + /.clock + /.time + (try#each (at /.equivalence = expected)) + (try.else false))) + (let [expected (/.clock expected)] + (`` (all _.and + (,, (with_template [ ] + [(_.coverage [] + (n.< (the expected)))] + + [0024 /.#hour] + [0060 /.#minute] + [0060 /.#second] + [1000 /.#milli_second] + ))))) + ))) (def for_ranges Test -- cgit v1.2.3