aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--documentation/bookmark/concurrency/lock_free_programming.md13
-rw-r--r--lux-ruby/source/program.lux4
-rw-r--r--stdlib/source/library/lux/target/jvm/field.lux4
-rw-r--r--stdlib/source/library/lux/target/jvm/method.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux17
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux16
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux14
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux26
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux31
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux75
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/export.lux71
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/io/context.lux4
-rw-r--r--stdlib/source/program/compositor.lux8
-rw-r--r--stdlib/source/program/compositor/export.lux71
-rw-r--r--stdlib/source/test/lux/target/jvm.lux26
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux52
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/export.lux115
32 files changed, 368 insertions, 231 deletions
diff --git a/documentation/bookmark/concurrency/lock_free_programming.md b/documentation/bookmark/concurrency/lock_free_programming.md
new file mode 100644
index 000000000..902dbb360
--- /dev/null
+++ b/documentation/bookmark/concurrency/lock_free_programming.md
@@ -0,0 +1,13 @@
+# Reference
+
+0. [Building a Lock-free Multi-producer, Multi-consumer Queue for Tcmalloc - Matt Kulukundis - CppCon 21](https://www.youtube.com/watch?v=_qaKkHuHYE0)
+0. [Fear and Loathing in Lock-Free Programming](https://medium.com/@tylerneely/fear-and-loathing-in-lock-free-programming-7158b1cdd50c)
+0. [Transactional Memory: Architectural Support for Lock-Free Data Structures](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.491.1948&rep=rep1&type=pdf)
+0. [YOW! 2012 Martin Thompson - Lock-free Algorithms for Ultimate Performance](https://www.youtube.com/watch?v=_uUkApe_yIk)
+0. [Adaptive Lock-Free Data Structures in Haskell: A General Method for Conc. Implementation Swapping](https://www.youtube.com/watch?v=kzR5-t7LMbQ)
+0. [John Valois on Wait-Free Synchronization [PWL NYC]](https://www.youtube.com/watch?v=7end3rQ0jkk)
+0. [An Introduction to Lock-Free Programming](https://preshing.com/20120612/an-introduction-to-lock-free-programming/)
+0. [How Lock-free Data Structures Performin Dynamic Environments: Models and Analyses](https://arxiv.org/pdf/1611.05793v1.pdf)
+0. [Awesome Lock-Free](https://github.com/rigtorp/awesome-lockfree)
+0. [An introduction to lockless algorithms](https://lwn.net/Articles/844224/)
+
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux
index 716c2745d..20bf0bc43 100644
--- a/lux-ruby/source/program.lux
+++ b/lux-ruby/source/program.lux
@@ -47,7 +47,7 @@
[language
[lux
[program {"+" Program}]
- [generation {"+" Context Host}]
+ [generation {"+" Host}]
["[0]" synthesis]
[analysis
[macro {"+" Expander}]]
@@ -65,8 +65,8 @@
[default
["[0]" platform {"+" Platform}]]
[meta
- ["[0]" cli]
[archive {"+" Archive}]
+ ["[0]" cli]
["[0]" packager "_"
["[1]" ruby]]]]]]]
[program
diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux
index ee6daa975..494583650 100644
--- a/stdlib/source/library/lux/target/jvm/field.lux
+++ b/stdlib/source/library/lux/target/jvm/field.lux
@@ -60,8 +60,8 @@
[(binaryF.sequence/16 //attribute.writer) #attributes]))
)))
-(def: .public (field modifier name type with_signature? attributes)
- (-> (Modifier Field) UTF8 (Type Value) Bit (Sequence Attribute)
+(def: .public (field modifier name with_signature? type attributes)
+ (-> (Modifier Field) UTF8 Bit (Type Value) (Sequence Attribute)
(Resource Field))
(do [! //constant/pool.monad]
[@name (//constant/pool.utf8 name)
diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux
index 00647a199..c5011887a 100644
--- a/stdlib/source/library/lux/target/jvm/method.lux
+++ b/stdlib/source/library/lux/target/jvm/method.lux
@@ -50,14 +50,15 @@
["1000" synthetic]
)
-(def: .public (method modifier name type attributes code)
- (-> (Modifier Method) UTF8 (Type //category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any))
+(def: .public (method modifier name with_signature? type attributes code)
+ (-> (Modifier Method) UTF8 Bit (Type //category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any))
(Resource Method))
(do [! //pool.monad]
[@name (//pool.utf8 name)
@descriptor (//pool.descriptor (//type.descriptor type))
- attributes (|> attributes
- (list& (//attribute.signature (//type.signature type)))
+ attributes (|> (if with_signature?
+ (list& (//attribute.signature (//type.signature type)) attributes)
+ attributes)
(monad.all !)
(# ! each sequence.of_list))
attributes (case code
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 02b35d0e7..42d8b9958 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -197,11 +197,11 @@
state
(///directive.Operation <type_vars> Any)
- (do ///phase.monad
+ (do [! ///phase.monad]
[_ (///directive.lifted_analysis
- (///analysis.install analysis_state))
- _ (///directive.lifted_analysis
- (extension.with extender analysers))
+ (do !
+ [_ (///analysis.set_state analysis_state)]
+ (extension.with extender analysers)))
_ (///directive.lifted_synthesis
(extension.with extender synthesizers))
_ (///directive.lifted_generation
@@ -214,11 +214,10 @@
(def: (phase_wrapper archive platform state)
(All (_ <type_vars>)
(-> Archive <Platform> <State+> (Try [<State+> ///phase.Wrapper])))
- (let [phase_wrapper (value@ #phase_wrapper platform)]
- (|> archive
- phase_wrapper
- ///directive.lifted_generation
- (///phase.result' state))))
+ (|> archive
+ ((value@ #phase_wrapper platform))
+ ///directive.lifted_generation
+ (///phase.result' state)))
(def: (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives])
(All (_ <type_vars>)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
index 116d84299..2d231f1cc 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
@@ -256,8 +256,8 @@
{try.#Success [[bundle' (with@ .#source old_source state')]
output]}
- {try.#Failure error}
- {try.#Failure error}))))
+ failure
+ failure))))
(def: .public (with_current_module name)
(All (_ a) (-> Text (Operation a) (Operation a)))
@@ -276,8 +276,8 @@
{try.#Success [[bundle' (with@ .#location old_location state')]
output]}
- {try.#Failure error}
- {try.#Failure error})))))
+ failure
+ failure)))))
(def: (locate_error location error)
(-> Location Text Text)
@@ -299,7 +299,7 @@
(# phase.monad in [])
(..except exception parameters)))
-(def: .public (with_stack exception message action)
+(def: .public (with_exception exception message action)
(All (_ e o) (-> (Exception e) e (Operation o) (Operation o)))
(function (_ bundle,state)
(.case (exception.with exception message
@@ -308,10 +308,10 @@
(let [[bundle state] bundle,state]
{try.#Failure (locate_error (value@ .#location state) error)})
- output
- output)))
+ success
+ success)))
-(def: .public (install state)
+(def: .public (set_state state)
(-> .Lux (Operation Any))
(function (_ [bundle _])
{try.#Success [[bundle state]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux
index 1d903e7d6..893f9df5a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux
@@ -119,7 +119,7 @@
{.#Function inputT outputT}
(do phase.monad
[[outputT' args'A] (general archive analyse outputT args')
- argA (<| (/.with_stack ..cannot_infer_argument [inputT argC])
+ argA (<| (/.with_exception ..cannot_infer_argument [inputT argC])
(/type.expecting inputT)
(analyse archive argC))]
(in [outputT' (list& argA args'A)]))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux
index 678a626da..726860314 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux
@@ -106,7 +106,7 @@
(do [! ///.monad]
[expectedT (///extension.lifted meta.expected_type)
expectedT' (/type.check (check.clean expectedT))]
- (/.with_stack ..cannot_analyse_variant [expectedT' lefts right? valueC]
+ (/.with_exception ..cannot_analyse_variant [expectedT' lefts right? valueC]
(case expectedT
{.#Sum _}
(|> (analyse archive valueC)
@@ -221,7 +221,7 @@
(-> Phase Archive (List Code) (Operation Analysis))
(do [! ///.monad]
[expectedT (///extension.lifted meta.expected_type)]
- (/.with_stack ..cannot_analyse_tuple [expectedT membersC]
+ (/.with_exception ..cannot_analyse_tuple [expectedT membersC]
(case expectedT
{.#Product _}
(..typed_product analyse expectedT archive membersC)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
index 63c315954..347604a35 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux
@@ -51,7 +51,7 @@
(do [! ///.monad]
[functionT (///extension.lifted meta.expected_type)]
(loop [expectedT functionT]
- (/.with_stack ..cannot_analyse [expectedT function_name arg_name body]
+ (/.with_exception ..cannot_analyse [expectedT function_name arg_name body]
(case expectedT
{.#Named name unnamedT}
(again unnamedT)
@@ -108,7 +108,7 @@
(def: .public (apply analyse argsC+ functionT functionA archive functionC)
(-> Phase (List Code) Type Analysis Phase)
- (<| (/.with_stack ..cannot_apply [functionT functionC argsC+])
+ (<| (/.with_exception ..cannot_apply [functionT functionC argsC+])
(do ///.monad
[[applyT argsA+] (/inference.general archive analyse functionT argsC+)])
(in (/.reified [functionA argsA+]))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index fa1a73e1e..a7d889777 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -2333,7 +2333,7 @@
(do pool.monad
[constant (`` (|> value (~~ (template.spliced <constant>))))
attribute (attribute.constant constant)]
- (field.field ..constant::modifier name <type> true (sequence.sequence attribute)))])
+ (field.field ..constant::modifier name #1 <type> (sequence.sequence attribute)))])
([.#Bit jvm.boolean [(case> #0 +0 #1 +1) .i64 i32.i32 constant.integer pool.integer]]
[.#Int jvm.byte [.i64 i32.i32 constant.integer pool.integer]]
[.#Int jvm.short [.i64 i32.i32 constant.integer pool.integer]]
@@ -2352,7 +2352,7 @@
... TODO: Handle annotations.
{#Variable [name visibility state annotations type]}
(field.field (modifier#composite visibility state)
- name type true sequence.empty)))
+ name #1 type sequence.empty)))
(def: method_privacy
(-> ffi.Privacy (Modifier method.Method))
@@ -2421,7 +2421,7 @@
method.strict
modifier.empty))
..constructor_name
- (jvm.method [variables (list#each product.right arguments) jvm.void exceptions])
+ #0 (jvm.method [variables (list#each product.right arguments) jvm.void exceptions])
(list)
{.#Some ($_ _.composite
(_.aload 0)
@@ -2442,7 +2442,7 @@
method.strict
modifier.empty))
name
- (jvm.method [variables (list#each product.right arguments) return exceptions])
+ #0 (jvm.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -2458,7 +2458,7 @@
method.final
modifier.empty))
name
- (jvm.method [variables (list#each product.right arguments) return exceptions])
+ #0 (jvm.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -2472,7 +2472,7 @@
method.strict
modifier.empty))
name
- (jvm.method [variables (list#each product.right arguments) return exceptions])
+ #0 (jvm.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -2482,7 +2482,7 @@
method.abstract
(..method_privacy privacy))
name
- (jvm.method [variables (list#each product.right arguments) return exceptions])
+ #0 (jvm.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#None})
))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
index 49cb5d6f0..b0660d074 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
@@ -229,7 +229,7 @@
(do pool.monad
[constant (`` (|> value (~~ (template.spliced <constant>))))
attribute (attribute.constant constant)]
- (field.field ..constant::modifier name <type> true (sequence.sequence attribute)))])
+ (field.field ..constant::modifier name #1 <type> (sequence.sequence attribute)))])
([.#Bit type.boolean [(case> #0 +0 #1 +1) .i64 i32.i32 constant.integer pool.integer]]
[.#Int type.byte [.i64 i32.i32 constant.integer pool.integer]]
[.#Int type.short [.i64 i32.i32 constant.integer pool.integer]]
@@ -248,7 +248,7 @@
... TODO: Handle annotations.
{#Variable [name visibility state annotations type]}
(field.field (modifier#composite visibility state)
- name type true sequence.empty)))
+ name #1 type sequence.empty)))
(def: annotation_parameter_synthesis
(<synthesis>.Parser (jvm.Annotation_Parameter Synthesis))
@@ -498,7 +498,7 @@
method.strict
modifier.empty))
..constructor_name
- (type.method [method_tvars argumentsT type.void exceptions])
+ #1 (type.method [method_tvars argumentsT type.void exceptions])
(list)
{.#Some ($_ _.composite
(_.aload 0)
@@ -564,7 +564,7 @@
method.strict
modifier.empty))
method_name
- (type.method [method_tvars argumentsT returnJ exceptionsJ])
+ #1 (type.method [method_tvars argumentsT returnJ exceptionsJ])
(list)
{.#Some ($_ _.composite
(method_arguments 1 argumentsT)
@@ -591,7 +591,7 @@
method.final
modifier.empty))
method_name
- (type.method [method_tvars argumentsT returnJ exceptionsJ])
+ #1 (type.method [method_tvars argumentsT returnJ exceptionsJ])
(list)
{.#Some ($_ _.composite
(method_arguments 1 argumentsT)
@@ -616,7 +616,7 @@
method.strict
modifier.empty))
method_name
- (type.method [method_tvars argumentsT returnJ exceptionsJ])
+ #1 (type.method [method_tvars argumentsT returnJ exceptionsJ])
(list)
{.#Some ($_ _.composite
(method_arguments 0 argumentsT)
@@ -631,7 +631,7 @@
(..method_privacy privacy)
method.abstract)
name
- (type.method [variables (list#each product.right arguments) return exceptions])
+ #1 (type.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#None})))
@@ -774,7 +774,7 @@
method.strict
modifier.empty))
..constructor_name
- (type.method [variables (list#each product.right arguments) type.void exceptions])
+ #1 (type.method [variables (list#each product.right arguments) type.void exceptions])
(list)
{.#Some ($_ _.composite
(_.aload 0)
@@ -795,7 +795,7 @@
method.strict
modifier.empty))
name
- (type.method [variables (list#each product.right arguments) return exceptions])
+ #1 (type.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -811,7 +811,7 @@
method.final
modifier.empty))
name
- (type.method [variables (list#each product.right arguments) return exceptions])
+ #1 (type.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -825,7 +825,7 @@
method.strict
modifier.empty))
name
- (type.method [variables (list#each product.right arguments) return exceptions])
+ #1 (type.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#Some (..mock_return return)})
@@ -835,7 +835,7 @@
method.abstract
(..method_privacy privacy))
name
- (type.method [variables (list#each product.right arguments) return exceptions])
+ #1 (type.method [variables (list#each product.right arguments) return exceptions])
(list)
{.#None})
))
@@ -943,7 +943,7 @@
method.public
method.abstract)
/#name
- type
+ #1 type
(list)
{.#None})))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
index 6f35d182a..4b4956d82 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
@@ -1028,7 +1028,8 @@
(_.aload 0)
(_.aload (n.+ inputs_offset (++ register)))
(_.putfield class (///reference.foreign_name register) $Object)))))]
- (method.method method.public "<init>" (anonymous_init_method env inputsTG)
+ (method.method method.public "<init>"
+ #1 (anonymous_init_method env inputsTG)
(list)
{.#Some ($_ _.composite
(_.aload 0)
@@ -1212,7 +1213,7 @@
method.strict
modifier#identity))
name
- methodT
+ #1 methodT
(list)
{.#Some ($_ _.composite
(prepare_arguments 1 argumentsT)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
index 10bf59a29..7d0bc8ae0 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux
@@ -23,4 +23,4 @@
(def: .public (constant name type)
(-> Text (Type Value) (Resource Field))
- (field.field ..modifier name type false (sequence.sequence)))
+ (field.field ..modifier name #0 type (sequence.sequence)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
index cc22b43b9..4e0684215 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
@@ -46,7 +46,7 @@
(def: .public (variable name type)
(-> Text (Type Value) (Resource Field))
- (field.field ..modifier name type false (sequence.sequence)))
+ (field.field ..modifier name #0 type (sequence.sequence)))
(def: .public (variables naming amount)
(-> (-> Register Text) Nat (List (Resource Field)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
index a7f0d7ac6..5020c98c0 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux
@@ -84,7 +84,7 @@
over_extent (i.- (.int apply_arity)
(.int function_arity))]
(method.method //.modifier ////runtime.apply::name
- (////runtime.apply::type apply_arity)
+ #0 (////runtime.apply::type apply_arity)
(list)
{.#Some (case num_partials
0 ($_ _.composite
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
index 6c8a9ee75..22e3a8b0d 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux
@@ -30,7 +30,7 @@
(def: .public (method' name arity @begin body)
(-> Text Arity Label (Bytecode Any) (Resource Method))
(method.method //.modifier name
- (..type arity)
+ #0 (..type arity)
(list)
{.#Some ($_ _.composite
(_.set_label @begin)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux
index 37278725b..14d2fdc03 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux
@@ -94,7 +94,7 @@
offset_partial (: (-> Register Register)
(|>> offset_arity (n.+ 1)))]
(method.method //.modifier ..name
- (..type environment arity)
+ #0 (..type environment arity)
(list)
{.#Some ($_ _.composite
////reference.this
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux
index 5c03b472b..3edbe1e05 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux
@@ -68,7 +68,7 @@
after_arity (: (-> Nat Nat)
(|>> after_environment (n.+ 1)))]
(method.method //.modifier //init.name
- (//init.type environment arity)
+ #0 (//init.type environment arity)
(list)
{.#Some ($_ _.composite
////reference.this
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
index d1a78ce86..037f2958d 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
@@ -41,7 +41,7 @@
(def: .public (method class environment arity)
(-> (Type Class) (Environment Synthesis) Arity (Resource Method))
(method.method //.modifier ..name
- (..type class)
+ #0 (..type class)
(list)
{.#Some ($_ _.composite
(if (arity.multiary? arity)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
index e232874c4..e852b63a3 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
@@ -125,8 +125,9 @@
(encoding/name.internal bytecode_name)
{.#None}
(encoding/name.internal "java.lang.Object") (list)
- (list (field.field ..value::modifier ..value::field ..value::type false (sequence.sequence)))
- (list (method.method ..init::modifier "<clinit>" ..init::type
+ (list (field.field ..value::modifier ..value::field #0 ..value::type (sequence.sequence)))
+ (list (method.method ..init::modifier "<clinit>"
+ #0 ..init::type
(list)
{.#Some
($_ _.composite
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux
index 7f72697ca..23ec9402e 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux
@@ -144,7 +144,8 @@
(def: .public (program artifact_name context program)
(-> (-> unit.ID Text) (Program (Bytecode Any) Definition))
(let [super_class (|> ..^Object type.reflection reflection.reflection name.internal)
- main (method.method ..main::modifier "main" ..main::type
+ main (method.method ..main::modifier "main"
+ #0 ..main::type
(list)
{.#Some ($_ _.composite
program
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
index 55cbcdb67..fc96c025f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
@@ -154,7 +154,7 @@
$right? _.aload_1
$value _.aload_2]
(method.method ..modifier ..variant::name
- ..variant::type
+ #0 ..variant::type
(list)
{.#Some ($_ _.composite
new_variant ... A[3]
@@ -216,7 +216,7 @@
(def: decode_frac::method
(method.method ..modifier ..decode_frac::name
- ..decode_frac::type
+ #0 ..decode_frac::type
(list)
{.#Some
(..risky
@@ -253,7 +253,7 @@
(def: (failure name message)
(-> Text Text (Resource Method))
(method.method ..modifier name
- ..failure::type
+ #0 ..failure::type
(list)
{.#Some
($_ _.composite
@@ -275,7 +275,7 @@
(def: push::method
(method.method ..modifier ..push::name
- ..push::type
+ #0 ..push::type
(list)
{.#Some
(let [new_stack_frame! ($_ _.composite
@@ -294,7 +294,8 @@
(def: .public case (..procedure ..case::name ..case::type))
(def: case::method
- (method.method ..modifier ..case::name ..case::type
+ (method.method ..modifier ..case::name
+ #0 ..case::type
(list)
{.#Some
(do _.monad
@@ -405,7 +406,8 @@
(_.goto @loop))))
left_projection::method
- (method.method ..modifier ..left_projection::name ..projection_type
+ (method.method ..modifier ..left_projection::name
+ #0 ..projection_type
(list)
{.#Some
(do _.monad
@@ -424,7 +426,8 @@
(recur @loop)))})
right_projection::method
- (method.method ..modifier ..right_projection::name ..projection_type
+ (method.method ..modifier ..right_projection::name
+ #0 ..projection_type
(list)
{.#Some
(do _.monad
@@ -479,7 +482,8 @@
(def: true _.iconst_1)
(def: try::method
- (method.method ..modifier ..try::name ..try::type
+ (method.method ..modifier ..try::name
+ #0 ..try::type
(list)
{.#Some
(do _.monad
@@ -573,7 +577,8 @@
(++ //function/arity.minimum)
//function/arity.maximum)
(list#each (function (_ arity)
- (method.method method.public ..apply::name (..apply::type arity)
+ (method.method method.public ..apply::name
+ #0 (..apply::type arity)
(list)
{.#Some
(let [previous_inputs (|> arity
@@ -587,10 +592,12 @@
(_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum))
_.areturn))})))
(list& (method.method (modifier#composite method.public method.abstract)
- ..apply::name (..apply::type //function/arity.minimum)
+ ..apply::name
+ #0 (..apply::type //function/arity.minimum)
(list)
{.#None})))
- <init>::method (method.method method.public "<init>" //function.init
+ <init>::method (method.method method.public "<init>"
+ #0 //function.init
(list)
{.#Some
(let [$partials _.iload_1]
@@ -609,7 +616,7 @@
partial_count (: (Resource Field)
(field.field (modifier#composite field.public field.final)
//function/count.field
- //function/count.type .false
+ #0 //function/count.type
sequence.empty))
bytecode (<| (format.result class.writer)
try.trusted
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
index 2e9deb0e4..1e427dbfc 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux
@@ -21,7 +21,7 @@
["//[1]" /// "_"
[synthesis {"+" Synthesis}]
[analysis {"+" Environment Abstraction Reification Analysis}]
- ["[1][0]" generation {"+" Context}]
+ ["[1][0]" generation]
["//[1]" /// "_"
[arity {"+" Arity}]
["[1][0]" phase]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
index 8a3196fb2..5249d2c55 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux
@@ -37,7 +37,7 @@
[variable {"+" Register}]]
[meta
[archive {"+" Output Archive}
- ["[0]" artifact]
+ ["[0]" unit]
["[0]" registry {"+" Registry}]]]]]])
(template [<name> <base>]
@@ -399,59 +399,19 @@
(_.- extra)
(_./ parameter)))))
-(def: i16##high
- (_.bit_shr (_.int +16)))
-
-(def: i16##low
- (_.bit_and (_.manual "+0xFFFF")))
-
-(def: i16##up
- (_.bit_shl (_.int +16)))
-
(runtime: (i64##+ parameter subject)
[..normal_ruby? (_.return (i64##i64 (_.+ parameter subject)))]
- (let [hh (|>> i32##high i16##high)
- hl (|>> i32##high i16##low)
- lh (|>> i32##low i16##high)
- ll (|>> i32##low i16##low)]
- (with_vars [l48 l32 l16 l00
- r48 r32 r16 r00
- x48 x32 x16 x00
- high low]
- ($_ _.then
- (_.set (list l48) (hh subject))
- (_.set (list l32) (hl subject))
- (_.set (list l16) (lh subject))
- (_.set (list l00) (ll subject))
-
- (_.set (list r48) (hh parameter))
- (_.set (list r32) (hl parameter))
- (_.set (list r16) (lh parameter))
- (_.set (list r00) (ll parameter))
-
- (_.set (list x00) (_.+ l00 r00))
-
- (_.set (list x16) (|> (i16##high x00)
- (_.+ l16)
- (_.+ r16)))
- (_.set (list x00) (i16##low x00))
-
- (_.set (list x32) (|> (i16##high x16)
- (_.+ l32)
- (_.+ r32)))
- (_.set (list x16) (i16##low x16))
-
- (_.set (list x48) (|> (i16##high x32)
- (_.+ l48)
- (_.+ r48)
- i16##low))
- (_.set (list x32) (i16##low x32))
-
- (_.set (list high) (_.bit_or (i16##up x48) x32))
- (_.set (list low) (_.bit_or (i16##up x16) x00))
- (_.return (..i64 high low))
- )))
- )
+ (with_vars [high low]
+ ($_ _.then
+ (_.set (list low) (_.+ (i32##low subject)
+ (i32##low parameter)))
+ (_.set (list high) (|> (i32##high low)
+ (_.+ (i32##high subject))
+ (_.+ (i32##high parameter))
+ i32##low))
+
+ (_.return (..i64 high (i32##low low)))
+ )))
(def: i64##min
(_.manual "-0x8000000000000000"))
@@ -465,6 +425,15 @@
[..normal_ruby? (_.return (i64##i64 (_.- parameter subject)))]
(_.return (i64##+ (i64##opposite parameter) subject)))
+(def: i16##high
+ (_.bit_shr (_.int +16)))
+
+(def: i16##low
+ (_.bit_and (_.manual "+0xFFFF")))
+
+(def: i16##up
+ (_.bit_shl (_.int +16)))
+
(runtime: (i64##* parameter subject)
[..normal_ruby? (_.return (i64##i64 (_.* parameter subject)))]
(let [hh (|>> i32##high i16##high)
@@ -623,7 +592,7 @@
[_ (/////generation.execute! ..runtime)
_ (/////generation.save! ..module_id {.#None} ..runtime)]
(in [(|> registry.empty
- (registry.resource true artifact.no_dependencies)
+ (registry.resource true unit.none)
product.right)
(sequence.sequence [..module_id
{.#None}
diff --git a/stdlib/source/library/lux/tool/compiler/meta/export.lux b/stdlib/source/library/lux/tool/compiler/meta/export.lux
new file mode 100644
index 000000000..79c5a2a44
--- /dev/null
+++ b/stdlib/source/library/lux/tool/compiler/meta/export.lux
@@ -0,0 +1,71 @@
+(.using
+ [library
+ [lux {"-" Source}
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" try {"+" Try} ("[1]#[0]" monad)]
+ [concurrency
+ ["[0]" async {"+" Async} ("[1]#[0]" functor)]]]
+ [data
+ ["[0]" text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" dictionary]
+ ["[0]" sequence]]
+ [format
+ ["[0]" binary]
+ ["[0]" tar]]]
+ [time
+ ["[0]" instant]]
+ [tool
+ [compiler
+ [meta
+ [cli {"+" Source Export}]
+ ["[0]" io "_"
+ ["[1]" context]]]]]
+ [world
+ ["[0]" file]]]])
+
+(def: .public file
+ "library.tar")
+
+(def: commons
+ tar.Ownership
+ (let [commons (: tar.Owner
+ [tar.#name tar.anonymous
+ tar.#id tar.no_id])]
+ [tar.#user commons
+ tar.#group commons]))
+
+(def: .public (library fs sources)
+ (-> (file.System Async) (List Source) (Async (Try tar.Tar)))
+ (|> sources
+ (io.listing fs)
+ (async#each (|>> (try#each (|>> dictionary.entries
+ (monad.each try.monad
+ (function (_ [path source_code])
+ (do try.monad
+ [path (|> path
+ (text.replaced (# fs separator) .module_separator)
+ tar.path)]
+ (try#each (|>> [path
+ (instant.of_millis +0)
+ ($_ tar.and
+ tar.read_by_owner tar.write_by_owner
+ tar.read_by_group tar.write_by_group
+ tar.read_by_other)
+ ..commons]
+ {tar.#Normal})
+ (tar.content source_code)))))
+ (try#each sequence.of_list)))
+ try#conjoint))))
+
+(def: .public (export fs [sources target])
+ (-> (file.System Async) Export (Async (Try Any)))
+ (do [! (try.with async.monad)]
+ [tar (|> sources
+ (..library fs)
+ (# ! each (binary.result tar.writer)))
+ .let [/ (# fs separator)]]
+ (# fs write tar (format target / ..file))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
index 400c9e6d2..2f99ddce1 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
@@ -45,7 +45,7 @@
(type: .public Extension
Text)
-(def: lux_extension
+(def: .public lux_extension
Extension
".lux")
@@ -151,7 +151,7 @@
(if (text.ends_with? ..lux_extension file)
(do !
[source_code (# fs read file)]
- (async#in (dictionary.has' (text.replaced context "" file) source_code enumeration)))
+ (async#in (dictionary.has' (text.replaced/1 context "" file) source_code enumeration)))
(in enumeration)))
enumeration))
(# ! conjoint))]
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index b2a5f4d15..55da4161b 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -40,8 +40,9 @@
[phase
[extension {"+" Extender}]]]]
[meta
- ["[0]" cli {"+" Service}]
[packager {"+" Packager}]
+ ["[0]" cli {"+" Service}]
+ ["[0]" export]
[archive {"+" Archive}
["[0]" unit]
[module
@@ -52,7 +53,6 @@
]]]
["[0]" / "_"
["[1][0]" static {"+" Static}]
- ["[1][0]" export]
["[1][0]" import]])
(def: (or_crash! failure_description action)
@@ -185,8 +185,8 @@
{cli.#Export export}
(<| (or_crash! "Export failed:")
(do (try.with async.monad)
- [_ (/export.export (value@ platform.#&file_system platform)
- export)]
+ [_ (export.export (value@ platform.#&file_system platform)
+ export)]
(in (debug.log! "Export complete!"))))
{cli.#Interpretation interpretation}
diff --git a/stdlib/source/program/compositor/export.lux b/stdlib/source/program/compositor/export.lux
deleted file mode 100644
index 4ac08f423..000000000
--- a/stdlib/source/program/compositor/export.lux
+++ /dev/null
@@ -1,71 +0,0 @@
-(.using
- [library
- [lux {"-" Source}
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" try {"+" Try}]
- [concurrency
- ["[0]" async {"+" Async}]]]
- [data
- ["[0]" text
- ["%" format {"+" format}]]
- [collection
- ["[0]" dictionary]
- ["[0]" sequence]]
- [format
- ["[0]" binary]
- ["[0]" tar]]]
- [time
- ["[0]" instant]]
- [tool
- [compiler
- [meta
- [cli {"+" Source Export}]
- ["[0]" io "_"
- ["[1]" context {"+" Extension}]]]]]
- [world
- ["[0]" file]]]])
-
-(def: file
- "library.tar")
-
-(def: no_ownership
- tar.Ownership
- (let [commons (: tar.Owner
- [tar.#name tar.anonymous
- tar.#id tar.no_id])]
- [tar.#user commons
- tar.#group commons]))
-
-(def: .public (library fs sources)
- (-> (file.System Async) (List Source) (Async (Try tar.Tar)))
- (do (try.with async.monad)
- [files (io.listing fs sources)]
- (|> (dictionary.entries files)
- (monad.each try.monad
- (function (_ [path source_code])
- (do try.monad
- [path (|> path
- (text.replaced (# fs separator) .module_separator)
- tar.path)
- source_code (tar.content source_code)]
- (in {tar.#Normal [path
- (instant.of_millis +0)
- ($_ tar.and
- tar.read_by_owner tar.write_by_owner
- tar.read_by_group tar.write_by_group
- tar.read_by_other)
- ..no_ownership
- source_code]}))))
- (# try.monad each sequence.of_list)
- (# async.monad in))))
-
-(def: .public (export fs [sources target])
- (-> (file.System Async) Export (Async (Try Any)))
- (do [! (try.with async.monad)]
- [tar (# ! each (binary.result tar.writer)
- (..library fs sources))]
- (|> ..file
- (format target (# fs separator))
- (# fs write tar))))
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index b6762f168..6a85e0354 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -116,7 +116,7 @@
(list)
(list (/method.method ..method_modifier
method_name
- (/type.method [(list) (list) ..$Object (list)])
+ #0 (/type.method [(list) (list) ..$Object (list)])
(list)
{.#Some (do /.monad
[_ bytecode]
@@ -857,11 +857,11 @@
{.#None}
(/name.internal "java.lang.Object")
(list)
- (list (/field.field /field.static class_field /type.long false (sequence.sequence))
- (/field.field /field.public object_field /type.long false (sequence.sequence)))
+ (list (/field.field /field.static class_field #0 /type.long (sequence.sequence))
+ (/field.field /field.public object_field #0 /type.long (sequence.sequence)))
(list (/method.method /method.private
constructor
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -876,7 +876,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) (list) ..$Long (list)])
+ #0 (/type.method [(list) (list) ..$Long (list)])
(list)
{.#Some (do /.monad
[_ (/.new $Self)
@@ -1338,14 +1338,14 @@
(list)
(list (/method.method ..method_modifier
primitive_method_name
- primitive_method_type
+ #0 primitive_method_type
(list)
{.#Some (do /.monad
[_ ((value@ #literal primitive) expected)]
return)})
(/method.method ..method_modifier
object_method_name
- (/type.method [(list) (list) (value@ #boxed primitive) (list)])
+ #0 (/type.method [(list) (list) (value@ #boxed primitive) (list)])
(list)
{.#Some (do /.monad
[_ (/.invokestatic $Self primitive_method_name primitive_method_type)
@@ -1624,7 +1624,7 @@
(function (_ name value)
(/method.method /method.public
name
- method::type
+ #0 method::type
(list)
{.#Some (do /.monad
[_ (..$Long::literal value)]
@@ -1637,7 +1637,7 @@
(list)
(list)
(list (/method.method ($_ /modifier#composite /method.public /method.abstract)
- interface_method method::type (list) {.#None}))
+ interface_method #0 method::type (list) {.#None}))
(sequence.sequence))
try.trusted
(format.result /class.writer))
@@ -1649,7 +1649,7 @@
(list)
(list (/method.method /method.public
"<init>"
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -1658,7 +1658,7 @@
(method inherited_method part0)
(method overriden_method fake_part2)
(/method.method ($_ /modifier#composite /method.public /method.abstract)
- abstract_method method::type (list) {.#None}))
+ abstract_method #0 method::type (list) {.#None}))
(sequence.sequence))
try.trusted
(format.result /class.writer))
@@ -1675,7 +1675,7 @@
(list)
(list (/method.method /method.public
"<init>"
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -1689,7 +1689,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) (list) ..$Long (list)])
+ #0 (/type.method [(list) (list) ..$Long (list)])
(list)
{.#Some (do /.monad
[_ (/.new $Concrete)
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 9d9d6c3a2..0f42f81db 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -22,7 +22,8 @@
]]]
["[1][0]" meta "_"
["[1]/[0]" archive]
- ["[1]/[0]" cli]]
+ ["[1]/[0]" cli]
+ ["[1]/[0]" export]]
]])
(def: .public test
@@ -35,6 +36,7 @@
/analysis.test
/meta/archive.test
/meta/cli.test
+ /meta/export.test
/phase/extension.test
/phase/analysis/simple.test
/phase/analysis/complex.test
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
index 135ac5840..858a294ae 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
@@ -9,6 +9,7 @@
["$[0]" equivalence]]]
[control
[pipe {"+" case>}]
+ ["[0]" function]
["[0]" maybe]
["[0]" try]
["[0]" exception {"+" exception:}]]
@@ -240,46 +241,73 @@
(def: test|phase
Test
(do random.monad
- [version random.nat
- host (random.ascii/lower 5)
+ [version/0 random.nat
+ host/0 (random.ascii/lower 5)
+ version/1 random.nat
+ host/1 (random.ascii/lower 5)
expected_error (random.ascii/lower 10)
- location /location.random
- .let [state (with@ .#location location
- (/.state (/.info version host)))]]
+ location/0 /location.random
+ location/1 /location.random
+ .let [state/0 (with@ .#location location/0
+ (/.state (/.info version/0 host/0)))
+ state/1 (with@ .#location location/1
+ (/.state (/.info version/1 host/1)))]]
($_ _.and
+ (_.cover [/.set_state]
+ (|> (do phase.monad
+ [pre (extension.read function.identity)
+ _ (/.set_state state/1)
+ post (extension.read function.identity)]
+ (in (and (same? state/0 pre)
+ (same? state/1 post))))
+ (phase.result [extension.#bundle extension.empty
+ extension.#state state/0])
+ (try.else false)))
(_.cover [/.failure]
(|> (/.failure expected_error)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? expected_error actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
_
false)))
(_.cover [/.except]
(|> (/.except <exception> [])
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? (exception.error <exception> []) actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
+
+ _
+ false)))
+ (_.cover [/.with_exception]
+ (|> (/.failure expected_error)
+ (/.with_exception <exception> [])
+ (phase.result [extension.#bundle extension.empty
+ extension.#state state/0])
+ (case> {try.#Failure actual_error}
+ (and (text.contains? expected_error actual_error)
+ (text.contains? (exception.error <exception> []) actual_error)
+ (text.contains? (location.format location/0) actual_error))
_
false)))
(_.cover [/.assertion]
(and (|> (/.assertion <exception> [] false)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? (exception.error <exception> []) actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
_
false))
(|> (/.assertion <exception> [] true)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Success _}
true
diff --git a/stdlib/source/test/lux/tool/compiler/meta/export.lux b/stdlib/source/test/lux/tool/compiler/meta/export.lux
new file mode 100644
index 000000000..11a6ea9ce
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/export.lux
@@ -0,0 +1,115 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ [pipe {"+" case>}]
+ ["[0]" try ("[1]#[0]" functor)]
+ [concurrency
+ ["[0]" async]]
+ [parser
+ ["<[0]>" binary]]]
+ [data
+ ["[0]" product]
+ ["[0]" binary {"+" Binary} ("[1]#[0]" equivalence)]
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ [format
+ ["[0]" tar]]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]
+ [encoding
+ ["[0]" utf8]]]
+ [collection
+ ["[0]" sequence]]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]]]
+ [world
+ ["[0]" file]]]]
+ [\\library
+ ["[0]" /
+ [//
+ ["[0]" io "_"
+ ["[1]" context]]]]])
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [.let [/ .module_separator]
+ source/0 (random.ascii/lower 1)
+ source/1 (random.ascii/lower 2)
+ target (random.ascii/lower 3)
+
+ .let [random_file (: (Random file.Path)
+ (# ! each (text.suffix io.lux_extension) (random.ascii/lower 4)))]
+ file/0' random_file
+ .let [file/0 (format source/0 / file/0')]
+
+ dir/0 (random.ascii/lower 5)
+ file/1' (# ! each (|>> (format dir/0 /)) random_file)
+ .let [file/1 (format source/1 / file/1')]
+
+ .let [random_content (: (Random Binary)
+ (# ! each (|>> %.nat (# utf8.codec encoded)) random.nat))]
+ content/0 random_content
+ content/1 random_content]
+ ($_ _.and
+ (in (do [! async.monad]
+ [it (do (try.with !)
+ [.let [fs (file.mock /)]
+ _ (# fs make_directory source/0)
+ _ (# fs write content/0 file/0)
+
+ _ (# fs make_directory source/1)
+ _ (# fs make_directory (format source/1 / dir/0))
+ _ (# fs write content/1 file/1)
+
+ _ (# fs make_directory target)
+ library_tar (/.library fs (list source/0 source/1))
+ _ (/.export fs [(list source/0 source/1) target])
+ export_tar (# fs read (format target / /.file))
+ export_tar (# ! in (<binary>.result tar.parser export_tar))]
+ (in [library_tar export_tar]))]
+ ($_ _.and'
+ (_.cover' [/.library]
+ (|> it
+ (try#each (|>> product.left
+ sequence.list
+ (case> (^ (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
+ {tar.#Normal [actual_path/1 _ _ _ actual_content/1]}))
+ (with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
+ (binary#= content/0 (tar.data actual_content/0)))
+ (and (text#= file/1' (tar.from_path actual_path/1))
+ (binary#= content/1 (tar.data actual_content/1))))]
+ (or <test>
+ (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+ [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+ <test>)))
+
+ _
+ false)))
+ (try.else false)))
+ (_.cover' [/.export /.file]
+ (|> it
+ (try#each (|>> product.right
+ sequence.list
+ (case> (^ (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
+ {tar.#Normal [actual_path/1 _ _ _ actual_content/1]}))
+ (with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
+ (binary#= content/0 (tar.data actual_content/0)))
+ (and (text#= file/1' (tar.from_path actual_path/1))
+ (binary#= content/1 (tar.data actual_content/1))))]
+ (or <test>
+ (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+ [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+ <test>)))
+
+ _
+ false)))
+ (try.else false)))
+ )))
+ ))))