aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/unsafe
diff options
context:
space:
mode:
authorEduardo Julian2022-02-16 04:41:41 -0400
committerEduardo Julian2022-02-16 04:41:41 -0400
commitde8af6044d590354563f4ea8849d98e8637c034a (patch)
tree7ac4dc03830fc4f8154ec7e31a3971e5b7a5a923 /stdlib/source/unsafe
parentb68f2b6aead6224c14902c80fc00c27705eece6c (diff)
FIXED loop binding initialization in several back-ends.
Diffstat (limited to 'stdlib/source/unsafe')
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux129
1 files changed, 65 insertions, 64 deletions
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index d91893c38..ffc2b5e84 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -30,14 +30,8 @@
@.jvm (as_is <jvm>)
@.js
- (as_is (ffi.import: ArrayBuffer
- ["[1]::[0]"
- (new [ffi.Number])])
-
- (ffi.import: Uint8Array
- ["[1]::[0]"
- (new [ArrayBuffer])
- (length ffi.Number)])
+ (as_is (ffi.import: ArrayBuffer)
+ (ffi.import: Uint8Array)
(type: .public Binary
Uint8Array))
@@ -71,8 +65,11 @@
(|> <size>
.int
"lux i64 f64"
- ArrayBuffer::new
- Uint8Array::new)
+ []
+ ("js object new" ("js constant" "ArrayBuffer"))
+ []
+ ("js object new" ("js constant" "Uint8Array"))
+ (:as ..Binary))
@.python
(|> <size>
@@ -94,8 +91,8 @@
@.js
(|> <it>
- Uint8Array::length
- (: Frac)
+ ("js object get" "length")
+ (:as Frac)
"lux f64 i64"
.nat)
@@ -123,64 +120,68 @@
(:as I64)
("lux i64 and" <byte_mask>))]
(template: .public (bytes/1 index it)
- [(: I64
- (`` (for [@.old (~~ <jvm>)
- @.jvm (~~ <jvm>)
-
- @.js
- (|> <it>
- (:as (array.Array .Frac))
- ("js array read" <index>)
- "lux f64 i64"
- .i64)
-
- @.python
- (|> <it>
- (:as (array.Array .I64))
- ("python array read" <index>))
-
- @.scheme
- (..bytevector-u8-ref [<it> <index>])]
-
- ... Default
- (.case (array.read! <index> <it>)
- {.#Some it}
- it
-
- {.#None}
- (.i64 (: (I64 Any) 0))))))]))
+ [(<| (:as .I64)
+ (: (.I64 .Any))
+ (`` (for [@.old (~~ <jvm>)
+ @.jvm (~~ <jvm>)
+
+ @.js
+ (|> <it>
+ (:as (array.Array .Frac))
+ ("js array read" <index>)
+ "lux f64 i64"
+ .i64)
+
+ @.python
+ (|> <it>
+ (:as (array.Array .I64))
+ ("python array read" <index>))
+
+ @.scheme
+ (..bytevector-u8-ref [<it> <index>])]
+
+ ... Default
+ (.case (array.read! <index> <it>)
+ {.#Some it}
+ it
+
+ {.#None}
+ (.i64 (: (I64 Any) 0))))))]))
(template: .public (bytes/2 index' it')
- [(let [index (: Nat index')
- it (: ..Binary it')]
- (: I64
- ($_ "lux i64 or"
- ("lux i64 left-shift" 8 (..bytes/1 index it))
- (..bytes/1 ("lux i64 +" 1 index) it))))])
+ [(<| (let [index (: Nat index')
+ it (: ..Binary it')])
+ (:as .I64)
+ (: (.I64 .Any))
+ ($_ "lux i64 or"
+ ("lux i64 left-shift" 8 (..bytes/1 index it))
+ (..bytes/1 ("lux i64 +" 1 index) it)))])
(template: .public (bytes/4 index' it')
- [(let [index (: Nat index')
- it (: ..Binary it')]
- (: I64
- ($_ "lux i64 or"
- ("lux i64 left-shift" 24 (..bytes/1 index it))
- ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 1 index) it))
- ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 2 index) it))
- (..bytes/1 ("lux i64 +" 3 index) it))))])
+ [(<| (let [index (: Nat index')
+ it (: ..Binary it')])
+ (:as .I64)
+ (: (.I64 .Any))
+ ($_ "lux i64 or"
+ ("lux i64 left-shift" 24 (..bytes/1 index it))
+ ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 1 index) it))
+ ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 2 index) it))
+ (..bytes/1 ("lux i64 +" 3 index) it)))])
(template: .public (bytes/8 index' it')
- [(let [index (: Nat index')
- it (: ..Binary it')]
- (: I64
- ($_ "lux i64 or"
- ("lux i64 left-shift" 56 (..bytes/1 index it))
- ("lux i64 left-shift" 48 (..bytes/1 ("lux i64 +" 1 index) it))
- ("lux i64 left-shift" 40 (..bytes/1 ("lux i64 +" 2 index) it))
- ("lux i64 left-shift" 32 (..bytes/1 ("lux i64 +" 3 index) it))
- ("lux i64 left-shift" 24 (..bytes/1 ("lux i64 +" 4 index) it))
- ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 5 index) it))
- ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 6 index) it))
- (..bytes/1 ("lux i64 +" 7 index) it))))])
+ [(<| (let [index (: Nat index')
+ it (: ..Binary it')])
+ (:as .I64)
+ (: (.I64 .Any))
+ ($_ "lux i64 or"
+ ("lux i64 left-shift" 56 (..bytes/1 index it))
+ ("lux i64 left-shift" 48 (..bytes/1 ("lux i64 +" 1 index) it))
+ ("lux i64 left-shift" 40 (..bytes/1 ("lux i64 +" 2 index) it))
+ ("lux i64 left-shift" 32 (..bytes/1 ("lux i64 +" 3 index) it))
+ ("lux i64 left-shift" 24 (..bytes/1 ("lux i64 +" 4 index) it))
+ ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 5 index) it))
+ ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 6 index) it))
+ (..bytes/1 ("lux i64 +" 7 index) it)))])
(with_expansions [<byte> (hex "FF")
<it> (: ..Binary it)