@scriptc/compiler 0.4.8 → 0.4.9
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/node-fallback/buffer.d.ts +2 -0
- package/ambient/node-fallback/child_process.d.ts +9 -3
- package/ambient/node-fallback/dns-promises.d.ts +25 -0
- package/ambient/node-fallback/dns.d.ts +29 -0
- package/ambient/node-fallback/test.d.ts +7 -0
- package/ambient/scriptc-node-fallback.d.ts +145 -2
- package/ambient/scriptc-overrides.d.ts +22 -13
- package/dist/backend/build-cache.d.ts +1 -1
- package/dist/backend/build-cache.js +1 -1
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +7 -0
- package/dist/backend/cache-root.js +27 -0
- package/dist/backend/cache-root.js.map +1 -1
- package/dist/backend/executable-features.js +5 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/link-plan.js +7 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +12 -1
- package/dist/backend/llvm/bytes-loop-versions.js +107 -30
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +96 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +1 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -5
- package/dist/backend/llvm/classes.js +34 -6
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -2
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +9 -0
- package/dist/backend/llvm/common.js +9 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +36 -2
- package/dist/backend/llvm/cpu-dispatch.js +96 -2
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +5 -2
- package/dist/backend/llvm/dense-array-access.js +16 -12
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +3 -1
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +24 -0
- package/dist/backend/llvm/dyn.js +117 -3
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +6 -0
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +1 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +48 -5
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.js +41 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +11 -0
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +87 -7
- package/dist/backend/llvm/emitter.js +136 -15
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +28 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +19 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +29 -1
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +104 -6
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +15 -1
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +53 -5
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/inline-arrays.js +1 -1
- package/dist/backend/llvm/inline-arrays.js.map +1 -1
- package/dist/backend/llvm/js-ic.js +126 -2
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lanes.d.ts +38 -0
- package/dist/backend/llvm/lanes.js +778 -0
- package/dist/backend/llvm/lanes.js.map +1 -0
- package/dist/backend/llvm/lanes.test.d.ts +1 -0
- package/dist/backend/llvm/lanes.test.js +402 -0
- package/dist/backend/llvm/lanes.test.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +9 -4
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +20 -0
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +27 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +11 -0
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +2 -2
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.js +8 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +5 -2
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +2 -2
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-groups.js +43 -4
- package/dist/backend/llvm/region-groups.js.map +1 -1
- package/dist/backend/llvm/region-groups.test.js +79 -0
- package/dist/backend/llvm/region-groups.test.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +32 -1
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/shapes.js +10 -1
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +1 -1
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.js +24 -2
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.test.js +38 -0
- package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +3 -0
- package/dist/backend/llvm/walkers.js +20 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +15 -3
- package/dist/backend/native/executable.js +19 -5
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +20 -0
- package/dist/backend/native-codegen-core.js +15 -0
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +5 -0
- package/dist/backend/native-codegen.js +62 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +48 -8
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +27 -3
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.test.js +17 -1
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +1 -1
- package/dist/backend/native-toolchain.js +1 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +14 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +9 -3
- package/dist/backend/runtime-pack-core.js +6 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +32 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/targets.d.ts +9 -1
- package/dist/backend/targets.js +11 -2
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +6 -0
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/cli/command.js +15 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +6 -0
- package/dist/cli/mcp.d.ts +72 -0
- package/dist/cli/mcp.js +601 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/mcp.test.d.ts +1 -0
- package/dist/cli/mcp.test.js +380 -0
- package/dist/cli/mcp.test.js.map +1 -0
- package/dist/cli/output-options.d.ts +1 -0
- package/dist/cli/output-options.js +3 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +51 -1
- package/dist/cli/usage.js +709 -186
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.js +9 -4
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +17 -0
- package/dist/coverage/report.d.ts +5 -9
- package/dist/coverage/report.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +17 -3
- package/dist/executable/executable-cache.js +17 -3
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/prepare.js +87 -10
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +3 -2
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/canon-map.js +13 -8
- package/dist/frontend/canon-map.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +18 -0
- package/dist/frontend/decl-projection.js +90 -22
- package/dist/frontend/decl-projection.js.map +1 -1
- package/dist/frontend/decl-projection.test.js +47 -1
- package/dist/frontend/decl-projection.test.js.map +1 -1
- package/dist/frontend/default-library.d.ts +10 -0
- package/dist/frontend/default-library.js +43 -0
- package/dist/frontend/default-library.js.map +1 -0
- package/dist/frontend/fork-target.js +54 -9
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.js +82 -0
- package/dist/frontend/fork-target.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +73 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/lowering/abstract-equality.d.ts +2 -1
- package/dist/frontend/lowering/abstract-equality.js +7 -1
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +2 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/assertion-members.js +52 -2
- package/dist/frontend/lowering/assertion-members.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +5 -0
- package/dist/frontend/lowering/builtin-namespaces.js +19 -12
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +42 -6
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +12 -11
- package/dist/frontend/lowering/builtins/child-process.js +235 -38
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +6 -1
- package/dist/frontend/lowering/builtins/compression.js +3 -3
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +2 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -1
- package/dist/frontend/lowering/builtins/crypto.js +9 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.js +26 -6
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +13 -1
- package/dist/frontend/lowering/builtins/environment.js +15 -4
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +33 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +213 -11
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +9 -2
- package/dist/frontend/lowering/builtins/module-resolution.js +187 -19
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.js +1 -1
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +40 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +33 -0
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +9 -5
- package/dist/frontend/lowering/builtins/readline.js +184 -75
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.d.ts +4 -0
- package/dist/frontend/lowering/builtins/url.js +6 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +15 -0
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/callable-properties.d.ts +34 -0
- package/dist/frontend/lowering/callable-properties.js +210 -0
- package/dist/frontend/lowering/callable-properties.js.map +1 -0
- package/dist/frontend/lowering/cjs-inline-require.d.ts +16 -0
- package/dist/frontend/lowering/cjs-inline-require.js +105 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.test.d.ts +1 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js +61 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +82 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +57 -4
- package/dist/frontend/lowering/class-protocols.js +597 -30
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +2 -2
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +12 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +62 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +56 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +9 -4
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collection-ingestion.d.ts +9 -0
- package/dist/frontend/lowering/collection-ingestion.js +115 -41
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +16 -0
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +66 -10
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +61 -5
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.js +11 -0
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +15 -0
- package/dist/frontend/lowering/containers/indexed-objects.js +213 -30
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/error-name-order.d.ts +16 -0
- package/dist/frontend/lowering/error-name-order.js +61 -0
- package/dist/frontend/lowering/error-name-order.js.map +1 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +17 -0
- package/dist/frontend/lowering/expressions/asserted-receiver.js +123 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +147 -20
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +63 -14
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/erased-delete.d.ts +59 -0
- package/dist/frontend/lowering/expressions/erased-delete.js +247 -0
- package/dist/frontend/lowering/expressions/erased-delete.js.map +1 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +10 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +48 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +20 -0
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +7 -2
- package/dist/frontend/lowering/expressions/narrowing.js +77 -45
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +62 -19
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +19 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +7 -7
- package/dist/frontend/lowering/expressions/property-access.js +247 -48
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.d.ts +1 -0
- package/dist/frontend/lowering/expressions/relational.js +18 -8
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js +11 -5
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +121 -11
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-context.d.ts +10 -0
- package/dist/frontend/lowering/function-context.js +36 -0
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +8 -8
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +62 -3
- package/dist/frontend/lowering/handle-properties.js +674 -26
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.test.js +95 -2
- package/dist/frontend/lowering/handle-properties.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +44 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +328 -136
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +82 -17
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +113 -9
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +13 -21
- package/dist/frontend/lowering/lower-expando.js +90 -126
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +2 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +65 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +471 -0
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +36 -10
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.js +28 -0
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +53 -7
- package/dist/frontend/lowering/lower-server.js +213 -42
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +50 -7
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -0
- package/dist/frontend/lowering/lower-stmts.js +463 -220
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +2 -2
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +71 -2
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +81 -10
- package/dist/frontend/lowering/lowerer.js +319 -72
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +10 -2
- package/dist/frontend/lowering/new-target.js.map +1 -1
- package/dist/frontend/lowering/nullish-empty-pattern.js +3 -3
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.js +30 -5
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- package/dist/frontend/lowering/primitive-throws.js +91 -1
- package/dist/frontend/lowering/primitive-throws.js.map +1 -1
- package/dist/frontend/lowering/primitive-wrappers.d.ts +9 -0
- package/dist/frontend/lowering/primitive-wrappers.js +2 -2
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- package/dist/frontend/lowering/promise-executor-adapter.js +5 -2
- package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
- package/dist/frontend/lowering/record-links.js +7 -2
- package/dist/frontend/lowering/record-links.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +4 -0
- package/dist/frontend/lowering/surfaces.js +118 -2
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/surfaces.test.d.ts +1 -0
- package/dist/frontend/lowering/surfaces.test.js +31 -0
- package/dist/frontend/lowering/surfaces.test.js.map +1 -0
- package/dist/frontend/mock-shapes.js +3 -3
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/npm-static-ladder.d.ts +21 -0
- package/dist/frontend/npm-static-ladder.js +2 -0
- package/dist/frontend/npm-static-ladder.js.map +1 -0
- package/dist/frontend/npm-static-ladder.test.d.ts +1 -0
- package/dist/frontend/npm-static-ladder.test.js +138 -0
- package/dist/frontend/npm-static-ladder.test.js.map +1 -0
- package/dist/frontend/npm-static-status.d.ts +15 -0
- package/dist/frontend/npm-static-status.js +2 -0
- package/dist/frontend/npm-static-status.js.map +1 -0
- package/dist/frontend/package-shims.js +1 -1
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +1 -1
- package/dist/frontend/pipeline.js +222 -25
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +4 -0
- package/dist/frontend/program-analysis.js +6 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.js +258 -32
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +30 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.js +29 -5
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +40 -0
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/services.d.ts +8 -0
- package/dist/frontend/services.js +7 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +7 -0
- package/dist/frontend/ts7/checker.js +12 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +1 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +39 -2
- package/dist/frontend/ts7/program-host.js +62 -8
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +33 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/session-cache.d.ts +5 -1
- package/dist/frontend/ts7/session-cache.js +7 -1
- package/dist/frontend/ts7/session-cache.js.map +1 -1
- package/dist/frontend/ts7/session-cache.test.js +37 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -1
- package/dist/frontend/ts7/session.js +19 -1
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/source-parser.d.ts +17 -2
- package/dist/frontend/ts7/source-parser.js +61 -2
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +55 -2
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +3 -2
- package/dist/frontend/tsc-codes.js +129 -22
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +5 -11
- package/dist/frontend/type-mapper.js +380 -70
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +29 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +72 -6
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/codec.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +321 -263
- package/dist/ir/codec.generated.js.map +1 -1
- package/dist/ir/constant-length-clones.d.ts +26 -0
- package/dist/ir/constant-length-clones.js +589 -0
- package/dist/ir/constant-length-clones.js.map +1 -0
- package/dist/ir/constant-length-clones.test.d.ts +1 -0
- package/dist/ir/constant-length-clones.test.js +292 -0
- package/dist/ir/constant-length-clones.test.js.map +1 -0
- package/dist/ir/constant-tables.d.ts +10 -5
- package/dist/ir/constant-tables.js +83 -17
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +58 -1
- package/dist/ir/constant-tables.test.js.map +1 -1
- package/dist/ir/fields.generated.js +5 -2
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/function-references.js +2 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +13 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/integer-loops.js +1 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +16 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/ir.d.ts +50 -6
- package/dist/ir/ir.js +44 -2
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +83 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-groups.js +5 -1
- package/dist/ir/js-groups.js.map +1 -1
- package/dist/ir/js-ic.d.ts +20 -0
- package/dist/ir/js-ic.js +81 -4
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +8 -1
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/lane-plans.d.ts +86 -0
- package/dist/ir/lane-plans.js +589 -0
- package/dist/ir/lane-plans.js.map +1 -0
- package/dist/ir/lane-plans.test.d.ts +1 -0
- package/dist/ir/lane-plans.test.js +549 -0
- package/dist/ir/lane-plans.test.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +68 -10
- package/dist/ir/runtime-features.js +285 -17
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +190 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/validate.js +61 -24
- package/dist/ir/validate.js.map +1 -1
- package/dist/native/cache.d.ts +5 -0
- package/dist/native/cache.js +23 -1
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +29 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +4 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.d.ts +11 -3
- package/dist/native/compiler.js +102 -16
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +244 -2
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.d.ts +14 -1
- package/dist/native/prepare.js +79 -29
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +3 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/unchanged.d.ts +80 -0
- package/dist/native/unchanged.js +301 -0
- package/dist/native/unchanged.js.map +1 -0
- package/dist/native/unchanged.test.d.ts +1 -0
- package/dist/native/unchanged.test.js +249 -0
- package/dist/native/unchanged.test.js.map +1 -0
- package/dist/node-islands/boundary.d.ts +16 -0
- package/dist/node-islands/boundary.js +70 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.js +59 -14
- package/dist/node-islands/boundary.test.js.map +1 -1
- package/dist/node-islands/detect.js +203 -47
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +45 -0
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/growth.js +4 -16
- package/dist/node-islands/growth.js.map +1 -1
- package/dist/node-islands/modules.d.ts +3 -0
- package/dist/node-islands/modules.js +143 -12
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +125 -0
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/report.d.ts +1 -1
- package/dist/node-islands/report.js +2 -1
- package/dist/node-islands/report.js.map +1 -1
- package/package.json +20 -20
- package/shims/undici/core/request.ts +7 -1
- package/surface-manifest.json +380 -2
|
@@ -22,6 +22,7 @@ import { recordMayKeepSource, recordSourceTest } from "./record-sources.js";
|
|
|
22
22
|
import { registerLinkedHelper } from "./record-links.js";
|
|
23
23
|
import { nullProtoRecordShape, recordNullProtoTest } from "./null-prototype.js";
|
|
24
24
|
import { dynArgumentPack } from "./call-arguments.js";
|
|
25
|
+
import { errorConstructionOrder } from "./error-name-order.js";
|
|
25
26
|
/* ── IR construction shorthand ───────────────────────────────────────── */
|
|
26
27
|
function concatAll(parts, loc) {
|
|
27
28
|
if (parts.length === 0)
|
|
@@ -150,6 +151,432 @@ function ownErrorFields(info) {
|
|
|
150
151
|
}
|
|
151
152
|
return info.def.fields.filter((f) => isClassOwnEnumerableFieldName(f.name) && !builtin.has(f.name));
|
|
152
153
|
}
|
|
154
|
+
/** The own enumerable properties JSON.stringify sees on an instance of a
|
|
155
|
+
* program error class, in creation order. The declared fields come first
|
|
156
|
+
* (the base chain's slots are already in their creation position), plus
|
|
157
|
+
* `message` when a class of the chain declares it as a field: the field
|
|
158
|
+
* redefines the base constructor's non-enumerable slot as enumerable. A
|
|
159
|
+
* `name` field or a `this.name = ...` assignment during construction
|
|
160
|
+
* creates an own enumerable property where the base's name lives on the
|
|
161
|
+
* prototype, at the position errorNameAfter records. */
|
|
162
|
+
function errorJsonFields(info) {
|
|
163
|
+
const declared = new Set();
|
|
164
|
+
for (let c = info; c && !c.builtinError && !c.def.runtime; c = c.base) {
|
|
165
|
+
for (const f of c.fieldOrder)
|
|
166
|
+
if (isClassOwnEnumerableFieldName(f.name))
|
|
167
|
+
declared.add(f.name);
|
|
168
|
+
}
|
|
169
|
+
const builtin = new Set();
|
|
170
|
+
for (let c = info.base; c; c = c.base) {
|
|
171
|
+
if (c.builtinError || c.def.runtime)
|
|
172
|
+
for (const f of c.def.fields)
|
|
173
|
+
builtin.add(f.name);
|
|
174
|
+
}
|
|
175
|
+
const fields = info.def.fields.filter((f) => isClassOwnEnumerableFieldName(f.name) &&
|
|
176
|
+
f.name !== "name" &&
|
|
177
|
+
(!builtin.has(f.name) || (f.name === "message" && declared.has("message"))));
|
|
178
|
+
const after = info.def.errorNameAfter;
|
|
179
|
+
if (after === undefined)
|
|
180
|
+
return fields;
|
|
181
|
+
const nameField = { name: "name", type: STRING };
|
|
182
|
+
if (after === null) {
|
|
183
|
+
// The base constructor's message slot precedes everything the subclass
|
|
184
|
+
// creates; a declared message field makes that slot enumerable.
|
|
185
|
+
if (fields[0]?.name === "message")
|
|
186
|
+
return [fields[0], nameField, ...fields.slice(1)];
|
|
187
|
+
return [nameField, ...fields];
|
|
188
|
+
}
|
|
189
|
+
const at = fields.findIndex((f) => f.name === after);
|
|
190
|
+
if (at === -1)
|
|
191
|
+
return [...fields, nameField];
|
|
192
|
+
return [...fields.slice(0, at + 1), nameField, ...fields.slice(at + 1)];
|
|
193
|
+
}
|
|
194
|
+
/** Serialize a JSON.stringify result of `expr` the way %j writes it: a
|
|
195
|
+
* checked-dynamic result crosses into the runtime walker (toJSON hooks and
|
|
196
|
+
* all, "[Circular]" and a dropped root included), a JSON-safe static type
|
|
197
|
+
* uses its type-directed writer, and a value that can neither stay static
|
|
198
|
+
* nor cross the boundary returns null. `skipToJson` is for the value a
|
|
199
|
+
* toJSON hook returned: JSON.stringify applies a hook only to a value read
|
|
200
|
+
* from a holder, so the returned value enters the walk at the write step
|
|
201
|
+
* and only its members take their hooks. */
|
|
202
|
+
function jsonSerializeExpr(lowerer, expr, loc, skipToJson = false) {
|
|
203
|
+
const runtimeStringify = (value) => ({
|
|
204
|
+
kind: "libCall",
|
|
205
|
+
fn: skipToJson ? "insp.jsonDynValue" : "insp.jsonDyn",
|
|
206
|
+
args: [value],
|
|
207
|
+
type: STRING,
|
|
208
|
+
loc,
|
|
209
|
+
});
|
|
210
|
+
if (expr.type.kind === "dyn")
|
|
211
|
+
return runtimeStringify(expr);
|
|
212
|
+
if (lowerer.jsonStringifySafe(expr.type))
|
|
213
|
+
return { kind: "jsonStringify", value: expr, circular: true, type: STRING, loc };
|
|
214
|
+
if (lowerer.dynConvertible(expr.type))
|
|
215
|
+
return runtimeStringify({ kind: "dynFrom", value: expr, liveRef: true, type: DYN, loc });
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
/** A toJSON member JSON.stringify calls before walking the own properties:
|
|
219
|
+
* a method with a body and at most the key parameter. A getter or a data
|
|
220
|
+
* field named toJSON leaves the class to the checked-dynamic walk. */
|
|
221
|
+
function errorToJsonMethod(lowerer, info) {
|
|
222
|
+
const found = findMethodOn(lowerer, info, "toJSON");
|
|
223
|
+
if (!found)
|
|
224
|
+
return null;
|
|
225
|
+
if (found.sig.abstract === true || found.sig.async === true || found.sig.gen !== undefined)
|
|
226
|
+
return null;
|
|
227
|
+
if (found.sig.params.length > 1)
|
|
228
|
+
return null;
|
|
229
|
+
return { ret: found.sig.ret, params: found.sig.params.length };
|
|
230
|
+
}
|
|
231
|
+
/** A class's own enumerable properties as a record of the same layout, or
|
|
232
|
+
* null when the static writer cannot serialize one of the field types.
|
|
233
|
+
*
|
|
234
|
+
* The key order is part of the shape's declaredOrder, which two classes
|
|
235
|
+
* with the same field set would share; a hidden field named after the class
|
|
236
|
+
* keeps each class's shape distinct, so its own order survives the
|
|
237
|
+
* whole-program key-order pass. Internal '%'-fields never serialize. */
|
|
238
|
+
function jsonErrorFieldsRecord(lowerer, info, receiver, loc) {
|
|
239
|
+
const className = info.def.name;
|
|
240
|
+
const fields = errorJsonFields(info);
|
|
241
|
+
if (fields.length === 0)
|
|
242
|
+
return strLit("{}", loc);
|
|
243
|
+
const marker = `%jsonOrder:${className}`;
|
|
244
|
+
const shapeId = lowerer.shapes.intern([...fields.map((f) => ({ ...f })), { name: marker, type: F64 }].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0), false, undefined, fields.map((f) => f.name));
|
|
245
|
+
const recordType = { kind: "record", shapeId };
|
|
246
|
+
if (!lowerer.jsonStringifySafe(recordType))
|
|
247
|
+
return null;
|
|
248
|
+
return {
|
|
249
|
+
kind: "jsonStringify",
|
|
250
|
+
value: {
|
|
251
|
+
kind: "recordLit",
|
|
252
|
+
fields: [
|
|
253
|
+
...fields.map((f) => ({
|
|
254
|
+
name: f.name,
|
|
255
|
+
value: {
|
|
256
|
+
kind: "fieldGet",
|
|
257
|
+
obj: receiver(),
|
|
258
|
+
className,
|
|
259
|
+
field: f.name,
|
|
260
|
+
type: f.type,
|
|
261
|
+
loc,
|
|
262
|
+
},
|
|
263
|
+
})),
|
|
264
|
+
{ name: marker, value: numLit(0, loc) },
|
|
265
|
+
],
|
|
266
|
+
type: recordType,
|
|
267
|
+
loc,
|
|
268
|
+
},
|
|
269
|
+
circular: true,
|
|
270
|
+
type: STRING,
|
|
271
|
+
loc,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** The runtime flag that records whether one of the error header's
|
|
275
|
+
* properties (name, message, cause) is an own ENUMERABLE property. Node's
|
|
276
|
+
* Error constructor gives name and message non-enumerable slots on the
|
|
277
|
+
* base's prototype and leaves cause to the options form, so a write
|
|
278
|
+
* through a slot creates the property — enumerable — only when nothing
|
|
279
|
+
* defined it enumerable before. */
|
|
280
|
+
const ERROR_HEADER_FLAGS = {
|
|
281
|
+
name: "%nameEnumerable",
|
|
282
|
+
message: "%messageEnumerable",
|
|
283
|
+
cause: "%causeEnumerable",
|
|
284
|
+
};
|
|
285
|
+
function errorHeaderFlag(receiver, className, key, loc) {
|
|
286
|
+
return {
|
|
287
|
+
kind: "fieldGet",
|
|
288
|
+
obj: receiver,
|
|
289
|
+
className,
|
|
290
|
+
field: ERROR_HEADER_FLAGS[key],
|
|
291
|
+
type: BOOL,
|
|
292
|
+
loc,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/** Whether a class of the chain redeclares Error.cause: its initializer
|
|
296
|
+
* writes the base's `%cause` slot where the declaration runs, which makes
|
|
297
|
+
* the property own and enumerable at that position. The slot is not a
|
|
298
|
+
* layout field, so the record writer has no place for it and the class
|
|
299
|
+
* renders through the ordered walk below. */
|
|
300
|
+
function errorDeclaresCause(info) {
|
|
301
|
+
for (let c = info; c && !c.builtinError && !c.def.runtime; c = c.base)
|
|
302
|
+
if (c.fieldOrder.some((f) => f.errorCause))
|
|
303
|
+
return true;
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
/** An error class's own enumerable properties in creation order, as a
|
|
307
|
+
* checked-dynamic object the runtime walker writes: a declared field keeps
|
|
308
|
+
* its type-directed value, `cause` reads the base's slot, and `name`,
|
|
309
|
+
* `message` and `cause` print only where the runtime recorded them as own
|
|
310
|
+
* enumerable. The statements return the text; null when a field cannot
|
|
311
|
+
* cross into the walk.
|
|
312
|
+
*
|
|
313
|
+
* The walk starts from the receiver's fields instead of boxing it: a
|
|
314
|
+
* checked-dynamic handle of the instance would make the class a property
|
|
315
|
+
* bag receiver, and every %j of the class would then render through the
|
|
316
|
+
* handle, whose fixed slot order is not the class's construction order. */
|
|
317
|
+
function errorOrderedBody(lowerer, info, receiver, loc) {
|
|
318
|
+
const className = info.def.name;
|
|
319
|
+
const types = new Map(errorJsonFields(info).map((f) => [f.name, f.type]));
|
|
320
|
+
const ordered = errorConstructionOrder(info, new Set(types.keys()));
|
|
321
|
+
// The base constructor creates the message slot before any class field
|
|
322
|
+
// runs, so a redeclared message prints first however late its
|
|
323
|
+
// declaration sits; a `name` or `cause` created after construction takes
|
|
324
|
+
// the end (Node: a write to a slot that has no own property yet).
|
|
325
|
+
const messageAt = ordered.findIndex((p) => p.kind === "message");
|
|
326
|
+
if (messageAt > 0)
|
|
327
|
+
ordered.unshift(...ordered.splice(messageAt, 1));
|
|
328
|
+
if (!ordered.some((p) => p.kind === "cause"))
|
|
329
|
+
ordered.push({ name: "cause", kind: "cause" });
|
|
330
|
+
if (!ordered.some((p) => p.kind === "name"))
|
|
331
|
+
ordered.push({ name: "name", kind: "name" });
|
|
332
|
+
const fields = [];
|
|
333
|
+
for (const property of ordered) {
|
|
334
|
+
let value;
|
|
335
|
+
if (property.kind === "cause") {
|
|
336
|
+
value = { kind: "libCall", fn: "error.cause", args: [receiver()], type: DYN, loc };
|
|
337
|
+
}
|
|
338
|
+
else if (property.kind === "name" || property.kind === "message") {
|
|
339
|
+
// The base error's slot: a class that does not declare the property
|
|
340
|
+
// still reads the value the base constructor (or a later write)
|
|
341
|
+
// stored there.
|
|
342
|
+
value = lowerer.coerceToExpected({ kind: "fieldGet", obj: receiver(), className, field: property.name, type: STRING, loc }, DYN);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const type = types.get(property.name);
|
|
346
|
+
if (!type || !lowerer.dynConvertible(type))
|
|
347
|
+
return null;
|
|
348
|
+
value = lowerer.coerceToExpected({ kind: "fieldGet", obj: receiver(), className, field: property.name, type, loc }, DYN);
|
|
349
|
+
}
|
|
350
|
+
// A declared `message` field prints where its declaration sits (Node
|
|
351
|
+
// redefines the base's slot as enumerable, which the slot's flag does
|
|
352
|
+
// not record); the other header properties print only where the runtime
|
|
353
|
+
// recorded them as own enumerable.
|
|
354
|
+
if (property.kind === "cause" ||
|
|
355
|
+
property.kind === "name" ||
|
|
356
|
+
(property.kind === "message" && !types.has("message")))
|
|
357
|
+
value = {
|
|
358
|
+
kind: "ternary",
|
|
359
|
+
cond: errorHeaderFlag(receiver(), className, property.kind, loc),
|
|
360
|
+
then: value,
|
|
361
|
+
else_: dynUndefinedExpr(loc),
|
|
362
|
+
type: DYN,
|
|
363
|
+
loc,
|
|
364
|
+
};
|
|
365
|
+
fields.push({ key: strLit(property.name, loc), value });
|
|
366
|
+
}
|
|
367
|
+
return [
|
|
368
|
+
{
|
|
369
|
+
kind: "return",
|
|
370
|
+
value: {
|
|
371
|
+
kind: "libCall",
|
|
372
|
+
fn: "insp.jsonDyn",
|
|
373
|
+
args: [{ kind: "dynObjLit", fields, type: DYN, loc }],
|
|
374
|
+
type: STRING,
|
|
375
|
+
loc,
|
|
376
|
+
},
|
|
377
|
+
loc,
|
|
378
|
+
},
|
|
379
|
+
];
|
|
380
|
+
}
|
|
381
|
+
/** The ordered walk of one class as a lifted function of its own. The %j
|
|
382
|
+
* helper calls it only when the instance's runtime flags disagree with its
|
|
383
|
+
* construction order, and keeping the walk out of line leaves the common
|
|
384
|
+
* path to the field record. Null when a field cannot cross into the walk. */
|
|
385
|
+
function errorOrderedHelper(lowerer, info, loc) {
|
|
386
|
+
const key = `jsonErrorOwn:${info.def.name}`;
|
|
387
|
+
const existing = lowerer.inspectHelpers.get(key);
|
|
388
|
+
if (existing !== undefined)
|
|
389
|
+
return existing;
|
|
390
|
+
const type = { kind: "object", className: info.def.name };
|
|
391
|
+
const body = errorOrderedBody(lowerer, info, () => varRef("v.0", type, loc), loc);
|
|
392
|
+
if (body === null)
|
|
393
|
+
return null;
|
|
394
|
+
const name = keyedHelperName(lowerer, "%util.format.jsonErrorOwn", info.def.name);
|
|
395
|
+
lowerer.inspectHelpers.set(key, name);
|
|
396
|
+
lowerer.liftedFns.push({
|
|
397
|
+
name,
|
|
398
|
+
params: [{ localId: "v.0", name: "v", type }],
|
|
399
|
+
returnType: STRING,
|
|
400
|
+
locals: [{ id: "v.0", name: "v", type, mutable: false }],
|
|
401
|
+
body,
|
|
402
|
+
loc,
|
|
403
|
+
});
|
|
404
|
+
return name;
|
|
405
|
+
}
|
|
406
|
+
/** The ordered walk invoked on a receiver. */
|
|
407
|
+
function errorOrderedJson(lowerer, info, receiver, loc) {
|
|
408
|
+
const helper = errorOrderedHelper(lowerer, info, loc);
|
|
409
|
+
return helper === null
|
|
410
|
+
? null
|
|
411
|
+
: { kind: "call", callee: helper, args: [receiver()], type: STRING, loc };
|
|
412
|
+
}
|
|
413
|
+
/** The condition under which a record rendering is no longer the class's
|
|
414
|
+
* property list: a `name` the construction did not create became own and
|
|
415
|
+
* enumerable (an assignment after construction), or a `cause` did. Both
|
|
416
|
+
* live outside the record's shape, and the ordered walk reads them. */
|
|
417
|
+
function errorRecordDeviation(info, receiver, loc) {
|
|
418
|
+
const className = info.def.name;
|
|
419
|
+
const hasName = errorJsonFields(info).some((f) => f.name === "name");
|
|
420
|
+
const name = errorHeaderFlag(receiver(), className, "name", loc);
|
|
421
|
+
const cause = errorHeaderFlag(receiver(), className, "cause", loc);
|
|
422
|
+
// A record that lists name prints it while the flag holds; one that does
|
|
423
|
+
// not must stay off the record the moment the flag turns on.
|
|
424
|
+
const nameDeviation = hasName
|
|
425
|
+
? { kind: "bin", op: "===", left: name, right: boolLit(false, loc), type: BOOL, loc }
|
|
426
|
+
: name;
|
|
427
|
+
return {
|
|
428
|
+
kind: "logical",
|
|
429
|
+
op: "||",
|
|
430
|
+
left: nameDeviation,
|
|
431
|
+
right: cause,
|
|
432
|
+
type: BOOL,
|
|
433
|
+
loc,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/** The lifted %j renderer for an error's static type. An instance reaching
|
|
437
|
+
* the base's static type can be any class in its subtree, and JSON.stringify
|
|
438
|
+
* prints the RUNTIME class's own enumerable properties (or its toJSON
|
|
439
|
+
* hook's result), so the helper tests the instance's class before rendering
|
|
440
|
+
* that class's shape. A class whose toJSON is a getter or a data field falls
|
|
441
|
+
* back to the checked-dynamic walk for that arm, as does an instance whose
|
|
442
|
+
* runtime own-property flags disagree with the shape the class's
|
|
443
|
+
* construction creates. A builtin error with no program subclass still
|
|
444
|
+
* builds the walk: `{}` is only right while it has no own enumerable
|
|
445
|
+
* property. */
|
|
446
|
+
function jsonErrorHelper(lowerer, t, loc) {
|
|
447
|
+
const key = `jsonError:${typeKey(t)}`;
|
|
448
|
+
const existing = lowerer.inspectHelpers.get(key);
|
|
449
|
+
if (existing !== undefined)
|
|
450
|
+
return existing;
|
|
451
|
+
const info = lowerer.classes.get(t.className);
|
|
452
|
+
if (!info)
|
|
453
|
+
return null;
|
|
454
|
+
const classes = userErrorClasses(info);
|
|
455
|
+
const v = () => varRef("v.0", t, loc);
|
|
456
|
+
const dynamicRender = (receiver) => ({
|
|
457
|
+
kind: "libCall",
|
|
458
|
+
fn: "insp.jsonDyn",
|
|
459
|
+
args: [{ kind: "dynFrom", value: receiver, liveRef: true, type: DYN, loc }],
|
|
460
|
+
type: STRING,
|
|
461
|
+
loc,
|
|
462
|
+
});
|
|
463
|
+
const body = [];
|
|
464
|
+
const fieldArms = [];
|
|
465
|
+
for (const c of classes) {
|
|
466
|
+
const receiverType = { kind: "object", className: c.def.name };
|
|
467
|
+
const recv = () => c.def.name === t.className ? v() : { kind: "downcast", value: v(), type: receiverType, loc };
|
|
468
|
+
const toJson = errorToJsonMethod(lowerer, c);
|
|
469
|
+
let rendered;
|
|
470
|
+
if (toJson) {
|
|
471
|
+
// JSON.stringify calls toJSON with the property key; the root's key is
|
|
472
|
+
// the empty string, and the result takes its own serialization — the
|
|
473
|
+
// hook does not run again over the value it returned.
|
|
474
|
+
const call = accessorCall(lowerer, c.def.name, "toJSON", recv(), toJson.params > 0 ? [strLit("", loc)] : [], toJson.ret, loc);
|
|
475
|
+
rendered = jsonSerializeExpr(lowerer, call, loc, true);
|
|
476
|
+
}
|
|
477
|
+
else if (errorDeclaresToJson(c)) {
|
|
478
|
+
// A getter or data-field toJSON: only the checked-dynamic view sees it.
|
|
479
|
+
rendered = null;
|
|
480
|
+
}
|
|
481
|
+
else if (errorDeclaresCause(c)) {
|
|
482
|
+
// A declared cause prints where its initializer runs, and the record
|
|
483
|
+
// writer has no slot for it: the ordered walk carries the class's
|
|
484
|
+
// properties.
|
|
485
|
+
rendered = errorOrderedJson(lowerer, c, recv, loc);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const record = jsonErrorFieldsRecord(lowerer, c, recv, loc);
|
|
489
|
+
const ordered = record === null ? null : errorOrderedJson(lowerer, c, recv, loc);
|
|
490
|
+
// A class whose fields the record writes but the checked walk cannot
|
|
491
|
+
// carry (a function-valued field) keeps the record alone: the head's
|
|
492
|
+
// rendering, and the runtime flags of such a class stay unread.
|
|
493
|
+
rendered =
|
|
494
|
+
record === null
|
|
495
|
+
? null
|
|
496
|
+
: ordered === null
|
|
497
|
+
? record
|
|
498
|
+
: {
|
|
499
|
+
kind: "ternary",
|
|
500
|
+
cond: errorRecordDeviation(c, recv, loc),
|
|
501
|
+
then: ordered,
|
|
502
|
+
else_: record,
|
|
503
|
+
type: STRING,
|
|
504
|
+
loc,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
const arm = {
|
|
508
|
+
kind: "return",
|
|
509
|
+
value: rendered ?? dynamicRender(recv()),
|
|
510
|
+
loc,
|
|
511
|
+
};
|
|
512
|
+
if (rendered !== null)
|
|
513
|
+
fieldArms.push({ info: c, arm, dyn: () => dynamicRender(recv()) });
|
|
514
|
+
if (c.def.name === t.className) {
|
|
515
|
+
body.push({ kind: "block", body: [arm], loc });
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
body.push({
|
|
519
|
+
kind: "if",
|
|
520
|
+
cond: { kind: "instanceOf", value: v(), className: c.def.name, type: BOOL, loc },
|
|
521
|
+
then: [arm],
|
|
522
|
+
else_: null,
|
|
523
|
+
loc,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
// A builtin error instance of the subtree (an Error-typed `new TypeError()`
|
|
527
|
+
// reaches here through an Error static type): its extra state rides
|
|
528
|
+
// non-enumerable slots, so the walk sees no own property — until a write
|
|
529
|
+
// after construction makes `name` or `cause` own and enumerable, which
|
|
530
|
+
// the runtime's flags record and the checked-dynamic view renders.
|
|
531
|
+
if (body.at(-1)?.kind !== "block") {
|
|
532
|
+
const className = t.className;
|
|
533
|
+
body.push({
|
|
534
|
+
kind: "return",
|
|
535
|
+
value: {
|
|
536
|
+
kind: "ternary",
|
|
537
|
+
cond: {
|
|
538
|
+
kind: "logical",
|
|
539
|
+
op: "||",
|
|
540
|
+
left: errorHeaderFlag(v(), className, "name", loc),
|
|
541
|
+
right: errorHeaderFlag(v(), className, "cause", loc),
|
|
542
|
+
type: BOOL,
|
|
543
|
+
loc,
|
|
544
|
+
},
|
|
545
|
+
then: {
|
|
546
|
+
kind: "libCall",
|
|
547
|
+
fn: "insp.jsonDyn",
|
|
548
|
+
args: [lowerer.coerceToExpected(v(), DYN)],
|
|
549
|
+
type: STRING,
|
|
550
|
+
loc,
|
|
551
|
+
},
|
|
552
|
+
else_: strLit("{}", loc),
|
|
553
|
+
type: STRING,
|
|
554
|
+
loc,
|
|
555
|
+
},
|
|
556
|
+
loc,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
const name = keyedHelperName(lowerer, "%util.format.jsonError", key);
|
|
560
|
+
lowerer.inspectHelpers.set(key, name);
|
|
561
|
+
lowerer.liftedFns.push({
|
|
562
|
+
name,
|
|
563
|
+
params: [{ localId: "v.0", name: "v", type: t }],
|
|
564
|
+
returnType: STRING,
|
|
565
|
+
locals: [{ id: "v.0", name: "v", type: t, mutable: false }],
|
|
566
|
+
body,
|
|
567
|
+
loc,
|
|
568
|
+
});
|
|
569
|
+
// A property created at run time (a write through an untyped reference)
|
|
570
|
+
// adds a property bag to a class after this helper was built. JSON
|
|
571
|
+
// enumerates those properties too, and only the checked-dynamic view
|
|
572
|
+
// reads the bag, so a bagged class's arm switches to that view.
|
|
573
|
+
lowerer.shapeOrderHelperFinalizers.push(() => {
|
|
574
|
+
for (const { info: c, arm, dyn } of fieldArms)
|
|
575
|
+
if (c.def.fields.some((f) => f.name === DYN_CLASS_PROPERTIES))
|
|
576
|
+
arm.value = dyn();
|
|
577
|
+
});
|
|
578
|
+
return name;
|
|
579
|
+
}
|
|
153
580
|
/** `info` and its descendants that declare fields, most-derived first (a
|
|
154
581
|
* runtime instance tests against its own class before an ancestor's). */
|
|
155
582
|
function fieldedErrorClasses(info) {
|
|
@@ -681,6 +1108,15 @@ function isErrorClass(lowerer, className) {
|
|
|
681
1108
|
return true;
|
|
682
1109
|
return lowerer.isSubclassOf(className, "%Error");
|
|
683
1110
|
}
|
|
1111
|
+
/** The class or a base declares a `toJSON` member (method, getter or
|
|
1112
|
+
* field): JSON.stringify calls it before walking the own properties. */
|
|
1113
|
+
function errorDeclaresToJson(info) {
|
|
1114
|
+
for (let c = info; c; c = c.base) {
|
|
1115
|
+
if (c.methods.has("toJSON") || c.methods.has("get:toJSON") || c.fields.has("toJSON"))
|
|
1116
|
+
return true;
|
|
1117
|
+
}
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
684
1120
|
/** inspUnsupportedReason: the deepUnsupportedReason twin. Fences name the
|
|
685
1121
|
* FIRST unsupported constituent. `visiting` terminates recursive shapes
|
|
686
1122
|
* and records their existence (the depth-null gate). */
|
|
@@ -3868,6 +4304,41 @@ export function lowerFormatCall(lowerer, expr, loc, withOptions, argNodesOverrid
|
|
|
3868
4304
|
if (value.type.kind === "dyn") {
|
|
3869
4305
|
return { kind: "libCall", fn: "insp.jsonDyn", args: [value], type: STRING, loc };
|
|
3870
4306
|
}
|
|
4307
|
+
// %j of an Error (the middleware logging idiom): JSON.stringify
|
|
4308
|
+
// sees an error's own ENUMERABLE properties, and message, stack and
|
|
4309
|
+
// cause are not enumerable — so a plain error prints "{}", as do
|
|
4310
|
+
// the runtime error classes whose extra state rides non-enumerable
|
|
4311
|
+
// slots (AggregateError's `errors`, DOMException's accessors,
|
|
4312
|
+
// AssertionError's dynamic view). A subclass that declares fields
|
|
4313
|
+
// prints those, and one that declares a toJSON hook prints the
|
|
4314
|
+
// hook's result, so the lifted walk renders the RUNTIME class's
|
|
4315
|
+
// shape; a toJSON member it cannot call statically keeps the
|
|
4316
|
+
// checked dynamic walk for that class.
|
|
4317
|
+
if (value.type.kind === "object" && isErrorClass(lowerer, value.type.className)) {
|
|
4318
|
+
const className = value.type.className;
|
|
4319
|
+
if (className === "%AssertionError") {
|
|
4320
|
+
lowerer.noLowering(`util.format %j of '${lowerer.fmt(value.type)}' values`, node, "AssertionError keeps its own properties in the error's dynamic view");
|
|
4321
|
+
}
|
|
4322
|
+
// The lifted walk reads the runtime class, so a subclass instance
|
|
4323
|
+
// reaching the base's static type prints its own fields and honors
|
|
4324
|
+
// its own toJSON hook. The receiver evaluates once as the call's
|
|
4325
|
+
// argument, so its calls and throws stay observable.
|
|
4326
|
+
const helper = jsonErrorHelper(lowerer, value.type, loc);
|
|
4327
|
+
if (helper !== null)
|
|
4328
|
+
return { kind: "call", callee: helper, args: [value], type: STRING, loc };
|
|
4329
|
+
// A builtin error with no program subclass has no own enumerable
|
|
4330
|
+
// property: Node prints "{}". The argument expression still runs;
|
|
4331
|
+
// only a discard-safe read folds away.
|
|
4332
|
+
if (isSafeToDiscard(value))
|
|
4333
|
+
return strLit("{}", loc);
|
|
4334
|
+
return {
|
|
4335
|
+
kind: "seqExpr",
|
|
4336
|
+
stmts: [{ kind: "exprStmt", expr: value, loc }],
|
|
4337
|
+
result: strLit("{}", loc),
|
|
4338
|
+
type: STRING,
|
|
4339
|
+
loc,
|
|
4340
|
+
};
|
|
4341
|
+
}
|
|
3871
4342
|
if (!lowerer.jsonStringifySafe(value.type)) {
|
|
3872
4343
|
lowerer.noLowering(`util.format %j of '${lowerer.fmt(value.type)}' values`, node, "only JSON-safe static types lower");
|
|
3873
4344
|
}
|