aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
authorEduardo Julian2022-10-01 18:39:48 -0400
committerEduardo Julian2022-10-01 18:39:48 -0400
commit0b2294bc184b1ed3e82dc00096e9971245239e2c (patch)
treeb3e0421bb7736d09562291118a562e15fd4f1ede /stdlib/source/library
parent53704218a3705132dbe807a8ef54f938809f84d5 (diff)
New format for extensions [part 1]
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux.lux3
-rw-r--r--stdlib/source/library/lux/math.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/default/init.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux8
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux24
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux4
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/generation.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux11
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux157
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux19
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux12
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux81
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/extension.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/apply.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/init.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/new.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/reset.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/loop.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/structure.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/when.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux74
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/variable.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux3
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux2
-rw-r--r--stdlib/source/library/lux/meta/extension.lux3
33 files changed, 248 insertions, 197 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 62a51de98..249e77569 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -5878,5 +5878,8 @@
_
(failure (..wrong_syntax_error (symbol ..Rec)))))))
+(def .public Synthesis
+ (Primitive "#Synthesis"))
+
(def .public Generation
(Primitive "#Generation"))
diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux
index eecff5842..a43b14b69 100644
--- a/stdlib/source/library/lux/math.lux
+++ b/stdlib/source/library/lux/math.lux
@@ -51,7 +51,7 @@
(when <+>
[_ {.#Text $}]
(phase#in (list#mix (function (_ left right)
- {analysis.#Extension $ (list left right)})
+ {analysis.#Extension ["" $] (list left right)})
last
prevs))
diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux
index 128e66ae2..b496058e6 100644
--- a/stdlib/source/library/lux/meta/compiler/default/init.lux
+++ b/stdlib/source/library/lux/meta/compiler/default/init.lux
@@ -68,14 +68,16 @@
(let [synthesis_state [synthesisE.bundle ///synthesis.init]
generation_state [generation_bundle (///generation.state host module)]
lux (///analysis.state (///analysis.info version.latest target configuration))
- eval (///analysis/evaluation.evaluator expander synthesis_state generation_state (generate extender lux))
+ eval (///analysis/evaluation.evaluator expander
+ [synthesis_state (synthesisP.phase extender lux)]
+ [generation_state (generate extender lux)])
analysis_state [(analysisE.bundle eval anchor,expression,declaration host_analysis)
lux]]
[extension.empty
[///declaration.#analysis [///declaration.#state analysis_state
///declaration.#phase (analysisP.phase expander)]
///declaration.#synthesis [///declaration.#state synthesis_state
- ///declaration.#phase synthesisP.phase]
+ ///declaration.#phase (synthesisP.phase extender)]
///declaration.#generation [///declaration.#state generation_state
///declaration.#phase (generate extender)]]]))
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 2b8a26b2b..47fbb877c 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux
@@ -24,6 +24,7 @@
["r" rev]
["f" frac]]]
[meta
+ ["[0]" symbol]
["[0]" location]
["[0]" configuration (.only Configuration)]
["[0]" code
@@ -64,7 +65,7 @@
{#When Analysis (Match' Analysis)}
{#Function (Environment Analysis) Analysis}
{#Apply Analysis Analysis}
- {#Extension (Extension Analysis)})))
+ {#Extension [Symbol (List Analysis)]})))
(type .public Branch
(Branch' Analysis))
@@ -109,7 +110,8 @@
(= reference_abstraction sample_abstraction))
[{#Extension reference} {#Extension sample}]
- (at (extension.equivalence =) = reference sample)
+ ... (at (extension.equivalence =) = reference sample)
+ (at (product.equivalence symbol.equivalence (list.equivalence =)) = reference sample)
_
false))))
@@ -241,7 +243,7 @@
(|> parameters
(list#each format)
(text.interposed " ")
- (%.format (%.text name) " ")
+ (%.format (%.symbol name) " ")
(text.enclosed ["(" ")"]))))
(with_template [<special> <general>]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux
index 402cf563a..95fba2a56 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux
@@ -24,7 +24,6 @@
[//
[phase
["[0]P" extension]
- ["[0]P" synthesis]
["[0]P" analysis]
[//
["[0]" synthesis]
@@ -42,29 +41,34 @@
(Atom (Dictionary module.ID Nat))
(atom.atom (dictionary.empty n.hash)))
-(def .public (evaluator expander synthesis_state generation_state generate)
+(def .public (evaluator expander
+ [synthesis_state synthesis]
+ [generation_state generation])
(All (_ anchor expression artifact)
(-> Expander
- synthesis.State+
- (generation.State+ anchor expression artifact)
- (generation.Phase anchor expression artifact)
+ [synthesis.State+
+ synthesis.Phase]
+ [(generation.State+ anchor expression artifact)
+ (generation.Phase anchor expression artifact)]
Eval))
- (let [analyze (analysisP.phase expander)]
+ (let [analysis (analysisP.phase expander)]
(function (eval archive type exprC)
(do phase.monad
[exprA (<| (//type.expecting type)
//scope.reset
- (analyze archive exprC))
+ (analysis archive exprC))
module (extensionP.lifted
meta.current_module_name)]
(<| phase.lifted
(do try.monad
- [exprS (|> exprA (synthesisP.phase archive) (phase.result synthesis_state))])
+ [exprS (|> exprA
+ (synthesis archive)
+ (phase.result synthesis_state))])
(phase.result generation_state)
(do phase.monad
[@module (sharing [anchor expression artifact]
(is (generation.Phase anchor expression artifact)
- generate)
+ generation)
(is (generation.Operation anchor expression artifact module.ID)
(generation.module_id module archive)))
.let [[evals _] (io.run! (atom.update! (dictionary.revised' @module 0 ++) ..evals))
@@ -73,5 +77,5 @@
("lux i64 left-shift" 16)
("lux i64 or" @eval)
("lux i64 left-shift" 32)))
- (generate archive exprS))]
+ (generation archive exprS))]
(generation.evaluate! [@module @eval] [{.#None} exprO])))))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
index 822c33d1d..132df96b9 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
@@ -31,7 +31,7 @@
[#analysis (Component analysis.State+
analysis.Phase)
#synthesis (Component synthesis.State+
- synthesis.Phase)
+ (-> Lux synthesis.Phase))
#generation (Component (generation.State+ anchor expression declaration)
(-> Lux (generation.Phase anchor expression declaration)))]))
@@ -74,7 +74,7 @@
{try.#Success [[bundle state] (the [<component> ..#phase] state)]}))]
[analysis ..#analysis analysis.Phase]
- [synthesis ..#synthesis synthesis.Phase]
+ [synthesis ..#synthesis (-> Lux synthesis.Phase)]
[generation ..#generation (-> Lux (generation.Phase anchor expression declaration))]
)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
index 78587f280..71caea7e7 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except #module #counter #host symbol)
+ [lux (.except Synthesis #module #counter #host symbol)
[abstract
[monad (.only do)]]
[control
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 4cd838c6f..4bfc09f26 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
@@ -86,11 +86,12 @@
[state //.state
.let [compiler_eval (meta_eval archive
(the [//extension.#state /.#analysis /.#state //extension.#bundle] state)
- (evaluation.evaluator expander
- (the [//extension.#state /.#synthesis /.#state] state)
- (the [//extension.#state /.#generation /.#state] state)
- ((the [//extension.#state /.#generation /.#phase] state)
- (the [//extension.#state /.#analysis /.#state //extension.#state] state))))
+ (let [analysis_state (the [//extension.#state /.#analysis /.#state //extension.#state] state)]
+ (evaluation.evaluator expander
+ [(the [//extension.#state /.#synthesis /.#state] state)
+ ((the [//extension.#state /.#synthesis /.#phase] state) analysis_state)]
+ [(the [//extension.#state /.#generation /.#state] state)
+ ((the [//extension.#state /.#generation /.#phase] state) analysis_state)])))
extension_eval (as Eval (wrapper (as_expected compiler_eval)))]
_ (//.with (has [//extension.#state /.#analysis /.#state //extension.#state .#eval] extension_eval state))]
(when code
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 eecfece1f..596336ddc 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
@@ -465,7 +465,7 @@
..reflection)
(list)})
(analyse archive arrayC))]
- (in {/////analysis.#Extension extension_name (list arrayA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list arrayA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -486,8 +486,8 @@
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))]
- (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT))
- arrayA)})))
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text (..signature arrayJT))
+ arrayA)})))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -502,7 +502,7 @@
(analyse archive lengthC))
_ (typeA.inference {.#Primitive (|> (jvm.array primitive_type) ..reflection)
(list)})]
- (in {/////analysis.#Extension extension_name (list lengthA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list lengthA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -523,8 +523,8 @@
{.#None}
(/////analysis.except ..non_array expectedT))]
- (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature elementJT))
- lengthA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text (..signature elementJT))
+ lengthA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -703,7 +703,7 @@
arrayA (<| (typeA.expecting {.#Primitive (|> (jvm.array jvm_type) ..reflection)
(list)})
(analyse archive arrayC))]
- (in {/////analysis.#Extension extension_name (list idxA arrayA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list idxA arrayA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)]))))
@@ -726,9 +726,9 @@
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))]
- (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT))
- idxA
- arrayA)})))
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text (..signature arrayJT))
+ idxA
+ arrayA)})))
_
(/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)]))))
@@ -748,9 +748,9 @@
(analyse archive valueC))
arrayA (<| (typeA.expecting array_type)
(analyse archive arrayC))]
- (in {/////analysis.#Extension extension_name (list idxA
- valueA
- arrayA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list idxA
+ valueA
+ arrayA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))))
@@ -775,10 +775,10 @@
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))]
- (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT))
- idxA
- valueA
- arrayA)})))
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text (..signature arrayJT))
+ idxA
+ valueA
+ arrayA)})))
_
(/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))
@@ -842,7 +842,7 @@
[expectedT (///.lifted meta.expected_type)
[_ :object:] (check_object expectedT)
_ (typeA.inference :object:)]
- (in {/////analysis.#Extension extension_name (list)}))
+ (in {/////analysis.#Extension ["" extension_name] (list)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)]))))
@@ -857,7 +857,7 @@
[objectT objectA] (typeA.inferring
(analyse archive objectC))
_ (check_object objectT)]
- (in {/////analysis.#Extension extension_name (list objectA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list objectA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -872,7 +872,7 @@
(analyse archive monitorC))
_ (check_object monitorT)
exprA (analyse archive exprC)]
- (in {/////analysis.#Extension extension_name (list monitorA exprA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list monitorA exprA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)]))))
@@ -892,7 +892,7 @@
(if ?
(in [])
(/////analysis.except non_throwable exception_class)))]
- (in {/////analysis.#Extension extension_name (list exceptionA)}))
+ (in {/////analysis.#Extension ["" extension_name] (list exceptionA)}))
_
(/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -908,7 +908,7 @@
[_ (..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 extension_name (list (/////analysis.text class))}))
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text class))}))
_
(/////analysis.except ///.invalid_syntax [extension_name %.code args]))
@@ -929,7 +929,7 @@
[object_class _] (check_object objectT)
? (phase.lifted (reflection!.sub? class_loader object_class sub_class))]
(if ?
- (in {/////analysis.#Extension extension_name (list (/////analysis.text sub_class) objectA)})
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text sub_class) objectA)})
(/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))]))
(def (class_candidate_parents class_loader from_name fromT to_name to_class)
@@ -1018,9 +1018,9 @@
_
false)))))))]
(if can_cast?
- (in {/////analysis.#Extension extension_name (list (/////analysis.text from_name)
- (/////analysis.text to_name)
- fromA)})
+ (in {/////analysis.#Extension ["" extension_name] (list (/////analysis.text from_name)
+ (/////analysis.text to_name)
+ fromA)})
(/////analysis.except ..cannot_cast [fromJT toJT fromC])))
_
@@ -1054,7 +1054,7 @@
(not deprecated?))
fieldT (reflection_type luxT.fresh fieldJT)
_ (typeA.inference fieldT)]
- (in (<| {/////analysis.#Extension extension_name}
+ (in (<| {/////analysis.#Extension ["" extension_name]}
(list (/////analysis.text class)
(/////analysis.text field)
(/////analysis.text (..signature fieldJT)))))))]))
@@ -1078,7 +1078,7 @@
fieldT (reflection_type luxT.fresh fieldJT)
valueA (<| (typeA.expecting fieldT)
(analyse archive valueC))]
- (in (<| {/////analysis.#Extension extension_name}
+ (in (<| {/////analysis.#Extension ["" extension_name]}
(list (/////analysis.text class)
(/////analysis.text field)
(/////analysis.text (..signature fieldJT))
@@ -1103,7 +1103,7 @@
(not deprecated?))
fieldT (reflection_type mapping fieldJT)
_ (typeA.inference fieldT)]
- (in (<| {/////analysis.#Extension extension_name}
+ (in (<| {/////analysis.#Extension ["" extension_name]}
(list (/////analysis.text class)
(/////analysis.text field)
(/////analysis.text (..signature fieldJT))
@@ -1132,7 +1132,7 @@
fieldT (reflection_type mapping fieldJT)
valueA (<| (typeA.expecting fieldT)
(analyse archive valueC))]
- (in (<| {/////analysis.#Extension extension_name}
+ (in (<| {/////analysis.#Extension ["" extension_name]}
(list (/////analysis.text class)
(/////analysis.text field)
(/////analysis.text (..signature fieldJT))
@@ -1518,10 +1518,10 @@
(not deprecated?))
[outputT argsA] (inference.general archive analyse methodT (list#each product.right argsTC))
outputJT (check_return outputT)]
- (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list))))
- (/////analysis.text method)
- (/////analysis.text (..signature outputJT))
- (decorate_inputs argsT argsA))})))]))
+ (in {/////analysis.#Extension ["" extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list))))
+ (/////analysis.text method)
+ (/////analysis.text (..signature outputJT))
+ (decorate_inputs argsT argsA))})))]))
(def (invoke::virtual class_loader)
(-> java/lang/ClassLoader Handler)
@@ -1542,11 +1542,11 @@
_
(undefined))]
outputJT (check_return outputT)]
- (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list))))
- (/////analysis.text method)
- (/////analysis.text (..signature outputJT))
- objectA
- (decorate_inputs argsT argsA))})))]))
+ (in {/////analysis.#Extension ["" extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list))))
+ (/////analysis.text method)
+ (/////analysis.text (..signature outputJT))
+ objectA
+ (decorate_inputs argsT argsA))})))]))
(def (invoke::special class_loader)
(-> java/lang/ClassLoader Handler)
@@ -1567,11 +1567,11 @@
_
(undefined))]
outputJT (check_return outputT)]
- (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list))))
- (/////analysis.text method)
- (/////analysis.text (..signature outputJT))
- objectA
- (decorate_inputs argsT argsA))})))]))
+ (in {/////analysis.#Extension ["" extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list))))
+ (/////analysis.text method)
+ (/////analysis.text (..signature outputJT))
+ objectA
+ (decorate_inputs argsT argsA))})))]))
(def (invoke::interface class_loader)
(-> java/lang/ClassLoader Handler)
@@ -1595,7 +1595,7 @@
_
(undefined))]
outputJT (check_return outputT)]
- (in {/////analysis.#Extension extension_name
+ (in {/////analysis.#Extension ["" extension_name]
(list.partial (/////analysis.text (..signature (jvm.class class_name (list))))
(/////analysis.text method)
(/////analysis.text (..signature outputJT))
@@ -1614,8 +1614,8 @@
_ (phase.assertion ..deprecated_method [class ..constructor_method methodT]
(not deprecated?))
[outputT argsA] (inference.general archive analyse methodT (list#each product.right argsTC))]
- (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list))))
- (decorate_inputs argsT argsA))})))]))
+ (in {/////analysis.#Extension ["" extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list))))
+ (decorate_inputs argsT argsA))})))]))
(def (bundle::member class_loader)
(-> java/lang/ClassLoader Bundle)
@@ -1745,7 +1745,7 @@
(with_template [<name>]
[(exception.def .public (<name> [expected actual])
(exception.Exception [(List [(Type Class) Text (Type Method)])
- (List [(Type Class) Text (Type Method)])])
+ (List [(Type Class) Text (Type Method)])])
(let [%method (is (%.Format [(Type Class) Text (Type Method)])
(function (_ [super name type])
(format (..signature super) " :: " (%.text name) " " (..signature type))))]
@@ -1957,8 +1957,7 @@
(with_fake_parameter abstraction)}
{/////analysis.#Extension name parameters}
- {/////analysis.#Extension name
- (list#each with_fake_parameter parameters)}))
+ {/////analysis.#Extension name (list#each with_fake_parameter parameters)}))
(def .public (hidden_method_body arity bodyA)
(-> Nat Analysis Analysis)
@@ -2584,18 +2583,18 @@
(if strict_floating_point?
method.strict
modifier.empty))
- ..constructor_name
- false (jvm.method [variables (list#each product.right arguments) jvm.void exceptions])
- (list)
- {.#Some (all _.composite
- (_.aload 0)
- (|> constructor_arguments
- (list#each (|>> product.left ..mock_value))
- (monad.all _.monad))
- (|> (jvm.method [(list) (list#each product.left constructor_arguments) jvm.void (list)])
- (_.invokespecial super ..constructor_name))
- _.return
- )})
+ ..constructor_name
+ false (jvm.method [variables (list#each product.right arguments) jvm.void exceptions])
+ (list)
+ {.#Some (all _.composite
+ (_.aload 0)
+ (|> constructor_arguments
+ (list#each (|>> product.left ..mock_value))
+ (monad.all _.monad))
+ (|> (jvm.method [(list) (list#each product.left constructor_arguments) jvm.void (list)])
+ (_.invokespecial super ..constructor_name))
+ _.return
+ )})
{#Overriden_Method [super name strict_floating_point? annotations variables
self arguments return exceptions
@@ -2605,10 +2604,10 @@
(if strict_floating_point?
method.strict
modifier.empty))
- name
- false (jvm.method [variables (list#each product.right arguments) return exceptions])
- (list)
- {.#Some (..mock_return return)})
+ name
+ false (jvm.method [variables (list#each product.right arguments) return exceptions])
+ (list)
+ {.#Some (..mock_return return)})
{#Virtual_Method [name privacy final? strict_floating_point? annotations variables
self arguments return exceptions
@@ -2621,10 +2620,10 @@
(if final?
method.final
modifier.empty))
- name
- false (jvm.method [variables (list#each product.right arguments) return exceptions])
- (list)
- {.#Some (..mock_return return)})
+ name
+ false (jvm.method [variables (list#each product.right arguments) return exceptions])
+ (list)
+ {.#Some (..mock_return return)})
{#Static_Method [name privacy strict_floating_point? annotations
variables arguments return exceptions
@@ -2635,20 +2634,20 @@
(if strict_floating_point?
method.strict
modifier.empty))
- name
- false (jvm.method [variables (list#each product.right arguments) return exceptions])
- (list)
- {.#Some (..mock_return return)})
+ name
+ false (jvm.method [variables (list#each product.right arguments) return exceptions])
+ (list)
+ {.#Some (..mock_return return)})
{#Abstract_Method [name privacy annotations
variables arguments return exceptions]}
(method.method (all modifier#composite
method.abstract
(..method_privacy privacy))
- name
- false (jvm.method [variables (list#each product.right arguments) return exceptions])
- (list)
- {.#None})
+ name
+ false (jvm.method [variables (list#each product.right arguments) return exceptions])
+ (list)
+ {.#None})
))
(def (mock declaration super interfaces inheritance fields methods)
@@ -2710,7 +2709,7 @@
.let [supers {.#Item super_class super_interfaces}]
_ (..require_complete_method_concretion class_loader supers methods)
methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods)]
- (in {/////analysis.#Extension extension_name
+ (in {/////analysis.#Extension ["" extension_name]
(list (class_analysis super_class)
(/////analysis.tuple (list#each class_analysis super_interfaces))
(/////analysis.tuple (list#each typed_analysis constructor_argsA+))
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 f2e202be9..edde397d7 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
@@ -31,6 +31,7 @@
["[1][0]" analysis (.only Analysis Operation Phase Handler Bundle)
[evaluation (.only Eval)]
["[0]A" type]]
+ ["[0]" synthesis]
["[0]" generation]
[///
["[1]" phase]
@@ -63,7 +64,7 @@
(<| (typeA.expecting argT)
(analyse archive argC)))
(list.zipped_2 inputsT+ args))]
- (in {////analysis.#Extension extension_name argsA}))
+ (in {////analysis.#Extension ["" extension_name] argsA}))
(////analysis.except ///.incorrect_arity [extension_name num_expected num_actual]))))))
(def .public (nullary valueT)
@@ -123,7 +124,7 @@
(list (////analysis.tuple (list#each (|>> ////analysis.nat) cases))
branch))))
(list.partial input else)
- {////analysis.#Extension extension_name}))))])))
+ {////analysis.#Extension ["" extension_name]}))))])))
... "lux is" represents reference/pointer equality.
(def lux::is
@@ -148,7 +149,7 @@
(|> opC
(analyse archive)
(typeA.expecting (type_literal (-> .Any :var:)))
- (at ! each (|>> list {////analysis.#Extension extension_name})))))
+ (at ! each (|>> list {////analysis.#Extension ["" extension_name]})))))
_
(////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)]))))
@@ -274,6 +275,17 @@
(///bundle.install "clip" (trinary Nat Nat Text Text))
)))
+(def synthesis_extension
+ Handler
+ (..custom
+ [<code>.any
+ (function (_ extension_name phase archive [it])
+ (do [! ////.monad]
+ [it (<| (typeA.expecting synthesis.Handler)
+ (phase archive it))
+ _ (typeA.inference .Synthesis)]
+ (in it)))]))
+
(def (generation_extension [anchor expression declaration])
(-> [Type Type Type] Handler)
(..custom
@@ -289,6 +301,7 @@
(-> [Type Type Type] Bundle)
(<| (///bundle.prefix "extension")
(|> ///bundle.empty
+ (///bundle.install "synthesis" synthesis_extension)
(///bundle.install "generation" (generation_extension anchor,expression,declaration))
)))
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 1d4f70473..8a3f5727d 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Definition Primitive)
+ [lux (.except Type Definition Primitive Synthesis)
["[0]" ffi (.only import)]
[abstract
["[0]" monad (.only do)]]
@@ -896,11 +896,11 @@
parameters)
selfT {.#Primitive name (list#each product.right parameters)}]
state (extension.lifted phase.state)
- methods (monad.each ! (..method_definition archive super interfaces [mapping selfT]
- [(the [declaration.#analysis declaration.#phase] state)
- (the [declaration.#synthesis declaration.#phase] state)
- ((the [declaration.#generation declaration.#phase] state)
- (the [declaration.#analysis declaration.#state extension.#state] state))])
+ methods (monad.each ! (let [analysis_state (the [declaration.#analysis declaration.#state extension.#state] state)]
+ (..method_definition archive super interfaces [mapping selfT]
+ [(the [declaration.#analysis declaration.#phase] state)
+ ((the [declaration.#synthesis declaration.#phase] state) analysis_state)
+ ((the [declaration.#generation declaration.#phase] state) analysis_state)]))
methods)
.let [all_dependencies (cache.all (list#each product.left methods))]
bytecode (<| (at ! each (\\format.result class.format))
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 b88520b8d..d7a42d308 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
@@ -79,7 +79,7 @@
[@module (n.- (++ @artifact) 0)])
... TODO: Inline "evaluate!'" into "evaluate!" ASAP
-(def (evaluate!' archive generate code//type codeS)
+(def (evaluate!' archive generation code//type codeS)
(All (_ anchor expression declaration)
(-> Archive
(/////generation.Phase anchor expression declaration)
@@ -90,7 +90,7 @@
(do phase.monad
[module /////generation.module
id /////generation.next
- codeG (generate archive codeS)
+ codeG (generation archive codeS)
@module (/////generation.module_id module archive)
codeV (/////generation.evaluate! (..context [@module id]) [{.#None} codeG])]
(in [code//type codeG codeV]))))
@@ -100,21 +100,21 @@
(-> Archive Type Code (Operation anchor expression declaration [Type expression Any])))
(do phase.monad
[state (///.lifted phase.state)
- .let [analyse (the [/////declaration.#analysis /////declaration.#phase] state)
- synthesize (the [/////declaration.#synthesis /////declaration.#phase] state)
- generate ((the [/////declaration.#generation /////declaration.#phase] state)
- (the [/////declaration.#analysis /////declaration.#state ///.#state] state))]
+ .let [analysis_state (the [/////declaration.#analysis /////declaration.#state ///.#state] state)
+ analysis (the [/////declaration.#analysis /////declaration.#phase] state)
+ synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state)
+ generation ((the [/////declaration.#generation /////declaration.#phase] state) analysis_state)]
[_ codeA] (<| /////declaration.lifted_analysis
scope.with
typeA.fresh
(typeA.expecting type)
- (analyse archive codeC))
+ (analysis archive codeC))
codeS (/////declaration.lifted_synthesis
- (synthesize archive codeA))]
- (evaluate!' archive generate type codeS)))
+ (synthesis archive codeA))]
+ (evaluate!' archive generation type codeS)))
... TODO: Inline "definition'" into "definition" ASAP
-(def (definition' archive generate [module name] code//type codeS)
+(def (definition' archive generation [module name] code//type codeS)
(All (_ anchor expression declaration)
(-> Archive
(/////generation.Phase anchor expression declaration)
@@ -126,7 +126,7 @@
(do phase.monad
[dependencies (cache/artifact.dependencies archive codeS)
[interim_artifacts codeG] (/////generation.with_interim_artifacts archive
- (generate archive codeS))
+ (generation archive codeS))
.let [@abstraction (when codeS
(/////synthesis.function/abstraction [env arity body])
(|> interim_artifacts
@@ -147,10 +147,10 @@
(Operation anchor expression declaration [Type expression Any])))
(do [! phase.monad]
[state (///.lifted phase.state)
- .let [analyse (the [/////declaration.#analysis /////declaration.#phase] state)
- synthesize (the [/////declaration.#synthesis /////declaration.#phase] state)
- generate ((the [/////declaration.#generation /////declaration.#phase] state)
- (the [/////declaration.#analysis /////declaration.#state ///.#state] state))]
+ .let [analysis_state (the [/////declaration.#analysis /////declaration.#state ///.#state] state)
+ analysis (the [/////declaration.#analysis /////declaration.#phase] state)
+ synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state)
+ generation ((the [/////declaration.#generation /////declaration.#phase] state) analysis_state)]
[_ code//type codeA] (/////declaration.lifted_analysis
(scope.with
(typeA.fresh
@@ -158,22 +158,22 @@
{.#None}
(do !
[[code//type codeA] (typeA.inferring
- (analyse archive codeC))
+ (analysis archive codeC))
code//type (typeA.check (check.clean (list) code//type))]
(in [code//type codeA]))
{.#Some expected}
(do !
[codeA (<| (typeA.expecting expected)
- (analyse archive codeC))]
+ (analysis archive codeC))]
(in [expected codeA]))))))
codeS (/////declaration.lifted_synthesis
- (synthesize archive codeA))]
- (definition' archive generate name code//type codeS)))
+ (synthesis archive codeA))]
+ (definition' archive generation name code//type codeS)))
(with_template [<full> <partial> <learn>]
[... TODO: Inline "<partial>" into "<full>" ASAP
- (def (<partial> archive generate extension codeT codeS)
+ (def (<partial> archive generation extension codeT codeS)
(All (_ anchor expression declaration)
(-> Archive
(/////generation.Phase anchor expression declaration)
@@ -188,7 +188,7 @@
(do phase.monad
[dependencies (cache/artifact.dependencies archive codeS)
[interim_artifacts codeG] (/////generation.with_interim_artifacts archive
- (generate archive codeS))
+ (generation archive codeS))
@module (phase.lifted (archive.id current_module archive))
@self (<learn> extension (list#mix set.has dependencies interim_artifacts))
[target_name value declaration] (/////generation.define! [@module @self] {.#None} [{.#None} codeG])
@@ -201,18 +201,18 @@
(Operation anchor expression declaration [expression Any])))
(do phase.monad
[state (///.lifted phase.state)
- .let [analyse (the [/////declaration.#analysis /////declaration.#phase] state)
- synthesize (the [/////declaration.#synthesis /////declaration.#phase] state)
- generate ((the [/////declaration.#generation /////declaration.#phase] state)
- (the [/////declaration.#analysis /////declaration.#state ///.#state] state))]
+ .let [analysis_state (the [/////declaration.#analysis /////declaration.#state ///.#state] state)
+ analysis (the [/////declaration.#analysis /////declaration.#phase] state)
+ synthesis ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state)
+ generation ((the [/////declaration.#generation /////declaration.#phase] state) analysis_state)]
[_ codeA] (<| /////declaration.lifted_analysis
scope.with
typeA.fresh
(typeA.expecting codeT)
- (analyse archive codeC))
+ (analysis archive codeC))
codeS (/////declaration.lifted_synthesis
- (synthesize archive codeA))]
- (<partial> archive generate extension codeT codeS)))]
+ (synthesis archive codeA))]
+ (<partial> archive generation extension codeT codeS)))]
[analyser analyser' /////generation.learn_analyser]
[synthesizer synthesizer' /////generation.learn_synthesizer]
@@ -226,11 +226,12 @@
(-> Expander [Type Type Type] /////analysis.Bundle (Operation anchor expression declaration Any)))
(do phase.monad
[[bundle state] phase.state
- .let [eval (/////analysis/evaluation.evaluator expander
- (the [/////declaration.#synthesis /////declaration.#state] state)
- (the [/////declaration.#generation /////declaration.#state] state)
- ((the [/////declaration.#generation /////declaration.#phase] state)
- (the [/////declaration.#analysis /////declaration.#state ///.#state] state)))
+ .let [analysis_state (the [/////declaration.#analysis /////declaration.#state ///.#state] state)
+ eval (/////analysis/evaluation.evaluator expander
+ [(the [/////declaration.#synthesis /////declaration.#state] state)
+ ((the [/////declaration.#synthesis /////declaration.#phase] state) analysis_state)]
+ [(the [/////declaration.#generation /////declaration.#state] state)
+ ((the [/////declaration.#generation /////declaration.#phase] state) analysis_state)])
previous_analysis_extensions (the [/////declaration.#analysis /////declaration.#state ///.#bundle] state)]]
(phase.with [bundle
(revised [/////declaration.#analysis /////declaration.#state]
@@ -408,16 +409,6 @@
/////analysis.Handler /////analysis.Handler
/////declaration.lifted_analysis
..analyser]
- ["Synthesis"
- def_synthesis
- /////synthesis.Handler /////synthesis.Handler
- /////declaration.lifted_synthesis
- ..synthesizer]
- ["Generation"
- def_generation
- (/////generation.Handler anchorT expressionT declarationT) (/////generation.Handler anchor expression declaration)
- /////declaration.lifted_generation
- ..generator]
["Declaration"
def_declaration
(/////declaration.Handler anchorT expressionT declarationT) (/////declaration.Handler anchor expression declaration)
@@ -438,8 +429,6 @@
(dictionary.has "module" def_module)
(dictionary.has "alias" def_alias)
(dictionary.has "analysis" (def_analysis anchor,expression,declaration extender))
- (dictionary.has "synthesis" (def_synthesis anchor,expression,declaration extender))
- (dictionary.has "generation" (def_generation anchor,expression,declaration extender))
(dictionary.has "declaration" (def_declaration anchor,expression,declaration extender))
)))
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 bc81d188e..10b7d920b 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Label Primitive)
+ [lux (.except Type Label Primitive Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
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 ecb42ed93..eeb793ab2 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Primitive)
+ [lux (.except Type Primitive Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
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 3566da9bf..321e8ca7b 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[data
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 77274bc83..4272682cb 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
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
[monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function.lux
index c6b9dac3a..e7fa794d8 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Label with)
+ [lux (.except Type Label Synthesis with)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux
index b8f01c6f1..ae7170923 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type)
+ [lux (.except Type Synthesis)
[data
[collection
["[0]" list]]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
index ae502cbee..2efd2e739 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Label)
+ [lux (.except Type Label Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/init.lux
index 6a2b7432e..220755282 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/init.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/init.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type type)
+ [lux (.except Type Synthesis type)
[abstract
["[0]" monad]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/new.lux
index 13dd6b6ee..fc53686f7 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/new.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/new.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type)
+ [lux (.except Type Synthesis)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
index fcb94a4ee..7f8154ed8 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type type)
+ [lux (.except Type Synthesis type)
[data
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/loop.lux
index 495882117..a4dedf683 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/loop.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/loop.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/structure.lux
index 1dfafd509..a05e38434 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/structure.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/structure.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Variant Tuple)
+ [lux (.except Variant Tuple Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/when.lux
index 767a48216..e66312fbd 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/when.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Label if let exec when int)
+ [lux (.except Type Label Synthesis if let exec when int)
[abstract
["[0]" monad (.only do)]]
[control
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 24c8189a3..3208a7b7d 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
@@ -1,18 +1,23 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
["[0]" pipe]
- ["[0]" try]]
+ ["[0]" try]
+ ["[0]" exception (.only Exception)]]
[data
+ [text
+ ["%" \\format]]
[collection
["[0]" list (.use "[1]#[0]" functor)]
["[0]" dictionary (.only Dictionary)]]]
- [meta
+ ["[0]" meta (.only)
[macro
- ["^" pattern]]]]]
+ ["^" pattern]]
+ [type
+ ["[0]" check]]]]]
["[0]" /
["[1][0]" function]
["[1][0]" when]
@@ -20,7 +25,7 @@
["/[1]" //
["[1][0]" extension]
["/[1]" //
- ["/" synthesis (.only Synthesis Phase)
+ ["/" synthesis (.only Synthesis Operation Phase Extender)
["[1][0]" simple]]
["[1][0]" analysis (.only Analysis)
["[2][0]" simple]
@@ -28,7 +33,9 @@
[///
["[0]" phase (.use "[1]#[0]" monad)]
[reference (.only)
- [variable (.only)]]]]]])
+ [variable (.only)]]
+ [meta
+ [archive (.only Archive)]]]]]])
(def (simple analysis)
(-> ///simple.Simple /simple.Simple)
@@ -50,8 +57,33 @@
[///simple.#Int /simple.#I64]
[///simple.#Rev /simple.#I64])))
-(def (optimization archive)
- Phase
+(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
+ (-> Extender Lux Phase) Archive
+ Symbol (List Analysis)
+ (Operation Synthesis))
+ (when (|> name
+ meta.export
+ (meta.result lux))
+ {try.#Success [exported? type value]}
+ (if (check.subsumes? .Synthesis type)
+ ((extender value) "" (phase extender lux) archive parameters)
+ (phase.except ..not_an_extension [name .Synthesis type]))
+
+ {try.#Failure error}
+ (phase.failure error)))
+
+(def (optimization phase extender lux archive)
+ (-> Phase Extender Lux Phase)
(function (optimization' analysis)
(when analysis
{///analysis.#Simple analysis'}
@@ -75,22 +107,22 @@
{///analysis.#When inputA branchesAB+}
(/.with_currying? false
- (/when.synthesize optimization branchesAB+ archive inputA))
+ (/when.synthesize (optimization phase extender lux) branchesAB+ archive inputA))
(///analysis.no_op value)
(optimization' value)
{///analysis.#Apply _}
(/.with_currying? false
- (/function.apply optimization archive analysis))
+ (/function.apply (optimization phase extender lux) archive analysis))
{///analysis.#Function environmentA bodyA}
- (/function.abstraction optimization environmentA archive bodyA)
+ (/function.abstraction (optimization phase extender lux) environmentA archive bodyA)
- {///analysis.#Extension name args}
+ {///analysis.#Extension ["" name] args}
(/.with_currying? false
(function (_ state)
- (|> (//extension.apply archive optimization [name args])
+ (|> (//extension.apply archive (optimization phase extender lux) [name args])
(phase.result' state)
(pipe.when
{try.#Failure _}
@@ -101,10 +133,16 @@
success
success))))
+
+ {///analysis.#Extension name parameters}
+ (extension_application extender lux
+ (optimization phase) archive
+ name parameters)
)))
-(def .public (phase archive analysis)
- Phase
- (do phase.monad
- [synthesis (..optimization archive analysis)]
- (phase.lifted (/variable.optimization synthesis))))
+(def .public (phase extender lux)
+ (-> Extender Lux Phase)
+ (function (phase archive analysis)
+ (do phase.monad
+ [synthesis (..optimization phase extender lux archive analysis)]
+ (phase.lifted (/variable.optimization synthesis)))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux
index 95fc2cc39..7d7c30660 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]
["[0]" enum]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux
index 99eddb022..4b78390ac 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/variable.lux
index 553a7e662..2ae6884e2 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/variable.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/variable.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Synthesis)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux
index c41a41da0..19ffdf596 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Pattern)
+ [lux (.except Pattern Synthesis)
[abstract
[equivalence (.only Equivalence)]
["[0]" monad (.only do)]]
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 090832274..22c0e171d 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Scope #Function #Apply #locals i64)
+ [lux (.except Scope Synthesis #Function #Apply #locals i64)
[abstract
[monad (.only do)]
[equivalence (.only Equivalence)]
@@ -141,6 +141,7 @@
[Phase extension.Phase]
[Handler extension.Handler]
[Bundle extension.Bundle]
+ [Extender extension.Extender]
)
(type .public Path
diff --git a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux
index 26f28d451..831a6e282 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux
@@ -1,7 +1,7 @@
... https://en.wikipedia.org/wiki/Tree_shaking
(.require
[library
- [lux (.except all)
+ [lux (.except Synthesis all)
[abstract
[hash (.only Hash)]
["[0]" monad (.only do)]]
diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux
index b8c707ddf..ef086411b 100644
--- a/stdlib/source/library/lux/meta/extension.lux
+++ b/stdlib/source/library/lux/meta/extension.lux
@@ -64,8 +64,6 @@
)))))))))]
[<c>.any <c>.end <c>.and <c>.result "lux def analysis" analysis]
- [<a>.any <a>.end <a>.and <a>.result "lux def synthesis" synthesis]
- ... [<s>.any <s>.end <s>.and <s>.result "lux def generation" generation]
[<c>.any <c>.end <c>.and <c>.result "lux def declaration" declaration]
)
@@ -97,5 +95,6 @@
(phase.failure (, g!error)))
)))))))))]
+ [<a>.any <a>.end <a>.and <a>.result "lux extension synthesis" synthesis .Synthesis]
[<s>.any <s>.end <s>.and <s>.result "lux extension generation" generation .Generation]
)