aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux116
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux60
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux380
4 files changed, 280 insertions, 278 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 0a9bf90bb..f162595e7 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
@@ -1,41 +1,41 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" try]
- ["<>" parser
- ["<s>" synthesis {"+" Parser}]]]
- [data
- ["[0]" product]
- [collection
- ["[0]" list ("[1]#[0]" functor)]
- ["[0]" dictionary]]]
- [math
- [number
- ["f" frac]]]
- ["@" target
- ["_" js {"+" Literal Expression Statement}]]]]
- ["[0]" //// "_"
- ["/" bundle]
- ["/[1]" // "_"
- ["[0]" extension]
- [generation
- [extension {"+" Nullary Unary Binary Trinary
- nullary unary binary trinary}]
- ["//" js "_"
- ["[1][0]" runtime {"+" Operation Phase Phase! Handler Bundle Generator}]
- ["[1][0]" primitive]
- ["[1][0]" structure]
- ["[1][0]" reference]
- ["[1][0]" case]
- ["[1][0]" loop]
- ["[1][0]" function]]]
- [//
- ["[0]" synthesis {"+" %synthesis}]
- [///
- ["[1]" phase ("[1]#[0]" monad)]]]]])
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" try]
+ ["<>" parser
+ ["<s>" synthesis {"+" Parser}]]]
+ [data
+ ["[0]" product]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]
+ ["[0]" dictionary]]]
+ [math
+ [number
+ ["f" frac]]]
+ ["@" target
+ ["_" js {"+" Literal Expression Statement}]]]]
+ ["[0]" //// "_"
+ ["/" bundle]
+ ["/[1]" // "_"
+ ["[0]" extension]
+ [generation
+ [extension {"+" Nullary Unary Binary Trinary
+ nullary unary binary trinary}]
+ ["//" js "_"
+ ["[1][0]" runtime {"+" Operation Phase Phase! Handler Bundle Generator}]
+ ["[1][0]" primitive]
+ ["[1][0]" structure]
+ ["[1][0]" reference]
+ ["[1][0]" case]
+ ["[1][0]" loop]
+ ["[1][0]" function]]]
+ [//
+ ["[0]" synthesis {"+" %synthesis}]
+ [///
+ ["[1]" phase ("[1]#[0]" monad)]]]]])
(def: .public (custom [parser handler])
(All (_ s)
@@ -55,10 +55,10 @@
(template [<name> <op>]
[(def: (<name> [paramG subjectG])
(Binary Expression)
- (<op> subjectG (//runtime.i64//number paramG)))]
+ (<op> subjectG (//runtime.i64##number paramG)))]
- [i64//left_shifted //runtime.i64//left_shifted]
- [i64//right_shifted //runtime.i64//right_shifted]
+ [i64##left_shifted //runtime.i64##left_shifted]
+ [i64##right_shifted //runtime.i64##right_shifted]
)
... [[Numbers]]
@@ -70,9 +70,9 @@
(_.closure (list))
//runtime.lux//try))
-(def: i64//char
+(def: i64##char
(Unary Expression)
- (|>> //runtime.i64//number
+ (|>> //runtime.i64##number
(list)
(_.apply/* (_.var "String.fromCharCode"))))
@@ -188,20 +188,20 @@
Bundle
(<| (/.prefix "i64")
(|> /.empty
- (/.install "and" (binary (product.uncurried //runtime.i64//and)))
- (/.install "or" (binary (product.uncurried //runtime.i64//or)))
- (/.install "xor" (binary (product.uncurried //runtime.i64//xor)))
- (/.install "left-shift" (binary i64//left_shifted))
- (/.install "right-shift" (binary i64//right_shifted))
- (/.install "=" (binary (product.uncurried //runtime.i64//=)))
- (/.install "<" (binary (product.uncurried //runtime.i64//<)))
- (/.install "+" (binary (product.uncurried //runtime.i64//+)))
- (/.install "-" (binary (product.uncurried //runtime.i64//-)))
- (/.install "*" (binary (product.uncurried //runtime.i64//*)))
- (/.install "/" (binary (product.uncurried //runtime.i64///)))
- (/.install "%" (binary (product.uncurried //runtime.i64//%)))
- (/.install "f64" (unary //runtime.i64//number))
- (/.install "char" (unary i64//char))
+ (/.install "and" (binary (product.uncurried //runtime.i64##and)))
+ (/.install "or" (binary (product.uncurried //runtime.i64##or)))
+ (/.install "xor" (binary (product.uncurried //runtime.i64##xor)))
+ (/.install "left-shift" (binary i64##left_shifted))
+ (/.install "right-shift" (binary i64##right_shifted))
+ (/.install "=" (binary (product.uncurried //runtime.i64##=)))
+ (/.install "<" (binary (product.uncurried //runtime.i64##<)))
+ (/.install "+" (binary (product.uncurried //runtime.i64##+)))
+ (/.install "-" (binary (product.uncurried //runtime.i64##-)))
+ (/.install "*" (binary (product.uncurried //runtime.i64##*)))
+ (/.install "/" (binary (product.uncurried //runtime.i64##/)))
+ (/.install "%" (binary (product.uncurried //runtime.i64##%)))
+ (/.install "f64" (unary //runtime.i64##number))
+ (/.install "char" (unary i64##char))
)))
(def: f64_procs
@@ -215,7 +215,7 @@
(/.install "%" (binary (product.uncurried _.%)))
(/.install "=" (binary (product.uncurried _.=)))
(/.install "<" (binary (product.uncurried _.<)))
- (/.install "i64" (unary //runtime.i64//of_number))
+ (/.install "i64" (unary //runtime.i64##of_number))
(/.install "encode" (unary (_.do "toString" (list))))
(/.install "decode" (unary f64//decode)))))
@@ -227,7 +227,7 @@
(/.install "<" (binary (product.uncurried _.<)))
(/.install "concat" (binary text//concat))
(/.install "index" (trinary text//index))
- (/.install "size" (unary (|>> (_.the "length") //runtime.i64//of_number)))
+ (/.install "size" (unary (|>> (_.the "length") //runtime.i64##of_number)))
(/.install "char" (binary (product.uncurried //runtime.text//char)))
(/.install "clip" (trinary text//clip))
)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
index e6461ad7a..9f6f59ab9 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux
@@ -1,34 +1,34 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" function]
- ["<>" parser
- ["<s>" synthesis {"+" Parser}]]]
- [data
- [collection
- ["[0]" dictionary]
- ["[0]" list]]]
- [target
- ["_" js {"+" Var Expression}]]]]
- ["[0]" // "_"
- ["[1][0]" common {"+" custom}]
- ["//[1]" /// "_"
- ["/" bundle]
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" function]
+ ["<>" parser
+ ["<s>" synthesis {"+" Parser}]]]
+ [data
+ [collection
+ ["[0]" dictionary]
+ ["[0]" list]]]
+ [target
+ ["_" js {"+" Var Expression}]]]]
+ ["[0]" // "_"
+ ["[1][0]" common {"+" custom}]
+ ["//[1]" /// "_"
+ ["/" bundle]
+ ["/[1]" // "_"
+ ["[0]" extension]
+ [generation
+ [extension {"+" Nullary Unary Binary Trinary
+ nullary unary binary trinary}]
+ ["//" js "_"
+ ["[1][0]" runtime {"+" Operation Phase Handler Bundle
+ with_vars}]]]
["/[1]" // "_"
- ["[0]" extension]
- [generation
- [extension {"+" Nullary Unary Binary Trinary
- nullary unary binary trinary}]
- ["//" js "_"
- ["[1][0]" runtime {"+" Operation Phase Handler Bundle
- with_vars}]]]
- ["/[1]" // "_"
- ["[0]" generation]
- ["//[1]" /// "_"
- ["[1][0]" phase]]]]]])
+ ["[0]" generation]
+ ["//[1]" /// "_"
+ ["[1][0]" phase]]]]]])
(def: array::new
(Unary Expression)
@@ -36,7 +36,7 @@
(def: array::length
(Unary Expression)
- (|>> (_.the "length") //runtime.i64//of_number))
+ (|>> (_.the "length") //runtime.i64##of_number))
(def: (array::read [indexG arrayG])
(Binary Expression)
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 c90729050..e9b316c72 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
@@ -274,7 +274,7 @@
[clauses (monad.each ! (function (_ [match then])
(do !
[then! (again then)]
- (in [(//runtime.i64//= (//primitive.i64 (.int match))
+ (in [(//runtime.i64##= (//primitive.i64 (.int match))
..peek_cursor)
then!])))
{.#Item item})]
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 0f8cbef41..2a53e6cf3 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
@@ -266,7 +266,7 @@
(def: .public i64_low_field Text "_lux_low")
(def: .public i64_high_field Text "_lux_high")
-(runtime: i64//new
+(runtime: i64##new
(let [@this (_.var "this")]
(with_vars [high low]
(_.closure (list high low)
@@ -277,52 +277,135 @@
(def: .public (i64 high low)
(-> Expression Expression Computation)
- (_.new ..i64//new (list high low)))
+ (_.new ..i64##new (list high low)))
-(runtime: i64//2^16
+(template [<name> <op>]
+ [(runtime: (<name> subject parameter)
+ (_.return (..i64 (<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 (_.bit_not (_.the ..i64_high_field value))
+ (_.bit_not (_.the ..i64_low_field value)))))
+
+(def: (cap_shift! shift)
+ (-> Var Statement)
+ (_.set shift (|> shift (_.bit_and (_.i32 +63)))))
+
+(def: (no_shift! shift input)
+ (-> Var Var (-> Expression Expression))
+ (_.? (|> shift (_.= (_.i32 +0)))
+ input))
+
+(def: small_shift?
+ (-> Var Expression)
+ (|>> (_.< (_.i32 +32))))
+
+(runtime: (i64##left_shifted input shift)
+ ($_ _.then
+ (..cap_shift! shift)
+ (_.return (<| (..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))]
+ (..i64 high low)))
+ (let [high (|> input (_.the ..i64_low_field) (_.left_shift (_.- (_.i32 +32) shift)))]
+ (..i64 high (_.i32 +0)))))
+ ))
+
+(runtime: (i64##arithmetic_right_shifted input shift)
+ ($_ _.then
+ (..cap_shift! shift)
+ (_.return (<| (..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))))))]
+ (..i64 high low)))
+ (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)))]
+ (..i64 high low))))))
+
+(runtime: (i64##right_shifted input shift)
+ ($_ _.then
+ (..cap_shift! shift)
+ (_.return (<| (..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))))))]
+ (..i64 high low)))
+ (_.? (|> shift (_.= (_.i32 +32)))
+ (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field))))
+ (..i64 (_.i32 +0)
+ (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift))))))))
+
+(def: runtime//bit
+ Statement
+ ($_ _.then
+ @i64##and
+ @i64##or
+ @i64##xor
+ @i64##not
+ @i64##left_shifted
+ @i64##arithmetic_right_shifted
+ @i64##right_shifted
+ ))
+
+(runtime: i64##2^16
(_.left_shift (_.i32 +16) (_.i32 +1)))
-(runtime: i64//2^32
- (_.* i64//2^16 i64//2^16))
+(runtime: i64##2^32
+ (_.* i64##2^16 i64##2^16))
-(runtime: i64//2^64
- (_.* i64//2^32 i64//2^32))
+(runtime: i64##2^64
+ (_.* i64##2^32 i64##2^32))
-(runtime: i64//2^63
- (|> i64//2^64 (_./ (_.i32 +2))))
+(runtime: i64##2^63
+ (|> i64##2^64 (_./ (_.i32 +2))))
-(runtime: (i64//unsigned_low i64)
+(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)))))
+ (|> i64 (_.the ..i64_low_field) (_.+ i64##2^32)))))
-(runtime: (i64//number i64)
+(runtime: (i64##number i64)
(_.return (|> i64
(_.the ..i64_high_field)
- (_.* i64//2^32)
- (_.+ (i64//unsigned_low i64)))))
+ (_.* i64##2^32)
+ (_.+ (i64##unsigned_low i64)))))
-(runtime: i64//zero
+(runtime: i64##zero
(..i64 (_.i32 +0) (_.i32 +0)))
-(runtime: i64//min
+(runtime: i64##min
(..i64 (_.i32 (.int (hex "80,00,00,00")))
(_.i32 +0)))
-(runtime: i64//max
+(runtime: i64##max
(..i64 (_.i32 (.int (hex "7F,FF,FF,FF")))
(_.i32 (.int (hex "FF,FF,FF,FF")))))
-(runtime: i64//one
+(runtime: i64##one
(..i64 (_.i32 +0) (_.i32 +1)))
-(runtime: (i64//= reference sample)
+(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)))))
-(runtime: (i64//+ parameter subject)
+(runtime: (i64##+ parameter subject)
(let [up_16 (_.left_shift (_.i32 +16))
high_16 (_.logic_right_shift (_.i32 +16))
low_16 (_.bit_and (_.i32 (.int (hex "FFFF"))))
@@ -366,113 +449,30 @@
(_.bit_or (up_16 x16) x00)))
))))
-(template [<name> <op>]
- [(runtime: (<name> subject parameter)
- (_.return (..i64 (<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 (_.bit_not (_.the ..i64_high_field value))
- (_.bit_not (_.the ..i64_low_field value)))))
-
-(runtime: (i64//opposite value)
- (_.return (_.? (i64//= i64//min value)
- i64//min
- (i64//+ i64//one (i64//not value)))))
+(runtime: (i64##opposite value)
+ (_.return (_.? (i64##= i64##min value)
+ i64##min
+ (i64##+ i64##one (i64##not value)))))
-(runtime: i64//-one
- (i64//opposite i64//one))
+(runtime: i64##-one
+ (i64##opposite i64##one))
-(runtime: (i64//of_number value)
+(runtime: (i64##of_number value)
(_.return (<| (_.? (_.not_a_number? value)
- i64//zero)
- (_.? (_.<= (_.opposite i64//2^63) value)
- i64//min)
- (_.? (|> value (_.+ (_.i32 +1)) (_.>= i64//2^63))
- i64//max)
+ i64##zero)
+ (_.? (_.<= (_.opposite i64##2^63) value)
+ i64##min)
+ (_.? (|> value (_.+ (_.i32 +1)) (_.>= i64##2^63))
+ i64##max)
(_.? (|> value (_.< (_.i32 +0)))
- (|> value _.opposite i64//of_number i64//opposite))
- (..i64 (|> value (_./ i64//2^32) _.to_i32)
- (|> value (_.% i64//2^32) _.to_i32)))))
-
-(def: (cap_shift! shift)
- (-> Var Statement)
- (_.set shift (|> shift (_.bit_and (_.i32 +63)))))
-
-(def: (no_shift! shift input)
- (-> Var Var (-> Expression Expression))
- (_.? (|> shift (_.= (_.i32 +0)))
- input))
-
-(def: small_shift?
- (-> Var Expression)
- (|>> (_.< (_.i32 +32))))
-
-(runtime: (i64//left_shifted input shift)
- ($_ _.then
- (..cap_shift! shift)
- (_.return (<| (..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))]
- (..i64 high low)))
- (let [high (|> input (_.the ..i64_low_field) (_.left_shift (_.- (_.i32 +32) shift)))]
- (..i64 high (_.i32 +0)))))
- ))
-
-(runtime: (i64//arithmetic_right_shifted input shift)
- ($_ _.then
- (..cap_shift! shift)
- (_.return (<| (..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))))))]
- (..i64 high low)))
- (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)))]
- (..i64 high low))))))
-
-(runtime: (i64//right_shifted input shift)
- ($_ _.then
- (..cap_shift! shift)
- (_.return (<| (..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))))))]
- (..i64 high low)))
- (_.? (|> shift (_.= (_.i32 +32)))
- (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field))))
- (..i64 (_.i32 +0)
- (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift))))))))
-
-(def: runtime//bit
- Statement
- ($_ _.then
- @i64//and
- @i64//or
- @i64//xor
- @i64//not
- @i64//left_shifted
- @i64//arithmetic_right_shifted
- @i64//right_shifted
- ))
+ (|> value _.opposite i64##of_number i64##opposite))
+ (..i64 (|> value (_./ i64##2^32) _.to_i32)
+ (|> value (_.% i64##2^32) _.to_i32)))))
-(runtime: (i64//- parameter subject)
- (_.return (i64//+ (i64//opposite parameter) subject)))
+(runtime: (i64##- parameter subject)
+ (_.return (i64##+ (i64##opposite parameter) subject)))
-(runtime: (i64//* parameter subject)
+(runtime: (i64##* parameter subject)
(let [up_16 (_.left_shift (_.i32 +16))
high_16 (_.logic_right_shift (_.i32 +16))
low_16 (_.bit_and (_.i32 (.int (hex "FFFF"))))
@@ -521,7 +521,7 @@
(_.bit_or (up_16 x16) x00)))
))))
-(runtime: (i64//< parameter subject)
+(runtime: (i64##< parameter subject)
(let [negative? (|>> (_.the ..i64_high_field) (_.< (_.i32 +0)))]
(with_vars [-subject? -parameter?]
($_ _.then
@@ -531,65 +531,65 @@
(_.boolean true))
(_.? (_.and (_.not -subject?) -parameter?)
(_.boolean false))
- (negative? (i64//- parameter subject))))
+ (negative? (i64##- parameter subject))))
))))
-(def: (i64//<= param subject)
+(def: (i64##<= param subject)
(-> Expression Expression Expression)
- (|> (i64//< param subject)
- (_.or (i64//= param subject))))
+ (|> (i64##< param subject)
+ (_.or (i64##= param subject))))
(def: negative?
- (i64//< i64//zero))
+ (i64##< i64##zero))
-(runtime: (i64/// parameter subject)
- (<| (_.if (i64//= i64//zero parameter)
+(runtime: (i64##/ parameter subject)
+ (<| (_.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))
+ (_.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))]
+ (let [subject/2 (..i64##arithmetic_right_shifted subject (_.i32 +1))]
($_ _.then
- (_.define approximation (i64//left_shifted (i64/// parameter
+ (_.define approximation (i64##left_shifted (i64##/ parameter
subject/2)
(_.i32 +1)))
- (_.if (i64//= i64//zero approximation)
+ (_.if (i64##= i64##zero approximation)
(_.return (_.? (..negative? parameter)
- i64//one
- i64//-one))
- (let [remainder (i64//- (i64//* approximation
+ i64##one
+ i64##-one))
+ (let [remainder (i64##- (i64##* approximation
parameter)
subject)]
- (_.return (i64//+ (i64/// parameter
+ (_.return (i64##+ (i64##/ parameter
remainder)
approximation)))))))))
- (_.if (i64//= i64//min parameter)
- (_.return i64//zero))
+ (_.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))))))
+ (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))))
+ (_.return (i64##opposite (i64##/ (i64##opposite parameter) subject))))
(with_vars [result remainder]
($_ _.then
- (_.define result i64//zero)
+ (_.define result i64##zero)
(_.define remainder subject)
- (_.while (i64//<= remainder parameter)
+ (_.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)]
+ (let [approximate_result' (i64##of_number approximate)
+ approx_remainder (i64##* parameter approximate_result)]
($_ _.then
- (_.define approximate (|> (i64//number remainder)
- (_./ (i64//number parameter))
+ (_.define approximate (|> (i64##number remainder)
+ (_./ (i64##number parameter))
(_.apply/1 (_.var "Math.floor"))
(_.apply/2 (_.var "Math.max") (_.i32 +1))))
(_.define log2 (|> approximate
@@ -605,58 +605,60 @@
(_.define approximate_result approximate_result')
(_.define approximate_remainder approx_remainder)
(_.while (_.or (..negative? approximate_remainder)
- (i64//< 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
+ (_.set result (i64##+ (_.? (i64##= i64##zero approximate_result)
+ i64##one
approximate_result)
result))
- (_.set remainder (i64//- approximate_remainder remainder))))))
+ (_.set remainder (i64##- approximate_remainder remainder))))))
(_.return result)))))
-(runtime: (i64//% parameter subject)
+(runtime: (i64##% parameter subject)
(let [flat (|> subject
- (i64/// parameter)
- (i64//* parameter))]
- (_.return (i64//- flat subject))))
+ (i64##/ parameter)
+ (i64##* parameter))]
+ (_.return (i64##- flat subject))))
(def: runtime//i64
Statement
($_ _.then
- @i64//2^16
- @i64//2^32
- @i64//2^64
- @i64//2^63
- @i64//unsigned_low
- @i64//new
- @i64//zero
- @i64//min
- @i64//max
- @i64//one
- @i64//=
- @i64//+
- @i64//opposite
- @i64//number
- @i64//of_number
- @i64//-
- @i64//*
- @i64//<
- @i64///
- @i64//%
- runtime//bit
+ ..runtime//bit
+
+ @i64##2^16
+ @i64##2^32
+ @i64##2^64
+ @i64##2^63
+ @i64##unsigned_low
+ @i64##new
+ @i64##zero
+ @i64##min
+ @i64##max
+ @i64##one
+ @i64##=
+ @i64##+
+ @i64##opposite
+ @i64##-one
+ @i64##number
+ @i64##of_number
+ @i64##-
+ @i64##*
+ @i64##<
+ @i64##/
+ @i64##%
))
(runtime: (text//index start part text)
(with_vars [idx]
($_ _.then
- (_.define idx (|> text (_.do "indexOf" (list part (i64//number start)))))
+ (_.define idx (|> text (_.do "indexOf" (list part (i64##number start)))))
(_.return (_.? (_.= (_.i32 -1) idx)
..none
- (..some (i64//of_number idx)))))))
+ (..some (i64##of_number idx)))))))
(runtime: (text//clip offset length text)
(_.return (|> text (_.do "substring" (list (_.the ..i64_low_field offset)
@@ -669,7 +671,7 @@
(_.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//of_number result))))))
+ (_.return (i64##of_number result))))))
(def: runtime//text
Statement