@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.
- package/CHANGELOG.md +73 -0
- package/array.gr +18 -18
- package/array.md +18 -18
- package/bigint.gr +497 -0
- package/bigint.md +811 -0
- package/buffer.gr +49 -213
- package/buffer.md +24 -17
- package/bytes.gr +100 -202
- package/bytes.md +19 -0
- package/char.gr +63 -133
- package/exception.md +6 -0
- package/float32.gr +39 -78
- package/float64.gr +43 -78
- package/hash.gr +37 -37
- package/int32.gr +152 -198
- package/int32.md +104 -0
- package/int64.gr +151 -197
- package/int64.md +104 -0
- package/list.gr +467 -70
- package/list.md +1141 -0
- package/map.gr +192 -7
- package/map.md +525 -0
- package/number.gr +30 -54
- package/number.md +3 -3
- package/option.md +1 -1
- package/package.json +3 -3
- package/pervasives.gr +499 -59
- package/pervasives.md +1116 -0
- package/queue.gr +4 -0
- package/queue.md +10 -0
- package/random.gr +196 -0
- package/random.md +179 -0
- package/regex.gr +1833 -842
- package/regex.md +11 -11
- package/result.md +1 -1
- package/runtime/bigint.gr +2045 -0
- package/runtime/bigint.md +326 -0
- package/runtime/dataStructures.gr +99 -278
- package/runtime/dataStructures.md +391 -0
- package/runtime/debug.md +6 -0
- package/runtime/equal.gr +5 -23
- package/runtime/equal.md +6 -0
- package/runtime/exception.md +30 -0
- package/runtime/gc.gr +20 -3
- package/runtime/gc.md +36 -0
- package/runtime/malloc.gr +13 -11
- package/runtime/malloc.md +55 -0
- package/runtime/numberUtils.gr +91 -41
- package/runtime/numberUtils.md +54 -0
- package/runtime/numbers.gr +1043 -391
- package/runtime/numbers.md +300 -0
- package/runtime/string.gr +136 -230
- package/runtime/string.md +24 -0
- package/runtime/stringUtils.gr +58 -38
- package/runtime/stringUtils.md +6 -0
- package/runtime/unsafe/constants.gr +17 -0
- package/runtime/unsafe/constants.md +72 -0
- package/runtime/unsafe/conv.md +71 -0
- package/runtime/unsafe/errors.md +204 -0
- package/runtime/unsafe/memory.md +54 -0
- package/runtime/unsafe/printWasm.md +24 -0
- package/runtime/unsafe/tags.gr +9 -8
- package/runtime/unsafe/tags.md +120 -0
- package/runtime/unsafe/wasmf32.md +168 -0
- package/runtime/unsafe/wasmf64.md +168 -0
- package/runtime/unsafe/wasmi32.md +282 -0
- package/runtime/unsafe/wasmi64.md +300 -0
- package/runtime/utils/printing.gr +62 -0
- package/runtime/utils/printing.md +18 -0
- package/runtime/wasi.gr +1 -1
- package/runtime/wasi.md +839 -0
- package/set.gr +17 -8
- package/set.md +24 -21
- package/stack.gr +3 -3
- package/stack.md +4 -6
- package/string.gr +194 -329
- package/string.md +3 -3
- package/sys/file.gr +245 -429
- package/sys/process.gr +27 -45
- package/sys/random.gr +47 -16
- package/sys/random.md +38 -0
- package/sys/time.gr +11 -27
package/int64.gr
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
8
8
|
import WasmI64 from "runtime/unsafe/wasmi64"
|
|
9
9
|
import Exception from "runtime/exception"
|
|
10
|
-
import Memory from "runtime/unsafe/memory"
|
|
11
10
|
|
|
12
11
|
import { newInt64 } from "runtime/dataStructures"
|
|
13
12
|
|
|
@@ -52,14 +51,11 @@ export toNumber
|
|
|
52
51
|
*
|
|
53
52
|
* @since v0.2.0
|
|
54
53
|
*/
|
|
55
|
-
@
|
|
56
|
-
export let
|
|
54
|
+
@unsafe
|
|
55
|
+
export let incr = (value: Int64) => {
|
|
57
56
|
let value = WasmI32.fromGrain(value)
|
|
58
57
|
let ptr = newInt64(WasmI64.add(WasmI64.load(value, 8n), 1N))
|
|
59
|
-
|
|
60
|
-
Memory.decRef(value)
|
|
61
|
-
Memory.decRef(WasmI32.fromGrain(incr))
|
|
62
|
-
ret
|
|
58
|
+
WasmI32.toGrain(ptr): Int64
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
/**
|
|
@@ -70,14 +66,11 @@ export let rec incr = (value: Int64) => {
|
|
|
70
66
|
*
|
|
71
67
|
* @since v0.2.0
|
|
72
68
|
*/
|
|
73
|
-
@
|
|
69
|
+
@unsafe
|
|
74
70
|
export let decr = (value: Int64) => {
|
|
75
71
|
let value = WasmI32.fromGrain(value)
|
|
76
72
|
let ptr = newInt64(WasmI64.sub(WasmI64.load(value, 8n), 1N))
|
|
77
|
-
|
|
78
|
-
Memory.decRef(value)
|
|
79
|
-
Memory.decRef(WasmI32.fromGrain(decr))
|
|
80
|
-
ret
|
|
73
|
+
WasmI32.toGrain(ptr): Int64
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
/**
|
|
@@ -89,16 +82,12 @@ export let decr = (value: Int64) => {
|
|
|
89
82
|
*
|
|
90
83
|
* @since v0.2.0
|
|
91
84
|
*/
|
|
92
|
-
@
|
|
93
|
-
export let
|
|
85
|
+
@unsafe
|
|
86
|
+
export let add = (x: Int64, y: Int64) => {
|
|
94
87
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
95
88
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
96
89
|
let ptr = newInt64(WasmI64.add(xv, yv))
|
|
97
|
-
|
|
98
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
99
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
100
|
-
Memory.decRef(WasmI32.fromGrain(add))
|
|
101
|
-
ret
|
|
90
|
+
WasmI32.toGrain(ptr): Int64
|
|
102
91
|
}
|
|
103
92
|
|
|
104
93
|
/**
|
|
@@ -110,16 +99,12 @@ export let rec add = (x: Int64, y: Int64) => {
|
|
|
110
99
|
*
|
|
111
100
|
* @since v0.2.0
|
|
112
101
|
*/
|
|
113
|
-
@
|
|
114
|
-
export let
|
|
102
|
+
@unsafe
|
|
103
|
+
export let sub = (x: Int64, y: Int64) => {
|
|
115
104
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
116
105
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
117
106
|
let ptr = newInt64(WasmI64.sub(xv, yv))
|
|
118
|
-
|
|
119
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
120
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
121
|
-
Memory.decRef(WasmI32.fromGrain(sub))
|
|
122
|
-
ret
|
|
107
|
+
WasmI32.toGrain(ptr): Int64
|
|
123
108
|
}
|
|
124
109
|
|
|
125
110
|
/**
|
|
@@ -131,16 +116,12 @@ export let rec sub = (x: Int64, y: Int64) => {
|
|
|
131
116
|
*
|
|
132
117
|
* @since v0.2.0
|
|
133
118
|
*/
|
|
134
|
-
@
|
|
135
|
-
export let
|
|
119
|
+
@unsafe
|
|
120
|
+
export let mul = (x: Int64, y: Int64) => {
|
|
136
121
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
137
122
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
138
123
|
let ptr = newInt64(WasmI64.mul(xv, yv))
|
|
139
|
-
|
|
140
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
141
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
142
|
-
Memory.decRef(WasmI32.fromGrain(mul))
|
|
143
|
-
ret
|
|
124
|
+
WasmI32.toGrain(ptr): Int64
|
|
144
125
|
}
|
|
145
126
|
|
|
146
127
|
/**
|
|
@@ -152,16 +133,12 @@ export let rec mul = (x: Int64, y: Int64) => {
|
|
|
152
133
|
*
|
|
153
134
|
* @since v0.2.0
|
|
154
135
|
*/
|
|
155
|
-
@
|
|
156
|
-
export let
|
|
136
|
+
@unsafe
|
|
137
|
+
export let div = (x: Int64, y: Int64) => {
|
|
157
138
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
158
139
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
159
140
|
let ptr = newInt64(WasmI64.divS(xv, yv))
|
|
160
|
-
|
|
161
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
162
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
163
|
-
Memory.decRef(WasmI32.fromGrain(div))
|
|
164
|
-
ret
|
|
141
|
+
WasmI32.toGrain(ptr): Int64
|
|
165
142
|
}
|
|
166
143
|
|
|
167
144
|
/**
|
|
@@ -173,16 +150,12 @@ export let rec div = (x: Int64, y: Int64) => {
|
|
|
173
150
|
*
|
|
174
151
|
* @since v0.2.0
|
|
175
152
|
*/
|
|
176
|
-
@
|
|
177
|
-
export let
|
|
153
|
+
@unsafe
|
|
154
|
+
export let divU = (x: Int64, y: Int64) => {
|
|
178
155
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
179
156
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
180
157
|
let ptr = newInt64(WasmI64.divU(xv, yv))
|
|
181
|
-
|
|
182
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
183
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
184
|
-
Memory.decRef(WasmI32.fromGrain(divU))
|
|
185
|
-
ret
|
|
158
|
+
WasmI32.toGrain(ptr): Int64
|
|
186
159
|
}
|
|
187
160
|
|
|
188
161
|
/**
|
|
@@ -194,16 +167,12 @@ export let rec divU = (x: Int64, y: Int64) => {
|
|
|
194
167
|
*
|
|
195
168
|
* @since v0.2.0
|
|
196
169
|
*/
|
|
197
|
-
@
|
|
198
|
-
export let
|
|
170
|
+
@unsafe
|
|
171
|
+
export let rem = (x: Int64, y: Int64) => {
|
|
199
172
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
200
173
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
201
174
|
let ptr = newInt64(WasmI64.remS(xv, yv))
|
|
202
|
-
|
|
203
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
204
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
205
|
-
Memory.decRef(WasmI32.fromGrain(rem))
|
|
206
|
-
ret
|
|
175
|
+
WasmI32.toGrain(ptr): Int64
|
|
207
176
|
}
|
|
208
177
|
|
|
209
178
|
/**
|
|
@@ -215,19 +184,15 @@ export let rec rem = (x: Int64, y: Int64) => {
|
|
|
215
184
|
*
|
|
216
185
|
* @since v0.2.0
|
|
217
186
|
*/
|
|
218
|
-
@
|
|
219
|
-
export let
|
|
187
|
+
@unsafe
|
|
188
|
+
export let remU = (x: Int64, y: Int64) => {
|
|
220
189
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
221
190
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
222
191
|
let ptr = newInt64(WasmI64.remU(xv, yv))
|
|
223
|
-
|
|
224
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
225
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
226
|
-
Memory.decRef(WasmI32.fromGrain(remU))
|
|
227
|
-
ret
|
|
192
|
+
WasmI32.toGrain(ptr): Int64
|
|
228
193
|
}
|
|
229
194
|
|
|
230
|
-
@
|
|
195
|
+
@unsafe
|
|
231
196
|
let abs = n => {
|
|
232
197
|
let mask = WasmI64.shrS(n, 63N)
|
|
233
198
|
WasmI64.sub(WasmI64.xor(n, mask), mask)
|
|
@@ -243,8 +208,8 @@ let abs = n => {
|
|
|
243
208
|
*
|
|
244
209
|
* @since v0.2.0
|
|
245
210
|
*/
|
|
246
|
-
@
|
|
247
|
-
export let
|
|
211
|
+
@unsafe
|
|
212
|
+
export let mod = (x: Int64, y: Int64) => {
|
|
248
213
|
let xval = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
249
214
|
let yval = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
250
215
|
|
|
@@ -265,11 +230,7 @@ export let rec mod = (x: Int64, y: Int64) => {
|
|
|
265
230
|
} else {
|
|
266
231
|
newInt64(WasmI64.remS(xval, yval))
|
|
267
232
|
}
|
|
268
|
-
|
|
269
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
270
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
271
|
-
Memory.decRef(WasmI32.fromGrain(mod))
|
|
272
|
-
ret
|
|
233
|
+
WasmI32.toGrain(ptr): Int64
|
|
273
234
|
}
|
|
274
235
|
|
|
275
236
|
/**
|
|
@@ -285,16 +246,12 @@ export let rec mod = (x: Int64, y: Int64) => {
|
|
|
285
246
|
*
|
|
286
247
|
* @since v0.4.0
|
|
287
248
|
*/
|
|
288
|
-
@
|
|
289
|
-
export let
|
|
249
|
+
@unsafe
|
|
250
|
+
export let rotl = (value: Int64, amount: Int64) => {
|
|
290
251
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
291
252
|
let yv = WasmI64.load(WasmI32.fromGrain(amount), 8n)
|
|
292
253
|
let ptr = newInt64(WasmI64.rotl(xv, yv))
|
|
293
|
-
|
|
294
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
295
|
-
Memory.decRef(WasmI32.fromGrain(amount))
|
|
296
|
-
Memory.decRef(WasmI32.fromGrain(rotl))
|
|
297
|
-
ret
|
|
254
|
+
WasmI32.toGrain(ptr): Int64
|
|
298
255
|
}
|
|
299
256
|
|
|
300
257
|
/**
|
|
@@ -306,16 +263,12 @@ export let rec rotl = (value: Int64, amount: Int64) => {
|
|
|
306
263
|
*
|
|
307
264
|
* @since v0.4.0
|
|
308
265
|
*/
|
|
309
|
-
@
|
|
310
|
-
export let
|
|
266
|
+
@unsafe
|
|
267
|
+
export let rotr = (value: Int64, amount: Int64) => {
|
|
311
268
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
312
269
|
let yv = WasmI64.load(WasmI32.fromGrain(amount), 8n)
|
|
313
270
|
let ptr = newInt64(WasmI64.rotr(xv, yv))
|
|
314
|
-
|
|
315
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
316
|
-
Memory.decRef(WasmI32.fromGrain(amount))
|
|
317
|
-
Memory.decRef(WasmI32.fromGrain(rotr))
|
|
318
|
-
ret
|
|
271
|
+
WasmI32.toGrain(ptr): Int64
|
|
319
272
|
}
|
|
320
273
|
|
|
321
274
|
/**
|
|
@@ -327,16 +280,12 @@ export let rec rotr = (value: Int64, amount: Int64) => {
|
|
|
327
280
|
*
|
|
328
281
|
* @since v0.2.0
|
|
329
282
|
*/
|
|
330
|
-
@
|
|
331
|
-
export let
|
|
283
|
+
@unsafe
|
|
284
|
+
export let shl = (value: Int64, amount: Int64) => {
|
|
332
285
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
333
286
|
let yv = WasmI64.load(WasmI32.fromGrain(amount), 8n)
|
|
334
287
|
let ptr = newInt64(WasmI64.shl(xv, yv))
|
|
335
|
-
|
|
336
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
337
|
-
Memory.decRef(WasmI32.fromGrain(amount))
|
|
338
|
-
Memory.decRef(WasmI32.fromGrain(shl))
|
|
339
|
-
ret
|
|
288
|
+
WasmI32.toGrain(ptr): Int64
|
|
340
289
|
}
|
|
341
290
|
|
|
342
291
|
/**
|
|
@@ -348,16 +297,12 @@ export let rec shl = (value: Int64, amount: Int64) => {
|
|
|
348
297
|
*
|
|
349
298
|
* @since v0.2.0
|
|
350
299
|
*/
|
|
351
|
-
@
|
|
352
|
-
export let
|
|
300
|
+
@unsafe
|
|
301
|
+
export let shr = (value: Int64, amount: Int64) => {
|
|
353
302
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
354
303
|
let yv = WasmI64.load(WasmI32.fromGrain(amount), 8n)
|
|
355
304
|
let ptr = newInt64(WasmI64.shrS(xv, yv))
|
|
356
|
-
|
|
357
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
358
|
-
Memory.decRef(WasmI32.fromGrain(amount))
|
|
359
|
-
Memory.decRef(WasmI32.fromGrain(shr))
|
|
360
|
-
ret
|
|
305
|
+
WasmI32.toGrain(ptr): Int64
|
|
361
306
|
}
|
|
362
307
|
|
|
363
308
|
/**
|
|
@@ -369,16 +314,12 @@ export let rec shr = (value: Int64, amount: Int64) => {
|
|
|
369
314
|
*
|
|
370
315
|
* @since v0.2.0
|
|
371
316
|
*/
|
|
372
|
-
@
|
|
373
|
-
export let
|
|
317
|
+
@unsafe
|
|
318
|
+
export let shrU = (value: Int64, amount: Int64) => {
|
|
374
319
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
375
320
|
let yv = WasmI64.load(WasmI32.fromGrain(amount), 8n)
|
|
376
321
|
let ptr = newInt64(WasmI64.shrU(xv, yv))
|
|
377
|
-
|
|
378
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
379
|
-
Memory.decRef(WasmI32.fromGrain(amount))
|
|
380
|
-
Memory.decRef(WasmI32.fromGrain(shrU))
|
|
381
|
-
ret
|
|
322
|
+
WasmI32.toGrain(ptr): Int64
|
|
382
323
|
}
|
|
383
324
|
|
|
384
325
|
/**
|
|
@@ -394,15 +335,11 @@ export let rec shrU = (value: Int64, amount: Int64) => {
|
|
|
394
335
|
*
|
|
395
336
|
* @since v0.4.0
|
|
396
337
|
*/
|
|
397
|
-
@
|
|
398
|
-
export let
|
|
338
|
+
@unsafe
|
|
339
|
+
export let eq = (x: Int64, y: Int64) => {
|
|
399
340
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
400
341
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
401
|
-
|
|
402
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
403
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
404
|
-
Memory.decRef(WasmI32.fromGrain(eq))
|
|
405
|
-
ret
|
|
342
|
+
WasmI64.eq(xv, yv)
|
|
406
343
|
}
|
|
407
344
|
|
|
408
345
|
/**
|
|
@@ -414,15 +351,11 @@ export let rec eq = (x: Int64, y: Int64) => {
|
|
|
414
351
|
*
|
|
415
352
|
* @since v0.4.0
|
|
416
353
|
*/
|
|
417
|
-
@
|
|
418
|
-
export let
|
|
354
|
+
@unsafe
|
|
355
|
+
export let ne = (x: Int64, y: Int64) => {
|
|
419
356
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
420
357
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
421
|
-
|
|
422
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
423
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
424
|
-
Memory.decRef(WasmI32.fromGrain(ne))
|
|
425
|
-
ret
|
|
358
|
+
WasmI64.ne(xv, yv)
|
|
426
359
|
}
|
|
427
360
|
|
|
428
361
|
/**
|
|
@@ -433,13 +366,10 @@ export let rec ne = (x: Int64, y: Int64) => {
|
|
|
433
366
|
*
|
|
434
367
|
* @since v0.4.0
|
|
435
368
|
*/
|
|
436
|
-
@
|
|
437
|
-
export let
|
|
369
|
+
@unsafe
|
|
370
|
+
export let eqz = (value: Int64) => {
|
|
438
371
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
439
|
-
|
|
440
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
441
|
-
Memory.decRef(WasmI32.fromGrain(eqz))
|
|
442
|
-
ret
|
|
372
|
+
WasmI64.eqz(xv)
|
|
443
373
|
}
|
|
444
374
|
|
|
445
375
|
/**
|
|
@@ -451,15 +381,27 @@ export let rec eqz = (value: Int64) => {
|
|
|
451
381
|
*
|
|
452
382
|
* @since v0.2.0
|
|
453
383
|
*/
|
|
454
|
-
@
|
|
455
|
-
export let
|
|
384
|
+
@unsafe
|
|
385
|
+
export let lt = (x: Int64, y: Int64) => {
|
|
456
386
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
457
387
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
388
|
+
WasmI64.ltS(xv, yv)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Checks if the first unsigned value is less than the second unsigned value.
|
|
393
|
+
*
|
|
394
|
+
* @param x: The first value
|
|
395
|
+
* @param y: The second value
|
|
396
|
+
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
397
|
+
*
|
|
398
|
+
* @since v0.5.0
|
|
399
|
+
*/
|
|
400
|
+
@unsafe
|
|
401
|
+
export let rec ltU = (x: Int64, y: Int64) => {
|
|
402
|
+
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
403
|
+
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
404
|
+
WasmI64.ltU(xv, yv)
|
|
463
405
|
}
|
|
464
406
|
|
|
465
407
|
/**
|
|
@@ -471,15 +413,27 @@ export let rec lt = (x: Int64, y: Int64) => {
|
|
|
471
413
|
*
|
|
472
414
|
* @since v0.2.0
|
|
473
415
|
*/
|
|
474
|
-
@
|
|
475
|
-
export let
|
|
416
|
+
@unsafe
|
|
417
|
+
export let gt = (x: Int64, y: Int64) => {
|
|
418
|
+
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
419
|
+
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
420
|
+
WasmI64.gtS(xv, yv)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Checks if the first unsigned value is greater than the second unsigned value.
|
|
425
|
+
*
|
|
426
|
+
* @param x: The first value
|
|
427
|
+
* @param y: The second value
|
|
428
|
+
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
429
|
+
*
|
|
430
|
+
* @since v0.5.0
|
|
431
|
+
*/
|
|
432
|
+
@unsafe
|
|
433
|
+
export let rec gtU = (x: Int64, y: Int64) => {
|
|
476
434
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
477
435
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
478
|
-
|
|
479
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
480
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
481
|
-
Memory.decRef(WasmI32.fromGrain(gt))
|
|
482
|
-
ret
|
|
436
|
+
WasmI64.gtU(xv, yv)
|
|
483
437
|
}
|
|
484
438
|
|
|
485
439
|
/**
|
|
@@ -491,15 +445,27 @@ export let rec gt = (x: Int64, y: Int64) => {
|
|
|
491
445
|
*
|
|
492
446
|
* @since v0.2.0
|
|
493
447
|
*/
|
|
494
|
-
@
|
|
495
|
-
export let
|
|
448
|
+
@unsafe
|
|
449
|
+
export let lte = (x: Int64, y: Int64) => {
|
|
496
450
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
497
451
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
452
|
+
WasmI64.leS(xv, yv)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Checks if the first unsigned value is less than or equal to the second unsigned value.
|
|
457
|
+
*
|
|
458
|
+
* @param x: The first value
|
|
459
|
+
* @param y: The second value
|
|
460
|
+
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
461
|
+
*
|
|
462
|
+
* @since v0.5.0
|
|
463
|
+
*/
|
|
464
|
+
@unsafe
|
|
465
|
+
export let rec lteU = (x: Int64, y: Int64) => {
|
|
466
|
+
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
467
|
+
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
468
|
+
WasmI64.leU(xv, yv)
|
|
503
469
|
}
|
|
504
470
|
|
|
505
471
|
/**
|
|
@@ -511,15 +477,27 @@ export let rec lte = (x: Int64, y: Int64) => {
|
|
|
511
477
|
*
|
|
512
478
|
* @since v0.2.0
|
|
513
479
|
*/
|
|
514
|
-
@
|
|
515
|
-
export let
|
|
480
|
+
@unsafe
|
|
481
|
+
export let gte = (x: Int64, y: Int64) => {
|
|
482
|
+
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
483
|
+
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
484
|
+
WasmI64.geS(xv, yv)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Checks if the first unsigned value is greater than or equal to the second unsigned value.
|
|
489
|
+
*
|
|
490
|
+
* @param x: The first value
|
|
491
|
+
* @param y: The second value
|
|
492
|
+
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
493
|
+
*
|
|
494
|
+
* @since v0.5.0
|
|
495
|
+
*/
|
|
496
|
+
@unsafe
|
|
497
|
+
export let rec gteU = (x: Int64, y: Int64) => {
|
|
516
498
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
517
499
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
518
|
-
|
|
519
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
520
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
521
|
-
Memory.decRef(WasmI32.fromGrain(gte))
|
|
522
|
-
ret
|
|
500
|
+
WasmI64.geU(xv, yv)
|
|
523
501
|
}
|
|
524
502
|
|
|
525
503
|
/**
|
|
@@ -534,14 +512,11 @@ export let rec gte = (x: Int64, y: Int64) => {
|
|
|
534
512
|
*
|
|
535
513
|
* @since v0.2.0
|
|
536
514
|
*/
|
|
537
|
-
@
|
|
538
|
-
export let
|
|
515
|
+
@unsafe
|
|
516
|
+
export let lnot = (value: Int64) => {
|
|
539
517
|
let xv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
540
518
|
let ptr = newInt64(WasmI64.xor(xv, 0xffffffffffffffffN))
|
|
541
|
-
|
|
542
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
543
|
-
Memory.decRef(WasmI32.fromGrain(lnot))
|
|
544
|
-
ret
|
|
519
|
+
WasmI32.toGrain(ptr): Int64
|
|
545
520
|
}
|
|
546
521
|
|
|
547
522
|
/**
|
|
@@ -553,16 +528,12 @@ export let rec lnot = (value: Int64) => {
|
|
|
553
528
|
*
|
|
554
529
|
* @since v0.2.0
|
|
555
530
|
*/
|
|
556
|
-
@
|
|
557
|
-
export let
|
|
531
|
+
@unsafe
|
|
532
|
+
export let land = (x: Int64, y: Int64) => {
|
|
558
533
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
559
534
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
560
535
|
let ptr = newInt64(WasmI64.and(xv, yv))
|
|
561
|
-
|
|
562
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
563
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
564
|
-
Memory.decRef(WasmI32.fromGrain(land))
|
|
565
|
-
ret
|
|
536
|
+
WasmI32.toGrain(ptr): Int64
|
|
566
537
|
}
|
|
567
538
|
|
|
568
539
|
/**
|
|
@@ -574,16 +545,12 @@ export let rec land = (x: Int64, y: Int64) => {
|
|
|
574
545
|
*
|
|
575
546
|
* @since v0.2.0
|
|
576
547
|
*/
|
|
577
|
-
@
|
|
578
|
-
export let
|
|
548
|
+
@unsafe
|
|
549
|
+
export let lor = (x: Int64, y: Int64) => {
|
|
579
550
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
580
551
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
581
552
|
let ptr = newInt64(WasmI64.or(xv, yv))
|
|
582
|
-
|
|
583
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
584
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
585
|
-
Memory.decRef(WasmI32.fromGrain(lor))
|
|
586
|
-
ret
|
|
553
|
+
WasmI32.toGrain(ptr): Int64
|
|
587
554
|
}
|
|
588
555
|
|
|
589
556
|
/**
|
|
@@ -595,16 +562,12 @@ export let rec lor = (x: Int64, y: Int64) => {
|
|
|
595
562
|
*
|
|
596
563
|
* @since v0.2.0
|
|
597
564
|
*/
|
|
598
|
-
@
|
|
599
|
-
export let
|
|
565
|
+
@unsafe
|
|
566
|
+
export let lxor = (x: Int64, y: Int64) => {
|
|
600
567
|
let xv = WasmI64.load(WasmI32.fromGrain(x), 8n)
|
|
601
568
|
let yv = WasmI64.load(WasmI32.fromGrain(y), 8n)
|
|
602
569
|
let ptr = newInt64(WasmI64.xor(xv, yv))
|
|
603
|
-
|
|
604
|
-
Memory.decRef(WasmI32.fromGrain(x))
|
|
605
|
-
Memory.decRef(WasmI32.fromGrain(y))
|
|
606
|
-
Memory.decRef(WasmI32.fromGrain(lxor))
|
|
607
|
-
ret
|
|
570
|
+
WasmI32.toGrain(ptr): Int64
|
|
608
571
|
}
|
|
609
572
|
|
|
610
573
|
/**
|
|
@@ -615,14 +578,11 @@ export let rec lxor = (x: Int64, y: Int64) => {
|
|
|
615
578
|
*
|
|
616
579
|
* @since v0.4.0
|
|
617
580
|
*/
|
|
618
|
-
@
|
|
619
|
-
export let
|
|
581
|
+
@unsafe
|
|
582
|
+
export let clz = (value: Int64) => {
|
|
620
583
|
let nv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
621
584
|
let ptr = newInt64(WasmI64.clz(nv))
|
|
622
|
-
|
|
623
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
624
|
-
Memory.decRef(WasmI32.fromGrain(clz))
|
|
625
|
-
ret
|
|
585
|
+
WasmI32.toGrain(ptr): Int64
|
|
626
586
|
}
|
|
627
587
|
|
|
628
588
|
/**
|
|
@@ -633,14 +593,11 @@ export let rec clz = (value: Int64) => {
|
|
|
633
593
|
*
|
|
634
594
|
* @since v0.4.0
|
|
635
595
|
*/
|
|
636
|
-
@
|
|
637
|
-
export let
|
|
596
|
+
@unsafe
|
|
597
|
+
export let ctz = (value: Int64) => {
|
|
638
598
|
let nv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
639
599
|
let ptr = newInt64(WasmI64.ctz(nv))
|
|
640
|
-
|
|
641
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
642
|
-
Memory.decRef(WasmI32.fromGrain(ctz))
|
|
643
|
-
ret
|
|
600
|
+
WasmI32.toGrain(ptr): Int64
|
|
644
601
|
}
|
|
645
602
|
|
|
646
603
|
/**
|
|
@@ -651,12 +608,9 @@ export let rec ctz = (value: Int64) => {
|
|
|
651
608
|
*
|
|
652
609
|
* @since v0.4.0
|
|
653
610
|
*/
|
|
654
|
-
@
|
|
655
|
-
export let
|
|
611
|
+
@unsafe
|
|
612
|
+
export let popcnt = (value: Int64) => {
|
|
656
613
|
let nv = WasmI64.load(WasmI32.fromGrain(value), 8n)
|
|
657
614
|
let ptr = newInt64(WasmI64.popcnt(nv))
|
|
658
|
-
|
|
659
|
-
Memory.decRef(WasmI32.fromGrain(value))
|
|
660
|
-
Memory.decRef(WasmI32.fromGrain(popcnt))
|
|
661
|
-
ret
|
|
615
|
+
WasmI32.toGrain(ptr): Int64
|
|
662
616
|
}
|