@grain/stdlib 0.4.6 → 0.5.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/array.gr +18 -18
  3. package/array.md +18 -18
  4. package/bigint.gr +497 -0
  5. package/bigint.md +811 -0
  6. package/buffer.gr +49 -213
  7. package/buffer.md +24 -17
  8. package/bytes.gr +100 -202
  9. package/bytes.md +19 -0
  10. package/char.gr +63 -133
  11. package/exception.md +6 -0
  12. package/float32.gr +39 -78
  13. package/float64.gr +43 -78
  14. package/hash.gr +37 -37
  15. package/int32.gr +152 -198
  16. package/int32.md +104 -0
  17. package/int64.gr +151 -197
  18. package/int64.md +104 -0
  19. package/list.gr +467 -70
  20. package/list.md +1141 -0
  21. package/map.gr +192 -7
  22. package/map.md +525 -0
  23. package/number.gr +30 -54
  24. package/number.md +3 -3
  25. package/option.md +1 -1
  26. package/package.json +3 -3
  27. package/pervasives.gr +499 -59
  28. package/pervasives.md +1116 -0
  29. package/queue.gr +4 -0
  30. package/queue.md +10 -0
  31. package/random.gr +196 -0
  32. package/random.md +179 -0
  33. package/regex.gr +1833 -842
  34. package/regex.md +11 -11
  35. package/result.md +1 -1
  36. package/runtime/bigint.gr +2045 -0
  37. package/runtime/bigint.md +326 -0
  38. package/runtime/dataStructures.gr +99 -278
  39. package/runtime/dataStructures.md +391 -0
  40. package/runtime/debug.md +6 -0
  41. package/runtime/equal.gr +5 -23
  42. package/runtime/equal.md +6 -0
  43. package/runtime/exception.md +30 -0
  44. package/runtime/gc.gr +20 -3
  45. package/runtime/gc.md +36 -0
  46. package/runtime/malloc.gr +13 -11
  47. package/runtime/malloc.md +55 -0
  48. package/runtime/numberUtils.gr +91 -41
  49. package/runtime/numberUtils.md +54 -0
  50. package/runtime/numbers.gr +1043 -391
  51. package/runtime/numbers.md +300 -0
  52. package/runtime/string.gr +136 -230
  53. package/runtime/string.md +24 -0
  54. package/runtime/stringUtils.gr +58 -38
  55. package/runtime/stringUtils.md +6 -0
  56. package/runtime/unsafe/constants.gr +17 -0
  57. package/runtime/unsafe/constants.md +72 -0
  58. package/runtime/unsafe/conv.md +71 -0
  59. package/runtime/unsafe/errors.md +204 -0
  60. package/runtime/unsafe/memory.md +54 -0
  61. package/runtime/unsafe/printWasm.md +24 -0
  62. package/runtime/unsafe/tags.gr +9 -8
  63. package/runtime/unsafe/tags.md +120 -0
  64. package/runtime/unsafe/wasmf32.md +168 -0
  65. package/runtime/unsafe/wasmf64.md +168 -0
  66. package/runtime/unsafe/wasmi32.md +282 -0
  67. package/runtime/unsafe/wasmi64.md +300 -0
  68. package/runtime/utils/printing.gr +62 -0
  69. package/runtime/utils/printing.md +18 -0
  70. package/runtime/wasi.gr +1 -1
  71. package/runtime/wasi.md +839 -0
  72. package/set.gr +17 -8
  73. package/set.md +24 -21
  74. package/stack.gr +3 -3
  75. package/stack.md +4 -6
  76. package/string.gr +194 -329
  77. package/string.md +3 -3
  78. package/sys/file.gr +245 -429
  79. package/sys/process.gr +27 -45
  80. package/sys/random.gr +47 -16
  81. package/sys/random.md +38 -0
  82. package/sys/time.gr +11 -27
@@ -14,9 +14,10 @@ import WasmI32, {
14
14
  import WasmI64 from "runtime/unsafe/wasmi64"
15
15
  import Memory from "runtime/unsafe/memory"
16
16
  import Tags from "runtime/unsafe/tags"
17
+ import BI from "runtime/bigint"
17
18
  import { reducedInteger } from "runtime/numbers"
18
19
 
19
- @disableGC
20
+ @unsafe
20
21
  export let rec parseInt = (string: String, radix: Number) => {
21
22
  let _CHAR_0 = 0x30n
22
23
  let _CHAR_B = 0x42n
@@ -45,15 +46,13 @@ export let rec parseInt = (string: String, radix: Number) => {
45
46
  let strEnd = offset + strLen
46
47
 
47
48
  let radix = WasmI32.fromGrain(radix)
48
- let result = if (
49
+ if (
49
50
  WasmI32.eqz(radix & Tags._GRAIN_NUMBER_TAG_MASK) ||
50
51
  radix < WasmI32.fromGrain(2) ||
51
52
  radix > WasmI32.fromGrain(36)
52
53
  ) {
53
- Memory.incRef(WasmI32.fromGrain(Err))
54
54
  Err("Radix must be an integer between 2 and 36")
55
55
  } else if (WasmI32.eqz(strLen)) {
56
- Memory.incRef(WasmI32.fromGrain(Err))
57
56
  Err("Invalid input")
58
57
  } else {
59
58
  let mut char = WasmI32.load8U(offset, 0n)
@@ -90,10 +89,13 @@ export let rec parseInt = (string: String, radix: Number) => {
90
89
  }
91
90
  }
92
91
 
92
+ // We try to avoid allocating a BigInt if it's not needed
93
93
  let mut value = 0N
94
+ let mut radixBigInt = 0n
95
+ let mut valueBigInt = 0n
96
+ let mut isBigInt = 0n
94
97
 
95
- // we use 0 to represent no error, 1 to represent an invalid
96
- // input, and 2 to represent an overflow
98
+ // we use 0 to represent no error and 1 to represent an invalid input
97
99
  let mut error = 1n
98
100
 
99
101
  for (let mut i = offset; i < strEnd; i += 1n) {
@@ -130,47 +132,65 @@ export let rec parseInt = (string: String, radix: Number) => {
130
132
 
131
133
  let digit = WasmI64.extendI32U(digit)
132
134
 
133
- value = WasmI64.mul(value, radix)
134
-
135
- // Check for overflow
136
- // 64-bit int min + 1
137
- if (WasmI64.ltS(value, WasmI64.add(limit, digit))) {
138
- error = 2n
139
- // overflow
140
- break
135
+ if (WasmI32.eqz(isBigInt)) {
136
+ let prevValue = value
137
+ value = WasmI64.mul(value, radix)
138
+ // Check for overflow
139
+ // 64-bit int min + 1
140
+ if (WasmI64.ltS(value, WasmI64.add(limit, digit))) {
141
+ // we overflowed. allocate BigInt and use instead
142
+ isBigInt = 1n
143
+ valueBigInt = BI.makeWrappedUint64(WasmI64.mul(prevValue, -1N))
144
+ radixBigInt = BI.makeWrappedUint64(radix)
145
+ let newvalue = BI.mul(valueBigInt, radixBigInt)
146
+ Memory.decRef(valueBigInt)
147
+ valueBigInt = newvalue
148
+ let newvalue = BI.addInt(valueBigInt, digit)
149
+ Memory.decRef(valueBigInt)
150
+ valueBigInt = newvalue
151
+ } else {
152
+ // To quote the OpenJDK,
153
+ // "Accumulating negatively avoids surprises near MAX_VALUE"
154
+ // The minimum value of a 64-bit integer (-9223372036854775808) can't be
155
+ // represented as a positive number because it would be larger than the
156
+ // maximum 64-bit integer (9223372036854775807), so we'd be unable to
157
+ // parse negatives as positives and multiply by the sign at the end.
158
+ // Instead, we represent all positive numbers as negative numbers since
159
+ // we have one unit more headroom.
160
+ value = WasmI64.sub(value, digit)
161
+ }
162
+ } else {
163
+ let newvalue = BI.mul(valueBigInt, radixBigInt)
164
+ Memory.decRef(valueBigInt)
165
+ valueBigInt = newvalue
166
+ let newvalue = BI.addInt(valueBigInt, digit)
167
+ Memory.decRef(valueBigInt)
168
+ valueBigInt = newvalue
141
169
  }
142
-
143
- // To quote the OpenJDK,
144
- // "Accumulating negatively avoids surprises near MAX_VALUE"
145
- // The minimum value of a 64-bit integer (-9223372036854775808) can't be
146
- // represented as a positive number because it would be larger than the
147
- // maximum 64-bit integer (9223372036854775807), so we'd be unable to
148
- // parse negatives as positives and multiply by the sign at the end.
149
- // Instead, we represent all positive numbers as negative numbers since
150
- // we have one unit more headroom.
151
- value = WasmI64.sub(value, digit)
152
170
  }
153
171
 
154
172
  match (error) {
155
173
  1n => {
156
- Memory.incRef(WasmI32.fromGrain(Err))
157
174
  Err("Invalid digit in input")
158
175
  },
159
- 2n => {
160
- Memory.incRef(WasmI32.fromGrain(Err))
161
- Err("Input out of range of representable integers")
162
- },
163
176
  _ => {
164
- let value = if (negative) value else WasmI64.mul(value, -1N)
165
- let number = WasmI32.toGrain(reducedInteger(value)): Number
166
- Memory.incRef(WasmI32.fromGrain(Ok))
167
- Ok(number)
177
+ if (WasmI32.eqz(isBigInt)) {
178
+ let value = if (negative) value else WasmI64.mul(value, -1N)
179
+ let number = WasmI32.toGrain(
180
+ Memory.incRef(reducedInteger(value))
181
+ ): Number
182
+ Ok(number)
183
+ } else {
184
+ // BigInt number is accumulated in positive form
185
+ if (negative) {
186
+ let newvalue = BI.negate(valueBigInt)
187
+ Memory.decRef(valueBigInt)
188
+ Ok(WasmI32.toGrain(newvalue))
189
+ } else {
190
+ Ok(WasmI32.toGrain(valueBigInt))
191
+ }
192
+ }
168
193
  },
169
194
  }
170
195
  }
171
-
172
- Memory.decRef(WasmI32.fromGrain(parseInt))
173
- Memory.decRef(radix)
174
-
175
- result
176
196
  }
@@ -0,0 +1,6 @@
1
+ ### StringUtils.**parseInt**
2
+
3
+ ```grain
4
+ parseInt : (String, Number) -> Result<Number, String>
5
+ ```
6
+
@@ -0,0 +1,17 @@
1
+ /* grainc-flags --compilation-mode=runtime */
2
+
3
+ // Signed/Unsigned Min/Max Constants
4
+ export let _SMIN_I32 = 0xFFFFFFFFn
5
+ export let _SMAX_I32 = 0x7FFFFFFFn
6
+ export let _UMIN_I32 = 0x0n
7
+ export let _UMAX_I32 = 0xFFFFFFFFn
8
+
9
+ export let _SMIN_I64 = 0xFFFFFFFFFFFFFFFFN
10
+ export let _SMAX_I64 = 0x7FFFFFFFFFFFFFFFN
11
+ export let _UMIN_I64 = 0x0N
12
+ export let _UMAX_I64 = 0xFFFFFFFFFFFFFFFFN
13
+
14
+ export let _SMIN32_I64 = -0x7FFFFFFFN
15
+ export let _SMAX32_I64 = 0x7FFFFFFFN
16
+ export let _UMIN32_I64 = 0x0N
17
+ export let _UMAX32_I64 = 0xFFFFFFFFN
@@ -0,0 +1,72 @@
1
+ ### Constants.**_SMIN_I32**
2
+
3
+ ```grain
4
+ _SMIN_I32 : WasmI32
5
+ ```
6
+
7
+ ### Constants.**_SMAX_I32**
8
+
9
+ ```grain
10
+ _SMAX_I32 : WasmI32
11
+ ```
12
+
13
+ ### Constants.**_UMIN_I32**
14
+
15
+ ```grain
16
+ _UMIN_I32 : WasmI32
17
+ ```
18
+
19
+ ### Constants.**_UMAX_I32**
20
+
21
+ ```grain
22
+ _UMAX_I32 : WasmI32
23
+ ```
24
+
25
+ ### Constants.**_SMIN_I64**
26
+
27
+ ```grain
28
+ _SMIN_I64 : WasmI64
29
+ ```
30
+
31
+ ### Constants.**_SMAX_I64**
32
+
33
+ ```grain
34
+ _SMAX_I64 : WasmI64
35
+ ```
36
+
37
+ ### Constants.**_UMIN_I64**
38
+
39
+ ```grain
40
+ _UMIN_I64 : WasmI64
41
+ ```
42
+
43
+ ### Constants.**_UMAX_I64**
44
+
45
+ ```grain
46
+ _UMAX_I64 : WasmI64
47
+ ```
48
+
49
+ ### Constants.**_SMIN32_I64**
50
+
51
+ ```grain
52
+ _SMIN32_I64 : WasmI64
53
+ ```
54
+
55
+ ### Constants.**_SMAX32_I64**
56
+
57
+ ```grain
58
+ _SMAX32_I64 : WasmI64
59
+ ```
60
+
61
+ ### Constants.**_UMIN32_I64**
62
+
63
+ ```grain
64
+ _UMIN32_I64 : WasmI64
65
+ ```
66
+
67
+ ### Constants.**_UMAX32_I64**
68
+
69
+ ```grain
70
+ _UMAX32_I64 : WasmI64
71
+ ```
72
+
@@ -0,0 +1,71 @@
1
+ ### Conv.**toInt32**
2
+
3
+ ```grain
4
+ toInt32 : WasmI32 -> Int32
5
+ ```
6
+
7
+ ### Conv.**fromInt32**
8
+
9
+ ```grain
10
+ fromInt32 : Int32 -> WasmI32
11
+ ```
12
+
13
+ ### Conv.**toInt64**
14
+
15
+ ```grain
16
+ toInt64 : WasmI64 -> Int64
17
+ ```
18
+
19
+ ### Conv.**fromInt64**
20
+
21
+ ```grain
22
+ fromInt64 : Int64 -> WasmI64
23
+ ```
24
+
25
+ ### Conv.**toFloat32**
26
+
27
+ ```grain
28
+ toFloat32 : WasmF32 -> Float32
29
+ ```
30
+
31
+ ### Conv.**fromFloat32**
32
+
33
+ ```grain
34
+ fromFloat32 : Float32 -> WasmF32
35
+ ```
36
+
37
+ ### Conv.**toFloat64**
38
+
39
+ ```grain
40
+ toFloat64 : WasmF64 -> Float64
41
+ ```
42
+
43
+ ### Conv.**fromFloat64**
44
+
45
+ ```grain
46
+ fromFloat64 : Float64 -> WasmF64
47
+ ```
48
+
49
+ ### Conv.**wasmI32ToNumber**
50
+
51
+ ```grain
52
+ wasmI32ToNumber : WasmI32 -> Number
53
+ ```
54
+
55
+ Converts a WasmI32 value to Number.
56
+
57
+ This function is meant to be called from a `@disableGC` context without
58
+ need to call incRef on the function.
59
+
60
+ Parameters:
61
+
62
+ |param|type|description|
63
+ |-----|----|-----------|
64
+ |`n`|`WasmI32`|The WasmI32 to convert|
65
+
66
+ Returns:
67
+
68
+ |type|description|
69
+ |----|-----------|
70
+ |`Number`|The value converted to either a simple or a 32 bit heap allocated number.|
71
+
@@ -0,0 +1,204 @@
1
+ ### Errors.**_GRAIN_ERR_NOT_NUMBER_COMP**
2
+
3
+ ```grain
4
+ _GRAIN_ERR_NOT_NUMBER_COMP : WasmI32
5
+ ```
6
+
7
+ ### Errors.**_GRAIN_ERR_NOT_NUMBER_ARITH**
8
+
9
+ ```grain
10
+ _GRAIN_ERR_NOT_NUMBER_ARITH : WasmI32
11
+ ```
12
+
13
+ ### Errors.**_GRAIN_ERR_NOT_BOOLEAN_LOGIC**
14
+
15
+ ```grain
16
+ _GRAIN_ERR_NOT_BOOLEAN_LOGIC : WasmI32
17
+ ```
18
+
19
+ ### Errors.**_GRAIN_ERR_NOT_BOOLEAN_IF**
20
+
21
+ ```grain
22
+ _GRAIN_ERR_NOT_BOOLEAN_IF : WasmI32
23
+ ```
24
+
25
+ ### Errors.**_GRAIN_ERR_OVERFLOW**
26
+
27
+ ```grain
28
+ _GRAIN_ERR_OVERFLOW : WasmI32
29
+ ```
30
+
31
+ ### Errors.**_GRAIN_ERR_GET_NOT_TUP**
32
+
33
+ ```grain
34
+ _GRAIN_ERR_GET_NOT_TUP : WasmI32
35
+ ```
36
+
37
+ ### Errors.**_GRAIN_ERR_GET_ITEM_IDX_NOT_NUMBER**
38
+
39
+ ```grain
40
+ _GRAIN_ERR_GET_ITEM_IDX_NOT_NUMBER : WasmI32
41
+ ```
42
+
43
+ ### Errors.**_GRAIN_ERR_GET_ITEM_IDX_TOO_SMALL**
44
+
45
+ ```grain
46
+ _GRAIN_ERR_GET_ITEM_IDX_TOO_SMALL : WasmI32
47
+ ```
48
+
49
+ ### Errors.**_GRAIN_ERR_GET_ITEM_IDX_TOO_LARGE**
50
+
51
+ ```grain
52
+ _GRAIN_ERR_GET_ITEM_IDX_TOO_LARGE : WasmI32
53
+ ```
54
+
55
+ ### Errors.**_GRAIN_ERR_CALLED_NON_FUNCTION**
56
+
57
+ ```grain
58
+ _GRAIN_ERR_CALLED_NON_FUNCTION : WasmI32
59
+ ```
60
+
61
+ ### Errors.**_GRAIN_ERR_ARITY_MISMATCH**
62
+
63
+ ```grain
64
+ _GRAIN_ERR_ARITY_MISMATCH : WasmI32
65
+ ```
66
+
67
+ ### Errors.**_GRAIN_ERR_OUT_OF_MEMORY**
68
+
69
+ ```grain
70
+ _GRAIN_ERR_OUT_OF_MEMORY : WasmI32
71
+ ```
72
+
73
+ ### Errors.**_GRAIN_ERR_SET_NOT_TUP**
74
+
75
+ ```grain
76
+ _GRAIN_ERR_SET_NOT_TUP : WasmI32
77
+ ```
78
+
79
+ ### Errors.**_GRAIN_ERR_SET_ITEM_IDX_NOT_NUMBER**
80
+
81
+ ```grain
82
+ _GRAIN_ERR_SET_ITEM_IDX_NOT_NUMBER : WasmI32
83
+ ```
84
+
85
+ ### Errors.**_GRAIN_ERR_SET_ITEM_IDX_TOO_SMALL**
86
+
87
+ ```grain
88
+ _GRAIN_ERR_SET_ITEM_IDX_TOO_SMALL : WasmI32
89
+ ```
90
+
91
+ ### Errors.**_GRAIN_ERR_SET_ITEM_IDX_TOO_LARGE**
92
+
93
+ ```grain
94
+ _GRAIN_ERR_SET_ITEM_IDX_TOO_LARGE : WasmI32
95
+ ```
96
+
97
+ ### Errors.**_GRAIN_ERR_DIVISION_BY_ZERO**
98
+
99
+ ```grain
100
+ _GRAIN_ERR_DIVISION_BY_ZERO : WasmI32
101
+ ```
102
+
103
+ ### Errors.**_GRAIN_ERR_MODULO_BY_ZERO**
104
+
105
+ ```grain
106
+ _GRAIN_ERR_MODULO_BY_ZERO : WasmI32
107
+ ```
108
+
109
+ ### Errors.**_GRAIN_ERR_ARRAY_INDEX_OUT_OF_BOUNDS**
110
+
111
+ ```grain
112
+ _GRAIN_ERR_ARRAY_INDEX_OUT_OF_BOUNDS : WasmI32
113
+ ```
114
+
115
+ ### Errors.**_GRAIN_ERR_INVALID_ARGUMENT**
116
+
117
+ ```grain
118
+ _GRAIN_ERR_INVALID_ARGUMENT : WasmI32
119
+ ```
120
+
121
+ ### Errors.**_GRAIN_ERR_ASSERTION_ERROR**
122
+
123
+ ```grain
124
+ _GRAIN_ERR_ASSERTION_ERROR : WasmI32
125
+ ```
126
+
127
+ ### Errors.**_GRAIN_ERR_FAILURE**
128
+
129
+ ```grain
130
+ _GRAIN_ERR_FAILURE : WasmI32
131
+ ```
132
+
133
+ ### Errors.**_GRAIN_ERR_SYSTEM**
134
+
135
+ ```grain
136
+ _GRAIN_ERR_SYSTEM : WasmI32
137
+ ```
138
+
139
+ ### Errors.**_GRAIN_ERR_NOT_INTLIKE**
140
+
141
+ ```grain
142
+ _GRAIN_ERR_NOT_INTLIKE : WasmI32
143
+ ```
144
+
145
+ ### Errors.**_GRAIN_ERR_NOT_RATIONAL**
146
+
147
+ ```grain
148
+ _GRAIN_ERR_NOT_RATIONAL : WasmI32
149
+ ```
150
+
151
+ ### Errors.**_GRAIN_ERR_MALFORMED_UTF8**
152
+
153
+ ```grain
154
+ _GRAIN_ERR_MALFORMED_UTF8 : WasmI32
155
+ ```
156
+
157
+ ### Errors.**_GRAIN_ERR_NOT_ADT_VAL_GENERIC**
158
+
159
+ ```grain
160
+ _GRAIN_ERR_NOT_ADT_VAL_GENERIC : WasmI32
161
+ ```
162
+
163
+ ### Errors.**_GRAIN_ERR_NOT_STRING_GENERIC**
164
+
165
+ ```grain
166
+ _GRAIN_ERR_NOT_STRING_GENERIC : WasmI32
167
+ ```
168
+
169
+ ### Errors.**_GRAIN_ERR_NOT_BOOLEAN_GENERIC**
170
+
171
+ ```grain
172
+ _GRAIN_ERR_NOT_BOOLEAN_GENERIC : WasmI32
173
+ ```
174
+
175
+ ### Errors.**_GRAIN_ERR_NOT_TUPLE_GENERIC**
176
+
177
+ ```grain
178
+ _GRAIN_ERR_NOT_TUPLE_GENERIC : WasmI32
179
+ ```
180
+
181
+ ### Errors.**_GRAIN_ERR_NOT_LAMBDA_GENERIC**
182
+
183
+ ```grain
184
+ _GRAIN_ERR_NOT_LAMBDA_GENERIC : WasmI32
185
+ ```
186
+
187
+ ### Errors.**_GRAIN_ERR_BAD_INPUT**
188
+
189
+ ```grain
190
+ _GRAIN_ERR_BAD_INPUT : WasmI32
191
+ ```
192
+
193
+ ### Errors.**_GRAIN_ERR_NOT_NONNEG**
194
+
195
+ ```grain
196
+ _GRAIN_ERR_NOT_NONNEG : WasmI32
197
+ ```
198
+
199
+ ### Errors.**_GRAIN_ERR_NOT_NUMBER_GENERIC**
200
+
201
+ ```grain
202
+ _GRAIN_ERR_NOT_NUMBER_GENERIC : WasmI32
203
+ ```
204
+
@@ -0,0 +1,54 @@
1
+ ### Memory.**malloc**
2
+
3
+ ```grain
4
+ malloc : WasmI32 -> WasmI32
5
+ ```
6
+
7
+ ### Memory.**free**
8
+
9
+ ```grain
10
+ free : WasmI32 -> Void
11
+ ```
12
+
13
+ ### Memory.**incRef**
14
+
15
+ ```grain
16
+ incRef : WasmI32 -> WasmI32
17
+ ```
18
+
19
+ ### Memory.**decRef**
20
+
21
+ ```grain
22
+ decRef : WasmI32 -> WasmI32
23
+ ```
24
+
25
+ ### Memory.**utoa32Buffered**
26
+
27
+ ```grain
28
+ utoa32Buffered : Box<(WasmI32, WasmI32, WasmI32) -> Void>
29
+ ```
30
+
31
+ ### Memory.**decimalCount32**
32
+
33
+ ```grain
34
+ decimalCount32 : Box<WasmI32 -> WasmI32>
35
+ ```
36
+
37
+ ### Memory.**copy**
38
+
39
+ ```grain
40
+ copy : (WasmI32, WasmI32, WasmI32) -> Void
41
+ ```
42
+
43
+ ### Memory.**fill**
44
+
45
+ ```grain
46
+ fill : (WasmI32, WasmI32, WasmI32) -> Void
47
+ ```
48
+
49
+ ### Memory.**compare**
50
+
51
+ ```grain
52
+ compare : (WasmI32, WasmI32, WasmI32) -> WasmI32
53
+ ```
54
+
@@ -0,0 +1,24 @@
1
+ ### PrintWasm.**printI32**
2
+
3
+ ```grain
4
+ printI32 : WasmI32 -> Void
5
+ ```
6
+
7
+ ### PrintWasm.**printI64**
8
+
9
+ ```grain
10
+ printI64 : WasmI64 -> Void
11
+ ```
12
+
13
+ ### PrintWasm.**printF32**
14
+
15
+ ```grain
16
+ printF32 : WasmF32 -> Void
17
+ ```
18
+
19
+ ### PrintWasm.**printF64**
20
+
21
+ ```grain
22
+ printF64 : WasmF64 -> Void
23
+ ```
24
+
@@ -1,6 +1,7 @@
1
1
  /* grainc-flags --compilation-mode=runtime */
2
2
 
3
3
  export let _GRAIN_NUMBER_TAG_TYPE = 0b0001n
4
+ export let _GRAIN_CHAR_TAG_TYPE = 0b0010n
4
5
  export let _GRAIN_CONST_TAG_TYPE = 0b0110n
5
6
  export let _GRAIN_GENERIC_HEAP_TAG_TYPE = 0b0000n
6
7
 
@@ -8,14 +9,13 @@ export let _GRAIN_NUMBER_TAG_MASK = 0b0001n
8
9
  export let _GRAIN_GENERIC_TAG_MASK = 0b0111n
9
10
 
10
11
  export let _GRAIN_STRING_HEAP_TAG = 1n
11
- export let _GRAIN_CHAR_HEAP_TAG = 2n
12
- export let _GRAIN_ADT_HEAP_TAG = 3n
13
- export let _GRAIN_RECORD_HEAP_TAG = 4n
14
- export let _GRAIN_ARRAY_HEAP_TAG = 5n
15
- export let _GRAIN_BOXED_NUM_HEAP_TAG = 6n
16
- export let _GRAIN_LAMBDA_HEAP_TAG = 7n
17
- export let _GRAIN_TUPLE_HEAP_TAG = 8n
18
- export let _GRAIN_BYTES_HEAP_TAG = 9n
12
+ export let _GRAIN_ADT_HEAP_TAG = 2n
13
+ export let _GRAIN_RECORD_HEAP_TAG = 3n
14
+ export let _GRAIN_ARRAY_HEAP_TAG = 4n
15
+ export let _GRAIN_BOXED_NUM_HEAP_TAG = 5n
16
+ export let _GRAIN_LAMBDA_HEAP_TAG = 6n
17
+ export let _GRAIN_TUPLE_HEAP_TAG = 7n
18
+ export let _GRAIN_BYTES_HEAP_TAG = 8n
19
19
 
20
20
  // Boxed number types
21
21
  export let _GRAIN_FLOAT32_BOXED_NUM_TAG = 1n
@@ -23,3 +23,4 @@ export let _GRAIN_FLOAT64_BOXED_NUM_TAG = 2n
23
23
  export let _GRAIN_INT32_BOXED_NUM_TAG = 3n
24
24
  export let _GRAIN_INT64_BOXED_NUM_TAG = 4n
25
25
  export let _GRAIN_RATIONAL_BOXED_NUM_TAG = 5n
26
+ export let _GRAIN_BIGINT_BOXED_NUM_TAG = 6n