aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/unsafe
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/unsafe')
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux115
-rw-r--r--stdlib/source/unsafe/lux/data/collection/array.lux74
2 files changed, 94 insertions, 95 deletions
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index d3b824dfb..1e79c9480 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -70,7 +70,7 @@
(,, (.static @.js))
(.|> <size>
.int
- "lux i64 f64"
+ .int_f64#
[]
("js object new" ("js constant" "ArrayBuffer"))
[]
@@ -101,7 +101,7 @@
(.|> <it>
("js object get" "length")
(.as .Frac)
- "lux f64 i64"
+ .f64_int#
.nat)
(,, (.static @.python))
@@ -126,7 +126,7 @@
<jvm> (ffi.byte_to_long <jvm>)
<jvm> (.|> <jvm>
(.as .I64)
- ("lux i64 and" <byte_mask>))]
+ (.i64_and# <byte_mask>))]
(def .public bits_8
(template (bits_8 index it)
[(.<| (.as .I64)
@@ -139,7 +139,7 @@
(.as (array.Array .Frac))
("js array read" <index>)
(.as .Frac)
- "lux f64 i64"
+ .f64_int#
.i64)
(,, (.static @.python))
@@ -161,9 +161,9 @@
it (.is ..Binary it')])
(.as .I64)
(.is (.I64 .Any))
- (.all "lux i64 or"
- ("lux i64 left-shift" 8 (..bits_8 index it))
- (..bits_8 ("lux i64 +" 1 index) it)))]))
+ (.all .i64_or#
+ (.i64_left# 08 (..bits_8 index it))
+ (..bits_8 (.i64_+# 1 index) it)))]))
(def .public bits_32
(template (bits_32 index' it')
@@ -171,11 +171,11 @@
it (.is ..Binary it')])
(.as .I64)
(.is (.I64 .Any))
- (.all "lux i64 or"
- ("lux i64 left-shift" 24 (..bits_8 index it))
- ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 1 index) it))
- ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 2 index) it))
- (..bits_8 ("lux i64 +" 3 index) it)))]))
+ (.all .i64_or#
+ (.i64_left# 24 (..bits_8 index it))
+ (.i64_left# 16 (..bits_8 (.i64_+# 1 index) it))
+ (.i64_left# 08 (..bits_8 (.i64_+# 2 index) it))
+ (..bits_8 (.i64_+# 3 index) it)))]))
(def .public bits_64
(template (bits_64 index' it')
@@ -183,15 +183,15 @@
it (.is ..Binary it')])
(.as .I64)
(.is (.I64 .Any))
- (.all "lux i64 or"
- ("lux i64 left-shift" 56 (..bits_8 index it))
- ("lux i64 left-shift" 48 (..bits_8 ("lux i64 +" 1 index) it))
- ("lux i64 left-shift" 40 (..bits_8 ("lux i64 +" 2 index) it))
- ("lux i64 left-shift" 32 (..bits_8 ("lux i64 +" 3 index) it))
- ("lux i64 left-shift" 24 (..bits_8 ("lux i64 +" 4 index) it))
- ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 5 index) it))
- ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 6 index) it))
- (..bits_8 ("lux i64 +" 7 index) it)))]))
+ (.all .i64_or#
+ (.i64_left# 56 (..bits_8 index it))
+ (.i64_left# 48 (..bits_8 (.i64_+# 1 index) it))
+ (.i64_left# 40 (..bits_8 (.i64_+# 2 index) it))
+ (.i64_left# 32 (..bits_8 (.i64_+# 3 index) it))
+ (.i64_left# 24 (..bits_8 (.i64_+# 4 index) it))
+ (.i64_left# 16 (..bits_8 (.i64_+# 5 index) it))
+ (.i64_left# 08 (..bits_8 (.i64_+# 6 index) it))
+ (..bits_8 (.i64_+# 7 index) it)))]))
(with_expansions [<byte> (hex "FF")
<it> (.is ..Binary it)
@@ -219,8 +219,8 @@
("js array write" <index>
(.|> <value>
.int
- ("lux i64 and" (.int <byte>))
- "lux i64 f64"
+ (.i64_and# (.int <byte>))
+ .int_f64#
.as_expected))
(.as ..Binary))
@@ -228,7 +228,7 @@
(.|> <it>
(.is ..Binary)
(.as (array.Array (.I64 .Any)))
- ("python array write" <index> (.|> <value> ("lux i64 and" <byte>) (.is (.I64 .Any))))
+ ("python array write" <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any))))
(.as ..Binary))
(,, (.static @.scheme))
@@ -238,52 +238,52 @@
it'))
... Default
- (array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))]))))
+ (array.has! <index> (.|> <value> .int (.i64_and# (.int <byte>))) <it>)))]))))
(def .public has_16!
(template (has_16! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.|> it
- (..has_8! index ("lux i64 right-shift" 8 value))
- (..has_8! ("lux i64 +" 1 index) value)))]))
+ (..has_8! index (.i64_right# 08 value))
+ (..has_8! (.i64_+# 1 index) value)))]))
(def .public has_32!
(template (has_32! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.|> it
- (..has_8! index ("lux i64 right-shift" 24 value))
- (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value))
- (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value))
- (..has_8! ("lux i64 +" 3 index) value)))]))
+ (..has_8! index (.i64_right# 24 value))
+ (..has_8! (.i64_+# 1 index) (.i64_right# 16 value))
+ (..has_8! (.i64_+# 2 index) (.i64_right# 08 value))
+ (..has_8! (.i64_+# 3 index) value)))]))
(`` (def .public has_64!
(template (has_64! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.for (,, (.static @.scheme)) (.let [write_high (.is (.-> ..Binary ..Binary)
- (.|>> (..has_8! index ("lux i64 right-shift" 56 value))
- (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
- (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
- (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))))
+ (.|>> (..has_8! index (.i64_right# 56 value))
+ (..has_8! (.i64_+# 1 index) (.i64_right# 48 value))
+ (..has_8! (.i64_+# 2 index) (.i64_right# 40 value))
+ (..has_8! (.i64_+# 3 index) (.i64_right# 32 value))))
write_low (.is (.-> ..Binary ..Binary)
- (.|>> (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
- (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
- (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
- (..has_8! ("lux i64 +" 7 index) value)))]
+ (.|>> (..has_8! (.i64_+# 4 index) (.i64_right# 24 value))
+ (..has_8! (.i64_+# 5 index) (.i64_right# 16 value))
+ (..has_8! (.i64_+# 6 index) (.i64_right# 08 value))
+ (..has_8! (.i64_+# 7 index) value)))]
(.|> it
write_high
write_low))
(.|> it
- (..has_8! index ("lux i64 right-shift" 56 value))
- (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
- (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
- (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))
- (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
- (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
- (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
- (..has_8! ("lux i64 +" 7 index) value))))])))
+ (..has_8! index (.i64_right# 56 value))
+ (..has_8! (.i64_+# 1 index) (.i64_right# 48 value))
+ (..has_8! (.i64_+# 2 index) (.i64_right# 40 value))
+ (..has_8! (.i64_+# 3 index) (.i64_right# 32 value))
+ (..has_8! (.i64_+# 4 index) (.i64_right# 24 value))
+ (..has_8! (.i64_+# 5 index) (.i64_right# 16 value))
+ (..has_8! (.i64_+# 6 index) (.i64_right# 08 value))
+ (..has_8! (.i64_+# 7 index) value))))])))
(with_expansions [<reference> (.is ..Binary reference')
<sample> (.is ..Binary sample')
@@ -296,14 +296,13 @@
(.let [reference <reference>
sample <sample>
limit (..size reference)]
- (.and ("lux i64 =" limit (..size sample))
+ (.and (.i64_=# limit (..size sample))
(.loop (again [index 0])
- (.if ("lux i64 =" limit index)
+ (.if (.i64_=# limit index)
.true
- (.and ("lux i64 ="
- (..bits_8 index reference)
- (..bits_8 index sample))
- (again ("lux i64 +" 1 index))))))))]))))
+ (.and (.i64_=# (..bits_8 index reference)
+ (..bits_8 index sample))
+ (again (.i64_+# 1 index))))))))]))))
... TODO: Turn into a template ASAP.
(`` (def .public copy!
@@ -320,19 +319,19 @@
... Default
(.loop (again [index 0])
- (.if ("lux i64 <" (.int bytes) (.int index))
+ (.if (.int_<# (.int bytes) (.int index))
(.exec
- (..has_8! ("lux i64 +" target_offset index)
- (..bits_8 ("lux i64 +" source_offset index) source)
+ (..has_8! (.i64_+# target_offset index)
+ (..bits_8 (.i64_+# source_offset index) source)
target)
- (again ("lux i64 +" 1 index)))
+ (again (.i64_+# 1 index)))
target)))))))
... TODO: Turn into a template ASAP.
(`` (with_expansions [<jvm> (java/util/Arrays::copyOfRange binary
(ffi.as_int (.int offset))
(ffi.as_int (.int limit)))
- <jvm> (.let [limit ("lux i64 +" size offset)]
+ <jvm> (.let [limit (.i64_+# size offset)]
<jvm>)]
(def .public slice
(inlined (_ offset size binary)
diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux
index 870e9eb4b..6f85f60bb 100644
--- a/stdlib/source/unsafe/lux/data/collection/array.lux
+++ b/stdlib/source/unsafe/lux/data/collection/array.lux
@@ -86,7 +86,7 @@
(.-> .Nat (..Array' r w) .Bit))
(.function (lacks? index array)
(.let [size (..size array)]
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.for (,, (.static @.old))
("jvm object null?" ("jvm aaload" array index))
@@ -155,7 +155,7 @@
(.-> .Nat (..Array' r w) (..Array' r w)))
(.function (lacks! index array)
(.let [size (..size array)]
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.for (,, (.static @.old))
(..has! index (.as_expected ("jvm object null")) array)
@@ -201,14 +201,14 @@
(..Array' r w)))
(.function (copy! length src_start src_array dest_start dest_array)
(.loop (again [offset 0])
- (.if ("lux i64 <" (.int length) (.int offset))
+ (.if (.int_<# (.int length) (.int offset))
(.exec
- (.if (..lacks? ("lux i64 +" offset src_start) src_array)
- (..lacks! ("lux i64 +" offset dest_start) dest_array)
- (..has! ("lux i64 +" offset dest_start)
- (..item ("lux i64 +" offset src_start) src_array)
+ (.if (..lacks? (.i64_+# offset src_start) src_array)
+ (..lacks! (.i64_+# offset dest_start) dest_array)
+ (..has! (.i64_+# offset dest_start)
+ (..item (.i64_+# offset src_start) src_array)
dest_array))
- (again ("lux i64 +" 1 offset)))
+ (again (.i64_+# 1 offset)))
dest_array))))
<length> <src_start> <src_array> <dest_start> <dest_array>)]))
@@ -220,15 +220,15 @@
(.let [size (..size array)]
(.loop (again [index 0
it 0])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.if (..lacks? index array)
- (again ("lux i64 +" 1 index) <when_lacks>)
- (again ("lux i64 +" 1 index) <when_has>))
+ (again (.i64_+# 1 index) <when_lacks>)
+ (again (.i64_+# 1 index) <when_has>))
it)))))
<array>)]))]
- [occupancy it ("lux i64 +" 1 it)]
- [vacancy ("lux i64 +" 1 it) it]
+ [occupancy it (.i64_+# 1 it)]
+ [vacancy (.i64_+# 1 it) it]
)
(def .public only!
@@ -238,14 +238,14 @@
(.function (only! ? it)
(.let [size (..size it)]
(.loop (again [index 0])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.exec
(.if (..lacks? index it)
it
(.if (? (..item index it))
it
(..lacks! index it)))
- (again ("lux i64 +" 1 index)))
+ (again (.i64_+# 1 index)))
it)))))
<?> <it>)]))
@@ -257,13 +257,13 @@
(.function (<name> ? it)
(.let [size (..size it)]
(.loop (again [index 0])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.if (..lacks? index it)
- (again ("lux i64 +" 1 index))
+ (again (.i64_+# 1 index))
(.let [it (..item index it)]
(.if <test>
{.#Some <term>}
- (again ("lux i64 +" 1 index)))))
+ (again (.i64_+# 1 index)))))
{.#None})))))
<?> <it>)]))]
@@ -294,7 +294,7 @@
{.#Item head tail}
(.exec
(..has! index head output)
- (again ("lux i64 +" 1 index) tail)))))))
+ (again (.i64_+# 1 index) tail)))))))
<input>)]))
(def underflow
@@ -305,11 +305,11 @@
(template (list|-default <empty> <array>)
[((.is (.All (_ r w) (.-> (.List r) (..Array' r w) (.List r)))
(.function (list|-default empty array)
- (.loop (again [index ("lux i64 -" 1 (..size array))
+ (.loop (again [index (.i64_-# 1 (..size array))
output empty])
- (.if ("lux i64 =" (,, (.static ..underflow)) index)
+ (.if (.i64_=# (,, (.static ..underflow)) index)
output
- (again ("lux i64 -" 1 index)
+ (again (.i64_-# 1 index)
(.if (..lacks? index array)
output
{.#Item (..item index array) output}))))))
@@ -319,12 +319,12 @@
(template (list|+default <default> <array>)
[((.is (.All (_ r w) (.-> r (..Array' r w) (.List r)))
(.function (list|+default default array)
- (.loop (again [index ("lux i64 -" 1 (..size array))
+ (.loop (again [index (.i64_-# 1 (..size array))
output (`` (.is (.List (,, (.these (,, (.type_of default)))))
{.#End}))])
- (.if ("lux i64 =" (,, (.static ..underflow)) index)
+ (.if (.i64_=# (,, (.static ..underflow)) index)
output
- (again ("lux i64 -" 1 index)
+ (again (.i64_-# 1 index)
{.#Item (.if (..lacks? index array)
default
(..item index array))
@@ -348,16 +348,16 @@
[((.is (.All (_ r w0 w1) (.-> (.-> r r .Bit) (..Array' r w0) (..Array' r w1) .Bit))
(.function (= //#= left/* right/*)
(.let [size (..size left/*)]
- (.and ("lux i64 =" (..size right/*) size)
+ (.and (.i64_=# (..size right/*) size)
(.loop (again [index 0])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.if (..lacks? index left/*)
(..lacks? index right/*)
(.if (..lacks? index right/*)
.false
(.and (//#= (..item index left/*)
(..item index right/*))
- (again ("lux i64 +" 1 index)))))
+ (again (.i64_+# 1 index)))))
true))))))
<//#=> <left/*> <right/*>)]))
@@ -367,7 +367,7 @@
(.function (composite left/* right/*)
(.let [|left| (..size left/*)
|right| (..size right/*)]
- (.|> (..empty ("lux i64 +" |left| |right|))
+ (.|> (..empty (.i64_+# |left| |right|))
(..copy! |left| 0 left/* 0)
(..copy! |right| 0 right/* |left|)))))
<left/*> <right/*>)]))
@@ -380,10 +380,10 @@
(.let [size (..size it)]
(.loop (again [index 0
so_far init])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.if (..lacks? index it)
- (again ("lux i64 +" 1 index) so_far)
- (again ("lux i64 +" 1 index) ($ index (..item index it) so_far)))
+ (again (.i64_+# 1 index) so_far)
+ (again (.i64_+# 1 index) ($ index (..item index it) so_far)))
so_far)))))
<$> <init> <it>)]))
@@ -406,11 +406,11 @@
(.function (<name> ? it)
(.let [size (..size it)]
(.loop (again [index 0])
- (.if ("lux i64 <" (.int size) (.int index))
+ (.if (.int_<# (.int size) (.int index))
(.if (..lacks? index it)
- (again ("lux i64 +" 1 index))
+ (again (.i64_+# 1 index))
(<op> (? (..item index it))
- (again ("lux i64 +" 1 index))))
+ (again (.i64_+# 1 index))))
<init>)))))
<?> <it>)]))]
@@ -425,8 +425,8 @@
(.function (one ? it)
(.let [size (..size it)]
(.loop (again [index 0])
- (.if ("lux i64 <" (.int size) (.int index))
- (with_expansions [<again> (again ("lux i64 +" 1 index))]
+ (.if (.int_<# (.int size) (.int index))
+ (with_expansions [<again> (again (.i64_+# 1 index))]
(.if (..lacks? index it)
<again>
(.when (? (..item index it))