@bytecodealliance/jco 1.17.3 → 1.17.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/obj/js-component-bindgen-component.core.wasm +0 -0
- package/obj/js-component-bindgen-component.js +1449 -1332
- package/obj/wasm-tools.js +1454 -1337
- package/package.json +1 -1
package/obj/wasm-tools.js
CHANGED
|
@@ -1750,8 +1750,9 @@ class Waitable {
|
|
|
1750
1750
|
|
|
1751
1751
|
const ready = readyFn();
|
|
1752
1752
|
if (ready && ASYNC_DETERMINISM === 'random') {
|
|
1753
|
-
const coinFlip = _coinFlip();
|
|
1754
|
-
if (coinFlip) { return true }
|
|
1753
|
+
// const coinFlip = _coinFlip();
|
|
1754
|
+
// if (coinFlip) { return true }
|
|
1755
|
+
return true;
|
|
1755
1756
|
}
|
|
1756
1757
|
|
|
1757
1758
|
const keepGoing = await this.immediateSuspend({ cancellable, readyFn });
|
|
@@ -2204,7 +2205,9 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2204
2205
|
if (ctx.storageLen !== undefined && ctx.storageLen < ctx.storagePtr + 1) {
|
|
2205
2206
|
throw new Error('not enough storage remaining for lift');
|
|
2206
2207
|
}
|
|
2208
|
+
|
|
2207
2209
|
val = new DataView(ctx.memory.buffer).getUint8(ctx.storagePtr, true);
|
|
2210
|
+
|
|
2208
2211
|
ctx.storagePtr += 1;
|
|
2209
2212
|
if (ctx.storageLen !== undefined) { ctx.storageLen -= 1; }
|
|
2210
2213
|
|
|
@@ -2361,47 +2364,11 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2361
2364
|
}
|
|
2362
2365
|
}
|
|
2363
2366
|
|
|
2364
|
-
function _liftFlatList(
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
let dataPtr;
|
|
2370
|
-
let len;
|
|
2371
|
-
if (ctx.useDirectParams) {
|
|
2372
|
-
if (knownLen) {
|
|
2373
|
-
dataPtr = _liftFlatU32(ctx);
|
|
2374
|
-
} else {
|
|
2375
|
-
metaPtr = _liftFlatU32(ctx);
|
|
2376
|
-
}
|
|
2377
|
-
} else {
|
|
2378
|
-
if (knownLen) {
|
|
2379
|
-
dataPtr = _liftFlatU32(ctx);
|
|
2380
|
-
} else {
|
|
2381
|
-
metaPtr = _liftFlatU32(ctx);
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
if (metaPtr) {
|
|
2386
|
-
if (dataPtr !== undefined) { throw new Error('both meta and data pointers should not be set yet'); }
|
|
2387
|
-
|
|
2388
|
-
if (ctx.useDirectParams) {
|
|
2389
|
-
ctx.useDirectParams = false;
|
|
2390
|
-
ctx.storagePtr = metaPtr;
|
|
2391
|
-
ctx.storageLen = 8;
|
|
2392
|
-
|
|
2393
|
-
dataPtr = _liftFlatU32(ctx);
|
|
2394
|
-
len = _liftFlatU32(ctx);
|
|
2395
|
-
|
|
2396
|
-
ctx.useDirectParams = true;
|
|
2397
|
-
ctx.storagePtr = null;
|
|
2398
|
-
ctx.storageLen = null;
|
|
2399
|
-
} else {
|
|
2400
|
-
dataPtr = _liftFlatU32(ctx);
|
|
2401
|
-
len = _liftFlatU32(ctx);
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2367
|
+
function _liftFlatList(meta) {
|
|
2368
|
+
const { elemLiftFn, align32, knownLen } = meta;
|
|
2369
|
+
|
|
2370
|
+
const readValuesAndReset = (ctx, originalPtr, dataPtr, len) => {
|
|
2371
|
+
ctx.storagePtr = dataPtr;
|
|
2405
2372
|
const val = [];
|
|
2406
2373
|
for (var i = 0; i < len; i++) {
|
|
2407
2374
|
const [res, nextCtx] = elemLiftFn(ctx);
|
|
@@ -2409,1431 +2376,1530 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2409
2376
|
ctx = nextCtx;
|
|
2410
2377
|
|
|
2411
2378
|
const rem = ctx.storagePtr % align32;
|
|
2412
|
-
if (rem !== 0) {
|
|
2379
|
+
if (rem !== 0) { ctx.storagePtr += align32 - rem; }
|
|
2413
2380
|
}
|
|
2414
|
-
|
|
2381
|
+
if (originalPtr !== null) { ctx.storagePtr = originalPtr; }
|
|
2415
2382
|
return [val, ctx];
|
|
2383
|
+
};
|
|
2384
|
+
|
|
2385
|
+
return function _liftFlatListInner(ctx) {
|
|
2386
|
+
_debugLog('[_liftFlatList()] args', { ctx });
|
|
2387
|
+
|
|
2388
|
+
let liftResults;
|
|
2389
|
+
if (knownLen) { // list with known length
|
|
2390
|
+
|
|
2391
|
+
if (ctx.useDirectParams) {
|
|
2392
|
+
// list with known length w/ direct params
|
|
2393
|
+
const dataPtr = ctx.params[0];
|
|
2394
|
+
ctx.params = ctx.params.slice(1);
|
|
2395
|
+
|
|
2396
|
+
// TODO: is it possible for all values to come in from params?
|
|
2397
|
+
|
|
2398
|
+
ctx.useDirectParams = false;
|
|
2399
|
+
const originalPtr = ctx.storagePtr;
|
|
2400
|
+
ctx.storageLen = 8;
|
|
2401
|
+
|
|
2402
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2403
|
+
|
|
2404
|
+
ctx.useDirectParams = true;
|
|
2405
|
+
ctx.storagePtr = null;
|
|
2406
|
+
ctx.storageLen = null;
|
|
2407
|
+
|
|
2408
|
+
} else {
|
|
2409
|
+
liftResults = readValuesAndReset(ctx, null, ctx.storagePtr, knownLen);
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
} else { // unknown length list
|
|
2413
|
+
|
|
2414
|
+
if (ctx.useDirectParams) {
|
|
2415
|
+
// unknown length list ptr w/ direct params
|
|
2416
|
+
const dataPtr = ctx.params[0];
|
|
2417
|
+
const len = ctx.params[1];
|
|
2418
|
+
ctx.params = ctx.params.slice(2);
|
|
2419
|
+
|
|
2420
|
+
ctx.useDirectParams = false;
|
|
2421
|
+
const originalPtr = ctx.storagePtr;
|
|
2422
|
+
ctx.storageLen = 8;
|
|
2423
|
+
|
|
2424
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2425
|
+
|
|
2426
|
+
ctx.useDirectParams = true;
|
|
2427
|
+
ctx.storagePtr = null;
|
|
2428
|
+
ctx.storageLen = null;
|
|
2429
|
+
|
|
2430
|
+
} else {
|
|
2431
|
+
// unknown length list ptr w/ in-memory params
|
|
2432
|
+
const dataPtrLiftRes = _liftFlatU32(ctx);
|
|
2433
|
+
const dataPtr = dataPtrLiftRes[0];
|
|
2434
|
+
ctx = dataPtrLiftRes[1];
|
|
2435
|
+
|
|
2436
|
+
const lenLiftRes = _liftFlatU32(ctx);
|
|
2437
|
+
const len = lenLiftRes[0];
|
|
2438
|
+
ctx = lenLiftRes[1];
|
|
2439
|
+
|
|
2440
|
+
const originalPtr = ctx.storagePtr;
|
|
2441
|
+
ctx.storagePtr = dataPtr;
|
|
2442
|
+
|
|
2443
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2416
2444
|
}
|
|
2417
2445
|
}
|
|
2418
2446
|
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2447
|
+
return liftResults;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
function _liftFlatFlags(meta) {
|
|
2452
|
+
const { names, size32, align32, intSize } = meta;
|
|
2453
|
+
|
|
2454
|
+
return function _liftFlatFlagsInner(ctx) {
|
|
2455
|
+
_debugLog('[_liftFlatFlags()] args', { ctx });
|
|
2456
|
+
|
|
2457
|
+
const val = {};
|
|
2458
|
+
|
|
2459
|
+
let liftRes;
|
|
2460
|
+
let align;
|
|
2461
|
+
switch (intSize) {
|
|
2462
|
+
case 1:
|
|
2463
|
+
liftRes = _liftFlatU8(ctx);
|
|
2464
|
+
break;
|
|
2465
|
+
case 2:
|
|
2466
|
+
liftRes = _liftFlatU16(ctx);
|
|
2467
|
+
break;
|
|
2468
|
+
case 4:
|
|
2469
|
+
liftRes = _liftFlatU32(ctx);
|
|
2470
|
+
break;
|
|
2471
|
+
default:
|
|
2472
|
+
throw new Error('invalid flags size');
|
|
2473
|
+
}
|
|
2474
|
+
let bits = liftRes[0];
|
|
2475
|
+
ctx = liftRes[1];
|
|
2476
|
+
|
|
2477
|
+
for (const name of names) {
|
|
2478
|
+
val[name] = (bits & 1) === 1;
|
|
2479
|
+
bits >>>= 1;
|
|
2423
2480
|
}
|
|
2481
|
+
|
|
2482
|
+
const rem = ctx.storagePtr % align32;
|
|
2483
|
+
if (rem !== 0) { ctx.storagePtr += align32 - rem; }
|
|
2484
|
+
|
|
2485
|
+
return [val, ctx];
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
function _liftFlatResult(casesAndLiftFns) {
|
|
2490
|
+
return function _liftFlatResultInner(ctx) {
|
|
2491
|
+
_debugLog('[_liftFlatResult()] args', { ctx });
|
|
2492
|
+
return _liftFlatVariant(casesAndLiftFns)(ctx);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
function _liftFlatBorrow(componentTableIdx, size, memory, vals, storagePtr, storageLen) {
|
|
2497
|
+
_debugLog('[_liftFlatBorrow()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2498
|
+
throw new Error('flat lift for borrowed resources not yet implemented!');
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
function _lowerFlatU8(ctx) {
|
|
2502
|
+
_debugLog('[_lowerFlatU8()] args', ctx);
|
|
2503
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2504
|
+
if (vals.length !== 1) {
|
|
2505
|
+
throw new Error('unexpected number (' + vals.length + ') of core vals (expected 1)');
|
|
2424
2506
|
}
|
|
2507
|
+
if (vals[0] > 255 || vals[0] < 0) { throw new Error('invalid value for core value representing u8'); }
|
|
2508
|
+
if (!memory) { throw new Error("missing memory for lower"); }
|
|
2509
|
+
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2510
|
+
|
|
2511
|
+
// TODO: ALIGNMENT IS WRONG?
|
|
2512
|
+
|
|
2513
|
+
return 1;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
function _lowerFlatU16(memory, vals, storagePtr, storageLen) {
|
|
2517
|
+
_debugLog('[_lowerFlatU16()] args', { memory, vals, storagePtr, storageLen });
|
|
2518
|
+
if (vals.length !== 1) {
|
|
2519
|
+
throw new Error('unexpected number (' + vals.length + ') of core vals (expected 1)');
|
|
2520
|
+
}
|
|
2521
|
+
if (vals[0] > 65_535 || vals[0] < 0) { throw new Error('invalid value for core value representing u16'); }
|
|
2522
|
+
new DataView(memory.buffer).setUint16(storagePtr, vals[0], true);
|
|
2523
|
+
return 2;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
function _lowerFlatU32(ctx) {
|
|
2527
|
+
_debugLog('[_lowerFlatU32()] args', { ctx });
|
|
2528
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2529
|
+
if (vals.length !== 1) { throw new Error('expected single value to lower, got (' + vals.length + ')'); }
|
|
2530
|
+
if (vals[0] > 4_294_967_295 || vals[0] < 0) { throw new Error('invalid value for core value representing u32'); }
|
|
2531
|
+
|
|
2532
|
+
// TODO(refactor): fail loudly on misaligned flat lowers?
|
|
2533
|
+
const rem = ctx.storagePtr % 4;
|
|
2534
|
+
if (rem !== 0) { ctx.storagePtr += (4 - rem); }
|
|
2535
|
+
|
|
2536
|
+
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2537
|
+
|
|
2538
|
+
return 4;
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
function _lowerFlatU64(memory, vals, storagePtr, storageLen) {
|
|
2542
|
+
_debugLog('[_lowerFlatU64()] args', { memory, vals, storagePtr, storageLen });
|
|
2543
|
+
if (vals.length !== 1) { throw new Error('unexpected number of core vals'); }
|
|
2544
|
+
if (vals[0] > 18_446_744_073_709_551_615n || vals[0] < 0n) { throw new Error('invalid value for core value representing u64'); }
|
|
2545
|
+
new DataView(memory.buffer).setBigUint64(storagePtr, vals[0], true);
|
|
2546
|
+
return 8;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
function _lowerFlatStringUTF8(ctx) {
|
|
2550
|
+
_debugLog('[_lowerFlatStringUTF8()] args', ctx);
|
|
2551
|
+
|
|
2552
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2425
2553
|
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2554
|
+
const s = vals[0];
|
|
2555
|
+
const { ptr, len, codepoints } = _utf8AllocateAndEncode(vals[0], realloc, memory);
|
|
2556
|
+
|
|
2557
|
+
const view = new DataView(memory.buffer);
|
|
2558
|
+
view.setUint32(storagePtr, ptr, true);
|
|
2559
|
+
view.setUint32(storagePtr + 4, codepoints, true);
|
|
2560
|
+
|
|
2561
|
+
return len;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
function _lowerFlatRecord(fieldMetas) {
|
|
2565
|
+
return (size, memory, vals, storagePtr, storageLen) => {
|
|
2566
|
+
const params = [...arguments].slice(5);
|
|
2567
|
+
_debugLog('[_lowerFlatRecord()] args', {
|
|
2568
|
+
size,
|
|
2569
|
+
memory,
|
|
2570
|
+
vals,
|
|
2571
|
+
storagePtr,
|
|
2572
|
+
storageLen,
|
|
2573
|
+
params,
|
|
2574
|
+
fieldMetas
|
|
2575
|
+
});
|
|
2576
|
+
|
|
2577
|
+
const [start] = vals;
|
|
2578
|
+
if (storageLen !== undefined && size !== undefined && size > storageLen) {
|
|
2579
|
+
throw new Error('not enough storage remaining for record flat lower');
|
|
2430
2580
|
}
|
|
2581
|
+
const data = new Uint8Array(memory.buffer, start, size);
|
|
2582
|
+
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2583
|
+
return data.byteLength;
|
|
2431
2584
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
function _lowerFlatVariant(lowerMetas) {
|
|
2588
|
+
return function _lowerFlatVariantInner(ctx) {
|
|
2589
|
+
_debugLog('[_lowerFlatVariant()] args', ctx);
|
|
2590
|
+
|
|
2591
|
+
const { memory, realloc, vals, storageLen, componentIdx } = ctx;
|
|
2592
|
+
let storagePtr = ctx.storagePtr;
|
|
2593
|
+
|
|
2594
|
+
const { tag, val } = vals[0];
|
|
2595
|
+
const disc = lowerMetas.findIndex(m => m[0] === tag);
|
|
2596
|
+
if (disc === -1) {
|
|
2597
|
+
throw new Error(`invalid variant tag/discriminant [${tag}] (valid tags: ${variantMetas.map(m => m[0])})`);
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
const [ _tag, lowerFn, size32, align32, payloadOffset32 ] = lowerMetas[disc];
|
|
2601
|
+
|
|
2602
|
+
const originalPtr = ctx.resultPtr;
|
|
2603
|
+
ctx.vals = [disc];
|
|
2604
|
+
let discLowerRes;
|
|
2605
|
+
if (lowerMetas.length < 256) {
|
|
2606
|
+
discLowerRes = _lowerFlatU8(ctx);
|
|
2607
|
+
} else if (lowerMetas.length >= 256 && lowerMetas.length < 65536) {
|
|
2608
|
+
discLowerRes = _lowerFlatU16(ctx);
|
|
2609
|
+
} else if (lowerMetas.length >= 65536 && lowerMetas.length < 4_294_967_296) {
|
|
2610
|
+
discLowerRes = _lowerFlatU32(ctx);
|
|
2611
|
+
} else {
|
|
2612
|
+
throw new Error('unsupported number of cases [' + lowerMetas.legnth + ']');
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
ctx.resultPtr = originalPtr + payloadOffset32;
|
|
2616
|
+
|
|
2617
|
+
const payloadBytesWritten = lowerFn({
|
|
2618
|
+
memory,
|
|
2619
|
+
realloc,
|
|
2620
|
+
vals: [val],
|
|
2621
|
+
storagePtr,
|
|
2622
|
+
storageLen,
|
|
2623
|
+
componentIdx,
|
|
2624
|
+
});
|
|
2625
|
+
let bytesWritten = payloadOffset + payloadBytesWritten;
|
|
2626
|
+
|
|
2627
|
+
const rem = ctx.storagePtr % align32;
|
|
2628
|
+
if (rem !== 0) {
|
|
2629
|
+
const pad = align32 - rem;
|
|
2630
|
+
ctx.storagePtr += pad;
|
|
2631
|
+
bytesWritten += pad;
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
return bytesWritten;
|
|
2436
2635
|
}
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
function _lowerFlatList(args) {
|
|
2639
|
+
const { elemLowerFn } = args;
|
|
2640
|
+
if (!elemLowerFn) { throw new TypeError("missing/invalid element lower fn for list"); }
|
|
2437
2641
|
|
|
2438
|
-
function
|
|
2439
|
-
_debugLog('[
|
|
2440
|
-
|
|
2441
|
-
if (
|
|
2442
|
-
|
|
2642
|
+
return function _lowerFlatListInner(ctx) {
|
|
2643
|
+
_debugLog('[_lowerFlatList()] args', { ctx });
|
|
2644
|
+
|
|
2645
|
+
if (ctx.params.length < 2) { throw new Error('insufficient params left to lower list'); }
|
|
2646
|
+
const storagePtr = ctx.params[0];
|
|
2647
|
+
const elemCount = ctx.params[1];
|
|
2648
|
+
ctx.params = ctx.params.slice(2);
|
|
2649
|
+
|
|
2650
|
+
if (ctx.useDirectParams) {
|
|
2651
|
+
const list = ctx.vals[0];
|
|
2652
|
+
if (!list) { throw new Error("missing direct param value"); }
|
|
2653
|
+
|
|
2654
|
+
const elemLowerCtx = { storagePtr, memory: ctx.memory };
|
|
2655
|
+
for (let idx = 0; idx < list.length; idx++) {
|
|
2656
|
+
elemLowerCtx.vals = list.slice(idx, idx+1);
|
|
2657
|
+
elemLowerCtx.storagePtr += elemLowerFn(elemLowerCtx);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
const bytesLowered = elemLowerCtx.storagePtr - ctx.storagePtr;
|
|
2661
|
+
ctx.storagePtr = elemLowerCtx.storagePtr;
|
|
2662
|
+
return bytesLowered;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
if (ctx.vals.length !== 2) {
|
|
2666
|
+
throw new Error('indirect parameter loading must have a pointer and length as vals');
|
|
2667
|
+
}
|
|
2668
|
+
let [valStartPtr, valLen] = ctx.vals;
|
|
2669
|
+
const totalSizeBytes = valLen * size;
|
|
2670
|
+
if (ctx.storageLen !== undefined && totalSizeBytes > ctx.storageLen) {
|
|
2671
|
+
throw new Error('not enough storage remaining for list flat lower');
|
|
2443
2672
|
}
|
|
2444
|
-
if (vals[0] > 255 || vals[0] < 0) { throw new Error('invalid value for core value representing u8'); }
|
|
2445
|
-
if (!memory) { throw new Error("missing memory for lower"); }
|
|
2446
|
-
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2447
2673
|
|
|
2448
|
-
|
|
2674
|
+
const data = new Uint8Array(memory.buffer, valStartPtr, totalSizeBytes);
|
|
2675
|
+
new Uint8Array(memory.buffer, storagePtr, totalSizeBytes).set(data);
|
|
2449
2676
|
|
|
2450
|
-
return
|
|
2677
|
+
return totalSizeBytes;
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
function _lowerFlatTuple(size, memory, vals, storagePtr, storageLen) {
|
|
2682
|
+
_debugLog('[_lowerFlatTuple()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2683
|
+
let [start, len] = vals;
|
|
2684
|
+
if (storageLen !== undefined && len > storageLen) {
|
|
2685
|
+
throw new Error('not enough storage remaining for tuple flat lower');
|
|
2686
|
+
}
|
|
2687
|
+
const data = new Uint8Array(memory.buffer, start, len);
|
|
2688
|
+
new Uint8Array(memory.buffer, storagePtr, len).set(data);
|
|
2689
|
+
return data.byteLength;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
function _lowerFlatFlags(memory, vals, storagePtr, storageLen) {
|
|
2693
|
+
_debugLog('[_lowerFlatFlags()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2694
|
+
if (vals.length !== 1) { throw new Error('unexpected number of core vals'); }
|
|
2695
|
+
new DataView(memory.buffer).setInt32(storagePtr, vals[0], true);
|
|
2696
|
+
return 4;
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
function _lowerFlatEnum(size, memory, vals, storagePtr, storageLen) {
|
|
2700
|
+
_debugLog('[_lowerFlatEnum()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2701
|
+
let [start] = vals;
|
|
2702
|
+
if (storageLen !== undefined && size !== undefined && size > storageLen) {
|
|
2703
|
+
throw new Error('not enough storage remaining for enum flat lower');
|
|
2704
|
+
}
|
|
2705
|
+
const data = new Uint8Array(memory.buffer, start, size);
|
|
2706
|
+
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2707
|
+
return data.byteLength;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
function _lowerFlatOption(lowerMetas) {
|
|
2711
|
+
function _lowerFlatOptionInner(ctx) {
|
|
2712
|
+
_debugLog('[_lowerFlatOption()] args', { ctx });
|
|
2713
|
+
return _lowerFlatVariant(lowerMetas)(ctx);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
function _lowerFlatResult(lowerMetas) {
|
|
2718
|
+
return function _lowerFlatResultInner(ctx) {
|
|
2719
|
+
_debugLog('[_lowerFlatResult()] args', { lowerMetas });
|
|
2720
|
+
return _lowerFlatVariant(lowerMetas)(ctx);
|
|
2721
|
+
};
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
function _lowerFlatOwn(size, memory, vals, storagePtr, storageLen) {
|
|
2725
|
+
_debugLog('[_lowerFlatOwn()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2726
|
+
throw new Error('flat lower for owned resources not yet implemented!');
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
const STREAMS = new RepTable({ target: 'global stream map' });
|
|
2730
|
+
const ASYNC_STATE = new Map();
|
|
2731
|
+
|
|
2732
|
+
function getOrCreateAsyncState(componentIdx, init) {
|
|
2733
|
+
if (!ASYNC_STATE.has(componentIdx)) {
|
|
2734
|
+
const newState = new ComponentAsyncState({ componentIdx });
|
|
2735
|
+
ASYNC_STATE.set(componentIdx, newState);
|
|
2451
2736
|
}
|
|
2737
|
+
return ASYNC_STATE.get(componentIdx);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
class ComponentAsyncState {
|
|
2741
|
+
static EVENT_HANDLER_EVENTS = [ 'backpressure-change' ];
|
|
2742
|
+
|
|
2743
|
+
#componentIdx;
|
|
2744
|
+
#callingAsyncImport = false;
|
|
2745
|
+
#syncImportWait = promiseWithResolvers();
|
|
2746
|
+
#locked = false;
|
|
2747
|
+
#parkedTasks = new Map();
|
|
2748
|
+
#suspendedTasksByTaskID = new Map();
|
|
2749
|
+
#suspendedTaskIDs = [];
|
|
2750
|
+
#errored = null;
|
|
2751
|
+
|
|
2752
|
+
#backpressure = 0;
|
|
2753
|
+
#backpressureWaiters = 0n;
|
|
2754
|
+
|
|
2755
|
+
#handlerMap = new Map();
|
|
2756
|
+
#nextHandlerID = 0n;
|
|
2757
|
+
|
|
2758
|
+
#tickLoop = null;
|
|
2759
|
+
#tickLoopInterval = null;
|
|
2760
|
+
|
|
2761
|
+
#onExclusiveReleaseHandlers = [];
|
|
2762
|
+
|
|
2763
|
+
mayLeave = true;
|
|
2452
2764
|
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2765
|
+
handles;
|
|
2766
|
+
subtasks;
|
|
2767
|
+
|
|
2768
|
+
constructor(args) {
|
|
2769
|
+
this.#componentIdx = args.componentIdx;
|
|
2770
|
+
this.handles = new RepTable({ target: `component [${this.#componentIdx}] handles (waitable objects)` });
|
|
2771
|
+
this.subtasks = new RepTable({ target: `component [${this.#componentIdx}] subtasks` });
|
|
2772
|
+
};
|
|
2773
|
+
|
|
2774
|
+
componentIdx() { return this.#componentIdx; }
|
|
2775
|
+
|
|
2776
|
+
errored() { return this.#errored !== null; }
|
|
2777
|
+
setErrored(err) {
|
|
2778
|
+
_debugLog('[ComponentAsyncState#setErrored()] component errored', { err, componentIdx: this.#componentIdx });
|
|
2779
|
+
if (this.#errored) { return; }
|
|
2780
|
+
if (!err) {
|
|
2781
|
+
err = new Error('error elswehere (see other component instance error)')
|
|
2782
|
+
err.componentIdx = this.#componentIdx;
|
|
2457
2783
|
}
|
|
2458
|
-
|
|
2459
|
-
new DataView(memory.buffer).setUint16(storagePtr, vals[0], true);
|
|
2460
|
-
return 2;
|
|
2784
|
+
this.#errored = err;
|
|
2461
2785
|
}
|
|
2462
2786
|
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
if (rem !== 0) { ctx.storagePtr += (4 - rem); }
|
|
2472
|
-
|
|
2473
|
-
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2474
|
-
|
|
2475
|
-
return 4;
|
|
2787
|
+
callingSyncImport(val) {
|
|
2788
|
+
if (val === undefined) { return this.#callingAsyncImport; }
|
|
2789
|
+
if (typeof val !== 'boolean') { throw new TypeError('invalid setting for async import'); }
|
|
2790
|
+
const prev = this.#callingAsyncImport;
|
|
2791
|
+
this.#callingAsyncImport = val;
|
|
2792
|
+
if (prev === true && this.#callingAsyncImport === false) {
|
|
2793
|
+
this.#notifySyncImportEnd();
|
|
2794
|
+
}
|
|
2476
2795
|
}
|
|
2477
2796
|
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
new DataView(memory.buffer).setBigUint64(storagePtr, vals[0], true);
|
|
2483
|
-
return 8;
|
|
2797
|
+
#notifySyncImportEnd() {
|
|
2798
|
+
const existing = this.#syncImportWait;
|
|
2799
|
+
this.#syncImportWait = promiseWithResolvers();
|
|
2800
|
+
existing.resolve();
|
|
2484
2801
|
}
|
|
2485
2802
|
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2490
|
-
|
|
2491
|
-
const s = vals[0];
|
|
2492
|
-
const { ptr, len, codepoints } = _utf8AllocateAndEncode(vals[0], realloc, memory);
|
|
2493
|
-
|
|
2494
|
-
const view = new DataView(memory.buffer);
|
|
2495
|
-
view.setUint32(storagePtr, ptr, true);
|
|
2496
|
-
view.setUint32(storagePtr + 4, codepoints, true);
|
|
2497
|
-
|
|
2498
|
-
return len;
|
|
2803
|
+
async waitForSyncImportCallEnd() {
|
|
2804
|
+
await this.#syncImportWait.promise;
|
|
2499
2805
|
}
|
|
2500
2806
|
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
if (storageLen !== undefined && size !== undefined && size > storageLen) {
|
|
2516
|
-
throw new Error('not enough storage remaining for record flat lower');
|
|
2517
|
-
}
|
|
2518
|
-
const data = new Uint8Array(memory.buffer, start, size);
|
|
2519
|
-
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2520
|
-
return data.byteLength;
|
|
2807
|
+
setBackpressure(v) {
|
|
2808
|
+
this.#backpressure = v;
|
|
2809
|
+
return this.#backpressure
|
|
2810
|
+
}
|
|
2811
|
+
getBackpressure() { return this.#backpressure; }
|
|
2812
|
+
|
|
2813
|
+
incrementBackpressure() {
|
|
2814
|
+
const current = this.#backpressure;
|
|
2815
|
+
if (current < 0 || current > 2**16) {
|
|
2816
|
+
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2817
|
+
}
|
|
2818
|
+
const newValue = this.getBackpressure() + 1;
|
|
2819
|
+
if (newValue >= 2**16) {
|
|
2820
|
+
throw new Error(`invalid new backpressure value [${newValue}], overflow`);
|
|
2521
2821
|
}
|
|
2822
|
+
return this.setBackpressure(newValue);
|
|
2522
2823
|
}
|
|
2523
2824
|
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
const disc = lowerMetas.findIndex(m => m[0] === tag);
|
|
2533
|
-
if (disc === -1) {
|
|
2534
|
-
throw new Error(`invalid variant tag/discriminant [${tag}] (valid tags: ${variantMetas.map(m => m[0])})`);
|
|
2535
|
-
}
|
|
2536
|
-
|
|
2537
|
-
const [ _tag, lowerFn, size32, align32, payloadOffset32 ] = lowerMetas[disc];
|
|
2538
|
-
|
|
2539
|
-
const originalPtr = ctx.resultPtr;
|
|
2540
|
-
ctx.vals = [disc];
|
|
2541
|
-
let discLowerRes;
|
|
2542
|
-
if (lowerMetas.length < 256) {
|
|
2543
|
-
discLowerRes = _lowerFlatU8(ctx);
|
|
2544
|
-
} else if (lowerMetas.length >= 256 && lowerMetas.length < 65536) {
|
|
2545
|
-
discLowerRes = _lowerFlatU16(ctx);
|
|
2546
|
-
} else if (lowerMetas.length >= 65536 && lowerMetas.length < 4_294_967_296) {
|
|
2547
|
-
discLowerRes = _lowerFlatU32(ctx);
|
|
2548
|
-
} else {
|
|
2549
|
-
throw new Error('unsupported number of cases [' + lowerMetas.legnth + ']');
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
ctx.resultPtr = originalPtr + payloadOffset32;
|
|
2553
|
-
|
|
2554
|
-
const payloadBytesWritten = lowerFn({
|
|
2555
|
-
memory,
|
|
2556
|
-
realloc,
|
|
2557
|
-
vals: [val],
|
|
2558
|
-
storagePtr,
|
|
2559
|
-
storageLen,
|
|
2560
|
-
componentIdx,
|
|
2561
|
-
});
|
|
2562
|
-
let bytesWritten = payloadOffset + payloadBytesWritten;
|
|
2563
|
-
|
|
2564
|
-
const rem = ctx.storagePtr % align32;
|
|
2565
|
-
if (rem !== 0) {
|
|
2566
|
-
const pad = align32 - rem;
|
|
2567
|
-
ctx.storagePtr += pad;
|
|
2568
|
-
bytesWritten += pad;
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
return bytesWritten;
|
|
2825
|
+
decrementBackpressure() {
|
|
2826
|
+
const current = this.#backpressure;
|
|
2827
|
+
if (current < 0 || current > 2**16) {
|
|
2828
|
+
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2829
|
+
}
|
|
2830
|
+
const newValue = Math.max(0, current - 1);
|
|
2831
|
+
if (newValue < 0) {
|
|
2832
|
+
throw new Error(`invalid new backpressure value [${newValue}], underflow`);
|
|
2572
2833
|
}
|
|
2834
|
+
return this.setBackpressure(newValue);
|
|
2573
2835
|
}
|
|
2836
|
+
hasBackpressure() { return this.#backpressure > 0; }
|
|
2574
2837
|
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
ctx.params = ctx.params.slice(2);
|
|
2586
|
-
|
|
2587
|
-
if (ctx.useDirectParams) {
|
|
2588
|
-
const list = ctx.vals[0];
|
|
2589
|
-
if (!list) { throw new Error("missing direct param value"); }
|
|
2590
|
-
|
|
2591
|
-
const elemLowerCtx = { storagePtr, memory: ctx.memory };
|
|
2592
|
-
for (let idx = 0; idx < list.length; idx++) {
|
|
2593
|
-
elemLowerCtx.vals = list.slice(idx, idx+1);
|
|
2594
|
-
elemLowerCtx.storagePtr += elemLowerFn(elemLowerCtx);
|
|
2838
|
+
waitForBackpressure() {
|
|
2839
|
+
let backpressureCleared = false;
|
|
2840
|
+
const cstate = this;
|
|
2841
|
+
cstate.addBackpressureWaiter();
|
|
2842
|
+
const handlerID = this.registerHandler({
|
|
2843
|
+
event: 'backpressure-change',
|
|
2844
|
+
fn: (bp) => {
|
|
2845
|
+
if (bp === 0) {
|
|
2846
|
+
cstate.removeHandler(handlerID);
|
|
2847
|
+
backpressureCleared = true;
|
|
2595
2848
|
}
|
|
2596
|
-
|
|
2597
|
-
const bytesLowered = elemLowerCtx.storagePtr - ctx.storagePtr;
|
|
2598
|
-
ctx.storagePtr = elemLowerCtx.storagePtr;
|
|
2599
|
-
return bytesLowered;
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
|
-
if (ctx.vals.length !== 2) {
|
|
2603
|
-
throw new Error('indirect parameter loading must have a pointer and length as vals');
|
|
2604
|
-
}
|
|
2605
|
-
let [valStartPtr, valLen] = ctx.vals;
|
|
2606
|
-
const totalSizeBytes = valLen * size;
|
|
2607
|
-
if (ctx.storageLen !== undefined && totalSizeBytes > ctx.storageLen) {
|
|
2608
|
-
throw new Error('not enough storage remaining for list flat lower');
|
|
2609
2849
|
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2850
|
+
});
|
|
2851
|
+
return new Promise((resolve) => {
|
|
2852
|
+
const interval = setInterval(() => {
|
|
2853
|
+
if (backpressureCleared) { return; }
|
|
2854
|
+
clearInterval(interval);
|
|
2855
|
+
cstate.removeBackpressureWaiter();
|
|
2856
|
+
resolve(null);
|
|
2857
|
+
}, 0);
|
|
2858
|
+
});
|
|
2616
2859
|
}
|
|
2617
2860
|
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
if (
|
|
2622
|
-
|
|
2861
|
+
registerHandler(args) {
|
|
2862
|
+
const { event, fn } = args;
|
|
2863
|
+
if (!event) { throw new Error("missing handler event"); }
|
|
2864
|
+
if (!fn) { throw new Error("missing handler fn"); }
|
|
2865
|
+
|
|
2866
|
+
if (!ComponentAsyncState.EVENT_HANDLER_EVENTS.includes(event)) {
|
|
2867
|
+
throw new Error(`unrecognized event handler [${event}]`);
|
|
2623
2868
|
}
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2869
|
+
|
|
2870
|
+
const handlerID = this.#nextHandlerID++;
|
|
2871
|
+
let handlers = this.#handlerMap.get(event);
|
|
2872
|
+
if (!handlers) {
|
|
2873
|
+
handlers = [];
|
|
2874
|
+
this.#handlerMap.set(event, handlers)
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2877
|
+
handlers.push({ id: handlerID, fn, event });
|
|
2878
|
+
return handlerID;
|
|
2627
2879
|
}
|
|
2628
2880
|
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2881
|
+
removeHandler(args) {
|
|
2882
|
+
const { event, handlerID } = args;
|
|
2883
|
+
const registeredHandlers = this.#handlerMap.get(event);
|
|
2884
|
+
if (!registeredHandlers) { return; }
|
|
2885
|
+
const found = registeredHandlers.find(h => h.id === handlerID);
|
|
2886
|
+
if (!found) { return; }
|
|
2887
|
+
this.#handlerMap.set(event, this.#handlerMap.get(event).filter(h => h.id !== handlerID));
|
|
2634
2888
|
}
|
|
2635
2889
|
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2890
|
+
getBackpressureWaiters() { return this.#backpressureWaiters; }
|
|
2891
|
+
addBackpressureWaiter() { this.#backpressureWaiters++; }
|
|
2892
|
+
removeBackpressureWaiter() {
|
|
2893
|
+
this.#backpressureWaiters--;
|
|
2894
|
+
if (this.#backpressureWaiters < 0) {
|
|
2895
|
+
throw new Error("unexepctedly negative number of backpressure waiters");
|
|
2641
2896
|
}
|
|
2642
|
-
const data = new Uint8Array(memory.buffer, start, size);
|
|
2643
|
-
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2644
|
-
return data.byteLength;
|
|
2645
2897
|
}
|
|
2646
2898
|
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2899
|
+
isExclusivelyLocked() { return this.#locked === true; }
|
|
2900
|
+
setLocked(locked) {
|
|
2901
|
+
this.#locked = locked;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
// TODO(fix): we might want to check for pre-locked status here, we should be deterministically
|
|
2905
|
+
// going from locked -> unlocked and vice versa
|
|
2906
|
+
exclusiveLock() {
|
|
2907
|
+
_debugLog('[ComponentAsyncState#exclusiveLock()]', {
|
|
2908
|
+
locked: this.#locked,
|
|
2909
|
+
componentIdx: this.#componentIdx,
|
|
2910
|
+
});
|
|
2911
|
+
this.setLocked(true);
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
exclusiveRelease() {
|
|
2915
|
+
_debugLog('[ComponentAsyncState#exclusiveRelease()] args', {
|
|
2916
|
+
locked: this.#locked,
|
|
2917
|
+
componentIdx: this.#componentIdx,
|
|
2918
|
+
});
|
|
2919
|
+
this.setLocked(false);
|
|
2920
|
+
|
|
2921
|
+
this.#onExclusiveReleaseHandlers = this.#onExclusiveReleaseHandlers.filter(v => !!v);
|
|
2922
|
+
for (const [idx, f] of this.#onExclusiveReleaseHandlers.entries()) {
|
|
2923
|
+
try {
|
|
2924
|
+
this.#onExclusiveReleaseHandlers[idx] = null;
|
|
2925
|
+
f();
|
|
2926
|
+
} catch (err) {
|
|
2927
|
+
_debugLog("error while executing handler for next exclusive release", err);
|
|
2928
|
+
throw err;
|
|
2929
|
+
}
|
|
2651
2930
|
}
|
|
2652
2931
|
}
|
|
2653
2932
|
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
return _lowerFlatVariant(lowerMetas)(ctx);
|
|
2658
|
-
};
|
|
2933
|
+
onNextExclusiveRelease(fn) {
|
|
2934
|
+
_debugLog('[ComponentAsyncState#()onNextExclusiveRelease] registering');
|
|
2935
|
+
this.#onExclusiveReleaseHandlers.push(fn);
|
|
2659
2936
|
}
|
|
2660
2937
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
throw new Error('flat lower for owned resources not yet implemented!');
|
|
2938
|
+
#getSuspendedTaskMeta(taskID) {
|
|
2939
|
+
return this.#suspendedTasksByTaskID.get(taskID);
|
|
2664
2940
|
}
|
|
2665
2941
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2942
|
+
#removeSuspendedTaskMeta(taskID) {
|
|
2943
|
+
_debugLog('[ComponentAsyncState#removeSuspendedTaskMeta()] removing suspended task', { taskID });
|
|
2944
|
+
const idx = this.#suspendedTaskIDs.findIndex(t => t === taskID);
|
|
2945
|
+
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
2946
|
+
this.#suspendedTaskIDs[idx] = null;
|
|
2947
|
+
this.#suspendedTasksByTaskID.delete(taskID);
|
|
2948
|
+
return meta;
|
|
2949
|
+
}
|
|
2668
2950
|
|
|
2669
|
-
|
|
2670
|
-
if (!
|
|
2671
|
-
|
|
2672
|
-
|
|
2951
|
+
#addSuspendedTaskMeta(meta) {
|
|
2952
|
+
if (!meta) { throw new Error('missing task meta'); }
|
|
2953
|
+
const taskID = meta.taskID;
|
|
2954
|
+
this.#suspendedTasksByTaskID.set(taskID, meta);
|
|
2955
|
+
this.#suspendedTaskIDs.push(taskID);
|
|
2956
|
+
if (this.#suspendedTasksByTaskID.size < this.#suspendedTaskIDs.length - 10) {
|
|
2957
|
+
this.#suspendedTaskIDs = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
2673
2958
|
}
|
|
2674
|
-
return ASYNC_STATE.get(componentIdx);
|
|
2675
2959
|
}
|
|
2676
2960
|
|
|
2677
|
-
|
|
2678
|
-
|
|
2961
|
+
// TODO(threads): readyFn is normally on the thread
|
|
2962
|
+
suspendTask(args) {
|
|
2963
|
+
const { task, readyFn } = args;
|
|
2964
|
+
const taskID = task.id();
|
|
2965
|
+
_debugLog('[ComponentAsyncState#suspendTask()]', {
|
|
2966
|
+
taskID,
|
|
2967
|
+
componentIdx: this.#componentIdx,
|
|
2968
|
+
taskEntryFnName: task.entryFnName(),
|
|
2969
|
+
subtask: task.getParentSubtask(),
|
|
2970
|
+
});
|
|
2679
2971
|
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
#locked = false;
|
|
2684
|
-
#parkedTasks = new Map();
|
|
2685
|
-
#suspendedTasksByTaskID = new Map();
|
|
2686
|
-
#suspendedTaskIDs = [];
|
|
2687
|
-
#errored = null;
|
|
2972
|
+
if (this.#getSuspendedTaskMeta(taskID)) {
|
|
2973
|
+
throw new Error(`task [${taskID}] already suspended`);
|
|
2974
|
+
}
|
|
2688
2975
|
|
|
2689
|
-
|
|
2690
|
-
|
|
2976
|
+
const { promise, resolve, reject } = promiseWithResolvers();
|
|
2977
|
+
this.#addSuspendedTaskMeta({
|
|
2978
|
+
task,
|
|
2979
|
+
taskID,
|
|
2980
|
+
readyFn,
|
|
2981
|
+
resume: () => {
|
|
2982
|
+
_debugLog('[ComponentAsyncState#suspendTask()] resuming suspended task', { taskID });
|
|
2983
|
+
// TODO(threads): it's thread cancellation we should be checking for below, not task
|
|
2984
|
+
resolve(!task.isCancelled());
|
|
2985
|
+
},
|
|
2986
|
+
});
|
|
2691
2987
|
|
|
2692
|
-
|
|
2693
|
-
#nextHandlerID = 0n;
|
|
2988
|
+
this.runTickLoop();
|
|
2694
2989
|
|
|
2695
|
-
|
|
2696
|
-
|
|
2990
|
+
return promise;
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
resumeTaskByID(taskID) {
|
|
2994
|
+
const meta = this.#removeSuspendedTaskMeta(taskID);
|
|
2995
|
+
if (!meta) { return; }
|
|
2996
|
+
if (meta.taskID !== taskID) { throw new Error('task ID does not match'); }
|
|
2997
|
+
meta.resume();
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
async runTickLoop() {
|
|
3001
|
+
if (this.#tickLoop !== null) { return; }
|
|
3002
|
+
this.#tickLoop = 1;
|
|
3003
|
+
setTimeout(async () => {
|
|
3004
|
+
let done = this.tick();
|
|
3005
|
+
while (!done) {
|
|
3006
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
3007
|
+
done = this.tick();
|
|
3008
|
+
}
|
|
3009
|
+
this.#tickLoop = null;
|
|
3010
|
+
}, 10);
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
tick() {
|
|
3014
|
+
// _debugLog('[ComponentAsyncState#tick()]', { suspendedTaskIDs: this.#suspendedTaskIDs });
|
|
2697
3015
|
|
|
2698
|
-
|
|
3016
|
+
const resumableTasks = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
3017
|
+
for (const taskID of resumableTasks) {
|
|
3018
|
+
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
3019
|
+
if (!meta || !meta.readyFn) {
|
|
3020
|
+
throw new Error(`missing/invalid task despite ID [${taskID}] being present`);
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
// If the task failed via any means, allow the task to resume because
|
|
3024
|
+
// it's been cancelled -- the callback should immediately exit as well
|
|
3025
|
+
if (meta.task.isRejected()) {
|
|
3026
|
+
_debugLog('[ComponentAsyncState#suspendTask()] detected task rejection, leaving early', { meta });
|
|
3027
|
+
this.resumeTaskByID(taskID);
|
|
3028
|
+
return;
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
const isReady = meta.readyFn();
|
|
3032
|
+
if (!isReady) { continue; }
|
|
3033
|
+
|
|
3034
|
+
this.resumeTaskByID(taskID);
|
|
3035
|
+
}
|
|
2699
3036
|
|
|
2700
|
-
|
|
3037
|
+
return this.#suspendedTaskIDs.filter(t => t !== null).length === 0;
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
addStreamEndToTable(args) {
|
|
3041
|
+
_debugLog('[ComponentAsyncState#addStreamEnd()] args', args);
|
|
3042
|
+
const { tableIdx, streamEnd } = args;
|
|
3043
|
+
if (typeof streamEnd === 'number') { throw new Error("INSERTING BAD STREAMEND"); }
|
|
2701
3044
|
|
|
2702
|
-
|
|
2703
|
-
|
|
3045
|
+
let { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3046
|
+
if (componentIdx === undefined || !table) {
|
|
3047
|
+
throw new Error(`invalid global stream table state for table [${tableIdx}]`);
|
|
3048
|
+
}
|
|
2704
3049
|
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
this.subtasks = new RepTable({ target: `component [${this.#componentIdx}] subtasks` });
|
|
2709
|
-
};
|
|
3050
|
+
const handle = table.insert(streamEnd);
|
|
3051
|
+
streamEnd.setHandle(handle);
|
|
3052
|
+
streamEnd.setStreamTableIdx(tableIdx);
|
|
2710
3053
|
|
|
2711
|
-
|
|
3054
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3055
|
+
const waitableIdx = cstate.handles.insert(streamEnd);
|
|
3056
|
+
streamEnd.setWaitableIdx(waitableIdx);
|
|
2712
3057
|
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
}
|
|
2721
|
-
this.#errored = err;
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
callingSyncImport(val) {
|
|
2725
|
-
if (val === undefined) { return this.#callingAsyncImport; }
|
|
2726
|
-
if (typeof val !== 'boolean') { throw new TypeError('invalid setting for async import'); }
|
|
2727
|
-
const prev = this.#callingAsyncImport;
|
|
2728
|
-
this.#callingAsyncImport = val;
|
|
2729
|
-
if (prev === true && this.#callingAsyncImport === false) {
|
|
2730
|
-
this.#notifySyncImportEnd();
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
|
|
2734
|
-
#notifySyncImportEnd() {
|
|
2735
|
-
const existing = this.#syncImportWait;
|
|
2736
|
-
this.#syncImportWait = promiseWithResolvers();
|
|
2737
|
-
existing.resolve();
|
|
2738
|
-
}
|
|
3058
|
+
_debugLog('[ComponentAsyncState#addStreamEnd()] added stream end', {
|
|
3059
|
+
tableIdx,
|
|
3060
|
+
table,
|
|
3061
|
+
handle,
|
|
3062
|
+
streamEnd,
|
|
3063
|
+
destComponentIdx: componentIdx,
|
|
3064
|
+
});
|
|
2739
3065
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
3066
|
+
return { handle, waitableIdx };
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
createWaitable(args) {
|
|
3070
|
+
return new Waitable({ target: args?.target, });
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
createStream(args) {
|
|
3074
|
+
_debugLog('[ComponentAsyncState#createStream()] args', args);
|
|
3075
|
+
const { tableIdx, elemMeta } = args;
|
|
3076
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while adding stream"); }
|
|
3077
|
+
if (elemMeta === undefined) { throw new Error("missing element metadata while adding stream"); }
|
|
2743
3078
|
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
3079
|
+
const { table: localStreamTable, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3080
|
+
if (!localStreamTable) {
|
|
3081
|
+
throw new Error(`missing global stream table lookup for table [${tableIdx}] while creating stream`);
|
|
2747
3082
|
}
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
incrementBackpressure() {
|
|
2751
|
-
const current = this.#backpressure;
|
|
2752
|
-
if (current < 0 || current > 2**16) {
|
|
2753
|
-
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2754
|
-
}
|
|
2755
|
-
const newValue = this.getBackpressure() + 1;
|
|
2756
|
-
if (newValue >= 2**16) {
|
|
2757
|
-
throw new Error(`invalid new backpressure value [${newValue}], overflow`);
|
|
2758
|
-
}
|
|
2759
|
-
return this.setBackpressure(newValue);
|
|
3083
|
+
if (componentIdx !== this.#componentIdx) {
|
|
3084
|
+
throw new Error('component idx mismatch while creating stream');
|
|
2760
3085
|
}
|
|
2761
3086
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
if (current < 0 || current > 2**16) {
|
|
2765
|
-
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2766
|
-
}
|
|
2767
|
-
const newValue = Math.max(0, current - 1);
|
|
2768
|
-
if (newValue < 0) {
|
|
2769
|
-
throw new Error(`invalid new backpressure value [${newValue}], underflow`);
|
|
2770
|
-
}
|
|
2771
|
-
return this.setBackpressure(newValue);
|
|
2772
|
-
}
|
|
2773
|
-
hasBackpressure() { return this.#backpressure > 0; }
|
|
3087
|
+
const readWaitable = this.createWaitable();
|
|
3088
|
+
const writeWaitable = this.createWaitable();
|
|
2774
3089
|
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
3090
|
+
const stream = new InternalStream({
|
|
3091
|
+
tableIdx,
|
|
3092
|
+
componentIdx: this.#componentIdx,
|
|
3093
|
+
elemMeta,
|
|
3094
|
+
readWaitable,
|
|
3095
|
+
writeWaitable,
|
|
3096
|
+
});
|
|
3097
|
+
stream.setGlobalStreamMapRep(STREAMS.insert(stream));
|
|
3098
|
+
|
|
3099
|
+
const writeEnd = stream.writeEnd();
|
|
3100
|
+
writeEnd.setWaitableIdx(this.handles.insert(writeEnd));
|
|
3101
|
+
writeEnd.setHandle(localStreamTable.insert(writeEnd));
|
|
3102
|
+
if (writeEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3103
|
+
|
|
3104
|
+
const writeEndWaitableIdx = writeEnd.waitableIdx();
|
|
3105
|
+
const writeEndHandle = writeEnd.handle();
|
|
3106
|
+
writeWaitable.setTarget(`waitable for stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3107
|
+
writeEnd.setTarget(`stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3108
|
+
|
|
3109
|
+
const readEnd = stream.readEnd();
|
|
3110
|
+
readEnd.setWaitableIdx(this.handles.insert(readEnd));
|
|
3111
|
+
readEnd.setHandle(localStreamTable.insert(readEnd));
|
|
3112
|
+
if (readEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3113
|
+
|
|
3114
|
+
const readEndWaitableIdx = readEnd.waitableIdx();
|
|
3115
|
+
const readEndHandle = readEnd.handle();
|
|
3116
|
+
readWaitable.setTarget(`waitable for read end (waitable [${readEndWaitableIdx}])`);
|
|
3117
|
+
readEnd.setTarget(`stream read end (waitable [${readEndWaitableIdx}])`);
|
|
3118
|
+
|
|
3119
|
+
return {
|
|
3120
|
+
writeEndWaitableIdx,
|
|
3121
|
+
writeEndHandle,
|
|
3122
|
+
readEndWaitableIdx,
|
|
3123
|
+
readEndHandle,
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
getStreamEnd(args) {
|
|
3128
|
+
_debugLog('[ComponentAsyncState#getStreamEnd()] args', args);
|
|
3129
|
+
const { tableIdx, streamEndHandle, streamEndWaitableIdx } = args;
|
|
3130
|
+
if (tableIdx === undefined) { throw new Error('missing table idx while getting stream end'); }
|
|
2797
3131
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
if (!event) { throw new Error("missing handler event"); }
|
|
2801
|
-
if (!fn) { throw new Error("missing handler fn"); }
|
|
2802
|
-
|
|
2803
|
-
if (!ComponentAsyncState.EVENT_HANDLER_EVENTS.includes(event)) {
|
|
2804
|
-
throw new Error(`unrecognized event handler [${event}]`);
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
|
-
const handlerID = this.#nextHandlerID++;
|
|
2808
|
-
let handlers = this.#handlerMap.get(event);
|
|
2809
|
-
if (!handlers) {
|
|
2810
|
-
handlers = [];
|
|
2811
|
-
this.#handlerMap.set(event, handlers)
|
|
2812
|
-
}
|
|
2813
|
-
|
|
2814
|
-
handlers.push({ id: handlerID, fn, event });
|
|
2815
|
-
return handlerID;
|
|
2816
|
-
}
|
|
3132
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3133
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2817
3134
|
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
3135
|
+
let streamEnd;
|
|
3136
|
+
if (streamEndWaitableIdx !== undefined) {
|
|
3137
|
+
streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3138
|
+
} else if (streamEndHandle !== undefined) {
|
|
3139
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while getting stream end`); }
|
|
3140
|
+
streamEnd = table.get(streamEndHandle);
|
|
3141
|
+
} else {
|
|
3142
|
+
throw new TypeError("must specify either waitable idx or handle to retrieve stream");
|
|
2825
3143
|
}
|
|
2826
3144
|
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
removeBackpressureWaiter() {
|
|
2830
|
-
this.#backpressureWaiters--;
|
|
2831
|
-
if (this.#backpressureWaiters < 0) {
|
|
2832
|
-
throw new Error("unexepctedly negative number of backpressure waiters");
|
|
2833
|
-
}
|
|
3145
|
+
if (!streamEnd) {
|
|
3146
|
+
throw new Error(`missing stream end (tableIdx [${tableIdx}], handle [${streamEndHandle}], waitableIdx [${streamEndWaitableIdx}])`);
|
|
2834
3147
|
}
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
setLocked(locked) {
|
|
2838
|
-
this.#locked = locked;
|
|
3148
|
+
if (tableIdx && streamEnd.streamTableIdx() !== tableIdx) {
|
|
3149
|
+
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
2839
3150
|
}
|
|
2840
3151
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
}
|
|
3152
|
+
return streamEnd;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
deleteStreamEnd(args) {
|
|
3156
|
+
_debugLog('[ComponentAsyncState#deleteStreamEnd()] args', args);
|
|
3157
|
+
const { tableIdx, streamEndWaitableIdx } = args;
|
|
3158
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3159
|
+
if (streamEndWaitableIdx === undefined) { throw new Error("missing stream idx while removing stream end"); }
|
|
2850
3160
|
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
locked: this.#locked,
|
|
2854
|
-
componentIdx: this.#componentIdx,
|
|
2855
|
-
});
|
|
2856
|
-
this.setLocked(false);
|
|
2857
|
-
|
|
2858
|
-
this.#onExclusiveReleaseHandlers = this.#onExclusiveReleaseHandlers.filter(v => !!v);
|
|
2859
|
-
for (const [idx, f] of this.#onExclusiveReleaseHandlers.entries()) {
|
|
2860
|
-
try {
|
|
2861
|
-
this.#onExclusiveReleaseHandlers[idx] = null;
|
|
2862
|
-
f();
|
|
2863
|
-
} catch (err) {
|
|
2864
|
-
_debugLog("error while executing handler for next exclusive release", err);
|
|
2865
|
-
throw err;
|
|
2866
|
-
}
|
|
2867
|
-
}
|
|
2868
|
-
}
|
|
3161
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3162
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2869
3163
|
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
3164
|
+
const streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3165
|
+
if (!streamEnd) {
|
|
3166
|
+
throw new Error(`missing stream end [${streamEndWaitableIdx}] in component handles while deleting stream`);
|
|
2873
3167
|
}
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
return this.#suspendedTasksByTaskID.get(taskID);
|
|
3168
|
+
if (streamEnd.streamTableIdx() !== tableIdx) {
|
|
3169
|
+
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
2877
3170
|
}
|
|
2878
3171
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
2883
|
-
this.#suspendedTaskIDs[idx] = null;
|
|
2884
|
-
this.#suspendedTasksByTaskID.delete(taskID);
|
|
2885
|
-
return meta;
|
|
3172
|
+
let removed = cstate.handles.remove(streamEnd.waitableIdx());
|
|
3173
|
+
if (!removed) {
|
|
3174
|
+
throw new Error(`failed to remove stream end [${streamEndWaitableIdx}] waitable obj in component [${componentIdx}]`);
|
|
2886
3175
|
}
|
|
2887
3176
|
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
this.#suspendedTasksByTaskID.set(taskID, meta);
|
|
2892
|
-
this.#suspendedTaskIDs.push(taskID);
|
|
2893
|
-
if (this.#suspendedTasksByTaskID.size < this.#suspendedTaskIDs.length - 10) {
|
|
2894
|
-
this.#suspendedTaskIDs = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
2895
|
-
}
|
|
3177
|
+
removed = table.remove(streamEnd.handle());
|
|
3178
|
+
if (!removed) {
|
|
3179
|
+
throw new Error(`failed to remove stream end with handle [${streamEnd.handle()}] from stream table [${tableIdx}] in component [${componentIdx}]`);
|
|
2896
3180
|
}
|
|
2897
3181
|
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
taskID,
|
|
2904
|
-
componentIdx: this.#componentIdx,
|
|
2905
|
-
taskEntryFnName: task.entryFnName(),
|
|
2906
|
-
subtask: task.getParentSubtask(),
|
|
2907
|
-
});
|
|
2908
|
-
|
|
2909
|
-
if (this.#getSuspendedTaskMeta(taskID)) {
|
|
2910
|
-
throw new Error(`task [${taskID}] already suspended`);
|
|
2911
|
-
}
|
|
2912
|
-
|
|
2913
|
-
const { promise, resolve, reject } = promiseWithResolvers();
|
|
2914
|
-
this.#addSuspendedTaskMeta({
|
|
2915
|
-
task,
|
|
2916
|
-
taskID,
|
|
2917
|
-
readyFn,
|
|
2918
|
-
resume: () => {
|
|
2919
|
-
_debugLog('[ComponentAsyncState#suspendTask()] resuming suspended task', { taskID });
|
|
2920
|
-
// TODO(threads): it's thread cancellation we should be checking for below, not task
|
|
2921
|
-
resolve(!task.isCancelled());
|
|
2922
|
-
},
|
|
2923
|
-
});
|
|
2924
|
-
|
|
2925
|
-
this.runTickLoop();
|
|
2926
|
-
|
|
2927
|
-
return promise;
|
|
2928
|
-
}
|
|
3182
|
+
return streamEnd;
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
removeStreamEndFromTable(args) {
|
|
3186
|
+
_debugLog('[ComponentAsyncState#removeStreamEndFromTable()] args', args);
|
|
2929
3187
|
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
meta.resume();
|
|
3188
|
+
const { tableIdx, streamWaitableIdx } = args;
|
|
3189
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3190
|
+
if (streamWaitableIdx === undefined) {
|
|
3191
|
+
throw new Error("missing stream end waitable idx while removing stream end");
|
|
2935
3192
|
}
|
|
2936
3193
|
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
this.#tickLoop = 1;
|
|
2940
|
-
setTimeout(async () => {
|
|
2941
|
-
let done = this.tick();
|
|
2942
|
-
while (!done) {
|
|
2943
|
-
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
2944
|
-
done = this.tick();
|
|
2945
|
-
}
|
|
2946
|
-
this.#tickLoop = null;
|
|
2947
|
-
}, 10);
|
|
2948
|
-
}
|
|
3194
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3195
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while removing stream end`); }
|
|
2949
3196
|
|
|
2950
|
-
|
|
2951
|
-
// _debugLog('[ComponentAsyncState#tick()]', { suspendedTaskIDs: this.#suspendedTaskIDs });
|
|
2952
|
-
|
|
2953
|
-
const resumableTasks = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
2954
|
-
for (const taskID of resumableTasks) {
|
|
2955
|
-
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
2956
|
-
if (!meta || !meta.readyFn) {
|
|
2957
|
-
throw new Error(`missing/invalid task despite ID [${taskID}] being present`);
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
|
-
// If the task failed via any means, allow the task to resume because
|
|
2961
|
-
// it's been cancelled -- the callback should immediately exit as well
|
|
2962
|
-
if (meta.task.isRejected()) {
|
|
2963
|
-
_debugLog('[ComponentAsyncState#suspendTask()] detected task rejection, leaving early', { meta });
|
|
2964
|
-
this.resumeTaskByID(taskID);
|
|
2965
|
-
return;
|
|
2966
|
-
}
|
|
2967
|
-
|
|
2968
|
-
const isReady = meta.readyFn();
|
|
2969
|
-
if (!isReady) { continue; }
|
|
2970
|
-
|
|
2971
|
-
this.resumeTaskByID(taskID);
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
return this.#suspendedTaskIDs.filter(t => t !== null).length === 0;
|
|
2975
|
-
}
|
|
3197
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2976
3198
|
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
if (typeof streamEnd === 'number') { throw new Error("INSERTING BAD STREAMEND"); }
|
|
2981
|
-
|
|
2982
|
-
let { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
2983
|
-
if (componentIdx === undefined || !table) {
|
|
2984
|
-
throw new Error(`invalid global stream table state for table [${tableIdx}]`);
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
const handle = table.insert(streamEnd);
|
|
2988
|
-
streamEnd.setHandle(handle);
|
|
2989
|
-
streamEnd.setStreamTableIdx(tableIdx);
|
|
2990
|
-
|
|
2991
|
-
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2992
|
-
const waitableIdx = cstate.handles.insert(streamEnd);
|
|
2993
|
-
streamEnd.setWaitableIdx(waitableIdx);
|
|
2994
|
-
|
|
2995
|
-
_debugLog('[ComponentAsyncState#addStreamEnd()] added stream end', {
|
|
2996
|
-
tableIdx,
|
|
2997
|
-
table,
|
|
2998
|
-
handle,
|
|
2999
|
-
streamEnd,
|
|
3000
|
-
destComponentIdx: componentIdx,
|
|
3001
|
-
});
|
|
3002
|
-
|
|
3003
|
-
return { handle, waitableIdx };
|
|
3199
|
+
const streamEnd = cstate.handles.get(streamWaitableIdx);
|
|
3200
|
+
if (!streamEnd) {
|
|
3201
|
+
throw new Error(`missing stream end (handle [${streamWaitableIdx}], table [${tableIdx}])`);
|
|
3004
3202
|
}
|
|
3203
|
+
const handle = streamEnd.handle();
|
|
3005
3204
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3205
|
+
let removed = cstate.handles.remove(streamWaitableIdx);
|
|
3206
|
+
if (!removed) {
|
|
3207
|
+
throw new Error(`failed to remove streamEnd from handles (waitable idx [${streamWaitableIdx}]), component [${componentIdx}])`);
|
|
3008
3208
|
}
|
|
3009
3209
|
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
if (tableIdx === undefined) { throw new Error("missing table idx while adding stream"); }
|
|
3014
|
-
if (elemMeta === undefined) { throw new Error("missing element metadata while adding stream"); }
|
|
3015
|
-
|
|
3016
|
-
const { table: localStreamTable, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3017
|
-
if (!localStreamTable) {
|
|
3018
|
-
throw new Error(`missing global stream table lookup for table [${tableIdx}] while creating stream`);
|
|
3019
|
-
}
|
|
3020
|
-
if (componentIdx !== this.#componentIdx) {
|
|
3021
|
-
throw new Error('component idx mismatch while creating stream');
|
|
3022
|
-
}
|
|
3023
|
-
|
|
3024
|
-
const readWaitable = this.createWaitable();
|
|
3025
|
-
const writeWaitable = this.createWaitable();
|
|
3026
|
-
|
|
3027
|
-
const stream = new InternalStream({
|
|
3028
|
-
tableIdx,
|
|
3029
|
-
componentIdx: this.#componentIdx,
|
|
3030
|
-
elemMeta,
|
|
3031
|
-
readWaitable,
|
|
3032
|
-
writeWaitable,
|
|
3033
|
-
});
|
|
3034
|
-
stream.setGlobalStreamMapRep(STREAMS.insert(stream));
|
|
3035
|
-
|
|
3036
|
-
const writeEnd = stream.writeEnd();
|
|
3037
|
-
writeEnd.setWaitableIdx(this.handles.insert(writeEnd));
|
|
3038
|
-
writeEnd.setHandle(localStreamTable.insert(writeEnd));
|
|
3039
|
-
if (writeEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3040
|
-
|
|
3041
|
-
const writeEndWaitableIdx = writeEnd.waitableIdx();
|
|
3042
|
-
const writeEndHandle = writeEnd.handle();
|
|
3043
|
-
writeWaitable.setTarget(`waitable for stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3044
|
-
writeEnd.setTarget(`stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3045
|
-
|
|
3046
|
-
const readEnd = stream.readEnd();
|
|
3047
|
-
readEnd.setWaitableIdx(this.handles.insert(readEnd));
|
|
3048
|
-
readEnd.setHandle(localStreamTable.insert(readEnd));
|
|
3049
|
-
if (readEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3050
|
-
|
|
3051
|
-
const readEndWaitableIdx = readEnd.waitableIdx();
|
|
3052
|
-
const readEndHandle = readEnd.handle();
|
|
3053
|
-
readWaitable.setTarget(`waitable for read end (waitable [${readEndWaitableIdx}])`);
|
|
3054
|
-
readEnd.setTarget(`stream read end (waitable [${readEndWaitableIdx}])`);
|
|
3055
|
-
|
|
3056
|
-
return {
|
|
3057
|
-
writeEndWaitableIdx,
|
|
3058
|
-
writeEndHandle,
|
|
3059
|
-
readEndWaitableIdx,
|
|
3060
|
-
readEndHandle,
|
|
3061
|
-
};
|
|
3210
|
+
removed = table.remove(handle);
|
|
3211
|
+
if (!removed) {
|
|
3212
|
+
throw new Error(`failed to remove streamEnd from table (handle [${handle}]), table [${tableIdx}], component [${componentIdx}])`);
|
|
3062
3213
|
}
|
|
3063
3214
|
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3215
|
+
return streamEnd;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
const base64Compile = str => WebAssembly.compile(typeof Buffer !== 'undefined' ? Buffer.from(str, 'base64') : Uint8Array.from(atob(str), b => b.charCodeAt(0)));
|
|
3220
|
+
|
|
3221
|
+
const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
|
3222
|
+
let _fs;
|
|
3223
|
+
async function fetchCompile (url) {
|
|
3224
|
+
if (isNode) {
|
|
3225
|
+
_fs = _fs || await import('node:fs/promises');
|
|
3226
|
+
return WebAssembly.compile(await _fs.readFile(url));
|
|
3227
|
+
}
|
|
3228
|
+
return fetch(url).then(WebAssembly.compileStreaming);
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
const symbolCabiDispose = Symbol.for('cabiDispose');
|
|
3232
|
+
|
|
3233
|
+
const symbolRscHandle = Symbol('handle');
|
|
3234
|
+
|
|
3235
|
+
const symbolRscRep = Symbol.for('cabiRep');
|
|
3236
|
+
|
|
3237
|
+
const symbolDispose = Symbol.dispose || Symbol.for('dispose');
|
|
3238
|
+
|
|
3239
|
+
const handleTables = [];
|
|
3240
|
+
|
|
3241
|
+
class ComponentError extends Error {
|
|
3242
|
+
constructor (value) {
|
|
3243
|
+
const enumerable = typeof value !== 'string';
|
|
3244
|
+
super(enumerable ? `${String(value)} (see error.payload)` : value);
|
|
3245
|
+
Object.defineProperty(this, 'payload', { value, enumerable });
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3249
|
+
function getErrorPayload(e) {
|
|
3250
|
+
if (e && hasOwnProperty.call(e, 'payload')) return e.payload;
|
|
3251
|
+
if (e instanceof Error) throw e;
|
|
3252
|
+
return e;
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
function throwUninitialized() {
|
|
3256
|
+
throw new TypeError('Wasm uninitialized use `await $init` first');
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3260
|
+
|
|
3261
|
+
const instantiateCore = WebAssembly.instantiate;
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
let exports0;
|
|
3265
|
+
let exports1;
|
|
3266
|
+
const handleTable2 = [T_FLAG, 0];
|
|
3267
|
+
const captureTable2= new Map();
|
|
3268
|
+
let captureCnt2 = 0;
|
|
3269
|
+
handleTables[2] = handleTable2;
|
|
3270
|
+
|
|
3271
|
+
const _trampoline5 = function() {
|
|
3272
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3273
|
+
let hostProvided = true;
|
|
3274
|
+
|
|
3275
|
+
let parentTask;
|
|
3276
|
+
let task;
|
|
3277
|
+
let subtask;
|
|
3278
|
+
|
|
3279
|
+
const createTask = () => {
|
|
3280
|
+
const results = createNewCurrentTask({
|
|
3281
|
+
componentIdx: -1, // 0,
|
|
3282
|
+
isAsync: false,
|
|
3283
|
+
entryFnName: 'getStderr',
|
|
3284
|
+
getCallbackFn: () => null,
|
|
3285
|
+
callbackFnName: 'null',
|
|
3286
|
+
errHandling: 'none',
|
|
3287
|
+
callingWasmExport: false,
|
|
3288
|
+
});
|
|
3289
|
+
task = results[0];
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
taskCreation: {
|
|
3293
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3294
|
+
if (!parentTask) {
|
|
3295
|
+
createTask();
|
|
3296
|
+
break taskCreation;
|
|
3090
3297
|
}
|
|
3091
3298
|
|
|
3092
|
-
|
|
3093
|
-
_debugLog('[ComponentAsyncState#deleteStreamEnd()] args', args);
|
|
3094
|
-
const { tableIdx, streamEndWaitableIdx } = args;
|
|
3095
|
-
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3096
|
-
if (streamEndWaitableIdx === undefined) { throw new Error("missing stream idx while removing stream end"); }
|
|
3097
|
-
|
|
3098
|
-
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3099
|
-
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3100
|
-
|
|
3101
|
-
const streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3102
|
-
if (!streamEnd) {
|
|
3103
|
-
throw new Error(`missing stream end [${streamEndWaitableIdx}] in component handles while deleting stream`);
|
|
3104
|
-
}
|
|
3105
|
-
if (streamEnd.streamTableIdx() !== tableIdx) {
|
|
3106
|
-
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
3107
|
-
}
|
|
3108
|
-
|
|
3109
|
-
let removed = cstate.handles.remove(streamEnd.waitableIdx());
|
|
3110
|
-
if (!removed) {
|
|
3111
|
-
throw new Error(`failed to remove stream end [${streamEndWaitableIdx}] waitable obj in component [${componentIdx}]`);
|
|
3112
|
-
}
|
|
3113
|
-
|
|
3114
|
-
removed = table.remove(streamEnd.handle());
|
|
3115
|
-
if (!removed) {
|
|
3116
|
-
throw new Error(`failed to remove stream end with handle [${streamEnd.handle()}] from stream table [${tableIdx}] in component [${componentIdx}]`);
|
|
3117
|
-
}
|
|
3118
|
-
|
|
3119
|
-
return streamEnd;
|
|
3120
|
-
}
|
|
3299
|
+
createTask();
|
|
3121
3300
|
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3127
|
-
if (streamWaitableIdx === undefined) {
|
|
3128
|
-
throw new Error("missing stream end waitable idx while removing stream end");
|
|
3129
|
-
}
|
|
3130
|
-
|
|
3131
|
-
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3132
|
-
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while removing stream end`); }
|
|
3133
|
-
|
|
3134
|
-
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3135
|
-
|
|
3136
|
-
const streamEnd = cstate.handles.get(streamWaitableIdx);
|
|
3137
|
-
if (!streamEnd) {
|
|
3138
|
-
throw new Error(`missing stream end (handle [${streamWaitableIdx}], table [${tableIdx}])`);
|
|
3139
|
-
}
|
|
3140
|
-
const handle = streamEnd.handle();
|
|
3141
|
-
|
|
3142
|
-
let removed = cstate.handles.remove(streamWaitableIdx);
|
|
3143
|
-
if (!removed) {
|
|
3144
|
-
throw new Error(`failed to remove streamEnd from handles (waitable idx [${streamWaitableIdx}]), component [${componentIdx}])`);
|
|
3145
|
-
}
|
|
3146
|
-
|
|
3147
|
-
removed = table.remove(handle);
|
|
3148
|
-
if (!removed) {
|
|
3149
|
-
throw new Error(`failed to remove streamEnd from table (handle [${handle}]), table [${tableIdx}], component [${componentIdx}])`);
|
|
3301
|
+
if (hostProvided) {
|
|
3302
|
+
subtask = parentTask.getLatestSubtask();
|
|
3303
|
+
if (!subtask) {
|
|
3304
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3150
3305
|
}
|
|
3151
|
-
|
|
3152
|
-
return streamEnd;
|
|
3306
|
+
task.setParentSubtask(subtask);
|
|
3153
3307
|
}
|
|
3154
3308
|
}
|
|
3155
3309
|
|
|
3156
|
-
const
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
return fetch(url).then(WebAssembly.compileStreaming);
|
|
3310
|
+
const started = task.enterSync();
|
|
3311
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3312
|
+
componentIdx: task.componentIdx(),
|
|
3313
|
+
taskID: task.id(),
|
|
3314
|
+
fn: () => getStderr()
|
|
3315
|
+
})
|
|
3316
|
+
;
|
|
3317
|
+
if (!(ret instanceof OutputStream)) {
|
|
3318
|
+
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3166
3319
|
}
|
|
3320
|
+
var handle0 = ret[symbolRscHandle];
|
|
3321
|
+
if (!handle0) {
|
|
3322
|
+
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3323
|
+
captureTable2.set(rep, ret);
|
|
3324
|
+
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3325
|
+
}
|
|
3326
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"][Instruction::Return]', {
|
|
3327
|
+
funcName: 'get-stderr',
|
|
3328
|
+
paramCount: 1,
|
|
3329
|
+
async: false,
|
|
3330
|
+
postReturn: false
|
|
3331
|
+
});
|
|
3332
|
+
task.resolve([handle0]);
|
|
3333
|
+
task.exit();
|
|
3334
|
+
return handle0;
|
|
3335
|
+
}
|
|
3336
|
+
_trampoline5.fnName = 'wasi:cli/stderr@0.2.3#getStderr';
|
|
3337
|
+
const handleTable1 = [T_FLAG, 0];
|
|
3338
|
+
const captureTable1= new Map();
|
|
3339
|
+
let captureCnt1 = 0;
|
|
3340
|
+
handleTables[1] = handleTable1;
|
|
3341
|
+
|
|
3342
|
+
const _trampoline8 = function() {
|
|
3343
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3344
|
+
let hostProvided = true;
|
|
3167
3345
|
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
const symbolRscRep = Symbol.for('cabiRep');
|
|
3173
|
-
|
|
3174
|
-
const symbolDispose = Symbol.dispose || Symbol.for('dispose');
|
|
3346
|
+
let parentTask;
|
|
3347
|
+
let task;
|
|
3348
|
+
let subtask;
|
|
3175
3349
|
|
|
3176
|
-
const
|
|
3350
|
+
const createTask = () => {
|
|
3351
|
+
const results = createNewCurrentTask({
|
|
3352
|
+
componentIdx: -1, // 0,
|
|
3353
|
+
isAsync: false,
|
|
3354
|
+
entryFnName: 'getStdin',
|
|
3355
|
+
getCallbackFn: () => null,
|
|
3356
|
+
callbackFnName: 'null',
|
|
3357
|
+
errHandling: 'none',
|
|
3358
|
+
callingWasmExport: false,
|
|
3359
|
+
});
|
|
3360
|
+
task = results[0];
|
|
3361
|
+
};
|
|
3177
3362
|
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3363
|
+
taskCreation: {
|
|
3364
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3365
|
+
if (!parentTask) {
|
|
3366
|
+
createTask();
|
|
3367
|
+
break taskCreation;
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
createTask();
|
|
3371
|
+
|
|
3372
|
+
if (hostProvided) {
|
|
3373
|
+
subtask = parentTask.getLatestSubtask();
|
|
3374
|
+
if (!subtask) {
|
|
3375
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3376
|
+
}
|
|
3377
|
+
task.setParentSubtask(subtask);
|
|
3183
3378
|
}
|
|
3184
3379
|
}
|
|
3185
3380
|
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3381
|
+
const started = task.enterSync();
|
|
3382
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3383
|
+
componentIdx: task.componentIdx(),
|
|
3384
|
+
taskID: task.id(),
|
|
3385
|
+
fn: () => getStdin()
|
|
3386
|
+
})
|
|
3387
|
+
;
|
|
3388
|
+
if (!(ret instanceof InputStream)) {
|
|
3389
|
+
throw new TypeError('Resource error: Not a valid "InputStream" resource.');
|
|
3190
3390
|
}
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3391
|
+
var handle0 = ret[symbolRscHandle];
|
|
3392
|
+
if (!handle0) {
|
|
3393
|
+
const rep = ret[symbolRscRep] || ++captureCnt1;
|
|
3394
|
+
captureTable1.set(rep, ret);
|
|
3395
|
+
handle0 = rscTableCreateOwn(handleTable1, rep);
|
|
3194
3396
|
}
|
|
3397
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"][Instruction::Return]', {
|
|
3398
|
+
funcName: 'get-stdin',
|
|
3399
|
+
paramCount: 1,
|
|
3400
|
+
async: false,
|
|
3401
|
+
postReturn: false
|
|
3402
|
+
});
|
|
3403
|
+
task.resolve([handle0]);
|
|
3404
|
+
task.exit();
|
|
3405
|
+
return handle0;
|
|
3406
|
+
}
|
|
3407
|
+
_trampoline8.fnName = 'wasi:cli/stdin@0.2.3#getStdin';
|
|
3408
|
+
|
|
3409
|
+
const _trampoline9 = function() {
|
|
3410
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3411
|
+
let hostProvided = true;
|
|
3195
3412
|
|
|
3196
|
-
|
|
3413
|
+
let parentTask;
|
|
3414
|
+
let task;
|
|
3415
|
+
let subtask;
|
|
3197
3416
|
|
|
3198
|
-
const
|
|
3417
|
+
const createTask = () => {
|
|
3418
|
+
const results = createNewCurrentTask({
|
|
3419
|
+
componentIdx: -1, // 0,
|
|
3420
|
+
isAsync: false,
|
|
3421
|
+
entryFnName: 'getStdout',
|
|
3422
|
+
getCallbackFn: () => null,
|
|
3423
|
+
callbackFnName: 'null',
|
|
3424
|
+
errHandling: 'none',
|
|
3425
|
+
callingWasmExport: false,
|
|
3426
|
+
});
|
|
3427
|
+
task = results[0];
|
|
3428
|
+
};
|
|
3199
3429
|
|
|
3430
|
+
taskCreation: {
|
|
3431
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3432
|
+
if (!parentTask) {
|
|
3433
|
+
createTask();
|
|
3434
|
+
break taskCreation;
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
createTask();
|
|
3438
|
+
|
|
3439
|
+
if (hostProvided) {
|
|
3440
|
+
subtask = parentTask.getLatestSubtask();
|
|
3441
|
+
if (!subtask) {
|
|
3442
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3443
|
+
}
|
|
3444
|
+
task.setParentSubtask(subtask);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3200
3447
|
|
|
3201
|
-
|
|
3202
|
-
let
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3448
|
+
const started = task.enterSync();
|
|
3449
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3450
|
+
componentIdx: task.componentIdx(),
|
|
3451
|
+
taskID: task.id(),
|
|
3452
|
+
fn: () => getStdout()
|
|
3453
|
+
})
|
|
3454
|
+
;
|
|
3455
|
+
if (!(ret instanceof OutputStream)) {
|
|
3456
|
+
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3457
|
+
}
|
|
3458
|
+
var handle0 = ret[symbolRscHandle];
|
|
3459
|
+
if (!handle0) {
|
|
3460
|
+
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3461
|
+
captureTable2.set(rep, ret);
|
|
3462
|
+
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3463
|
+
}
|
|
3464
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"][Instruction::Return]', {
|
|
3465
|
+
funcName: 'get-stdout',
|
|
3466
|
+
paramCount: 1,
|
|
3467
|
+
async: false,
|
|
3468
|
+
postReturn: false
|
|
3469
|
+
});
|
|
3470
|
+
task.resolve([handle0]);
|
|
3471
|
+
task.exit();
|
|
3472
|
+
return handle0;
|
|
3473
|
+
}
|
|
3474
|
+
_trampoline9.fnName = 'wasi:cli/stdout@0.2.3#getStdout';
|
|
3475
|
+
|
|
3476
|
+
const _trampoline10 = function(arg0) {
|
|
3477
|
+
let variant0;
|
|
3478
|
+
switch (arg0) {
|
|
3479
|
+
case 0: {
|
|
3480
|
+
variant0= {
|
|
3481
|
+
tag: 'ok',
|
|
3482
|
+
val: undefined
|
|
3483
|
+
};
|
|
3484
|
+
break;
|
|
3485
|
+
}
|
|
3486
|
+
case 1: {
|
|
3487
|
+
variant0= {
|
|
3488
|
+
tag: 'err',
|
|
3489
|
+
val: undefined
|
|
3490
|
+
};
|
|
3491
|
+
break;
|
|
3492
|
+
}
|
|
3493
|
+
default: {
|
|
3494
|
+
throw new TypeError('invalid variant discriminant for expected');
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3498
|
+
let hostProvided = true;
|
|
3207
3499
|
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3500
|
+
let parentTask;
|
|
3501
|
+
let task;
|
|
3502
|
+
let subtask;
|
|
3503
|
+
|
|
3504
|
+
const createTask = () => {
|
|
3505
|
+
const results = createNewCurrentTask({
|
|
3506
|
+
componentIdx: -1, // 0,
|
|
3507
|
+
isAsync: false,
|
|
3508
|
+
entryFnName: 'exit',
|
|
3509
|
+
getCallbackFn: () => null,
|
|
3510
|
+
callbackFnName: 'null',
|
|
3511
|
+
errHandling: 'none',
|
|
3512
|
+
callingWasmExport: false,
|
|
3513
|
+
});
|
|
3514
|
+
task = results[0];
|
|
3515
|
+
};
|
|
3516
|
+
|
|
3517
|
+
taskCreation: {
|
|
3518
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3519
|
+
if (!parentTask) {
|
|
3520
|
+
createTask();
|
|
3521
|
+
break taskCreation;
|
|
3522
|
+
}
|
|
3215
3523
|
|
|
3216
|
-
|
|
3217
|
-
const results = createNewCurrentTask({
|
|
3218
|
-
componentIdx: -1, // 0,
|
|
3219
|
-
isAsync: false,
|
|
3220
|
-
entryFnName: 'getStderr',
|
|
3221
|
-
getCallbackFn: () => null,
|
|
3222
|
-
callbackFnName: 'null',
|
|
3223
|
-
errHandling: 'none',
|
|
3224
|
-
callingWasmExport: false,
|
|
3225
|
-
});
|
|
3226
|
-
task = results[0];
|
|
3227
|
-
};
|
|
3524
|
+
createTask();
|
|
3228
3525
|
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
if (!
|
|
3232
|
-
|
|
3233
|
-
break taskCreation;
|
|
3526
|
+
if (hostProvided) {
|
|
3527
|
+
subtask = parentTask.getLatestSubtask();
|
|
3528
|
+
if (!subtask) {
|
|
3529
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3234
3530
|
}
|
|
3235
|
-
|
|
3531
|
+
task.setParentSubtask(subtask);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
const started = task.enterSync();
|
|
3536
|
+
let ret;_withGlobalCurrentTaskMeta({
|
|
3537
|
+
componentIdx: task.componentIdx(),
|
|
3538
|
+
taskID: task.id(),
|
|
3539
|
+
fn: () => exit(variant0)
|
|
3540
|
+
})
|
|
3541
|
+
;
|
|
3542
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"][Instruction::Return]', {
|
|
3543
|
+
funcName: 'exit',
|
|
3544
|
+
paramCount: 0,
|
|
3545
|
+
async: false,
|
|
3546
|
+
postReturn: false
|
|
3547
|
+
});
|
|
3548
|
+
task.resolve([ret]);
|
|
3549
|
+
task.exit();
|
|
3550
|
+
}
|
|
3551
|
+
_trampoline10.fnName = 'wasi:cli/exit@0.2.3#exit';
|
|
3552
|
+
let exports2;
|
|
3553
|
+
let memory0;
|
|
3554
|
+
let realloc0;
|
|
3555
|
+
let realloc0Async;
|
|
3556
|
+
|
|
3557
|
+
const _trampoline11 = function(arg0) {
|
|
3558
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3559
|
+
let hostProvided = true;
|
|
3560
|
+
|
|
3561
|
+
let parentTask;
|
|
3562
|
+
let task;
|
|
3563
|
+
let subtask;
|
|
3564
|
+
|
|
3565
|
+
const createTask = () => {
|
|
3566
|
+
const results = createNewCurrentTask({
|
|
3567
|
+
componentIdx: -1, // 0,
|
|
3568
|
+
isAsync: false,
|
|
3569
|
+
entryFnName: 'getEnvironment',
|
|
3570
|
+
getCallbackFn: () => null,
|
|
3571
|
+
callbackFnName: 'null',
|
|
3572
|
+
errHandling: 'none',
|
|
3573
|
+
callingWasmExport: false,
|
|
3574
|
+
});
|
|
3575
|
+
task = results[0];
|
|
3576
|
+
};
|
|
3577
|
+
|
|
3578
|
+
taskCreation: {
|
|
3579
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3580
|
+
if (!parentTask) {
|
|
3236
3581
|
createTask();
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3582
|
+
break taskCreation;
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
createTask();
|
|
3586
|
+
|
|
3587
|
+
if (hostProvided) {
|
|
3588
|
+
subtask = parentTask.getLatestSubtask();
|
|
3589
|
+
if (!subtask) {
|
|
3590
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3244
3591
|
}
|
|
3592
|
+
task.setParentSubtask(subtask);
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
const started = task.enterSync();
|
|
3597
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3598
|
+
componentIdx: task.componentIdx(),
|
|
3599
|
+
taskID: task.id(),
|
|
3600
|
+
fn: () => getEnvironment()
|
|
3601
|
+
})
|
|
3602
|
+
;
|
|
3603
|
+
var vec3 = ret;
|
|
3604
|
+
var len3 = vec3.length;
|
|
3605
|
+
var result3 = realloc0(0, 0, 4, len3 * 16);
|
|
3606
|
+
for (let i = 0; i < vec3.length; i++) {
|
|
3607
|
+
const e = vec3[i];
|
|
3608
|
+
const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
|
|
3609
|
+
|
|
3610
|
+
var encodeRes = _utf8AllocateAndEncode(tuple0_0, realloc0, memory0);
|
|
3611
|
+
var ptr1= encodeRes.ptr;
|
|
3612
|
+
var len1 = encodeRes.len;
|
|
3613
|
+
|
|
3614
|
+
dataView(memory0).setUint32(base + 4, len1, true);
|
|
3615
|
+
dataView(memory0).setUint32(base + 0, ptr1, true);
|
|
3616
|
+
|
|
3617
|
+
var encodeRes = _utf8AllocateAndEncode(tuple0_1, realloc0, memory0);
|
|
3618
|
+
var ptr2= encodeRes.ptr;
|
|
3619
|
+
var len2 = encodeRes.len;
|
|
3620
|
+
|
|
3621
|
+
dataView(memory0).setUint32(base + 12, len2, true);
|
|
3622
|
+
dataView(memory0).setUint32(base + 8, ptr2, true);
|
|
3623
|
+
}
|
|
3624
|
+
dataView(memory0).setUint32(arg0 + 4, len3, true);
|
|
3625
|
+
dataView(memory0).setUint32(arg0 + 0, result3, true);
|
|
3626
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"][Instruction::Return]', {
|
|
3627
|
+
funcName: 'get-environment',
|
|
3628
|
+
paramCount: 0,
|
|
3629
|
+
async: false,
|
|
3630
|
+
postReturn: false
|
|
3631
|
+
});
|
|
3632
|
+
task.resolve([ret]);
|
|
3633
|
+
task.exit();
|
|
3634
|
+
}
|
|
3635
|
+
_trampoline11.fnName = 'wasi:cli/environment@0.2.3#getEnvironment';
|
|
3636
|
+
const handleTable6 = [T_FLAG, 0];
|
|
3637
|
+
const captureTable6= new Map();
|
|
3638
|
+
let captureCnt6 = 0;
|
|
3639
|
+
handleTables[6] = handleTable6;
|
|
3640
|
+
|
|
3641
|
+
const _trampoline12 = function(arg0, arg1) {
|
|
3642
|
+
var handle1 = arg0;
|
|
3643
|
+
|
|
3644
|
+
var rep2 = handleTable6[(handle1 << 1) + 1] & ~T_FLAG;
|
|
3645
|
+
var rsc0 = captureTable6.get(rep2);
|
|
3646
|
+
if (!rsc0) {
|
|
3647
|
+
rsc0 = Object.create(Descriptor.prototype);
|
|
3648
|
+
Object.defineProperty(rsc0, symbolRscHandle, { writable: true, value: handle1});
|
|
3649
|
+
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
curResourceBorrows.push(rsc0);
|
|
3653
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-flags"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3654
|
+
let hostProvided = true;
|
|
3655
|
+
|
|
3656
|
+
let parentTask;
|
|
3657
|
+
let task;
|
|
3658
|
+
let subtask;
|
|
3659
|
+
|
|
3660
|
+
const createTask = () => {
|
|
3661
|
+
const results = createNewCurrentTask({
|
|
3662
|
+
componentIdx: -1, // 0,
|
|
3663
|
+
isAsync: false,
|
|
3664
|
+
entryFnName: 'getFlags',
|
|
3665
|
+
getCallbackFn: () => null,
|
|
3666
|
+
callbackFnName: 'null',
|
|
3667
|
+
errHandling: 'result-catch-handler',
|
|
3668
|
+
callingWasmExport: false,
|
|
3669
|
+
});
|
|
3670
|
+
task = results[0];
|
|
3671
|
+
};
|
|
3672
|
+
|
|
3673
|
+
taskCreation: {
|
|
3674
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3675
|
+
if (!parentTask) {
|
|
3676
|
+
createTask();
|
|
3677
|
+
break taskCreation;
|
|
3245
3678
|
}
|
|
3246
3679
|
|
|
3247
|
-
|
|
3248
|
-
|
|
3680
|
+
createTask();
|
|
3681
|
+
|
|
3682
|
+
if (hostProvided) {
|
|
3683
|
+
subtask = parentTask.getLatestSubtask();
|
|
3684
|
+
if (!subtask) {
|
|
3685
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3686
|
+
}
|
|
3687
|
+
task.setParentSubtask(subtask);
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
const started = task.enterSync();
|
|
3692
|
+
|
|
3693
|
+
let ret;
|
|
3694
|
+
try {
|
|
3695
|
+
ret = { tag: 'ok', val: _withGlobalCurrentTaskMeta({
|
|
3249
3696
|
componentIdx: task.componentIdx(),
|
|
3250
3697
|
taskID: task.id(),
|
|
3251
|
-
fn: () =>
|
|
3698
|
+
fn: () => rsc0.getFlags()
|
|
3252
3699
|
})
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3700
|
+
};
|
|
3701
|
+
} catch (e) {
|
|
3702
|
+
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
for (const rsc of curResourceBorrows) {
|
|
3706
|
+
rsc[symbolRscHandle] = undefined;
|
|
3707
|
+
}
|
|
3708
|
+
curResourceBorrows = [];
|
|
3709
|
+
var variant5 = ret;
|
|
3710
|
+
switch (variant5.tag) {
|
|
3711
|
+
case 'ok': {
|
|
3712
|
+
const e = variant5.val;
|
|
3713
|
+
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
3714
|
+
let flags3 = 0;
|
|
3715
|
+
if (typeof e === 'object' && e !== null) {
|
|
3716
|
+
flags3 = Boolean(e.read) << 0 | Boolean(e.write) << 1 | Boolean(e.fileIntegritySync) << 2 | Boolean(e.dataIntegritySync) << 3 | Boolean(e.requestedWriteSync) << 4 | Boolean(e.mutateDirectory) << 5;
|
|
3717
|
+
} else if (e !== null && e!== undefined) {
|
|
3718
|
+
throw new TypeError('only an object, undefined or null can be converted to flags');
|
|
3256
3719
|
}
|
|
3257
|
-
|
|
3258
|
-
if (!handle0) {
|
|
3259
|
-
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3260
|
-
captureTable2.set(rep, ret);
|
|
3261
|
-
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3262
|
-
}
|
|
3263
|
-
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"][Instruction::Return]', {
|
|
3264
|
-
funcName: 'get-stderr',
|
|
3265
|
-
paramCount: 1,
|
|
3266
|
-
async: false,
|
|
3267
|
-
postReturn: false
|
|
3268
|
-
});
|
|
3269
|
-
task.resolve([handle0]);
|
|
3270
|
-
task.exit();
|
|
3271
|
-
return handle0;
|
|
3272
|
-
}
|
|
3273
|
-
_trampoline5.fnName = 'wasi:cli/stderr@0.2.3#getStderr';
|
|
3274
|
-
const handleTable1 = [T_FLAG, 0];
|
|
3275
|
-
const captureTable1= new Map();
|
|
3276
|
-
let captureCnt1 = 0;
|
|
3277
|
-
handleTables[1] = handleTable1;
|
|
3278
|
-
|
|
3279
|
-
const _trampoline8 = function() {
|
|
3280
|
-
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3281
|
-
let hostProvided = true;
|
|
3282
|
-
|
|
3283
|
-
let parentTask;
|
|
3284
|
-
let task;
|
|
3285
|
-
let subtask;
|
|
3286
|
-
|
|
3287
|
-
const createTask = () => {
|
|
3288
|
-
const results = createNewCurrentTask({
|
|
3289
|
-
componentIdx: -1, // 0,
|
|
3290
|
-
isAsync: false,
|
|
3291
|
-
entryFnName: 'getStdin',
|
|
3292
|
-
getCallbackFn: () => null,
|
|
3293
|
-
callbackFnName: 'null',
|
|
3294
|
-
errHandling: 'none',
|
|
3295
|
-
callingWasmExport: false,
|
|
3296
|
-
});
|
|
3297
|
-
task = results[0];
|
|
3298
|
-
};
|
|
3720
|
+
dataView(memory0).setInt8(arg1 + 1, flags3, true);
|
|
3299
3721
|
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3722
|
+
break;
|
|
3723
|
+
}
|
|
3724
|
+
case 'err': {
|
|
3725
|
+
const e = variant5.val;
|
|
3726
|
+
dataView(memory0).setInt8(arg1 + 0, 1, true);
|
|
3727
|
+
var val4 = e;
|
|
3728
|
+
let enum4;
|
|
3729
|
+
switch (val4) {
|
|
3730
|
+
case 'access': {
|
|
3731
|
+
enum4 = 0;
|
|
3732
|
+
break;
|
|
3305
3733
|
}
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3734
|
+
case 'would-block': {
|
|
3735
|
+
enum4 = 1;
|
|
3736
|
+
break;
|
|
3737
|
+
}
|
|
3738
|
+
case 'already': {
|
|
3739
|
+
enum4 = 2;
|
|
3740
|
+
break;
|
|
3741
|
+
}
|
|
3742
|
+
case 'bad-descriptor': {
|
|
3743
|
+
enum4 = 3;
|
|
3744
|
+
break;
|
|
3745
|
+
}
|
|
3746
|
+
case 'busy': {
|
|
3747
|
+
enum4 = 4;
|
|
3748
|
+
break;
|
|
3749
|
+
}
|
|
3750
|
+
case 'deadlock': {
|
|
3751
|
+
enum4 = 5;
|
|
3752
|
+
break;
|
|
3753
|
+
}
|
|
3754
|
+
case 'quota': {
|
|
3755
|
+
enum4 = 6;
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
case 'exist': {
|
|
3759
|
+
enum4 = 7;
|
|
3760
|
+
break;
|
|
3761
|
+
}
|
|
3762
|
+
case 'file-too-large': {
|
|
3763
|
+
enum4 = 8;
|
|
3764
|
+
break;
|
|
3765
|
+
}
|
|
3766
|
+
case 'illegal-byte-sequence': {
|
|
3767
|
+
enum4 = 9;
|
|
3768
|
+
break;
|
|
3769
|
+
}
|
|
3770
|
+
case 'in-progress': {
|
|
3771
|
+
enum4 = 10;
|
|
3772
|
+
break;
|
|
3773
|
+
}
|
|
3774
|
+
case 'interrupted': {
|
|
3775
|
+
enum4 = 11;
|
|
3776
|
+
break;
|
|
3777
|
+
}
|
|
3778
|
+
case 'invalid': {
|
|
3779
|
+
enum4 = 12;
|
|
3780
|
+
break;
|
|
3781
|
+
}
|
|
3782
|
+
case 'io': {
|
|
3783
|
+
enum4 = 13;
|
|
3784
|
+
break;
|
|
3785
|
+
}
|
|
3786
|
+
case 'is-directory': {
|
|
3787
|
+
enum4 = 14;
|
|
3788
|
+
break;
|
|
3789
|
+
}
|
|
3790
|
+
case 'loop': {
|
|
3791
|
+
enum4 = 15;
|
|
3792
|
+
break;
|
|
3793
|
+
}
|
|
3794
|
+
case 'too-many-links': {
|
|
3795
|
+
enum4 = 16;
|
|
3796
|
+
break;
|
|
3797
|
+
}
|
|
3798
|
+
case 'message-size': {
|
|
3799
|
+
enum4 = 17;
|
|
3800
|
+
break;
|
|
3801
|
+
}
|
|
3802
|
+
case 'name-too-long': {
|
|
3803
|
+
enum4 = 18;
|
|
3804
|
+
break;
|
|
3805
|
+
}
|
|
3806
|
+
case 'no-device': {
|
|
3807
|
+
enum4 = 19;
|
|
3808
|
+
break;
|
|
3809
|
+
}
|
|
3810
|
+
case 'no-entry': {
|
|
3811
|
+
enum4 = 20;
|
|
3812
|
+
break;
|
|
3813
|
+
}
|
|
3814
|
+
case 'no-lock': {
|
|
3815
|
+
enum4 = 21;
|
|
3816
|
+
break;
|
|
3817
|
+
}
|
|
3818
|
+
case 'insufficient-memory': {
|
|
3819
|
+
enum4 = 22;
|
|
3820
|
+
break;
|
|
3821
|
+
}
|
|
3822
|
+
case 'insufficient-space': {
|
|
3823
|
+
enum4 = 23;
|
|
3824
|
+
break;
|
|
3825
|
+
}
|
|
3826
|
+
case 'not-directory': {
|
|
3827
|
+
enum4 = 24;
|
|
3828
|
+
break;
|
|
3829
|
+
}
|
|
3830
|
+
case 'not-empty': {
|
|
3831
|
+
enum4 = 25;
|
|
3832
|
+
break;
|
|
3833
|
+
}
|
|
3834
|
+
case 'not-recoverable': {
|
|
3835
|
+
enum4 = 26;
|
|
3836
|
+
break;
|
|
3315
3837
|
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
let ret = _withGlobalCurrentTaskMeta({
|
|
3320
|
-
componentIdx: task.componentIdx(),
|
|
3321
|
-
taskID: task.id(),
|
|
3322
|
-
fn: () => getStdin()
|
|
3323
|
-
})
|
|
3324
|
-
;
|
|
3325
|
-
if (!(ret instanceof InputStream)) {
|
|
3326
|
-
throw new TypeError('Resource error: Not a valid "InputStream" resource.');
|
|
3327
|
-
}
|
|
3328
|
-
var handle0 = ret[symbolRscHandle];
|
|
3329
|
-
if (!handle0) {
|
|
3330
|
-
const rep = ret[symbolRscRep] || ++captureCnt1;
|
|
3331
|
-
captureTable1.set(rep, ret);
|
|
3332
|
-
handle0 = rscTableCreateOwn(handleTable1, rep);
|
|
3333
|
-
}
|
|
3334
|
-
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"][Instruction::Return]', {
|
|
3335
|
-
funcName: 'get-stdin',
|
|
3336
|
-
paramCount: 1,
|
|
3337
|
-
async: false,
|
|
3338
|
-
postReturn: false
|
|
3339
|
-
});
|
|
3340
|
-
task.resolve([handle0]);
|
|
3341
|
-
task.exit();
|
|
3342
|
-
return handle0;
|
|
3343
|
-
}
|
|
3344
|
-
_trampoline8.fnName = 'wasi:cli/stdin@0.2.3#getStdin';
|
|
3345
|
-
|
|
3346
|
-
const _trampoline9 = function() {
|
|
3347
|
-
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3348
|
-
let hostProvided = true;
|
|
3349
|
-
|
|
3350
|
-
let parentTask;
|
|
3351
|
-
let task;
|
|
3352
|
-
let subtask;
|
|
3353
|
-
|
|
3354
|
-
const createTask = () => {
|
|
3355
|
-
const results = createNewCurrentTask({
|
|
3356
|
-
componentIdx: -1, // 0,
|
|
3357
|
-
isAsync: false,
|
|
3358
|
-
entryFnName: 'getStdout',
|
|
3359
|
-
getCallbackFn: () => null,
|
|
3360
|
-
callbackFnName: 'null',
|
|
3361
|
-
errHandling: 'none',
|
|
3362
|
-
callingWasmExport: false,
|
|
3363
|
-
});
|
|
3364
|
-
task = results[0];
|
|
3365
|
-
};
|
|
3366
|
-
|
|
3367
|
-
taskCreation: {
|
|
3368
|
-
parentTask = getCurrentTask(0)?.task;
|
|
3369
|
-
if (!parentTask) {
|
|
3370
|
-
createTask();
|
|
3371
|
-
break taskCreation;
|
|
3838
|
+
case 'unsupported': {
|
|
3839
|
+
enum4 = 27;
|
|
3840
|
+
break;
|
|
3372
3841
|
}
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
if (hostProvided) {
|
|
3377
|
-
subtask = parentTask.getLatestSubtask();
|
|
3378
|
-
if (!subtask) {
|
|
3379
|
-
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3380
|
-
}
|
|
3381
|
-
task.setParentSubtask(subtask);
|
|
3842
|
+
case 'no-tty': {
|
|
3843
|
+
enum4 = 28;
|
|
3844
|
+
break;
|
|
3382
3845
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
const started = task.enterSync();
|
|
3386
|
-
let ret = _withGlobalCurrentTaskMeta({
|
|
3387
|
-
componentIdx: task.componentIdx(),
|
|
3388
|
-
taskID: task.id(),
|
|
3389
|
-
fn: () => getStdout()
|
|
3390
|
-
})
|
|
3391
|
-
;
|
|
3392
|
-
if (!(ret instanceof OutputStream)) {
|
|
3393
|
-
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3394
|
-
}
|
|
3395
|
-
var handle0 = ret[symbolRscHandle];
|
|
3396
|
-
if (!handle0) {
|
|
3397
|
-
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3398
|
-
captureTable2.set(rep, ret);
|
|
3399
|
-
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3400
|
-
}
|
|
3401
|
-
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"][Instruction::Return]', {
|
|
3402
|
-
funcName: 'get-stdout',
|
|
3403
|
-
paramCount: 1,
|
|
3404
|
-
async: false,
|
|
3405
|
-
postReturn: false
|
|
3406
|
-
});
|
|
3407
|
-
task.resolve([handle0]);
|
|
3408
|
-
task.exit();
|
|
3409
|
-
return handle0;
|
|
3410
|
-
}
|
|
3411
|
-
_trampoline9.fnName = 'wasi:cli/stdout@0.2.3#getStdout';
|
|
3412
|
-
|
|
3413
|
-
const _trampoline10 = function(arg0) {
|
|
3414
|
-
let variant0;
|
|
3415
|
-
switch (arg0) {
|
|
3416
|
-
case 0: {
|
|
3417
|
-
variant0= {
|
|
3418
|
-
tag: 'ok',
|
|
3419
|
-
val: undefined
|
|
3420
|
-
};
|
|
3846
|
+
case 'no-such-device': {
|
|
3847
|
+
enum4 = 29;
|
|
3421
3848
|
break;
|
|
3422
3849
|
}
|
|
3423
|
-
case
|
|
3424
|
-
|
|
3425
|
-
tag: 'err',
|
|
3426
|
-
val: undefined
|
|
3427
|
-
};
|
|
3850
|
+
case 'overflow': {
|
|
3851
|
+
enum4 = 30;
|
|
3428
3852
|
break;
|
|
3429
3853
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3854
|
+
case 'not-permitted': {
|
|
3855
|
+
enum4 = 31;
|
|
3856
|
+
break;
|
|
3432
3857
|
}
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
let parentTask;
|
|
3438
|
-
let task;
|
|
3439
|
-
let subtask;
|
|
3440
|
-
|
|
3441
|
-
const createTask = () => {
|
|
3442
|
-
const results = createNewCurrentTask({
|
|
3443
|
-
componentIdx: -1, // 0,
|
|
3444
|
-
isAsync: false,
|
|
3445
|
-
entryFnName: 'exit',
|
|
3446
|
-
getCallbackFn: () => null,
|
|
3447
|
-
callbackFnName: 'null',
|
|
3448
|
-
errHandling: 'none',
|
|
3449
|
-
callingWasmExport: false,
|
|
3450
|
-
});
|
|
3451
|
-
task = results[0];
|
|
3452
|
-
};
|
|
3453
|
-
|
|
3454
|
-
taskCreation: {
|
|
3455
|
-
parentTask = getCurrentTask(0)?.task;
|
|
3456
|
-
if (!parentTask) {
|
|
3457
|
-
createTask();
|
|
3458
|
-
break taskCreation;
|
|
3858
|
+
case 'pipe': {
|
|
3859
|
+
enum4 = 32;
|
|
3860
|
+
break;
|
|
3459
3861
|
}
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
if (hostProvided) {
|
|
3464
|
-
subtask = parentTask.getLatestSubtask();
|
|
3465
|
-
if (!subtask) {
|
|
3466
|
-
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3467
|
-
}
|
|
3468
|
-
task.setParentSubtask(subtask);
|
|
3862
|
+
case 'read-only': {
|
|
3863
|
+
enum4 = 33;
|
|
3864
|
+
break;
|
|
3469
3865
|
}
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
let ret;_withGlobalCurrentTaskMeta({
|
|
3474
|
-
componentIdx: task.componentIdx(),
|
|
3475
|
-
taskID: task.id(),
|
|
3476
|
-
fn: () => exit(variant0)
|
|
3477
|
-
})
|
|
3478
|
-
;
|
|
3479
|
-
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"][Instruction::Return]', {
|
|
3480
|
-
funcName: 'exit',
|
|
3481
|
-
paramCount: 0,
|
|
3482
|
-
async: false,
|
|
3483
|
-
postReturn: false
|
|
3484
|
-
});
|
|
3485
|
-
task.resolve([ret]);
|
|
3486
|
-
task.exit();
|
|
3487
|
-
}
|
|
3488
|
-
_trampoline10.fnName = 'wasi:cli/exit@0.2.3#exit';
|
|
3489
|
-
let exports2;
|
|
3490
|
-
let memory0;
|
|
3491
|
-
let realloc0;
|
|
3492
|
-
let realloc0Async;
|
|
3493
|
-
|
|
3494
|
-
const _trampoline11 = function(arg0) {
|
|
3495
|
-
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3496
|
-
let hostProvided = true;
|
|
3497
|
-
|
|
3498
|
-
let parentTask;
|
|
3499
|
-
let task;
|
|
3500
|
-
let subtask;
|
|
3501
|
-
|
|
3502
|
-
const createTask = () => {
|
|
3503
|
-
const results = createNewCurrentTask({
|
|
3504
|
-
componentIdx: -1, // 0,
|
|
3505
|
-
isAsync: false,
|
|
3506
|
-
entryFnName: 'getEnvironment',
|
|
3507
|
-
getCallbackFn: () => null,
|
|
3508
|
-
callbackFnName: 'null',
|
|
3509
|
-
errHandling: 'none',
|
|
3510
|
-
callingWasmExport: false,
|
|
3511
|
-
});
|
|
3512
|
-
task = results[0];
|
|
3513
|
-
};
|
|
3514
|
-
|
|
3515
|
-
taskCreation: {
|
|
3516
|
-
parentTask = getCurrentTask(0)?.task;
|
|
3517
|
-
if (!parentTask) {
|
|
3518
|
-
createTask();
|
|
3519
|
-
break taskCreation;
|
|
3866
|
+
case 'invalid-seek': {
|
|
3867
|
+
enum4 = 34;
|
|
3868
|
+
break;
|
|
3520
3869
|
}
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
if (hostProvided) {
|
|
3525
|
-
subtask = parentTask.getLatestSubtask();
|
|
3526
|
-
if (!subtask) {
|
|
3527
|
-
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3528
|
-
}
|
|
3529
|
-
task.setParentSubtask(subtask);
|
|
3870
|
+
case 'text-file-busy': {
|
|
3871
|
+
enum4 = 35;
|
|
3872
|
+
break;
|
|
3530
3873
|
}
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
let ret = _withGlobalCurrentTaskMeta({
|
|
3535
|
-
componentIdx: task.componentIdx(),
|
|
3536
|
-
taskID: task.id(),
|
|
3537
|
-
fn: () => getEnvironment()
|
|
3538
|
-
})
|
|
3539
|
-
;
|
|
3540
|
-
var vec3 = ret;
|
|
3541
|
-
var len3 = vec3.length;
|
|
3542
|
-
var result3 = realloc0(0, 0, 4, len3 * 16);
|
|
3543
|
-
for (let i = 0; i < vec3.length; i++) {
|
|
3544
|
-
const e = vec3[i];
|
|
3545
|
-
const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
|
|
3546
|
-
|
|
3547
|
-
var encodeRes = _utf8AllocateAndEncode(tuple0_0, realloc0, memory0);
|
|
3548
|
-
var ptr1= encodeRes.ptr;
|
|
3549
|
-
var len1 = encodeRes.len;
|
|
3550
|
-
|
|
3551
|
-
dataView(memory0).setUint32(base + 4, len1, true);
|
|
3552
|
-
dataView(memory0).setUint32(base + 0, ptr1, true);
|
|
3553
|
-
|
|
3554
|
-
var encodeRes = _utf8AllocateAndEncode(tuple0_1, realloc0, memory0);
|
|
3555
|
-
var ptr2= encodeRes.ptr;
|
|
3556
|
-
var len2 = encodeRes.len;
|
|
3557
|
-
|
|
3558
|
-
dataView(memory0).setUint32(base + 12, len2, true);
|
|
3559
|
-
dataView(memory0).setUint32(base + 8, ptr2, true);
|
|
3560
|
-
}
|
|
3561
|
-
dataView(memory0).setUint32(arg0 + 4, len3, true);
|
|
3562
|
-
dataView(memory0).setUint32(arg0 + 0, result3, true);
|
|
3563
|
-
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"][Instruction::Return]', {
|
|
3564
|
-
funcName: 'get-environment',
|
|
3565
|
-
paramCount: 0,
|
|
3566
|
-
async: false,
|
|
3567
|
-
postReturn: false
|
|
3568
|
-
});
|
|
3569
|
-
task.resolve([ret]);
|
|
3570
|
-
task.exit();
|
|
3571
|
-
}
|
|
3572
|
-
_trampoline11.fnName = 'wasi:cli/environment@0.2.3#getEnvironment';
|
|
3573
|
-
const handleTable6 = [T_FLAG, 0];
|
|
3574
|
-
const captureTable6= new Map();
|
|
3575
|
-
let captureCnt6 = 0;
|
|
3576
|
-
handleTables[6] = handleTable6;
|
|
3577
|
-
|
|
3578
|
-
const _trampoline12 = function(arg0, arg1) {
|
|
3579
|
-
var handle1 = arg0;
|
|
3580
|
-
|
|
3581
|
-
var rep2 = handleTable6[(handle1 << 1) + 1] & ~T_FLAG;
|
|
3582
|
-
var rsc0 = captureTable6.get(rep2);
|
|
3583
|
-
if (!rsc0) {
|
|
3584
|
-
rsc0 = Object.create(Descriptor.prototype);
|
|
3585
|
-
Object.defineProperty(rsc0, symbolRscHandle, { writable: true, value: handle1});
|
|
3586
|
-
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3587
|
-
}
|
|
3588
|
-
|
|
3589
|
-
curResourceBorrows.push(rsc0);
|
|
3590
|
-
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-flags"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3591
|
-
let hostProvided = true;
|
|
3592
|
-
|
|
3593
|
-
let parentTask;
|
|
3594
|
-
let task;
|
|
3595
|
-
let subtask;
|
|
3596
|
-
|
|
3597
|
-
const createTask = () => {
|
|
3598
|
-
const results = createNewCurrentTask({
|
|
3599
|
-
componentIdx: -1, // 0,
|
|
3600
|
-
isAsync: false,
|
|
3601
|
-
entryFnName: 'getFlags',
|
|
3602
|
-
getCallbackFn: () => null,
|
|
3603
|
-
callbackFnName: 'null',
|
|
3604
|
-
errHandling: 'result-catch-handler',
|
|
3605
|
-
callingWasmExport: false,
|
|
3606
|
-
});
|
|
3607
|
-
task = results[0];
|
|
3608
|
-
};
|
|
3609
|
-
|
|
3610
|
-
taskCreation: {
|
|
3611
|
-
parentTask = getCurrentTask(0)?.task;
|
|
3612
|
-
if (!parentTask) {
|
|
3613
|
-
createTask();
|
|
3614
|
-
break taskCreation;
|
|
3874
|
+
case 'cross-device': {
|
|
3875
|
+
enum4 = 36;
|
|
3876
|
+
break;
|
|
3615
3877
|
}
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
if (hostProvided) {
|
|
3620
|
-
subtask = parentTask.getLatestSubtask();
|
|
3621
|
-
if (!subtask) {
|
|
3622
|
-
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3878
|
+
default: {
|
|
3879
|
+
if ((e) instanceof Error) {
|
|
3880
|
+
console.error(e);
|
|
3623
3881
|
}
|
|
3624
|
-
|
|
3882
|
+
|
|
3883
|
+
throw new TypeError(`"${val4}" is not one of the cases of error-code`);
|
|
3625
3884
|
}
|
|
3626
3885
|
}
|
|
3886
|
+
dataView(memory0).setInt8(arg1 + 1, enum4, true);
|
|
3627
3887
|
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
let ret;
|
|
3631
|
-
try {
|
|
3632
|
-
ret = { tag: 'ok', val: _withGlobalCurrentTaskMeta({
|
|
3633
|
-
componentIdx: task.componentIdx(),
|
|
3634
|
-
taskID: task.id(),
|
|
3635
|
-
fn: () => rsc0.getFlags()
|
|
3636
|
-
})
|
|
3637
|
-
};
|
|
3638
|
-
} catch (e) {
|
|
3639
|
-
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3640
|
-
}
|
|
3641
|
-
|
|
3642
|
-
for (const rsc of curResourceBorrows) {
|
|
3643
|
-
rsc[symbolRscHandle] = undefined;
|
|
3888
|
+
break;
|
|
3644
3889
|
}
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
case 'ok': {
|
|
3649
|
-
const e = variant5.val;
|
|
3650
|
-
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
3651
|
-
let flags3 = 0;
|
|
3652
|
-
if (typeof e === 'object' && e !== null) {
|
|
3653
|
-
flags3 = Boolean(e.read) << 0 | Boolean(e.write) << 1 | Boolean(e.fileIntegritySync) << 2 | Boolean(e.dataIntegritySync) << 3 | Boolean(e.requestedWriteSync) << 4 | Boolean(e.mutateDirectory) << 5;
|
|
3654
|
-
} else if (e !== null && e!== undefined) {
|
|
3655
|
-
throw new TypeError('only an object, undefined or null can be converted to flags');
|
|
3656
|
-
}
|
|
3657
|
-
dataView(memory0).setInt8(arg1 + 1, flags3, true);
|
|
3658
|
-
break;
|
|
3659
|
-
}
|
|
3660
|
-
case 'err': {
|
|
3661
|
-
const e = variant5.val;
|
|
3662
|
-
dataView(memory0).setInt8(arg1 + 0, 1, true);
|
|
3663
|
-
var val4 = e;
|
|
3664
|
-
let enum4;
|
|
3665
|
-
switch (val4) {
|
|
3666
|
-
case 'access': {
|
|
3667
|
-
enum4 = 0;
|
|
3668
|
-
break;
|
|
3669
|
-
}
|
|
3670
|
-
case 'would-block': {
|
|
3671
|
-
enum4 = 1;
|
|
3672
|
-
break;
|
|
3673
|
-
}
|
|
3674
|
-
case 'already': {
|
|
3675
|
-
enum4 = 2;
|
|
3676
|
-
break;
|
|
3677
|
-
}
|
|
3678
|
-
case 'bad-descriptor': {
|
|
3679
|
-
enum4 = 3;
|
|
3680
|
-
break;
|
|
3681
|
-
}
|
|
3682
|
-
case 'busy': {
|
|
3683
|
-
enum4 = 4;
|
|
3684
|
-
break;
|
|
3685
|
-
}
|
|
3686
|
-
case 'deadlock': {
|
|
3687
|
-
enum4 = 5;
|
|
3688
|
-
break;
|
|
3689
|
-
}
|
|
3690
|
-
case 'quota': {
|
|
3691
|
-
enum4 = 6;
|
|
3692
|
-
break;
|
|
3693
|
-
}
|
|
3694
|
-
case 'exist': {
|
|
3695
|
-
enum4 = 7;
|
|
3696
|
-
break;
|
|
3697
|
-
}
|
|
3698
|
-
case 'file-too-large': {
|
|
3699
|
-
enum4 = 8;
|
|
3700
|
-
break;
|
|
3701
|
-
}
|
|
3702
|
-
case 'illegal-byte-sequence': {
|
|
3703
|
-
enum4 = 9;
|
|
3704
|
-
break;
|
|
3705
|
-
}
|
|
3706
|
-
case 'in-progress': {
|
|
3707
|
-
enum4 = 10;
|
|
3708
|
-
break;
|
|
3709
|
-
}
|
|
3710
|
-
case 'interrupted': {
|
|
3711
|
-
enum4 = 11;
|
|
3712
|
-
break;
|
|
3713
|
-
}
|
|
3714
|
-
case 'invalid': {
|
|
3715
|
-
enum4 = 12;
|
|
3716
|
-
break;
|
|
3717
|
-
}
|
|
3718
|
-
case 'io': {
|
|
3719
|
-
enum4 = 13;
|
|
3720
|
-
break;
|
|
3721
|
-
}
|
|
3722
|
-
case 'is-directory': {
|
|
3723
|
-
enum4 = 14;
|
|
3724
|
-
break;
|
|
3725
|
-
}
|
|
3726
|
-
case 'loop': {
|
|
3727
|
-
enum4 = 15;
|
|
3728
|
-
break;
|
|
3729
|
-
}
|
|
3730
|
-
case 'too-many-links': {
|
|
3731
|
-
enum4 = 16;
|
|
3732
|
-
break;
|
|
3733
|
-
}
|
|
3734
|
-
case 'message-size': {
|
|
3735
|
-
enum4 = 17;
|
|
3736
|
-
break;
|
|
3737
|
-
}
|
|
3738
|
-
case 'name-too-long': {
|
|
3739
|
-
enum4 = 18;
|
|
3740
|
-
break;
|
|
3741
|
-
}
|
|
3742
|
-
case 'no-device': {
|
|
3743
|
-
enum4 = 19;
|
|
3744
|
-
break;
|
|
3745
|
-
}
|
|
3746
|
-
case 'no-entry': {
|
|
3747
|
-
enum4 = 20;
|
|
3748
|
-
break;
|
|
3749
|
-
}
|
|
3750
|
-
case 'no-lock': {
|
|
3751
|
-
enum4 = 21;
|
|
3752
|
-
break;
|
|
3753
|
-
}
|
|
3754
|
-
case 'insufficient-memory': {
|
|
3755
|
-
enum4 = 22;
|
|
3756
|
-
break;
|
|
3757
|
-
}
|
|
3758
|
-
case 'insufficient-space': {
|
|
3759
|
-
enum4 = 23;
|
|
3760
|
-
break;
|
|
3761
|
-
}
|
|
3762
|
-
case 'not-directory': {
|
|
3763
|
-
enum4 = 24;
|
|
3764
|
-
break;
|
|
3765
|
-
}
|
|
3766
|
-
case 'not-empty': {
|
|
3767
|
-
enum4 = 25;
|
|
3768
|
-
break;
|
|
3769
|
-
}
|
|
3770
|
-
case 'not-recoverable': {
|
|
3771
|
-
enum4 = 26;
|
|
3772
|
-
break;
|
|
3773
|
-
}
|
|
3774
|
-
case 'unsupported': {
|
|
3775
|
-
enum4 = 27;
|
|
3776
|
-
break;
|
|
3777
|
-
}
|
|
3778
|
-
case 'no-tty': {
|
|
3779
|
-
enum4 = 28;
|
|
3780
|
-
break;
|
|
3781
|
-
}
|
|
3782
|
-
case 'no-such-device': {
|
|
3783
|
-
enum4 = 29;
|
|
3784
|
-
break;
|
|
3785
|
-
}
|
|
3786
|
-
case 'overflow': {
|
|
3787
|
-
enum4 = 30;
|
|
3788
|
-
break;
|
|
3789
|
-
}
|
|
3790
|
-
case 'not-permitted': {
|
|
3791
|
-
enum4 = 31;
|
|
3792
|
-
break;
|
|
3793
|
-
}
|
|
3794
|
-
case 'pipe': {
|
|
3795
|
-
enum4 = 32;
|
|
3796
|
-
break;
|
|
3797
|
-
}
|
|
3798
|
-
case 'read-only': {
|
|
3799
|
-
enum4 = 33;
|
|
3800
|
-
break;
|
|
3801
|
-
}
|
|
3802
|
-
case 'invalid-seek': {
|
|
3803
|
-
enum4 = 34;
|
|
3804
|
-
break;
|
|
3805
|
-
}
|
|
3806
|
-
case 'text-file-busy': {
|
|
3807
|
-
enum4 = 35;
|
|
3808
|
-
break;
|
|
3809
|
-
}
|
|
3810
|
-
case 'cross-device': {
|
|
3811
|
-
enum4 = 36;
|
|
3812
|
-
break;
|
|
3813
|
-
}
|
|
3814
|
-
default: {
|
|
3815
|
-
if ((e) instanceof Error) {
|
|
3816
|
-
console.error(e);
|
|
3817
|
-
}
|
|
3818
|
-
|
|
3819
|
-
throw new TypeError(`"${val4}" is not one of the cases of error-code`);
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
dataView(memory0).setInt8(arg1 + 1, enum4, true);
|
|
3823
|
-
break;
|
|
3824
|
-
}
|
|
3825
|
-
default: {
|
|
3826
|
-
throw new TypeError('invalid variant specified for result');
|
|
3827
|
-
}
|
|
3890
|
+
default: {
|
|
3891
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
3892
|
+
throw new TypeError('invalid variant specified for result');
|
|
3828
3893
|
}
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3894
|
+
}
|
|
3895
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-flags"][Instruction::Return]', {
|
|
3896
|
+
funcName: '[method]descriptor.get-flags',
|
|
3897
|
+
paramCount: 0,
|
|
3898
|
+
async: false,
|
|
3899
|
+
postReturn: false
|
|
3900
|
+
});
|
|
3901
|
+
task.resolve([ret]);
|
|
3902
|
+
task.exit();
|
|
3837
3903
|
}
|
|
3838
3904
|
_trampoline12.fnName = 'wasi:filesystem/types@0.2.3#getFlags';
|
|
3839
3905
|
|
|
@@ -3954,6 +4020,7 @@ switch (variant5.tag) {
|
|
|
3954
4020
|
}
|
|
3955
4021
|
}
|
|
3956
4022
|
dataView(memory0).setInt8(arg1 + 1, enum3, true);
|
|
4023
|
+
|
|
3957
4024
|
break;
|
|
3958
4025
|
}
|
|
3959
4026
|
case 'err': {
|
|
@@ -4119,9 +4186,11 @@ switch (variant5.tag) {
|
|
|
4119
4186
|
}
|
|
4120
4187
|
}
|
|
4121
4188
|
dataView(memory0).setInt8(arg1 + 1, enum4, true);
|
|
4189
|
+
|
|
4122
4190
|
break;
|
|
4123
4191
|
}
|
|
4124
4192
|
default: {
|
|
4193
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
4125
4194
|
throw new TypeError('invalid variant specified for result');
|
|
4126
4195
|
}
|
|
4127
4196
|
}
|
|
@@ -4212,6 +4281,7 @@ switch (variant5.tag) {
|
|
|
4212
4281
|
var {lower: v3_0, upper: v3_1 } = e;
|
|
4213
4282
|
dataView(memory0).setBigInt64(arg1 + 8, toUint64(v3_0), true);
|
|
4214
4283
|
dataView(memory0).setBigInt64(arg1 + 16, toUint64(v3_1), true);
|
|
4284
|
+
|
|
4215
4285
|
break;
|
|
4216
4286
|
}
|
|
4217
4287
|
case 'err': {
|
|
@@ -4377,9 +4447,11 @@ switch (variant5.tag) {
|
|
|
4377
4447
|
}
|
|
4378
4448
|
}
|
|
4379
4449
|
dataView(memory0).setInt8(arg1 + 8, enum4, true);
|
|
4450
|
+
|
|
4380
4451
|
break;
|
|
4381
4452
|
}
|
|
4382
4453
|
default: {
|
|
4454
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
4383
4455
|
throw new TypeError('invalid variant specified for result');
|
|
4384
4456
|
}
|
|
4385
4457
|
}
|
|
@@ -4722,6 +4794,7 @@ switch (variant7.tag) {
|
|
|
4722
4794
|
var {lower: v5_0, upper: v5_1 } = e;
|
|
4723
4795
|
dataView(memory0).setBigInt64(arg4 + 8, toUint64(v5_0), true);
|
|
4724
4796
|
dataView(memory0).setBigInt64(arg4 + 16, toUint64(v5_1), true);
|
|
4797
|
+
|
|
4725
4798
|
break;
|
|
4726
4799
|
}
|
|
4727
4800
|
case 'err': {
|
|
@@ -4887,9 +4960,11 @@ switch (variant7.tag) {
|
|
|
4887
4960
|
}
|
|
4888
4961
|
}
|
|
4889
4962
|
dataView(memory0).setInt8(arg4 + 8, enum6, true);
|
|
4963
|
+
|
|
4890
4964
|
break;
|
|
4891
4965
|
}
|
|
4892
4966
|
default: {
|
|
4967
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant7, valueType: typeof variant7});
|
|
4893
4968
|
throw new TypeError('invalid variant specified for result');
|
|
4894
4969
|
}
|
|
4895
4970
|
}
|
|
@@ -4987,6 +5062,7 @@ switch (variant5.tag) {
|
|
|
4987
5062
|
handle3 = rscTableCreateOwn(handleTable1, rep);
|
|
4988
5063
|
}
|
|
4989
5064
|
dataView(memory0).setInt32(arg2 + 4, handle3, true);
|
|
5065
|
+
|
|
4990
5066
|
break;
|
|
4991
5067
|
}
|
|
4992
5068
|
case 'err': {
|
|
@@ -5152,9 +5228,11 @@ switch (variant5.tag) {
|
|
|
5152
5228
|
}
|
|
5153
5229
|
}
|
|
5154
5230
|
dataView(memory0).setInt8(arg2 + 4, enum4, true);
|
|
5231
|
+
|
|
5155
5232
|
break;
|
|
5156
5233
|
}
|
|
5157
5234
|
default: {
|
|
5235
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5158
5236
|
throw new TypeError('invalid variant specified for result');
|
|
5159
5237
|
}
|
|
5160
5238
|
}
|
|
@@ -5252,6 +5330,7 @@ switch (variant5.tag) {
|
|
|
5252
5330
|
handle3 = rscTableCreateOwn(handleTable2, rep);
|
|
5253
5331
|
}
|
|
5254
5332
|
dataView(memory0).setInt32(arg2 + 4, handle3, true);
|
|
5333
|
+
|
|
5255
5334
|
break;
|
|
5256
5335
|
}
|
|
5257
5336
|
case 'err': {
|
|
@@ -5417,9 +5496,11 @@ switch (variant5.tag) {
|
|
|
5417
5496
|
}
|
|
5418
5497
|
}
|
|
5419
5498
|
dataView(memory0).setInt8(arg2 + 4, enum4, true);
|
|
5499
|
+
|
|
5420
5500
|
break;
|
|
5421
5501
|
}
|
|
5422
5502
|
default: {
|
|
5503
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5423
5504
|
throw new TypeError('invalid variant specified for result');
|
|
5424
5505
|
}
|
|
5425
5506
|
}
|
|
@@ -5517,6 +5598,7 @@ switch (variant5.tag) {
|
|
|
5517
5598
|
handle3 = rscTableCreateOwn(handleTable2, rep);
|
|
5518
5599
|
}
|
|
5519
5600
|
dataView(memory0).setInt32(arg1 + 4, handle3, true);
|
|
5601
|
+
|
|
5520
5602
|
break;
|
|
5521
5603
|
}
|
|
5522
5604
|
case 'err': {
|
|
@@ -5682,9 +5764,11 @@ switch (variant5.tag) {
|
|
|
5682
5764
|
}
|
|
5683
5765
|
}
|
|
5684
5766
|
dataView(memory0).setInt8(arg1 + 4, enum4, true);
|
|
5767
|
+
|
|
5685
5768
|
break;
|
|
5686
5769
|
}
|
|
5687
5770
|
default: {
|
|
5771
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5688
5772
|
throw new TypeError('invalid variant specified for result');
|
|
5689
5773
|
}
|
|
5690
5774
|
}
|
|
@@ -5786,6 +5870,7 @@ switch (variant5.tag) {
|
|
|
5786
5870
|
handle3 = rscTableCreateOwn(handleTable5, rep);
|
|
5787
5871
|
}
|
|
5788
5872
|
dataView(memory0).setInt32(arg1 + 4, handle3, true);
|
|
5873
|
+
|
|
5789
5874
|
break;
|
|
5790
5875
|
}
|
|
5791
5876
|
case 'err': {
|
|
@@ -5951,9 +6036,11 @@ switch (variant5.tag) {
|
|
|
5951
6036
|
}
|
|
5952
6037
|
}
|
|
5953
6038
|
dataView(memory0).setInt8(arg1 + 4, enum4, true);
|
|
6039
|
+
|
|
5954
6040
|
break;
|
|
5955
6041
|
}
|
|
5956
6042
|
default: {
|
|
6043
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5957
6044
|
throw new TypeError('invalid variant specified for result');
|
|
5958
6045
|
}
|
|
5959
6046
|
}
|
|
@@ -6118,6 +6205,7 @@ switch (variant12.tag) {
|
|
|
6118
6205
|
dataView(memory0).setBigInt64(arg1 + 88, toUint64(v9_0), true);
|
|
6119
6206
|
dataView(memory0).setInt32(arg1 + 96, toUint32(v9_1), true);
|
|
6120
6207
|
}
|
|
6208
|
+
|
|
6121
6209
|
break;
|
|
6122
6210
|
}
|
|
6123
6211
|
case 'err': {
|
|
@@ -6283,9 +6371,11 @@ switch (variant12.tag) {
|
|
|
6283
6371
|
}
|
|
6284
6372
|
}
|
|
6285
6373
|
dataView(memory0).setInt8(arg1 + 8, enum11, true);
|
|
6374
|
+
|
|
6286
6375
|
break;
|
|
6287
6376
|
}
|
|
6288
6377
|
default: {
|
|
6378
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant12, valueType: typeof variant12});
|
|
6289
6379
|
throw new TypeError('invalid variant specified for result');
|
|
6290
6380
|
}
|
|
6291
6381
|
}
|
|
@@ -6459,6 +6549,7 @@ switch (variant14.tag) {
|
|
|
6459
6549
|
dataView(memory0).setBigInt64(arg4 + 88, toUint64(v11_0), true);
|
|
6460
6550
|
dataView(memory0).setInt32(arg4 + 96, toUint32(v11_1), true);
|
|
6461
6551
|
}
|
|
6552
|
+
|
|
6462
6553
|
break;
|
|
6463
6554
|
}
|
|
6464
6555
|
case 'err': {
|
|
@@ -6624,9 +6715,11 @@ switch (variant14.tag) {
|
|
|
6624
6715
|
}
|
|
6625
6716
|
}
|
|
6626
6717
|
dataView(memory0).setInt8(arg4 + 8, enum13, true);
|
|
6718
|
+
|
|
6627
6719
|
break;
|
|
6628
6720
|
}
|
|
6629
6721
|
default: {
|
|
6722
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant14, valueType: typeof variant14});
|
|
6630
6723
|
throw new TypeError('invalid variant specified for result');
|
|
6631
6724
|
}
|
|
6632
6725
|
}
|
|
@@ -6753,6 +6846,7 @@ switch (variant9.tag) {
|
|
|
6753
6846
|
handle7 = rscTableCreateOwn(handleTable6, rep);
|
|
6754
6847
|
}
|
|
6755
6848
|
dataView(memory0).setInt32(arg6 + 4, handle7, true);
|
|
6849
|
+
|
|
6756
6850
|
break;
|
|
6757
6851
|
}
|
|
6758
6852
|
case 'err': {
|
|
@@ -6918,9 +7012,11 @@ switch (variant9.tag) {
|
|
|
6918
7012
|
}
|
|
6919
7013
|
}
|
|
6920
7014
|
dataView(memory0).setInt8(arg6 + 4, enum8, true);
|
|
7015
|
+
|
|
6921
7016
|
break;
|
|
6922
7017
|
}
|
|
6923
7018
|
default: {
|
|
7019
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant9, valueType: typeof variant9});
|
|
6924
7020
|
throw new TypeError('invalid variant specified for result');
|
|
6925
7021
|
}
|
|
6926
7022
|
}
|
|
@@ -7067,6 +7163,7 @@ switch (variant8.tag) {
|
|
|
7067
7163
|
dataView(memory0).setUint32(arg1 + 16, len5, true);
|
|
7068
7164
|
dataView(memory0).setUint32(arg1 + 12, ptr5, true);
|
|
7069
7165
|
}
|
|
7166
|
+
|
|
7070
7167
|
break;
|
|
7071
7168
|
}
|
|
7072
7169
|
case 'err': {
|
|
@@ -7232,9 +7329,11 @@ switch (variant8.tag) {
|
|
|
7232
7329
|
}
|
|
7233
7330
|
}
|
|
7234
7331
|
dataView(memory0).setInt8(arg1 + 4, enum7, true);
|
|
7332
|
+
|
|
7235
7333
|
break;
|
|
7236
7334
|
}
|
|
7237
7335
|
default: {
|
|
7336
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant8, valueType: typeof variant8});
|
|
7238
7337
|
throw new TypeError('invalid variant specified for result');
|
|
7239
7338
|
}
|
|
7240
7339
|
}
|
|
@@ -7323,7 +7422,7 @@ switch (variant6.tag) {
|
|
|
7323
7422
|
const e = variant6.val;
|
|
7324
7423
|
dataView(memory0).setInt8(arg2 + 0, 0, true);
|
|
7325
7424
|
var val3 = e;
|
|
7326
|
-
var len3 = val3.byteLength;
|
|
7425
|
+
var len3 = Array.isArray(val3) ? val3.length : val3.byteLength;
|
|
7327
7426
|
var ptr3 = realloc0(0, 0, 1, len3 * 1);
|
|
7328
7427
|
|
|
7329
7428
|
let valData3;
|
|
@@ -7345,6 +7444,7 @@ switch (variant6.tag) {
|
|
|
7345
7444
|
|
|
7346
7445
|
dataView(memory0).setUint32(arg2 + 8, len3, true);
|
|
7347
7446
|
dataView(memory0).setUint32(arg2 + 4, ptr3, true);
|
|
7447
|
+
|
|
7348
7448
|
break;
|
|
7349
7449
|
}
|
|
7350
7450
|
case 'err': {
|
|
@@ -7375,9 +7475,11 @@ switch (variant6.tag) {
|
|
|
7375
7475
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7376
7476
|
}
|
|
7377
7477
|
}
|
|
7478
|
+
|
|
7378
7479
|
break;
|
|
7379
7480
|
}
|
|
7380
7481
|
default: {
|
|
7482
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7381
7483
|
throw new TypeError('invalid variant specified for result');
|
|
7382
7484
|
}
|
|
7383
7485
|
}
|
|
@@ -7466,7 +7568,7 @@ switch (variant6.tag) {
|
|
|
7466
7568
|
const e = variant6.val;
|
|
7467
7569
|
dataView(memory0).setInt8(arg2 + 0, 0, true);
|
|
7468
7570
|
var val3 = e;
|
|
7469
|
-
var len3 = val3.byteLength;
|
|
7571
|
+
var len3 = Array.isArray(val3) ? val3.length : val3.byteLength;
|
|
7470
7572
|
var ptr3 = realloc0(0, 0, 1, len3 * 1);
|
|
7471
7573
|
|
|
7472
7574
|
let valData3;
|
|
@@ -7488,6 +7590,7 @@ switch (variant6.tag) {
|
|
|
7488
7590
|
|
|
7489
7591
|
dataView(memory0).setUint32(arg2 + 8, len3, true);
|
|
7490
7592
|
dataView(memory0).setUint32(arg2 + 4, ptr3, true);
|
|
7593
|
+
|
|
7491
7594
|
break;
|
|
7492
7595
|
}
|
|
7493
7596
|
case 'err': {
|
|
@@ -7518,9 +7621,11 @@ switch (variant6.tag) {
|
|
|
7518
7621
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7519
7622
|
}
|
|
7520
7623
|
}
|
|
7624
|
+
|
|
7521
7625
|
break;
|
|
7522
7626
|
}
|
|
7523
7627
|
default: {
|
|
7628
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7524
7629
|
throw new TypeError('invalid variant specified for result');
|
|
7525
7630
|
}
|
|
7526
7631
|
}
|
|
@@ -7609,6 +7714,7 @@ switch (variant5.tag) {
|
|
|
7609
7714
|
const e = variant5.val;
|
|
7610
7715
|
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
7611
7716
|
dataView(memory0).setBigInt64(arg1 + 8, toUint64(e), true);
|
|
7717
|
+
|
|
7612
7718
|
break;
|
|
7613
7719
|
}
|
|
7614
7720
|
case 'err': {
|
|
@@ -7639,9 +7745,11 @@ switch (variant5.tag) {
|
|
|
7639
7745
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant4.tag)}\` (received \`${variant4}\`) specified for \`StreamError\``);
|
|
7640
7746
|
}
|
|
7641
7747
|
}
|
|
7748
|
+
|
|
7642
7749
|
break;
|
|
7643
7750
|
}
|
|
7644
7751
|
default: {
|
|
7752
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
7645
7753
|
throw new TypeError('invalid variant specified for result');
|
|
7646
7754
|
}
|
|
7647
7755
|
}
|
|
@@ -7732,6 +7840,7 @@ switch (variant6.tag) {
|
|
|
7732
7840
|
case 'ok': {
|
|
7733
7841
|
const e = variant6.val;
|
|
7734
7842
|
dataView(memory0).setInt8(arg3 + 0, 0, true);
|
|
7843
|
+
|
|
7735
7844
|
break;
|
|
7736
7845
|
}
|
|
7737
7846
|
case 'err': {
|
|
@@ -7762,9 +7871,11 @@ switch (variant6.tag) {
|
|
|
7762
7871
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7763
7872
|
}
|
|
7764
7873
|
}
|
|
7874
|
+
|
|
7765
7875
|
break;
|
|
7766
7876
|
}
|
|
7767
7877
|
default: {
|
|
7878
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7768
7879
|
throw new TypeError('invalid variant specified for result');
|
|
7769
7880
|
}
|
|
7770
7881
|
}
|
|
@@ -7855,6 +7966,7 @@ switch (variant6.tag) {
|
|
|
7855
7966
|
case 'ok': {
|
|
7856
7967
|
const e = variant6.val;
|
|
7857
7968
|
dataView(memory0).setInt8(arg3 + 0, 0, true);
|
|
7969
|
+
|
|
7858
7970
|
break;
|
|
7859
7971
|
}
|
|
7860
7972
|
case 'err': {
|
|
@@ -7885,9 +7997,11 @@ switch (variant6.tag) {
|
|
|
7885
7997
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7886
7998
|
}
|
|
7887
7999
|
}
|
|
8000
|
+
|
|
7888
8001
|
break;
|
|
7889
8002
|
}
|
|
7890
8003
|
default: {
|
|
8004
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7891
8005
|
throw new TypeError('invalid variant specified for result');
|
|
7892
8006
|
}
|
|
7893
8007
|
}
|
|
@@ -7975,6 +8089,7 @@ switch (variant5.tag) {
|
|
|
7975
8089
|
case 'ok': {
|
|
7976
8090
|
const e = variant5.val;
|
|
7977
8091
|
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
8092
|
+
|
|
7978
8093
|
break;
|
|
7979
8094
|
}
|
|
7980
8095
|
case 'err': {
|
|
@@ -8005,9 +8120,11 @@ switch (variant5.tag) {
|
|
|
8005
8120
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant4.tag)}\` (received \`${variant4}\`) specified for \`StreamError\``);
|
|
8006
8121
|
}
|
|
8007
8122
|
}
|
|
8123
|
+
|
|
8008
8124
|
break;
|
|
8009
8125
|
}
|
|
8010
8126
|
default: {
|
|
8127
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
8011
8128
|
throw new TypeError('invalid variant specified for result');
|
|
8012
8129
|
}
|
|
8013
8130
|
}
|
|
@@ -8069,7 +8186,7 @@ const _trampoline31 = function(arg0, arg1) {
|
|
|
8069
8186
|
})
|
|
8070
8187
|
;
|
|
8071
8188
|
var val0 = ret;
|
|
8072
|
-
var len0 = val0.byteLength;
|
|
8189
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
8073
8190
|
var ptr0 = realloc0(0, 0, 1, len0 * 1);
|
|
8074
8191
|
|
|
8075
8192
|
let valData0;
|
|
@@ -8852,7 +8969,7 @@ null,
|
|
|
8852
8969
|
componentIdx: 0,
|
|
8853
8970
|
isAsync: false,
|
|
8854
8971
|
isManualAsync: _trampoline16.manuallyAsync,
|
|
8855
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
8972
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
8856
8973
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatRecord.bind(null, [['lower', _lowerFlatU64, 16, 8 ],['upper', _lowerFlatU64, 16, 8 ],]), 24, 8, 8 ],[ 'err', _lowerFlatEnum.bind(null, 0), 24, 8, 8 ],])],
|
|
8857
8974
|
funcTypeIsAsync: false,
|
|
8858
8975
|
getCallbackFn: () => null,
|
|
@@ -8870,7 +8987,7 @@ null,
|
|
|
8870
8987
|
componentIdx: 0,
|
|
8871
8988
|
isAsync: false,
|
|
8872
8989
|
isManualAsync: _trampoline16.manuallyAsync,
|
|
8873
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
8990
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
8874
8991
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatRecord.bind(null, [['lower', _lowerFlatU64, 16, 8 ],['upper', _lowerFlatU64, 16, 8 ],]), 24, 8, 8 ],[ 'err', _lowerFlatEnum.bind(null, 0), 24, 8, 8 ],])],
|
|
8875
8992
|
funcTypeIsAsync: false,
|
|
8876
8993
|
getCallbackFn: () => null,
|
|
@@ -9074,7 +9191,7 @@ null,
|
|
|
9074
9191
|
componentIdx: 0,
|
|
9075
9192
|
isAsync: false,
|
|
9076
9193
|
isManualAsync: _trampoline22.manuallyAsync,
|
|
9077
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9194
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
9078
9195
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatRecord.bind(null, [['type', _lowerFlatEnum.bind(null, 1), 96, 8 ],['linkCount', _lowerFlatU64, 96, 8 ],['size', _lowerFlatU64, 96, 8 ],['dataAccessTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],['dataModificationTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],['statusChangeTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],]), 104, 8, 8 ],[ 'err', _lowerFlatEnum.bind(null, 0), 104, 8, 8 ],])],
|
|
9079
9196
|
funcTypeIsAsync: false,
|
|
9080
9197
|
getCallbackFn: () => null,
|
|
@@ -9092,7 +9209,7 @@ null,
|
|
|
9092
9209
|
componentIdx: 0,
|
|
9093
9210
|
isAsync: false,
|
|
9094
9211
|
isManualAsync: _trampoline22.manuallyAsync,
|
|
9095
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9212
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
9096
9213
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatRecord.bind(null, [['type', _lowerFlatEnum.bind(null, 1), 96, 8 ],['linkCount', _lowerFlatU64, 96, 8 ],['size', _lowerFlatU64, 96, 8 ],['dataAccessTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],['dataModificationTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],['statusChangeTimestamp', _lowerFlatOption([[ 'some', _lowerFlatRecord.bind(null, [['seconds', _lowerFlatU64, 16, 8 ],['nanoseconds', _lowerFlatU32, 16, 8 ],]), 24, 8, 8 ],[ 'none', null, 24, 8, 8 ],]), 96, 8 ],]), 104, 8, 8 ],[ 'err', _lowerFlatEnum.bind(null, 0), 104, 8, 8 ],])],
|
|
9097
9214
|
funcTypeIsAsync: false,
|
|
9098
9215
|
getCallbackFn: () => null,
|
|
@@ -9111,7 +9228,7 @@ null,
|
|
|
9111
9228
|
componentIdx: 0,
|
|
9112
9229
|
isAsync: false,
|
|
9113
9230
|
isManualAsync: _trampoline23.manuallyAsync,
|
|
9114
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9231
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8,_liftFlatFlags({ names: ['create','directory','exclusive','truncate'], size32: 1, align32: 1, intSize: 1 }),_liftFlatFlags({ names: ['read','write','file-integrity-sync','data-integrity-sync','requested-write-sync','mutate-directory'], size32: 1, align32: 1, intSize: 1 })],
|
|
9115
9232
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatOwn.bind(null, 6), 8, 4, 4 ],[ 'err', _lowerFlatEnum.bind(null, 0), 8, 4, 4 ],])],
|
|
9116
9233
|
funcTypeIsAsync: false,
|
|
9117
9234
|
getCallbackFn: () => null,
|
|
@@ -9129,7 +9246,7 @@ null,
|
|
|
9129
9246
|
componentIdx: 0,
|
|
9130
9247
|
isAsync: false,
|
|
9131
9248
|
isManualAsync: _trampoline23.manuallyAsync,
|
|
9132
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9249
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8,_liftFlatFlags({ names: ['create','directory','exclusive','truncate'], size32: 1, align32: 1, intSize: 1 }),_liftFlatFlags({ names: ['read','write','file-integrity-sync','data-integrity-sync','requested-write-sync','mutate-directory'], size32: 1, align32: 1, intSize: 1 })],
|
|
9133
9250
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatOwn.bind(null, 6), 8, 4, 4 ],[ 'err', _lowerFlatEnum.bind(null, 0), 8, 4, 4 ],])],
|
|
9134
9251
|
funcTypeIsAsync: false,
|
|
9135
9252
|
getCallbackFn: () => null,
|
|
@@ -9296,7 +9413,7 @@ null,
|
|
|
9296
9413
|
componentIdx: 0,
|
|
9297
9414
|
isAsync: false,
|
|
9298
9415
|
isManualAsync: _trampoline28.manuallyAsync,
|
|
9299
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9416
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9300
9417
|
resultLowerFns: [_lowerFlatResult([[ 'ok', null, 12, 4, 4 ],[ 'err', _lowerFlatVariant([[ 'last-operation-failed', _lowerFlatOwn.bind(null, 0), 8, 4, 4 ],[ 'closed', null, 8, 4, 4 ],]), 12, 4, 4 ],])],
|
|
9301
9418
|
funcTypeIsAsync: false,
|
|
9302
9419
|
getCallbackFn: () => null,
|
|
@@ -9314,7 +9431,7 @@ null,
|
|
|
9314
9431
|
componentIdx: 0,
|
|
9315
9432
|
isAsync: false,
|
|
9316
9433
|
isManualAsync: _trampoline28.manuallyAsync,
|
|
9317
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9434
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9318
9435
|
resultLowerFns: [_lowerFlatResult([[ 'ok', null, 12, 4, 4 ],[ 'err', _lowerFlatVariant([[ 'last-operation-failed', _lowerFlatOwn.bind(null, 0), 8, 4, 4 ],[ 'closed', null, 8, 4, 4 ],]), 12, 4, 4 ],])],
|
|
9319
9436
|
funcTypeIsAsync: false,
|
|
9320
9437
|
getCallbackFn: () => null,
|
|
@@ -9333,7 +9450,7 @@ null,
|
|
|
9333
9450
|
componentIdx: 0,
|
|
9334
9451
|
isAsync: false,
|
|
9335
9452
|
isManualAsync: _trampoline29.manuallyAsync,
|
|
9336
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9453
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9337
9454
|
resultLowerFns: [_lowerFlatResult([[ 'ok', null, 12, 4, 4 ],[ 'err', _lowerFlatVariant([[ 'last-operation-failed', _lowerFlatOwn.bind(null, 0), 8, 4, 4 ],[ 'closed', null, 8, 4, 4 ],]), 12, 4, 4 ],])],
|
|
9338
9455
|
funcTypeIsAsync: false,
|
|
9339
9456
|
getCallbackFn: () => null,
|
|
@@ -9351,7 +9468,7 @@ null,
|
|
|
9351
9468
|
componentIdx: 0,
|
|
9352
9469
|
isAsync: false,
|
|
9353
9470
|
isManualAsync: _trampoline29.manuallyAsync,
|
|
9354
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9471
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9355
9472
|
resultLowerFns: [_lowerFlatResult([[ 'ok', null, 12, 4, 4 ],[ 'err', _lowerFlatVariant([[ 'last-operation-failed', _lowerFlatOwn.bind(null, 0), 8, 4, 4 ],[ 'closed', null, 8, 4, 4 ],]), 12, 4, 4 ],])],
|
|
9356
9473
|
funcTypeIsAsync: false,
|
|
9357
9474
|
getCallbackFn: () => null,
|
|
@@ -9676,7 +9793,7 @@ let toolsPrint;
|
|
|
9676
9793
|
function print(arg0) {
|
|
9677
9794
|
if (!_initialized) throwUninitialized();
|
|
9678
9795
|
var val0 = arg0;
|
|
9679
|
-
var len0 = val0.byteLength;
|
|
9796
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
9680
9797
|
var ptr0 = realloc1(0, 0, 1, len0 * 1);
|
|
9681
9798
|
|
|
9682
9799
|
let valData0;
|
|
@@ -9778,7 +9895,7 @@ let toolsComponentNew;
|
|
|
9778
9895
|
function componentNew(arg0, arg1) {
|
|
9779
9896
|
if (!_initialized) throwUninitialized();
|
|
9780
9897
|
var val0 = arg0;
|
|
9781
|
-
var len0 = val0.byteLength;
|
|
9898
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
9782
9899
|
var ptr0 = realloc1(0, 0, 1, len0 * 1);
|
|
9783
9900
|
|
|
9784
9901
|
let valData0;
|
|
@@ -9822,7 +9939,7 @@ function componentNew(arg0, arg1) {
|
|
|
9822
9939
|
dataView(memory0).setUint32(base + 4, len2, true);
|
|
9823
9940
|
dataView(memory0).setUint32(base + 0, ptr2, true);
|
|
9824
9941
|
var val3 = tuple1_1;
|
|
9825
|
-
var len3 = val3.byteLength;
|
|
9942
|
+
var len3 = Array.isArray(val3) ? val3.length : val3.byteLength;
|
|
9826
9943
|
var ptr3 = realloc1(0, 0, 1, len3 * 1);
|
|
9827
9944
|
|
|
9828
9945
|
let valData3;
|
|
@@ -9931,7 +10048,7 @@ let toolsComponentWit;
|
|
|
9931
10048
|
function componentWit(arg0) {
|
|
9932
10049
|
if (!_initialized) throwUninitialized();
|
|
9933
10050
|
var val0 = arg0;
|
|
9934
|
-
var len0 = val0.byteLength;
|
|
10051
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
9935
10052
|
var ptr0 = realloc1(0, 0, 1, len0 * 1);
|
|
9936
10053
|
|
|
9937
10054
|
let valData0;
|
|
@@ -10041,7 +10158,7 @@ function componentEmbed(arg0) {
|
|
|
10041
10158
|
const e = variant3;
|
|
10042
10159
|
dataView(memory0).setInt8(ptr0 + 0, 1, true);
|
|
10043
10160
|
var val2 = e;
|
|
10044
|
-
var len2 = val2.byteLength;
|
|
10161
|
+
var len2 = Array.isArray(val2) ? val2.length : val2.byteLength;
|
|
10045
10162
|
var ptr2 = realloc1(0, 0, 1, len2 * 1);
|
|
10046
10163
|
|
|
10047
10164
|
let valData2;
|
|
@@ -10310,7 +10427,7 @@ let toolsMetadataShow;
|
|
|
10310
10427
|
function metadataShow(arg0) {
|
|
10311
10428
|
if (!_initialized) throwUninitialized();
|
|
10312
10429
|
var val0 = arg0;
|
|
10313
|
-
var len0 = val0.byteLength;
|
|
10430
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
10314
10431
|
var ptr0 = realloc1(0, 0, 1, len0 * 1);
|
|
10315
10432
|
|
|
10316
10433
|
let valData0;
|
|
@@ -10495,7 +10612,7 @@ let toolsMetadataAdd;
|
|
|
10495
10612
|
function metadataAdd(arg0, arg1) {
|
|
10496
10613
|
if (!_initialized) throwUninitialized();
|
|
10497
10614
|
var val0 = arg0;
|
|
10498
|
-
var len0 = val0.byteLength;
|
|
10615
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
10499
10616
|
var ptr0 = realloc1(0, 0, 1, len0 * 1);
|
|
10500
10617
|
|
|
10501
10618
|
let valData0;
|