@scriptc/compiler 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +45 -17
- package/ambient/scriptc.d.ts +2 -1
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/c/async.js +24 -2
- package/dist/backend/c/async.js.map +1 -1
- package/dist/backend/c/c-emitter.d.ts +22 -10
- package/dist/backend/c/c-emitter.js +60 -15
- package/dist/backend/c/c-emitter.js.map +1 -1
- package/dist/backend/c/exprs.js +220 -10
- package/dist/backend/c/exprs.js.map +1 -1
- package/dist/backend/c/island.js.map +1 -1
- package/dist/backend/c/may-throw.js.map +1 -1
- package/dist/backend/c/stmts.d.ts +3 -5
- package/dist/backend/c/stmts.js +58 -17
- package/dist/backend/c/stmts.js.map +1 -1
- package/dist/backend/c/types.js.map +1 -1
- package/dist/backend/c/walkers.js +31 -5
- package/dist/backend/c/walkers.js.map +1 -1
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/dyn.js +56 -3
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +98 -19
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +85 -3
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +1 -0
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +6 -3
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +220 -9
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +2 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +18 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +6 -3
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -0
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/compat/fetch-profile.js +4 -2
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +12 -0
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +6 -5
- package/dist/diagnostics/diagnostic.js +7 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +10 -0
- package/dist/frontend/input-tracker.js +26 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +8 -1
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -0
- package/dist/frontend/lowering/array-values.js +18 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +35 -0
- package/dist/frontend/lowering/containers/bytes.js +1021 -0
- package/dist/frontend/lowering/containers/bytes.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +17 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +345 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.d.ts +13 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.js +76 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.d.ts +44 -0
- package/dist/frontend/lowering/expressions/object-literals.js +1815 -0
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -0
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +31 -0
- package/dist/frontend/lowering/expressions/optional-chains.js +382 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.d.ts +7 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js +26 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.js +7 -2
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +7 -0
- package/dist/frontend/lowering/lower-async-iteration.js +657 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +18 -0
- package/dist/frontend/lowering/lower-builtins.js +219 -48
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +13 -4
- package/dist/frontend/lowering/lower-calls.js +407 -64
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +7 -13
- package/dist/frontend/lowering/lower-classes.js +128 -35
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +1 -47
- package/dist/frontend/lowering/lower-containers.js +135 -1467
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +51 -5
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -78
- package/dist/frontend/lowering/lower-exprs.js +402 -2351
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +18 -3
- package/dist/frontend/lowering/lower-generators.js +145 -9
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +3 -3
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +6 -0
- package/dist/frontend/lowering/lower-island.js +37 -5
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +52 -15
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +18 -0
- package/dist/frontend/lowering/lower-node-module.js +302 -0
- package/dist/frontend/lowering/lower-node-module.js.map +1 -0
- package/dist/frontend/lowering/lower-server.js +1 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +5 -24
- package/dist/frontend/lowering/lower-stmts.js +519 -253
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +4 -4
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +37 -34
- package/dist/frontend/lowering/lowerer.js +143 -57
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.d.ts +9 -0
- package/dist/frontend/lowering/optional-arguments.js +57 -0
- package/dist/frontend/lowering/optional-arguments.js.map +1 -0
- package/dist/frontend/npm-static-declarations.d.ts +35 -0
- package/dist/frontend/npm-static-declarations.js +506 -0
- package/dist/frontend/npm-static-declarations.js.map +1 -0
- package/dist/frontend/npm-static-declarations.test.d.ts +1 -0
- package/dist/frontend/npm-static-declarations.test.js +122 -0
- package/dist/frontend/npm-static-declarations.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +2 -0
- package/dist/frontend/npm-static.js +26 -10
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +60 -0
- package/dist/frontend/npm.js +38 -4
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.d.ts +1 -0
- package/dist/frontend/npm.test.js +50 -0
- package/dist/frontend/npm.test.js.map +1 -0
- package/dist/frontend/program.d.ts +3 -2
- package/dist/frontend/program.js +495 -68
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +10 -2
- package/dist/frontend/resolve.js +90 -14
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +4 -1
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +22 -0
- package/dist/frontend/runtime-resolve.js +101 -0
- package/dist/frontend/runtime-resolve.js.map +1 -0
- package/dist/frontend/runtime-resolve.test.d.ts +1 -0
- package/dist/frontend/runtime-resolve.test.js +18 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.js +12 -13
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +3 -3
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +3 -0
- package/dist/frontend/ts7/checker.js +12 -3
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/program-adapter.js +42 -3
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/type-mapper.js +120 -7
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/ir.d.ts +60 -30
- package/dist/ir/ir.js +57 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/validate.js +44 -59
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/cache-reset.test.js.map +1 -1
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.js.map +1 -1
- package/dist/startup-cache.js.map +1 -1
- package/dist/wasi-paths.js.map +1 -1
- package/package.json +18 -18
- package/surface-manifest.json +60 -4
package/dist/ir/ir.d.ts
CHANGED
|
@@ -359,6 +359,7 @@ export type IrType = {
|
|
|
359
359
|
* array elements, and JSON. */
|
|
360
360
|
| {
|
|
361
361
|
kind: "generator";
|
|
362
|
+
async?: true;
|
|
362
363
|
yieldT: IrType;
|
|
363
364
|
retT: IrType;
|
|
364
365
|
nextT: IrType;
|
|
@@ -389,11 +390,11 @@ interface IrKindSet<K extends IrType["kind"]> extends ReadonlySet<IrType["kind"]
|
|
|
389
390
|
* every other handle has pointer representation. */
|
|
390
391
|
declare const HANDLE_KIND_LIST: readonly ["stats", "fileHandle", "spawnRes", "child", "netServer", "netSocket", "http2Session", "http2Stream", "dgramSocket", "testCtx", "httpReq", "httpRes", "httpClientReq", "secureCtx", "fsWatcher", "childStream", "procStream"];
|
|
391
392
|
export type HandleKind = typeof HANDLE_KIND_LIST[number];
|
|
392
|
-
export declare const HANDLE_KINDS: IrKindSet<"
|
|
393
|
+
export declare const HANDLE_KINDS: IrKindSet<"child" | "childStream" | "dgramSocket" | "fileHandle" | "fsWatcher" | "http2Session" | "http2Stream" | "httpClientReq" | "httpReq" | "httpRes" | "netServer" | "netSocket" | "procStream" | "secureCtx" | "spawnRes" | "stats" | "testCtx">;
|
|
393
394
|
/** The IR kinds represented as pointers in both native backends. */
|
|
394
395
|
declare const POINTER_KIND_LIST: readonly ["string", "array", "map", "set", "regex", "bytes", "url", "searchParams", "symbol", "stats", "fileHandle", "spawnRes", "child", "netServer", "netSocket", "http2Session", "http2Stream", "dgramSocket", "testCtx", "httpReq", "httpRes", "httpClientReq", "secureCtx", "fsWatcher", "childStream", "func", "object", "classval", "record", "union", "dyn", "jsval", "caught", "promise", "generator"];
|
|
395
396
|
export type PointerKind = typeof POINTER_KIND_LIST[number];
|
|
396
|
-
export declare const POINTER_KINDS: IrKindSet<"
|
|
397
|
+
export declare const POINTER_KINDS: IrKindSet<"array" | "bytes" | "caught" | "child" | "childStream" | "classval" | "dgramSocket" | "dyn" | "fileHandle" | "fsWatcher" | "func" | "generator" | "http2Session" | "http2Stream" | "httpClientReq" | "httpReq" | "httpRes" | "jsval" | "map" | "netServer" | "netSocket" | "object" | "promise" | "record" | "regex" | "searchParams" | "secureCtx" | "set" | "spawnRes" | "stats" | "string" | "symbol" | "testCtx" | "union" | "url">;
|
|
397
398
|
/** Runtime RC symbol stem for each IR type kind. An empty stem means the
|
|
398
399
|
* kind is scalar/unit or uses an emitted per-shape helper (object/record).
|
|
399
400
|
* Keeping this exhaustive makes a new runtime handle kind a compile error
|
|
@@ -945,7 +946,9 @@ export interface IrFunction {
|
|
|
945
946
|
* Each is also listed in `locals` (with boxed: true); it is NOT a param. */
|
|
946
947
|
captures?: IrParam[];
|
|
947
948
|
/** Async: the body runs on a fiber; `returnType` is the INNER type T (a
|
|
948
|
-
* `return v` fulfills with v) while call sites receive
|
|
949
|
+
* `return v` fulfills with v) while ordinary call sites receive
|
|
950
|
+
* Promise<T>. With `generator` present, call sites receive the lazy
|
|
951
|
+
* async-generator object instead. */
|
|
949
952
|
async?: true;
|
|
950
953
|
/** Async module initializers only: a module-global Promise<T> slot where
|
|
951
954
|
* the spawn wrapper caches its first evaluation promise. Every later
|
|
@@ -958,17 +961,21 @@ export interface IrFunction {
|
|
|
958
961
|
* becomes the runtime cycle root. Dynamic imports wait on this shared
|
|
959
962
|
* completion verdict instead of a build-time-selected member. */
|
|
960
963
|
asyncCycleCacheGlobal?: string;
|
|
961
|
-
/** Generator (`function*`): the body runs on a fiber created SUSPENDED
|
|
964
|
+
/** Generator (`function*` / `async function*`): the body runs on a fiber created SUSPENDED
|
|
962
965
|
* (nothing runs until the first `.next()`); `returnType` is the
|
|
963
966
|
* generator's TReturn (VOID when it carries no value — `return;`
|
|
964
967
|
* completes with the undefined arm) while call sites receive the
|
|
965
|
-
* generator type `{ yieldT, retT: returnType, nextT }` from an emitted
|
|
968
|
+
* generator type `{ async?, yieldT, retT: returnType, nextT }` from an emitted
|
|
966
969
|
* spawn wrapper that only allocates. `yieldT` is what `yield e` sends
|
|
967
970
|
* out, `nextT` what `.next(v)` sends in (the yield expression's result
|
|
968
|
-
* type).
|
|
971
|
+
* type). `async` alongside this field marks an async generator: its
|
|
972
|
+
* resume methods queue requests and return promises. */
|
|
969
973
|
generator?: {
|
|
970
974
|
yieldT: IrType;
|
|
971
975
|
nextT: IrType;
|
|
976
|
+
resultType: IrType & {
|
|
977
|
+
kind: "record";
|
|
978
|
+
};
|
|
972
979
|
};
|
|
973
980
|
body: IrStmt[];
|
|
974
981
|
loc: SrcLoc;
|
|
@@ -1283,23 +1290,19 @@ export type IrStmt =
|
|
|
1283
1290
|
* completion AND on the exception path (after catch, or with the
|
|
1284
1291
|
* exception still pending when there is no catch — it keeps propagating
|
|
1285
1292
|
* after the finally completes; a throw inside the finally replaces it).
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* the
|
|
1290
|
-
* invisible, Node-exact; a throw inside such a finally replaces the
|
|
1291
|
-
* pending return, releasing the snapshot). The frontend still rejects
|
|
1292
|
-
* break/continue crossing a try-with-finally and ANY jump out of a
|
|
1293
|
-
* finally body, so normal, exception, and pending-return are the only
|
|
1294
|
-
* completions a finally sees; plain try/catch has no such restriction
|
|
1295
|
-
* (jumps out release the try scopes like any other jump). Each body is
|
|
1296
|
-
* its own lexical scope. */
|
|
1293
|
+
* Every abrupt completion crossing the region runs the finally
|
|
1294
|
+
* inner-to-outer. Return values are snapshotted first; break/continue
|
|
1295
|
+
* retain their resolved targets; and a completion raised inside the
|
|
1296
|
+
* finally replaces the pending one. Each body is its own lexical scope. */
|
|
1297
1297
|
| {
|
|
1298
1298
|
kind: "tryCatch";
|
|
1299
1299
|
tryBody: IrStmt[];
|
|
1300
1300
|
catchBody: IrStmt[] | null;
|
|
1301
1301
|
catchLocalId: string | null;
|
|
1302
1302
|
finallyBody: IrStmt[] | null;
|
|
1303
|
+
/** Resource-management cleanup: if the guarded body and cleanup both
|
|
1304
|
+
* throw, raise a SuppressedError instead of replacing the first error. */
|
|
1305
|
+
suppressFinallyErrors?: true;
|
|
1303
1306
|
loc: SrcLoc;
|
|
1304
1307
|
};
|
|
1305
1308
|
/** The complete array method/property surface (mirrors ambient/scriptc.d.ts).
|
|
@@ -1578,7 +1581,11 @@ export type IrLibFn =
|
|
|
1578
1581
|
* (bytes decode per the literal encoding — utf8 default; strings,
|
|
1579
1582
|
* numbers, booleans, arrays, objects answer JS-exactly; undefined and
|
|
1580
1583
|
* null throw the catchable TypeError). */
|
|
1581
|
-
| "dyn.toString"
|
|
1584
|
+
| "dyn.toString"
|
|
1585
|
+
/** Engine-free CommonJS module graph. Module values are scalar f64
|
|
1586
|
+
* handles; generated startup defines the registry, init wrappers update
|
|
1587
|
+
* loading/cache state, and the read surface answers Node's live metadata. */
|
|
1588
|
+
| "module.registryInit" | "module.define" | "module.enter" | "module.link" | "module.finish" | "module.fail" | "module.filename" | "module.id" | "module.path" | "module.paths" | "module.children" | "module.parent" | "module.loaded" | "module.cacheGet" | "module.cacheHas" | "module.cacheKeys" | "fs.readFileSync"
|
|
1582
1589
|
/** readFileSync(path) — the Buffer read (+1 bytes); throws catchably
|
|
1583
1590
|
* like the utf8 form. */
|
|
1584
1591
|
| "fs.readFileSyncBuf"
|
|
@@ -2855,7 +2862,11 @@ export type IrLibFn =
|
|
|
2855
2862
|
* error. The Dyn twin boxes chunks by runtime tag (the JS lane).
|
|
2856
2863
|
* readable.fromArr is Readable.from(array): a fully-seeded object-
|
|
2857
2864
|
* entry stream (one whole chunk per element; strings per the flag). */
|
|
2858
|
-
| "readable.nextChunk" | "readable.nextChunkDyn" | "readable.fromArr" | "readable.isPaused" | "readable.pipe" | "readable.unpipe" | "readable.flowing" | "writable.write" | "writable.writeStr" | "writable.writeU" | "writable.writeDyn" | "writable.end" | "writable.cork" | "writable.uncork" | "stream.destroy" | "stream.destroyErr"
|
|
2865
|
+
| "readable.nextChunk" | "readable.nextChunkDyn" | "readable.fromArr" | "readable.isPaused" | "readable.pipe" | "readable.unpipe" | "readable.flowing" | "writable.write" | "writable.writeStr" | "writable.writeU" | "writable.writeDyn" | "writable.end" | "writable.cork" | "writable.uncork" | "stream.destroy" | "stream.destroyErr"
|
|
2866
|
+
/** AsyncIteratorClose for Readable[Symbol.asyncIterator](): destroy with
|
|
2867
|
+
* Node's AbortError/ABORT_ERR payload while the iterator's internal error
|
|
2868
|
+
* consumer prevents an unhandled-error crash. */
|
|
2869
|
+
| "stream.iteratorClose" | "stream.prop" | "stream.errored"
|
|
2859
2870
|
/** The underscore-method assignment surface (`r._read = fn` after
|
|
2860
2871
|
* construction — Node's own-property shadow of the prototype method):
|
|
2861
2872
|
* args [stream receiver (borrowed), callback closure (+1 moves)]. The
|
|
@@ -3859,6 +3870,7 @@ export type IrExpr =
|
|
|
3859
3870
|
| {
|
|
3860
3871
|
kind: "yieldExpr";
|
|
3861
3872
|
value: IrExpr | null;
|
|
3873
|
+
awaited?: true;
|
|
3862
3874
|
type: IrType;
|
|
3863
3875
|
loc: SrcLoc;
|
|
3864
3876
|
}
|
|
@@ -3877,8 +3889,9 @@ export type IrExpr =
|
|
|
3877
3889
|
* unless suspended (then the GENRET unwind runs finallys; a finally
|
|
3878
3890
|
* yield answers done:false and parks the return value) / throw on a
|
|
3879
3891
|
* non-suspended generator marks it done and re-throws at the call site.
|
|
3880
|
-
*
|
|
3881
|
-
*
|
|
3892
|
+
* Sync generators return that record directly and propagate body errors
|
|
3893
|
+
* synchronously. Async generators return Promise<record>; requests queue,
|
|
3894
|
+
* and body errors reject the corresponding promise. */
|
|
3882
3895
|
| {
|
|
3883
3896
|
kind: "genResume";
|
|
3884
3897
|
mode: "next" | "return" | "throw";
|
|
@@ -4158,12 +4171,13 @@ export type IrExpr =
|
|
|
4158
4171
|
* TypeError), the interned signature key (dynCheck's exact-unwrap fast
|
|
4159
4172
|
* path), and `fnName` — the best-effort static spelling for inspect
|
|
4160
4173
|
* ([Function: name]) and Node-shaped call errors. The operand is
|
|
4161
|
-
* borrowed; the result is owned (+1). Never throws.
|
|
4162
|
-
*
|
|
4163
|
-
*
|
|
4164
|
-
*
|
|
4165
|
-
*
|
|
4166
|
-
*
|
|
4174
|
+
* borrowed; the result is owned (+1). Never throws. Program class
|
|
4175
|
+
* instances always use a typed capsule so an exact checked cast recovers
|
|
4176
|
+
* the original identity. `liveRef` requests the same capsule form for
|
|
4177
|
+
* record/array/bytes values (including mutable arms selected at runtime
|
|
4178
|
+
* from a union) whose Web API contract exposes the reference again, such
|
|
4179
|
+
* as stream chunks and abort reasons; ordinary JSON-shaped values retain
|
|
4180
|
+
* the documented deep-copy boundary. */
|
|
4167
4181
|
| {
|
|
4168
4182
|
kind: "dynFrom";
|
|
4169
4183
|
value: IrExpr;
|
|
@@ -4935,10 +4949,22 @@ export declare const DYN_HANDLE_KINDS: ReadonlyMap<string, {
|
|
|
4935
4949
|
tag: string;
|
|
4936
4950
|
cls: string;
|
|
4937
4951
|
}>;
|
|
4952
|
+
/** A class value that crosses an `unknown` slot as a compiler-owned typed
|
|
4953
|
+
* reference. %Error keeps its dedicated error encoding; every other class
|
|
4954
|
+
* preserves the original object identity and exposes a materialized own-field
|
|
4955
|
+
* view only when a checked-dynamic operation actually needs one. */
|
|
4956
|
+
export declare function isDynTypedRefType(t: IrType): t is Extract<IrType, {
|
|
4957
|
+
kind: "object";
|
|
4958
|
+
}>;
|
|
4959
|
+
/** Whether a class layout field is an ECMAScript own enumerable property.
|
|
4960
|
+
* `#private` slots and `%`-prefixed compiler storage exist only in the native
|
|
4961
|
+
* layout; TypeScript `private`/`protected` fields keep ordinary names and are
|
|
4962
|
+
* observable properties at runtime. */
|
|
4963
|
+
export declare function isClassOwnEnumerableFieldName(name: string): boolean;
|
|
4938
4964
|
/** A static type that CONVERTS into a dyn value — the dynFrom domain:
|
|
4939
|
-
* JSON-safe data, bytes<u8> (payload copied),
|
|
4940
|
-
*
|
|
4941
|
-
* (boxed by reference — DYN_HANDLE_KINDS). */
|
|
4965
|
+
* JSON-safe data, bytes<u8> (payload copied), identity-preserving class
|
|
4966
|
+
* references, undefined-armed unions of those arms, boxable function types,
|
|
4967
|
+
* and the runtime HANDLE kinds (boxed by reference — DYN_HANDLE_KINDS). */
|
|
4942
4968
|
export declare function canConvertToDyn(t: IrType, getRecord: (shapeId: string) => IrRecordShape | undefined, getUnion: (unionId: string) => IrUnionDef | undefined): boolean;
|
|
4943
4969
|
/** A type a dyn value can be VALIDATED into — the dynCheck domain:
|
|
4944
4970
|
* JSON-safe data, bytes<u8> (a fresh copy out), the %Error extraction,
|
|
@@ -5080,6 +5106,10 @@ export declare function moduleUsesDynInvoke(mod: IrModule): boolean;
|
|
|
5080
5106
|
* walk shape as moduleUsesZlib. */
|
|
5081
5107
|
export declare function moduleUsesDynAsync(mod: IrModule): boolean;
|
|
5082
5108
|
export declare function moduleUsesInspect(mod: IrModule): boolean;
|
|
5109
|
+
/** True when the module reaches child_process or carries one of its runtime
|
|
5110
|
+
* handle/result types. Besides the existing link consequence, this gates the
|
|
5111
|
+
* checked-dynamic ChildProcess handle table installed from scr_child.c. */
|
|
5112
|
+
export declare function moduleUsesChildProcess(mod: IrModule): boolean;
|
|
5083
5113
|
/** True when the module contains any net libCall — the link switch that
|
|
5084
5114
|
* pulls scr_net.c into the binary and has the emitted main call
|
|
5085
5115
|
* scr_net_install (native-toolchain.ts + emitter; the scr_events gating precedent).
|
package/dist/ir/ir.js
CHANGED
|
@@ -366,7 +366,7 @@ export function typeKey(t) {
|
|
|
366
366
|
case "promise":
|
|
367
367
|
return `promise<${typeKey(t.inner)}>`;
|
|
368
368
|
case "generator":
|
|
369
|
-
return
|
|
369
|
+
return `${t.async ? "async-generator" : "generator"}<${typeKey(t.yieldT)},${typeKey(t.retT)},${typeKey(t.nextT)}>`;
|
|
370
370
|
default: {
|
|
371
371
|
const _exhaustive = t;
|
|
372
372
|
void _exhaustive;
|
|
@@ -406,6 +406,7 @@ export function typeEquals(a, b) {
|
|
|
406
406
|
return b.kind === "promise" && typeEquals(a.inner, b.inner);
|
|
407
407
|
if (a.kind === "generator") {
|
|
408
408
|
return (b.kind === "generator" &&
|
|
409
|
+
(a.async === true) === (b.async === true) &&
|
|
409
410
|
typeEquals(a.yieldT, b.yieldT) &&
|
|
410
411
|
typeEquals(a.retT, b.retT) &&
|
|
411
412
|
typeEquals(a.nextT, b.nextT));
|
|
@@ -916,6 +917,7 @@ export function canMarshalTypedFuncIntoIsland(t, getRecord, getUnion) {
|
|
|
916
917
|
* entry carries the runtime tag spelling and the class display name
|
|
917
918
|
* (dynCheck's "expected IncomingMessage ..." texts). */
|
|
918
919
|
export const DYN_HANDLE_KINDS = new Map([
|
|
920
|
+
["child", { tag: "SCR_DYNH_CHILD", cls: "ChildProcess" }],
|
|
919
921
|
["httpReq", { tag: "SCR_DYNH_HTTP_REQ", cls: "IncomingMessage" }],
|
|
920
922
|
["httpRes", { tag: "SCR_DYNH_HTTP_RES", cls: "ServerResponse" }],
|
|
921
923
|
["netSocket", { tag: "SCR_DYNH_NET_SOCKET", cls: "Socket" }],
|
|
@@ -924,10 +926,24 @@ export const DYN_HANDLE_KINDS = new Map([
|
|
|
924
926
|
["http2Stream", { tag: "SCR_DYNH_H2_STREAM", cls: "Http2Stream" }],
|
|
925
927
|
["httpClientReq", { tag: "SCR_DYNH_HTTP_CLIENT", cls: "ClientRequest" }],
|
|
926
928
|
]);
|
|
929
|
+
/** A class value that crosses an `unknown` slot as a compiler-owned typed
|
|
930
|
+
* reference. %Error keeps its dedicated error encoding; every other class
|
|
931
|
+
* preserves the original object identity and exposes a materialized own-field
|
|
932
|
+
* view only when a checked-dynamic operation actually needs one. */
|
|
933
|
+
export function isDynTypedRefType(t) {
|
|
934
|
+
return t.kind === "object" && !RUNTIME_ERROR_CLASSES.has(t.className);
|
|
935
|
+
}
|
|
936
|
+
/** Whether a class layout field is an ECMAScript own enumerable property.
|
|
937
|
+
* `#private` slots and `%`-prefixed compiler storage exist only in the native
|
|
938
|
+
* layout; TypeScript `private`/`protected` fields keep ordinary names and are
|
|
939
|
+
* observable properties at runtime. */
|
|
940
|
+
export function isClassOwnEnumerableFieldName(name) {
|
|
941
|
+
return !name.startsWith("#") && !name.startsWith("%");
|
|
942
|
+
}
|
|
927
943
|
/** A static type that CONVERTS into a dyn value — the dynFrom domain:
|
|
928
|
-
* JSON-safe data, bytes<u8> (payload copied),
|
|
929
|
-
*
|
|
930
|
-
* (boxed by reference — DYN_HANDLE_KINDS). */
|
|
944
|
+
* JSON-safe data, bytes<u8> (payload copied), identity-preserving class
|
|
945
|
+
* references, undefined-armed unions of those arms, boxable function types,
|
|
946
|
+
* and the runtime HANDLE kinds (boxed by reference — DYN_HANDLE_KINDS). */
|
|
931
947
|
export function canConvertToDyn(t, getRecord, getUnion) {
|
|
932
948
|
if (isJsonSafeType(t, getRecord, getUnion))
|
|
933
949
|
return true;
|
|
@@ -945,6 +961,8 @@ export function canConvertToDyn(t, getRecord, getUnion) {
|
|
|
945
961
|
// listener boundary (a mustCall-wrapped handler receiving the payload).
|
|
946
962
|
if (t.kind === "object" && t.className === "%Error")
|
|
947
963
|
return true;
|
|
964
|
+
if (isDynTypedRefType(t))
|
|
965
|
+
return true;
|
|
948
966
|
if (t.kind === "func")
|
|
949
967
|
return canBoxFuncIntoDyn(t, getRecord, getUnion);
|
|
950
968
|
if (DYN_HANDLE_KINDS.has(t.kind))
|
|
@@ -962,12 +980,14 @@ export function canConvertToDyn(t, getRecord, getUnion) {
|
|
|
962
980
|
}
|
|
963
981
|
if (t.kind === "union") {
|
|
964
982
|
const def = getUnion(t.unionId);
|
|
965
|
-
// JSON-safe arms box as before; BOXABLE FUNCTION arms join them (the
|
|
983
|
+
// JSON-safe arms box as before; BOXABLE FUNCTION and PROMISE arms join them (the
|
|
966
984
|
// invalid-input probes iterate `[1, null, () => {}, true]` — the
|
|
967
985
|
// union's func arm crosses through the checked-dynamic function
|
|
968
986
|
// boundary exactly like a bare func dynFrom).
|
|
969
987
|
return !!def && def.arms.every((a) => a.kind === "undefinedT" || isJsonSafeType(a, getRecord, getUnion) ||
|
|
970
|
-
(a
|
|
988
|
+
isDynTypedRefType(a) || DYN_HANDLE_KINDS.has(a.kind) ||
|
|
989
|
+
(a.kind === "func" && canBoxFuncIntoDyn(a, getRecord, getUnion)) ||
|
|
990
|
+
(a.kind === "promise" && canConvertToDyn(a, getRecord, getUnion)));
|
|
971
991
|
}
|
|
972
992
|
return false;
|
|
973
993
|
}
|
|
@@ -1594,6 +1614,36 @@ export function moduleUsesInspect(mod) {
|
|
|
1594
1614
|
visit(mod);
|
|
1595
1615
|
return found;
|
|
1596
1616
|
}
|
|
1617
|
+
/** True when the module reaches child_process or carries one of its runtime
|
|
1618
|
+
* handle/result types. Besides the existing link consequence, this gates the
|
|
1619
|
+
* checked-dynamic ChildProcess handle table installed from scr_child.c. */
|
|
1620
|
+
export function moduleUsesChildProcess(mod) {
|
|
1621
|
+
let found = false;
|
|
1622
|
+
const visit = (v) => {
|
|
1623
|
+
if (found || v === null || typeof v !== "object")
|
|
1624
|
+
return;
|
|
1625
|
+
if (Array.isArray(v)) {
|
|
1626
|
+
for (const item of v)
|
|
1627
|
+
visit(item);
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
const node = v;
|
|
1631
|
+
if (node.kind === "libCall" &&
|
|
1632
|
+
typeof node.fn === "string" &&
|
|
1633
|
+
(node.fn.startsWith("cp.") || node.fn.startsWith("child.") || node.fn.startsWith("spawnRes."))) {
|
|
1634
|
+
found = true;
|
|
1635
|
+
return;
|
|
1636
|
+
}
|
|
1637
|
+
if (node.kind === "child" || node.kind === "childStream" || node.kind === "spawnRes") {
|
|
1638
|
+
found = true;
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
for (const key of Object.keys(v))
|
|
1642
|
+
visit(v[key]);
|
|
1643
|
+
};
|
|
1644
|
+
visit(mod);
|
|
1645
|
+
return found;
|
|
1646
|
+
}
|
|
1597
1647
|
/** True when the module contains any net libCall — the link switch that
|
|
1598
1648
|
* pulls scr_net.c into the binary and has the emitted main call
|
|
1599
1649
|
* scr_net_install (native-toolchain.ts + emitter; the scr_events gating precedent).
|
|
@@ -2377,6 +2427,7 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2377
2427
|
"writable.uncork",
|
|
2378
2428
|
"stream.destroy",
|
|
2379
2429
|
"stream.destroyErr",
|
|
2430
|
+
"stream.iteratorClose",
|
|
2380
2431
|
// setMaxListeners(n) throws Node's ERR_OUT_OF_RANGE RangeError for
|
|
2381
2432
|
// negative/NaN arguments; the static form's default-max write validates
|
|
2382
2433
|
// identically (Node's validateNumber(n, "setMaxListeners", 0)).
|