@grain/stdlib 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +123 -77
- package/bigint.md +30 -30
- package/buffer.gr +20 -53
- package/buffer.md +47 -47
- package/bytes.gr +111 -35
- package/bytes.md +111 -32
- package/char.gr +201 -99
- package/char.md +361 -34
- package/exception.gr +11 -11
- package/exception.md +26 -1
- package/float32.gr +327 -3
- package/float32.md +606 -19
- package/float64.gr +320 -3
- package/float64.md +606 -19
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +102 -14
- package/int16.md +23 -23
- package/int32.gr +25 -4
- package/int32.md +65 -30
- package/int64.gr +26 -1
- package/int64.md +65 -30
- package/int8.md +23 -23
- package/json.gr +366 -51
- package/json.md +418 -2
- package/list.gr +328 -31
- package/list.md +492 -69
- package/map.gr +20 -12
- package/map.md +44 -38
- package/marshal.gr +41 -40
- package/marshal.md +2 -2
- package/number.gr +159 -30
- package/number.md +215 -38
- package/option.md +21 -21
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +103 -12
- package/pervasives.gr +2 -2
- package/pervasives.md +37 -37
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +19 -19
- package/queue.gr +183 -29
- package/queue.md +296 -40
- package/random.md +6 -6
- package/range.gr +4 -4
- package/range.md +6 -6
- package/rational.md +16 -16
- package/regex.gr +52 -51
- package/regex.md +11 -11
- package/result.md +16 -16
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +8 -8
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +1 -1
- package/runtime/dataStructures.md +33 -33
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +1 -1
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +4 -4
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +79 -73
- package/runtime/string.gr +37 -105
- package/runtime/string.md +3 -9
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +13 -13
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +138 -138
- package/set.gr +18 -11
- package/set.md +42 -36
- package/stack.gr +171 -2
- package/stack.md +297 -15
- package/string.gr +352 -557
- package/string.md +77 -34
- package/uint16.md +22 -22
- package/uint32.gr +25 -4
- package/uint32.md +63 -28
- package/uint64.gr +25 -5
- package/uint64.md +63 -28
- package/uint8.md +22 -22
- package/uri.gr +57 -53
- package/uri.md +11 -12
- package/wasi/file.gr +67 -59
- package/wasi/file.md +39 -39
- package/wasi/process.md +5 -5
- package/wasi/random.md +3 -3
- package/wasi/time.md +4 -4
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/bigint.md
CHANGED
|
@@ -37,7 +37,7 @@ No other changes yet.
|
|
|
37
37
|
</details>
|
|
38
38
|
|
|
39
39
|
```grain
|
|
40
|
-
fromNumber
|
|
40
|
+
fromNumber: (number: Number) => BigInt
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Converts a Number to a BigInt.
|
|
@@ -62,7 +62,7 @@ No other changes yet.
|
|
|
62
62
|
</details>
|
|
63
63
|
|
|
64
64
|
```grain
|
|
65
|
-
toNumber
|
|
65
|
+
toNumber: (num: BigInt) => Number
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Converts a BigInt to a Number.
|
|
@@ -87,7 +87,7 @@ No other changes yet.
|
|
|
87
87
|
</details>
|
|
88
88
|
|
|
89
89
|
```grain
|
|
90
|
-
incr
|
|
90
|
+
incr: (num: BigInt) => BigInt
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
Increments the value by one.
|
|
@@ -122,7 +122,7 @@ No other changes yet.
|
|
|
122
122
|
</details>
|
|
123
123
|
|
|
124
124
|
```grain
|
|
125
|
-
decr
|
|
125
|
+
decr: (num: BigInt) => BigInt
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
Decrements the value by one.
|
|
@@ -157,7 +157,7 @@ No other changes yet.
|
|
|
157
157
|
</details>
|
|
158
158
|
|
|
159
159
|
```grain
|
|
160
|
-
neg
|
|
160
|
+
neg: (num: BigInt) => BigInt
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
Negates the given operand.
|
|
@@ -192,7 +192,7 @@ No other changes yet.
|
|
|
192
192
|
</details>
|
|
193
193
|
|
|
194
194
|
```grain
|
|
195
|
-
abs
|
|
195
|
+
abs: (num: BigInt) => BigInt
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
Returns the absolute value of the given operand.
|
|
@@ -234,7 +234,7 @@ BigInt.abs(-1t) == 1t
|
|
|
234
234
|
</details>
|
|
235
235
|
|
|
236
236
|
```grain
|
|
237
|
-
(+)
|
|
237
|
+
(+): (num1: BigInt, num2: BigInt) => BigInt
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
Computes the sum of its operands.
|
|
@@ -274,7 +274,7 @@ assert 1t + 1t == 2t
|
|
|
274
274
|
</details>
|
|
275
275
|
|
|
276
276
|
```grain
|
|
277
|
-
(-)
|
|
277
|
+
(-): (num1: BigInt, num2: BigInt) => BigInt
|
|
278
278
|
```
|
|
279
279
|
|
|
280
280
|
Computes the difference of its operands.
|
|
@@ -314,7 +314,7 @@ assert 3t - 1t == 2t
|
|
|
314
314
|
</details>
|
|
315
315
|
|
|
316
316
|
```grain
|
|
317
|
-
(*)
|
|
317
|
+
(*): (num1: BigInt, num2: BigInt) => BigInt
|
|
318
318
|
```
|
|
319
319
|
|
|
320
320
|
Computes the product of its operands.
|
|
@@ -354,7 +354,7 @@ assert 3t * 3t == 9t
|
|
|
354
354
|
</details>
|
|
355
355
|
|
|
356
356
|
```grain
|
|
357
|
-
(/)
|
|
357
|
+
(/): (num1: BigInt, num2: BigInt) => BigInt
|
|
358
358
|
```
|
|
359
359
|
|
|
360
360
|
Computes the quotient of its operands using signed (truncated) division
|
|
@@ -388,7 +388,7 @@ No other changes yet.
|
|
|
388
388
|
</details>
|
|
389
389
|
|
|
390
390
|
```grain
|
|
391
|
-
rem
|
|
391
|
+
rem: (num1: BigInt, num2: BigInt) => BigInt
|
|
392
392
|
```
|
|
393
393
|
|
|
394
394
|
Computes the remainder of the division of its operands using signed (truncated) division
|
|
@@ -421,7 +421,7 @@ No other changes yet.
|
|
|
421
421
|
</details>
|
|
422
422
|
|
|
423
423
|
```grain
|
|
424
|
-
quotRem
|
|
424
|
+
quotRem: (num1: BigInt, num2: BigInt) => (BigInt, BigInt)
|
|
425
425
|
```
|
|
426
426
|
|
|
427
427
|
Computes the quotient and remainder of its operands using signed (truncated) division.
|
|
@@ -453,7 +453,7 @@ No other changes yet.
|
|
|
453
453
|
</details>
|
|
454
454
|
|
|
455
455
|
```grain
|
|
456
|
-
gcd
|
|
456
|
+
gcd: (num1: BigInt, num2: BigInt) => BigInt
|
|
457
457
|
```
|
|
458
458
|
|
|
459
459
|
Computes the greatest common divisior of the two operands.
|
|
@@ -492,7 +492,7 @@ BigInt.gcd(36t, 24t) == 12t
|
|
|
492
492
|
</details>
|
|
493
493
|
|
|
494
494
|
```grain
|
|
495
|
-
(<<)
|
|
495
|
+
(<<): (num: BigInt, places: Int32) => BigInt
|
|
496
496
|
```
|
|
497
497
|
|
|
498
498
|
Shifts the bits of the value left by the given number of bits.
|
|
@@ -532,7 +532,7 @@ assert (10t << 2l) == 40t
|
|
|
532
532
|
</details>
|
|
533
533
|
|
|
534
534
|
```grain
|
|
535
|
-
(>>)
|
|
535
|
+
(>>): (num: BigInt, places: Int32) => BigInt
|
|
536
536
|
```
|
|
537
537
|
|
|
538
538
|
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
@@ -565,7 +565,7 @@ No other changes yet.
|
|
|
565
565
|
</details>
|
|
566
566
|
|
|
567
567
|
```grain
|
|
568
|
-
eqz
|
|
568
|
+
eqz: (num: BigInt) => Bool
|
|
569
569
|
```
|
|
570
570
|
|
|
571
571
|
Checks if the given value is equal to zero.
|
|
@@ -607,7 +607,7 @@ assert BigInt.eqz(1t) == false
|
|
|
607
607
|
</details>
|
|
608
608
|
|
|
609
609
|
```grain
|
|
610
|
-
(==)
|
|
610
|
+
(==): (num1: BigInt, num2: BigInt) => Bool
|
|
611
611
|
```
|
|
612
612
|
|
|
613
613
|
Checks if the first value is equal to the second value.
|
|
@@ -652,7 +652,7 @@ assert -10t == -10t
|
|
|
652
652
|
</details>
|
|
653
653
|
|
|
654
654
|
```grain
|
|
655
|
-
(!=)
|
|
655
|
+
(!=): (num1: BigInt, num2: BigInt) => Bool
|
|
656
656
|
```
|
|
657
657
|
|
|
658
658
|
Checks if the first value is not equal to the second value.
|
|
@@ -697,7 +697,7 @@ assert -10t != -20t
|
|
|
697
697
|
</details>
|
|
698
698
|
|
|
699
699
|
```grain
|
|
700
|
-
(<)
|
|
700
|
+
(<): (num1: BigInt, num2: BigInt) => Bool
|
|
701
701
|
```
|
|
702
702
|
|
|
703
703
|
Checks if the first value is less than the second value.
|
|
@@ -742,7 +742,7 @@ assert -10t < 0t
|
|
|
742
742
|
</details>
|
|
743
743
|
|
|
744
744
|
```grain
|
|
745
|
-
(<=)
|
|
745
|
+
(<=): (num1: BigInt, num2: BigInt) => Bool
|
|
746
746
|
```
|
|
747
747
|
|
|
748
748
|
Checks if the first value is less than or equal to the second value.
|
|
@@ -792,7 +792,7 @@ assert 2t <= 3t
|
|
|
792
792
|
</details>
|
|
793
793
|
|
|
794
794
|
```grain
|
|
795
|
-
(>)
|
|
795
|
+
(>): (num1: BigInt, num2: BigInt) => Bool
|
|
796
796
|
```
|
|
797
797
|
|
|
798
798
|
Checks if the first value is greater than the second value.
|
|
@@ -837,7 +837,7 @@ assert 0t > -10t
|
|
|
837
837
|
</details>
|
|
838
838
|
|
|
839
839
|
```grain
|
|
840
|
-
(>=)
|
|
840
|
+
(>=): (num1: BigInt, num2: BigInt) => Bool
|
|
841
841
|
```
|
|
842
842
|
|
|
843
843
|
Checks if the first value is greater than or equal to the second value.
|
|
@@ -880,7 +880,7 @@ No other changes yet.
|
|
|
880
880
|
</details>
|
|
881
881
|
|
|
882
882
|
```grain
|
|
883
|
-
lnot
|
|
883
|
+
lnot: (num: BigInt) => BigInt
|
|
884
884
|
```
|
|
885
885
|
|
|
886
886
|
Computes the bitwise NOT of the given value.
|
|
@@ -918,7 +918,7 @@ BigInt.lnot(91234t) == -91235t
|
|
|
918
918
|
</details>
|
|
919
919
|
|
|
920
920
|
```grain
|
|
921
|
-
(&)
|
|
921
|
+
(&): (num1: BigInt, num2: BigInt) => BigInt
|
|
922
922
|
```
|
|
923
923
|
|
|
924
924
|
Computes the bitwise AND (`&`) on the given operands.
|
|
@@ -958,7 +958,7 @@ assert (4t & 3t) == 0t
|
|
|
958
958
|
</details>
|
|
959
959
|
|
|
960
960
|
```grain
|
|
961
|
-
(|)
|
|
961
|
+
(|): (num1: BigInt, num2: BigInt) => BigInt
|
|
962
962
|
```
|
|
963
963
|
|
|
964
964
|
Computes the bitwise OR (`|`) on the given operands.
|
|
@@ -998,7 +998,7 @@ assert (5t | 3t) == 7t
|
|
|
998
998
|
</details>
|
|
999
999
|
|
|
1000
1000
|
```grain
|
|
1001
|
-
(^)
|
|
1001
|
+
(^): (num1: BigInt, num2: BigInt) => BigInt
|
|
1002
1002
|
```
|
|
1003
1003
|
|
|
1004
1004
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
@@ -1031,7 +1031,7 @@ No other changes yet.
|
|
|
1031
1031
|
</details>
|
|
1032
1032
|
|
|
1033
1033
|
```grain
|
|
1034
|
-
clz
|
|
1034
|
+
clz: (num: BigInt) => Int32
|
|
1035
1035
|
```
|
|
1036
1036
|
|
|
1037
1037
|
Counts the number of leading zero bits in the value.
|
|
@@ -1063,7 +1063,7 @@ No other changes yet.
|
|
|
1063
1063
|
</details>
|
|
1064
1064
|
|
|
1065
1065
|
```grain
|
|
1066
|
-
ctz
|
|
1066
|
+
ctz: (num: BigInt) => Int64
|
|
1067
1067
|
```
|
|
1068
1068
|
|
|
1069
1069
|
Counts the number of trailing zero bits in the value.
|
|
@@ -1094,7 +1094,7 @@ No other changes yet.
|
|
|
1094
1094
|
</details>
|
|
1095
1095
|
|
|
1096
1096
|
```grain
|
|
1097
|
-
popcnt
|
|
1097
|
+
popcnt: (num: BigInt) => Option<Int64>
|
|
1098
1098
|
```
|
|
1099
1099
|
|
|
1100
1100
|
Counts the number of bits set to `1` in the value, also known as a population count.
|
|
@@ -1126,7 +1126,7 @@ No other changes yet.
|
|
|
1126
1126
|
</details>
|
|
1127
1127
|
|
|
1128
1128
|
```grain
|
|
1129
|
-
toString
|
|
1129
|
+
toString: (num: BigInt) => String
|
|
1130
1130
|
```
|
|
1131
1131
|
|
|
1132
1132
|
Converts the given operand to a string.
|
package/buffer.gr
CHANGED
|
@@ -16,13 +16,17 @@ from "runtime/unsafe/wasmi32" include WasmI32
|
|
|
16
16
|
from "runtime/unsafe/conv" include Conv
|
|
17
17
|
from "runtime/exception" include Exception
|
|
18
18
|
from "runtime/dataStructures" include DataStructures
|
|
19
|
-
use DataStructures.{ untagChar }
|
|
19
|
+
use DataStructures.{ untagChar, tagSimpleNumber }
|
|
20
20
|
from "int32" include Int32
|
|
21
21
|
from "bytes" include Bytes
|
|
22
22
|
from "string" include String
|
|
23
23
|
from "char" include Char
|
|
24
24
|
from "runtime/numbers" include Numbers
|
|
25
25
|
use Numbers.{ coerceNumberToWasmI32 }
|
|
26
|
+
from "runtime/utf8" include Utf8
|
|
27
|
+
use Utf8.{ usvEncodeLength }
|
|
28
|
+
from "runtime/unsafe/offsets" include Offsets
|
|
29
|
+
use Offsets.{ _BYTES_LEN_OFFSET, _BYTES_DATA_OFFSET }
|
|
26
30
|
|
|
27
31
|
abstract record Buffer {
|
|
28
32
|
mut len: Number,
|
|
@@ -30,12 +34,6 @@ abstract record Buffer {
|
|
|
30
34
|
mut data: Bytes,
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
@unsafe
|
|
34
|
-
let _SIZE_OFFSET = 4n
|
|
35
|
-
|
|
36
|
-
@unsafe
|
|
37
|
-
let _VALUE_OFFSET = 8n
|
|
38
|
-
|
|
39
37
|
let _8BIT_LEN = 1
|
|
40
38
|
|
|
41
39
|
let _16BIT_LEN = 2
|
|
@@ -46,7 +44,7 @@ let _64BIT_LEN = 8
|
|
|
46
44
|
|
|
47
45
|
/* Gets the size of a Bytes via its ptr */
|
|
48
46
|
@unsafe
|
|
49
|
-
let getSize = ptr => WasmI32.load(ptr,
|
|
47
|
+
let getSize = ptr => WasmI32.load(ptr, _BYTES_LEN_OFFSET)
|
|
50
48
|
|
|
51
49
|
/* Doubles the size of buffer's underlying byte sequence, if the given size is larger than the size of a buffer's underlying byte sequence */
|
|
52
50
|
let autogrow = (len, buf) => {
|
|
@@ -75,7 +73,11 @@ let autogrow = (len, buf) => {
|
|
|
75
73
|
@unsafe
|
|
76
74
|
let appendBytes = (srcOff, dstOff, len, src, dst) => {
|
|
77
75
|
use WasmI32.{ (+) }
|
|
78
|
-
Memory.copy(
|
|
76
|
+
Memory.copy(
|
|
77
|
+
dst + _BYTES_DATA_OFFSET + dstOff,
|
|
78
|
+
src + _BYTES_DATA_OFFSET + srcOff,
|
|
79
|
+
len
|
|
80
|
+
)
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/*
|
|
@@ -237,7 +239,7 @@ provide let truncate = (length, buffer) => {
|
|
|
237
239
|
let src = WasmI32.fromGrain(buffer.data)
|
|
238
240
|
let size = getSize(src)
|
|
239
241
|
let off = coerceNumberToWasmI32(length)
|
|
240
|
-
let ret = Memory.fill(src +
|
|
242
|
+
let ret = Memory.fill(src + _BYTES_DATA_OFFSET + off, 0n, size - off)
|
|
241
243
|
buffer.len = length
|
|
242
244
|
}
|
|
243
245
|
|
|
@@ -389,48 +391,12 @@ provide let addString = (string, buffer) => {
|
|
|
389
391
|
*/
|
|
390
392
|
@unsafe
|
|
391
393
|
provide let addChar = (char, buffer) => {
|
|
392
|
-
use WasmI32.{ (-), (*), (&), (|), (>>>), ltU as (<), gtU as (>), leU as (<=) }
|
|
393
394
|
let usv = untagChar(char)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
let dst = WasmI32.fromGrain(buffer.data) + _VALUE_OFFSET
|
|
400
|
-
WasmI32.store8(dst, usv, off)
|
|
401
|
-
1
|
|
402
|
-
} else {
|
|
403
|
-
let mut count = 0n
|
|
404
|
-
let mut bytelen = 0
|
|
405
|
-
let mut offset = 0n
|
|
406
|
-
if (usv <= 0x07FFn) {
|
|
407
|
-
count = 1n
|
|
408
|
-
bytelen = 2
|
|
409
|
-
offset = 0xC0n
|
|
410
|
-
} else if (usv <= 0xFFFFn) {
|
|
411
|
-
count = 2n
|
|
412
|
-
bytelen = 3
|
|
413
|
-
offset = 0xE0n
|
|
414
|
-
} else {
|
|
415
|
-
count = 3n
|
|
416
|
-
bytelen = 4
|
|
417
|
-
offset = 0xF0n
|
|
418
|
-
}
|
|
419
|
-
use WasmI32.{ (+) }
|
|
420
|
-
autogrow(bytelen, buffer)
|
|
421
|
-
let off = coerceNumberToWasmI32(buffer.len)
|
|
422
|
-
let dst = WasmI32.fromGrain(buffer.data) + _VALUE_OFFSET
|
|
423
|
-
WasmI32.store8(dst, (usv >>> (6n * count)) + offset, off)
|
|
424
|
-
let mut n = 0n
|
|
425
|
-
while (count > 0n) {
|
|
426
|
-
n += 1n
|
|
427
|
-
let temp = usv >>> (6n * (count - 1n))
|
|
428
|
-
WasmI32.store8(dst + n, 0x80n | temp & 0x3Fn, off)
|
|
429
|
-
count -= 1n
|
|
430
|
-
}
|
|
431
|
-
bytelen
|
|
432
|
-
}
|
|
433
|
-
buffer.len += bytelen
|
|
395
|
+
let byteCount = tagSimpleNumber(usvEncodeLength(usv))
|
|
396
|
+
autogrow(byteCount, buffer)
|
|
397
|
+
let index = buffer.len
|
|
398
|
+
buffer.len += byteCount
|
|
399
|
+
Bytes.setChar(index, char, buffer.data)
|
|
434
400
|
}
|
|
435
401
|
|
|
436
402
|
/**
|
|
@@ -514,7 +480,8 @@ provide let addBytesSlice = (
|
|
|
514
480
|
use WasmI32.{ (-), (<), (>), (>=) }
|
|
515
481
|
|
|
516
482
|
// bounds check start
|
|
517
|
-
let
|
|
483
|
+
let src = WasmI32.fromGrain(bytes)
|
|
484
|
+
let bytelen = getSize(src)
|
|
518
485
|
let srcOff = coerceNumberToWasmI32(start)
|
|
519
486
|
if (srcOff < 0n || srcOff >= bytelen) {
|
|
520
487
|
throw IndexOutOfBounds
|
|
@@ -529,9 +496,9 @@ provide let addBytesSlice = (
|
|
|
529
496
|
autogrow(length, buffer)
|
|
530
497
|
|
|
531
498
|
let dstOff = coerceNumberToWasmI32(buffer.len)
|
|
532
|
-
let src = WasmI32.fromGrain(bytes)
|
|
533
499
|
let dst = WasmI32.fromGrain(buffer.data)
|
|
534
500
|
appendBytes(srcOff, dstOff, len, src, dst)
|
|
501
|
+
ignore(src)
|
|
535
502
|
|
|
536
503
|
buffer.len += length
|
|
537
504
|
}
|