@bytecodealliance/jco 1.17.3 → 1.17.5
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 +1514 -1342
- package/obj/wasm-tools.js +1519 -1347
- package/package.json +1 -1
|
@@ -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 });
|
|
@@ -2050,10 +2051,52 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2050
2051
|
importFn,
|
|
2051
2052
|
} = args;
|
|
2052
2053
|
|
|
2053
|
-
|
|
2054
|
+
let meta = _getGlobalCurrentTaskMeta(componentIdx);
|
|
2055
|
+
let createdTask;
|
|
2056
|
+
|
|
2057
|
+
// Some components depend on initialization logic (i.e. `_initialize` or some such
|
|
2058
|
+
// core wasm export) that is embedded in the component, but is not executed or wizer'd
|
|
2059
|
+
// away before the transpiled component is attempted to be used.
|
|
2060
|
+
//
|
|
2061
|
+
// These components execut their initialization logic *when they are imported* in the
|
|
2062
|
+
// transpiled context -- so we may get a call to an export that is lowered without going
|
|
2063
|
+
// through `CallWasm` or `CallInterface`.
|
|
2064
|
+
//
|
|
2065
|
+
if (!meta) {
|
|
2066
|
+
if (funcTypeIsAsync || (isAsync && !isManualAsync)) {
|
|
2067
|
+
throw new Error('p3 async wasm exports cannot use backwards compat auto-task init');
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
const [newTask, newTaskID] = createNewCurrentTask({
|
|
2071
|
+
componentIdx,
|
|
2072
|
+
isAsync,
|
|
2073
|
+
isManualAsync,
|
|
2074
|
+
callingWasmExport: false,
|
|
2075
|
+
});
|
|
2076
|
+
createdTask = newTask;
|
|
2077
|
+
|
|
2078
|
+
// Since we're managing the task creation ourselves we must clear ourselves
|
|
2079
|
+
createdTask.registerOnResolveHandler(() => {
|
|
2080
|
+
_clearCurrentTask({
|
|
2081
|
+
taskID: task.id(),
|
|
2082
|
+
componentIdx: task.componentIdx(),
|
|
2083
|
+
});
|
|
2084
|
+
});
|
|
2085
|
+
|
|
2086
|
+
_setGlobalCurrentTaskMeta({
|
|
2087
|
+
componentIdx,
|
|
2088
|
+
taskID: newTaskID,
|
|
2089
|
+
});
|
|
2090
|
+
|
|
2091
|
+
meta = _getGlobalCurrentTaskMeta(componentIdx);
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
const { taskID } = meta;
|
|
2054
2095
|
|
|
2055
2096
|
const taskMeta = getCurrentTask(componentIdx, taskID);
|
|
2056
|
-
if (!taskMeta) {
|
|
2097
|
+
if (!taskMeta) {
|
|
2098
|
+
throw new Error('invalid/missing async task meta');
|
|
2099
|
+
}
|
|
2057
2100
|
|
|
2058
2101
|
const task = taskMeta.task;
|
|
2059
2102
|
if (!task) { throw new Error('invalid/missing async task'); }
|
|
@@ -2097,13 +2140,20 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2097
2140
|
// TODO(breaking): remove once we get rid of manual async import specification,
|
|
2098
2141
|
// as func types cannot be detected in that case only (and we don't need that w/ p3)
|
|
2099
2142
|
if (!isManualAsync && !isAsync && !funcTypeIsAsync) {
|
|
2143
|
+
if (createdTask) { createdTask.enterSync(); }
|
|
2144
|
+
|
|
2100
2145
|
const res = importFn(...params);
|
|
2146
|
+
|
|
2101
2147
|
// TODO(breaking): remove once we get rid of manual async import specification,
|
|
2102
2148
|
// as func types cannot be detected in that case only (and we don't need that w/ p3)
|
|
2103
2149
|
if (!funcTypeIsAsync && !subtask.isReturned()) {
|
|
2104
2150
|
throw new Error('post-execution subtasks must either be async or returned');
|
|
2105
2151
|
}
|
|
2106
|
-
|
|
2152
|
+
|
|
2153
|
+
const syncRes = subtask.getResult();
|
|
2154
|
+
if (createdTask) { createdTask.resolve([syncRes]); }
|
|
2155
|
+
|
|
2156
|
+
return syncRes;
|
|
2107
2157
|
}
|
|
2108
2158
|
|
|
2109
2159
|
// Sync-lowered async functions requires async behavior because the callee *can* block,
|
|
@@ -2172,10 +2222,16 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2172
2222
|
queueMicrotask(async () => {
|
|
2173
2223
|
try {
|
|
2174
2224
|
_debugLog('[_lowerImportBackwardsCompat()] calling lowered import', { importFn, params });
|
|
2175
|
-
|
|
2225
|
+
if (createdTask) { await createdTask.enter(); }
|
|
2226
|
+
|
|
2227
|
+
const asyncRes = await importFn(...params);
|
|
2176
2228
|
if (requiresManualAsyncResult) {
|
|
2177
2229
|
manualAsyncResult.resolve(subtask.getResult());
|
|
2178
2230
|
}
|
|
2231
|
+
|
|
2232
|
+
if (createdTask) { createdTask.resolve([asyncRes]); }
|
|
2233
|
+
|
|
2234
|
+
|
|
2179
2235
|
} catch (err) {
|
|
2180
2236
|
_debugLog("[_lowerImportBackwardsCompat()] import fn error:", err);
|
|
2181
2237
|
if (requiresManualAsyncResult) {
|
|
@@ -2204,7 +2260,9 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2204
2260
|
if (ctx.storageLen !== undefined && ctx.storageLen < ctx.storagePtr + 1) {
|
|
2205
2261
|
throw new Error('not enough storage remaining for lift');
|
|
2206
2262
|
}
|
|
2263
|
+
|
|
2207
2264
|
val = new DataView(ctx.memory.buffer).getUint8(ctx.storagePtr, true);
|
|
2265
|
+
|
|
2208
2266
|
ctx.storagePtr += 1;
|
|
2209
2267
|
if (ctx.storageLen !== undefined) { ctx.storageLen -= 1; }
|
|
2210
2268
|
|
|
@@ -2361,47 +2419,11 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2361
2419
|
}
|
|
2362
2420
|
}
|
|
2363
2421
|
|
|
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
|
-
|
|
2422
|
+
function _liftFlatList(meta) {
|
|
2423
|
+
const { elemLiftFn, align32, knownLen } = meta;
|
|
2424
|
+
|
|
2425
|
+
const readValuesAndReset = (ctx, originalPtr, dataPtr, len) => {
|
|
2426
|
+
ctx.storagePtr = dataPtr;
|
|
2405
2427
|
const val = [];
|
|
2406
2428
|
for (var i = 0; i < len; i++) {
|
|
2407
2429
|
const [res, nextCtx] = elemLiftFn(ctx);
|
|
@@ -2409,1431 +2431,1530 @@ function _lowerImportBackwardsCompat(args) {
|
|
|
2409
2431
|
ctx = nextCtx;
|
|
2410
2432
|
|
|
2411
2433
|
const rem = ctx.storagePtr % align32;
|
|
2412
|
-
if (rem !== 0) {
|
|
2434
|
+
if (rem !== 0) { ctx.storagePtr += align32 - rem; }
|
|
2413
2435
|
}
|
|
2414
|
-
|
|
2436
|
+
if (originalPtr !== null) { ctx.storagePtr = originalPtr; }
|
|
2415
2437
|
return [val, ctx];
|
|
2438
|
+
};
|
|
2439
|
+
|
|
2440
|
+
return function _liftFlatListInner(ctx) {
|
|
2441
|
+
_debugLog('[_liftFlatList()] args', { ctx });
|
|
2442
|
+
|
|
2443
|
+
let liftResults;
|
|
2444
|
+
if (knownLen) { // list with known length
|
|
2445
|
+
|
|
2446
|
+
if (ctx.useDirectParams) {
|
|
2447
|
+
// list with known length w/ direct params
|
|
2448
|
+
const dataPtr = ctx.params[0];
|
|
2449
|
+
ctx.params = ctx.params.slice(1);
|
|
2450
|
+
|
|
2451
|
+
// TODO: is it possible for all values to come in from params?
|
|
2452
|
+
|
|
2453
|
+
ctx.useDirectParams = false;
|
|
2454
|
+
const originalPtr = ctx.storagePtr;
|
|
2455
|
+
ctx.storageLen = 8;
|
|
2456
|
+
|
|
2457
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2458
|
+
|
|
2459
|
+
ctx.useDirectParams = true;
|
|
2460
|
+
ctx.storagePtr = null;
|
|
2461
|
+
ctx.storageLen = null;
|
|
2462
|
+
|
|
2463
|
+
} else {
|
|
2464
|
+
liftResults = readValuesAndReset(ctx, null, ctx.storagePtr, knownLen);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
} else { // unknown length list
|
|
2468
|
+
|
|
2469
|
+
if (ctx.useDirectParams) {
|
|
2470
|
+
// unknown length list ptr w/ direct params
|
|
2471
|
+
const dataPtr = ctx.params[0];
|
|
2472
|
+
const len = ctx.params[1];
|
|
2473
|
+
ctx.params = ctx.params.slice(2);
|
|
2474
|
+
|
|
2475
|
+
ctx.useDirectParams = false;
|
|
2476
|
+
const originalPtr = ctx.storagePtr;
|
|
2477
|
+
ctx.storageLen = 8;
|
|
2478
|
+
|
|
2479
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2480
|
+
|
|
2481
|
+
ctx.useDirectParams = true;
|
|
2482
|
+
ctx.storagePtr = null;
|
|
2483
|
+
ctx.storageLen = null;
|
|
2484
|
+
|
|
2485
|
+
} else {
|
|
2486
|
+
// unknown length list ptr w/ in-memory params
|
|
2487
|
+
const dataPtrLiftRes = _liftFlatU32(ctx);
|
|
2488
|
+
const dataPtr = dataPtrLiftRes[0];
|
|
2489
|
+
ctx = dataPtrLiftRes[1];
|
|
2490
|
+
|
|
2491
|
+
const lenLiftRes = _liftFlatU32(ctx);
|
|
2492
|
+
const len = lenLiftRes[0];
|
|
2493
|
+
ctx = lenLiftRes[1];
|
|
2494
|
+
|
|
2495
|
+
const originalPtr = ctx.storagePtr;
|
|
2496
|
+
ctx.storagePtr = dataPtr;
|
|
2497
|
+
|
|
2498
|
+
liftResults = readValuesAndReset(ctx, originalPtr, dataPtr, len);
|
|
2416
2499
|
}
|
|
2417
2500
|
}
|
|
2418
2501
|
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
function _liftFlatResult(casesAndLiftFns) {
|
|
2427
|
-
return function _liftFlatResultInner(ctx) {
|
|
2428
|
-
_debugLog('[_liftFlatResult()] args', { ctx });
|
|
2429
|
-
return _liftFlatVariant(casesAndLiftFns)(ctx);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
|
-
function _liftFlatBorrow(componentTableIdx, size, memory, vals, storagePtr, storageLen) {
|
|
2434
|
-
_debugLog('[_liftFlatBorrow()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2435
|
-
throw new Error('flat lift for borrowed resources not yet implemented!');
|
|
2436
|
-
}
|
|
2502
|
+
return liftResults;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
function _liftFlatFlags(meta) {
|
|
2507
|
+
const { names, size32, align32, intSize } = meta;
|
|
2437
2508
|
|
|
2438
|
-
function
|
|
2439
|
-
_debugLog('[
|
|
2440
|
-
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2441
|
-
if (vals.length !== 1) {
|
|
2442
|
-
throw new Error('unexpected number (' + vals.length + ') of core vals (expected 1)');
|
|
2443
|
-
}
|
|
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);
|
|
2509
|
+
return function _liftFlatFlagsInner(ctx) {
|
|
2510
|
+
_debugLog('[_liftFlatFlags()] args', { ctx });
|
|
2447
2511
|
|
|
2448
|
-
|
|
2512
|
+
const val = {};
|
|
2449
2513
|
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2514
|
+
let liftRes;
|
|
2515
|
+
let align;
|
|
2516
|
+
switch (intSize) {
|
|
2517
|
+
case 1:
|
|
2518
|
+
liftRes = _liftFlatU8(ctx);
|
|
2519
|
+
break;
|
|
2520
|
+
case 2:
|
|
2521
|
+
liftRes = _liftFlatU16(ctx);
|
|
2522
|
+
break;
|
|
2523
|
+
case 4:
|
|
2524
|
+
liftRes = _liftFlatU32(ctx);
|
|
2525
|
+
break;
|
|
2526
|
+
default:
|
|
2527
|
+
throw new Error('invalid flags size');
|
|
2457
2528
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
return 2;
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
function _lowerFlatU32(ctx) {
|
|
2464
|
-
_debugLog('[_lowerFlatU32()] args', { ctx });
|
|
2465
|
-
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2466
|
-
if (vals.length !== 1) { throw new Error('expected single value to lower, got (' + vals.length + ')'); }
|
|
2467
|
-
if (vals[0] > 4_294_967_295 || vals[0] < 0) { throw new Error('invalid value for core value representing u32'); }
|
|
2529
|
+
let bits = liftRes[0];
|
|
2530
|
+
ctx = liftRes[1];
|
|
2468
2531
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2532
|
+
for (const name of names) {
|
|
2533
|
+
val[name] = (bits & 1) === 1;
|
|
2534
|
+
bits >>>= 1;
|
|
2535
|
+
}
|
|
2472
2536
|
|
|
2473
|
-
|
|
2537
|
+
const rem = ctx.storagePtr % align32;
|
|
2538
|
+
if (rem !== 0) { ctx.storagePtr += align32 - rem; }
|
|
2474
2539
|
|
|
2475
|
-
return
|
|
2540
|
+
return [val, ctx];
|
|
2476
2541
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
function _liftFlatResult(casesAndLiftFns) {
|
|
2545
|
+
return function _liftFlatResultInner(ctx) {
|
|
2546
|
+
_debugLog('[_liftFlatResult()] args', { ctx });
|
|
2547
|
+
return _liftFlatVariant(casesAndLiftFns)(ctx);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
function _liftFlatBorrow(componentTableIdx, size, memory, vals, storagePtr, storageLen) {
|
|
2552
|
+
_debugLog('[_liftFlatBorrow()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2553
|
+
throw new Error('flat lift for borrowed resources not yet implemented!');
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
function _lowerFlatU8(ctx) {
|
|
2557
|
+
_debugLog('[_lowerFlatU8()] args', ctx);
|
|
2558
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2559
|
+
if (vals.length !== 1) {
|
|
2560
|
+
throw new Error('unexpected number (' + vals.length + ') of core vals (expected 1)');
|
|
2484
2561
|
}
|
|
2562
|
+
if (vals[0] > 255 || vals[0] < 0) { throw new Error('invalid value for core value representing u8'); }
|
|
2563
|
+
if (!memory) { throw new Error("missing memory for lower"); }
|
|
2564
|
+
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2565
|
+
|
|
2566
|
+
// TODO: ALIGNMENT IS WRONG?
|
|
2567
|
+
|
|
2568
|
+
return 1;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
function _lowerFlatU16(memory, vals, storagePtr, storageLen) {
|
|
2572
|
+
_debugLog('[_lowerFlatU16()] args', { memory, vals, storagePtr, storageLen });
|
|
2573
|
+
if (vals.length !== 1) {
|
|
2574
|
+
throw new Error('unexpected number (' + vals.length + ') of core vals (expected 1)');
|
|
2575
|
+
}
|
|
2576
|
+
if (vals[0] > 65_535 || vals[0] < 0) { throw new Error('invalid value for core value representing u16'); }
|
|
2577
|
+
new DataView(memory.buffer).setUint16(storagePtr, vals[0], true);
|
|
2578
|
+
return 2;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
function _lowerFlatU32(ctx) {
|
|
2582
|
+
_debugLog('[_lowerFlatU32()] args', { ctx });
|
|
2583
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2584
|
+
if (vals.length !== 1) { throw new Error('expected single value to lower, got (' + vals.length + ')'); }
|
|
2585
|
+
if (vals[0] > 4_294_967_295 || vals[0] < 0) { throw new Error('invalid value for core value representing u32'); }
|
|
2586
|
+
|
|
2587
|
+
// TODO(refactor): fail loudly on misaligned flat lowers?
|
|
2588
|
+
const rem = ctx.storagePtr % 4;
|
|
2589
|
+
if (rem !== 0) { ctx.storagePtr += (4 - rem); }
|
|
2590
|
+
|
|
2591
|
+
new DataView(memory.buffer).setUint32(storagePtr, vals[0], true);
|
|
2592
|
+
|
|
2593
|
+
return 4;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
function _lowerFlatU64(memory, vals, storagePtr, storageLen) {
|
|
2597
|
+
_debugLog('[_lowerFlatU64()] args', { memory, vals, storagePtr, storageLen });
|
|
2598
|
+
if (vals.length !== 1) { throw new Error('unexpected number of core vals'); }
|
|
2599
|
+
if (vals[0] > 18_446_744_073_709_551_615n || vals[0] < 0n) { throw new Error('invalid value for core value representing u64'); }
|
|
2600
|
+
new DataView(memory.buffer).setBigUint64(storagePtr, vals[0], true);
|
|
2601
|
+
return 8;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
function _lowerFlatStringUTF8(ctx) {
|
|
2605
|
+
_debugLog('[_lowerFlatStringUTF8()] args', ctx);
|
|
2606
|
+
|
|
2607
|
+
const { memory, realloc, vals, storagePtr, storageLen } = ctx;
|
|
2608
|
+
|
|
2609
|
+
const s = vals[0];
|
|
2610
|
+
const { ptr, len, codepoints } = _utf8AllocateAndEncode(vals[0], realloc, memory);
|
|
2611
|
+
|
|
2612
|
+
const view = new DataView(memory.buffer);
|
|
2613
|
+
view.setUint32(storagePtr, ptr, true);
|
|
2614
|
+
view.setUint32(storagePtr + 4, codepoints, true);
|
|
2485
2615
|
|
|
2486
|
-
|
|
2487
|
-
|
|
2616
|
+
return len;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
function _lowerFlatRecord(fieldMetas) {
|
|
2620
|
+
return (size, memory, vals, storagePtr, storageLen) => {
|
|
2621
|
+
const params = [...arguments].slice(5);
|
|
2622
|
+
_debugLog('[_lowerFlatRecord()] args', {
|
|
2623
|
+
size,
|
|
2624
|
+
memory,
|
|
2625
|
+
vals,
|
|
2626
|
+
storagePtr,
|
|
2627
|
+
storageLen,
|
|
2628
|
+
params,
|
|
2629
|
+
fieldMetas
|
|
2630
|
+
});
|
|
2488
2631
|
|
|
2489
|
-
const
|
|
2632
|
+
const [start] = vals;
|
|
2633
|
+
if (storageLen !== undefined && size !== undefined && size > storageLen) {
|
|
2634
|
+
throw new Error('not enough storage remaining for record flat lower');
|
|
2635
|
+
}
|
|
2636
|
+
const data = new Uint8Array(memory.buffer, start, size);
|
|
2637
|
+
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2638
|
+
return data.byteLength;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
function _lowerFlatVariant(lowerMetas) {
|
|
2643
|
+
return function _lowerFlatVariantInner(ctx) {
|
|
2644
|
+
_debugLog('[_lowerFlatVariant()] args', ctx);
|
|
2645
|
+
|
|
2646
|
+
const { memory, realloc, vals, storageLen, componentIdx } = ctx;
|
|
2647
|
+
let storagePtr = ctx.storagePtr;
|
|
2648
|
+
|
|
2649
|
+
const { tag, val } = vals[0];
|
|
2650
|
+
const disc = lowerMetas.findIndex(m => m[0] === tag);
|
|
2651
|
+
if (disc === -1) {
|
|
2652
|
+
throw new Error(`invalid variant tag/discriminant [${tag}] (valid tags: ${variantMetas.map(m => m[0])})`);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
const [ _tag, lowerFn, size32, align32, payloadOffset32 ] = lowerMetas[disc];
|
|
2656
|
+
|
|
2657
|
+
const originalPtr = ctx.resultPtr;
|
|
2658
|
+
ctx.vals = [disc];
|
|
2659
|
+
let discLowerRes;
|
|
2660
|
+
if (lowerMetas.length < 256) {
|
|
2661
|
+
discLowerRes = _lowerFlatU8(ctx);
|
|
2662
|
+
} else if (lowerMetas.length >= 256 && lowerMetas.length < 65536) {
|
|
2663
|
+
discLowerRes = _lowerFlatU16(ctx);
|
|
2664
|
+
} else if (lowerMetas.length >= 65536 && lowerMetas.length < 4_294_967_296) {
|
|
2665
|
+
discLowerRes = _lowerFlatU32(ctx);
|
|
2666
|
+
} else {
|
|
2667
|
+
throw new Error('unsupported number of cases [' + lowerMetas.legnth + ']');
|
|
2668
|
+
}
|
|
2490
2669
|
|
|
2491
|
-
|
|
2492
|
-
const { ptr, len, codepoints } = _utf8AllocateAndEncode(vals[0], realloc, memory);
|
|
2670
|
+
ctx.resultPtr = originalPtr + payloadOffset32;
|
|
2493
2671
|
|
|
2494
|
-
const
|
|
2495
|
-
|
|
2496
|
-
|
|
2672
|
+
const payloadBytesWritten = lowerFn({
|
|
2673
|
+
memory,
|
|
2674
|
+
realloc,
|
|
2675
|
+
vals: [val],
|
|
2676
|
+
storagePtr,
|
|
2677
|
+
storageLen,
|
|
2678
|
+
componentIdx,
|
|
2679
|
+
});
|
|
2680
|
+
let bytesWritten = payloadOffset + payloadBytesWritten;
|
|
2497
2681
|
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
const params = [...arguments].slice(5);
|
|
2504
|
-
_debugLog('[_lowerFlatRecord()] args', {
|
|
2505
|
-
size,
|
|
2506
|
-
memory,
|
|
2507
|
-
vals,
|
|
2508
|
-
storagePtr,
|
|
2509
|
-
storageLen,
|
|
2510
|
-
params,
|
|
2511
|
-
fieldMetas
|
|
2512
|
-
});
|
|
2513
|
-
|
|
2514
|
-
const [start] = vals;
|
|
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;
|
|
2682
|
+
const rem = ctx.storagePtr % align32;
|
|
2683
|
+
if (rem !== 0) {
|
|
2684
|
+
const pad = align32 - rem;
|
|
2685
|
+
ctx.storagePtr += pad;
|
|
2686
|
+
bytesWritten += pad;
|
|
2521
2687
|
}
|
|
2688
|
+
|
|
2689
|
+
return bytesWritten;
|
|
2522
2690
|
}
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
function _lowerFlatList(args) {
|
|
2694
|
+
const { elemLowerFn } = args;
|
|
2695
|
+
if (!elemLowerFn) { throw new TypeError("missing/invalid element lower fn for list"); }
|
|
2523
2696
|
|
|
2524
|
-
function
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
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;
|
|
2697
|
+
return function _lowerFlatListInner(ctx) {
|
|
2698
|
+
_debugLog('[_lowerFlatList()] args', { ctx });
|
|
2699
|
+
|
|
2700
|
+
if (ctx.params.length < 2) { throw new Error('insufficient params left to lower list'); }
|
|
2701
|
+
const storagePtr = ctx.params[0];
|
|
2702
|
+
const elemCount = ctx.params[1];
|
|
2703
|
+
ctx.params = ctx.params.slice(2);
|
|
2704
|
+
|
|
2705
|
+
if (ctx.useDirectParams) {
|
|
2706
|
+
const list = ctx.vals[0];
|
|
2707
|
+
if (!list) { throw new Error("missing direct param value"); }
|
|
2563
2708
|
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
bytesWritten += pad;
|
|
2709
|
+
const elemLowerCtx = { storagePtr, memory: ctx.memory };
|
|
2710
|
+
for (let idx = 0; idx < list.length; idx++) {
|
|
2711
|
+
elemLowerCtx.vals = list.slice(idx, idx+1);
|
|
2712
|
+
elemLowerCtx.storagePtr += elemLowerFn(elemLowerCtx);
|
|
2569
2713
|
}
|
|
2570
2714
|
|
|
2571
|
-
|
|
2715
|
+
const bytesLowered = elemLowerCtx.storagePtr - ctx.storagePtr;
|
|
2716
|
+
ctx.storagePtr = elemLowerCtx.storagePtr;
|
|
2717
|
+
return bytesLowered;
|
|
2572
2718
|
}
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
function _lowerFlatList(args) {
|
|
2576
|
-
const { elemLowerFn } = args;
|
|
2577
|
-
if (!elemLowerFn) { throw new TypeError("missing/invalid element lower fn for list"); }
|
|
2578
2719
|
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
if (ctx.params.length < 2) { throw new Error('insufficient params left to lower list'); }
|
|
2583
|
-
const storagePtr = ctx.params[0];
|
|
2584
|
-
const elemCount = ctx.params[1];
|
|
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);
|
|
2595
|
-
}
|
|
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
|
-
}
|
|
2610
|
-
|
|
2611
|
-
const data = new Uint8Array(memory.buffer, valStartPtr, totalSizeBytes);
|
|
2612
|
-
new Uint8Array(memory.buffer, storagePtr, totalSizeBytes).set(data);
|
|
2613
|
-
|
|
2614
|
-
return totalSizeBytes;
|
|
2720
|
+
if (ctx.vals.length !== 2) {
|
|
2721
|
+
throw new Error('indirect parameter loading must have a pointer and length as vals');
|
|
2615
2722
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
let [start, len] = vals;
|
|
2621
|
-
if (storageLen !== undefined && len > storageLen) {
|
|
2622
|
-
throw new Error('not enough storage remaining for tuple flat lower');
|
|
2723
|
+
let [valStartPtr, valLen] = ctx.vals;
|
|
2724
|
+
const totalSizeBytes = valLen * size;
|
|
2725
|
+
if (ctx.storageLen !== undefined && totalSizeBytes > ctx.storageLen) {
|
|
2726
|
+
throw new Error('not enough storage remaining for list flat lower');
|
|
2623
2727
|
}
|
|
2624
|
-
|
|
2625
|
-
new Uint8Array(memory.buffer,
|
|
2626
|
-
|
|
2728
|
+
|
|
2729
|
+
const data = new Uint8Array(memory.buffer, valStartPtr, totalSizeBytes);
|
|
2730
|
+
new Uint8Array(memory.buffer, storagePtr, totalSizeBytes).set(data);
|
|
2731
|
+
|
|
2732
|
+
return totalSizeBytes;
|
|
2627
2733
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
function _lowerFlatTuple(size, memory, vals, storagePtr, storageLen) {
|
|
2737
|
+
_debugLog('[_lowerFlatTuple()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2738
|
+
let [start, len] = vals;
|
|
2739
|
+
if (storageLen !== undefined && len > storageLen) {
|
|
2740
|
+
throw new Error('not enough storage remaining for tuple flat lower');
|
|
2741
|
+
}
|
|
2742
|
+
const data = new Uint8Array(memory.buffer, start, len);
|
|
2743
|
+
new Uint8Array(memory.buffer, storagePtr, len).set(data);
|
|
2744
|
+
return data.byteLength;
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
function _lowerFlatFlags(memory, vals, storagePtr, storageLen) {
|
|
2748
|
+
_debugLog('[_lowerFlatFlags()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2749
|
+
if (vals.length !== 1) { throw new Error('unexpected number of core vals'); }
|
|
2750
|
+
new DataView(memory.buffer).setInt32(storagePtr, vals[0], true);
|
|
2751
|
+
return 4;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
function _lowerFlatEnum(size, memory, vals, storagePtr, storageLen) {
|
|
2755
|
+
_debugLog('[_lowerFlatEnum()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2756
|
+
let [start] = vals;
|
|
2757
|
+
if (storageLen !== undefined && size !== undefined && size > storageLen) {
|
|
2758
|
+
throw new Error('not enough storage remaining for enum flat lower');
|
|
2759
|
+
}
|
|
2760
|
+
const data = new Uint8Array(memory.buffer, start, size);
|
|
2761
|
+
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2762
|
+
return data.byteLength;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
function _lowerFlatOption(lowerMetas) {
|
|
2766
|
+
function _lowerFlatOptionInner(ctx) {
|
|
2767
|
+
_debugLog('[_lowerFlatOption()] args', { ctx });
|
|
2768
|
+
return _lowerFlatVariant(lowerMetas)(ctx);
|
|
2634
2769
|
}
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2772
|
+
function _lowerFlatResult(lowerMetas) {
|
|
2773
|
+
return function _lowerFlatResultInner(ctx) {
|
|
2774
|
+
_debugLog('[_lowerFlatResult()] args', { lowerMetas });
|
|
2775
|
+
return _lowerFlatVariant(lowerMetas)(ctx);
|
|
2776
|
+
};
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
function _lowerFlatOwn(size, memory, vals, storagePtr, storageLen) {
|
|
2780
|
+
_debugLog('[_lowerFlatOwn()] args', { size, memory, vals, storagePtr, storageLen });
|
|
2781
|
+
throw new Error('flat lower for owned resources not yet implemented!');
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
const STREAMS = new RepTable({ target: 'global stream map' });
|
|
2785
|
+
const ASYNC_STATE = new Map();
|
|
2786
|
+
|
|
2787
|
+
function getOrCreateAsyncState(componentIdx, init) {
|
|
2788
|
+
if (!ASYNC_STATE.has(componentIdx)) {
|
|
2789
|
+
const newState = new ComponentAsyncState({ componentIdx });
|
|
2790
|
+
ASYNC_STATE.set(componentIdx, newState);
|
|
2791
|
+
}
|
|
2792
|
+
return ASYNC_STATE.get(componentIdx);
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
class ComponentAsyncState {
|
|
2796
|
+
static EVENT_HANDLER_EVENTS = [ 'backpressure-change' ];
|
|
2635
2797
|
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2798
|
+
#componentIdx;
|
|
2799
|
+
#callingAsyncImport = false;
|
|
2800
|
+
#syncImportWait = promiseWithResolvers();
|
|
2801
|
+
#locked = false;
|
|
2802
|
+
#parkedTasks = new Map();
|
|
2803
|
+
#suspendedTasksByTaskID = new Map();
|
|
2804
|
+
#suspendedTaskIDs = [];
|
|
2805
|
+
#errored = null;
|
|
2806
|
+
|
|
2807
|
+
#backpressure = 0;
|
|
2808
|
+
#backpressureWaiters = 0n;
|
|
2809
|
+
|
|
2810
|
+
#handlerMap = new Map();
|
|
2811
|
+
#nextHandlerID = 0n;
|
|
2812
|
+
|
|
2813
|
+
#tickLoop = null;
|
|
2814
|
+
#tickLoopInterval = null;
|
|
2815
|
+
|
|
2816
|
+
#onExclusiveReleaseHandlers = [];
|
|
2817
|
+
|
|
2818
|
+
mayLeave = true;
|
|
2819
|
+
|
|
2820
|
+
handles;
|
|
2821
|
+
subtasks;
|
|
2822
|
+
|
|
2823
|
+
constructor(args) {
|
|
2824
|
+
this.#componentIdx = args.componentIdx;
|
|
2825
|
+
this.handles = new RepTable({ target: `component [${this.#componentIdx}] handles (waitable objects)` });
|
|
2826
|
+
this.subtasks = new RepTable({ target: `component [${this.#componentIdx}] subtasks` });
|
|
2827
|
+
};
|
|
2828
|
+
|
|
2829
|
+
componentIdx() { return this.#componentIdx; }
|
|
2830
|
+
|
|
2831
|
+
errored() { return this.#errored !== null; }
|
|
2832
|
+
setErrored(err) {
|
|
2833
|
+
_debugLog('[ComponentAsyncState#setErrored()] component errored', { err, componentIdx: this.#componentIdx });
|
|
2834
|
+
if (this.#errored) { return; }
|
|
2835
|
+
if (!err) {
|
|
2836
|
+
err = new Error('error elswehere (see other component instance error)')
|
|
2837
|
+
err.componentIdx = this.#componentIdx;
|
|
2641
2838
|
}
|
|
2642
|
-
|
|
2643
|
-
new Uint8Array(memory.buffer, storagePtr, size).set(data);
|
|
2644
|
-
return data.byteLength;
|
|
2839
|
+
this.#errored = err;
|
|
2645
2840
|
}
|
|
2646
2841
|
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2842
|
+
callingSyncImport(val) {
|
|
2843
|
+
if (val === undefined) { return this.#callingAsyncImport; }
|
|
2844
|
+
if (typeof val !== 'boolean') { throw new TypeError('invalid setting for async import'); }
|
|
2845
|
+
const prev = this.#callingAsyncImport;
|
|
2846
|
+
this.#callingAsyncImport = val;
|
|
2847
|
+
if (prev === true && this.#callingAsyncImport === false) {
|
|
2848
|
+
this.#notifySyncImportEnd();
|
|
2651
2849
|
}
|
|
2652
2850
|
}
|
|
2653
2851
|
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
};
|
|
2852
|
+
#notifySyncImportEnd() {
|
|
2853
|
+
const existing = this.#syncImportWait;
|
|
2854
|
+
this.#syncImportWait = promiseWithResolvers();
|
|
2855
|
+
existing.resolve();
|
|
2659
2856
|
}
|
|
2660
2857
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
throw new Error('flat lower for owned resources not yet implemented!');
|
|
2858
|
+
async waitForSyncImportCallEnd() {
|
|
2859
|
+
await this.#syncImportWait.promise;
|
|
2664
2860
|
}
|
|
2665
2861
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2862
|
+
setBackpressure(v) {
|
|
2863
|
+
this.#backpressure = v;
|
|
2864
|
+
return this.#backpressure
|
|
2865
|
+
}
|
|
2866
|
+
getBackpressure() { return this.#backpressure; }
|
|
2668
2867
|
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2868
|
+
incrementBackpressure() {
|
|
2869
|
+
const current = this.#backpressure;
|
|
2870
|
+
if (current < 0 || current > 2**16) {
|
|
2871
|
+
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2872
|
+
}
|
|
2873
|
+
const newValue = this.getBackpressure() + 1;
|
|
2874
|
+
if (newValue >= 2**16) {
|
|
2875
|
+
throw new Error(`invalid new backpressure value [${newValue}], overflow`);
|
|
2673
2876
|
}
|
|
2674
|
-
return
|
|
2877
|
+
return this.setBackpressure(newValue);
|
|
2675
2878
|
}
|
|
2676
2879
|
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
#callingAsyncImport = false;
|
|
2682
|
-
#syncImportWait = promiseWithResolvers();
|
|
2683
|
-
#locked = false;
|
|
2684
|
-
#parkedTasks = new Map();
|
|
2685
|
-
#suspendedTasksByTaskID = new Map();
|
|
2686
|
-
#suspendedTaskIDs = [];
|
|
2687
|
-
#errored = null;
|
|
2688
|
-
|
|
2689
|
-
#backpressure = 0;
|
|
2690
|
-
#backpressureWaiters = 0n;
|
|
2691
|
-
|
|
2692
|
-
#handlerMap = new Map();
|
|
2693
|
-
#nextHandlerID = 0n;
|
|
2694
|
-
|
|
2695
|
-
#tickLoop = null;
|
|
2696
|
-
#tickLoopInterval = null;
|
|
2697
|
-
|
|
2698
|
-
#onExclusiveReleaseHandlers = [];
|
|
2699
|
-
|
|
2700
|
-
mayLeave = true;
|
|
2701
|
-
|
|
2702
|
-
handles;
|
|
2703
|
-
subtasks;
|
|
2704
|
-
|
|
2705
|
-
constructor(args) {
|
|
2706
|
-
this.#componentIdx = args.componentIdx;
|
|
2707
|
-
this.handles = new RepTable({ target: `component [${this.#componentIdx}] handles (waitable objects)` });
|
|
2708
|
-
this.subtasks = new RepTable({ target: `component [${this.#componentIdx}] subtasks` });
|
|
2709
|
-
};
|
|
2710
|
-
|
|
2711
|
-
componentIdx() { return this.#componentIdx; }
|
|
2712
|
-
|
|
2713
|
-
errored() { return this.#errored !== null; }
|
|
2714
|
-
setErrored(err) {
|
|
2715
|
-
_debugLog('[ComponentAsyncState#setErrored()] component errored', { err, componentIdx: this.#componentIdx });
|
|
2716
|
-
if (this.#errored) { return; }
|
|
2717
|
-
if (!err) {
|
|
2718
|
-
err = new Error('error elswehere (see other component instance error)')
|
|
2719
|
-
err.componentIdx = this.#componentIdx;
|
|
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
|
-
}
|
|
2880
|
+
decrementBackpressure() {
|
|
2881
|
+
const current = this.#backpressure;
|
|
2882
|
+
if (current < 0 || current > 2**16) {
|
|
2883
|
+
throw new Error(`invalid current backpressure value [${current}]`);
|
|
2732
2884
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
this.#syncImportWait = promiseWithResolvers();
|
|
2737
|
-
existing.resolve();
|
|
2885
|
+
const newValue = Math.max(0, current - 1);
|
|
2886
|
+
if (newValue < 0) {
|
|
2887
|
+
throw new Error(`invalid new backpressure value [${newValue}], underflow`);
|
|
2738
2888
|
}
|
|
2889
|
+
return this.setBackpressure(newValue);
|
|
2890
|
+
}
|
|
2891
|
+
hasBackpressure() { return this.#backpressure > 0; }
|
|
2892
|
+
|
|
2893
|
+
waitForBackpressure() {
|
|
2894
|
+
let backpressureCleared = false;
|
|
2895
|
+
const cstate = this;
|
|
2896
|
+
cstate.addBackpressureWaiter();
|
|
2897
|
+
const handlerID = this.registerHandler({
|
|
2898
|
+
event: 'backpressure-change',
|
|
2899
|
+
fn: (bp) => {
|
|
2900
|
+
if (bp === 0) {
|
|
2901
|
+
cstate.removeHandler(handlerID);
|
|
2902
|
+
backpressureCleared = true;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
return new Promise((resolve) => {
|
|
2907
|
+
const interval = setInterval(() => {
|
|
2908
|
+
if (backpressureCleared) { return; }
|
|
2909
|
+
clearInterval(interval);
|
|
2910
|
+
cstate.removeBackpressureWaiter();
|
|
2911
|
+
resolve(null);
|
|
2912
|
+
}, 0);
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
registerHandler(args) {
|
|
2917
|
+
const { event, fn } = args;
|
|
2918
|
+
if (!event) { throw new Error("missing handler event"); }
|
|
2919
|
+
if (!fn) { throw new Error("missing handler fn"); }
|
|
2739
2920
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2921
|
+
if (!ComponentAsyncState.EVENT_HANDLER_EVENTS.includes(event)) {
|
|
2922
|
+
throw new Error(`unrecognized event handler [${event}]`);
|
|
2742
2923
|
}
|
|
2743
2924
|
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2925
|
+
const handlerID = this.#nextHandlerID++;
|
|
2926
|
+
let handlers = this.#handlerMap.get(event);
|
|
2927
|
+
if (!handlers) {
|
|
2928
|
+
handlers = [];
|
|
2929
|
+
this.#handlerMap.set(event, handlers)
|
|
2747
2930
|
}
|
|
2748
|
-
getBackpressure() { return this.#backpressure; }
|
|
2749
2931
|
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2932
|
+
handlers.push({ id: handlerID, fn, event });
|
|
2933
|
+
return handlerID;
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
removeHandler(args) {
|
|
2937
|
+
const { event, handlerID } = args;
|
|
2938
|
+
const registeredHandlers = this.#handlerMap.get(event);
|
|
2939
|
+
if (!registeredHandlers) { return; }
|
|
2940
|
+
const found = registeredHandlers.find(h => h.id === handlerID);
|
|
2941
|
+
if (!found) { return; }
|
|
2942
|
+
this.#handlerMap.set(event, this.#handlerMap.get(event).filter(h => h.id !== handlerID));
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
getBackpressureWaiters() { return this.#backpressureWaiters; }
|
|
2946
|
+
addBackpressureWaiter() { this.#backpressureWaiters++; }
|
|
2947
|
+
removeBackpressureWaiter() {
|
|
2948
|
+
this.#backpressureWaiters--;
|
|
2949
|
+
if (this.#backpressureWaiters < 0) {
|
|
2950
|
+
throw new Error("unexepctedly negative number of backpressure waiters");
|
|
2760
2951
|
}
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
isExclusivelyLocked() { return this.#locked === true; }
|
|
2955
|
+
setLocked(locked) {
|
|
2956
|
+
this.#locked = locked;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
// TODO(fix): we might want to check for pre-locked status here, we should be deterministically
|
|
2960
|
+
// going from locked -> unlocked and vice versa
|
|
2961
|
+
exclusiveLock() {
|
|
2962
|
+
_debugLog('[ComponentAsyncState#exclusiveLock()]', {
|
|
2963
|
+
locked: this.#locked,
|
|
2964
|
+
componentIdx: this.#componentIdx,
|
|
2965
|
+
});
|
|
2966
|
+
this.setLocked(true);
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
exclusiveRelease() {
|
|
2970
|
+
_debugLog('[ComponentAsyncState#exclusiveRelease()] args', {
|
|
2971
|
+
locked: this.#locked,
|
|
2972
|
+
componentIdx: this.#componentIdx,
|
|
2973
|
+
});
|
|
2974
|
+
this.setLocked(false);
|
|
2761
2975
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
throw
|
|
2976
|
+
this.#onExclusiveReleaseHandlers = this.#onExclusiveReleaseHandlers.filter(v => !!v);
|
|
2977
|
+
for (const [idx, f] of this.#onExclusiveReleaseHandlers.entries()) {
|
|
2978
|
+
try {
|
|
2979
|
+
this.#onExclusiveReleaseHandlers[idx] = null;
|
|
2980
|
+
f();
|
|
2981
|
+
} catch (err) {
|
|
2982
|
+
_debugLog("error while executing handler for next exclusive release", err);
|
|
2983
|
+
throw err;
|
|
2770
2984
|
}
|
|
2771
|
-
return this.setBackpressure(newValue);
|
|
2772
2985
|
}
|
|
2773
|
-
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
onNextExclusiveRelease(fn) {
|
|
2989
|
+
_debugLog('[ComponentAsyncState#()onNextExclusiveRelease] registering');
|
|
2990
|
+
this.#onExclusiveReleaseHandlers.push(fn);
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
#getSuspendedTaskMeta(taskID) {
|
|
2994
|
+
return this.#suspendedTasksByTaskID.get(taskID);
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
#removeSuspendedTaskMeta(taskID) {
|
|
2998
|
+
_debugLog('[ComponentAsyncState#removeSuspendedTaskMeta()] removing suspended task', { taskID });
|
|
2999
|
+
const idx = this.#suspendedTaskIDs.findIndex(t => t === taskID);
|
|
3000
|
+
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
3001
|
+
this.#suspendedTaskIDs[idx] = null;
|
|
3002
|
+
this.#suspendedTasksByTaskID.delete(taskID);
|
|
3003
|
+
return meta;
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
#addSuspendedTaskMeta(meta) {
|
|
3007
|
+
if (!meta) { throw new Error('missing task meta'); }
|
|
3008
|
+
const taskID = meta.taskID;
|
|
3009
|
+
this.#suspendedTasksByTaskID.set(taskID, meta);
|
|
3010
|
+
this.#suspendedTaskIDs.push(taskID);
|
|
3011
|
+
if (this.#suspendedTasksByTaskID.size < this.#suspendedTaskIDs.length - 10) {
|
|
3012
|
+
this.#suspendedTaskIDs = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
// TODO(threads): readyFn is normally on the thread
|
|
3017
|
+
suspendTask(args) {
|
|
3018
|
+
const { task, readyFn } = args;
|
|
3019
|
+
const taskID = task.id();
|
|
3020
|
+
_debugLog('[ComponentAsyncState#suspendTask()]', {
|
|
3021
|
+
taskID,
|
|
3022
|
+
componentIdx: this.#componentIdx,
|
|
3023
|
+
taskEntryFnName: task.entryFnName(),
|
|
3024
|
+
subtask: task.getParentSubtask(),
|
|
3025
|
+
});
|
|
2774
3026
|
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
const cstate = this;
|
|
2778
|
-
cstate.addBackpressureWaiter();
|
|
2779
|
-
const handlerID = this.registerHandler({
|
|
2780
|
-
event: 'backpressure-change',
|
|
2781
|
-
fn: (bp) => {
|
|
2782
|
-
if (bp === 0) {
|
|
2783
|
-
cstate.removeHandler(handlerID);
|
|
2784
|
-
backpressureCleared = true;
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
});
|
|
2788
|
-
return new Promise((resolve) => {
|
|
2789
|
-
const interval = setInterval(() => {
|
|
2790
|
-
if (backpressureCleared) { return; }
|
|
2791
|
-
clearInterval(interval);
|
|
2792
|
-
cstate.removeBackpressureWaiter();
|
|
2793
|
-
resolve(null);
|
|
2794
|
-
}, 0);
|
|
2795
|
-
});
|
|
3027
|
+
if (this.#getSuspendedTaskMeta(taskID)) {
|
|
3028
|
+
throw new Error(`task [${taskID}] already suspended`);
|
|
2796
3029
|
}
|
|
2797
3030
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
3031
|
+
const { promise, resolve, reject } = promiseWithResolvers();
|
|
3032
|
+
this.#addSuspendedTaskMeta({
|
|
3033
|
+
task,
|
|
3034
|
+
taskID,
|
|
3035
|
+
readyFn,
|
|
3036
|
+
resume: () => {
|
|
3037
|
+
_debugLog('[ComponentAsyncState#suspendTask()] resuming suspended task', { taskID });
|
|
3038
|
+
// TODO(threads): it's thread cancellation we should be checking for below, not task
|
|
3039
|
+
resolve(!task.isCancelled());
|
|
3040
|
+
},
|
|
3041
|
+
});
|
|
3042
|
+
|
|
3043
|
+
this.runTickLoop();
|
|
3044
|
+
|
|
3045
|
+
return promise;
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
resumeTaskByID(taskID) {
|
|
3049
|
+
const meta = this.#removeSuspendedTaskMeta(taskID);
|
|
3050
|
+
if (!meta) { return; }
|
|
3051
|
+
if (meta.taskID !== taskID) { throw new Error('task ID does not match'); }
|
|
3052
|
+
meta.resume();
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
async runTickLoop() {
|
|
3056
|
+
if (this.#tickLoop !== null) { return; }
|
|
3057
|
+
this.#tickLoop = 1;
|
|
3058
|
+
setTimeout(async () => {
|
|
3059
|
+
let done = this.tick();
|
|
3060
|
+
while (!done) {
|
|
3061
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
3062
|
+
done = this.tick();
|
|
3063
|
+
}
|
|
3064
|
+
this.#tickLoop = null;
|
|
3065
|
+
}, 10);
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
tick() {
|
|
3069
|
+
// _debugLog('[ComponentAsyncState#tick()]', { suspendedTaskIDs: this.#suspendedTaskIDs });
|
|
3070
|
+
|
|
3071
|
+
const resumableTasks = this.#suspendedTaskIDs.filter(t => t !== null);
|
|
3072
|
+
for (const taskID of resumableTasks) {
|
|
3073
|
+
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
3074
|
+
if (!meta || !meta.readyFn) {
|
|
3075
|
+
throw new Error(`missing/invalid task despite ID [${taskID}] being present`);
|
|
2805
3076
|
}
|
|
2806
3077
|
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
if (
|
|
2810
|
-
|
|
2811
|
-
this
|
|
3078
|
+
// If the task failed via any means, allow the task to resume because
|
|
3079
|
+
// it's been cancelled -- the callback should immediately exit as well
|
|
3080
|
+
if (meta.task.isRejected()) {
|
|
3081
|
+
_debugLog('[ComponentAsyncState#suspendTask()] detected task rejection, leaving early', { meta });
|
|
3082
|
+
this.resumeTaskByID(taskID);
|
|
3083
|
+
return;
|
|
2812
3084
|
}
|
|
2813
3085
|
|
|
2814
|
-
|
|
2815
|
-
|
|
3086
|
+
const isReady = meta.readyFn();
|
|
3087
|
+
if (!isReady) { continue; }
|
|
3088
|
+
|
|
3089
|
+
this.resumeTaskByID(taskID);
|
|
2816
3090
|
}
|
|
2817
3091
|
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
}
|
|
3092
|
+
return this.#suspendedTaskIDs.filter(t => t !== null).length === 0;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
addStreamEndToTable(args) {
|
|
3096
|
+
_debugLog('[ComponentAsyncState#addStreamEnd()] args', args);
|
|
3097
|
+
const { tableIdx, streamEnd } = args;
|
|
3098
|
+
if (typeof streamEnd === 'number') { throw new Error("INSERTING BAD STREAMEND"); }
|
|
2826
3099
|
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
this.#backpressureWaiters--;
|
|
2831
|
-
if (this.#backpressureWaiters < 0) {
|
|
2832
|
-
throw new Error("unexepctedly negative number of backpressure waiters");
|
|
2833
|
-
}
|
|
3100
|
+
let { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3101
|
+
if (componentIdx === undefined || !table) {
|
|
3102
|
+
throw new Error(`invalid global stream table state for table [${tableIdx}]`);
|
|
2834
3103
|
}
|
|
2835
3104
|
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
}
|
|
3105
|
+
const handle = table.insert(streamEnd);
|
|
3106
|
+
streamEnd.setHandle(handle);
|
|
3107
|
+
streamEnd.setStreamTableIdx(tableIdx);
|
|
2840
3108
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
_debugLog('[ComponentAsyncState#exclusiveLock()]', {
|
|
2845
|
-
locked: this.#locked,
|
|
2846
|
-
componentIdx: this.#componentIdx,
|
|
2847
|
-
});
|
|
2848
|
-
this.setLocked(true);
|
|
2849
|
-
}
|
|
3109
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3110
|
+
const waitableIdx = cstate.handles.insert(streamEnd);
|
|
3111
|
+
streamEnd.setWaitableIdx(waitableIdx);
|
|
2850
3112
|
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
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
|
-
}
|
|
3113
|
+
_debugLog('[ComponentAsyncState#addStreamEnd()] added stream end', {
|
|
3114
|
+
tableIdx,
|
|
3115
|
+
table,
|
|
3116
|
+
handle,
|
|
3117
|
+
streamEnd,
|
|
3118
|
+
destComponentIdx: componentIdx,
|
|
3119
|
+
});
|
|
2869
3120
|
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
3121
|
+
return { handle, waitableIdx };
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
createWaitable(args) {
|
|
3125
|
+
return new Waitable({ target: args?.target, });
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
createStream(args) {
|
|
3129
|
+
_debugLog('[ComponentAsyncState#createStream()] args', args);
|
|
3130
|
+
const { tableIdx, elemMeta } = args;
|
|
3131
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while adding stream"); }
|
|
3132
|
+
if (elemMeta === undefined) { throw new Error("missing element metadata while adding stream"); }
|
|
2874
3133
|
|
|
2875
|
-
|
|
2876
|
-
|
|
3134
|
+
const { table: localStreamTable, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3135
|
+
if (!localStreamTable) {
|
|
3136
|
+
throw new Error(`missing global stream table lookup for table [${tableIdx}] while creating stream`);
|
|
2877
3137
|
}
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
_debugLog('[ComponentAsyncState#removeSuspendedTaskMeta()] removing suspended task', { taskID });
|
|
2881
|
-
const idx = this.#suspendedTaskIDs.findIndex(t => t === taskID);
|
|
2882
|
-
const meta = this.#suspendedTasksByTaskID.get(taskID);
|
|
2883
|
-
this.#suspendedTaskIDs[idx] = null;
|
|
2884
|
-
this.#suspendedTasksByTaskID.delete(taskID);
|
|
2885
|
-
return meta;
|
|
3138
|
+
if (componentIdx !== this.#componentIdx) {
|
|
3139
|
+
throw new Error('component idx mismatch while creating stream');
|
|
2886
3140
|
}
|
|
2887
3141
|
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
const taskID = meta.taskID;
|
|
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
|
-
}
|
|
2896
|
-
}
|
|
3142
|
+
const readWaitable = this.createWaitable();
|
|
3143
|
+
const writeWaitable = this.createWaitable();
|
|
2897
3144
|
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3145
|
+
const stream = new InternalStream({
|
|
3146
|
+
tableIdx,
|
|
3147
|
+
componentIdx: this.#componentIdx,
|
|
3148
|
+
elemMeta,
|
|
3149
|
+
readWaitable,
|
|
3150
|
+
writeWaitable,
|
|
3151
|
+
});
|
|
3152
|
+
stream.setGlobalStreamMapRep(STREAMS.insert(stream));
|
|
3153
|
+
|
|
3154
|
+
const writeEnd = stream.writeEnd();
|
|
3155
|
+
writeEnd.setWaitableIdx(this.handles.insert(writeEnd));
|
|
3156
|
+
writeEnd.setHandle(localStreamTable.insert(writeEnd));
|
|
3157
|
+
if (writeEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3158
|
+
|
|
3159
|
+
const writeEndWaitableIdx = writeEnd.waitableIdx();
|
|
3160
|
+
const writeEndHandle = writeEnd.handle();
|
|
3161
|
+
writeWaitable.setTarget(`waitable for stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3162
|
+
writeEnd.setTarget(`stream write end (waitable [${writeEndWaitableIdx}])`);
|
|
3163
|
+
|
|
3164
|
+
const readEnd = stream.readEnd();
|
|
3165
|
+
readEnd.setWaitableIdx(this.handles.insert(readEnd));
|
|
3166
|
+
readEnd.setHandle(localStreamTable.insert(readEnd));
|
|
3167
|
+
if (readEnd.streamTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched stream table"); }
|
|
3168
|
+
|
|
3169
|
+
const readEndWaitableIdx = readEnd.waitableIdx();
|
|
3170
|
+
const readEndHandle = readEnd.handle();
|
|
3171
|
+
readWaitable.setTarget(`waitable for read end (waitable [${readEndWaitableIdx}])`);
|
|
3172
|
+
readEnd.setTarget(`stream read end (waitable [${readEndWaitableIdx}])`);
|
|
3173
|
+
|
|
3174
|
+
return {
|
|
3175
|
+
writeEndWaitableIdx,
|
|
3176
|
+
writeEndHandle,
|
|
3177
|
+
readEndWaitableIdx,
|
|
3178
|
+
readEndHandle,
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
getStreamEnd(args) {
|
|
3183
|
+
_debugLog('[ComponentAsyncState#getStreamEnd()] args', args);
|
|
3184
|
+
const { tableIdx, streamEndHandle, streamEndWaitableIdx } = args;
|
|
3185
|
+
if (tableIdx === undefined) { throw new Error('missing table idx while getting stream end'); }
|
|
2929
3186
|
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
3187
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3188
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3189
|
+
|
|
3190
|
+
let streamEnd;
|
|
3191
|
+
if (streamEndWaitableIdx !== undefined) {
|
|
3192
|
+
streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3193
|
+
} else if (streamEndHandle !== undefined) {
|
|
3194
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while getting stream end`); }
|
|
3195
|
+
streamEnd = table.get(streamEndHandle);
|
|
3196
|
+
} else {
|
|
3197
|
+
throw new TypeError("must specify either waitable idx or handle to retrieve stream");
|
|
2935
3198
|
}
|
|
2936
3199
|
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
while (!done) {
|
|
2943
|
-
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
2944
|
-
done = this.tick();
|
|
2945
|
-
}
|
|
2946
|
-
this.#tickLoop = null;
|
|
2947
|
-
}, 10);
|
|
3200
|
+
if (!streamEnd) {
|
|
3201
|
+
throw new Error(`missing stream end (tableIdx [${tableIdx}], handle [${streamEndHandle}], waitableIdx [${streamEndWaitableIdx}])`);
|
|
3202
|
+
}
|
|
3203
|
+
if (tableIdx && streamEnd.streamTableIdx() !== tableIdx) {
|
|
3204
|
+
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
2948
3205
|
}
|
|
2949
3206
|
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
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;
|
|
3207
|
+
return streamEnd;
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
deleteStreamEnd(args) {
|
|
3211
|
+
_debugLog('[ComponentAsyncState#deleteStreamEnd()] args', args);
|
|
3212
|
+
const { tableIdx, streamEndWaitableIdx } = args;
|
|
3213
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3214
|
+
if (streamEndWaitableIdx === undefined) { throw new Error("missing stream idx while removing stream end"); }
|
|
3215
|
+
|
|
3216
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3217
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3218
|
+
|
|
3219
|
+
const streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3220
|
+
if (!streamEnd) {
|
|
3221
|
+
throw new Error(`missing stream end [${streamEndWaitableIdx}] in component handles while deleting stream`);
|
|
3222
|
+
}
|
|
3223
|
+
if (streamEnd.streamTableIdx() !== tableIdx) {
|
|
3224
|
+
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
2975
3225
|
}
|
|
2976
3226
|
|
|
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 };
|
|
3227
|
+
let removed = cstate.handles.remove(streamEnd.waitableIdx());
|
|
3228
|
+
if (!removed) {
|
|
3229
|
+
throw new Error(`failed to remove stream end [${streamEndWaitableIdx}] waitable obj in component [${componentIdx}]`);
|
|
3004
3230
|
}
|
|
3005
3231
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3232
|
+
removed = table.remove(streamEnd.handle());
|
|
3233
|
+
if (!removed) {
|
|
3234
|
+
throw new Error(`failed to remove stream end with handle [${streamEnd.handle()}] from stream table [${tableIdx}] in component [${componentIdx}]`);
|
|
3008
3235
|
}
|
|
3009
3236
|
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
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
|
-
};
|
|
3237
|
+
return streamEnd;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
removeStreamEndFromTable(args) {
|
|
3241
|
+
_debugLog('[ComponentAsyncState#removeStreamEndFromTable()] args', args);
|
|
3242
|
+
|
|
3243
|
+
const { tableIdx, streamWaitableIdx } = args;
|
|
3244
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while removing stream end"); }
|
|
3245
|
+
if (streamWaitableIdx === undefined) {
|
|
3246
|
+
throw new Error("missing stream end waitable idx while removing stream end");
|
|
3062
3247
|
}
|
|
3063
3248
|
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
let streamEnd;
|
|
3073
|
-
if (streamEndWaitableIdx !== undefined) {
|
|
3074
|
-
streamEnd = cstate.handles.get(streamEndWaitableIdx);
|
|
3075
|
-
} else if (streamEndHandle !== undefined) {
|
|
3076
|
-
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while getting stream end`); }
|
|
3077
|
-
streamEnd = table.get(streamEndHandle);
|
|
3078
|
-
} else {
|
|
3079
|
-
throw new TypeError("must specify either waitable idx or handle to retrieve stream");
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
if (!streamEnd) {
|
|
3083
|
-
throw new Error(`missing stream end (tableIdx [${tableIdx}], handle [${streamEndHandle}], waitableIdx [${streamEndWaitableIdx}])`);
|
|
3084
|
-
}
|
|
3085
|
-
if (tableIdx && streamEnd.streamTableIdx() !== tableIdx) {
|
|
3086
|
-
throw new Error(`stream end table idx [${streamEnd.streamTableIdx()}] does not match [${tableIdx}]`);
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3089
|
-
return streamEnd;
|
|
3249
|
+
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
3250
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while removing stream end`); }
|
|
3251
|
+
|
|
3252
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
3253
|
+
|
|
3254
|
+
const streamEnd = cstate.handles.get(streamWaitableIdx);
|
|
3255
|
+
if (!streamEnd) {
|
|
3256
|
+
throw new Error(`missing stream end (handle [${streamWaitableIdx}], table [${tableIdx}])`);
|
|
3090
3257
|
}
|
|
3258
|
+
const handle = streamEnd.handle();
|
|
3091
3259
|
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
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;
|
|
3260
|
+
let removed = cstate.handles.remove(streamWaitableIdx);
|
|
3261
|
+
if (!removed) {
|
|
3262
|
+
throw new Error(`failed to remove streamEnd from handles (waitable idx [${streamWaitableIdx}]), component [${componentIdx}])`);
|
|
3120
3263
|
}
|
|
3121
3264
|
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
const { tableIdx, streamWaitableIdx } = args;
|
|
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}])`);
|
|
3150
|
-
}
|
|
3151
|
-
|
|
3152
|
-
return streamEnd;
|
|
3265
|
+
removed = table.remove(handle);
|
|
3266
|
+
if (!removed) {
|
|
3267
|
+
throw new Error(`failed to remove streamEnd from table (handle [${handle}]), table [${tableIdx}], component [${componentIdx}])`);
|
|
3153
3268
|
}
|
|
3269
|
+
|
|
3270
|
+
return streamEnd;
|
|
3154
3271
|
}
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
const base64Compile = str => WebAssembly.compile(typeof Buffer !== 'undefined' ? Buffer.from(str, 'base64') : Uint8Array.from(atob(str), b => b.charCodeAt(0)));
|
|
3275
|
+
|
|
3276
|
+
const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
|
3277
|
+
let _fs;
|
|
3278
|
+
async function fetchCompile (url) {
|
|
3279
|
+
if (isNode) {
|
|
3280
|
+
_fs = _fs || await import('node:fs/promises');
|
|
3281
|
+
return WebAssembly.compile(await _fs.readFile(url));
|
|
3282
|
+
}
|
|
3283
|
+
return fetch(url).then(WebAssembly.compileStreaming);
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
const symbolCabiDispose = Symbol.for('cabiDispose');
|
|
3287
|
+
|
|
3288
|
+
const symbolRscHandle = Symbol('handle');
|
|
3289
|
+
|
|
3290
|
+
const symbolRscRep = Symbol.for('cabiRep');
|
|
3291
|
+
|
|
3292
|
+
const symbolDispose = Symbol.dispose || Symbol.for('dispose');
|
|
3293
|
+
|
|
3294
|
+
const handleTables = [];
|
|
3295
|
+
|
|
3296
|
+
class ComponentError extends Error {
|
|
3297
|
+
constructor (value) {
|
|
3298
|
+
const enumerable = typeof value !== 'string';
|
|
3299
|
+
super(enumerable ? `${String(value)} (see error.payload)` : value);
|
|
3300
|
+
Object.defineProperty(this, 'payload', { value, enumerable });
|
|
3166
3301
|
}
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
function getErrorPayload(e) {
|
|
3305
|
+
if (e && hasOwnProperty.call(e, 'payload')) return e.payload;
|
|
3306
|
+
if (e instanceof Error) throw e;
|
|
3307
|
+
return e;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
function throwUninitialized() {
|
|
3311
|
+
throw new TypeError('Wasm uninitialized use `await $init` first');
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3315
|
+
|
|
3316
|
+
const instantiateCore = WebAssembly.instantiate;
|
|
3317
|
+
|
|
3318
|
+
|
|
3319
|
+
let exports0;
|
|
3320
|
+
let exports1;
|
|
3321
|
+
const handleTable2 = [T_FLAG, 0];
|
|
3322
|
+
const captureTable2= new Map();
|
|
3323
|
+
let captureCnt2 = 0;
|
|
3324
|
+
handleTables[2] = handleTable2;
|
|
3325
|
+
|
|
3326
|
+
const _trampoline5 = function() {
|
|
3327
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3328
|
+
let hostProvided = true;
|
|
3167
3329
|
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
const symbolRscRep = Symbol.for('cabiRep');
|
|
3173
|
-
|
|
3174
|
-
const symbolDispose = Symbol.dispose || Symbol.for('dispose');
|
|
3330
|
+
let parentTask;
|
|
3331
|
+
let task;
|
|
3332
|
+
let subtask;
|
|
3175
3333
|
|
|
3176
|
-
const
|
|
3334
|
+
const createTask = () => {
|
|
3335
|
+
const results = createNewCurrentTask({
|
|
3336
|
+
componentIdx: -1, // 0,
|
|
3337
|
+
isAsync: false,
|
|
3338
|
+
entryFnName: 'getStderr',
|
|
3339
|
+
getCallbackFn: () => null,
|
|
3340
|
+
callbackFnName: 'null',
|
|
3341
|
+
errHandling: 'none',
|
|
3342
|
+
callingWasmExport: false,
|
|
3343
|
+
});
|
|
3344
|
+
task = results[0];
|
|
3345
|
+
};
|
|
3177
3346
|
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3347
|
+
taskCreation: {
|
|
3348
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3349
|
+
if (!parentTask) {
|
|
3350
|
+
createTask();
|
|
3351
|
+
break taskCreation;
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
createTask();
|
|
3355
|
+
|
|
3356
|
+
if (hostProvided) {
|
|
3357
|
+
subtask = parentTask.getLatestSubtask();
|
|
3358
|
+
if (!subtask) {
|
|
3359
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3360
|
+
}
|
|
3361
|
+
task.setParentSubtask(subtask);
|
|
3183
3362
|
}
|
|
3184
3363
|
}
|
|
3185
3364
|
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3365
|
+
const started = task.enterSync();
|
|
3366
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3367
|
+
componentIdx: task.componentIdx(),
|
|
3368
|
+
taskID: task.id(),
|
|
3369
|
+
fn: () => getStderr()
|
|
3370
|
+
})
|
|
3371
|
+
;
|
|
3372
|
+
if (!(ret instanceof OutputStream)) {
|
|
3373
|
+
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3190
3374
|
}
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3375
|
+
var handle0 = ret[symbolRscHandle];
|
|
3376
|
+
if (!handle0) {
|
|
3377
|
+
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3378
|
+
captureTable2.set(rep, ret);
|
|
3379
|
+
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3194
3380
|
}
|
|
3381
|
+
_debugLog('[iface="wasi:cli/stderr@0.2.3", function="get-stderr"][Instruction::Return]', {
|
|
3382
|
+
funcName: 'get-stderr',
|
|
3383
|
+
paramCount: 1,
|
|
3384
|
+
async: false,
|
|
3385
|
+
postReturn: false
|
|
3386
|
+
});
|
|
3387
|
+
task.resolve([handle0]);
|
|
3388
|
+
task.exit();
|
|
3389
|
+
return handle0;
|
|
3390
|
+
}
|
|
3391
|
+
_trampoline5.fnName = 'wasi:cli/stderr@0.2.3#getStderr';
|
|
3392
|
+
const handleTable1 = [T_FLAG, 0];
|
|
3393
|
+
const captureTable1= new Map();
|
|
3394
|
+
let captureCnt1 = 0;
|
|
3395
|
+
handleTables[1] = handleTable1;
|
|
3396
|
+
|
|
3397
|
+
const _trampoline8 = function() {
|
|
3398
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3399
|
+
let hostProvided = true;
|
|
3195
3400
|
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3401
|
+
let parentTask;
|
|
3402
|
+
let task;
|
|
3403
|
+
let subtask;
|
|
3200
3404
|
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3405
|
+
const createTask = () => {
|
|
3406
|
+
const results = createNewCurrentTask({
|
|
3407
|
+
componentIdx: -1, // 0,
|
|
3408
|
+
isAsync: false,
|
|
3409
|
+
entryFnName: 'getStdin',
|
|
3410
|
+
getCallbackFn: () => null,
|
|
3411
|
+
callbackFnName: 'null',
|
|
3412
|
+
errHandling: 'none',
|
|
3413
|
+
callingWasmExport: false,
|
|
3414
|
+
});
|
|
3415
|
+
task = results[0];
|
|
3416
|
+
};
|
|
3207
3417
|
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
let subtask;
|
|
3418
|
+
taskCreation: {
|
|
3419
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3420
|
+
if (!parentTask) {
|
|
3421
|
+
createTask();
|
|
3422
|
+
break taskCreation;
|
|
3423
|
+
}
|
|
3215
3424
|
|
|
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
|
-
};
|
|
3425
|
+
createTask();
|
|
3228
3426
|
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
if (!
|
|
3232
|
-
|
|
3233
|
-
break taskCreation;
|
|
3427
|
+
if (hostProvided) {
|
|
3428
|
+
subtask = parentTask.getLatestSubtask();
|
|
3429
|
+
if (!subtask) {
|
|
3430
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3234
3431
|
}
|
|
3235
|
-
|
|
3432
|
+
task.setParentSubtask(subtask);
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
const started = task.enterSync();
|
|
3437
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3438
|
+
componentIdx: task.componentIdx(),
|
|
3439
|
+
taskID: task.id(),
|
|
3440
|
+
fn: () => getStdin()
|
|
3441
|
+
})
|
|
3442
|
+
;
|
|
3443
|
+
if (!(ret instanceof InputStream)) {
|
|
3444
|
+
throw new TypeError('Resource error: Not a valid "InputStream" resource.');
|
|
3445
|
+
}
|
|
3446
|
+
var handle0 = ret[symbolRscHandle];
|
|
3447
|
+
if (!handle0) {
|
|
3448
|
+
const rep = ret[symbolRscRep] || ++captureCnt1;
|
|
3449
|
+
captureTable1.set(rep, ret);
|
|
3450
|
+
handle0 = rscTableCreateOwn(handleTable1, rep);
|
|
3451
|
+
}
|
|
3452
|
+
_debugLog('[iface="wasi:cli/stdin@0.2.3", function="get-stdin"][Instruction::Return]', {
|
|
3453
|
+
funcName: 'get-stdin',
|
|
3454
|
+
paramCount: 1,
|
|
3455
|
+
async: false,
|
|
3456
|
+
postReturn: false
|
|
3457
|
+
});
|
|
3458
|
+
task.resolve([handle0]);
|
|
3459
|
+
task.exit();
|
|
3460
|
+
return handle0;
|
|
3461
|
+
}
|
|
3462
|
+
_trampoline8.fnName = 'wasi:cli/stdin@0.2.3#getStdin';
|
|
3463
|
+
|
|
3464
|
+
const _trampoline9 = function() {
|
|
3465
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3466
|
+
let hostProvided = true;
|
|
3467
|
+
|
|
3468
|
+
let parentTask;
|
|
3469
|
+
let task;
|
|
3470
|
+
let subtask;
|
|
3471
|
+
|
|
3472
|
+
const createTask = () => {
|
|
3473
|
+
const results = createNewCurrentTask({
|
|
3474
|
+
componentIdx: -1, // 0,
|
|
3475
|
+
isAsync: false,
|
|
3476
|
+
entryFnName: 'getStdout',
|
|
3477
|
+
getCallbackFn: () => null,
|
|
3478
|
+
callbackFnName: 'null',
|
|
3479
|
+
errHandling: 'none',
|
|
3480
|
+
callingWasmExport: false,
|
|
3481
|
+
});
|
|
3482
|
+
task = results[0];
|
|
3483
|
+
};
|
|
3484
|
+
|
|
3485
|
+
taskCreation: {
|
|
3486
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3487
|
+
if (!parentTask) {
|
|
3236
3488
|
createTask();
|
|
3237
|
-
|
|
3238
|
-
if (hostProvided) {
|
|
3239
|
-
subtask = parentTask.getLatestSubtask();
|
|
3240
|
-
if (!subtask) {
|
|
3241
|
-
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3242
|
-
}
|
|
3243
|
-
task.setParentSubtask(subtask);
|
|
3244
|
-
}
|
|
3489
|
+
break taskCreation;
|
|
3245
3490
|
}
|
|
3246
3491
|
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3492
|
+
createTask();
|
|
3493
|
+
|
|
3494
|
+
if (hostProvided) {
|
|
3495
|
+
subtask = parentTask.getLatestSubtask();
|
|
3496
|
+
if (!subtask) {
|
|
3497
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3498
|
+
}
|
|
3499
|
+
task.setParentSubtask(subtask);
|
|
3256
3500
|
}
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
const started = task.enterSync();
|
|
3504
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3505
|
+
componentIdx: task.componentIdx(),
|
|
3506
|
+
taskID: task.id(),
|
|
3507
|
+
fn: () => getStdout()
|
|
3508
|
+
})
|
|
3509
|
+
;
|
|
3510
|
+
if (!(ret instanceof OutputStream)) {
|
|
3511
|
+
throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
|
|
3512
|
+
}
|
|
3513
|
+
var handle0 = ret[symbolRscHandle];
|
|
3514
|
+
if (!handle0) {
|
|
3515
|
+
const rep = ret[symbolRscRep] || ++captureCnt2;
|
|
3516
|
+
captureTable2.set(rep, ret);
|
|
3517
|
+
handle0 = rscTableCreateOwn(handleTable2, rep);
|
|
3518
|
+
}
|
|
3519
|
+
_debugLog('[iface="wasi:cli/stdout@0.2.3", function="get-stdout"][Instruction::Return]', {
|
|
3520
|
+
funcName: 'get-stdout',
|
|
3521
|
+
paramCount: 1,
|
|
3522
|
+
async: false,
|
|
3523
|
+
postReturn: false
|
|
3524
|
+
});
|
|
3525
|
+
task.resolve([handle0]);
|
|
3526
|
+
task.exit();
|
|
3527
|
+
return handle0;
|
|
3528
|
+
}
|
|
3529
|
+
_trampoline9.fnName = 'wasi:cli/stdout@0.2.3#getStdout';
|
|
3530
|
+
|
|
3531
|
+
const _trampoline10 = function(arg0) {
|
|
3532
|
+
let variant0;
|
|
3533
|
+
switch (arg0) {
|
|
3534
|
+
case 0: {
|
|
3535
|
+
variant0= {
|
|
3536
|
+
tag: 'ok',
|
|
3537
|
+
val: undefined
|
|
3538
|
+
};
|
|
3539
|
+
break;
|
|
3540
|
+
}
|
|
3541
|
+
case 1: {
|
|
3542
|
+
variant0= {
|
|
3543
|
+
tag: 'err',
|
|
3544
|
+
val: undefined
|
|
3545
|
+
};
|
|
3546
|
+
break;
|
|
3547
|
+
}
|
|
3548
|
+
default: {
|
|
3549
|
+
throw new TypeError('invalid variant discriminant for expected');
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3553
|
+
let hostProvided = true;
|
|
3554
|
+
|
|
3555
|
+
let parentTask;
|
|
3556
|
+
let task;
|
|
3557
|
+
let subtask;
|
|
3558
|
+
|
|
3559
|
+
const createTask = () => {
|
|
3560
|
+
const results = createNewCurrentTask({
|
|
3561
|
+
componentIdx: -1, // 0,
|
|
3562
|
+
isAsync: false,
|
|
3563
|
+
entryFnName: 'exit',
|
|
3564
|
+
getCallbackFn: () => null,
|
|
3565
|
+
callbackFnName: 'null',
|
|
3566
|
+
errHandling: 'none',
|
|
3567
|
+
callingWasmExport: false,
|
|
3268
3568
|
});
|
|
3269
|
-
task
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
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
|
-
};
|
|
3569
|
+
task = results[0];
|
|
3570
|
+
};
|
|
3571
|
+
|
|
3572
|
+
taskCreation: {
|
|
3573
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3574
|
+
if (!parentTask) {
|
|
3575
|
+
createTask();
|
|
3576
|
+
break taskCreation;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
createTask();
|
|
3299
3580
|
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
if (!
|
|
3303
|
-
|
|
3304
|
-
break taskCreation;
|
|
3581
|
+
if (hostProvided) {
|
|
3582
|
+
subtask = parentTask.getLatestSubtask();
|
|
3583
|
+
if (!subtask) {
|
|
3584
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3305
3585
|
}
|
|
3306
|
-
|
|
3586
|
+
task.setParentSubtask(subtask);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3590
|
+
const started = task.enterSync();
|
|
3591
|
+
let ret;_withGlobalCurrentTaskMeta({
|
|
3592
|
+
componentIdx: task.componentIdx(),
|
|
3593
|
+
taskID: task.id(),
|
|
3594
|
+
fn: () => exit(variant0)
|
|
3595
|
+
})
|
|
3596
|
+
;
|
|
3597
|
+
_debugLog('[iface="wasi:cli/exit@0.2.3", function="exit"][Instruction::Return]', {
|
|
3598
|
+
funcName: 'exit',
|
|
3599
|
+
paramCount: 0,
|
|
3600
|
+
async: false,
|
|
3601
|
+
postReturn: false
|
|
3602
|
+
});
|
|
3603
|
+
task.resolve([ret]);
|
|
3604
|
+
task.exit();
|
|
3605
|
+
}
|
|
3606
|
+
_trampoline10.fnName = 'wasi:cli/exit@0.2.3#exit';
|
|
3607
|
+
let exports2;
|
|
3608
|
+
let memory0;
|
|
3609
|
+
let realloc0;
|
|
3610
|
+
let realloc0Async;
|
|
3611
|
+
|
|
3612
|
+
const _trampoline11 = function(arg0) {
|
|
3613
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3614
|
+
let hostProvided = true;
|
|
3615
|
+
|
|
3616
|
+
let parentTask;
|
|
3617
|
+
let task;
|
|
3618
|
+
let subtask;
|
|
3619
|
+
|
|
3620
|
+
const createTask = () => {
|
|
3621
|
+
const results = createNewCurrentTask({
|
|
3622
|
+
componentIdx: -1, // 0,
|
|
3623
|
+
isAsync: false,
|
|
3624
|
+
entryFnName: 'getEnvironment',
|
|
3625
|
+
getCallbackFn: () => null,
|
|
3626
|
+
callbackFnName: 'null',
|
|
3627
|
+
errHandling: 'none',
|
|
3628
|
+
callingWasmExport: false,
|
|
3629
|
+
});
|
|
3630
|
+
task = results[0];
|
|
3631
|
+
};
|
|
3632
|
+
|
|
3633
|
+
taskCreation: {
|
|
3634
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3635
|
+
if (!parentTask) {
|
|
3307
3636
|
createTask();
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3637
|
+
break taskCreation;
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
createTask();
|
|
3641
|
+
|
|
3642
|
+
if (hostProvided) {
|
|
3643
|
+
subtask = parentTask.getLatestSubtask();
|
|
3644
|
+
if (!subtask) {
|
|
3645
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3315
3646
|
}
|
|
3647
|
+
task.setParentSubtask(subtask);
|
|
3316
3648
|
}
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
const started = task.enterSync();
|
|
3652
|
+
let ret = _withGlobalCurrentTaskMeta({
|
|
3653
|
+
componentIdx: task.componentIdx(),
|
|
3654
|
+
taskID: task.id(),
|
|
3655
|
+
fn: () => getEnvironment()
|
|
3656
|
+
})
|
|
3657
|
+
;
|
|
3658
|
+
var vec3 = ret;
|
|
3659
|
+
var len3 = vec3.length;
|
|
3660
|
+
var result3 = realloc0(0, 0, 4, len3 * 16);
|
|
3661
|
+
for (let i = 0; i < vec3.length; i++) {
|
|
3662
|
+
const e = vec3[i];
|
|
3663
|
+
const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
|
|
3664
|
+
|
|
3665
|
+
var encodeRes = _utf8AllocateAndEncode(tuple0_0, realloc0, memory0);
|
|
3666
|
+
var ptr1= encodeRes.ptr;
|
|
3667
|
+
var len1 = encodeRes.len;
|
|
3668
|
+
|
|
3669
|
+
dataView(memory0).setUint32(base + 4, len1, true);
|
|
3670
|
+
dataView(memory0).setUint32(base + 0, ptr1, true);
|
|
3671
|
+
|
|
3672
|
+
var encodeRes = _utf8AllocateAndEncode(tuple0_1, realloc0, memory0);
|
|
3673
|
+
var ptr2= encodeRes.ptr;
|
|
3674
|
+
var len2 = encodeRes.len;
|
|
3317
3675
|
|
|
3318
|
-
|
|
3319
|
-
|
|
3676
|
+
dataView(memory0).setUint32(base + 12, len2, true);
|
|
3677
|
+
dataView(memory0).setUint32(base + 8, ptr2, true);
|
|
3678
|
+
}
|
|
3679
|
+
dataView(memory0).setUint32(arg0 + 4, len3, true);
|
|
3680
|
+
dataView(memory0).setUint32(arg0 + 0, result3, true);
|
|
3681
|
+
_debugLog('[iface="wasi:cli/environment@0.2.3", function="get-environment"][Instruction::Return]', {
|
|
3682
|
+
funcName: 'get-environment',
|
|
3683
|
+
paramCount: 0,
|
|
3684
|
+
async: false,
|
|
3685
|
+
postReturn: false
|
|
3686
|
+
});
|
|
3687
|
+
task.resolve([ret]);
|
|
3688
|
+
task.exit();
|
|
3689
|
+
}
|
|
3690
|
+
_trampoline11.fnName = 'wasi:cli/environment@0.2.3#getEnvironment';
|
|
3691
|
+
const handleTable6 = [T_FLAG, 0];
|
|
3692
|
+
const captureTable6= new Map();
|
|
3693
|
+
let captureCnt6 = 0;
|
|
3694
|
+
handleTables[6] = handleTable6;
|
|
3695
|
+
|
|
3696
|
+
const _trampoline12 = function(arg0, arg1) {
|
|
3697
|
+
var handle1 = arg0;
|
|
3698
|
+
|
|
3699
|
+
var rep2 = handleTable6[(handle1 << 1) + 1] & ~T_FLAG;
|
|
3700
|
+
var rsc0 = captureTable6.get(rep2);
|
|
3701
|
+
if (!rsc0) {
|
|
3702
|
+
rsc0 = Object.create(Descriptor.prototype);
|
|
3703
|
+
Object.defineProperty(rsc0, symbolRscHandle, { writable: true, value: handle1});
|
|
3704
|
+
Object.defineProperty(rsc0, symbolRscRep, { writable: true, value: rep2});
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
curResourceBorrows.push(rsc0);
|
|
3708
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-flags"] [Instruction::CallInterface] (sync, @ enter)');
|
|
3709
|
+
let hostProvided = true;
|
|
3710
|
+
|
|
3711
|
+
let parentTask;
|
|
3712
|
+
let task;
|
|
3713
|
+
let subtask;
|
|
3714
|
+
|
|
3715
|
+
const createTask = () => {
|
|
3716
|
+
const results = createNewCurrentTask({
|
|
3717
|
+
componentIdx: -1, // 0,
|
|
3718
|
+
isAsync: false,
|
|
3719
|
+
entryFnName: 'getFlags',
|
|
3720
|
+
getCallbackFn: () => null,
|
|
3721
|
+
callbackFnName: 'null',
|
|
3722
|
+
errHandling: 'result-catch-handler',
|
|
3723
|
+
callingWasmExport: false,
|
|
3724
|
+
});
|
|
3725
|
+
task = results[0];
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3728
|
+
taskCreation: {
|
|
3729
|
+
parentTask = getCurrentTask(0)?.task;
|
|
3730
|
+
if (!parentTask) {
|
|
3731
|
+
createTask();
|
|
3732
|
+
break taskCreation;
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
createTask();
|
|
3736
|
+
|
|
3737
|
+
if (hostProvided) {
|
|
3738
|
+
subtask = parentTask.getLatestSubtask();
|
|
3739
|
+
if (!subtask) {
|
|
3740
|
+
throw new Error(`Missing subtask (in parent task [${parentTask.id()}]) for host import, has the import been lowered? (ensure asyncImports are set properly)`);
|
|
3741
|
+
}
|
|
3742
|
+
task.setParentSubtask(subtask);
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
const started = task.enterSync();
|
|
3747
|
+
|
|
3748
|
+
let ret;
|
|
3749
|
+
try {
|
|
3750
|
+
ret = { tag: 'ok', val: _withGlobalCurrentTaskMeta({
|
|
3320
3751
|
componentIdx: task.componentIdx(),
|
|
3321
3752
|
taskID: task.id(),
|
|
3322
|
-
fn: () =>
|
|
3753
|
+
fn: () => rsc0.getFlags()
|
|
3323
3754
|
})
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3755
|
+
};
|
|
3756
|
+
} catch (e) {
|
|
3757
|
+
ret = { tag: 'err', val: getErrorPayload(e) };
|
|
3758
|
+
}
|
|
3759
|
+
|
|
3760
|
+
for (const rsc of curResourceBorrows) {
|
|
3761
|
+
rsc[symbolRscHandle] = undefined;
|
|
3762
|
+
}
|
|
3763
|
+
curResourceBorrows = [];
|
|
3764
|
+
var variant5 = ret;
|
|
3765
|
+
switch (variant5.tag) {
|
|
3766
|
+
case 'ok': {
|
|
3767
|
+
const e = variant5.val;
|
|
3768
|
+
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
3769
|
+
let flags3 = 0;
|
|
3770
|
+
if (typeof e === 'object' && e !== null) {
|
|
3771
|
+
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;
|
|
3772
|
+
} else if (e !== null && e!== undefined) {
|
|
3773
|
+
throw new TypeError('only an object, undefined or null can be converted to flags');
|
|
3327
3774
|
}
|
|
3328
|
-
|
|
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
|
-
};
|
|
3775
|
+
dataView(memory0).setInt8(arg1 + 1, flags3, true);
|
|
3366
3776
|
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3777
|
+
break;
|
|
3778
|
+
}
|
|
3779
|
+
case 'err': {
|
|
3780
|
+
const e = variant5.val;
|
|
3781
|
+
dataView(memory0).setInt8(arg1 + 0, 1, true);
|
|
3782
|
+
var val4 = e;
|
|
3783
|
+
let enum4;
|
|
3784
|
+
switch (val4) {
|
|
3785
|
+
case 'access': {
|
|
3786
|
+
enum4 = 0;
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
case 'would-block': {
|
|
3790
|
+
enum4 = 1;
|
|
3791
|
+
break;
|
|
3792
|
+
}
|
|
3793
|
+
case 'already': {
|
|
3794
|
+
enum4 = 2;
|
|
3795
|
+
break;
|
|
3796
|
+
}
|
|
3797
|
+
case 'bad-descriptor': {
|
|
3798
|
+
enum4 = 3;
|
|
3799
|
+
break;
|
|
3800
|
+
}
|
|
3801
|
+
case 'busy': {
|
|
3802
|
+
enum4 = 4;
|
|
3803
|
+
break;
|
|
3804
|
+
}
|
|
3805
|
+
case 'deadlock': {
|
|
3806
|
+
enum4 = 5;
|
|
3807
|
+
break;
|
|
3808
|
+
}
|
|
3809
|
+
case 'quota': {
|
|
3810
|
+
enum4 = 6;
|
|
3811
|
+
break;
|
|
3812
|
+
}
|
|
3813
|
+
case 'exist': {
|
|
3814
|
+
enum4 = 7;
|
|
3815
|
+
break;
|
|
3816
|
+
}
|
|
3817
|
+
case 'file-too-large': {
|
|
3818
|
+
enum4 = 8;
|
|
3819
|
+
break;
|
|
3820
|
+
}
|
|
3821
|
+
case 'illegal-byte-sequence': {
|
|
3822
|
+
enum4 = 9;
|
|
3823
|
+
break;
|
|
3824
|
+
}
|
|
3825
|
+
case 'in-progress': {
|
|
3826
|
+
enum4 = 10;
|
|
3827
|
+
break;
|
|
3828
|
+
}
|
|
3829
|
+
case 'interrupted': {
|
|
3830
|
+
enum4 = 11;
|
|
3831
|
+
break;
|
|
3832
|
+
}
|
|
3833
|
+
case 'invalid': {
|
|
3834
|
+
enum4 = 12;
|
|
3835
|
+
break;
|
|
3836
|
+
}
|
|
3837
|
+
case 'io': {
|
|
3838
|
+
enum4 = 13;
|
|
3839
|
+
break;
|
|
3840
|
+
}
|
|
3841
|
+
case 'is-directory': {
|
|
3842
|
+
enum4 = 14;
|
|
3843
|
+
break;
|
|
3844
|
+
}
|
|
3845
|
+
case 'loop': {
|
|
3846
|
+
enum4 = 15;
|
|
3847
|
+
break;
|
|
3848
|
+
}
|
|
3849
|
+
case 'too-many-links': {
|
|
3850
|
+
enum4 = 16;
|
|
3851
|
+
break;
|
|
3852
|
+
}
|
|
3853
|
+
case 'message-size': {
|
|
3854
|
+
enum4 = 17;
|
|
3855
|
+
break;
|
|
3856
|
+
}
|
|
3857
|
+
case 'name-too-long': {
|
|
3858
|
+
enum4 = 18;
|
|
3859
|
+
break;
|
|
3860
|
+
}
|
|
3861
|
+
case 'no-device': {
|
|
3862
|
+
enum4 = 19;
|
|
3863
|
+
break;
|
|
3864
|
+
}
|
|
3865
|
+
case 'no-entry': {
|
|
3866
|
+
enum4 = 20;
|
|
3867
|
+
break;
|
|
3868
|
+
}
|
|
3869
|
+
case 'no-lock': {
|
|
3870
|
+
enum4 = 21;
|
|
3871
|
+
break;
|
|
3872
|
+
}
|
|
3873
|
+
case 'insufficient-memory': {
|
|
3874
|
+
enum4 = 22;
|
|
3875
|
+
break;
|
|
3876
|
+
}
|
|
3877
|
+
case 'insufficient-space': {
|
|
3878
|
+
enum4 = 23;
|
|
3879
|
+
break;
|
|
3880
|
+
}
|
|
3881
|
+
case 'not-directory': {
|
|
3882
|
+
enum4 = 24;
|
|
3883
|
+
break;
|
|
3372
3884
|
}
|
|
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);
|
|
3885
|
+
case 'not-empty': {
|
|
3886
|
+
enum4 = 25;
|
|
3887
|
+
break;
|
|
3382
3888
|
}
|
|
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
|
-
};
|
|
3889
|
+
case 'not-recoverable': {
|
|
3890
|
+
enum4 = 26;
|
|
3421
3891
|
break;
|
|
3422
3892
|
}
|
|
3423
|
-
case
|
|
3424
|
-
|
|
3425
|
-
tag: 'err',
|
|
3426
|
-
val: undefined
|
|
3427
|
-
};
|
|
3893
|
+
case 'unsupported': {
|
|
3894
|
+
enum4 = 27;
|
|
3428
3895
|
break;
|
|
3429
3896
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3897
|
+
case 'no-tty': {
|
|
3898
|
+
enum4 = 28;
|
|
3899
|
+
break;
|
|
3432
3900
|
}
|
|
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;
|
|
3901
|
+
case 'no-such-device': {
|
|
3902
|
+
enum4 = 29;
|
|
3903
|
+
break;
|
|
3459
3904
|
}
|
|
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);
|
|
3905
|
+
case 'overflow': {
|
|
3906
|
+
enum4 = 30;
|
|
3907
|
+
break;
|
|
3469
3908
|
}
|
|
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;
|
|
3909
|
+
case 'not-permitted': {
|
|
3910
|
+
enum4 = 31;
|
|
3911
|
+
break;
|
|
3520
3912
|
}
|
|
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);
|
|
3913
|
+
case 'pipe': {
|
|
3914
|
+
enum4 = 32;
|
|
3915
|
+
break;
|
|
3530
3916
|
}
|
|
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;
|
|
3917
|
+
case 'read-only': {
|
|
3918
|
+
enum4 = 33;
|
|
3919
|
+
break;
|
|
3615
3920
|
}
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3921
|
+
case 'invalid-seek': {
|
|
3922
|
+
enum4 = 34;
|
|
3923
|
+
break;
|
|
3924
|
+
}
|
|
3925
|
+
case 'text-file-busy': {
|
|
3926
|
+
enum4 = 35;
|
|
3927
|
+
break;
|
|
3928
|
+
}
|
|
3929
|
+
case 'cross-device': {
|
|
3930
|
+
enum4 = 36;
|
|
3931
|
+
break;
|
|
3932
|
+
}
|
|
3933
|
+
default: {
|
|
3934
|
+
if ((e) instanceof Error) {
|
|
3935
|
+
console.error(e);
|
|
3623
3936
|
}
|
|
3624
|
-
|
|
3937
|
+
|
|
3938
|
+
throw new TypeError(`"${val4}" is not one of the cases of error-code`);
|
|
3625
3939
|
}
|
|
3626
3940
|
}
|
|
3941
|
+
dataView(memory0).setInt8(arg1 + 1, enum4, true);
|
|
3627
3942
|
|
|
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;
|
|
3943
|
+
break;
|
|
3644
3944
|
}
|
|
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
|
-
}
|
|
3945
|
+
default: {
|
|
3946
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
3947
|
+
throw new TypeError('invalid variant specified for result');
|
|
3828
3948
|
}
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3949
|
+
}
|
|
3950
|
+
_debugLog('[iface="wasi:filesystem/types@0.2.3", function="[method]descriptor.get-flags"][Instruction::Return]', {
|
|
3951
|
+
funcName: '[method]descriptor.get-flags',
|
|
3952
|
+
paramCount: 0,
|
|
3953
|
+
async: false,
|
|
3954
|
+
postReturn: false
|
|
3955
|
+
});
|
|
3956
|
+
task.resolve([ret]);
|
|
3957
|
+
task.exit();
|
|
3837
3958
|
}
|
|
3838
3959
|
_trampoline12.fnName = 'wasi:filesystem/types@0.2.3#getFlags';
|
|
3839
3960
|
|
|
@@ -3954,6 +4075,7 @@ switch (variant5.tag) {
|
|
|
3954
4075
|
}
|
|
3955
4076
|
}
|
|
3956
4077
|
dataView(memory0).setInt8(arg1 + 1, enum3, true);
|
|
4078
|
+
|
|
3957
4079
|
break;
|
|
3958
4080
|
}
|
|
3959
4081
|
case 'err': {
|
|
@@ -4119,9 +4241,11 @@ switch (variant5.tag) {
|
|
|
4119
4241
|
}
|
|
4120
4242
|
}
|
|
4121
4243
|
dataView(memory0).setInt8(arg1 + 1, enum4, true);
|
|
4244
|
+
|
|
4122
4245
|
break;
|
|
4123
4246
|
}
|
|
4124
4247
|
default: {
|
|
4248
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
4125
4249
|
throw new TypeError('invalid variant specified for result');
|
|
4126
4250
|
}
|
|
4127
4251
|
}
|
|
@@ -4212,6 +4336,7 @@ switch (variant5.tag) {
|
|
|
4212
4336
|
var {lower: v3_0, upper: v3_1 } = e;
|
|
4213
4337
|
dataView(memory0).setBigInt64(arg1 + 8, toUint64(v3_0), true);
|
|
4214
4338
|
dataView(memory0).setBigInt64(arg1 + 16, toUint64(v3_1), true);
|
|
4339
|
+
|
|
4215
4340
|
break;
|
|
4216
4341
|
}
|
|
4217
4342
|
case 'err': {
|
|
@@ -4377,9 +4502,11 @@ switch (variant5.tag) {
|
|
|
4377
4502
|
}
|
|
4378
4503
|
}
|
|
4379
4504
|
dataView(memory0).setInt8(arg1 + 8, enum4, true);
|
|
4505
|
+
|
|
4380
4506
|
break;
|
|
4381
4507
|
}
|
|
4382
4508
|
default: {
|
|
4509
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
4383
4510
|
throw new TypeError('invalid variant specified for result');
|
|
4384
4511
|
}
|
|
4385
4512
|
}
|
|
@@ -4722,6 +4849,7 @@ switch (variant7.tag) {
|
|
|
4722
4849
|
var {lower: v5_0, upper: v5_1 } = e;
|
|
4723
4850
|
dataView(memory0).setBigInt64(arg4 + 8, toUint64(v5_0), true);
|
|
4724
4851
|
dataView(memory0).setBigInt64(arg4 + 16, toUint64(v5_1), true);
|
|
4852
|
+
|
|
4725
4853
|
break;
|
|
4726
4854
|
}
|
|
4727
4855
|
case 'err': {
|
|
@@ -4887,9 +5015,11 @@ switch (variant7.tag) {
|
|
|
4887
5015
|
}
|
|
4888
5016
|
}
|
|
4889
5017
|
dataView(memory0).setInt8(arg4 + 8, enum6, true);
|
|
5018
|
+
|
|
4890
5019
|
break;
|
|
4891
5020
|
}
|
|
4892
5021
|
default: {
|
|
5022
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant7, valueType: typeof variant7});
|
|
4893
5023
|
throw new TypeError('invalid variant specified for result');
|
|
4894
5024
|
}
|
|
4895
5025
|
}
|
|
@@ -4987,6 +5117,7 @@ switch (variant5.tag) {
|
|
|
4987
5117
|
handle3 = rscTableCreateOwn(handleTable1, rep);
|
|
4988
5118
|
}
|
|
4989
5119
|
dataView(memory0).setInt32(arg2 + 4, handle3, true);
|
|
5120
|
+
|
|
4990
5121
|
break;
|
|
4991
5122
|
}
|
|
4992
5123
|
case 'err': {
|
|
@@ -5152,9 +5283,11 @@ switch (variant5.tag) {
|
|
|
5152
5283
|
}
|
|
5153
5284
|
}
|
|
5154
5285
|
dataView(memory0).setInt8(arg2 + 4, enum4, true);
|
|
5286
|
+
|
|
5155
5287
|
break;
|
|
5156
5288
|
}
|
|
5157
5289
|
default: {
|
|
5290
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5158
5291
|
throw new TypeError('invalid variant specified for result');
|
|
5159
5292
|
}
|
|
5160
5293
|
}
|
|
@@ -5252,6 +5385,7 @@ switch (variant5.tag) {
|
|
|
5252
5385
|
handle3 = rscTableCreateOwn(handleTable2, rep);
|
|
5253
5386
|
}
|
|
5254
5387
|
dataView(memory0).setInt32(arg2 + 4, handle3, true);
|
|
5388
|
+
|
|
5255
5389
|
break;
|
|
5256
5390
|
}
|
|
5257
5391
|
case 'err': {
|
|
@@ -5417,9 +5551,11 @@ switch (variant5.tag) {
|
|
|
5417
5551
|
}
|
|
5418
5552
|
}
|
|
5419
5553
|
dataView(memory0).setInt8(arg2 + 4, enum4, true);
|
|
5554
|
+
|
|
5420
5555
|
break;
|
|
5421
5556
|
}
|
|
5422
5557
|
default: {
|
|
5558
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5423
5559
|
throw new TypeError('invalid variant specified for result');
|
|
5424
5560
|
}
|
|
5425
5561
|
}
|
|
@@ -5517,6 +5653,7 @@ switch (variant5.tag) {
|
|
|
5517
5653
|
handle3 = rscTableCreateOwn(handleTable2, rep);
|
|
5518
5654
|
}
|
|
5519
5655
|
dataView(memory0).setInt32(arg1 + 4, handle3, true);
|
|
5656
|
+
|
|
5520
5657
|
break;
|
|
5521
5658
|
}
|
|
5522
5659
|
case 'err': {
|
|
@@ -5682,9 +5819,11 @@ switch (variant5.tag) {
|
|
|
5682
5819
|
}
|
|
5683
5820
|
}
|
|
5684
5821
|
dataView(memory0).setInt8(arg1 + 4, enum4, true);
|
|
5822
|
+
|
|
5685
5823
|
break;
|
|
5686
5824
|
}
|
|
5687
5825
|
default: {
|
|
5826
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5688
5827
|
throw new TypeError('invalid variant specified for result');
|
|
5689
5828
|
}
|
|
5690
5829
|
}
|
|
@@ -5786,6 +5925,7 @@ switch (variant5.tag) {
|
|
|
5786
5925
|
handle3 = rscTableCreateOwn(handleTable5, rep);
|
|
5787
5926
|
}
|
|
5788
5927
|
dataView(memory0).setInt32(arg1 + 4, handle3, true);
|
|
5928
|
+
|
|
5789
5929
|
break;
|
|
5790
5930
|
}
|
|
5791
5931
|
case 'err': {
|
|
@@ -5951,9 +6091,11 @@ switch (variant5.tag) {
|
|
|
5951
6091
|
}
|
|
5952
6092
|
}
|
|
5953
6093
|
dataView(memory0).setInt8(arg1 + 4, enum4, true);
|
|
6094
|
+
|
|
5954
6095
|
break;
|
|
5955
6096
|
}
|
|
5956
6097
|
default: {
|
|
6098
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
5957
6099
|
throw new TypeError('invalid variant specified for result');
|
|
5958
6100
|
}
|
|
5959
6101
|
}
|
|
@@ -6118,6 +6260,7 @@ switch (variant12.tag) {
|
|
|
6118
6260
|
dataView(memory0).setBigInt64(arg1 + 88, toUint64(v9_0), true);
|
|
6119
6261
|
dataView(memory0).setInt32(arg1 + 96, toUint32(v9_1), true);
|
|
6120
6262
|
}
|
|
6263
|
+
|
|
6121
6264
|
break;
|
|
6122
6265
|
}
|
|
6123
6266
|
case 'err': {
|
|
@@ -6283,9 +6426,11 @@ switch (variant12.tag) {
|
|
|
6283
6426
|
}
|
|
6284
6427
|
}
|
|
6285
6428
|
dataView(memory0).setInt8(arg1 + 8, enum11, true);
|
|
6429
|
+
|
|
6286
6430
|
break;
|
|
6287
6431
|
}
|
|
6288
6432
|
default: {
|
|
6433
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant12, valueType: typeof variant12});
|
|
6289
6434
|
throw new TypeError('invalid variant specified for result');
|
|
6290
6435
|
}
|
|
6291
6436
|
}
|
|
@@ -6459,6 +6604,7 @@ switch (variant14.tag) {
|
|
|
6459
6604
|
dataView(memory0).setBigInt64(arg4 + 88, toUint64(v11_0), true);
|
|
6460
6605
|
dataView(memory0).setInt32(arg4 + 96, toUint32(v11_1), true);
|
|
6461
6606
|
}
|
|
6607
|
+
|
|
6462
6608
|
break;
|
|
6463
6609
|
}
|
|
6464
6610
|
case 'err': {
|
|
@@ -6624,9 +6770,11 @@ switch (variant14.tag) {
|
|
|
6624
6770
|
}
|
|
6625
6771
|
}
|
|
6626
6772
|
dataView(memory0).setInt8(arg4 + 8, enum13, true);
|
|
6773
|
+
|
|
6627
6774
|
break;
|
|
6628
6775
|
}
|
|
6629
6776
|
default: {
|
|
6777
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant14, valueType: typeof variant14});
|
|
6630
6778
|
throw new TypeError('invalid variant specified for result');
|
|
6631
6779
|
}
|
|
6632
6780
|
}
|
|
@@ -6753,6 +6901,7 @@ switch (variant9.tag) {
|
|
|
6753
6901
|
handle7 = rscTableCreateOwn(handleTable6, rep);
|
|
6754
6902
|
}
|
|
6755
6903
|
dataView(memory0).setInt32(arg6 + 4, handle7, true);
|
|
6904
|
+
|
|
6756
6905
|
break;
|
|
6757
6906
|
}
|
|
6758
6907
|
case 'err': {
|
|
@@ -6918,9 +7067,11 @@ switch (variant9.tag) {
|
|
|
6918
7067
|
}
|
|
6919
7068
|
}
|
|
6920
7069
|
dataView(memory0).setInt8(arg6 + 4, enum8, true);
|
|
7070
|
+
|
|
6921
7071
|
break;
|
|
6922
7072
|
}
|
|
6923
7073
|
default: {
|
|
7074
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant9, valueType: typeof variant9});
|
|
6924
7075
|
throw new TypeError('invalid variant specified for result');
|
|
6925
7076
|
}
|
|
6926
7077
|
}
|
|
@@ -7067,6 +7218,7 @@ switch (variant8.tag) {
|
|
|
7067
7218
|
dataView(memory0).setUint32(arg1 + 16, len5, true);
|
|
7068
7219
|
dataView(memory0).setUint32(arg1 + 12, ptr5, true);
|
|
7069
7220
|
}
|
|
7221
|
+
|
|
7070
7222
|
break;
|
|
7071
7223
|
}
|
|
7072
7224
|
case 'err': {
|
|
@@ -7232,9 +7384,11 @@ switch (variant8.tag) {
|
|
|
7232
7384
|
}
|
|
7233
7385
|
}
|
|
7234
7386
|
dataView(memory0).setInt8(arg1 + 4, enum7, true);
|
|
7387
|
+
|
|
7235
7388
|
break;
|
|
7236
7389
|
}
|
|
7237
7390
|
default: {
|
|
7391
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant8, valueType: typeof variant8});
|
|
7238
7392
|
throw new TypeError('invalid variant specified for result');
|
|
7239
7393
|
}
|
|
7240
7394
|
}
|
|
@@ -7323,7 +7477,7 @@ switch (variant6.tag) {
|
|
|
7323
7477
|
const e = variant6.val;
|
|
7324
7478
|
dataView(memory0).setInt8(arg2 + 0, 0, true);
|
|
7325
7479
|
var val3 = e;
|
|
7326
|
-
var len3 = val3.byteLength;
|
|
7480
|
+
var len3 = Array.isArray(val3) ? val3.length : val3.byteLength;
|
|
7327
7481
|
var ptr3 = realloc0(0, 0, 1, len3 * 1);
|
|
7328
7482
|
|
|
7329
7483
|
let valData3;
|
|
@@ -7345,6 +7499,7 @@ switch (variant6.tag) {
|
|
|
7345
7499
|
|
|
7346
7500
|
dataView(memory0).setUint32(arg2 + 8, len3, true);
|
|
7347
7501
|
dataView(memory0).setUint32(arg2 + 4, ptr3, true);
|
|
7502
|
+
|
|
7348
7503
|
break;
|
|
7349
7504
|
}
|
|
7350
7505
|
case 'err': {
|
|
@@ -7375,9 +7530,11 @@ switch (variant6.tag) {
|
|
|
7375
7530
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7376
7531
|
}
|
|
7377
7532
|
}
|
|
7533
|
+
|
|
7378
7534
|
break;
|
|
7379
7535
|
}
|
|
7380
7536
|
default: {
|
|
7537
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7381
7538
|
throw new TypeError('invalid variant specified for result');
|
|
7382
7539
|
}
|
|
7383
7540
|
}
|
|
@@ -7466,7 +7623,7 @@ switch (variant6.tag) {
|
|
|
7466
7623
|
const e = variant6.val;
|
|
7467
7624
|
dataView(memory0).setInt8(arg2 + 0, 0, true);
|
|
7468
7625
|
var val3 = e;
|
|
7469
|
-
var len3 = val3.byteLength;
|
|
7626
|
+
var len3 = Array.isArray(val3) ? val3.length : val3.byteLength;
|
|
7470
7627
|
var ptr3 = realloc0(0, 0, 1, len3 * 1);
|
|
7471
7628
|
|
|
7472
7629
|
let valData3;
|
|
@@ -7488,6 +7645,7 @@ switch (variant6.tag) {
|
|
|
7488
7645
|
|
|
7489
7646
|
dataView(memory0).setUint32(arg2 + 8, len3, true);
|
|
7490
7647
|
dataView(memory0).setUint32(arg2 + 4, ptr3, true);
|
|
7648
|
+
|
|
7491
7649
|
break;
|
|
7492
7650
|
}
|
|
7493
7651
|
case 'err': {
|
|
@@ -7518,9 +7676,11 @@ switch (variant6.tag) {
|
|
|
7518
7676
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7519
7677
|
}
|
|
7520
7678
|
}
|
|
7679
|
+
|
|
7521
7680
|
break;
|
|
7522
7681
|
}
|
|
7523
7682
|
default: {
|
|
7683
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7524
7684
|
throw new TypeError('invalid variant specified for result');
|
|
7525
7685
|
}
|
|
7526
7686
|
}
|
|
@@ -7609,6 +7769,7 @@ switch (variant5.tag) {
|
|
|
7609
7769
|
const e = variant5.val;
|
|
7610
7770
|
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
7611
7771
|
dataView(memory0).setBigInt64(arg1 + 8, toUint64(e), true);
|
|
7772
|
+
|
|
7612
7773
|
break;
|
|
7613
7774
|
}
|
|
7614
7775
|
case 'err': {
|
|
@@ -7639,9 +7800,11 @@ switch (variant5.tag) {
|
|
|
7639
7800
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant4.tag)}\` (received \`${variant4}\`) specified for \`StreamError\``);
|
|
7640
7801
|
}
|
|
7641
7802
|
}
|
|
7803
|
+
|
|
7642
7804
|
break;
|
|
7643
7805
|
}
|
|
7644
7806
|
default: {
|
|
7807
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
7645
7808
|
throw new TypeError('invalid variant specified for result');
|
|
7646
7809
|
}
|
|
7647
7810
|
}
|
|
@@ -7732,6 +7895,7 @@ switch (variant6.tag) {
|
|
|
7732
7895
|
case 'ok': {
|
|
7733
7896
|
const e = variant6.val;
|
|
7734
7897
|
dataView(memory0).setInt8(arg3 + 0, 0, true);
|
|
7898
|
+
|
|
7735
7899
|
break;
|
|
7736
7900
|
}
|
|
7737
7901
|
case 'err': {
|
|
@@ -7762,9 +7926,11 @@ switch (variant6.tag) {
|
|
|
7762
7926
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7763
7927
|
}
|
|
7764
7928
|
}
|
|
7929
|
+
|
|
7765
7930
|
break;
|
|
7766
7931
|
}
|
|
7767
7932
|
default: {
|
|
7933
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7768
7934
|
throw new TypeError('invalid variant specified for result');
|
|
7769
7935
|
}
|
|
7770
7936
|
}
|
|
@@ -7855,6 +8021,7 @@ switch (variant6.tag) {
|
|
|
7855
8021
|
case 'ok': {
|
|
7856
8022
|
const e = variant6.val;
|
|
7857
8023
|
dataView(memory0).setInt8(arg3 + 0, 0, true);
|
|
8024
|
+
|
|
7858
8025
|
break;
|
|
7859
8026
|
}
|
|
7860
8027
|
case 'err': {
|
|
@@ -7885,9 +8052,11 @@ switch (variant6.tag) {
|
|
|
7885
8052
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant5.tag)}\` (received \`${variant5}\`) specified for \`StreamError\``);
|
|
7886
8053
|
}
|
|
7887
8054
|
}
|
|
8055
|
+
|
|
7888
8056
|
break;
|
|
7889
8057
|
}
|
|
7890
8058
|
default: {
|
|
8059
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant6, valueType: typeof variant6});
|
|
7891
8060
|
throw new TypeError('invalid variant specified for result');
|
|
7892
8061
|
}
|
|
7893
8062
|
}
|
|
@@ -7975,6 +8144,7 @@ switch (variant5.tag) {
|
|
|
7975
8144
|
case 'ok': {
|
|
7976
8145
|
const e = variant5.val;
|
|
7977
8146
|
dataView(memory0).setInt8(arg1 + 0, 0, true);
|
|
8147
|
+
|
|
7978
8148
|
break;
|
|
7979
8149
|
}
|
|
7980
8150
|
case 'err': {
|
|
@@ -8005,9 +8175,11 @@ switch (variant5.tag) {
|
|
|
8005
8175
|
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant4.tag)}\` (received \`${variant4}\`) specified for \`StreamError\``);
|
|
8006
8176
|
}
|
|
8007
8177
|
}
|
|
8178
|
+
|
|
8008
8179
|
break;
|
|
8009
8180
|
}
|
|
8010
8181
|
default: {
|
|
8182
|
+
_debugLog("ERROR: invalid value (expected result as object with 'tag' member)", { value: variant5, valueType: typeof variant5});
|
|
8011
8183
|
throw new TypeError('invalid variant specified for result');
|
|
8012
8184
|
}
|
|
8013
8185
|
}
|
|
@@ -8069,7 +8241,7 @@ const _trampoline31 = function(arg0, arg1) {
|
|
|
8069
8241
|
})
|
|
8070
8242
|
;
|
|
8071
8243
|
var val0 = ret;
|
|
8072
|
-
var len0 = val0.byteLength;
|
|
8244
|
+
var len0 = Array.isArray(val0) ? val0.length : val0.byteLength;
|
|
8073
8245
|
var ptr0 = realloc0(0, 0, 1, len0 * 1);
|
|
8074
8246
|
|
|
8075
8247
|
let valData0;
|
|
@@ -8852,7 +9024,7 @@ null,
|
|
|
8852
9024
|
componentIdx: 0,
|
|
8853
9025
|
isAsync: false,
|
|
8854
9026
|
isManualAsync: _trampoline16.manuallyAsync,
|
|
8855
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9027
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
8856
9028
|
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
9029
|
funcTypeIsAsync: false,
|
|
8858
9030
|
getCallbackFn: () => null,
|
|
@@ -8870,7 +9042,7 @@ null,
|
|
|
8870
9042
|
componentIdx: 0,
|
|
8871
9043
|
isAsync: false,
|
|
8872
9044
|
isManualAsync: _trampoline16.manuallyAsync,
|
|
8873
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9045
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
8874
9046
|
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
9047
|
funcTypeIsAsync: false,
|
|
8876
9048
|
getCallbackFn: () => null,
|
|
@@ -9074,7 +9246,7 @@ null,
|
|
|
9074
9246
|
componentIdx: 0,
|
|
9075
9247
|
isAsync: false,
|
|
9076
9248
|
isManualAsync: _trampoline22.manuallyAsync,
|
|
9077
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9249
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
9078
9250
|
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
9251
|
funcTypeIsAsync: false,
|
|
9080
9252
|
getCallbackFn: () => null,
|
|
@@ -9092,7 +9264,7 @@ null,
|
|
|
9092
9264
|
componentIdx: 0,
|
|
9093
9265
|
isAsync: false,
|
|
9094
9266
|
isManualAsync: _trampoline22.manuallyAsync,
|
|
9095
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9267
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags({ names: ['symlink-follow'], size32: 1, align32: 1, intSize: 1 }),_liftFlatStringUTF8],
|
|
9096
9268
|
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
9269
|
funcTypeIsAsync: false,
|
|
9098
9270
|
getCallbackFn: () => null,
|
|
@@ -9111,7 +9283,7 @@ null,
|
|
|
9111
9283
|
componentIdx: 0,
|
|
9112
9284
|
isAsync: false,
|
|
9113
9285
|
isManualAsync: _trampoline23.manuallyAsync,
|
|
9114
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9286
|
+
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
9287
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatOwn.bind(null, 6), 8, 4, 4 ],[ 'err', _lowerFlatEnum.bind(null, 0), 8, 4, 4 ],])],
|
|
9116
9288
|
funcTypeIsAsync: false,
|
|
9117
9289
|
getCallbackFn: () => null,
|
|
@@ -9129,7 +9301,7 @@ null,
|
|
|
9129
9301
|
componentIdx: 0,
|
|
9130
9302
|
isAsync: false,
|
|
9131
9303
|
isManualAsync: _trampoline23.manuallyAsync,
|
|
9132
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 6),_liftFlatFlags
|
|
9304
|
+
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
9305
|
resultLowerFns: [_lowerFlatResult([[ 'ok', _lowerFlatOwn.bind(null, 6), 8, 4, 4 ],[ 'err', _lowerFlatEnum.bind(null, 0), 8, 4, 4 ],])],
|
|
9134
9306
|
funcTypeIsAsync: false,
|
|
9135
9307
|
getCallbackFn: () => null,
|
|
@@ -9296,7 +9468,7 @@ null,
|
|
|
9296
9468
|
componentIdx: 0,
|
|
9297
9469
|
isAsync: false,
|
|
9298
9470
|
isManualAsync: _trampoline28.manuallyAsync,
|
|
9299
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9471
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9300
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 ],])],
|
|
9301
9473
|
funcTypeIsAsync: false,
|
|
9302
9474
|
getCallbackFn: () => null,
|
|
@@ -9314,7 +9486,7 @@ null,
|
|
|
9314
9486
|
componentIdx: 0,
|
|
9315
9487
|
isAsync: false,
|
|
9316
9488
|
isManualAsync: _trampoline28.manuallyAsync,
|
|
9317
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9489
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9318
9490
|
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
9491
|
funcTypeIsAsync: false,
|
|
9320
9492
|
getCallbackFn: () => null,
|
|
@@ -9333,7 +9505,7 @@ null,
|
|
|
9333
9505
|
componentIdx: 0,
|
|
9334
9506
|
isAsync: false,
|
|
9335
9507
|
isManualAsync: _trampoline29.manuallyAsync,
|
|
9336
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9508
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9337
9509
|
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
9510
|
funcTypeIsAsync: false,
|
|
9339
9511
|
getCallbackFn: () => null,
|
|
@@ -9351,7 +9523,7 @@ null,
|
|
|
9351
9523
|
componentIdx: 0,
|
|
9352
9524
|
isAsync: false,
|
|
9353
9525
|
isManualAsync: _trampoline29.manuallyAsync,
|
|
9354
|
-
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList
|
|
9526
|
+
paramLiftFns: [_liftFlatBorrow.bind(null, 2),_liftFlatList({ elemLiftFn: _liftFlatU8, align32: 1, size32: 1 })],
|
|
9355
9527
|
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
9528
|
funcTypeIsAsync: false,
|
|
9357
9529
|
getCallbackFn: () => null,
|
|
@@ -9591,7 +9763,7 @@ function generate(arg0, arg1) {
|
|
|
9591
9763
|
if (!_initialized) throwUninitialized();
|
|
9592
9764
|
var ptr0 = realloc1(0, 0, 4, 84);
|
|
9593
9765
|
var val1 = arg0;
|
|
9594
|
-
var len1 = val1.byteLength;
|
|
9766
|
+
var len1 = Array.isArray(val1) ? val1.length : val1.byteLength;
|
|
9595
9767
|
var ptr1 = realloc1(0, 0, 1, len1 * 1);
|
|
9596
9768
|
|
|
9597
9769
|
let valData1;
|
|
@@ -9990,7 +10162,7 @@ function generateTypes(arg0, arg1) {
|
|
|
9990
10162
|
const e = variant6.val;
|
|
9991
10163
|
dataView(memory0).setInt8(ptr0 + 8, 1, true);
|
|
9992
10164
|
var val4 = e;
|
|
9993
|
-
var len4 = val4.byteLength;
|
|
10165
|
+
var len4 = Array.isArray(val4) ? val4.length : val4.byteLength;
|
|
9994
10166
|
var ptr4 = realloc1(0, 0, 1, len4 * 1);
|
|
9995
10167
|
|
|
9996
10168
|
let valData4;
|