aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2022-01-09 05:35:12 -0400
committerEduardo Julian2022-01-09 05:35:12 -0400
commitb7873d4b68ffc041f9ff134c52a32b54c20febf9 (patch)
treeb4892c00eee2e57ebd763b646dc4a89796235000 /stdlib
parent54e219ee24c1508713d07473cd8a3b04c7f8fe18 (diff)
Fixed a bug when testing extensions on the JVM compiler.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux24
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux54
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux233
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux20
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux13
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux1
-rw-r--r--stdlib/source/test/lux/extension.lux53
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux1
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux56
17 files changed, 304 insertions, 181 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
index 6d86b681f..0a9bf90bb 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
@@ -33,7 +33,6 @@
["[1][0]" loop]
["[1][0]" function]]]
[//
- [analysis {"+" }]
["[0]" synthesis {"+" %synthesis}]
[///
["[1]" phase ("[1]#[0]" monad)]]]]])
@@ -127,6 +126,9 @@
(^ (synthesis.branch/case case))
(//case.case! statement expression archive case)
+ (^ (synthesis.branch/exec it))
+ (//case.exec! statement expression archive it)
+
(^ (synthesis.branch/let let))
(//case.let! statement expression archive let)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index bcaa03ee6..15bc133a7 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -87,6 +87,9 @@
(^ (synthesis.branch/case case))
(//case.case! statement expression archive case)
+ (^ (synthesis.branch/exec it))
+ (//case.exec! statement expression archive it)
+
(^ (synthesis.branch/let let))
(//case.let! statement expression archive let)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
index 57cfbd1e4..af1b3b605 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux
@@ -55,6 +55,9 @@
(^ (synthesis.branch/case case))
(/case.case ///extension/common.statement expression archive case)
+ (^ (synthesis.branch/exec it))
+ (/case.exec expression archive it)
+
(^ (synthesis.branch/let let))
(/case.let expression archive let)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux
index c21dc12ec..b2d828de3 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" case let if}
+ [lux {"-" case exec let if}
[abstract
["[0]" monad {"+" do}]]
[control
@@ -36,6 +36,23 @@
(-> Register Var)
(|>> (///reference.local //reference.system) :expected))
+(def: .public (exec expression archive [this that])
+ (Generator [Synthesis Synthesis])
+ (do ///////phase.monad
+ [this (expression archive this)
+ that (expression archive that)]
+ (in (|> (_.array (list this that))
+ (_.at (_.int +1))))))
+
+(def: .public (exec! statement expression archive [this that])
+ (Generator! [Synthesis Synthesis])
+ (do ///////phase.monad
+ [this (expression archive this)
+ that (statement expression archive that)]
+ (in ($_ _.then
+ (_.statement this)
+ that))))
+
(def: .public (let expression archive [valueS register bodyS])
(Generator [Synthesis Register Synthesis])
(do ///////phase.monad
@@ -262,7 +279,10 @@
..peek_cursor)
then!])))
{.#Item item})]
- (in (_.cond clauses ..fail_pm!)))
+ (in (list#mix (function (_ [when then] else)
+ (_.if when then else))
+ ..fail_pm!
+ clauses)))
(^template [<tag> <format>]
[{<tag> item}
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
index ca4b71fa0..65e38cba2 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" Variant Tuple function}
+ [lux {"-" function}
[abstract
["[0]" monad {"+" do}]]
[data
@@ -18,7 +18,7 @@
["/[1]" // "_"
["[1][0]" reference]
["//[1]" /// "_"
- [analysis {"+" Variant Tuple Abstraction Application Analysis}]
+ [analysis {"+" Abstraction Application Analysis}]
[synthesis {"+" Synthesis}]
["[1][0]" generation {"+" Context}]
["//[1]" /// "_"
@@ -95,32 +95,32 @@
.let [[definition instantiation] (with_closure @self environment
($_ _.then
(_.define @num_args (_.the "length" @@arguments))
- (_.cond (list [(|> @num_args (_.= arityO))
- ($_ _.then
- initialize!
- (_.with_label (_.label @scope)
- (_.do_while (_.boolean true)
- body!)))]
- [(|> @num_args (_.> arityO))
- (let [arity_inputs (|> (_.array (list))
- (_.the "slice")
- (_.do "call" (list @@arguments (_.i32 +0) arityO)))
- extra_inputs (|> (_.array (list))
- (_.the "slice")
- (_.do "call" (list @@arguments arityO)))]
- (_.return (|> @self
- (apply_poly arity_inputs)
- (apply_poly extra_inputs))))])
- ... (|> @num_args (_.< arityO))
- (let [all_inputs (|> (_.array (list))
+ (<| (_.if (|> @num_args (_.= arityO))
+ ($_ _.then
+ initialize!
+ (_.with_label (_.label @scope)
+ (_.do_while (_.boolean true)
+ body!))))
+ (_.if (|> @num_args (_.> arityO))
+ (let [arity_inputs (|> (_.array (list))
(_.the "slice")
- (_.do "call" (list @@arguments)))]
- ($_ _.then
- (_.define @curried all_inputs)
- (_.return (_.closure (list)
- (let [@missing all_inputs]
- (_.return (apply_poly (_.do "concat" (list @missing) @curried)
- @self))))))))
+ (_.do "call" (list @@arguments (_.i32 +0) arityO)))
+ extra_inputs (|> (_.array (list))
+ (_.the "slice")
+ (_.do "call" (list @@arguments arityO)))]
+ (_.return (|> @self
+ (apply_poly arity_inputs)
+ (apply_poly extra_inputs)))))
+ ... (|> @num_args (_.< arityO))
+ (let [all_inputs (|> (_.array (list))
+ (_.the "slice")
+ (_.do "call" (list @@arguments)))]
+ ($_ _.then
+ (_.define @curried all_inputs)
+ (_.return (_.closure (list)
+ (let [@missing all_inputs]
+ (_.return (apply_poly (_.do "concat" (list @missing) @curried)
+ @self))))))))
))]
_ (/////generation.execute! definition)
_ (/////generation.save! (product.right function_name) {.#None} definition)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
index 1bf29150f..7be5cfb48 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
@@ -164,12 +164,12 @@
($_ _.then
(_.define last_index_right (..last_index tuple))
(_.define right_index (_.+ (_.i32 +1) lefts))
- (_.cond (list [(_.= last_index_right right_index)
- (_.return (_.at right_index tuple))]
- [(_.> last_index_right right_index)
- ... Needs recursion.
- <recur>])
- (_.return (_.do "slice" (list right_index) tuple)))
+ (<| (_.if (_.= last_index_right right_index)
+ (_.return (_.at right_index tuple)))
+ (_.if (_.> last_index_right right_index)
+ ... Needs recursion.
+ <recur>)
+ (_.return (_.do "slice" (list right_index) tuple)))
)))))
(def: .public variant_tag_field "_lux_tag")
@@ -202,23 +202,21 @@
(_.- (_.i32 +1))))
(_.set sum actual##value))]
(<| (_.while (_.boolean true))
- (_.cond (list [(_.= expected##lefts actual##lefts)
- (_.if (_.= expected##right? actual##right?)
- (_.return actual##value)
- mismatch!)]
-
- [(_.< expected##lefts actual##lefts)
- (_.if (_.= ..unit actual##right?)
- recur!
- mismatch!)]
-
- [(_.= ..unit expected##right?)
- (_.return (..variant (|> actual##lefts
- (_.- expected##lefts)
- (_.- (_.i32 +1)))
- actual##right?
- actual##value))])
- mismatch!))))
+ (_.if (_.= expected##lefts actual##lefts)
+ (_.if (_.= expected##right? actual##right?)
+ (_.return actual##value)
+ mismatch!))
+ (_.if (_.< expected##lefts actual##lefts)
+ (_.if (_.= ..unit actual##right?)
+ recur!
+ mismatch!))
+ (_.if (_.= ..unit expected##right?)
+ (_.return (..variant (|> actual##lefts
+ (_.- expected##lefts)
+ (_.- (_.i32 +1)))
+ actual##right?
+ actual##value)))
+ mismatch!)))
(def: left
(-> Expression Computation)
@@ -545,89 +543,84 @@
(|> (i64//< param subject)
(_.or (i64//= param subject))))
+(def: negative?
+ (i64//< i64//zero))
+
(runtime: (i64/// parameter subject)
- (let [negative? (function (_ value)
- (i64//< i64//zero value))
- valid_division_check [(i64//= i64//zero parameter)
- (_.throw (_.string "Cannot divide by zero!"))]
- short_circuit_check [(i64//= i64//zero subject)
- (_.return i64//zero)]]
- (_.cond (list valid_division_check
- short_circuit_check
-
- [(i64//= i64//min subject)
- (_.cond (list [(_.or (i64//= i64//one parameter)
- (i64//= i64//-one parameter))
- (_.return i64//min)]
- [(i64//= i64//min parameter)
- (_.return i64//one)])
- (with_vars [approximation]
- (let [subject/2 (..i64//arithmetic_right_shifted subject (_.i32 +1))]
- ($_ _.then
- (_.define approximation (i64//left_shifted (i64/// parameter
- subject/2)
- (_.i32 +1)))
- (_.if (i64//= i64//zero approximation)
- (_.return (_.? (negative? parameter)
- i64//one
- i64//-one))
- (let [remainder (i64//- (i64//* approximation
- parameter)
- subject)]
- (_.return (i64//+ (i64/// parameter
- remainder)
- approximation))))))))]
- [(i64//= i64//min parameter)
- (_.return i64//zero)]
-
- [(negative? subject)
- (_.return (_.? (negative? parameter)
- (i64/// (i64//opposite parameter)
- (i64//opposite subject))
- (i64//opposite (i64/// parameter
- (i64//opposite subject)))))]
-
- [(negative? parameter)
- (_.return (i64//opposite (i64/// (i64//opposite parameter) subject)))])
- (with_vars [result remainder]
- ($_ _.then
- (_.define result i64//zero)
- (_.define remainder subject)
- (_.while (i64//<= remainder parameter)
- (with_vars [approximate approximate_result approximate_remainder log2 delta]
- (let [approximate_result' (i64//of_number approximate)
- approx_remainder (i64//* parameter approximate_result)]
- ($_ _.then
- (_.define approximate (|> (i64//number remainder)
- (_./ (i64//number parameter))
- (_.apply/1 (_.var "Math.floor"))
- (_.apply/2 (_.var "Math.max") (_.i32 +1))))
- (_.define log2 (|> approximate
- (_.apply/1 (_.var "Math.log"))
- (_./ (_.var "Math.LN2"))
- (_.apply/1 (_.var "Math.ceil"))))
- (_.define delta (_.? (_.> (_.i32 +48) log2)
- (_.apply/2 (_.var "Math.pow")
- (_.i32 +2)
- (_.- (_.i32 +48)
- log2))
- (_.i32 +1)))
- (_.define approximate_result approximate_result')
- (_.define approximate_remainder approx_remainder)
- (_.while (_.or (negative? approximate_remainder)
- (i64//< approximate_remainder
- remainder))
- ($_ _.then
- (_.set approximate (_.- delta approximate))
- (_.set approximate_result approximate_result')
- (_.set approximate_remainder approx_remainder)))
- (_.set result (i64//+ (_.? (i64//= i64//zero approximate_result)
- i64//one
- approximate_result)
- result))
- (_.set remainder (i64//- approximate_remainder remainder))))))
- (_.return result)))
- )))
+ (<| (_.if (i64//= i64//zero parameter)
+ (_.throw (_.string "Cannot divide by zero!")))
+ (_.if (i64//= i64//zero subject)
+ (_.return i64//zero))
+ (_.if (i64//= i64//min subject)
+ (<| (_.if (_.or (i64//= i64//one parameter)
+ (i64//= i64//-one parameter))
+ (_.return i64//min))
+ (_.if (i64//= i64//min parameter)
+ (_.return i64//one))
+ (with_vars [approximation]
+ (let [subject/2 (..i64//arithmetic_right_shifted subject (_.i32 +1))]
+ ($_ _.then
+ (_.define approximation (i64//left_shifted (i64/// parameter
+ subject/2)
+ (_.i32 +1)))
+ (_.if (i64//= i64//zero approximation)
+ (_.return (_.? (..negative? parameter)
+ i64//one
+ i64//-one))
+ (let [remainder (i64//- (i64//* approximation
+ parameter)
+ subject)]
+ (_.return (i64//+ (i64/// parameter
+ remainder)
+ approximation)))))))))
+ (_.if (i64//= i64//min parameter)
+ (_.return i64//zero))
+ (_.if (..negative? subject)
+ (_.return (_.? (..negative? parameter)
+ (i64/// (i64//opposite parameter)
+ (i64//opposite subject))
+ (i64//opposite (i64/// parameter
+ (i64//opposite subject))))))
+ (_.if (..negative? parameter)
+ (_.return (i64//opposite (i64/// (i64//opposite parameter) subject))))
+ (with_vars [result remainder]
+ ($_ _.then
+ (_.define result i64//zero)
+ (_.define remainder subject)
+ (_.while (i64//<= remainder parameter)
+ (with_vars [approximate approximate_result approximate_remainder log2 delta]
+ (let [approximate_result' (i64//of_number approximate)
+ approx_remainder (i64//* parameter approximate_result)]
+ ($_ _.then
+ (_.define approximate (|> (i64//number remainder)
+ (_./ (i64//number parameter))
+ (_.apply/1 (_.var "Math.floor"))
+ (_.apply/2 (_.var "Math.max") (_.i32 +1))))
+ (_.define log2 (|> approximate
+ (_.apply/1 (_.var "Math.log"))
+ (_./ (_.var "Math.LN2"))
+ (_.apply/1 (_.var "Math.ceil"))))
+ (_.define delta (_.? (_.> (_.i32 +48) log2)
+ (_.apply/2 (_.var "Math.pow")
+ (_.i32 +2)
+ (_.- (_.i32 +48)
+ log2))
+ (_.i32 +1)))
+ (_.define approximate_result approximate_result')
+ (_.define approximate_remainder approx_remainder)
+ (_.while (_.or (..negative? approximate_remainder)
+ (i64//< approximate_remainder
+ remainder))
+ ($_ _.then
+ (_.set approximate (_.- delta approximate))
+ (_.set approximate_result approximate_result')
+ (_.set approximate_remainder approx_remainder)))
+ (_.set result (i64//+ (_.? (i64//= i64//zero approximate_result)
+ i64//one
+ approximate_result)
+ result))
+ (_.set remainder (i64//- approximate_remainder remainder))))))
+ (_.return result)))))
(runtime: (i64//% parameter subject)
(let [flat (|> subject
@@ -694,19 +687,19 @@
(let [console (_.var "console")
print (_.var "print")
end! (_.return ..unit)]
- (_.cond (list [(|> console _.type_of (_.= (_.string "undefined")) _.not
- (_.and (_.the "log" console)))
- ($_ _.then
- (_.statement (|> console (_.do "log" (list message))))
- end!)]
- [(|> print _.type_of (_.= (_.string "undefined")) _.not)
- ($_ _.then
- (_.statement (_.apply/1 print (_.? (_.= (_.string "string")
- (_.type_of message))
- message
- (_.apply/1 (_.var "JSON.stringify") message))))
- end!)])
- end!)))
+ (<| (_.if (|> console _.type_of (_.= (_.string "undefined")) _.not
+ (_.and (_.the "log" console)))
+ ($_ _.then
+ (_.statement (|> console (_.do "log" (list message))))
+ end!))
+ (_.if (|> print _.type_of (_.= (_.string "undefined")) _.not)
+ ($_ _.then
+ (_.statement (_.apply/1 print (_.? (_.= (_.string "string")
+ (_.type_of message))
+ message
+ (_.apply/1 (_.var "JSON.stringify") message))))
+ end!))
+ end!)))
(runtime: (io//error message)
(_.throw message))
@@ -733,7 +726,7 @@
(runtime: (js//delete object field)
($_ _.then
- (_.delete (_.at field object))
+ (_.statement (_.delete (_.at field object)))
(_.return object)))
(def: runtime//js
@@ -751,7 +744,7 @@
(runtime: (array//delete idx array)
($_ _.then
- (_.delete (_.at (_.the ..i64_low_field idx) array))
+ (_.statement (_.delete (_.at (_.the ..i64_low_field idx) array)))
(_.return array)))
(def: runtime//array
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
index 9aefc6a48..b1e96b617 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux
@@ -9,8 +9,9 @@
["[1][0]" runtime {"+" Operation Phase Generator}]
["[1][0]" primitive]
["///[1]" //// "_"
- [analysis {"+" Variant Tuple}]
["[1][0]" synthesis {"+" Synthesis}]
+ [analysis
+ [composite {"+" Variant Tuple}]]
["//[1]" ///
["[1][0]" phase ("[1]#[0]" monad)]]]])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
index 7ba6496cd..3319eb024 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux
@@ -55,6 +55,9 @@
(^ (synthesis.branch/case case))
(/case.case ///extension/common.statement expression archive case)
+ (^ (synthesis.branch/exec it))
+ (/case.exec expression archive it)
+
(^ (synthesis.branch/let let))
(/case.let expression archive let)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
index 16c8d5c19..dfb7908e7 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" case let if}
+ [lux {"-" case exec let if}
[abstract
["[0]" monad {"+" do}]]
[data
@@ -38,6 +38,24 @@
(-> Register Var)
(|>> (///reference.foreign //reference.system) :expected))
+(def: .public (exec expression archive [this that])
+ (Generator [Synthesis Synthesis])
+ (do ///////phase.monad
+ [this (expression archive this)
+ that (expression archive that)]
+ (in (|> (_.array (list this that))
+ (_.item (_.int +2))))))
+
+(def: .public (exec! statement expression archive [this that])
+ (Generator! [Synthesis Synthesis])
+ (do [! ///////phase.monad]
+ [this (expression archive this)
+ that (statement expression archive that)
+ $dummy (# ! each _.var (/////generation.symbol "_exec"))]
+ (in ($_ _.then
+ (_.set (list $dummy) this)
+ that))))
+
(def: .public (let expression archive [valueS register bodyS])
(Generator [Synthesis Register Synthesis])
(do ///////phase.monad
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
index 5ce1e0b7a..b5899731b 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux {"-" Tuple Variant Label function}
+ [lux {"-" Label function}
[abstract
["[0]" monad {"+" do}]]
[control
@@ -20,7 +20,7 @@
["/[1]" // "_"
["[1][0]" reference]
["//[1]" /// "_"
- [analysis {"+" Variant Tuple Abstraction Application Analysis}]
+ [analysis {"+" Abstraction Application Analysis}]
[synthesis {"+" Synthesis}]
["[1][0]" generation {"+" Context}]
["//[1]" /// "_"
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
index 3c491e788..97784804e 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux
@@ -9,26 +9,27 @@
["[1][0]" runtime {"+" Operation Phase Generator}]
["[1][0]" primitive]
["///[1]" //// "_"
- [analysis {"+" Variant Tuple}]
["[1][0]" synthesis {"+" Synthesis}]
+ [analysis
+ [composite {"+" Variant Tuple}]]
["//[1]" /// "_"
["[1][0]" phase ("[1]#[0]" monad)]]]])
-(def: .public (tuple generate archive elemsS+)
+(def: .public (tuple phase archive elemsS+)
(Generator (Tuple Synthesis))
(case elemsS+
{.#End}
(///////phase#in (//primitive.text /////synthesis.unit))
{.#Item singletonS {.#End}}
- (generate archive singletonS)
+ (phase archive singletonS)
_
(|> elemsS+
- (monad.each ///////phase.monad (generate archive))
+ (monad.each ///////phase.monad (phase archive))
(///////phase#each _.array))))
-(def: .public (variant generate archive [lefts right? valueS])
+(def: .public (variant phase archive [lefts right? valueS])
(Generator (Variant Synthesis))
(///////phase#each (//runtime.variant lefts right?)
- (generate archive valueS)))
+ (phase archive valueS)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
index 79321ad28..0389a03af 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux
@@ -383,9 +383,9 @@
(dictionary.value register)
(maybe.else ..necessary!))]]
(in [(dictionary.lacks register redundancy)
- {/.#Control (if redundant?
- {/.#Branch {/.#Exec input (..remove_local register output)}}
- {/.#Branch {/.#Let input register output}})}]))
+ {/.#Control {/.#Branch (if redundant?
+ {/.#Exec input (..remove_local register output)}
+ {/.#Let input register output})}}]))
{/.#If test then else}
(do try.monad
diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux
index b4b1df413..0f933172d 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux
@@ -144,6 +144,7 @@
(let [class_path (|> custom
(maybe#each (|>> name.internal name.read))
(maybe.else (runtime.class_name [module artifact]))
+ (text.replaced "." "/")
(text.suffix (value@ static.#artifact_extension static)))]
(do try.monad
[_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path) sink)]
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index a754e9bd2..a48460778 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -3,28 +3,35 @@
[lux "*"
["[0]" debug]
["@" target
- ["[0]" jvm]
["[0]" js]
["[0]" python]
["[0]" lua]
["[0]" ruby]
["[0]" php]
- ["[0]" scheme]]
+ ["[0]" scheme]
+ ["[0]" jvm
+ ["[0]" class]
+ ["[0]" version]
+ [encoding
+ ["[0]" name]]]]
[abstract
["[0]" monad {"+" do}]]
[control
- ["[0]" try]
+ ["[0]" try ("[1]#[0]" functor)]
["<>" parser
["<[0]>" code]
["<[0]>" analysis]
["<[0]>" synthesis]]]
[data
+ ["[0]" binary]
["[0]" product]
["[0]" text ("[1]#[0]" equivalence)
["%" format {"+" format}]]
[collection
["[0]" sequence]
- ["[0]" list ("[1]#[0]" functor)]]]
+ ["[0]" list ("[1]#[0]" functor)]]
+ [format
+ ["[0]F" binary]]]
[macro
["[0]" template]]
[math
@@ -45,7 +52,10 @@
["[0]" directive]
[phase
[analysis
- ["[0]" type]]]]]]]
+ ["[0]" type]]
+ [generation
+ ["[0]" jvm "_"
+ ["[1]/[0]" runtime]]]]]]]]
["_" test {"+" Test}]]]
[\\library
["[0]" / {"+" analysis: synthesis: generation: directive:}]])
@@ -146,19 +156,26 @@
(do !
[[module_id artifact_id] (generation.context archive)
.let [commentary (format "Successfully installed directive " (%.text self) "!")]
- _ (for [@.jvm (in [])
- @.js (generation.save! artifact_id {.#None}
- (js.comment commentary
- (js.statement (js.string commentary))))
- @.python (generation.save! artifact_id {.#None}
- (python.comment commentary
- (python.statement (python.string commentary))))
- @.lua (generation.save! artifact_id {.#None}
- (lua.comment commentary
- (lua.statement (lua.string commentary))))
- @.ruby (generation.save! artifact_id {.#None}
- (ruby.comment commentary
- (ruby.statement (ruby.string commentary))))])]
+ _ (generation.save! artifact_id {.#None}
+ (for [@.jvm (let [$class (jvm/runtime.class_name [module_id artifact_id])]
+ (<| [$class]
+ (try.else (binary.empty 0))
+ (try#each (binaryF.result class.writer))
+ (class.class version.v6_0 class.public
+ (name.internal $class)
+ (name.internal "java.lang.Object")
+ (list)
+ (list)
+ (list)
+ sequence.empty)))
+ @.js (js.comment commentary
+ (js.statement (js.string commentary)))
+ @.python (python.comment commentary
+ (python.statement (python.string commentary)))
+ @.lua (lua.comment commentary
+ (lua.statement (lua.string commentary)))
+ @.ruby (ruby.comment commentary
+ (ruby.statement (ruby.string commentary)))]))]
(generation.log! commentary))))]
(in directive.no_requirements)))
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 4e3bad586..df128f232 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -17,6 +17,9 @@
... ["[1][0]" analysis]
... ["[1][0]" synthesis]]
]]
+ ["[1][0]" meta "_"
+ ["[1]/[0]" archive "_"
+ ["[1]/[0]" signature]]]
]])
(def: .public test
@@ -27,6 +30,7 @@
/reference.test
/analysis/primitive.test
/analysis/composite.test
+ /meta/archive/signature.test
... /syntax.test
... /analysis.test
... /synthesis.test
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux
index 4d67a47f9..3c88cd1e5 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux
@@ -35,6 +35,7 @@
($_ _.and
(_.for [/.equivalence]
($equivalence.spec /.equivalence ..random))
+
(do random.monad
[left ..random
right ..random]
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux
new file mode 100644
index 000000000..948329ada
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux
@@ -0,0 +1,56 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]]]
+ [control
+ ["[0]" try ("[1]#[0]" functor)]
+ [parser
+ ["<[0]>" binary]]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [format
+ ["[0]F" binary]]]
+ [math
+ ["[0]" random {"+" Random}]]]]
+ [\\library
+ ["[0]" /]]
+ ["[0]" //// "_"
+ ["[1][0]" version]])
+
+(def: .public random
+ (Random /.Signature)
+ ($_ random.and
+ ($_ random.and
+ (random.ascii/upper 5)
+ (random.ascii/lower 5))
+ ////version.random
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Signature])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+
+ (do random.monad
+ [left ..random
+ right ..random]
+ (_.cover [/.description]
+ (bit#= (# /.equivalence = left right)
+ (text#= (/.description left) (/.description right)))))
+ (do random.monad
+ [expected ..random]
+ (_.cover [/.writer /.parser]
+ (|> expected
+ (binaryF.result /.writer)
+ (<binary>.result /.parser)
+ (try#each (# /.equivalence = expected))
+ (try.else false))))
+ )))