aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool
diff options
context:
space:
mode:
authorEduardo Julian2021-01-05 07:55:22 -0400
committerEduardo Julian2021-01-05 07:55:22 -0400
commit75102dcfa7c2c0afd32cb5bf5ac012df2db6a7a1 (patch)
tree643350e00eebc8682c5087a4cd73b5f9406d92fb /stdlib/source/lux/tool
parentc03bd9f9787fb9f383c57b4ebb0fa9d49abbfaa1 (diff)
Added lexically-scoped templates.
Diffstat (limited to 'stdlib/source/lux/tool')
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux50
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux87
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux10
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/case.lux129
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/function.lux58
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/loop.lux19
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux456
-rw-r--r--stdlib/source/lux/tool/compiler/meta/packager/script.lux34
8 files changed, 424 insertions, 419 deletions
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
index 708b93ddd..764479799 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
@@ -33,9 +33,9 @@
[<c>.any
(function (_ extension phase archive lengthC)
(do phase.monad
- [lengthA (type.with-type Nat
+ [lengthA (type.with_type Nat
(phase archive lengthC))
- [var-id varT] (type.with-env check.var)
+ [var_id varT] (type.with_env check.var)
_ (type.infer (type (Array varT)))]
(wrap (#analysis.Extension extension (list lengthA)))))]))
@@ -45,8 +45,8 @@
[<c>.any
(function (_ extension phase archive arrayC)
(do phase.monad
- [[var-id varT] (type.with-env check.var)
- arrayA (type.with-type (type (Array varT))
+ [[var_id varT] (type.with_env check.var)
+ arrayA (type.with_type (type (Array varT))
(phase archive arrayC))
_ (type.infer Nat)]
(wrap (#analysis.Extension extension (list arrayA)))))]))
@@ -57,10 +57,10 @@
[(<>.and <c>.any <c>.any)
(function (_ extension phase archive [indexC arrayC])
(do phase.monad
- [indexA (type.with-type Nat
+ [indexA (type.with_type Nat
(phase archive indexC))
- [var-id varT] (type.with-env check.var)
- arrayA (type.with-type (type (Array varT))
+ [var_id varT] (type.with_env check.var)
+ arrayA (type.with_type (type (Array varT))
(phase archive arrayC))
_ (type.infer varT)]
(wrap (#analysis.Extension extension (list indexA arrayA)))))]))
@@ -71,12 +71,12 @@
[($_ <>.and <c>.any <c>.any <c>.any)
(function (_ extension phase archive [indexC valueC arrayC])
(do phase.monad
- [indexA (type.with-type Nat
+ [indexA (type.with_type Nat
(phase archive indexC))
- [var-id varT] (type.with-env check.var)
- valueA (type.with-type varT
+ [var_id varT] (type.with_env check.var)
+ valueA (type.with_type varT
(phase archive valueC))
- arrayA (type.with-type (type (Array varT))
+ arrayA (type.with_type (type (Array varT))
(phase archive arrayC))
_ (type.infer (type (Array varT)))]
(wrap (#analysis.Extension extension (list indexA valueA arrayA)))))]))
@@ -87,10 +87,10 @@
[($_ <>.and <c>.any <c>.any)
(function (_ extension phase archive [indexC arrayC])
(do phase.monad
- [indexA (type.with-type Nat
+ [indexA (type.with_type Nat
(phase archive indexC))
- [var-id varT] (type.with-env check.var)
- arrayA (type.with-type (type (Array varT))
+ [var_id varT] (type.with_env check.var)
+ arrayA (type.with_type (type (Array varT))
(phase archive arrayC))
_ (type.infer (type (Array varT)))]
(wrap (#analysis.Extension extension (list indexA arrayA)))))]))
@@ -112,9 +112,9 @@
[($_ <>.and <c>.any (<c>.tuple (<>.some <c>.any)))
(function (_ extension phase archive [constructorC inputsC])
(do {! phase.monad}
- [constructorA (type.with-type Any
+ [constructorA (type.with_type Any
(phase archive constructorC))
- inputsA (monad.map ! (|>> (phase archive) (type.with-type Any)) inputsC)
+ inputsA (monad.map ! (|>> (phase archive) (type.with_type Any)) inputsC)
_ (type.infer .Any)]
(wrap (#analysis.Extension extension (list& constructorA inputsA)))))]))
@@ -124,7 +124,7 @@
[($_ <>.and <c>.text <c>.any)
(function (_ extension phase archive [fieldC objectC])
(do phase.monad
- [objectA (type.with-type Any
+ [objectA (type.with_type Any
(phase archive objectC))
_ (type.infer .Any)]
(wrap (#analysis.Extension extension (list (analysis.text fieldC)
@@ -136,9 +136,9 @@
[($_ <>.and <c>.text <c>.any (<c>.tuple (<>.some <c>.any)))
(function (_ extension phase archive [methodC objectC inputsC])
(do {! phase.monad}
- [objectA (type.with-type Any
+ [objectA (type.with_type Any
(phase archive objectC))
- inputsA (monad.map ! (|>> (phase archive) (type.with-type Any)) inputsC)
+ inputsA (monad.map ! (|>> (phase archive) (type.with_type Any)) inputsC)
_ (type.infer .Any)]
(wrap (#analysis.Extension extension (list& (analysis.text methodC)
objectA
@@ -172,19 +172,19 @@
[($_ <>.and <c>.any (<>.some <c>.any))
(function (_ extension phase archive [abstractionC inputsC])
(do {! phase.monad}
- [abstractionA (type.with-type Any
+ [abstractionA (type.with_type Any
(phase archive abstractionC))
- inputsA (monad.map ! (|>> (phase archive) (type.with-type Any)) inputsC)
+ inputsA (monad.map ! (|>> (phase archive) (type.with_type Any)) inputsC)
_ (type.infer Any)]
(wrap (#analysis.Extension extension (list& abstractionA inputsA)))))]))
-(def: js::type-of
+(def: js::type_of
Handler
(custom
[<c>.any
(function (_ extension phase archive objectC)
(do phase.monad
- [objectA (type.with-type Any
+ [objectA (type.with_type Any
(phase archive objectC))
_ (type.infer .Text)]
(wrap (#analysis.Extension extension (list objectA)))))]))
@@ -196,7 +196,7 @@
(function (_ extension phase archive [arity abstractionC])
(do phase.monad
[#let [inputT (tuple (list.repeat arity Any))]
- abstractionA (type.with-type (-> inputT Any)
+ abstractionA (type.with_type (-> inputT Any)
(phase archive abstractionC))
_ (type.infer (for {@.js host.Function}
Any))]
@@ -209,7 +209,7 @@
(|> bundle.empty
(bundle.install "constant" js::constant)
(bundle.install "apply" js::apply)
- (bundle.install "type-of" js::type-of)
+ (bundle.install "type-of" js::type_of)
(bundle.install "function" js::function)
(dictionary.merge bundle::array)
(dictionary.merge bundle::object)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
index 1485d7230..03b2ca14b 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
@@ -8,11 +8,12 @@
["<s>" synthesis (#+ Parser)]]]
[data
["." product]
- [number
- ["f" frac]]
[collection
["." list ("#\." functor)]
["." dictionary]]]
+ [math
+ [number
+ ["f" frac]]]
["@" target
["_" js (#+ Literal Expression Statement)]]]
["." //// #_
@@ -35,24 +36,24 @@
(-> [(Parser s)
(-> Text (Generator s))]
Handler))
- (function (_ extension-name phase archive input)
+ (function (_ extension_name phase archive input)
(case (<s>.run parser input)
(#try.Success input')
- (handler extension-name phase archive input')
+ (handler extension_name phase archive input')
(#try.Failure error)
- (/////.throw extension.invalid-syntax [extension-name %synthesis input]))))
+ (/////.throw extension.invalid_syntax [extension_name %synthesis input]))))
## [Procedures]
## [[Bits]]
(template [<name> <op>]
[(def: (<name> [paramG subjectG])
(Binary Expression)
- (<op> subjectG (//runtime.i64//to-number paramG)))]
+ (<op> subjectG (//runtime.i64//to_number paramG)))]
- [i64//left-shift //runtime.i64//left-shift]
- [i64//arithmetic-right-shift //runtime.i64//arithmetic-right-shift]
- [i64//logical-right-shift //runtime.i64//logic-right-shift]
+ [i64//left_shift //runtime.i64//left_shift]
+ [i64//arithmetic_right_shift //runtime.i64//arithmetic_right_shift]
+ [i64//logical_right_shift //runtime.i64//logic_right_shift]
)
## [[Numbers]]
@@ -66,7 +67,7 @@
(def: i64//char
(Unary Expression)
- (|>> //runtime.i64//to-number
+ (|>> //runtime.i64//to_number
(list)
(_.apply/* (_.var "String.fromCharCode"))))
@@ -92,37 +93,37 @@
(def: (io//exit codeG)
(Unary Expression)
- (let [exit-node-js! (let [@@process (_.var "process")]
- (|> (_.not (_.= _.undefined (_.type-of @@process)))
+ (let [exit_node_js! (let [@@process (_.var "process")]
+ (|> (_.not (_.= _.undefined (_.type_of @@process)))
(_.and (_.the "exit" @@process))
- (_.and (_.do "exit" (list (//runtime.i64//to-number codeG)) @@process))))
- close-browser-window! (let [@@window (_.var "window")]
- (|> (_.not (_.= _.undefined (_.type-of @@window)))
+ (_.and (_.do "exit" (list (//runtime.i64//to_number codeG)) @@process))))
+ close_browser_window! (let [@@window (_.var "window")]
+ (|> (_.not (_.= _.undefined (_.type_of @@window)))
(_.and (_.the "close" @@window))
(_.and (_.do "close" (list) @@window))))
- reload-page! (let [@@location (_.var "location")]
- (|> (_.not (_.= _.undefined (_.type-of @@location)))
+ reload_page! (let [@@location (_.var "location")]
+ (|> (_.not (_.= _.undefined (_.type_of @@location)))
(_.and (_.the "reload" @@location))
(_.and (_.do "reload" (list) @@location))))]
- (|> exit-node-js!
- (_.or close-browser-window!)
- (_.or reload-page!))))
+ (|> exit_node_js!
+ (_.or close_browser_window!)
+ (_.or reload_page!))))
-(def: (io//current-time _)
+(def: (io//current_time _)
(Nullary Expression)
(|> (_.new (_.var "Date") (list))
(_.do "getTime" (list))
- //runtime.i64//from-number))
+ //runtime.i64//from_number))
## TODO: Get rid of this ASAP
-(def: lux::syntax-char-case!
+(def: lux::syntax_char_case!
(..custom [($_ <>.and
<s>.any
<s>.any
(<>.some (<s>.tuple ($_ <>.and
(<s>.tuple (<>.many <s>.i64))
<s>.any))))
- (function (_ extension-name phase archive [input else conditionals])
+ (function (_ extension_name phase archive [input else conditionals])
(do {! /////.monad}
[inputG (phase archive input)
elseG (phase archive else)
@@ -135,29 +136,29 @@
(_.return branchG)])))
conditionals))]
(wrap (_.apply/* (_.closure (list)
- (_.switch (_.the //runtime.i64-low-field inputG)
+ (_.switch (_.the //runtime.i64_low_field inputG)
conditionalsG
(#.Some (_.return elseG))))
(list)))))]))
## [Bundles]
-(def: lux-procs
+(def: lux_procs
Bundle
(|> /.empty
- (/.install "syntax char case!" lux::syntax-char-case!)
+ (/.install "syntax char case!" lux::syntax_char_case!)
(/.install "is" (binary (product.uncurry _.=)))
(/.install "try" (unary //runtime.lux//try))))
-(def: i64-procs
+(def: i64_procs
Bundle
(<| (/.prefix "i64")
(|> /.empty
(/.install "and" (binary (product.uncurry //runtime.i64//and)))
(/.install "or" (binary (product.uncurry //runtime.i64//or)))
(/.install "xor" (binary (product.uncurry //runtime.i64//xor)))
- (/.install "left-shift" (binary i64//left-shift))
- (/.install "logical-right-shift" (binary i64//logical-right-shift))
- (/.install "arithmetic-right-shift" (binary i64//arithmetic-right-shift))
+ (/.install "left-shift" (binary i64//left_shift))
+ (/.install "logical-right-shift" (binary i64//logical_right_shift))
+ (/.install "arithmetic-right-shift" (binary i64//arithmetic_right_shift))
(/.install "=" (binary (product.uncurry //runtime.i64//=)))
(/.install "<" (binary (product.uncurry //runtime.i64//<)))
(/.install "+" (binary (product.uncurry //runtime.i64//+)))
@@ -165,11 +166,11 @@
(/.install "*" (binary (product.uncurry //runtime.i64//*)))
(/.install "/" (binary (product.uncurry //runtime.i64///)))
(/.install "%" (binary (product.uncurry //runtime.i64//%)))
- (/.install "f64" (unary //runtime.i64//to-number))
+ (/.install "f64" (unary //runtime.i64//to_number))
(/.install "char" (unary i64//char))
)))
-(def: f64-procs
+(def: f64_procs
Bundle
(<| (/.prefix "f64")
(|> /.empty
@@ -180,11 +181,11 @@
(/.install "%" (binary (product.uncurry _.%)))
(/.install "=" (binary (product.uncurry _.=)))
(/.install "<" (binary (product.uncurry _.<)))
- (/.install "i64" (unary //runtime.i64//from-number))
+ (/.install "i64" (unary //runtime.i64//from_number))
(/.install "encode" (unary (_.do "toString" (list))))
(/.install "decode" (unary f64//decode)))))
-(def: text-procs
+(def: text_procs
Bundle
(<| (/.prefix "text")
(|> /.empty
@@ -192,26 +193,26 @@
(/.install "<" (binary (product.uncurry _.<)))
(/.install "concat" (binary text//concat))
(/.install "index" (trinary text//index))
- (/.install "size" (unary (|>> (_.the "length") //runtime.i64//from-number)))
+ (/.install "size" (unary (|>> (_.the "length") //runtime.i64//from_number)))
(/.install "char" (binary (product.uncurry //runtime.text//char)))
(/.install "clip" (trinary text//clip))
)))
-(def: io-procs
+(def: io_procs
Bundle
(<| (/.prefix "io")
(|> /.empty
(/.install "log" (unary io//log))
(/.install "error" (unary //runtime.io//error))
(/.install "exit" (unary io//exit))
- (/.install "current-time" (nullary io//current-time)))))
+ (/.install "current-time" (nullary io//current_time)))))
(def: #export bundle
Bundle
(<| (/.prefix "lux")
- (|> lux-procs
- (dictionary.merge i64-procs)
- (dictionary.merge f64-procs)
- (dictionary.merge text-procs)
- (dictionary.merge io-procs)
+ (|> lux_procs
+ (dictionary.merge i64_procs)
+ (dictionary.merge f64_procs)
+ (dictionary.merge text_procs)
+ (dictionary.merge io_procs)
)))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
index 0aeea4cd2..c81705f24 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
@@ -23,7 +23,7 @@
nullary unary binary trinary)]
["//" js #_
["#." runtime (#+ Operation Phase Handler Bundle
- with-vars)]]]
+ with_vars)]]]
["/#" // #_
["." generation]
["//#" /// #_
@@ -31,15 +31,15 @@
(def: array::new
(Unary Expression)
- (|>> (_.the //runtime.i64-low-field) list (_.new (_.var "Array"))))
+ (|>> (_.the //runtime.i64_low_field) list (_.new (_.var "Array"))))
(def: array::length
(Unary Expression)
- (|>> (_.the "length") //runtime.i64//from-number))
+ (|>> (_.the "length") //runtime.i64//from_number))
(def: (array::read [indexG arrayG])
(Binary Expression)
- (_.at (_.the //runtime.i64-low-field indexG)
+ (_.at (_.the //runtime.i64_low_field indexG)
arrayG))
(def: (array::write [indexG valueG arrayG])
@@ -153,7 +153,7 @@
(|> /.empty
(/.install "constant" js::constant)
(/.install "apply" js::apply)
- (/.install "type-of" (unary _.type-of))
+ (/.install "type-of" (unary _.type_of))
(/.install "function" js::function)
(dictionary.merge ..array)
(dictionary.merge ..object)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/case.lux
index 13038972b..3a828bbb9 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/case.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/case.lux
@@ -7,10 +7,11 @@
[data
["." maybe]
["." text]
- [number
- ["n" nat]]
[collection
["." list ("#\." functor fold)]]]
+ [math
+ [number
+ ["n" nat]]]
[target
["_" js (#+ Expression Computation Var Statement)]]]
["." // #_
@@ -89,40 +90,40 @@
(def: @cursor (_.var "lux_pm_cursor"))
(def: @temp (_.var "lux_pm_temp"))
-(def: (push-cursor! value)
+(def: (push_cursor! value)
(-> Expression Statement)
(_.statement (|> @cursor (_.do "push" (list value)))))
-(def: peek-and-pop-cursor
+(def: peek_and_pop_cursor
Expression
(|> @cursor (_.do "pop" (list))))
-(def: pop-cursor!
+(def: pop_cursor!
Statement
- (_.statement ..peek-and-pop-cursor))
+ (_.statement ..peek_and_pop_cursor))
(def: length
(|>> (_.the "length")))
-(def: last-index
+(def: last_index
(|>> ..length (_.- (_.i32 +1))))
-(def: peek-cursor
+(def: peek_cursor
Expression
- (|> @cursor (_.at (last-index @cursor))))
+ (|> @cursor (_.at (last_index @cursor))))
-(def: save-cursor!
+(def: save_cursor!
Statement
(.let [cursor (|> @cursor (_.do "slice" (list)))]
(_.statement (|> @savepoint (_.do "push" (list cursor))))))
-(def: restore-cursor!
+(def: restore_cursor!
Statement
(_.set @cursor (|> @savepoint (_.do "pop" (list)))))
-(def: fail-pm! _.break)
+(def: fail_pm! _.break)
-(def: (multi-pop-cursor! pops)
+(def: (multi_pop_cursor! pops)
(-> Nat Statement)
(.let [popsJS (_.i32 (.int pops))]
(_.statement (|> @cursor (_.do "splice" (list (|> @cursor ..length (_.- popsJS))
@@ -132,30 +133,30 @@
[(def: (<name> simple? idx)
(-> Bit Nat Statement)
($_ _.then
- (_.set @temp (|> idx <prep> .int _.i32 (//runtime.sum//get ..peek-cursor <flag>)))
+ (_.set @temp (|> idx <prep> .int _.i32 (//runtime.sum//get ..peek_cursor <flag>)))
(.if simple?
(_.when (_.= _.null @temp)
- ..fail-pm!)
+ ..fail_pm!)
(_.if (_.= _.null @temp)
- ..fail-pm!
- (push-cursor! @temp)))))]
+ ..fail_pm!
+ (push_cursor! @temp)))))]
- [left-choice _.null (<|)]
- [right-choice (_.string "") inc]
+ [left_choice _.null (<|)]
+ [right_choice (_.string "") inc]
)
(def: (alternation pre! post!)
(-> Statement Statement Statement)
($_ _.then
- (_.do-while (_.boolean false)
+ (_.do_while (_.boolean false)
($_ _.then
- ..save-cursor!
+ ..save_cursor!
pre!))
($_ _.then
- ..restore-cursor!
+ ..restore_cursor!
post!)))
-(def: (optimized-pattern-matching recur pathP)
+(def: (optimized_pattern_matching recur pathP)
(-> (-> Path (Operation Statement))
(-> Path (Operation (Maybe Statement))))
(.case pathP
@@ -164,59 +165,59 @@
(|> nextP
recur
(\ ///////phase.monad map (|>> (_.then (<choice> true idx)) #.Some)))])
- ([/////synthesis.simple-left-side ..left-choice]
- [/////synthesis.simple-right-side ..right-choice])
+ ([/////synthesis.simple_left_side ..left_choice]
+ [/////synthesis.simple_right_side ..right_choice])
(^ (/////synthesis.member/left 0))
- (///////phase\wrap (#.Some (push-cursor! (_.at (_.i32 +0) ..peek-cursor))))
+ (///////phase\wrap (#.Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor))))
## Extra optimization
(^ (/////synthesis.path/seq
(/////synthesis.member/left 0)
- (/////synthesis.!bind-top register thenP)))
+ (/////synthesis.!bind_top register thenP)))
(do ///////phase.monad
[then! (recur thenP)]
(wrap (#.Some ($_ _.then
- (_.define (..register register) (_.at (_.i32 +0) ..peek-cursor))
+ (_.define (..register register) (_.at (_.i32 +0) ..peek_cursor))
then!))))
## Extra optimization
(^template [<pm> <getter>]
[(^ (/////synthesis.path/seq
(<pm> lefts)
- (/////synthesis.!bind-top register thenP)))
+ (/////synthesis.!bind_top register thenP)))
(do ///////phase.monad
[then! (recur thenP)]
(wrap (#.Some ($_ _.then
- (_.define (..register register) (<getter> (_.i32 (.int lefts)) ..peek-cursor))
+ (_.define (..register register) (<getter> (_.i32 (.int lefts)) ..peek_cursor))
then!))))])
([/////synthesis.member/left //runtime.tuple//left]
[/////synthesis.member/right //runtime.tuple//right])
- (^ (/////synthesis.!bind-top register thenP))
+ (^ (/////synthesis.!bind_top register thenP))
(do ///////phase.monad
[then! (recur thenP)]
(wrap (#.Some ($_ _.then
- (_.define (..register register) ..peek-and-pop-cursor)
+ (_.define (..register register) ..peek_and_pop_cursor)
then!))))
- (^ (/////synthesis.!multi-pop nextP))
- (.let [[extra-pops nextP'] (////synthesis/case.count-pops nextP)]
+ (^ (/////synthesis.!multi_pop nextP))
+ (.let [[extra_pops nextP'] (////synthesis/case.count_pops nextP)]
(do ///////phase.monad
[next! (recur nextP')]
(wrap (#.Some ($_ _.then
- (multi-pop-cursor! (n.+ 2 extra-pops))
+ (multi_pop_cursor! (n.+ 2 extra_pops))
next!)))))
_
(///////phase\wrap #.None)))
-(def: (pattern-matching' statement expression archive)
+(def: (pattern_matching' statement expression archive)
(-> Phase! Phase Archive
(-> Path (Operation Statement)))
(function (recur pathP)
(do ///////phase.monad
- [outcome (optimized-pattern-matching recur pathP)]
+ [outcome (optimized_pattern_matching recur pathP)]
(.case outcome
(#.Some outcome)
(wrap outcome)
@@ -224,12 +225,12 @@
#.None
(.case pathP
#/////synthesis.Pop
- (///////phase\wrap pop-cursor!)
+ (///////phase\wrap pop_cursor!)
(#/////synthesis.Bind register)
- (///////phase\wrap (_.define (..register register) ..peek-cursor))
+ (///////phase\wrap (_.define (..register register) ..peek_cursor))
- (#/////synthesis.Bit-Fork when thenP elseP)
+ (#/////synthesis.Bit_Fork when thenP elseP)
(do {! ///////phase.monad}
[then! (recur thenP)
else! (.case elseP
@@ -237,25 +238,25 @@
(recur elseP)
#.None
- (wrap ..fail-pm!))]
+ (wrap ..fail_pm!))]
(wrap (.if when
- (_.if ..peek-cursor
+ (_.if ..peek_cursor
then!
else!)
- (_.if ..peek-cursor
+ (_.if ..peek_cursor
else!
then!))))
- (#/////synthesis.I64-Fork cons)
+ (#/////synthesis.I64_Fork cons)
(do {! ///////phase.monad}
[clauses (monad.map ! (function (_ [match then])
(do !
[then! (recur then)]
(wrap [(//runtime.i64//= (//primitive.i64 (.int match))
- ..peek-cursor)
+ ..peek_cursor)
then!])))
(#.Cons cons))]
- (wrap (_.cond clauses ..fail-pm!)))
+ (wrap (_.cond clauses ..fail_pm!)))
(^template [<tag> <format> <type>]
[(<tag> cons)
@@ -263,11 +264,11 @@
[cases (monad.map ! (function (_ [match then])
(\ ! map (|>> [(list (<format> match))]) (recur then)))
(#.Cons cons))]
- (wrap (_.switch ..peek-cursor
+ (wrap (_.switch ..peek_cursor
cases
- (#.Some ..fail-pm!))))])
- ([#/////synthesis.F64-Fork //primitive.f64 Frac]
- [#/////synthesis.Text-Fork //primitive.text Text])
+ (#.Some ..fail_pm!))))])
+ ([#/////synthesis.F64_Fork //primitive.f64 Frac]
+ [#/////synthesis.Text_Fork //primitive.text Text])
(#/////synthesis.Then bodyS)
(statement expression archive bodyS)
@@ -275,12 +276,12 @@
(^template [<complex> <choice>]
[(^ (<complex> idx))
(///////phase\wrap (<choice> false idx))])
- ([/////synthesis.side/left ..left-choice]
- [/////synthesis.side/right ..right-choice])
+ ([/////synthesis.side/left ..left_choice]
+ [/////synthesis.side/right ..right_choice])
(^template [<pm> <getter>]
[(^ (<pm> lefts))
- (///////phase\wrap (push-cursor! (<getter> (_.i32 (.int lefts)) ..peek-cursor)))])
+ (///////phase\wrap (push_cursor! (<getter> (_.i32 (.int lefts)) ..peek_cursor)))])
([/////synthesis.member/left //runtime.tuple//left]
[/////synthesis.member/right //runtime.tuple//right])
@@ -293,24 +294,24 @@
([/////synthesis.path/seq _.then]
[/////synthesis.path/alt ..alternation]))))))
-(def: (pattern-matching statement expression archive pathP)
+(def: (pattern_matching statement expression archive pathP)
(-> Phase! Phase Archive Path (Operation Statement))
(do ///////phase.monad
- [pattern-matching! (pattern-matching' statement expression archive pathP)]
+ [pattern_matching! (pattern_matching' statement expression archive pathP)]
(wrap ($_ _.then
- (_.do-while (_.boolean false)
- pattern-matching!)
- (_.throw (_.string ////synthesis/case.pattern-matching-error))))))
+ (_.do_while (_.boolean false)
+ pattern_matching!)
+ (_.throw (_.string ////synthesis/case.pattern_matching_error))))))
(def: #export (case statement expression archive [valueS pathP])
(-> Phase! (Generator [Synthesis Path]))
(do ///////phase.monad
- [stack-init (expression archive valueS)
- path! (pattern-matching statement expression archive pathP)
+ [stack_init (expression archive valueS)
+ path! (pattern_matching statement expression archive pathP)
#let [closure (<| (_.closure (list))
($_ _.then
(_.declare @temp)
- (_.define @cursor (_.array (list stack-init)))
+ (_.define @cursor (_.array (list stack_init)))
(_.define @savepoint (_.array (list)))
path!))]]
(wrap (_.apply/* closure (list)))))
@@ -318,10 +319,10 @@
(def: #export (case! statement expression archive [valueS pathP])
(Generator! [Synthesis Path])
(do ///////phase.monad
- [stack-init (expression archive valueS)
- path! (pattern-matching statement expression archive pathP)]
+ [stack_init (expression archive valueS)
+ path! (pattern_matching statement expression archive pathP)]
(wrap ($_ _.then
(_.declare @temp)
- (_.define @cursor (_.array (list stack-init)))
+ (_.define @cursor (_.array (list stack_init)))
(_.define @savepoint (_.array (list)))
path!))))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/function.lux
index c939b36a6..0d47e9fe8 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/function.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/function.lux
@@ -35,11 +35,11 @@
argsO+ (monad.map ! (generate archive) argsS+)]
(wrap (_.apply/* functionO argsO+))))
-(def: (with-closure @self inits function-body)
+(def: (with_closure @self inits function_body)
(-> Var (List Expression) Statement [Statement Expression])
(case inits
#.Nil
- [(_.function! @self (list) function-body)
+ [(_.function! @self (list) function_body)
@self]
_
@@ -48,7 +48,7 @@
[(_.function! @self
(|> (list.enumeration inits)
(list\map (|>> product.left capture)))
- (_.return (_.function @self (list) function-body)))
+ (_.return (_.function @self (list) function_body)))
(_.apply/* @self inits)])))
(def: @curried (_.var "curried"))
@@ -58,63 +58,63 @@
(def: @@arguments (_.var "arguments"))
-(def: (@scope function-name)
+(def: (@scope function_name)
(-> Context Text)
- (format (///reference.artifact function-name) "_scope"))
+ (format (///reference.artifact function_name) "_scope"))
(def: #export (function statement expression archive [environment arity bodyS])
(-> Phase! (Generator (Abstraction Synthesis)))
(do {! ///////phase.monad}
- [[function-name body!] (/////generation.with-new-context archive
+ [[function_name body!] (/////generation.with_new_context archive
(do !
[scope (\ ! map ..@scope
(/////generation.context archive))]
- (/////generation.with-anchor [1 scope]
+ (/////generation.with_anchor [1 scope]
(statement expression archive bodyS))))
#let [arityO (|> arity .int _.i32)
- @num-args (_.var "num_args")
- @scope (..@scope function-name)
- @self (_.var (///reference.artifact function-name))
- apply-poly (.function (_ args func)
+ @num_args (_.var "num_args")
+ @scope (..@scope function_name)
+ @self (_.var (///reference.artifact function_name))
+ apply_poly (.function (_ args func)
(|> func (_.do "apply" (list _.null args))))
- initialize-self! (_.define (//case.register 0) @self)
+ initialize_self! (_.define (//case.register 0) @self)
initialize! (list\fold (.function (_ post pre!)
($_ _.then
pre!
(_.define (..input post) (_.at (_.i32 (.int post)) @@arguments))))
- initialize-self!
+ initialize_self!
(list.indices arity))]
environment (monad.map ! (expression archive) environment)
- #let [[definition instantiation] (with-closure @self environment
+ #let [[definition instantiation] (with_closure @self environment
($_ _.then
- (_.define @num-args (_.the "length" @@arguments))
- (_.cond (list [(|> @num-args (_.= arityO))
+ (_.define @num_args (_.the "length" @@arguments))
+ (_.cond (list [(|> @num_args (_.= arityO))
($_ _.then
initialize!
- (_.with-label (_.label @scope)
- (_.do-while (_.boolean true)
+ (_.with_label (_.label @scope)
+ (_.do_while (_.boolean true)
body!)))]
- [(|> @num-args (_.> arityO))
- (let [arity-inputs (|> (_.array (list))
+ [(|> @num_args (_.> arityO))
+ (let [arity_inputs (|> (_.array (list))
(_.the "slice")
(_.do "call" (list @@arguments (_.i32 +0) arityO)))
- extra-inputs (|> (_.array (list))
+ 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))
+ (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)
+ (_.define @curried all_inputs)
(_.return (_.closure (list)
- (let [@missing all-inputs]
- (_.return (apply-poly (_.do "concat" (list @missing) @curried)
+ (let [@missing all_inputs]
+ (_.return (apply_poly (_.do "concat" (list @missing) @curried)
@self))))))))
))]
_ (/////generation.execute! definition)
- _ (/////generation.save! (%.nat (product.right function-name)) definition)]
+ _ (/////generation.save! (%.nat (product.right function_name)) definition)]
(wrap instantiation)))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/loop.lux
index 29cdc1180..bbeaca725 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/loop.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/loop.lux
@@ -6,10 +6,11 @@
["." product]
["." text
["%" format (#+ format)]]
- [number
- ["n" nat]]
[collection
["." list ("#\." functor fold)]]]
+ [math
+ [number
+ ["n" nat]]]
[target
["_" js (#+ Computation Var Expression Statement)]]]
["." // #_
@@ -51,11 +52,11 @@
(do {! ///////phase.monad}
[@scope (\ ! map ..@scope /////generation.next)
initsO+ (monad.map ! (expression archive) initsS+)
- body! (/////generation.with-anchor [start @scope]
+ body! (/////generation.with_anchor [start @scope]
(statement expression archive bodyS))]
(wrap (..setup true start initsO+
- (_.with-label (_.label @scope)
- (_.do-while (_.boolean true)
+ (_.with_label (_.label @scope)
+ (_.do_while (_.boolean true)
body!)))))))
(def: #export (scope statement expression archive [start initsS+ bodyS])
@@ -70,14 +71,14 @@
(do {! ///////phase.monad}
[@scope (\ ! map ..@scope /////generation.next)
initsO+ (monad.map ! (expression archive) initsS+)
- body! (/////generation.with-anchor [start @scope]
+ body! (/////generation.with_anchor [start @scope]
(statement expression archive bodyS))
#let [closure (_.closure
(|> initsS+
list.enumeration
(list\map (|>> product.left (n.+ start) //case.register)))
- (_.with-label (_.label @scope)
- (_.do-while (_.boolean true)
+ (_.with_label (_.label @scope)
+ (_.do_while (_.boolean true)
body!)))]]
(wrap (_.apply/* closure initsO+)))))
@@ -95,4 +96,4 @@
list.enumeration
(list\map (function (_ [idx _])
(_.at (_.i32 (.int idx)) @temp))))
- (_.continue-at (_.label @scope)))))))
+ (_.continue_at (_.label @scope)))))))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
index d8859f767..119796a73 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux
@@ -1,5 +1,6 @@
(.module:
[lux #*
+ ["." meta]
[abstract
["." monad (#+ do)]]
[control
@@ -8,17 +9,18 @@
["s" code]]]
[data
["." product]
- [number (#+ hex)
- ["." i64]]
["." text ("#\." hash)
["%" format (#+ format)]
["." encoding]]
[collection
["." list ("#\." functor)]
["." row]]]
- ["." macro
- ["." code]
- [syntax (#+ syntax:)]]
+ [macro
+ [syntax (#+ syntax:)]
+ ["." code]]
+ [math
+ [number (#+ hex)
+ ["." i64]]]
[target
["_" js (#+ Expression Var Computation Statement)]]
[tool
@@ -64,11 +66,11 @@
(def: #export high
(-> (I64 Any) (I64 Any))
- (i64.logic-right-shift 32))
+ (i64.logic_right_shift 32))
(def: #export low
(-> (I64 Any) (I64 Any))
- (let [mask (dec (i64.left-shift 32 1))]
+ (let [mask (dec (i64.left_shift 32 1))]
(|>> (i64.and mask))))
(def: #export unit Computation (_.string /////synthesis.unit))
@@ -83,67 +85,67 @@
(-> Var (-> Var Expression) Statement)
(_.define name (definition name)))
-(syntax: #export (with-vars {vars (s.tuple (p.some s.local-identifier))}
+(syntax: #export (with_vars {vars (s.tuple (p.some s.local_identifier))}
body)
- (do {! macro.monad}
- [ids (monad.seq ! (list.repeat (list.size vars) macro.count))]
+ (do {! meta.monad}
+ [ids (monad.seq ! (list.repeat (list.size vars) meta.count))]
(wrap (list (` (let [(~+ (|> vars
(list.zip/2 ids)
(list\map (function (_ [id var])
- (list (code.local-identifier var)
+ (list (code.local_identifier var)
(` (_.var (~ (code.text (format "v" (%.nat id)))))))))
list.concat))]
(~ body)))))))
-(def: (runtime-name name)
+(def: (runtime_name name)
(-> Text [Code Code])
(let [identifier (format ..prefix
"_" (%.nat $.version)
"_" (%.nat (text\hash name)))]
[(` (_.var (~ (code.text identifier))))
- (code.local-identifier identifier)]))
+ (code.local_identifier identifier)]))
-(syntax: (runtime: {declaration (p.or s.local-identifier
- (s.form (p.and s.local-identifier
- (p.some s.local-identifier))))}
+(syntax: (runtime: {declaration (p.or s.local_identifier
+ (s.form (p.and s.local_identifier
+ (p.some s.local_identifier))))}
code)
(case declaration
(#.Left name)
- (macro.with-gensyms [g!_]
- (let [[runtime-nameC runtime-nameC!] (..runtime-name name)
- nameC (code.local-identifier name)]
- (wrap (list (` (def: (~ runtime-nameC!)
+ (meta.with_gensyms [g!_]
+ (let [[runtime_nameC runtime_nameC!] (..runtime_name name)
+ nameC (code.local_identifier name)]
+ (wrap (list (` (def: (~ runtime_nameC!)
Var
- (~ runtime-nameC)))
+ (~ runtime_nameC)))
(` (def: #export (~ nameC)
- (~ runtime-nameC!)))
+ (~ runtime_nameC!)))
- (` (def: (~ (code.local-identifier (format "@" name)))
+ (` (def: (~ (code.local_identifier (format "@" name)))
Statement
- (..feature (~ runtime-nameC)
+ (..feature (~ runtime_nameC)
(function ((~ g!_) (~ nameC))
(~ code)))))))))
(#.Right [name inputs])
- (macro.with-gensyms [g!_]
- (let [[runtime-nameC runtime-nameC!] (..runtime-name name)
- nameC (code.local-identifier name)
- code-nameC (code.local-identifier (format "@" name))
- inputsC (list\map code.local-identifier inputs)
- inputs-typesC (list\map (function.constant (` _.Expression)) inputs)]
- (wrap (list (` (def: ((~ runtime-nameC!) (~+ inputsC))
- (-> (~+ inputs-typesC) Computation)
- (_.apply/* (~ runtime-nameC) (list (~+ inputsC)))))
+ (meta.with_gensyms [g!_]
+ (let [[runtime_nameC runtime_nameC!] (..runtime_name name)
+ nameC (code.local_identifier name)
+ code_nameC (code.local_identifier (format "@" name))
+ inputsC (list\map code.local_identifier inputs)
+ inputs_typesC (list\map (function.constant (` _.Expression)) inputs)]
+ (wrap (list (` (def: ((~ runtime_nameC!) (~+ inputsC))
+ (-> (~+ inputs_typesC) Computation)
+ (_.apply/* (~ runtime_nameC) (list (~+ inputsC)))))
(` (def: #export (~ nameC)
- (~ runtime-nameC!)))
+ (~ runtime_nameC!)))
- (` (def: (~ (code.local-identifier (format "@" name)))
+ (` (def: (~ (code.local_identifier (format "@" name)))
Statement
- (..feature (~ runtime-nameC)
+ (..feature (~ runtime_nameC)
(function ((~ g!_) (~ g!_))
- (..with-vars [(~+ inputsC)]
+ (..with_vars [(~+ inputsC)]
(_.function (~ g!_) (list (~+ inputsC))
(~ code)))))))))))))
@@ -151,80 +153,80 @@
(-> Expression Computation)
(_.the "length"))
-(def: last-index
+(def: last_index
(-> Expression Computation)
(|>> ..length (_.- (_.i32 +1))))
-(def: (last-element tuple)
- (_.at (..last-index tuple)
+(def: (last_element tuple)
+ (_.at (..last_index tuple)
tuple))
-(with-expansions [<recur> (as-is ($_ _.then
- (_.set lefts (_.- last-index-right lefts))
- (_.set tuple (_.at last-index-right tuple))))]
+(with_expansions [<recur> (as_is ($_ _.then
+ (_.set lefts (_.- last_index_right lefts))
+ (_.set tuple (_.at last_index_right tuple))))]
(runtime: (tuple//left lefts tuple)
- (with-vars [last-index-right]
+ (with_vars [last_index_right]
(<| (_.while (_.boolean true))
($_ _.then
- (_.define last-index-right (..last-index tuple))
- (_.if (_.> lefts last-index-right)
+ (_.define last_index_right (..last_index tuple))
+ (_.if (_.> lefts last_index_right)
## No need for recursion
(_.return (_.at lefts tuple))
## Needs recursion
<recur>)))))
(runtime: (tuple//right lefts tuple)
- (with-vars [last-index-right right-index]
+ (with_vars [last_index_right right_index]
(<| (_.while (_.boolean true))
($_ _.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)
+ (_.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)))
+ (_.return (_.do "slice" (list right_index) tuple)))
)))))
-(def: #export variant-tag-field "_lux_tag")
-(def: #export variant-flag-field "_lux_flag")
-(def: #export variant-value-field "_lux_value")
+(def: #export variant_tag_field "_lux_tag")
+(def: #export variant_flag_field "_lux_flag")
+(def: #export variant_value_field "_lux_value")
(runtime: (variant//create tag last? value)
- (_.return (_.object (list [..variant-tag-field tag]
- [..variant-flag-field last?]
- [..variant-value-field value]))))
+ (_.return (_.object (list [..variant_tag_field tag]
+ [..variant_flag_field last?]
+ [..variant_value_field value]))))
(def: #export (variant tag last? value)
(-> Expression Expression Expression Computation)
(..variant//create tag last? value))
-(runtime: (sum//get sum wants-last wanted-tag)
- (let [no-match! (_.return _.null)
- sum-tag (|> sum (_.the ..variant-tag-field))
- sum-flag (|> sum (_.the ..variant-flag-field))
- sum-value (|> sum (_.the ..variant-value-field))
- is-last? (_.= ..unit sum-flag)
- extact-match! (_.return sum-value)
- test-recursion! (_.if is-last?
+(runtime: (sum//get sum wants_last wanted_tag)
+ (let [no_match! (_.return _.null)
+ sum_tag (|> sum (_.the ..variant_tag_field))
+ sum_flag (|> sum (_.the ..variant_flag_field))
+ sum_value (|> sum (_.the ..variant_value_field))
+ is_last? (_.= ..unit sum_flag)
+ extact_match! (_.return sum_value)
+ test_recursion! (_.if is_last?
## Must recurse.
($_ _.then
- (_.set wanted-tag (_.- sum-tag wanted-tag))
- (_.set sum sum-value))
- no-match!)
- extrac-sub-variant! (_.return (..variant (_.- wanted-tag sum-tag) sum-flag sum-value))]
+ (_.set wanted_tag (_.- sum_tag wanted_tag))
+ (_.set sum sum_value))
+ no_match!)
+ extrac_sub_variant! (_.return (..variant (_.- wanted_tag sum_tag) sum_flag sum_value))]
(<| (_.while (_.boolean true))
- (_.cond (list [(_.= wanted-tag sum-tag)
- (_.if (_.= wants-last sum-flag)
- extact-match!
- test-recursion!)]
- [(_.< wanted-tag sum-tag)
- test-recursion!]
- [(_.and (_.> wanted-tag sum-tag)
- (_.= ..unit wants-last))
- extrac-sub-variant!])
- no-match!))))
+ (_.cond (list [(_.= wanted_tag sum_tag)
+ (_.if (_.= wants_last sum_flag)
+ extact_match!
+ test_recursion!)]
+ [(_.< wanted_tag sum_tag)
+ test_recursion!]
+ [(_.and (_.> wanted_tag sum_tag)
+ (_.= ..unit wants_last))
+ extrac_sub_variant!])
+ no_match!))))
(def: none
Computation
@@ -252,16 +254,16 @@
))
(runtime: (lux//try op)
- (with-vars [ex]
+ (with_vars [ex]
(_.try (_.return (..right (_.apply/1 op ..unit)))
[ex (_.return (..left (|> ex (_.do "toString" (list)))))])))
-(runtime: (lux//program-args inputs)
- (with-vars [output idx]
+(runtime: (lux//program_args inputs)
+ (with_vars [output idx]
($_ _.then
(_.define output ..none)
(_.for idx
- (..last-index inputs)
+ (..last_index inputs)
(_.>= (_.i32 +0) idx)
(_.-- idx)
(_.set output (..some (_.array (list (_.at idx inputs)
@@ -272,18 +274,18 @@
Statement
($_ _.then
@lux//try
- @lux//program-args
+ @lux//program_args
))
-(def: #export i64-low-field Text "_lux_low")
-(def: #export i64-high-field Text "_lux_high")
+(def: #export i64_low_field Text "_lux_low")
+(def: #export i64_high_field Text "_lux_high")
(runtime: (i64//new high low)
- (_.return (_.object (list [..i64-high-field high]
- [..i64-low-field low]))))
+ (_.return (_.object (list [..i64_high_field high]
+ [..i64_low_field low]))))
(runtime: i64//2^16
- (_.left-shift (_.i32 +16) (_.i32 +1)))
+ (_.left_shift (_.i32 +16) (_.i32 +1)))
(runtime: i64//2^32
(_.* i64//2^16 i64//2^16))
@@ -294,14 +296,14 @@
(runtime: i64//2^63
(|> i64//2^64 (_./ (_.i32 +2))))
-(runtime: (i64//unsigned-low i64)
- (_.return (_.? (|> i64 (_.the ..i64-low-field) (_.>= (_.i32 +0)))
- (|> i64 (_.the ..i64-low-field))
- (|> i64 (_.the ..i64-low-field) (_.+ i64//2^32)))))
+(runtime: (i64//unsigned_low i64)
+ (_.return (_.? (|> i64 (_.the ..i64_low_field) (_.>= (_.i32 +0)))
+ (|> i64 (_.the ..i64_low_field))
+ (|> i64 (_.the ..i64_low_field) (_.+ i64//2^32)))))
-(runtime: (i64//to-number i64)
- (_.return (|> i64 (_.the ..i64-high-field) (_.* i64//2^32)
- (_.+ (i64//unsigned-low i64)))))
+(runtime: (i64//to_number i64)
+ (_.return (|> i64 (_.the ..i64_high_field) (_.* i64//2^32)
+ (_.+ (i64//unsigned_low i64)))))
(runtime: i64//zero
(i64//new (_.i32 +0) (_.i32 +0)))
@@ -316,20 +318,20 @@
(i64//new (_.i32 +0) (_.i32 +1)))
(runtime: (i64//= reference sample)
- (_.return (_.and (_.= (_.the ..i64-high-field reference)
- (_.the ..i64-high-field sample))
- (_.= (_.the ..i64-low-field reference)
- (_.the ..i64-low-field sample)))))
+ (_.return (_.and (_.= (_.the ..i64_high_field reference)
+ (_.the ..i64_high_field sample))
+ (_.= (_.the ..i64_low_field reference)
+ (_.the ..i64_low_field sample)))))
(runtime: (i64//+ parameter subject)
- (let [up-16 (_.left-shift (_.i32 +16))
- high-16 (_.logic-right-shift (_.i32 +16))
- low-16 (_.bit-and (_.i32 (hex "+FFFF")))
- hh (|>> (_.the ..i64-high-field) high-16)
- hl (|>> (_.the ..i64-high-field) low-16)
- lh (|>> (_.the ..i64-low-field) high-16)
- ll (|>> (_.the ..i64-low-field) low-16)]
- (with-vars [l48 l32 l16 l00
+ (let [up_16 (_.left_shift (_.i32 +16))
+ high_16 (_.logic_right_shift (_.i32 +16))
+ low_16 (_.bit_and (_.i32 (hex "+FFFF")))
+ hh (|>> (_.the ..i64_high_field) high_16)
+ hl (|>> (_.the ..i64_high_field) low_16)
+ lh (|>> (_.the ..i64_low_field) high_16)
+ ll (|>> (_.the ..i64_low_field) low_16)]
+ (with_vars [l48 l32 l16 l00
r48 r32 r16 r00
x48 x32 x16 x00]
($_ _.then
@@ -344,34 +346,34 @@
(_.define r00 (ll parameter))
(_.define x00 (_.+ l00 r00))
- (_.define x16 (high-16 x00))
- (_.set x00 (low-16 x00))
+ (_.define x16 (high_16 x00))
+ (_.set x00 (low_16 x00))
(_.set x16 (|> x16 (_.+ l16) (_.+ r16)))
- (_.define x32 (high-16 x16))
- (_.set x16 (low-16 x16))
+ (_.define x32 (high_16 x16))
+ (_.set x16 (low_16 x16))
(_.set x32 (|> x32 (_.+ l32) (_.+ r32)))
- (_.define x48 (|> (high-16 x32) (_.+ l48) (_.+ r48) low-16))
- (_.set x32 (low-16 x32))
+ (_.define x48 (|> (high_16 x32) (_.+ l48) (_.+ r48) low_16))
+ (_.set x32 (low_16 x32))
- (_.return (i64//new (_.bit-or (up-16 x48) x32)
- (_.bit-or (up-16 x16) x00)))
+ (_.return (i64//new (_.bit_or (up_16 x48) x32)
+ (_.bit_or (up_16 x16) x00)))
))))
(template [<name> <op>]
[(runtime: (<name> subject parameter)
- (_.return (i64//new (<op> (_.the ..i64-high-field subject)
- (_.the ..i64-high-field parameter))
- (<op> (_.the ..i64-low-field subject)
- (_.the ..i64-low-field parameter)))))]
-
- [i64//xor _.bit-xor]
- [i64//or _.bit-or]
- [i64//and _.bit-and]
+ (_.return (i64//new (<op> (_.the ..i64_high_field subject)
+ (_.the ..i64_high_field parameter))
+ (<op> (_.the ..i64_low_field subject)
+ (_.the ..i64_low_field parameter)))))]
+
+ [i64//xor _.bit_xor]
+ [i64//or _.bit_or]
+ [i64//and _.bit_and]
)
(runtime: (i64//not value)
- (_.return (i64//new (_.bit-not (_.the ..i64-high-field value))
- (_.bit-not (_.the ..i64-low-field value)))))
+ (_.return (i64//new (_.bit_not (_.the ..i64_high_field value))
+ (_.bit_not (_.the ..i64_low_field value)))))
(runtime: (i64//negate value)
(_.if (i64//= i64//min value)
@@ -381,71 +383,71 @@
(runtime: i64//-one
(i64//negate i64//one))
-(runtime: (i64//from-number value)
- (_.cond (list [(_.not-a-number? value)
+(runtime: (i64//from_number value)
+ (_.cond (list [(_.not_a_number? value)
(_.return i64//zero)]
[(_.<= (_.negate i64//2^63) value)
(_.return i64//min)]
[(|> value (_.+ (_.i32 +1)) (_.>= i64//2^63))
(_.return i64//max)]
[(|> value (_.< (_.i32 +0)))
- (_.return (|> value _.negate i64//from-number i64//negate))])
- (_.return (i64//new (|> value (_./ i64//2^32) _.to-i32)
- (|> value (_.% i64//2^32) _.to-i32)))))
+ (_.return (|> value _.negate i64//from_number i64//negate))])
+ (_.return (i64//new (|> value (_./ i64//2^32) _.to_i32)
+ (|> value (_.% i64//2^32) _.to_i32)))))
-(def: (cap-shift! shift)
+(def: (cap_shift! shift)
(-> Var Statement)
- (_.set shift (|> shift (_.bit-and (_.i32 +63)))))
+ (_.set shift (|> shift (_.bit_and (_.i32 +63)))))
-(def: (no-shift! shift input)
+(def: (no_shift! shift input)
(-> Var Var [Expression Statement])
[(|> shift (_.= (_.i32 +0)))
(_.return input)])
-(def: small-shift?
+(def: small_shift?
(-> Var Expression)
(|>> (_.< (_.i32 +32))))
-(runtime: (i64//left-shift input shift)
+(runtime: (i64//left_shift input shift)
($_ _.then
- (..cap-shift! shift)
- (_.cond (list (..no-shift! shift input)
- [(..small-shift? shift)
- (let [high (_.bit-or (|> input (_.the ..i64-high-field) (_.left-shift shift))
- (|> input (_.the ..i64-low-field) (_.logic-right-shift (_.- shift (_.i32 +32)))))
- low (|> input (_.the ..i64-low-field) (_.left-shift shift))]
+ (..cap_shift! shift)
+ (_.cond (list (..no_shift! shift input)
+ [(..small_shift? shift)
+ (let [high (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift shift))
+ (|> input (_.the ..i64_low_field) (_.logic_right_shift (_.- shift (_.i32 +32)))))
+ low (|> input (_.the ..i64_low_field) (_.left_shift shift))]
(_.return (i64//new high low)))])
- (let [high (|> input (_.the ..i64-low-field) (_.left-shift (_.- (_.i32 +32) shift)))]
+ (let [high (|> input (_.the ..i64_low_field) (_.left_shift (_.- (_.i32 +32) shift)))]
(_.return (i64//new high (_.i32 +0)))))))
-(runtime: (i64//arithmetic-right-shift input shift)
+(runtime: (i64//arithmetic_right_shift input shift)
($_ _.then
- (..cap-shift! shift)
- (_.cond (list (..no-shift! shift input)
- [(..small-shift? shift)
- (let [high (|> input (_.the ..i64-high-field) (_.arithmetic-right-shift shift))
- low (|> input (_.the ..i64-low-field) (_.logic-right-shift shift)
- (_.bit-or (|> input (_.the ..i64-high-field) (_.left-shift (_.- shift (_.i32 +32))))))]
+ (..cap_shift! shift)
+ (_.cond (list (..no_shift! shift input)
+ [(..small_shift? shift)
+ (let [high (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift shift))
+ low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift)
+ (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))]
(_.return (i64//new high low)))])
- (let [high (_.? (|> input (_.the ..i64-high-field) (_.>= (_.i32 +0)))
+ (let [high (_.? (|> input (_.the ..i64_high_field) (_.>= (_.i32 +0)))
(_.i32 +0)
(_.i32 -1))
- low (|> input (_.the ..i64-high-field) (_.arithmetic-right-shift (_.- (_.i32 +32) shift)))]
+ low (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift (_.- (_.i32 +32) shift)))]
(_.return (i64//new high low))))))
-(runtime: (i64//logic-right-shift input shift)
+(runtime: (i64//logic_right_shift input shift)
($_ _.then
- (..cap-shift! shift)
- (_.cond (list (..no-shift! shift input)
- [(..small-shift? shift)
- (let [high (|> input (_.the ..i64-high-field) (_.logic-right-shift shift))
- low (|> input (_.the ..i64-low-field) (_.logic-right-shift shift)
- (_.bit-or (|> input (_.the ..i64-high-field) (_.left-shift (_.- shift (_.i32 +32))))))]
+ (..cap_shift! shift)
+ (_.cond (list (..no_shift! shift input)
+ [(..small_shift? shift)
+ (let [high (|> input (_.the ..i64_high_field) (_.logic_right_shift shift))
+ low (|> input (_.the ..i64_low_field) (_.logic_right_shift shift)
+ (_.bit_or (|> input (_.the ..i64_high_field) (_.left_shift (_.- shift (_.i32 +32))))))]
(_.return (i64//new high low)))]
[(|> shift (_.= (_.i32 +32)))
- (_.return (i64//new (_.i32 +0) (|> input (_.the ..i64-high-field))))])
+ (_.return (i64//new (_.i32 +0) (|> input (_.the ..i64_high_field))))])
(_.return (i64//new (_.i32 +0)
- (|> input (_.the ..i64-high-field) (_.logic-right-shift (_.- (_.i32 +32) shift))))))))
+ (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift))))))))
(def: runtime//bit
Statement
@@ -454,16 +456,16 @@
@i64//or
@i64//xor
@i64//not
- @i64//left-shift
- @i64//arithmetic-right-shift
- @i64//logic-right-shift
+ @i64//left_shift
+ @i64//arithmetic_right_shift
+ @i64//logic_right_shift
))
(runtime: (i64//- parameter subject)
(_.return (i64//+ (i64//negate parameter) subject)))
(runtime: (i64//* parameter subject)
- (let [negative? (|>> (_.the ..i64-high-field) (_.< (_.i32 +0)))]
+ (let [negative? (|>> (_.the ..i64_high_field) (_.< (_.i32 +0)))]
(_.cond (list [(negative? subject)
(_.if (negative? parameter)
## Both are negative
@@ -474,14 +476,14 @@
## Parameter is negative
(_.return (i64//negate (i64//* (i64//negate parameter) subject)))])
## Both are positive
- (let [up-16 (_.left-shift (_.i32 +16))
- high-16 (_.logic-right-shift (_.i32 +16))
- low-16 (_.bit-and (_.i32 (hex "+FFFF")))
- hh (|>> (_.the ..i64-high-field) high-16)
- hl (|>> (_.the ..i64-high-field) low-16)
- lh (|>> (_.the ..i64-low-field) high-16)
- ll (|>> (_.the ..i64-low-field) low-16)]
- (with-vars [l48 l32 l16 l00
+ (let [up_16 (_.left_shift (_.i32 +16))
+ high_16 (_.logic_right_shift (_.i32 +16))
+ low_16 (_.bit_and (_.i32 (hex "+FFFF")))
+ hh (|>> (_.the ..i64_high_field) high_16)
+ hl (|>> (_.the ..i64_high_field) low_16)
+ lh (|>> (_.the ..i64_low_field) high_16)
+ ll (|>> (_.the ..i64_low_field) low_16)]
+ (with_vars [l48 l32 l16 l00
r48 r32 r16 r00
x48 x32 x16 x00]
($_ _.then
@@ -496,35 +498,35 @@
(_.define r00 (ll parameter))
(_.define x00 (_.* l00 r00))
- (_.define x16 (high-16 x00))
- (_.set x00 (low-16 x00))
+ (_.define x16 (high_16 x00))
+ (_.set x00 (low_16 x00))
(_.set x16 (|> x16 (_.+ (_.* l16 r00))))
- (_.define x32 (high-16 x16)) (_.set x16 (low-16 x16))
+ (_.define x32 (high_16 x16)) (_.set x16 (low_16 x16))
(_.set x16 (|> x16 (_.+ (_.* l00 r16))))
- (_.set x32 (|> x32 (_.+ (high-16 x16)))) (_.set x16 (low-16 x16))
+ (_.set x32 (|> x32 (_.+ (high_16 x16)))) (_.set x16 (low_16 x16))
(_.set x32 (|> x32 (_.+ (_.* l32 r00))))
- (_.define x48 (high-16 x32)) (_.set x32 (low-16 x32))
+ (_.define x48 (high_16 x32)) (_.set x32 (low_16 x32))
(_.set x32 (|> x32 (_.+ (_.* l16 r16))))
- (_.set x48 (|> x48 (_.+ (high-16 x32)))) (_.set x32 (low-16 x32))
+ (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32))
(_.set x32 (|> x32 (_.+ (_.* l00 r32))))
- (_.set x48 (|> x48 (_.+ (high-16 x32)))) (_.set x32 (low-16 x32))
+ (_.set x48 (|> x48 (_.+ (high_16 x32)))) (_.set x32 (low_16 x32))
(_.set x48 (|> x48
(_.+ (_.* l48 r00))
(_.+ (_.* l32 r16))
(_.+ (_.* l16 r32))
(_.+ (_.* l00 r48))
- low-16))
+ low_16))
- (_.return (i64//new (_.bit-or (up-16 x48) x32)
- (_.bit-or (up-16 x16) x00)))
+ (_.return (i64//new (_.bit_or (up_16 x48) x32)
+ (_.bit_or (up_16 x16) x00)))
))))))
(runtime: (i64//< parameter subject)
- (let [negative? (|>> (_.the ..i64-high-field) (_.< (_.i32 +0)))]
- (with-vars [-subject? -parameter?]
+ (let [negative? (|>> (_.the ..i64_high_field) (_.< (_.i32 +0)))]
+ (with_vars [-subject? -parameter?]
($_ _.then
(_.define -subject? (negative? subject))
(_.define -parameter? (negative? parameter))
@@ -542,12 +544,12 @@
(runtime: (i64/// parameter subject)
(let [negative? (function (_ value)
(i64//< i64//zero value))
- valid-division-check [(i64//= i64//zero parameter)
+ valid_division_check [(i64//= i64//zero parameter)
(_.throw (_.string "Cannot divide by zero!"))]
- short-circuit-check [(i64//= i64//zero subject)
+ short_circuit_check [(i64//= i64//zero subject)
(_.return i64//zero)]]
- (_.cond (list valid-division-check
- short-circuit-check
+ (_.cond (list valid_division_check
+ short_circuit_check
[(i64//= i64//min subject)
(_.cond (list [(_.or (i64//= i64//one parameter)
@@ -555,10 +557,10 @@
(_.return i64//min)]
[(i64//= i64//min parameter)
(_.return i64//one)])
- (with-vars [approximation]
- (let [subject/2 (i64//arithmetic-right-shift subject (_.i32 +1))]
+ (with_vars [approximation]
+ (let [subject/2 (i64//arithmetic_right_shift subject (_.i32 +1))]
($_ _.then
- (_.define approximation (i64//left-shift (i64/// parameter
+ (_.define approximation (i64//left_shift (i64/// parameter
subject/2)
(_.i32 +1)))
(_.if (i64//= i64//zero approximation)
@@ -583,17 +585,17 @@
[(negative? parameter)
(_.return (i64//negate (i64/// (i64//negate parameter) subject)))])
- (with-vars [result remainder]
+ (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//from-number approximate)
- approx-remainder (i64//* parameter approximate-result)]
+ (with_vars [approximate approximate_result approximate_remainder log2 delta]
+ (let [approximate_result' (i64//from_number approximate)
+ approx_remainder (i64//* parameter approximate_result)]
($_ _.then
- (_.define approximate (|> (i64//to-number remainder)
- (_./ (i64//to-number parameter))
+ (_.define approximate (|> (i64//to_number remainder)
+ (_./ (i64//to_number parameter))
(_.apply/1 (_.var "Math.floor"))
(_.apply/2 (_.var "Math.max") (_.i32 +1))))
(_.define log2 (|> approximate
@@ -606,20 +608,20 @@
(_.i32 +2)
(_.- (_.i32 +48)
log2))))
- (_.define approximate-result approximate-result')
- (_.define approximate-remainder approx-remainder)
- (_.while (_.or (negative? approximate-remainder)
- (i64//< approximate-remainder
+ (_.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)
+ (_.set approximate_result approximate_result')
+ (_.set approximate_remainder approx_remainder)))
+ (_.set result (i64//+ (_.? (i64//= i64//zero approximate_result)
i64//one
- approximate-result)
+ approximate_result)
result))
- (_.set remainder (i64//- approximate-remainder remainder))))))
+ (_.set remainder (i64//- approximate_remainder remainder))))))
(_.return result)))
)))
@@ -636,7 +638,7 @@
@i64//2^32
@i64//2^64
@i64//2^63
- @i64//unsigned-low
+ @i64//unsigned_low
@i64//new
@i64//zero
@i64//min
@@ -645,8 +647,8 @@
@i64//=
@i64//+
@i64//negate
- @i64//to-number
- @i64//from-number
+ @i64//to_number
+ @i64//from_number
@i64//-
@i64//*
@i64//<
@@ -656,24 +658,24 @@
))
(runtime: (text//index start part text)
- (with-vars [idx]
+ (with_vars [idx]
($_ _.then
- (_.define idx (|> text (_.do "indexOf" (list part (i64//to-number start)))))
+ (_.define idx (|> text (_.do "indexOf" (list part (i64//to_number start)))))
(_.if (_.= (_.i32 -1) idx)
(_.return ..none)
- (_.return (..some (i64//from-number idx)))))))
+ (_.return (..some (i64//from_number idx)))))))
(runtime: (text//clip start end text)
- (_.return (|> text (_.do "substring" (list (_.the ..i64-low-field start)
- (_.the ..i64-low-field end))))))
+ (_.return (|> text (_.do "substring" (list (_.the ..i64_low_field start)
+ (_.the ..i64_low_field end))))))
(runtime: (text//char idx text)
- (with-vars [result]
+ (with_vars [result]
($_ _.then
- (_.define result (|> text (_.do "charCodeAt" (list (_.the ..i64-low-field idx)))))
- (_.if (_.not-a-number? result)
+ (_.define result (|> text (_.do "charCodeAt" (list (_.the ..i64_low_field idx)))))
+ (_.if (_.not_a_number? result)
(_.throw (_.string "[Lux Error] Cannot get char from text."))
- (_.return (i64//from-number result))))))
+ (_.return (i64//from_number result))))))
(def: runtime//text
Statement
@@ -687,15 +689,15 @@
(let [console (_.var "console")
print (_.var "print")
end! (_.return ..unit)]
- (_.cond (list [(|> console _.type-of (_.= (_.string "undefined")) _.not
+ (_.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)
+ [(|> print _.type_of (_.= (_.string "undefined")) _.not)
($_ _.then
(_.statement (_.apply/1 print (_.? (_.= (_.string "string")
- (_.type-of message))
+ (_.type_of message))
message
(_.apply/1 (_.var "JSON.stringify") message))))
end!)])
@@ -712,7 +714,7 @@
))
(runtime: (js//get object field)
- (with-vars [temp]
+ (with_vars [temp]
($_ _.then
(_.define temp (_.at field object))
(_.if (_.= _.undefined temp)
@@ -739,12 +741,12 @@
(runtime: (array//write idx value array)
($_ _.then
- (_.set (_.at (_.the ..i64-low-field idx) array) value)
+ (_.set (_.at (_.the ..i64_low_field idx) array) value)
(_.return array)))
(runtime: (array//delete idx array)
($_ _.then
- (_.delete (_.at (_.the ..i64-low-field idx) array))
+ (_.delete (_.at (_.the ..i64_low_field idx) array))
(_.return array)))
(def: runtime//array
diff --git a/stdlib/source/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/lux/tool/compiler/meta/packager/script.lux
index 543b2682a..1dd13c664 100644
--- a/stdlib/source/lux/tool/compiler/meta/packager/script.lux
+++ b/stdlib/source/lux/tool/compiler/meta/packager/script.lux
@@ -38,50 +38,50 @@
(type: (Action ! a)
(! (Try a)))
-(def: (write-artifact monad file-system static context)
+(def: (write_artifact monad file_system static context)
(All [!]
(-> (Monad !) (file.System !) Static Context
(Action ! Binary)))
(do (try.with monad)
[artifact (let [[module artifact] context]
- (!.use (\ file-system file) [(io.artifact file-system static module (%.nat artifact))]))]
+ (!.use (\ file_system file) [(io.artifact file_system static module (%.nat artifact))]))]
(!.use (\ artifact content) [])))
-(def: (write-module monad file-system static sequence [module artifacts] so-far)
+(def: (write_module monad file_system static sequence [module artifacts] so_far)
(All [! directive]
(-> (Monad !) (file.System !) Static (-> directive directive directive) [archive.ID (List artifact.ID)] directive
(Action ! directive)))
(monad.fold (:assume (try.with monad))
- (function (_ artifact so-far)
+ (function (_ artifact so_far)
(do (try.with monad)
- [content (..write-artifact monad file-system static [module artifact])
+ [content (..write_artifact monad file_system static [module artifact])
content (\ monad wrap (\ encoding.utf8 decode content))]
- (wrap (sequence so-far
+ (wrap (sequence so_far
(:share [directive]
{directive
- so-far}
+ so_far}
{directive
(:assume content)})))))
- so-far
+ so_far
artifacts))
-(def: #export (package header to-code sequence)
+(def: #export (package header to_code sequence)
(All [! directive]
(-> directive
(-> directive Text)
(-> directive directive directive)
(Packager !)))
- (function (package monad file-system static archive program)
+ (function (package monad file_system static archive program)
(do {! (try.with monad)}
- [cache (!.use (\ file-system directory) [(get@ #static.target static)])
- order (\ monad wrap (dependency.load-order $.key archive))]
+ [cache (!.use (\ file_system directory) [(get@ #static.target static)])
+ order (\ monad wrap (dependency.load_order $.key archive))]
(|> order
- (list\map (function (_ [module [module-id [descriptor document]]])
- [module-id
+ (list\map (function (_ [module [module_id [descriptor document]]])
+ [module_id
(|> descriptor
(get@ #descriptor.registry)
artifact.artifacts
- row.to-list
+ row.to_list
(list\map (|>> (get@ #artifact.id))))]))
- (monad.fold ! (..write-module monad file-system static sequence) header)
- (\ ! map (|>> to-code (\ encoding.utf8 encode)))))))
+ (monad.fold ! (..write_module monad file_system static sequence) header)
+ (\ ! map (|>> to_code (\ encoding.utf8 encode)))))))