@grain/stdlib 0.4.2 → 0.4.6
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 +52 -0
- package/LICENSE +1 -1
- package/array.gr +200 -89
- package/array.md +81 -5
- package/buffer.gr +93 -36
- package/bytes.gr +10 -10
- package/char.gr +112 -56
- package/char.md +200 -0
- package/float32.gr +120 -4
- package/float32.md +315 -0
- package/float64.gr +120 -4
- package/float64.md +315 -0
- package/hash.gr +42 -15
- package/hash.md +44 -0
- package/int32.gr +370 -75
- package/int32.md +833 -0
- package/int64.gr +370 -75
- package/int64.md +833 -0
- package/list.gr +121 -50
- package/map.gr +106 -110
- package/number.gr +37 -1
- package/number.md +66 -0
- package/option.gr +260 -53
- package/option.md +579 -0
- package/package.json +1 -1
- package/pervasives.gr +32 -20
- package/queue.gr +102 -30
- package/queue.md +191 -0
- package/range.gr +26 -26
- package/range.md +1 -1
- package/regex.md +9 -9
- package/result.gr +216 -70
- package/result.md +446 -0
- package/runtime/dataStructures.gr +28 -29
- package/runtime/debug.gr +0 -1
- package/runtime/equal.gr +37 -16
- package/runtime/exception.gr +28 -15
- package/runtime/gc.gr +33 -20
- package/runtime/malloc.gr +19 -11
- package/runtime/numberUtils.gr +208 -103
- package/runtime/numbers.gr +217 -118
- package/runtime/string.gr +98 -39
- package/runtime/stringUtils.gr +176 -0
- package/runtime/unsafe/conv.gr +10 -10
- package/runtime/unsafe/memory.gr +14 -3
- package/runtime/unsafe/printWasm.gr +4 -4
- package/runtime/unsafe/tags.gr +2 -2
- package/runtime/unsafe/wasmf32.gr +9 -2
- package/runtime/unsafe/wasmf64.gr +9 -2
- package/runtime/unsafe/wasmi32.gr +65 -47
- package/runtime/unsafe/wasmi64.gr +78 -50
- package/runtime/wasi.gr +199 -45
- package/set.gr +281 -119
- package/set.md +502 -0
- package/stack.gr +26 -26
- package/string.gr +657 -341
- package/string.md +815 -0
- package/sys/file.gr +356 -177
- package/sys/process.gr +10 -6
- package/sys/random.gr +3 -6
- package/sys/time.gr +3 -3
|
@@ -1,58 +1,76 @@
|
|
|
1
1
|
/* grainc-flags --compilation-mode=runtime */
|
|
2
2
|
|
|
3
3
|
// WebAssembly Memory Instructions
|
|
4
|
-
export primitive load
|
|
5
|
-
export primitive load8S
|
|
6
|
-
export primitive load8U
|
|
7
|
-
export primitive load16S
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export primitive
|
|
4
|
+
export primitive load: (WasmI32, WasmI32) -> WasmI32 = "@wasm.load_int32"
|
|
5
|
+
export primitive load8S: (WasmI32, WasmI32) -> WasmI32 = "@wasm.load_8_s_int32"
|
|
6
|
+
export primitive load8U: (WasmI32, WasmI32) -> WasmI32 = "@wasm.load_8_u_int32"
|
|
7
|
+
export primitive load16S: (
|
|
8
|
+
WasmI32,
|
|
9
|
+
WasmI32,
|
|
10
|
+
) -> WasmI32 = "@wasm.load_16_s_int32"
|
|
11
|
+
export primitive load16U: (
|
|
12
|
+
WasmI32,
|
|
13
|
+
WasmI32,
|
|
14
|
+
) -> WasmI32 = "@wasm.load_16_u_int32"
|
|
15
|
+
export primitive store: (
|
|
16
|
+
WasmI32,
|
|
17
|
+
WasmI32,
|
|
18
|
+
WasmI32,
|
|
19
|
+
) -> Void = "@wasm.store_int32"
|
|
20
|
+
export primitive store8: (
|
|
21
|
+
WasmI32,
|
|
22
|
+
WasmI32,
|
|
23
|
+
WasmI32,
|
|
24
|
+
) -> Void = "@wasm.store_8_int32"
|
|
25
|
+
export primitive store16: (
|
|
26
|
+
WasmI32,
|
|
27
|
+
WasmI32,
|
|
28
|
+
WasmI32,
|
|
29
|
+
) -> Void = "@wasm.store_16_int32"
|
|
12
30
|
|
|
13
31
|
// WebAssembly Unary Instructions
|
|
14
|
-
export primitive clz
|
|
15
|
-
export primitive ctz
|
|
16
|
-
export primitive popcnt
|
|
17
|
-
export primitive eqz
|
|
32
|
+
export primitive clz: WasmI32 -> WasmI32 = "@wasm.clz_int32"
|
|
33
|
+
export primitive ctz: WasmI32 -> WasmI32 = "@wasm.ctz_int32"
|
|
34
|
+
export primitive popcnt: WasmI32 -> WasmI32 = "@wasm.popcnt_int32"
|
|
35
|
+
export primitive eqz: WasmI32 -> Bool = "@wasm.eq_z_int32"
|
|
18
36
|
|
|
19
37
|
// WebAssembly Binary Instructions
|
|
20
|
-
export primitive add
|
|
21
|
-
export primitive sub
|
|
22
|
-
export primitive mul
|
|
23
|
-
export primitive divS
|
|
24
|
-
export primitive divU
|
|
25
|
-
export primitive remS
|
|
26
|
-
export primitive remU
|
|
27
|
-
export primitive and
|
|
28
|
-
export primitive or
|
|
29
|
-
export primitive xor
|
|
30
|
-
export primitive shl
|
|
31
|
-
export primitive shrS
|
|
32
|
-
export primitive shrU
|
|
33
|
-
export primitive rotl
|
|
34
|
-
export primitive rotr
|
|
35
|
-
export primitive eq
|
|
36
|
-
export primitive ne
|
|
37
|
-
export primitive ltS
|
|
38
|
-
export primitive ltU
|
|
39
|
-
export primitive leS
|
|
40
|
-
export primitive leU
|
|
41
|
-
export primitive gtS
|
|
42
|
-
export primitive gtU
|
|
43
|
-
export primitive geS
|
|
44
|
-
export primitive geU
|
|
38
|
+
export primitive add: (WasmI32, WasmI32) -> WasmI32 = "@wasm.add_int32"
|
|
39
|
+
export primitive sub: (WasmI32, WasmI32) -> WasmI32 = "@wasm.sub_int32"
|
|
40
|
+
export primitive mul: (WasmI32, WasmI32) -> WasmI32 = "@wasm.mul_int32"
|
|
41
|
+
export primitive divS: (WasmI32, WasmI32) -> WasmI32 = "@wasm.div_s_int32"
|
|
42
|
+
export primitive divU: (WasmI32, WasmI32) -> WasmI32 = "@wasm.div_u_int32"
|
|
43
|
+
export primitive remS: (WasmI32, WasmI32) -> WasmI32 = "@wasm.rem_s_int32"
|
|
44
|
+
export primitive remU: (WasmI32, WasmI32) -> WasmI32 = "@wasm.rem_u_int32"
|
|
45
|
+
export primitive and: (WasmI32, WasmI32) -> WasmI32 = "@wasm.and_int32"
|
|
46
|
+
export primitive or: (WasmI32, WasmI32) -> WasmI32 = "@wasm.or_int32"
|
|
47
|
+
export primitive xor: (WasmI32, WasmI32) -> WasmI32 = "@wasm.xor_int32"
|
|
48
|
+
export primitive shl: (WasmI32, WasmI32) -> WasmI32 = "@wasm.shl_int32"
|
|
49
|
+
export primitive shrS: (WasmI32, WasmI32) -> WasmI32 = "@wasm.shr_s_int32"
|
|
50
|
+
export primitive shrU: (WasmI32, WasmI32) -> WasmI32 = "@wasm.shr_u_int32"
|
|
51
|
+
export primitive rotl: (WasmI32, WasmI32) -> WasmI32 = "@wasm.rot_l_int32"
|
|
52
|
+
export primitive rotr: (WasmI32, WasmI32) -> WasmI32 = "@wasm.rot_r_int32"
|
|
53
|
+
export primitive eq: (WasmI32, WasmI32) -> Bool = "@wasm.eq_int32"
|
|
54
|
+
export primitive ne: (WasmI32, WasmI32) -> Bool = "@wasm.ne_int32"
|
|
55
|
+
export primitive ltS: (WasmI32, WasmI32) -> Bool = "@wasm.lt_s_int32"
|
|
56
|
+
export primitive ltU: (WasmI32, WasmI32) -> Bool = "@wasm.lt_u_int32"
|
|
57
|
+
export primitive leS: (WasmI32, WasmI32) -> Bool = "@wasm.le_s_int32"
|
|
58
|
+
export primitive leU: (WasmI32, WasmI32) -> Bool = "@wasm.le_u_int32"
|
|
59
|
+
export primitive gtS: (WasmI32, WasmI32) -> Bool = "@wasm.gt_s_int32"
|
|
60
|
+
export primitive gtU: (WasmI32, WasmI32) -> Bool = "@wasm.gt_u_int32"
|
|
61
|
+
export primitive geS: (WasmI32, WasmI32) -> Bool = "@wasm.ge_s_int32"
|
|
62
|
+
export primitive geU: (WasmI32, WasmI32) -> Bool = "@wasm.ge_u_int32"
|
|
45
63
|
|
|
46
64
|
// WebAssembly Conversion Instructions
|
|
47
|
-
export primitive wrapI64
|
|
48
|
-
export primitive truncF32S
|
|
49
|
-
export primitive truncF32U
|
|
50
|
-
export primitive truncF64S
|
|
51
|
-
export primitive truncF64U
|
|
52
|
-
export primitive reinterpretF32
|
|
53
|
-
export primitive extendS8
|
|
54
|
-
export primitive extendS16
|
|
65
|
+
export primitive wrapI64: WasmI64 -> WasmI32 = "@wasm.wrap_int64"
|
|
66
|
+
export primitive truncF32S: WasmF32 -> WasmI32 = "@wasm.trunc_s_float32_to_int32"
|
|
67
|
+
export primitive truncF32U: WasmF32 -> WasmI32 = "@wasm.trunc_u_float32_to_int32"
|
|
68
|
+
export primitive truncF64S: WasmF64 -> WasmI32 = "@wasm.trunc_s_float64_to_int32"
|
|
69
|
+
export primitive truncF64U: WasmF64 -> WasmI32 = "@wasm.trunc_u_float64_to_int32"
|
|
70
|
+
export primitive reinterpretF32: WasmF32 -> WasmI32 = "@wasm.reinterpret_float32"
|
|
71
|
+
export primitive extendS8: WasmI32 -> WasmI32 = "@wasm.extend_s8_int32"
|
|
72
|
+
export primitive extendS16: WasmI32 -> WasmI32 = "@wasm.extend_s16_int32"
|
|
55
73
|
|
|
56
74
|
// Grain Conversions
|
|
57
|
-
export primitive fromGrain
|
|
58
|
-
export primitive toGrain
|
|
75
|
+
export primitive fromGrain: a -> WasmI32 = "@wasm.fromGrain"
|
|
76
|
+
export primitive toGrain: WasmI32 -> a = "@wasm.toGrain"
|
|
@@ -1,59 +1,87 @@
|
|
|
1
1
|
/* grainc-flags --compilation-mode=runtime */
|
|
2
2
|
|
|
3
3
|
// WebAssembly Memory Instructions
|
|
4
|
-
export primitive load
|
|
5
|
-
export primitive load8S
|
|
6
|
-
export primitive load8U
|
|
7
|
-
export primitive load16S
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export primitive
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
export primitive load: (WasmI32, WasmI32) -> WasmI64 = "@wasm.load_int64"
|
|
5
|
+
export primitive load8S: (WasmI32, WasmI32) -> WasmI64 = "@wasm.load_8_s_int64"
|
|
6
|
+
export primitive load8U: (WasmI32, WasmI32) -> WasmI64 = "@wasm.load_8_u_int64"
|
|
7
|
+
export primitive load16S: (
|
|
8
|
+
WasmI32,
|
|
9
|
+
WasmI32,
|
|
10
|
+
) -> WasmI64 = "@wasm.load_16_s_int64"
|
|
11
|
+
export primitive load16U: (
|
|
12
|
+
WasmI32,
|
|
13
|
+
WasmI32,
|
|
14
|
+
) -> WasmI64 = "@wasm.load_16_u_int64"
|
|
15
|
+
export primitive load32S: (
|
|
16
|
+
WasmI32,
|
|
17
|
+
WasmI32,
|
|
18
|
+
) -> WasmI64 = "@wasm.load_32_s_int64"
|
|
19
|
+
export primitive load32U: (
|
|
20
|
+
WasmI32,
|
|
21
|
+
WasmI32,
|
|
22
|
+
) -> WasmI64 = "@wasm.load_32_u_int64"
|
|
23
|
+
export primitive store: (
|
|
24
|
+
WasmI32,
|
|
25
|
+
WasmI64,
|
|
26
|
+
WasmI32,
|
|
27
|
+
) -> Void = "@wasm.store_int64"
|
|
28
|
+
export primitive store8: (
|
|
29
|
+
WasmI32,
|
|
30
|
+
WasmI64,
|
|
31
|
+
WasmI32,
|
|
32
|
+
) -> Void = "@wasm.store_8_int64"
|
|
33
|
+
export primitive store16: (
|
|
34
|
+
WasmI32,
|
|
35
|
+
WasmI64,
|
|
36
|
+
WasmI32,
|
|
37
|
+
) -> Void = "@wasm.store_16_int64"
|
|
38
|
+
export primitive store32: (
|
|
39
|
+
WasmI32,
|
|
40
|
+
WasmI64,
|
|
41
|
+
WasmI32,
|
|
42
|
+
) -> Void = "@wasm.store_32_int64"
|
|
15
43
|
|
|
16
44
|
// WebAssembly Unary Instructions
|
|
17
|
-
export primitive clz
|
|
18
|
-
export primitive ctz
|
|
19
|
-
export primitive popcnt
|
|
20
|
-
export primitive eqz
|
|
45
|
+
export primitive clz: WasmI64 -> WasmI64 = "@wasm.clz_int64"
|
|
46
|
+
export primitive ctz: WasmI64 -> WasmI64 = "@wasm.ctz_int64"
|
|
47
|
+
export primitive popcnt: WasmI64 -> WasmI64 = "@wasm.popcnt_int64"
|
|
48
|
+
export primitive eqz: WasmI64 -> Bool = "@wasm.eq_z_int64"
|
|
21
49
|
|
|
22
50
|
// WebAssembly Binary Instructions
|
|
23
|
-
export primitive add
|
|
24
|
-
export primitive sub
|
|
25
|
-
export primitive mul
|
|
26
|
-
export primitive divS
|
|
27
|
-
export primitive divU
|
|
28
|
-
export primitive remS
|
|
29
|
-
export primitive remU
|
|
30
|
-
export primitive and
|
|
31
|
-
export primitive or
|
|
32
|
-
export primitive xor
|
|
33
|
-
export primitive shl
|
|
34
|
-
export primitive shrU
|
|
35
|
-
export primitive shrS
|
|
36
|
-
export primitive rotl
|
|
37
|
-
export primitive rotr
|
|
38
|
-
export primitive eq
|
|
39
|
-
export primitive ne
|
|
40
|
-
export primitive ltS
|
|
41
|
-
export primitive ltU
|
|
42
|
-
export primitive leS
|
|
43
|
-
export primitive leU
|
|
44
|
-
export primitive gtS
|
|
45
|
-
export primitive gtU
|
|
46
|
-
export primitive geS
|
|
47
|
-
export primitive geU
|
|
51
|
+
export primitive add: (WasmI64, WasmI64) -> WasmI64 = "@wasm.add_int64"
|
|
52
|
+
export primitive sub: (WasmI64, WasmI64) -> WasmI64 = "@wasm.sub_int64"
|
|
53
|
+
export primitive mul: (WasmI64, WasmI64) -> WasmI64 = "@wasm.mul_int64"
|
|
54
|
+
export primitive divS: (WasmI64, WasmI64) -> WasmI64 = "@wasm.div_s_int64"
|
|
55
|
+
export primitive divU: (WasmI64, WasmI64) -> WasmI64 = "@wasm.div_u_int64"
|
|
56
|
+
export primitive remS: (WasmI64, WasmI64) -> WasmI64 = "@wasm.rem_s_int64"
|
|
57
|
+
export primitive remU: (WasmI64, WasmI64) -> WasmI64 = "@wasm.rem_u_int64"
|
|
58
|
+
export primitive and: (WasmI64, WasmI64) -> WasmI64 = "@wasm.and_int64"
|
|
59
|
+
export primitive or: (WasmI64, WasmI64) -> WasmI64 = "@wasm.or_int64"
|
|
60
|
+
export primitive xor: (WasmI64, WasmI64) -> WasmI64 = "@wasm.xor_int64"
|
|
61
|
+
export primitive shl: (WasmI64, WasmI64) -> WasmI64 = "@wasm.shl_int64"
|
|
62
|
+
export primitive shrU: (WasmI64, WasmI64) -> WasmI64 = "@wasm.shr_u_int64"
|
|
63
|
+
export primitive shrS: (WasmI64, WasmI64) -> WasmI64 = "@wasm.shr_s_int64"
|
|
64
|
+
export primitive rotl: (WasmI64, WasmI64) -> WasmI64 = "@wasm.rot_l_int64"
|
|
65
|
+
export primitive rotr: (WasmI64, WasmI64) -> WasmI64 = "@wasm.rot_r_int64"
|
|
66
|
+
export primitive eq: (WasmI64, WasmI64) -> Bool = "@wasm.eq_int64"
|
|
67
|
+
export primitive ne: (WasmI64, WasmI64) -> Bool = "@wasm.ne_int64"
|
|
68
|
+
export primitive ltS: (WasmI64, WasmI64) -> Bool = "@wasm.lt_s_int64"
|
|
69
|
+
export primitive ltU: (WasmI64, WasmI64) -> Bool = "@wasm.lt_u_int64"
|
|
70
|
+
export primitive leS: (WasmI64, WasmI64) -> Bool = "@wasm.le_s_int64"
|
|
71
|
+
export primitive leU: (WasmI64, WasmI64) -> Bool = "@wasm.le_u_int64"
|
|
72
|
+
export primitive gtS: (WasmI64, WasmI64) -> Bool = "@wasm.gt_s_int64"
|
|
73
|
+
export primitive gtU: (WasmI64, WasmI64) -> Bool = "@wasm.gt_u_int64"
|
|
74
|
+
export primitive geS: (WasmI64, WasmI64) -> Bool = "@wasm.ge_s_int64"
|
|
75
|
+
export primitive geU: (WasmI64, WasmI64) -> Bool = "@wasm.ge_u_int64"
|
|
48
76
|
|
|
49
77
|
// WebAssembly Conversion instructions
|
|
50
|
-
export primitive extendI32S
|
|
51
|
-
export primitive extendI32U
|
|
52
|
-
export primitive truncF32S
|
|
53
|
-
export primitive truncF32U
|
|
54
|
-
export primitive truncF64S
|
|
55
|
-
export primitive truncF64U
|
|
56
|
-
export primitive reinterpretF64
|
|
57
|
-
export primitive extendS8
|
|
58
|
-
export primitive extendS16
|
|
59
|
-
export primitive extendS32
|
|
78
|
+
export primitive extendI32S: WasmI32 -> WasmI64 = "@wasm.extend_s_int32"
|
|
79
|
+
export primitive extendI32U: WasmI32 -> WasmI64 = "@wasm.extend_u_int32"
|
|
80
|
+
export primitive truncF32S: WasmF32 -> WasmI64 = "@wasm.trunc_s_float32_to_int64"
|
|
81
|
+
export primitive truncF32U: WasmF32 -> WasmI64 = "@wasm.trunc_u_float32_to_int64"
|
|
82
|
+
export primitive truncF64S: WasmF64 -> WasmI64 = "@wasm.trunc_s_float64_to_int64"
|
|
83
|
+
export primitive truncF64U: WasmF64 -> WasmI64 = "@wasm.trunc_u_float64_to_int64"
|
|
84
|
+
export primitive reinterpretF64: WasmF64 -> WasmI64 = "@wasm.reinterpret_float64"
|
|
85
|
+
export primitive extendS8: WasmI64 -> WasmI64 = "@wasm.extend_s8_int64"
|
|
86
|
+
export primitive extendS16: WasmI64 -> WasmI64 = "@wasm.extend_s16_int64"
|
|
87
|
+
export primitive extendS32: WasmI64 -> WasmI64 = "@wasm.extend_s32_int64"
|
package/runtime/wasi.gr
CHANGED
|
@@ -6,26 +6,66 @@ import WasmI32 from "runtime/unsafe/wasmi32"
|
|
|
6
6
|
import Exception from "exception"
|
|
7
7
|
|
|
8
8
|
// env
|
|
9
|
-
import foreign wasm args_get: (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import foreign wasm args_get: (
|
|
10
|
+
WasmI32,
|
|
11
|
+
WasmI32,
|
|
12
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
13
|
+
import foreign wasm args_sizes_get: (
|
|
14
|
+
WasmI32,
|
|
15
|
+
WasmI32,
|
|
16
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
17
|
+
import foreign wasm environ_get: (
|
|
18
|
+
WasmI32,
|
|
19
|
+
WasmI32,
|
|
20
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
21
|
+
import foreign wasm environ_sizes_get: (
|
|
22
|
+
WasmI32,
|
|
23
|
+
WasmI32,
|
|
24
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
13
25
|
|
|
14
26
|
// proc
|
|
15
|
-
import foreign wasm proc_exit:
|
|
16
|
-
import foreign wasm proc_raise:
|
|
27
|
+
import foreign wasm proc_exit: WasmI32 -> Void from "wasi_snapshot_preview1"
|
|
28
|
+
import foreign wasm proc_raise: WasmI32 -> WasmI32 from "wasi_snapshot_preview1"
|
|
17
29
|
import foreign wasm sched_yield: () -> WasmI32 from "wasi_snapshot_preview1"
|
|
18
30
|
|
|
19
31
|
// random
|
|
20
|
-
import foreign wasm random_get
|
|
32
|
+
import foreign wasm random_get: (
|
|
33
|
+
WasmI32,
|
|
34
|
+
WasmI32,
|
|
35
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
21
36
|
|
|
22
37
|
// time
|
|
23
|
-
import foreign wasm clock_time_get: (
|
|
38
|
+
import foreign wasm clock_time_get: (
|
|
39
|
+
WasmI32,
|
|
40
|
+
WasmI64,
|
|
41
|
+
WasmI32,
|
|
42
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
24
43
|
|
|
25
44
|
// file
|
|
26
|
-
import foreign wasm path_open
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
import foreign wasm path_open: (
|
|
46
|
+
WasmI32,
|
|
47
|
+
WasmI32,
|
|
48
|
+
WasmI32,
|
|
49
|
+
WasmI32,
|
|
50
|
+
WasmI32,
|
|
51
|
+
WasmI64,
|
|
52
|
+
WasmI64,
|
|
53
|
+
WasmI32,
|
|
54
|
+
WasmI32,
|
|
55
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
56
|
+
import foreign wasm fd_read: (
|
|
57
|
+
WasmI32,
|
|
58
|
+
WasmI32,
|
|
59
|
+
WasmI32,
|
|
60
|
+
WasmI32,
|
|
61
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
62
|
+
import foreign wasm fd_pread: (
|
|
63
|
+
WasmI32,
|
|
64
|
+
WasmI32,
|
|
65
|
+
WasmI32,
|
|
66
|
+
WasmI64,
|
|
67
|
+
WasmI32,
|
|
68
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
29
69
|
/**
|
|
30
70
|
* Invokes the `fd_write` system call.
|
|
31
71
|
*
|
|
@@ -35,31 +75,138 @@ import foreign wasm fd_pread : (WasmI32, WasmI32, WasmI32, WasmI64, WasmI32) ->
|
|
|
35
75
|
* @param nwritten: Where to store the number of bytes written
|
|
36
76
|
* @return The number of bytes written
|
|
37
77
|
*/
|
|
38
|
-
import foreign wasm fd_write
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import foreign wasm
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import foreign wasm
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
import foreign wasm
|
|
57
|
-
import foreign wasm
|
|
58
|
-
import foreign wasm
|
|
59
|
-
import foreign wasm
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
import foreign wasm fd_write: (
|
|
79
|
+
WasmI32,
|
|
80
|
+
WasmI32,
|
|
81
|
+
WasmI32,
|
|
82
|
+
WasmI32,
|
|
83
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
84
|
+
import foreign wasm fd_pwrite: (
|
|
85
|
+
WasmI32,
|
|
86
|
+
WasmI32,
|
|
87
|
+
WasmI32,
|
|
88
|
+
WasmI64,
|
|
89
|
+
WasmI32,
|
|
90
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
91
|
+
import foreign wasm fd_allocate: (
|
|
92
|
+
WasmI32,
|
|
93
|
+
WasmI64,
|
|
94
|
+
WasmI64,
|
|
95
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
96
|
+
import foreign wasm fd_close: WasmI32 -> WasmI32 from "wasi_snapshot_preview1"
|
|
97
|
+
import foreign wasm fd_datasync: WasmI32 -> WasmI32 from "wasi_snapshot_preview1"
|
|
98
|
+
import foreign wasm fd_sync: WasmI32 -> WasmI32 from "wasi_snapshot_preview1"
|
|
99
|
+
import foreign wasm fd_fdstat_get: (
|
|
100
|
+
WasmI32,
|
|
101
|
+
WasmI32,
|
|
102
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
103
|
+
import foreign wasm fd_fdstat_set_flags: (
|
|
104
|
+
WasmI32,
|
|
105
|
+
WasmI32,
|
|
106
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
107
|
+
import foreign wasm fd_fdstat_set_rights: (
|
|
108
|
+
WasmI32,
|
|
109
|
+
WasmI64,
|
|
110
|
+
WasmI64,
|
|
111
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
112
|
+
import foreign wasm fd_filestat_get: (
|
|
113
|
+
WasmI32,
|
|
114
|
+
WasmI32,
|
|
115
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
116
|
+
import foreign wasm fd_filestat_set_size: (
|
|
117
|
+
WasmI32,
|
|
118
|
+
WasmI64,
|
|
119
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
120
|
+
import foreign wasm fd_filestat_set_times: (
|
|
121
|
+
WasmI32,
|
|
122
|
+
WasmI64,
|
|
123
|
+
WasmI64,
|
|
124
|
+
WasmI32,
|
|
125
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
126
|
+
import foreign wasm fd_readdir: (
|
|
127
|
+
WasmI32,
|
|
128
|
+
WasmI32,
|
|
129
|
+
WasmI32,
|
|
130
|
+
WasmI64,
|
|
131
|
+
WasmI32,
|
|
132
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
133
|
+
import foreign wasm fd_renumber: (
|
|
134
|
+
WasmI32,
|
|
135
|
+
WasmI32,
|
|
136
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
137
|
+
import foreign wasm fd_seek: (
|
|
138
|
+
WasmI32,
|
|
139
|
+
WasmI64,
|
|
140
|
+
WasmI32,
|
|
141
|
+
WasmI32,
|
|
142
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
143
|
+
import foreign wasm fd_tell: (
|
|
144
|
+
WasmI32,
|
|
145
|
+
WasmI32,
|
|
146
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
147
|
+
import foreign wasm path_create_directory: (
|
|
148
|
+
WasmI32,
|
|
149
|
+
WasmI32,
|
|
150
|
+
WasmI32,
|
|
151
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
152
|
+
import foreign wasm path_filestat_get: (
|
|
153
|
+
WasmI32,
|
|
154
|
+
WasmI32,
|
|
155
|
+
WasmI32,
|
|
156
|
+
WasmI32,
|
|
157
|
+
WasmI32,
|
|
158
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
159
|
+
import foreign wasm path_filestat_set_times: (
|
|
160
|
+
WasmI32,
|
|
161
|
+
WasmI32,
|
|
162
|
+
WasmI32,
|
|
163
|
+
WasmI32,
|
|
164
|
+
WasmI64,
|
|
165
|
+
WasmI64,
|
|
166
|
+
WasmI32,
|
|
167
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
168
|
+
import foreign wasm path_link: (
|
|
169
|
+
WasmI32,
|
|
170
|
+
WasmI32,
|
|
171
|
+
WasmI32,
|
|
172
|
+
WasmI32,
|
|
173
|
+
WasmI32,
|
|
174
|
+
WasmI32,
|
|
175
|
+
WasmI32,
|
|
176
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
177
|
+
import foreign wasm path_symlink: (
|
|
178
|
+
WasmI32,
|
|
179
|
+
WasmI32,
|
|
180
|
+
WasmI32,
|
|
181
|
+
WasmI32,
|
|
182
|
+
WasmI32,
|
|
183
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
184
|
+
import foreign wasm path_unlink_file: (
|
|
185
|
+
WasmI32,
|
|
186
|
+
WasmI32,
|
|
187
|
+
WasmI32,
|
|
188
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
189
|
+
import foreign wasm path_readlink: (
|
|
190
|
+
WasmI32,
|
|
191
|
+
WasmI32,
|
|
192
|
+
WasmI32,
|
|
193
|
+
WasmI32,
|
|
194
|
+
WasmI32,
|
|
195
|
+
WasmI32,
|
|
196
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
197
|
+
import foreign wasm path_remove_directory: (
|
|
198
|
+
WasmI32,
|
|
199
|
+
WasmI32,
|
|
200
|
+
WasmI32,
|
|
201
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
202
|
+
import foreign wasm path_rename: (
|
|
203
|
+
WasmI32,
|
|
204
|
+
WasmI32,
|
|
205
|
+
WasmI32,
|
|
206
|
+
WasmI32,
|
|
207
|
+
WasmI32,
|
|
208
|
+
WasmI32,
|
|
209
|
+
) -> WasmI32 from "wasi_snapshot_preview1"
|
|
63
210
|
|
|
64
211
|
// clocks
|
|
65
212
|
let _CLOCK_REALTIME = 0n
|
|
@@ -176,17 +323,19 @@ let _ENOTCAPABLE = 76n
|
|
|
176
323
|
|
|
177
324
|
exception SystemError(Number)
|
|
178
325
|
|
|
179
|
-
let stringOfSystemError =
|
|
326
|
+
let stringOfSystemError = code => {
|
|
180
327
|
let n = WasmI32.shrS(WasmI32.fromGrain(code), 1n)
|
|
181
328
|
let (==) = WasmI32.eq
|
|
182
329
|
match (n) {
|
|
183
|
-
n when n == _ESUCCESS =>
|
|
330
|
+
n when n == _ESUCCESS =>
|
|
331
|
+
"SystemError: No error occurred. System call completed successfully.",
|
|
184
332
|
n when n == _ETOOBIG => "SystemError: Argument list too long.",
|
|
185
333
|
n when n == _EACCES => "SystemError: Permission denied.",
|
|
186
334
|
n when n == _EADDRINUSE => "SystemError: Address in use.",
|
|
187
335
|
n when n == _EADDRNOTAVAIL => "SystemError: Address not available.",
|
|
188
336
|
n when n == _EAFNOSUPPORT => "SystemError: Address family not supported.",
|
|
189
|
-
n when n == _EAGAIN =>
|
|
337
|
+
n when n == _EAGAIN =>
|
|
338
|
+
"SystemError: Resource unavailable, or operation would block.",
|
|
190
339
|
n when n == _EALREADY => "SystemError: Connection already in progress.",
|
|
191
340
|
n when n == _EBADF => "SystemError: Bad file descriptor.",
|
|
192
341
|
n when n == _EBADMSG => "SystemError: Bad message.",
|
|
@@ -198,7 +347,8 @@ let stringOfSystemError = (code) => {
|
|
|
198
347
|
n when n == _ECONNRESET => "SystemError: Connection reset.",
|
|
199
348
|
n when n == _EDEADLK => "SystemError: Resource deadlock would occur.",
|
|
200
349
|
n when n == _EDESTADDRREQ => "SystemError: Destination address required.",
|
|
201
|
-
n when n == _EDOM =>
|
|
350
|
+
n when n == _EDOM =>
|
|
351
|
+
"SystemError: Mathematics argument out of domain of function.",
|
|
202
352
|
n when n == _EDQUOT => "SystemError: Reserved.",
|
|
203
353
|
n when n == _EEXIST => "SystemError: File exists.",
|
|
204
354
|
n when n == _EFAULT => "SystemError: Bad address.",
|
|
@@ -234,14 +384,17 @@ let stringOfSystemError = (code) => {
|
|
|
234
384
|
n when n == _ENOSPC => "SystemError: No space left on device.",
|
|
235
385
|
n when n == _ENOSYS => "SystemError: Function not supported.",
|
|
236
386
|
n when n == _ENOTCONN => "SystemError: The socket is not connected.",
|
|
237
|
-
n when n == _ENOTDIR =>
|
|
387
|
+
n when n == _ENOTDIR =>
|
|
388
|
+
"SystemError: Not a directory or a symbolic link to a directory.",
|
|
238
389
|
n when n == _ENOTEMPTY => "SystemError: Directory not empty.",
|
|
239
390
|
n when n == _ENOTRECOVERABLE => "SystemError: State not recoverable.",
|
|
240
391
|
n when n == _ENOTSOCK => "SystemError: Not a socket.",
|
|
241
|
-
n when n == _ENOTSUP =>
|
|
392
|
+
n when n == _ENOTSUP =>
|
|
393
|
+
"SystemError: Not supported, or operation not supported on socket.",
|
|
242
394
|
n when n == _ENOTTY => "SystemError: Inappropriate I/O control operation.",
|
|
243
395
|
n when n == _ENXIO => "SystemError: No such device or address.",
|
|
244
|
-
n when n == _EOVERFLOW =>
|
|
396
|
+
n when n == _EOVERFLOW =>
|
|
397
|
+
"SystemError: Value too large to be stored in data type.",
|
|
245
398
|
n when n == _EOWNERDEAD => "SystemError: Previous owner died.",
|
|
246
399
|
n when n == _EPERM => "SystemError: Operation not permitted.",
|
|
247
400
|
n when n == _EPIPE => "SystemError: Broken pipe.",
|
|
@@ -256,7 +409,8 @@ let stringOfSystemError = (code) => {
|
|
|
256
409
|
n when n == _ETIMEDOUT => "SystemError: Connection timed out.",
|
|
257
410
|
n when n == _ETXTBSY => "SystemError: Text file busy.",
|
|
258
411
|
n when n == _EXDEV => "SystemError: Cross-device link.",
|
|
259
|
-
n when n == _ENOTCAPABLE =>
|
|
412
|
+
n when n == _ENOTCAPABLE =>
|
|
413
|
+
"SystemError: Extension: Capabilities insufficient.",
|
|
260
414
|
_ => "SystemError: Unknown system error: " ++ toString(code),
|
|
261
415
|
}
|
|
262
416
|
}
|
|
@@ -264,6 +418,6 @@ let stringOfSystemError = (code) => {
|
|
|
264
418
|
Exception.registerPrinter(e => {
|
|
265
419
|
match (e) {
|
|
266
420
|
SystemError(n) => Some(stringOfSystemError(n)),
|
|
267
|
-
_ => None
|
|
421
|
+
_ => None,
|
|
268
422
|
}
|
|
269
423
|
})
|