@wasmgroundup/emit 1.0.0 → 1.0.2
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/index.js +3 -53
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export function version() {
|
|
|
16
16
|
|
|
17
17
|
export const CONTINUATION_BIT = 0b10000000;
|
|
18
18
|
export const SEVEN_BIT_MASK_BIG_INT = 0b01111111n;
|
|
19
|
+
|
|
19
20
|
export function leb128(v) {
|
|
20
21
|
let val = BigInt(v);
|
|
21
22
|
let more = true;
|
|
@@ -37,6 +38,7 @@ export function leb128(v) {
|
|
|
37
38
|
|
|
38
39
|
export const MIN_U32 = 0;
|
|
39
40
|
export const MAX_U32 = 2 ** 32 - 1;
|
|
41
|
+
|
|
40
42
|
export function u32(v) {
|
|
41
43
|
if (v < MIN_U32 || v > MAX_U32) {
|
|
42
44
|
throw Error(`Value out of range for u32: ${v}`);
|
|
@@ -70,6 +72,7 @@ export function sleb128(v) {
|
|
|
70
72
|
export const MIN_I32 = -(2 ** 32 / 2);
|
|
71
73
|
export const MAX_I32 = 2 ** 32 / 2 - 1;
|
|
72
74
|
export const I32_NEG_OFFSET = 2 ** 32;
|
|
75
|
+
|
|
73
76
|
export function i32(v) {
|
|
74
77
|
if (v < MIN_I32 || v > MAX_U32) {
|
|
75
78
|
throw Error(`Value out of range for i32: ${v}`);
|
|
@@ -408,40 +411,11 @@ export function elem(x, e, ys) {
|
|
|
408
411
|
export function elemsec(segs) {
|
|
409
412
|
return section(SECTION_ID_ELEMENT, vec(segs));
|
|
410
413
|
}
|
|
411
|
-
export function assert(cond, msg) {
|
|
412
|
-
if (!cond) {
|
|
413
|
-
throw new Error(msg);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
414
|
|
|
417
|
-
instr.local ??= {};
|
|
418
|
-
instr.global ??= {};
|
|
419
|
-
instr.memory ??= {};
|
|
420
|
-
instr.i32 ??= {};
|
|
421
|
-
instr.i64 ??= {};
|
|
422
|
-
instr.f32 ??= {};
|
|
423
|
-
instr.f64 ??= {};
|
|
424
|
-
instr.unreachable = 0x0;
|
|
425
415
|
instr.nop = 0x1;
|
|
426
|
-
instr.block = 0x2;
|
|
427
|
-
instr.loop = 0x3;
|
|
428
|
-
instr.if = 0x4;
|
|
429
|
-
instr.else = 0x5;
|
|
430
|
-
instr.end = 0xb;
|
|
431
|
-
instr.br = 0xc;
|
|
432
|
-
instr.br_if = 0xd;
|
|
433
416
|
instr.br_table = 0xe;
|
|
434
417
|
instr.return = 0xf;
|
|
435
|
-
instr.call = 0x10;
|
|
436
|
-
instr.call_indirect = 0x11;
|
|
437
|
-
instr.drop = 0x1a;
|
|
438
418
|
instr.select = 0x1b;
|
|
439
|
-
instr.local.get = 0x20;
|
|
440
|
-
instr.local.set = 0x21;
|
|
441
|
-
instr.local.tee = 0x22;
|
|
442
|
-
instr.global.get = 0x23;
|
|
443
|
-
instr.global.set = 0x24;
|
|
444
|
-
instr.i32.load = 0x28;
|
|
445
419
|
instr.i64.load = 0x29;
|
|
446
420
|
instr.f32.load = 0x2a;
|
|
447
421
|
instr.f64.load = 0x2b;
|
|
@@ -455,7 +429,6 @@ instr.i64.load16_s = 0x32;
|
|
|
455
429
|
instr.i64.load16_u = 0x33;
|
|
456
430
|
instr.i64.load32_s = 0x34;
|
|
457
431
|
instr.i64.load32_u = 0x35;
|
|
458
|
-
instr.i32.store = 0x36;
|
|
459
432
|
instr.i64.store = 0x37;
|
|
460
433
|
instr.f32.store = 0x38;
|
|
461
434
|
instr.f64.store = 0x39;
|
|
@@ -464,23 +437,6 @@ instr.i32.store16 = 0x3b;
|
|
|
464
437
|
instr.i64.store8 = 0x3c;
|
|
465
438
|
instr.i64.store16 = 0x3d;
|
|
466
439
|
instr.i64.store32 = 0x3e;
|
|
467
|
-
instr.memory.size = 0x3f;
|
|
468
|
-
instr.memory.grow = 0x40;
|
|
469
|
-
instr.i32.const = 0x41;
|
|
470
|
-
instr.i64.const = 0x42;
|
|
471
|
-
instr.f32.const = 0x43;
|
|
472
|
-
instr.f64.const = 0x44;
|
|
473
|
-
instr.i32.eqz = 0x45;
|
|
474
|
-
instr.i32.eq = 0x46;
|
|
475
|
-
instr.i32.ne = 0x47;
|
|
476
|
-
instr.i32.lt_s = 0x48;
|
|
477
|
-
instr.i32.lt_u = 0x49;
|
|
478
|
-
instr.i32.gt_s = 0x4a;
|
|
479
|
-
instr.i32.gt_u = 0x4b;
|
|
480
|
-
instr.i32.le_s = 0x4c;
|
|
481
|
-
instr.i32.le_u = 0x4d;
|
|
482
|
-
instr.i32.ge_s = 0x4e;
|
|
483
|
-
instr.i32.ge_u = 0x4f;
|
|
484
440
|
instr.i64.eqz = 0x50;
|
|
485
441
|
instr.i64.eq = 0x51;
|
|
486
442
|
instr.i64.ne = 0x52;
|
|
@@ -507,15 +463,9 @@ instr.f64.ge = 0x66;
|
|
|
507
463
|
instr.i32.clz = 0x67;
|
|
508
464
|
instr.i32.ctz = 0x68;
|
|
509
465
|
instr.i32.popcnt = 0x69;
|
|
510
|
-
instr.i32.add = 0x6a;
|
|
511
|
-
instr.i32.sub = 0x6b;
|
|
512
|
-
instr.i32.mul = 0x6c;
|
|
513
|
-
instr.i32.div_s = 0x6d;
|
|
514
466
|
instr.i32.div_u = 0x6e;
|
|
515
467
|
instr.i32.rem_s = 0x6f;
|
|
516
468
|
instr.i32.rem_u = 0x70;
|
|
517
|
-
instr.i32.and = 0x71;
|
|
518
|
-
instr.i32.or = 0x72;
|
|
519
469
|
instr.i32.xor = 0x73;
|
|
520
470
|
instr.i32.shl = 0x74;
|
|
521
471
|
instr.i32.shr_s = 0x75;
|