aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/binary.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/world/binary.lux')
-rw-r--r--stdlib/source/lux/world/binary.lux70
1 files changed, 35 insertions, 35 deletions
diff --git a/stdlib/source/lux/world/binary.lux b/stdlib/source/lux/world/binary.lux
index d89b7ae3a..0b72af60b 100644
--- a/stdlib/source/lux/world/binary.lux
+++ b/stdlib/source/lux/world/binary.lux
@@ -30,7 +30,7 @@
(def: byte-mask
I64
- (|> +1 (i64.left-shift +8) dec .i64))
+ (|> |1 (i64.left-shift |8) dec .i64))
(def: i64
(-> (primitive "java.lang.Byte") I64)
@@ -52,34 +52,34 @@
(def: #export (read/16 idx binary)
(-> Nat Binary (Error I64))
- (if (n/< (host.array-length binary) (n/+ +1 idx))
+ (if (n/< (host.array-length binary) (n/+ |1 idx))
(#error.Success ($_ i64.or
- (i64.left-shift +8 (..i64 (host.array-read idx binary)))
- (..i64 (host.array-read (n/+ +1 idx) binary))))
+ (i64.left-shift |8 (..i64 (host.array-read idx binary)))
+ (..i64 (host.array-read (n/+ |1 idx) binary))))
(ex.throw index-out-of-bounds (%n idx))))
(def: #export (read/32 idx binary)
(-> Nat Binary (Error I64))
- (if (n/< (host.array-length binary) (n/+ +3 idx))
+ (if (n/< (host.array-length binary) (n/+ |3 idx))
(#error.Success ($_ i64.or
- (i64.left-shift +24 (..i64 (host.array-read idx binary)))
- (i64.left-shift +16 (..i64 (host.array-read (n/+ +1 idx) binary)))
- (i64.left-shift +8 (..i64 (host.array-read (n/+ +2 idx) binary)))
- (..i64 (host.array-read (n/+ +3 idx) binary))))
+ (i64.left-shift |24 (..i64 (host.array-read idx binary)))
+ (i64.left-shift |16 (..i64 (host.array-read (n/+ |1 idx) binary)))
+ (i64.left-shift |8 (..i64 (host.array-read (n/+ |2 idx) binary)))
+ (..i64 (host.array-read (n/+ |3 idx) binary))))
(ex.throw index-out-of-bounds (%n idx))))
(def: #export (read/64 idx binary)
(-> Nat Binary (Error I64))
- (if (n/< (host.array-length binary) (n/+ +7 idx))
+ (if (n/< (host.array-length binary) (n/+ |7 idx))
(#error.Success ($_ i64.or
- (i64.left-shift +56 (..i64 (host.array-read idx binary)))
- (i64.left-shift +48 (..i64 (host.array-read (n/+ +1 idx) binary)))
- (i64.left-shift +40 (..i64 (host.array-read (n/+ +2 idx) binary)))
- (i64.left-shift +32 (..i64 (host.array-read (n/+ +3 idx) binary)))
- (i64.left-shift +24 (..i64 (host.array-read (n/+ +4 idx) binary)))
- (i64.left-shift +16 (..i64 (host.array-read (n/+ +5 idx) binary)))
- (i64.left-shift +8 (..i64 (host.array-read (n/+ +6 idx) binary)))
- (..i64 (host.array-read (n/+ +7 idx) binary))))
+ (i64.left-shift |56 (..i64 (host.array-read idx binary)))
+ (i64.left-shift |48 (..i64 (host.array-read (n/+ |1 idx) binary)))
+ (i64.left-shift |40 (..i64 (host.array-read (n/+ |2 idx) binary)))
+ (i64.left-shift |32 (..i64 (host.array-read (n/+ |3 idx) binary)))
+ (i64.left-shift |24 (..i64 (host.array-read (n/+ |4 idx) binary)))
+ (i64.left-shift |16 (..i64 (host.array-read (n/+ |5 idx) binary)))
+ (i64.left-shift |8 (..i64 (host.array-read (n/+ |6 idx) binary)))
+ (..i64 (host.array-read (n/+ |7 idx) binary))))
(ex.throw index-out-of-bounds (%n idx))))
(def: #export (write/8 idx value binary)
@@ -92,36 +92,36 @@
(def: #export (write/16 idx value binary)
(-> Nat (I64 Any) Binary (Error Binary))
- (if (n/< (host.array-length binary) (n/+ +1 idx))
+ (if (n/< (host.array-length binary) (n/+ |1 idx))
(exec (|> binary
- (host.array-write idx (..byte (i64.logical-right-shift +8 value)))
- (host.array-write (n/+ +1 idx) (..byte value)))
+ (host.array-write idx (..byte (i64.logical-right-shift |8 value)))
+ (host.array-write (n/+ |1 idx) (..byte value)))
(#error.Success binary))
(ex.throw index-out-of-bounds (%n idx))))
(def: #export (write/32 idx value binary)
(-> Nat (I64 Any) Binary (Error Binary))
- (if (n/< (host.array-length binary) (n/+ +3 idx))
+ (if (n/< (host.array-length binary) (n/+ |3 idx))
(exec (|> binary
- (host.array-write idx (..byte (i64.logical-right-shift +24 value)))
- (host.array-write (n/+ +1 idx) (..byte (i64.logical-right-shift +16 value)))
- (host.array-write (n/+ +2 idx) (..byte (i64.logical-right-shift +8 value)))
- (host.array-write (n/+ +3 idx) (..byte value)))
+ (host.array-write idx (..byte (i64.logical-right-shift |24 value)))
+ (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |16 value)))
+ (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |8 value)))
+ (host.array-write (n/+ |3 idx) (..byte value)))
(#error.Success binary))
(ex.throw index-out-of-bounds (%n idx))))
(def: #export (write/64 idx value binary)
(-> Nat (I64 Any) Binary (Error Binary))
- (if (n/< (host.array-length binary) (n/+ +7 idx))
+ (if (n/< (host.array-length binary) (n/+ |7 idx))
(exec (|> binary
- (host.array-write idx (..byte (i64.logical-right-shift +56 value)))
- (host.array-write (n/+ +1 idx) (..byte (i64.logical-right-shift +48 value)))
- (host.array-write (n/+ +2 idx) (..byte (i64.logical-right-shift +40 value)))
- (host.array-write (n/+ +3 idx) (..byte (i64.logical-right-shift +32 value)))
- (host.array-write (n/+ +4 idx) (..byte (i64.logical-right-shift +24 value)))
- (host.array-write (n/+ +5 idx) (..byte (i64.logical-right-shift +16 value)))
- (host.array-write (n/+ +6 idx) (..byte (i64.logical-right-shift +8 value)))
- (host.array-write (n/+ +7 idx) (..byte value)))
+ (host.array-write idx (..byte (i64.logical-right-shift |56 value)))
+ (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |48 value)))
+ (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |40 value)))
+ (host.array-write (n/+ |3 idx) (..byte (i64.logical-right-shift |32 value)))
+ (host.array-write (n/+ |4 idx) (..byte (i64.logical-right-shift |24 value)))
+ (host.array-write (n/+ |5 idx) (..byte (i64.logical-right-shift |16 value)))
+ (host.array-write (n/+ |6 idx) (..byte (i64.logical-right-shift |8 value)))
+ (host.array-write (n/+ |7 idx) (..byte value)))
(#error.Success binary))
(ex.throw index-out-of-bounds (%n idx))))