@grain/stdlib 0.5.2 → 0.5.4
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 +59 -0
- package/array.gr +61 -1
- package/array.md +113 -0
- package/bigint.md +30 -30
- package/buffer.gr +24 -22
- package/char.gr +2 -2
- package/float32.md +3 -3
- package/float64.md +3 -3
- package/immutablemap.gr +493 -0
- package/immutablemap.md +479 -0
- package/immutablepriorityqueue.gr +360 -0
- package/immutablepriorityqueue.md +291 -0
- package/immutableset.gr +498 -0
- package/immutableset.md +449 -0
- package/list.gr +75 -2
- package/list.md +110 -0
- package/map.gr +1 -2
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +689 -23
- package/number.md +362 -27
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +261 -0
- package/priorityqueue.md +309 -0
- package/queue.gr +14 -1
- package/queue.md +16 -1
- package/regex.gr +90 -67
- package/runtime/bigint.gr +4 -4
- package/runtime/compare.gr +179 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +3 -3
- package/runtime/exception.gr +9 -5
- package/runtime/exception.md +8 -2
- package/runtime/gc.gr +2 -1
- package/runtime/malloc.gr +1 -3
- package/runtime/numberUtils.gr +11 -11
- package/runtime/numbers.gr +423 -100
- package/runtime/numbers.md +50 -0
- package/runtime/string.gr +4 -2
- package/set.gr +26 -27
- package/stack.gr +12 -0
- package/stack.md +15 -0
- package/string.gr +409 -53
- package/string.md +164 -1
- package/sys/file.gr +4 -4
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +2 -2
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/runtime/gc.gr
CHANGED
|
@@ -213,7 +213,8 @@ let rec decRef = (userPtr: WasmI32, ignoreZeros: Bool) => {
|
|
|
213
213
|
} else {
|
|
214
214
|
userPtr
|
|
215
215
|
}
|
|
216
|
-
},
|
|
216
|
+
},
|
|
217
|
+
decRefChildren = (userPtr: WasmI32) => {
|
|
217
218
|
match (WasmI32.load(userPtr, 0n)) {
|
|
218
219
|
t when t == Tags._GRAIN_BOXED_NUM_HEAP_TAG => {
|
|
219
220
|
let tag = WasmI32.load(userPtr, 4n)
|
package/runtime/malloc.gr
CHANGED
|
@@ -28,8 +28,6 @@ primitive (!): Bool -> Bool = "@not"
|
|
|
28
28
|
primitive (&&): (Bool, Bool) -> Bool = "@and"
|
|
29
29
|
primitive (||): (Bool, Bool) -> Bool = "@or"
|
|
30
30
|
|
|
31
|
-
primitive throw: Exception -> a = "@throw"
|
|
32
|
-
|
|
33
31
|
primitive heapBase: WasmI32 = "@heap.base"
|
|
34
32
|
|
|
35
33
|
/* UNDERSTANDING THE STRUCTURE OF THE FREE LIST
|
|
@@ -221,7 +219,7 @@ let morecore = (nbytes: WasmI32) => {
|
|
|
221
219
|
|
|
222
220
|
// If there was an error, fail
|
|
223
221
|
if (cp == -1n) {
|
|
224
|
-
|
|
222
|
+
Exception.panic("OutOfMemory: Maximum memory size exceeded")
|
|
225
223
|
} else {
|
|
226
224
|
// Set the size of the new block to the amount the
|
|
227
225
|
// heap was grown.
|
package/runtime/numberUtils.gr
CHANGED
|
@@ -728,16 +728,16 @@ export let decimalCount32 = value => {
|
|
|
728
728
|
1n + (if (WasmI32.geU(value, 10n)) 1n else 0n)
|
|
729
729
|
} else {
|
|
730
730
|
3n +
|
|
731
|
-
|
|
732
|
-
|
|
731
|
+
(if (WasmI32.geU(value, 10000n)) 1n else 0n) +
|
|
732
|
+
(if (WasmI32.geU(value, 1000n)) 1n else 0n)
|
|
733
733
|
}
|
|
734
734
|
} else {
|
|
735
735
|
if (WasmI32.ltU(value, 10000000n)) {
|
|
736
736
|
6n + (if (WasmI32.geU(value, 1000000n)) 1n else 0n)
|
|
737
737
|
} else {
|
|
738
738
|
8n +
|
|
739
|
-
|
|
740
|
-
|
|
739
|
+
(if (WasmI32.geU(value, 1000000000n)) 1n else 0n) +
|
|
740
|
+
(if (WasmI32.geU(value, 100000000n)) 1n else 0n)
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
743
|
}
|
|
@@ -749,20 +749,20 @@ let decimalCount64High = value => {
|
|
|
749
749
|
if (WasmI64.ltU(value, 1000000000000000N)) {
|
|
750
750
|
if (WasmI64.ltU(value, 1000000000000N)) {
|
|
751
751
|
10n +
|
|
752
|
-
|
|
753
|
-
|
|
752
|
+
(if (WasmI64.geU(value, 100000000000N)) 1n else 0n) +
|
|
753
|
+
(if (WasmI64.geU(value, 10000000000N)) 1n else 0n)
|
|
754
754
|
} else {
|
|
755
755
|
13n +
|
|
756
|
-
|
|
757
|
-
|
|
756
|
+
(if (WasmI64.geU(value, 100000000000000N)) 1n else 0n) +
|
|
757
|
+
(if (WasmI64.geU(value, 10000000000000N)) 1n else 0n)
|
|
758
758
|
}
|
|
759
759
|
} else {
|
|
760
760
|
if (WasmI64.ltU(value, 100000000000000000N)) {
|
|
761
761
|
16n + (if (WasmI64.geU(value, 10000000000000000N)) 1n else 0n)
|
|
762
762
|
} else {
|
|
763
763
|
18n +
|
|
764
|
-
|
|
765
|
-
|
|
764
|
+
(if (WasmI64.geU(value, 0x8AC7230489E80000N)) 1n else 0n) +
|
|
765
|
+
(if (WasmI64.geU(value, 1000000000000000000N)) 1n else 0n)
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
}
|
|
@@ -774,7 +774,7 @@ let ulog_base = (num, base) => {
|
|
|
774
774
|
63n - WasmI32.wrapI64(WasmI64.clz(num)),
|
|
775
775
|
31n - WasmI32.clz(base)
|
|
776
776
|
) +
|
|
777
|
-
|
|
777
|
+
1n
|
|
778
778
|
} else {
|
|
779
779
|
let b64 = WasmI64.extendI32U(base)
|
|
780
780
|
let mut b = b64
|