@scriptc/compiler 0.2.9 → 0.3.0
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 +2 -36
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.d.ts +56 -0
- package/dist/backend/cycle-analysis.js +175 -14
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +95 -2
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +3 -7
- package/dist/backend/cycle-mutability.js +4 -30
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +3 -8
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +57 -0
- package/dist/backend/immutability.js +178 -0
- package/dist/backend/immutability.js.map +1 -0
- package/dist/backend/immutability.test.js +131 -0
- package/dist/backend/immutability.test.js.map +1 -0
- package/dist/backend/library-pack.js +0 -2
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.d.ts +9 -2
- package/dist/backend/llvm/borrowed-inputs.js +31 -3
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/classes.d.ts +28 -0
- package/dist/backend/llvm/classes.js +48 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +134 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +13 -0
- package/dist/backend/llvm/common.js +13 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +1 -1
- package/dist/backend/llvm/constant-callbacks.js +3 -3
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +1 -1
- package/dist/backend/llvm/dense-array-access.js +5 -4
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +10 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +2 -1
- package/dist/backend/llvm/dyn.js +3 -76
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +67 -19
- package/dist/backend/llvm/emitter.js +443 -226
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +21 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-calls.js +14 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +41 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +4 -107
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -2
- package/dist/backend/llvm/expr-dispatch.js +0 -41
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +1 -1
- package/dist/backend/llvm/expr-dynamic.js +13 -27
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +30 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/lib-dispatch.js +0 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +0 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +0 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +3 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +5 -2
- package/dist/backend/llvm/loop-array-borrows.js +27 -8
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +14 -0
- package/dist/backend/llvm/map-number-lookup.js +33 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -4
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +25 -3
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +124 -0
- package/dist/backend/llvm/reference-writes.js +1090 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +8 -5
- package/dist/backend/llvm/shapes.js +37 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -3
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +40 -11
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +3 -0
- package/dist/backend/llvm/string-reads.js +31 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.d.ts +2 -2
- package/dist/backend/llvm/switch-dispatch.js +35 -22
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +29 -11
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +8 -1
- package/dist/backend/llvm/walk-borrows.js +15 -4
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/may-throw.d.ts +36 -2
- package/dist/backend/may-throw.js +308 -21
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +147 -2
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.js +0 -2
- package/dist/backend/native/artifact-stamps.js.map +1 -1
- package/dist/backend/native/cache-warm.d.ts +1 -1
- package/dist/backend/native/cache-warm.js +2 -3
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +1 -1
- package/dist/backend/native/compiler-fingerprint.js +4 -7
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +3 -28
- package/dist/backend/native/driver.js +1 -3
- package/dist/backend/native/driver.js.map +1 -1
- package/dist/backend/native/executable.d.ts +0 -15
- package/dist/backend/native/executable.js +17 -172
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/tool-identity.js +0 -1
- package/dist/backend/native/tool-identity.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +0 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +23 -33
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/publication.d.ts +5 -0
- package/dist/backend/publication.js +10 -0
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -2
- package/dist/backend/runtime-pack-core.js +5 -14
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -8
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +22 -19
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +0 -5
- package/dist/backend/target-diagnostics.js +1 -11
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -7
- package/dist/backend/vendor-archives.js +9 -189
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +0 -1
- package/dist/backend/vendor-inputs.js +0 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -5
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +4 -8
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +1 -1
- package/dist/cli/usage.d.ts +1 -5
- package/dist/cli/usage.js +4 -9
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +2 -2
- package/dist/compat/fetch-profile.js +16 -25
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +2 -17
- package/dist/contracts/check.d.ts +8 -0
- package/dist/contracts/check.js +1573 -0
- package/dist/contracts/check.js.map +1 -0
- package/dist/coverage/report.d.ts +5 -22
- package/dist/coverage/report.js +12 -76
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +3 -3
- package/dist/coverage/surface-manifest.js +22 -27
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -3
- package/dist/coverage/verdict-cache.js +2 -7
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -60
- package/dist/diagnostics/diagnostic.js +39 -118
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -4
- package/dist/diagnostics/envelope.js +0 -9
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +0 -3
- package/dist/executable/executable-cache.js +2 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +0 -4
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +14 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +10 -10
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +0 -88
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/contract-types.d.ts +50 -0
- package/dist/frontend/contract-types.js +232 -0
- package/dist/frontend/contract-types.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +1 -1
- package/dist/frontend/dts-paths.js +1 -1
- package/dist/frontend/lowering/abstract-equality.js +1 -4
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +4 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.js +0 -13
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +0 -4
- package/dist/frontend/lowering/builtins/crypto.js +0 -4
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +1 -39
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +0 -15
- package/dist/frontend/lowering/builtins/module-resolution.js +5 -44
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +0 -6
- package/dist/frontend/lowering/builtins/numbers.js +6 -57
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +4 -67
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +1 -1
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +1 -37
- package/dist/frontend/lowering/call-arguments.js +11 -94
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +1 -6
- package/dist/frontend/lowering/call-signatures.js +16 -68
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +19 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.js +168 -98
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +44 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +0 -2
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +1 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +5 -35
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +0 -1
- package/dist/frontend/lowering/coercions/state.js +0 -1
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -4
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +2 -12
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +12 -0
- package/dist/frontend/lowering/coercions/unions.js +63 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +9 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +2 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +10 -54
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +0 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +2 -10
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +1 -6
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +0 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +0 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +2 -10
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +0 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +0 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -8
- package/dist/frontend/lowering/expressions/object-literals.js +8 -35
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +0 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +7 -67
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +0 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +0 -1
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +10 -77
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +1 -10
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +2 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +2 -27
- package/dist/frontend/lowering/lower-calls.js +56 -465
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +11 -49
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js +2 -3
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -8
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +3 -4
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +3 -5
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -8
- package/dist/frontend/lowering/lower-exprs.js +133 -908
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -5
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +1 -50
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +0 -43
- package/dist/frontend/lowering/lower-modules.js +25 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +5 -5
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +0 -30
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +98 -0
- package/dist/frontend/lowering/{lower-island.js → lower-stdlib.js} +97 -1160
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +0 -16
- package/dist/frontend/lowering/lower-stmts.js +58 -1016
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -3
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +26 -151
- package/dist/frontend/lowering/lowerer.js +120 -770
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +4 -51
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +100 -0
- package/dist/frontend/lowering/narrowing-stability.js +1174 -0
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -0
- package/dist/frontend/lowering/narrowing-stability.test.js +150 -0
- package/dist/frontend/lowering/narrowing-stability.test.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/strict-equality.js +1 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -45
- package/dist/frontend/lowering/surfaces.js +5 -65
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +0 -3
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-node.d.ts +0 -7
- package/dist/frontend/npm-node.js +0 -7
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +6 -82
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +1 -1
- package/dist/frontend/npm-static.js +6 -71
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +3 -319
- package/dist/frontend/npm.js +6 -1007
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -197
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js +1 -2
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +3 -11
- package/dist/frontend/pipeline.js +37 -56
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +12 -6
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +0 -34
- package/dist/frontend/program.js +13 -98
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +0 -4
- package/dist/frontend/provenance-core.js +4 -37
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -4
- package/dist/frontend/provenance-registry.js +0 -20
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.d.ts +0 -12
- package/dist/frontend/resolve.js +0 -34
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +2 -2
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/services-node.js +2 -3
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services.d.ts +1 -8
- package/dist/frontend/services.js +2 -22
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +0 -38
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +0 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +2 -27
- package/dist/frontend/type-mapper.js +85 -153
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/builtin-effects.js +0 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +1 -55
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +29 -3
- package/dist/ir/int32-slots.js +152 -66
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/integer-loops.js +3 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +26 -1
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +20 -0
- package/dist/ir/integer-ranges.js +178 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +148 -3
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +44 -284
- package/dist/ir/ir.js +10 -259
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -7
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -30
- package/dist/ir/runtime-features.js +5 -41
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +6 -2
- package/dist/ir/serialize.js +11 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +0 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.d.ts +14 -0
- package/dist/ir/unshare.js +60 -0
- package/dist/ir/unshare.js.map +1 -0
- package/dist/ir/unshare.test.js +115 -0
- package/dist/ir/unshare.test.js.map +1 -0
- package/dist/ir/validate.js +9 -207
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +6 -6
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/prepare.js +14 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +0 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.test.js +2 -4
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -4
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +2 -16
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +0 -3
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.js +0 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +80 -88
- package/dist/backend/llvm/expr-island.d.ts +0 -15
- package/dist/backend/llvm/expr-island.js +0 -709
- package/dist/backend/llvm/expr-island.js.map +0 -1
- package/dist/frontend/lowering/coercions/island.d.ts +0 -37
- package/dist/frontend/lowering/coercions/island.js +0 -350
- package/dist/frontend/lowering/coercions/island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.d.ts +0 -229
- package/dist/frontend/lowering/lower-island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.test.js +0 -56
- package/dist/frontend/lowering/lower-island.test.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.d.ts +0 -17
- package/dist/frontend/npm-fetch-analysis.js +0 -109
- package/dist/frontend/npm-fetch-analysis.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.test.js +0 -130
- package/dist/frontend/npm-fetch-analysis.test.js.map +0 -1
- package/dist/frontend/npm-fetch-node.d.ts +0 -2
- package/dist/frontend/npm-fetch-node.js +0 -12
- package/dist/frontend/npm-fetch-node.js.map +0 -1
- package/dist/frontend/npm-fetch-syntax.d.ts +0 -6
- package/dist/frontend/npm-fetch-syntax.js +0 -202
- package/dist/frontend/npm-fetch-syntax.js.map +0 -1
- package/dist/native/runtime-typescript.d.ts +0 -4
- package/dist/native/runtime-typescript.js +0 -74
- package/dist/native/runtime-typescript.js.map +0 -1
- package/dist/native/runtime-typescript.test.js +0 -41
- package/dist/native/runtime-typescript.test.js.map +0 -1
- /package/dist/{frontend/lowering/lower-island.test.d.ts → backend/immutability.test.d.ts} +0 -0
- /package/dist/frontend/{npm-fetch-analysis.test.d.ts → lowering/narrowing-stability.test.d.ts} +0 -0
- /package/dist/{native/runtime-typescript.test.d.ts → ir/unshare.test.d.ts} +0 -0
|
@@ -14,17 +14,18 @@ import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocke
|
|
|
14
14
|
import { widthCoerce, applyWidthLift, unionRecordWidthHelper, recordWidthHelper, tupleArrayWidthHelper, emptyArrayLiftHelper, arrayWidthHelper, objRecordWidthHelper, recordClassWidthHelper, classStaticsProjection, } from "./coercions/structural.js";
|
|
15
15
|
import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
|
|
16
16
|
import { unionRetagMappable, narrowedRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
|
|
17
|
-
import { jsvalLiftable, jsvalLiftExpr, unionToJsvalHelper, recordToJsvalHelper, arrayToJsvalHelper, arrayToJsvalArrayHelper, } from "./coercions/island.js";
|
|
18
17
|
import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
|
|
19
|
-
import {
|
|
18
|
+
import { transformStmtList } from "../../ir/traverse.js";
|
|
20
19
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
21
20
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
21
|
+
import { NarrowingStability } from "./narrowing-stability.js";
|
|
22
22
|
import { ArrayElementStates } from "./runtime-optional-elements.js";
|
|
23
23
|
import { indexReadInBounds } from "./runtime-optional-bounds.js";
|
|
24
24
|
import { ArrayOwnership } from "./runtime-optional-ownership.js";
|
|
25
25
|
import { StringIndexBounds } from "./string-index-bounds.js";
|
|
26
26
|
import { NanCodedReads } from "./nan-coded-reads.js";
|
|
27
27
|
import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
|
|
28
|
+
import { collectContractAnnotations } from "../contract-types.js";
|
|
28
29
|
import { sanitizeUnregisteredClassTypes } from "./sanitize-class-types.js";
|
|
29
30
|
import { UnregisteredClassTypes } from "./unregistered-class-types.js";
|
|
30
31
|
import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, } from "./function-context.js";
|
|
@@ -55,12 +56,12 @@ import { tsgoPath } from "../dts-paths.js";
|
|
|
55
56
|
import * as ts from "../ts7/adapter.js";
|
|
56
57
|
import { literalValues } from "../literal-values.js";
|
|
57
58
|
import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
|
|
58
|
-
import {
|
|
59
|
-
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn,
|
|
59
|
+
import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
|
|
60
|
+
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
60
61
|
import { provenanceActive } from "../provenance-registry.js";
|
|
61
62
|
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
62
|
-
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType,
|
|
63
|
-
import {
|
|
63
|
+
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
64
|
+
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
64
65
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
65
66
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
66
67
|
import { registerBuiltinErrorClasses, registerBuiltinEmitterClass, registerBuiltinStreamClasses, builtinErrorInfoOf, builtinEmitterInfoOf, builtinStreamInfoOf, analyzeClassDecoration, classIteratorDrainCall, classIteratorNextCall, classIteratorOf, classIteratorOpenCall, classIteratorRestDrainCall, classMemberNameOf, classValueRef, collectClassShape, exactClassOfReceiver, collectClassShapeInner, ctorAbiEquals, findMethodOn, findStaticOn, genericClassInstanceType, isSubclassOf, inHierarchy, overrideBelow, staticShadowBelow, upcastTo, lowerClassMembers, lowerClassCtor, lowerClassExpression, lowerClassExpressionInfo, lowerClassMethodMember, lowerClassValueProperty, lowerStaticMethod, throwingSetterFn, fieldInitStmts, lowerStaticFieldInits, lowerStaticFieldRead, lowerDerivedCtorBody, superCallStmt, lowerSuperMethodCall, superThisRef, lowerSuperAccessorRead, lowerSuperAccessorWrite, inheritsBuiltinErrorCtor, inheritsBuiltinEmitterCtor, errorConstructorArgs, lowerNew, accessorCall, } from "./lower-classes.js";
|
|
@@ -81,7 +82,7 @@ import { lowerEnvToPairsHelper } from "./containers/indexed-objects.js";
|
|
|
81
82
|
import { lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew } from "./containers/bytes.js";
|
|
82
83
|
import { lowerRegexMethodCall, lowerStringMethodCall } from "./containers/string-and-regexp.js";
|
|
83
84
|
import { lowerEmitOverrideSpec, } from "./lower-event-emitter.js";
|
|
84
|
-
import { builtinImportOf,
|
|
85
|
+
import { builtinImportOf, createRequireProgramModuleOf, createRequireSpecOf, fencedBuiltinImportOf, } from "./builtins/module-bindings.js";
|
|
85
86
|
import { stripTypeCasts } from "./builtins/arguments.js";
|
|
86
87
|
import { lowerBuiltinModuleCall } from "./builtins/module-calls.js";
|
|
87
88
|
import { lowerTimersPromisesSetInterval, lowerTimeoutMethodCall } from "./builtins/timers.js";
|
|
@@ -108,7 +109,7 @@ import { lowerDateCall } from "./builtins/dates.js";
|
|
|
108
109
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
109
110
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
110
111
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
111
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember,
|
|
112
|
+
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
112
113
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
113
114
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
114
115
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -116,7 +117,7 @@ import { lowerAssertModuleCall, lowerAssertDirectCall } from "./lower-assert.js"
|
|
|
116
117
|
import { lowerUtilModuleCall } from "./lower-inspect.js";
|
|
117
118
|
import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
|
|
118
119
|
import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
|
|
119
|
-
import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern,
|
|
120
|
+
import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, } from "./lower-stmts.js";
|
|
120
121
|
import { lowerExpr, maybeNarrow, lowerUnitComparison, lowerNullishCoalesce, lowerCondition, ensureBool, requireTruthyUnion, eqComparableUnion, lowerIntrinsicProperty, lowerArrayLiteral, lowerElementAccess, lowerElementWrite, lowerRecordKeyRead, ensureString, lowerTemplate, lowerAsExpression, lowerPrefixUnary, lowerBinary, lowerCaughtTypeofTest, caughtRead, caughtLocalOf, caughtToString, lowerInstanceOf, lowerRegexLiteral, lowerFieldRead, lowerUnionProperty, fieldTarget, fieldGetExpr, fieldSetStmt, lowerFieldCompound, uniqueSymbolKeyOf, } from "./lower-exprs.js";
|
|
121
122
|
import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
|
|
122
123
|
import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
|
|
@@ -137,35 +138,6 @@ export class PoisonError extends Error {
|
|
|
137
138
|
export function own(table, key) {
|
|
138
139
|
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
139
140
|
}
|
|
140
|
-
/** IrStmt discriminants — the island walk below must not descend into
|
|
141
|
-
* NESTED statements (each is counted individually by its own lowerStmts
|
|
142
|
-
* visit; descending would attribute a nested island statement to every
|
|
143
|
-
* enclosing construct too). The top-level statement object itself is
|
|
144
|
-
* always visited. */
|
|
145
|
-
const IR_STMT_KINDS = new Set([
|
|
146
|
-
"varDecl",
|
|
147
|
-
"assign",
|
|
148
|
-
"exprStmt",
|
|
149
|
-
"if",
|
|
150
|
-
"while",
|
|
151
|
-
"doWhile",
|
|
152
|
-
"switch",
|
|
153
|
-
"arraySet",
|
|
154
|
-
"arraySetLength",
|
|
155
|
-
"arraySetUndefined",
|
|
156
|
-
"arrayDelete",
|
|
157
|
-
"forOf",
|
|
158
|
-
"return",
|
|
159
|
-
"fieldSet",
|
|
160
|
-
"recordSet",
|
|
161
|
-
"break",
|
|
162
|
-
"continue",
|
|
163
|
-
"block",
|
|
164
|
-
"tryCatch",
|
|
165
|
-
"throw",
|
|
166
|
-
"rethrow",
|
|
167
|
-
"runtimeFence",
|
|
168
|
-
]);
|
|
169
141
|
/** Every identifier a binding name binds: the identifier itself, or all
|
|
170
142
|
* identifiers of a (possibly nested) destructuring pattern in source
|
|
171
143
|
* order. */
|
|
@@ -182,28 +154,6 @@ export function boundIdentifiersOf(name) {
|
|
|
182
154
|
}
|
|
183
155
|
return out;
|
|
184
156
|
}
|
|
185
|
-
/** Inspect executable children directly, without boxing the statement tree
|
|
186
|
-
* into checked-dynamic storage just to calculate coverage. */
|
|
187
|
-
export function stmtUsesIsland(stmts) {
|
|
188
|
-
// Keep the accounting boundary at the source statement: nested statement
|
|
189
|
-
// lists are counted by their own lowerStmts invocation.
|
|
190
|
-
const nested = (stmt) => IR_STMT_KINDS.has(stmt.kind) || everyStmtChild(stmt, expr, nested);
|
|
191
|
-
const expr = (node) => {
|
|
192
|
-
if (node.kind === "jsOp" ||
|
|
193
|
-
node.kind === "jsExit" ||
|
|
194
|
-
node.kind === "jsBridgePromise" ||
|
|
195
|
-
(node.kind === "libCall" &&
|
|
196
|
-
(node.fn === "island.eval" ||
|
|
197
|
-
node.fn === "island.import" ||
|
|
198
|
-
node.fn === "island.importDyn" ||
|
|
199
|
-
node.fn === "island.castFail")))
|
|
200
|
-
return false;
|
|
201
|
-
return everyExprChild(node, expr, nested);
|
|
202
|
-
};
|
|
203
|
-
if (Array.isArray(stmts))
|
|
204
|
-
return !stmts.every((stmt) => everyStmtChild(stmt, expr, nested));
|
|
205
|
-
return !everyStmtChild(stmts, expr, nested);
|
|
206
|
-
}
|
|
207
157
|
/** Statements a never-lowered body would have contributed to the coverage
|
|
208
158
|
* totals: every element of a statement list (blocks, case clauses), plus
|
|
209
159
|
* the single-statement bodies of control flow, nested functions included —
|
|
@@ -284,13 +234,12 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
284
234
|
process.stderr.write(`scriptc lowering ${JSON.stringify(event)}\n`);
|
|
285
235
|
phaseLast = now;
|
|
286
236
|
};
|
|
287
|
-
const dynamic = options.dynamic ?? false;
|
|
288
237
|
const targetPlatform = options.targetPlatform ?? process.platform;
|
|
289
238
|
const startupCrash = options.startupCrash ?? null;
|
|
290
239
|
// Modules reachable only through literal import() of the program's own
|
|
291
240
|
// files join the compiled graph here, ONCE, before any
|
|
292
241
|
// pass constructs (nothing calls their %init at startup — the import()
|
|
293
|
-
// site's namespace builder does, on the
|
|
242
|
+
// site's namespace builder does, on the native microtask, Node's
|
|
294
243
|
// evaluation point for them). Inadmissible static cycles inside the
|
|
295
244
|
// added subgraph are minted here and handed to reachable emit after this
|
|
296
245
|
// extension of the shared array; no later pass re-walks the subgraph.
|
|
@@ -319,7 +268,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
319
268
|
const libraryCallbacks = options.libraryCallbacks ?? false;
|
|
320
269
|
const externalTypes = options.externalTypes ?? new Map();
|
|
321
270
|
const externalTypeSpecifiersByFile = options.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(externalTypes);
|
|
322
|
-
const validation = new Lowerer(program, entry, moduleOrder,
|
|
271
|
+
const validation = new Lowerer(program, entry, moduleOrder, {
|
|
323
272
|
frontendServices: options.frontendServices,
|
|
324
273
|
targetPlatform,
|
|
325
274
|
startupCrash,
|
|
@@ -339,7 +288,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
339
288
|
// lowerer because validation is an immediate no-op there.
|
|
340
289
|
const reachableEmit = ffiImports.length === 0
|
|
341
290
|
? validation
|
|
342
|
-
: new Lowerer(program, entry, moduleOrder,
|
|
291
|
+
: new Lowerer(program, entry, moduleOrder, {
|
|
343
292
|
frontendServices: options.frontendServices,
|
|
344
293
|
targetPlatform,
|
|
345
294
|
startupCrash,
|
|
@@ -368,7 +317,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
368
317
|
// historical compiler. This is a rare compatibility fallback; programs
|
|
369
318
|
// without such a settled fence retain checker-backed IR exactly once.
|
|
370
319
|
if (reachableEmit.requiresHistoricalOrderRelower) {
|
|
371
|
-
const emit = new Lowerer(program, entry, moduleOrder,
|
|
320
|
+
const emit = new Lowerer(program, entry, moduleOrder, {
|
|
372
321
|
frontendServices: options.frontendServices,
|
|
373
322
|
reachable,
|
|
374
323
|
targetPlatform,
|
|
@@ -395,9 +344,42 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
395
344
|
timing("divergence-scan", { found: divergences.length });
|
|
396
345
|
if (divergences.length > 0)
|
|
397
346
|
result = { ...result, divergences };
|
|
347
|
+
// Contract types (@scriptc/types): written annotations, checked against
|
|
348
|
+
// the IR by the compile pipeline (contracts/check.ts).
|
|
349
|
+
// Acyclic object types name the IR unit the program lowered them to; a
|
|
350
|
+
// type the module never uses has no unit (mapping it now only touches the
|
|
351
|
+
// lowerer's tables, never the finished module).
|
|
352
|
+
const lowered = result.module;
|
|
353
|
+
const contracts = collectContractAnnotations(program.getTypeChecker(), moduleOrder, (type) => {
|
|
354
|
+
if (lowered === null)
|
|
355
|
+
return null;
|
|
356
|
+
const mapped = panicSafe(() => resultLowerer.mapTypeOf(type), null);
|
|
357
|
+
if (mapped?.kind === "object")
|
|
358
|
+
return lowered.classes?.some((c) => c.name === mapped.className)
|
|
359
|
+
? `object:${mapped.className}`
|
|
360
|
+
: null;
|
|
361
|
+
if (mapped?.kind === "record")
|
|
362
|
+
return lowered.records?.some((r) => r.id === mapped.shapeId)
|
|
363
|
+
? `record:${mapped.shapeId}`
|
|
364
|
+
: null;
|
|
365
|
+
if (mapped?.kind === "union")
|
|
366
|
+
return lowered.unions?.some((u) => u.id === mapped.unionId)
|
|
367
|
+
? `union:${mapped.unionId}`
|
|
368
|
+
: null;
|
|
369
|
+
return null;
|
|
370
|
+
});
|
|
371
|
+
timing("contract-annotations", { found: contracts.count });
|
|
372
|
+
if (contracts.diagnostics.length > 0)
|
|
373
|
+
result = {
|
|
374
|
+
...result,
|
|
375
|
+
module: null,
|
|
376
|
+
diagnostics: [...result.diagnostics, ...contracts.diagnostics],
|
|
377
|
+
};
|
|
378
|
+
else if (contracts.count > 0)
|
|
379
|
+
result = { ...result, contracts };
|
|
398
380
|
if (options.coverage !== true)
|
|
399
381
|
return result;
|
|
400
|
-
const remainder = new Lowerer(program, entry, moduleOrder,
|
|
382
|
+
const remainder = new Lowerer(program, entry, moduleOrder, {
|
|
401
383
|
frontendServices: options.frontendServices,
|
|
402
384
|
reachable,
|
|
403
385
|
remainder: true,
|
|
@@ -424,40 +406,13 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
424
406
|
},
|
|
425
407
|
};
|
|
426
408
|
}
|
|
427
|
-
/** The island-handle type a `import(...)` initializer gives a binding
|
|
428
|
-
* whose DECLARED type has no static mapping (`Promise<typeof
|
|
429
|
-
* import("./m")>` — module-namespace types don't map): the direct form
|
|
430
|
-
* holds the static promise-of-handle, the awaited form holds the handle
|
|
431
|
-
* itself. Null for every other initializer shape. */
|
|
432
|
-
export function importCallHandleType(expr) {
|
|
433
|
-
if (!expr)
|
|
434
|
-
return null;
|
|
435
|
-
let e = expr;
|
|
436
|
-
let awaited = false;
|
|
437
|
-
for (;;) {
|
|
438
|
-
if (ts.isParenthesizedExpression(e)) {
|
|
439
|
-
e = e.expression;
|
|
440
|
-
}
|
|
441
|
-
else if (ts.isAwaitExpression(e)) {
|
|
442
|
-
awaited = true;
|
|
443
|
-
e = e.expression;
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
break;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
if (ts.isCallExpression(e) && e.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
450
|
-
return awaited ? JSVAL : { kind: "promise", inner: JSVAL };
|
|
451
|
-
}
|
|
452
|
-
return null;
|
|
453
|
-
}
|
|
454
409
|
/** The native namespace type produced by a literal static import() of a
|
|
455
410
|
* compiled program module or supported Node builtin. This syntax-level
|
|
456
411
|
* fallback is used where the checker exposes an anonymous builtin-module
|
|
457
412
|
* object type with no stable module symbol (locals/globals are still
|
|
458
413
|
* represented nominally by the value they actually receive). */
|
|
459
414
|
export function staticImportNamespaceType(lowerer, expr) {
|
|
460
|
-
if (!expr
|
|
415
|
+
if (!expr)
|
|
461
416
|
return null;
|
|
462
417
|
let e = expr;
|
|
463
418
|
let awaited = false;
|
|
@@ -496,48 +451,8 @@ export function staticImportNamespaceType(lowerer, expr) {
|
|
|
496
451
|
const ns = { kind: "moduleNs", moduleId };
|
|
497
452
|
return awaited ? ns : { kind: "promise", inner: ns };
|
|
498
453
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
* (`any` under --dynamic): tsc never checks overload return types against
|
|
502
|
-
* the body — only the implementation signature is checked — so the
|
|
503
|
-
* overload's return is an unverifiable claim about an island value. The
|
|
504
|
-
* binding stores the HANDLE instead of trap-extracting the claimed type
|
|
505
|
-
* (reconcileOverloadReturn keeps the call jsval by the same rule), and
|
|
506
|
-
* uses dispatch to engine ops — exactly the value Node's binding holds.
|
|
507
|
-
* Ambient (.d.ts) declarations never reach this: they have no compiled
|
|
508
|
-
* implementation, so their calls lower through the island/builtin paths
|
|
509
|
-
* whose validated exits keep the checker-trust trap. */
|
|
510
|
-
export function uncheckedOverloadHandleCall(lowerer, expr) {
|
|
511
|
-
if (!lowerer.dynamic || !expr)
|
|
512
|
-
return false;
|
|
513
|
-
let e = expr;
|
|
514
|
-
while (ts.isParenthesizedExpression(e))
|
|
515
|
-
e = e.expression;
|
|
516
|
-
// Tagged templates are calls too (tag(strings, ...values)) and resolve
|
|
517
|
-
// overload sets the same way — foo1`${1}` against a TemplateStringsArray
|
|
518
|
-
// overload of an any-returning implementation stores the handle.
|
|
519
|
-
if (!ts.isCallExpression(e) && !ts.isTaggedTemplateExpression(e))
|
|
520
|
-
return false;
|
|
521
|
-
const rsig = lowerer.checker.getResolvedSignature(e);
|
|
522
|
-
const rdecl = rsig ? lowerer.checker.signatureDeclaration(rsig) : undefined;
|
|
523
|
-
if (!rsig || !rdecl)
|
|
524
|
-
return false;
|
|
525
|
-
if (!(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) || rdecl.body)
|
|
526
|
-
return false;
|
|
527
|
-
const name = rdecl.name;
|
|
528
|
-
const symbol = name ? lowerer.checker.getSymbolAtLocation(name) : undefined;
|
|
529
|
-
if (!symbol)
|
|
530
|
-
return false;
|
|
531
|
-
const impl = lowerer.checker
|
|
532
|
-
.declarationsOf(symbol)
|
|
533
|
-
.find((d) => (ts.isFunctionDeclaration(d) || ts.isMethodDeclaration(d)) &&
|
|
534
|
-
d.body !== undefined);
|
|
535
|
-
if (!impl)
|
|
536
|
-
return false;
|
|
537
|
-
const implSig = lowerer.checker.getSignatureFromDeclaration(impl);
|
|
538
|
-
if (!implSig)
|
|
539
|
-
return false;
|
|
540
|
-
return lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(implSig))?.kind === "jsval";
|
|
454
|
+
export function uncheckedOverloadHandleCall(_lowerer, _expr) {
|
|
455
|
+
return false;
|
|
541
456
|
}
|
|
542
457
|
/** The JavaScript declaration fallback for unmappable binding types (see
|
|
543
458
|
* irTypeOf): `any` and every other inference residue is the checked-
|
|
@@ -593,29 +508,6 @@ export function ladderFenceExpr(lowerer, surface, node, hint) {
|
|
|
593
508
|
loc,
|
|
594
509
|
};
|
|
595
510
|
}
|
|
596
|
-
/** The checked-dynamic declaration fallback for unmappable binding types
|
|
597
|
-
* (see irTypeOf), two gates over one story:
|
|
598
|
-
*
|
|
599
|
-
* JAVASCRIPT files: `any` and every other inference residue is the
|
|
600
|
-
* checked-dynamic 'unknown' kind, and array types keep their array-ness
|
|
601
|
-
* with the fallback applied to the ELEMENT (any[]/never[] evolving arrays
|
|
602
|
-
* become unknown[], so length/push/index still lower).
|
|
603
|
-
*
|
|
604
|
-
* TYPESCRIPT files: genuine checker-`any` residue ONLY — a bare `any`
|
|
605
|
-
* binding (`flags & Any`), or a single-call-signature function type whose
|
|
606
|
-
* only unmappable pieces are `any` (`(value: any) => value is string` —
|
|
607
|
-
* the arrow the binding holds lowers those params to dyn, so the binding
|
|
608
|
-
* keeps its func-ness with the same per-piece fallback). The honest
|
|
609
|
-
* static subset of `any` is a binding whose VALUES are dyn-representable:
|
|
610
|
-
* the binding is 'unknown' storage with the boundary conversions
|
|
611
|
-
* coerceToExpected already applies (dynFrom into the slot, validated
|
|
612
|
-
* dynCheck out) and per-site SC2011 fences for the operations the checked-dynamic tree
|
|
613
|
-
* cannot carry JS-exactly (the island still lifts those). Every OTHER
|
|
614
|
-
* unmappable TS type keeps its own diagnostic — annotations exist there,
|
|
615
|
-
* and the fence names the real blocker. `--dynamic` builds never reach
|
|
616
|
-
* this fallback for `any` (mapType answers jsval first).
|
|
617
|
-
*
|
|
618
|
-
* Null for void (no value exists to represent). */
|
|
619
511
|
export function dynFallbackType(lowerer, node, t) {
|
|
620
512
|
if (t.flags & ts.TypeFlags.Void)
|
|
621
513
|
return null;
|
|
@@ -771,10 +663,7 @@ function jsFallbackFunctionType(lowerer, node, t) {
|
|
|
771
663
|
const optional = decl !== undefined &&
|
|
772
664
|
ts.isParameter(decl) &&
|
|
773
665
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
774
|
-
if (optional &&
|
|
775
|
-
mapped.kind !== "dyn" &&
|
|
776
|
-
mapped.kind !== "jsval" &&
|
|
777
|
-
!lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
666
|
+
if (optional && mapped.kind !== "dyn" && !lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
778
667
|
mapped = lowerer.withUndefinedArm(mapped);
|
|
779
668
|
}
|
|
780
669
|
return mapped;
|
|
@@ -953,7 +842,6 @@ export class Lowerer {
|
|
|
953
842
|
program;
|
|
954
843
|
entry;
|
|
955
844
|
moduleOrder;
|
|
956
|
-
dynamic;
|
|
957
845
|
frontendServices;
|
|
958
846
|
checker;
|
|
959
847
|
diags = [];
|
|
@@ -1219,6 +1107,10 @@ export class Lowerer {
|
|
|
1219
1107
|
* discriminant was captured. A case match narrows the captured value,
|
|
1220
1108
|
* not that mutable binding; preserve its tagged representation on reads. */
|
|
1221
1109
|
unstableSwitchBindings = new Set();
|
|
1110
|
+
/** Whether a checker narrowing of a mutable member or closure-assigned
|
|
1111
|
+
* binding still holds at its use (calls do not reset TypeScript's
|
|
1112
|
+
* narrowing). Stale ones read the declared storage or check it. */
|
|
1113
|
+
narrowing = new NarrowingStability(this);
|
|
1222
1114
|
/** All storage slots widened for runtime absence, including slots whose
|
|
1223
1115
|
* current control-flow branch has temporarily narrowed the value. */
|
|
1224
1116
|
runtimeOptionalStorageLocals = new Set();
|
|
@@ -1475,7 +1367,7 @@ export class Lowerer {
|
|
|
1475
1367
|
runtimeOptionalType(t) {
|
|
1476
1368
|
if (t.kind === "union")
|
|
1477
1369
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
1478
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
1370
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
1479
1371
|
return t;
|
|
1480
1372
|
return this.withUndefinedArm(t);
|
|
1481
1373
|
}
|
|
@@ -1731,43 +1623,21 @@ export class Lowerer {
|
|
|
1731
1623
|
* falls back through the shared node (collectGlobals registers both). */
|
|
1732
1624
|
globalsByDeclNode = new Map();
|
|
1733
1625
|
globalsList = [];
|
|
1734
|
-
/** npm-import init statements (--dynamic), keyed by file AND import
|
|
1735
|
-
* declaration: the island.import assignments/side-effect loads for that
|
|
1736
|
-
* statement. lowerFileInit splices them into the importing file's %init
|
|
1737
|
-
* header at the statement's position — Node evaluates each imported
|
|
1738
|
-
* module (island packages included) where the import appears, so an
|
|
1739
|
-
* `import "polyfill"` before an `import "./app.js"` runs the package
|
|
1740
|
-
* top-level BEFORE app's init, not after. */
|
|
1741
1626
|
npmInitActions = new Map();
|
|
1742
1627
|
/** Per-file %init PRELUDE statements for JSON imports: bakeable DATA
|
|
1743
1628
|
* assignments with no observable evaluation order of their own —
|
|
1744
1629
|
* prepended by lowerFileInit so the bindings are live before any
|
|
1745
1630
|
* top-level statement runs. */
|
|
1746
1631
|
jsonInitActions = new Map();
|
|
1747
|
-
/** The embedded npm runtime graph (collectNpmImports), attached to the
|
|
1748
|
-
* emitted module. Null without npm imports or without --dynamic. */
|
|
1749
|
-
npmEmbedded = null;
|
|
1750
|
-
npmBuiltins = null;
|
|
1751
|
-
npmLazyTraps = null;
|
|
1752
1632
|
/** Dynamic `import("literal")` resolutions, keyed
|
|
1753
1633
|
* `fileName\u0000specifier` (collectDynamicImports fills it during npm
|
|
1754
1634
|
* collection; lowerDynamicImportCall reads it per site). */
|
|
1755
1635
|
dynImports = new Map();
|
|
1756
|
-
/** createRequire-require resolutions of BARE npm specifiers, keyed
|
|
1757
|
-
* `fileName\u0000specifier` (collectCreateRequires fills it during npm
|
|
1758
|
-
* collection under --dynamic — the require-condition entry key plus its
|
|
1759
|
-
* embedded format; lowerCreateRequireCall reads it per site; "" marks a
|
|
1760
|
-
* failed resolution already reported at collection). */
|
|
1761
1636
|
createRequireImports = new Map();
|
|
1762
1637
|
/** Module → the name of its synthesized namespace-BUILDER function
|
|
1763
1638
|
* (lowerOwnModuleImport): every `import()` of the same program module
|
|
1764
1639
|
* shares one builder. */
|
|
1765
1640
|
dynNsBuilders = new Map();
|
|
1766
|
-
/** Parameters forced to the island-handle type (jsval) regardless of
|
|
1767
|
-
* their checker type: then-handler params whose settled value is an
|
|
1768
|
-
* engine handle (a dynamic import's namespace object) — paramShape's
|
|
1769
|
-
* early-out. */
|
|
1770
|
-
jsvalParamOverrides = new Set();
|
|
1771
1641
|
checkedCallbackParams = new Set();
|
|
1772
1642
|
/** Inline Promise.then parameters whose contextual type is a builtin
|
|
1773
1643
|
* module namespace anonymous object. The settled native token is the
|
|
@@ -1853,7 +1723,6 @@ export class Lowerer {
|
|
|
1853
1723
|
stats = {
|
|
1854
1724
|
statementsTotal: 0,
|
|
1855
1725
|
statementsFailed: 0,
|
|
1856
|
-
statementsIsland: 0,
|
|
1857
1726
|
functionsSkipped: 0,
|
|
1858
1727
|
};
|
|
1859
1728
|
/** Reachability edge sink: every resolution of
|
|
@@ -1987,19 +1856,16 @@ export class Lowerer {
|
|
|
1987
1856
|
return;
|
|
1988
1857
|
let s = this.statsByFile.get(file);
|
|
1989
1858
|
if (!s)
|
|
1990
|
-
this.statsByFile.set(file, (s = { total: 0, failed: 0
|
|
1859
|
+
this.statsByFile.set(file, (s = { total: 0, failed: 0 }));
|
|
1991
1860
|
if (kind === "total")
|
|
1992
1861
|
s.total += 1;
|
|
1993
1862
|
else if (kind === "failed")
|
|
1994
1863
|
s.failed += 1;
|
|
1995
|
-
else
|
|
1996
|
-
s.island += 1;
|
|
1997
1864
|
}
|
|
1998
|
-
constructor(program, entry, moduleOrder,
|
|
1865
|
+
constructor(program, entry, moduleOrder, mode = {}) {
|
|
1999
1866
|
this.program = program;
|
|
2000
1867
|
this.entry = entry;
|
|
2001
1868
|
this.moduleOrder = moduleOrder;
|
|
2002
|
-
this.dynamic = dynamic;
|
|
2003
1869
|
this.frontendServices = mode.frontendServices;
|
|
2004
1870
|
this.reachable = mode.reachable ?? null;
|
|
2005
1871
|
this.remainder = mode.remainder ?? false;
|
|
@@ -2082,7 +1948,6 @@ export class Lowerer {
|
|
|
2082
1948
|
isStdlibFile: this.isStdlibFile,
|
|
2083
1949
|
isNpmFile: this.isNpmFile,
|
|
2084
1950
|
isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
|
|
2085
|
-
dynamic: this.dynamic,
|
|
2086
1951
|
typeMemo: this.typeMemo,
|
|
2087
1952
|
canMemoizeType: () => this.typeParamBindings === null &&
|
|
2088
1953
|
this.typeParamTsBindings === null &&
|
|
@@ -3271,7 +3136,6 @@ export class Lowerer {
|
|
|
3271
3136
|
if (!element ||
|
|
3272
3137
|
element.kind === "void" ||
|
|
3273
3138
|
element.kind === "dyn" ||
|
|
3274
|
-
element.kind === "jsval" ||
|
|
3275
3139
|
element.kind === "generator")
|
|
3276
3140
|
return null;
|
|
3277
3141
|
return e;
|
|
@@ -3305,12 +3169,12 @@ export class Lowerer {
|
|
|
3305
3169
|
return false;
|
|
3306
3170
|
const object = init.arguments[0];
|
|
3307
3171
|
const objectType = object ? this.mapTypeOf(this.typeOf(object)) : null;
|
|
3308
|
-
return objectType?.kind === "dyn"
|
|
3172
|
+
return objectType?.kind === "dyn";
|
|
3309
3173
|
};
|
|
3310
3174
|
const addUndefined = (t) => {
|
|
3311
3175
|
if (t.kind === "union")
|
|
3312
3176
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
3313
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
3177
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
3314
3178
|
return t;
|
|
3315
3179
|
return this.withUndefinedArm(t);
|
|
3316
3180
|
};
|
|
@@ -3552,10 +3416,7 @@ export class Lowerer {
|
|
|
3552
3416
|
// checker. The array's element ABI describes every value a
|
|
3553
3417
|
// position may hold after that call, so bind from that type.
|
|
3554
3418
|
const mapped = sourceType.elem;
|
|
3555
|
-
if (mapped &&
|
|
3556
|
-
mapped.kind !== "void" &&
|
|
3557
|
-
mapped.kind !== "dyn" &&
|
|
3558
|
-
mapped.kind !== "jsval") {
|
|
3419
|
+
if (mapped && mapped.kind !== "void" && mapped.kind !== "dyn") {
|
|
3559
3420
|
const widened = mapped.kind === "union"
|
|
3560
3421
|
? this.withUndefinedArmOf(mapped)
|
|
3561
3422
|
: this.withUndefinedArm(mapped);
|
|
@@ -3922,7 +3783,7 @@ export class Lowerer {
|
|
|
3922
3783
|
if (mapped?.kind === "promise")
|
|
3923
3784
|
mapped = mapped.inner;
|
|
3924
3785
|
const anyElements = mapped?.kind === "array"
|
|
3925
|
-
? mapped.elem.kind === "dyn"
|
|
3786
|
+
? mapped.elem.kind === "dyn"
|
|
3926
3787
|
: mapped === null &&
|
|
3927
3788
|
this.checker.isArrayType(checkerType) &&
|
|
3928
3789
|
!this.checker.isTupleType(checkerType) &&
|
|
@@ -4102,7 +3963,6 @@ export class Lowerer {
|
|
|
4102
3963
|
mapped.kind === "record" ||
|
|
4103
3964
|
mapped.kind === "object" ||
|
|
4104
3965
|
mapped.kind === "dyn" ||
|
|
4105
|
-
mapped.kind === "jsval" ||
|
|
4106
3966
|
mapped.kind === "union");
|
|
4107
3967
|
},
|
|
4108
3968
|
restKeys: (call) => {
|
|
@@ -4500,10 +4360,7 @@ export class Lowerer {
|
|
|
4500
4360
|
}
|
|
4501
4361
|
}
|
|
4502
4362
|
}
|
|
4503
|
-
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" ||
|
|
4504
|
-
shape.mode === "dynRest" ||
|
|
4505
|
-
shape.mode === "islandRest" ||
|
|
4506
|
-
shape.mode === "arguments");
|
|
4363
|
+
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" || shape.mode === "dynRest" || shape.mode === "arguments");
|
|
4507
4364
|
node.arguments.forEach((arg, argumentIndex) => {
|
|
4508
4365
|
const i = restAt >= 0 && argumentIndex >= restAt ? restAt : argumentIndex;
|
|
4509
4366
|
const shape = sig.params[i];
|
|
@@ -4941,6 +4798,7 @@ export class Lowerer {
|
|
|
4941
4798
|
}
|
|
4942
4799
|
run() {
|
|
4943
4800
|
const parts = this.splitFiles();
|
|
4801
|
+
this.narrowing.setFiles(parts.map((fp) => fp.sf));
|
|
4944
4802
|
// The coverage remainder deliberately visits every body that reachable
|
|
4945
4803
|
// emit skipped. Those files are already phase-managed, so an ordinary
|
|
4946
4804
|
// checker miss would stay a one-node IPC query instead of falling back
|
|
@@ -4998,8 +4856,7 @@ export class Lowerer {
|
|
|
4998
4856
|
}
|
|
4999
4857
|
}
|
|
5000
4858
|
// Each file's top-level statements form its run-once init function.
|
|
5001
|
-
// %main calls only the
|
|
5002
|
-
// runs its dependencies (npm island loads at their import positions),
|
|
4859
|
+
// %main calls only the entry's init. Hoisted imports call their inits;
|
|
5003
4860
|
// inline require statements call theirs mid-body, and the guards make
|
|
5004
4861
|
// revisits cache hits — Node's evaluation order over the WHOLE graph
|
|
5005
4862
|
// falls out of the nesting. The coverage remainder skips them — they
|
|
@@ -5071,7 +4928,7 @@ export class Lowerer {
|
|
|
5071
4928
|
!this.remainder &&
|
|
5072
4929
|
classDispatch.process(this, [...functions, ...this.liftedFns, ...this.implicitFns]);
|
|
5073
4930
|
}
|
|
5074
|
-
classDispatch.finalize();
|
|
4931
|
+
classDispatch.finalize(this);
|
|
5075
4932
|
}
|
|
5076
4933
|
// Lambdas lifted while lowering any of the above (plus synthetic
|
|
5077
4934
|
// array-HOF loop functions, which ride the same list), and the
|
|
@@ -5095,8 +4952,6 @@ export class Lowerer {
|
|
|
5095
4952
|
stats: this.stats,
|
|
5096
4953
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5097
4954
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5098
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5099
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5100
4955
|
};
|
|
5101
4956
|
}
|
|
5102
4957
|
return this.finishModule(functions);
|
|
@@ -5196,14 +5051,13 @@ export class Lowerer {
|
|
|
5196
5051
|
const module = this.diags.length > 0
|
|
5197
5052
|
? null
|
|
5198
5053
|
: {
|
|
5199
|
-
irVersion:
|
|
5054
|
+
irVersion: 16,
|
|
5200
5055
|
sourceFile: this.entry.fileName,
|
|
5201
5056
|
functions,
|
|
5202
5057
|
classes: artifacts.classes,
|
|
5203
5058
|
records: artifacts.records,
|
|
5204
5059
|
unions: artifacts.unions,
|
|
5205
5060
|
globals: this.globalsList,
|
|
5206
|
-
...(this.npmEmbedded ? { embedded: this.npmEmbedded } : {}),
|
|
5207
5061
|
entry: ENTRY_NAME,
|
|
5208
5062
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
5209
5063
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
@@ -5220,8 +5074,6 @@ export class Lowerer {
|
|
|
5220
5074
|
stats: this.stats,
|
|
5221
5075
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5222
5076
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5223
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5224
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5225
5077
|
};
|
|
5226
5078
|
}
|
|
5227
5079
|
/** True when `t` (recursively) names a class instance type with no
|
|
@@ -5320,6 +5172,7 @@ export class Lowerer {
|
|
|
5320
5172
|
emitReachable(extraRoots) {
|
|
5321
5173
|
this.deferredModuleInitializers = new DeferredModuleInitializers();
|
|
5322
5174
|
const parts = this.splitFiles();
|
|
5175
|
+
this.narrowing.setFiles(parts.map((fp) => fp.sf));
|
|
5323
5176
|
// Direct lowering callers do not necessarily run program preflight.
|
|
5324
5177
|
// Establish the same managed header/top-level batch here before
|
|
5325
5178
|
// collection, while the production path simply finds warm memos.
|
|
@@ -5682,7 +5535,7 @@ export class Lowerer {
|
|
|
5682
5535
|
this.restoreGenericInstanceOrder(instLowered);
|
|
5683
5536
|
this.restoreGenericClassInstanceOrder(clsInstLowered);
|
|
5684
5537
|
}
|
|
5685
|
-
classDispatch.finalize();
|
|
5538
|
+
classDispatch.finalize(this);
|
|
5686
5539
|
const orderedUnits = [...loweredUnits]
|
|
5687
5540
|
.sort(([left], [right]) => units.get(left).order - units.get(right).order)
|
|
5688
5541
|
.map(([, fn]) => fn);
|
|
@@ -5862,22 +5715,13 @@ export class Lowerer {
|
|
|
5862
5715
|
? `values from the '${specifier}' external host module (types supplied by --external-types, but no runtime implementation or scriptc lowering was provided)`
|
|
5863
5716
|
: `the '${specifier}' external host module (types supplied by --external-types, but no runtime implementation or scriptc lowering was provided)`, `the declaration mapping is analysis-only: coverage continues through project code, while executing ${valueUse ? "this value" : "this module"} requires an embedder integration with explicit runtime semantics`);
|
|
5864
5717
|
}
|
|
5865
|
-
/** The dynamic-family fence for an OPERATION on an `any`-origin
|
|
5866
|
-
* checked-dynamic value that only the engine can execute (operators,
|
|
5867
|
-
* iteration, computed member names, ...). Carries SC2011 — the same
|
|
5868
|
-
* code as the `any` type fence — so the coverage report groups it with
|
|
5869
|
-
* the dynamic-capable family and the two-tier retry knows the island
|
|
5870
|
-
* lifts the site. Use exactly when the blocking operand IS dyn-typed
|
|
5871
|
-
* and its checker type is `any`-flavored; genuine `unknown` keeps the
|
|
5872
|
-
* SC1100-family fences (tsc constrains what unknown can do, so those
|
|
5873
|
-
* sites are checker-error territory, not engine territory). */
|
|
5874
5718
|
anyOpFence(feature, node) {
|
|
5875
|
-
this.pushDiag(
|
|
5719
|
+
this.pushDiag(unsupportedAnyOperationDiag(feature, locOf(node)));
|
|
5876
5720
|
throw new PoisonError();
|
|
5877
5721
|
}
|
|
5878
5722
|
/** True when this expression's CHECKER type is `any`-flavored — the
|
|
5879
5723
|
* gate anyOpFence's call sites use to tell `any`-origin dyn values
|
|
5880
|
-
*
|
|
5724
|
+
* with an unsupported operation from genuine `unknown` ones. */
|
|
5881
5725
|
anyOrigin(node) {
|
|
5882
5726
|
return (this.typeOf(node).flags & ts.TypeFlags.Any) !== 0;
|
|
5883
5727
|
}
|
|
@@ -5899,11 +5743,10 @@ export class Lowerer {
|
|
|
5899
5743
|
// SC2012 rather than the generic supported-types recitation. Native
|
|
5900
5744
|
// fetch values map earlier to checked-dynamic handles and do not reach
|
|
5901
5745
|
// here; constructor objects such as Headers still can.
|
|
5902
|
-
if (
|
|
5903
|
-
typeSym &&
|
|
5904
|
-
ISLAND_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5746
|
+
if (typeSym &&
|
|
5747
|
+
FETCH_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5905
5748
|
this.isStdlibSymbol(typeSym)) {
|
|
5906
|
-
this.pushDiag(
|
|
5749
|
+
this.pushDiag(unsupportedNativeApiDiag(`a value of type '${typeSym.name}'`, locOf(node)));
|
|
5907
5750
|
throw new PoisonError();
|
|
5908
5751
|
}
|
|
5909
5752
|
// ENUM OBJECTS (`typeof e` — a numeric enum's type carries the
|
|
@@ -5942,30 +5785,14 @@ export class Lowerer {
|
|
|
5942
5785
|
this.pushDiag(noLoweringDiag(this.checker.typeToString(type), locOf(node)));
|
|
5943
5786
|
throw new PoisonError();
|
|
5944
5787
|
}
|
|
5945
|
-
// The MEASURED island probe, same mechanism as the general dynamic
|
|
5946
|
-
// reroute below: an index-signature shape the dynamic mapping
|
|
5947
|
-
// accepts (an `any`-valued signature absorbing into an island
|
|
5948
|
-
// object, jsval-entangled members) reports the retry-eligible
|
|
5949
|
-
// SC2011 choice instead of the static recitation.
|
|
5950
|
-
if (!this.dynamic &&
|
|
5951
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
5952
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
5953
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5954
|
-
throw new PoisonError();
|
|
5955
|
-
}
|
|
5956
5788
|
this.pushDiag(indexSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5957
5789
|
throw new PoisonError();
|
|
5958
5790
|
}
|
|
5959
|
-
//
|
|
5960
|
-
|
|
5961
|
-
// report's one-line-per-package attribution). Under --dynamic these
|
|
5962
|
-
// types map to jsval, so reaching here means the type is genuinely
|
|
5963
|
-
// unrepresentable (a jsval union arm, a jsval array element) — the
|
|
5964
|
-
// generic type message tells that story better.
|
|
5965
|
-
if (!this.dynamic) {
|
|
5791
|
+
// Attribute an unsupported package type to its package.
|
|
5792
|
+
{
|
|
5966
5793
|
const pkg = this.npmPackageOf(widened);
|
|
5967
5794
|
if (pkg) {
|
|
5968
|
-
this.pushDiag(
|
|
5795
|
+
this.pushDiag(unsupportedPackageValueDiag(pkg, locOf(node)));
|
|
5969
5796
|
throw new PoisonError();
|
|
5970
5797
|
}
|
|
5971
5798
|
}
|
|
@@ -5982,24 +5809,6 @@ export class Lowerer {
|
|
|
5982
5809
|
throw new PoisonError();
|
|
5983
5810
|
}
|
|
5984
5811
|
}
|
|
5985
|
-
// A type the DYNAMIC mapping accepts (`any[]`, records/functions with
|
|
5986
|
-
// `any`-typed members, .d.ts-declared shapes whose values are island
|
|
5987
|
-
// handles): the honest per-site story is the dynamic-family choice, not
|
|
5988
|
-
// the supported-types recitation — proved by re-running mapType with
|
|
5989
|
-
// `dynamic: true`, never guessed from the type text. Probing is safe
|
|
5990
|
-
// here: a diagnostic means this build already failed, so anything the
|
|
5991
|
-
// probe interns or registers on the way is never emitted. Checked LAST
|
|
5992
|
-
// so every more specific story above (island ambients, index
|
|
5993
|
-
// signatures, per-package attribution, generic signatures) keeps its
|
|
5994
|
-
// own fence class. Bare `any` is excepted: unsupportedTypeDiag's own
|
|
5995
|
-
// SC2011 arm tells that story with the stronger stay-static remedy
|
|
5996
|
-
// ('unknown' + a checked cast).
|
|
5997
|
-
if (!this.dynamic &&
|
|
5998
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
5999
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
6000
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
6001
|
-
throw new PoisonError();
|
|
6002
|
-
}
|
|
6003
5812
|
// STANDARD-LIBRARY nominal provenance, decided once: interface/class
|
|
6004
5813
|
// declarations in the lib's own files (Date, ArrayBuffer, WeakMap, the
|
|
6005
5814
|
// iterator/constructor interfaces). Such types report the SC2020 story
|
|
@@ -6106,12 +5915,6 @@ export class Lowerer {
|
|
|
6106
5915
|
fenceFetchObjectAssignment(target, source) {
|
|
6107
5916
|
return fenceFetchObjectAssignment(this, target, source);
|
|
6108
5917
|
}
|
|
6109
|
-
lowerDynamicHeadersIteratorCall(call, access) {
|
|
6110
|
-
return lowerDynamicHeadersIteratorCall(this, call, access);
|
|
6111
|
-
}
|
|
6112
|
-
lowerDynamicHeadersSpread(node, type) {
|
|
6113
|
-
return lowerDynamicHeadersSpread(this, node, type);
|
|
6114
|
-
}
|
|
6115
5918
|
fenceStaticReadableStreamMember(access, use) {
|
|
6116
5919
|
return fenceStaticReadableStreamMember(this, access, use);
|
|
6117
5920
|
}
|
|
@@ -6145,6 +5948,12 @@ export class Lowerer {
|
|
|
6145
5948
|
const narrowed = this.chainNarrowedType.get(node);
|
|
6146
5949
|
if (narrowed)
|
|
6147
5950
|
return narrowed;
|
|
5951
|
+
// A stale narrowing of a mutable member or closure-assigned binding in
|
|
5952
|
+
// an absence/type test (or a slot accepting the declared type) reads
|
|
5953
|
+
// as declared, so the test inspects the stored value.
|
|
5954
|
+
const widened = this.narrowing.widenedType(node);
|
|
5955
|
+
if (widened)
|
|
5956
|
+
return widened;
|
|
6148
5957
|
const t = this.checker.getTypeAtLocation(node);
|
|
6149
5958
|
// ALIASED-TYPEOF narrowing: inside a branch a `type === 'string'`
|
|
6150
5959
|
// test proves (type = typeof val, both never reassigned), references
|
|
@@ -6297,23 +6106,6 @@ export class Lowerer {
|
|
|
6297
6106
|
bareUndefinedArmedUnion(t) {
|
|
6298
6107
|
return isUndefinedArmedUnion(t, (id) => this.unions.get(id));
|
|
6299
6108
|
}
|
|
6300
|
-
/** canCrossIslandBoundary with this Lowerer's registries — THE test
|
|
6301
|
-
* behind every marshal/exit decision (the implicit coercions, jsvalIn,
|
|
6302
|
-
* the checked island-exit cast). Rejections that follow a false answer
|
|
6303
|
-
* speak through boundaryIntoIslandMsg / boundaryOutOfIslandMsg. */
|
|
6304
|
-
boundarySafe(t) {
|
|
6305
|
-
return canCrossIslandBoundary(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6306
|
-
}
|
|
6307
|
-
/** canExitIslandToType with this Lowerer's registries — the EXIT
|
|
6308
|
-
* direction's slightly wider test (bare undefined-armed unions of
|
|
6309
|
-
* JSON-safe data arms exit; the engine's undefined takes the undefined
|
|
6310
|
-
* arm before the JSON round trip). */
|
|
6311
|
-
boundaryExitSafe(t) {
|
|
6312
|
-
return canExitIslandToType(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6313
|
-
}
|
|
6314
|
-
isIslandExpr(node) {
|
|
6315
|
-
return isIslandExpr(this, node);
|
|
6316
|
-
}
|
|
6317
6109
|
/** True when this node's CHECKER type is proven `any[]`/`unknown[]`,
|
|
6318
6110
|
* directly or through the intersection tsc builds for a readonly tuple
|
|
6319
6111
|
* union (`(Model | readonly [Model, Command]) & any[]`; TS7 distributes
|
|
@@ -6445,14 +6237,6 @@ export class Lowerer {
|
|
|
6445
6237
|
}
|
|
6446
6238
|
this.unsupported("SC1101", node);
|
|
6447
6239
|
}
|
|
6448
|
-
// jsval mismatches surviving coerceToExpected involve a type with no
|
|
6449
|
-
// island representation (in) or no validated exit (out).
|
|
6450
|
-
if (actual.kind === "jsval") {
|
|
6451
|
-
this.unsupported("SC1090", node, boundaryOutOfIslandMsg(this.fmt(expected)));
|
|
6452
|
-
}
|
|
6453
|
-
if (expected.kind === "jsval") {
|
|
6454
|
-
this.unsupported("SC1090", node, boundaryIntoIslandMsg(this.fmt(actual)));
|
|
6455
|
-
}
|
|
6456
6240
|
// Class-value mismatches: the pointed stories — a widening whose
|
|
6457
6241
|
// constructor ABIs differ (construction through the slot would
|
|
6458
6242
|
// dispatch a mismatched signature), or a structural flow between
|
|
@@ -6601,98 +6385,12 @@ export class Lowerer {
|
|
|
6601
6385
|
if (adapted)
|
|
6602
6386
|
return adapted;
|
|
6603
6387
|
}
|
|
6604
|
-
// Island boundary, both directions. IN: any static value flowing into
|
|
6605
6388
|
// an any-typed slot marshals implicitly (tsc allows the assignment;
|
|
6606
6389
|
// the marshal is where its semantics live). OUT: an 'any' value
|
|
6607
6390
|
// flowing into a typed slot compiles to a VALIDATED exit — like every
|
|
6608
6391
|
// dyn→static edge, trust-but-verify: a lying `any` throws a catchable
|
|
6609
6392
|
// TypeError instead of corrupting memory (SEMANTICS.md). Unmarshalable
|
|
6610
6393
|
// and unextractable types fall through to requireExactShape's fences.
|
|
6611
|
-
if (expected.kind === "jsval" && expr.type.kind !== "jsval") {
|
|
6612
|
-
// Bare unit literals: the engine's own undefined/null (units have no
|
|
6613
|
-
// other producers, so dropping the operand loses nothing).
|
|
6614
|
-
if (isUnitType(expr.type)) {
|
|
6615
|
-
return {
|
|
6616
|
-
kind: "jsOp",
|
|
6617
|
-
op: expr.type.kind === "undefinedT" ? "undefLit" : "nullLit",
|
|
6618
|
-
args: [],
|
|
6619
|
-
type: JSVAL,
|
|
6620
|
-
loc: expr.loc,
|
|
6621
|
-
};
|
|
6622
|
-
}
|
|
6623
|
-
// A CHECKED-DYNAMIC (dyn/'unknown') value entering the island (the
|
|
6624
|
-
// `isJson ? JSON.parse(text) : islandParser(text)` config ternary):
|
|
6625
|
-
// the dyn tree deep-copies into engine values — data kinds only; a
|
|
6626
|
-
// dyn carrying a boxed function/handle/promise throws the catchable
|
|
6627
|
-
// TypeError at runtime (trust-but-verify, like every boundary).
|
|
6628
|
-
if (expr.type.kind === "dyn") {
|
|
6629
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6630
|
-
}
|
|
6631
|
-
if (this.boundarySafe(expr.type)) {
|
|
6632
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6633
|
-
}
|
|
6634
|
-
// Closures cross as host functions when their signature marshals —
|
|
6635
|
-
// the same shapes jsvalIn admits at call arguments (`const f: any =
|
|
6636
|
-
// (x: number) => x * 3` is the declaration-slot spelling of the
|
|
6637
|
-
// package-callback pattern).
|
|
6638
|
-
if (expr.type.kind === "func" &&
|
|
6639
|
-
canMarshalTypedFuncIntoIsland(expr.type, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
|
|
6640
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6641
|
-
}
|
|
6642
|
-
// jsval-BEARING composites (a record holding `any` fields, an array
|
|
6643
|
-
// of such records) have no JSON marshal but an honest per-field
|
|
6644
|
-
// island construction — see jsvalLiftExpr.
|
|
6645
|
-
if (this.jsvalLiftable(expr.type)) {
|
|
6646
|
-
return this.jsvalLiftExpr(expr, expr.loc);
|
|
6647
|
-
}
|
|
6648
|
-
// A RegExp flowing into an 'any' slot: the fresh-engine-RegExp
|
|
6649
|
-
// rebuild (see jsvalIn's regex rule); computed regex values fall
|
|
6650
|
-
// through to requireExactShape's fence.
|
|
6651
|
-
if (expr.type.kind === "regex") {
|
|
6652
|
-
const re = islandRegexpOf(expr);
|
|
6653
|
-
if (re)
|
|
6654
|
-
return re;
|
|
6655
|
-
}
|
|
6656
|
-
return expr;
|
|
6657
|
-
}
|
|
6658
|
-
if (expr.type.kind === "jsval" && expected.kind !== "jsval") {
|
|
6659
|
-
// The jsval→dyn crossing (the world unification's engine-handle
|
|
6660
|
-
// kind): an 'any'-typed engine value flowing into an 'unknown'/
|
|
6661
|
-
// 'object'/JS-residue slot wraps BY REFERENCE as the checked-dynamic tree's island
|
|
6662
|
-
// kind — engine scalars normalize to native dyn kinds at wrap time,
|
|
6663
|
-
// typeof/truthiness/String()/=== route to the engine, un-armed dyn
|
|
6664
|
-
// walks fence loudly, and the value unwraps back identity-preserved
|
|
6665
|
-
// (scr_jsval_from_dyn). Monotone under evolution/widening: a value
|
|
6666
|
-
// wraps once at its first dyn edge and stays valid through every
|
|
6667
|
-
// subsequent dyn slot; narrowing never changes representation.
|
|
6668
|
-
// This wrap RETIRES the silent-wrong-answer fence-closure box for
|
|
6669
|
-
// jsval members of dyn object literals (lowerDynObjectLiteral's
|
|
6670
|
-
// coercion lands here first).
|
|
6671
|
-
if (expected.kind === "dyn") {
|
|
6672
|
-
return { kind: "dynFromJsval", value: expr, type: DYN, loc: expr.loc };
|
|
6673
|
-
}
|
|
6674
|
-
// An island value flowing into a PROMISE-typed slot (the inferred
|
|
6675
|
-
// `loadPlugins` return — `Promise.all(...)` lowered engine-side
|
|
6676
|
-
// against a Promise<any[]> inference): the island→static promise
|
|
6677
|
-
// bridge — the engine promise settles a fresh static promise (void
|
|
6678
|
-
// fulfillments drop, `any[]`-declared fulfillments exit
|
|
6679
|
-
// Array.isArray-gated by reference at the settle, 'any' parks as an
|
|
6680
|
-
// island handle). Only inner shapes the bridge can deliver take the
|
|
6681
|
-
// arm; the rest keep the exit fence with the type named.
|
|
6682
|
-
if (expected.kind === "promise" &&
|
|
6683
|
-
(expected.inner.kind === "void" ||
|
|
6684
|
-
expected.inner.kind === "jsval" ||
|
|
6685
|
-
(expected.inner.kind === "array" && expected.inner.elem.kind === "jsval"))) {
|
|
6686
|
-
return { kind: "jsBridgePromise", value: expr, type: expected, loc: expr.loc };
|
|
6687
|
-
}
|
|
6688
|
-
// The exit set: everything round-trippable, plus bare undefined-armed
|
|
6689
|
-
// unions of JSON-safe data arms (the engine's undefined takes the
|
|
6690
|
-
// undefined arm before the JSON detour) — canExitIslandToType.
|
|
6691
|
-
if (this.boundaryExitSafe(expected)) {
|
|
6692
|
-
return { kind: "jsExit", value: expr, type: expected, loc: expr.loc };
|
|
6693
|
-
}
|
|
6694
|
-
return expr;
|
|
6695
|
-
}
|
|
6696
6394
|
// A TYPED value flowing into an 'unknown' slot (`const u: unknown = 5`,
|
|
6697
6395
|
// an unknown-typed param/return, a dyn-valued index slot): the
|
|
6698
6396
|
// static→dyn conversion — dynFrom, a DEEP COPY (the jsMarshal aliasing
|
|
@@ -6775,8 +6473,7 @@ export class Lowerer {
|
|
|
6775
6473
|
// A dyn ('unknown') ACTUAL flowing into a typed slot the checker
|
|
6776
6474
|
// approved (an assertion function's narrowing, the error-any world's
|
|
6777
6475
|
// forgiven chains): the VALIDATED extraction — dynCheck, the
|
|
6778
|
-
// checked-cast machinery, applied automatically.
|
|
6779
|
-
// exactly the island exit's stance: a value that doesn't match the
|
|
6476
|
+
// checked-cast machinery, applied automatically. A value outside the
|
|
6780
6477
|
// slot's type throws a catchable TypeError instead of misreading the
|
|
6781
6478
|
// payload. Only dynCheck's own domain (JSON-representable types,
|
|
6782
6479
|
// undefined-armed unions of those, bytes<u8>, the %Error root)
|
|
@@ -7067,17 +6764,15 @@ export class Lowerer {
|
|
|
7067
6764
|
return this.applyWidthLift(lift, expr, expected, expr.loc);
|
|
7068
6765
|
// Arms OUTSIDE widthLiftPlan's domain keep the historic per-arm
|
|
7069
6766
|
// widthCoerce probe (first match): index-signature record arms (the
|
|
7070
|
-
// overflow CAPTURE helper owns their reshapes)
|
|
7071
|
-
//
|
|
7072
|
-
//
|
|
7073
|
-
// never undone by a first-match fallback.
|
|
6767
|
+
// overflow CAPTURE helper owns their reshapes). Exclude shapes
|
|
6768
|
+
// already owned by the plan so first-match fallback cannot undo
|
|
6769
|
+
// its ambiguity rule for record/array lifts.
|
|
7074
6770
|
{
|
|
7075
6771
|
const def = this.unions.get(expected.unionId);
|
|
7076
6772
|
if (def) {
|
|
7077
6773
|
for (let i = 0; i < def.arms.length; i++) {
|
|
7078
6774
|
const arm = def.arms[i];
|
|
7079
|
-
const boundaryArm =
|
|
7080
|
-
(arm.kind === "array" && arm.elem.kind === "jsval");
|
|
6775
|
+
const boundaryArm = arm.kind === "record" && this.shapes.get(arm.shapeId)?.indexValue !== undefined;
|
|
7081
6776
|
if (!boundaryArm)
|
|
7082
6777
|
continue;
|
|
7083
6778
|
const w = this.widthCoerce(expr, arm);
|
|
@@ -7212,27 +6907,6 @@ export class Lowerer {
|
|
|
7212
6907
|
deferredReadHelper(fromId, target, loc) {
|
|
7213
6908
|
return deferredReadHelper(this, fromId, target, loc);
|
|
7214
6909
|
}
|
|
7215
|
-
jsvalLiftable(t, visiting = new Set()) {
|
|
7216
|
-
return jsvalLiftable(this, t, visiting);
|
|
7217
|
-
}
|
|
7218
|
-
jsvalLiftExpr(e, loc) {
|
|
7219
|
-
return jsvalLiftExpr(this, e, loc);
|
|
7220
|
-
}
|
|
7221
|
-
unionToJsvalHelper(unionId, loc) {
|
|
7222
|
-
return unionToJsvalHelper(this, unionId, loc);
|
|
7223
|
-
}
|
|
7224
|
-
recordToJsvalHelper(shapeId, loc) {
|
|
7225
|
-
return recordToJsvalHelper(this, shapeId, loc);
|
|
7226
|
-
}
|
|
7227
|
-
arrayToJsvalHelper(elem, loc) {
|
|
7228
|
-
return arrayToJsvalHelper(this, elem, loc);
|
|
7229
|
-
}
|
|
7230
|
-
arrayToJsvalArrayHelper(fromElem, loc) {
|
|
7231
|
-
return arrayToJsvalArrayHelper(this, fromElem, loc);
|
|
7232
|
-
}
|
|
7233
|
-
jsvalIn(e, node) {
|
|
7234
|
-
return jsvalIn(this, e, node);
|
|
7235
|
-
}
|
|
7236
6910
|
/** THE coercion path for values flowing into a typed slot: union arms
|
|
7237
6911
|
* wrap implicitly (coerceToExpected), then the exact-type fence runs
|
|
7238
6912
|
* (SC2002 for record shapes, SC2003 for unions). Every slot-directed
|
|
@@ -7294,17 +6968,7 @@ export class Lowerer {
|
|
|
7294
6968
|
}
|
|
7295
6969
|
}
|
|
7296
6970
|
}
|
|
7297
|
-
let e = this.
|
|
7298
|
-
expr.type.kind === "dyn" &&
|
|
7299
|
-
expected.kind === "array" &&
|
|
7300
|
-
expected.elem.kind === "jsval"
|
|
7301
|
-
? {
|
|
7302
|
-
kind: "jsExit",
|
|
7303
|
-
value: this.jsvalIn(expr, node),
|
|
7304
|
-
type: expected,
|
|
7305
|
-
loc: expr.loc,
|
|
7306
|
-
}
|
|
7307
|
-
: this.coerceToExpected(expr, expected);
|
|
6971
|
+
let e = this.coerceToExpected(expr, expected);
|
|
7308
6972
|
// Keep storage intact when ordinary widening already accepts it. Only
|
|
7309
6973
|
// a destination needing a more specific class layout uses the site's
|
|
7310
6974
|
// refinement and checked extraction.
|
|
@@ -7328,24 +6992,6 @@ export class Lowerer {
|
|
|
7328
6992
|
e.value.type.kind === "array") {
|
|
7329
6993
|
e = { ...e, liveRef: true };
|
|
7330
6994
|
}
|
|
7331
|
-
// An 'any' value PROVABLY null/undefined (the unit literal itself, or
|
|
7332
|
-
// a read of a binding nothing ever assigns a non-unit value) flowing
|
|
7333
|
-
// implicitly into a primitive slot: the validated exit refuses units
|
|
7334
|
-
// unconditionally, so every run would throw the boundary TypeError
|
|
7335
|
-
// where Node proceeds silently. A failure certain at compile time is
|
|
7336
|
-
// a fence, not a runtime surprise. Explicit casts keep their runtime
|
|
7337
|
-
// checked-cast semantics (the cast lowering builds its own jsExit
|
|
7338
|
-
// before this runs, so `e !== expr` skips them), and union/composite
|
|
7339
|
-
// targets keep the runtime exit (an undefined-armed union ACCEPTS the
|
|
7340
|
-
// engine's undefined; composite validation is dynCheck's business).
|
|
7341
|
-
if (e !== expr &&
|
|
7342
|
-
e.kind === "jsExit" &&
|
|
7343
|
-
(e.type.kind === "f64" || e.type.kind === "string" || e.type.kind === "bool")) {
|
|
7344
|
-
const unit = this.provenUnitAnyOf(node, e.value);
|
|
7345
|
-
if (unit !== null) {
|
|
7346
|
-
this.unsupported("SC1090", node, `an 'any' value that is always ${unit} flowing into a '${this.fmt(expected)}' slot (nothing in the program gives this value another shape, and the island boundary's validated exit refuses ${unit} — every run would throw a TypeError where Node proceeds silently)`, `give the binding a value other than ${unit} before this use, or keep the slot's type 'any'`);
|
|
7347
|
-
}
|
|
7348
|
-
}
|
|
7349
6995
|
// A closure that just BOXED into dyn takes its best-effort JS name
|
|
7350
6996
|
// from the source node (identifier reads, named function expressions,
|
|
7351
6997
|
// NamedEvaluation through a variable initializer) — inspect prints
|
|
@@ -7381,34 +7027,12 @@ export class Lowerer {
|
|
|
7381
7027
|
}
|
|
7382
7028
|
}
|
|
7383
7029
|
}
|
|
7384
|
-
// A JS FUNC value outside the island marshal set flowing into a
|
|
7385
|
-
// jsval slot (`withPlugins(getSupportInfoWithoutPlugins, 0)` — a
|
|
7386
|
-
// wrapper built at module init around a function the run may never
|
|
7387
|
-
// call): the crossing defers to a call-time fence closure instead of
|
|
7388
|
-
// stopping the statement — jsvalIn's deferral, the implicit-coercion
|
|
7389
|
-
// spelling.
|
|
7390
|
-
if (expected.kind === "jsval" && e.type.kind === "func" && !typeEquals(e.type, expected)) {
|
|
7391
|
-
const diagsBefore = this.diags.length;
|
|
7392
|
-
try {
|
|
7393
|
-
this.requireExactShape(node, e.type, expected);
|
|
7394
|
-
}
|
|
7395
|
-
catch (err) {
|
|
7396
|
-
if (!(err instanceof PoisonError))
|
|
7397
|
-
throw err;
|
|
7398
|
-
const fence = islandFuncValueFence(this, diagsBefore, node);
|
|
7399
|
-
if (fence)
|
|
7400
|
-
return fence;
|
|
7401
|
-
throw err;
|
|
7402
|
-
}
|
|
7403
|
-
return e;
|
|
7404
|
-
}
|
|
7405
7030
|
this.requireExactShape(node, e.type, expected);
|
|
7406
7031
|
return e;
|
|
7407
7032
|
}
|
|
7408
7033
|
/** The unit an 'any' expression PROVABLY holds on every run, or null
|
|
7409
|
-
* when no proof exists.
|
|
7410
|
-
*
|
|
7411
|
-
* or the node is an identifier whose every declaration is a plain,
|
|
7034
|
+
* when no proof exists. The node must be an identifier whose every
|
|
7035
|
+
* declaration is a plain,
|
|
7412
7036
|
* non-ambient `var`/`let`/`const` declarator under a variable STATEMENT
|
|
7413
7037
|
* (catch bindings, for-of/for-in cursors, parameters, and imports all
|
|
7414
7038
|
* fail this shape test — each receives values from elsewhere), each
|
|
@@ -7419,13 +7043,7 @@ export class Lowerer {
|
|
|
7419
7043
|
* bindings are read-only, so cross-file writes don't exist). A hoisted
|
|
7420
7044
|
* `var` read before its unit-initialized statement holds undefined —
|
|
7421
7045
|
* also a unit — so the mixed case reports both names. */
|
|
7422
|
-
provenUnitAnyOf(node,
|
|
7423
|
-
if (value.kind === "jsOp" && value.args.length === 0) {
|
|
7424
|
-
if (value.op === "undefLit")
|
|
7425
|
-
return "undefined";
|
|
7426
|
-
if (value.op === "nullLit")
|
|
7427
|
-
return "null";
|
|
7428
|
-
}
|
|
7046
|
+
provenUnitAnyOf(node, _value) {
|
|
7429
7047
|
let n = node;
|
|
7430
7048
|
while (ts.isParenthesizedExpression(n))
|
|
7431
7049
|
n = n.expression;
|
|
@@ -7533,7 +7151,6 @@ export class Lowerer {
|
|
|
7533
7151
|
const from = this.mapTypeOf(this.typeOf(asserted.expression));
|
|
7534
7152
|
const to = this.mapTypeOf(this.checker.getTypeFromTypeNode(asserted.type));
|
|
7535
7153
|
if (from?.kind === "dyn" ||
|
|
7536
|
-
from?.kind === "jsval" ||
|
|
7537
7154
|
(from?.kind === "record" && to?.kind === "record" && !typeEquals(from, to))) {
|
|
7538
7155
|
this.noLowering("collection key assertion requiring a structural copy or dynamic conversion", asserted, "use the original reference with the same type as the collection key");
|
|
7539
7156
|
}
|
|
@@ -7547,7 +7164,7 @@ export class Lowerer {
|
|
|
7547
7164
|
(from.kind === "object" &&
|
|
7548
7165
|
to.kind === "object" &&
|
|
7549
7166
|
this.isSubclassOf(from.className, to.className))));
|
|
7550
|
-
if (!preservesIdentity || value.kind === "dynCheck"
|
|
7167
|
+
if (!preservesIdentity || value.kind === "dynCheck") {
|
|
7551
7168
|
this.noLowering(`collection key conversion from '${this.fmt(value.type)}' to '${this.fmt(expected)}' requiring a structural copy or dynamic conversion`, node, "use the same reference type for the key and collection; copying a key would change its identity");
|
|
7552
7169
|
}
|
|
7553
7170
|
return this.coerceInto(node, value, expected);
|
|
@@ -7739,11 +7356,6 @@ export class Lowerer {
|
|
|
7739
7356
|
if (value.kind === "unitLit") {
|
|
7740
7357
|
return { kind: "dynFrom", value, type: DYN, loc: value.loc };
|
|
7741
7358
|
}
|
|
7742
|
-
// An ISLAND ('any') value: the by-reference jsval→dyn wrap — the same
|
|
7743
|
-
// edge coerceToExpected converts (dyn slots accept engine values).
|
|
7744
|
-
if (value.type.kind === "jsval") {
|
|
7745
|
-
return { kind: "dynFromJsval", value, type: DYN, loc: value.loc };
|
|
7746
|
-
}
|
|
7747
7359
|
if (!this.dynConvertible(value.type)) {
|
|
7748
7360
|
this.unsupported("SC1100", node, `storing '${this.fmt(value.type)}' values under an 'unknown'-valued index signature (only numbers, strings, booleans, and JSON-safe records/arrays/unions convert)`);
|
|
7749
7361
|
}
|
|
@@ -7940,18 +7552,7 @@ export class Lowerer {
|
|
|
7940
7552
|
}
|
|
7941
7553
|
return { kind: "boolLit", value: true, type: BOOL, loc };
|
|
7942
7554
|
}
|
|
7943
|
-
/** The entry value of a binding JS initializes to `undefined` (an
|
|
7944
|
-
* initializer-less declaration, a hoisted `var` before its statement):
|
|
7945
|
-
* undefined-armed unions hold the interned undefined arm, and 'any'
|
|
7946
|
-
* slots hold the ENGINE's undefined — tsc's definite-assignment
|
|
7947
|
-
* analysis never guards `any` reads, so a jsval slot IS readable before
|
|
7948
|
-
* any assignment and must never stay a C-level NULL (a validated exit
|
|
7949
|
-
* or engine op on NULL is memory-unsafe, not a TypeError). Null for
|
|
7950
|
-
* every other type: tsc rejects their pre-assignment reads. */
|
|
7951
7555
|
unassignedSlotInit(type, loc) {
|
|
7952
|
-
if (type.kind === "jsval") {
|
|
7953
|
-
return { kind: "jsOp", op: "undefLit", args: [], type: JSVAL, loc };
|
|
7954
|
-
}
|
|
7955
7556
|
return this.wrappedUndefined(type, loc);
|
|
7956
7557
|
}
|
|
7957
7558
|
undefinedArgFor(type, loc, blame) {
|
|
@@ -8477,24 +8078,19 @@ export class Lowerer {
|
|
|
8477
8078
|
// identifier-param prologue's ternary), then destructure the
|
|
8478
8079
|
// picked value.
|
|
8479
8080
|
const abi = shape.type;
|
|
8480
|
-
if (abi.kind === "dyn"
|
|
8481
|
-
//
|
|
8482
|
-
//
|
|
8483
|
-
// dynamic dyn): the slot holds its tier's undefined directly,
|
|
8484
|
-
// so the default test is the runtime undefined test — then
|
|
8485
|
-
// the pattern destructures the picked value.
|
|
8081
|
+
if (abi.kind === "dyn") {
|
|
8082
|
+
// The checked-value slot holds native undefined directly.
|
|
8083
|
+
// Test it at runtime, then destructure the selected value.
|
|
8486
8084
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8487
8085
|
const src = this.declareHiddenLocal("%psrc", abi);
|
|
8488
8086
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8489
|
-
const isUndef =
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
}
|
|
8497
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8087
|
+
const isUndef = {
|
|
8088
|
+
kind: "dynTest",
|
|
8089
|
+
test: "undefined",
|
|
8090
|
+
value: inRef(),
|
|
8091
|
+
type: BOOL,
|
|
8092
|
+
loc,
|
|
8093
|
+
};
|
|
8498
8094
|
prologue.push({
|
|
8499
8095
|
kind: "varDecl",
|
|
8500
8096
|
localId: src.id,
|
|
@@ -8594,24 +8190,20 @@ export class Lowerer {
|
|
|
8594
8190
|
const name = decl.name.text;
|
|
8595
8191
|
if (shape.mode === "omittable" && shape.bodyType && decl.initializer) {
|
|
8596
8192
|
const abi = shape.type;
|
|
8597
|
-
if (abi.kind === "dyn"
|
|
8598
|
-
//
|
|
8599
|
-
//
|
|
8600
|
-
// dynamic dyn): the slot holds its tier's undefined directly —
|
|
8601
|
-
// the body local picks the default on the runtime test.
|
|
8193
|
+
if (abi.kind === "dyn") {
|
|
8194
|
+
// The checked-value slot holds native undefined directly;
|
|
8195
|
+
// the body local selects the default with a runtime test.
|
|
8602
8196
|
const loc = locOf(decl);
|
|
8603
8197
|
const slot = this.declareHiddenLocal(name, abi);
|
|
8604
8198
|
params.push({ localId: slot.id, name, type: abi });
|
|
8605
8199
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8606
|
-
const isUndef =
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
}
|
|
8614
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8200
|
+
const isUndef = {
|
|
8201
|
+
kind: "dynTest",
|
|
8202
|
+
test: "undefined",
|
|
8203
|
+
value: inRef(),
|
|
8204
|
+
type: BOOL,
|
|
8205
|
+
loc,
|
|
8206
|
+
};
|
|
8615
8207
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8616
8208
|
const body = this.declareLocal(decl.name, name, abi, true);
|
|
8617
8209
|
prologue.push({
|
|
@@ -8794,13 +8386,6 @@ export class Lowerer {
|
|
|
8794
8386
|
resolveThis() {
|
|
8795
8387
|
return this.resolveKey(undefined);
|
|
8796
8388
|
}
|
|
8797
|
-
/** READ-ONLY twin of resolveLocal for PROBES (isIslandExpr): answers
|
|
8798
|
-
* the nearest binding entry without boxing, threading, or predeclaring.
|
|
8799
|
-
* resolveKey mutates capture state as a side effect, and a speculative
|
|
8800
|
-
* island-ness query through a context that takes no captures (a plain
|
|
8801
|
-
* declared function between the origin and the reference) was an ICE —
|
|
8802
|
-
* the REAL lowering path still resolves (and diagnoses) the reference
|
|
8803
|
-
* itself. */
|
|
8804
8389
|
peekLocal(ident) {
|
|
8805
8390
|
let symbol = this.checker.getSymbolAtLocation(ident);
|
|
8806
8391
|
if (ident.parent &&
|
|
@@ -8968,79 +8553,6 @@ export class Lowerer {
|
|
|
8968
8553
|
allowDynObject ||=
|
|
8969
8554
|
srcType.kind === "dyn" && isParseArgsDynCheckerType(this, this.typeOf(pattern));
|
|
8970
8555
|
}
|
|
8971
|
-
// An ISLAND source (`const { readFileSync } = await import("fs")` —
|
|
8972
|
-
// a namespace handle, or any 'any'-typed object): each bound name is
|
|
8973
|
-
// an engine property read, mirroring the island property-read rule —
|
|
8974
|
-
// a member the .d.ts declares as a primitive exits eagerly to the
|
|
8975
|
-
// static type; everything else (including members whose declared
|
|
8976
|
-
// types have no static mapping, like @types/node's function types)
|
|
8977
|
-
// stays a HANDLE, and its use sites dispatch to engine ops. Patterns
|
|
8978
|
-
// the element-wise walk cannot spell — ARRAY patterns (the iterator
|
|
8979
|
-
// protocol), empty patterns (the coercion checks), holes, rest,
|
|
8980
|
-
// defaults — run the REAL pattern in a synthesized engine function
|
|
8981
|
-
// instead (lowerJsvalBindingPattern).
|
|
8982
|
-
const elementWise = srcType.kind === "jsval" &&
|
|
8983
|
-
ts.isObjectBindingPattern(pattern) &&
|
|
8984
|
-
pattern.elements.length > 0 &&
|
|
8985
|
-
pattern.elements.every((el) => !el.dotDotDotToken &&
|
|
8986
|
-
!el.initializer &&
|
|
8987
|
-
el.name !== undefined &&
|
|
8988
|
-
ts.isIdentifier(el.propertyName ?? el.name));
|
|
8989
|
-
if (srcType.kind === "jsval" && !elementWise) {
|
|
8990
|
-
if (lowerJsvalBindingPattern(this, pattern, srcRef, isLet, out))
|
|
8991
|
-
return;
|
|
8992
|
-
// No engine form (computed keys, untransportable defaults): fall
|
|
8993
|
-
// through to the static fences below.
|
|
8994
|
-
}
|
|
8995
|
-
if (srcType.kind === "jsval" && ts.isObjectBindingPattern(pattern)) {
|
|
8996
|
-
for (const el of pattern.elements) {
|
|
8997
|
-
this.checkBindingElement(el);
|
|
8998
|
-
// 7's BindingElement declares name optional (array elisions are
|
|
8999
|
-
// nameless there); object-pattern elements always carry one.
|
|
9000
|
-
if (el.name === undefined)
|
|
9001
|
-
continue;
|
|
9002
|
-
const prop = el.propertyName ?? el.name;
|
|
9003
|
-
if (!ts.isIdentifier(prop)) {
|
|
9004
|
-
this.unsupported("SC1031", el, "destructuring with computed or non-identifier keys");
|
|
9005
|
-
}
|
|
9006
|
-
const loc = locOf(el);
|
|
9007
|
-
const read = {
|
|
9008
|
-
kind: "jsOp",
|
|
9009
|
-
op: "getProp",
|
|
9010
|
-
name: prop.text,
|
|
9011
|
-
args: [srcRef()],
|
|
9012
|
-
type: JSVAL,
|
|
9013
|
-
loc,
|
|
9014
|
-
};
|
|
9015
|
-
if (!ts.isIdentifier(el.name)) {
|
|
9016
|
-
// A nested pattern reads through its own handle temp.
|
|
9017
|
-
const tmp = this.declareHiddenLocal("%destr", JSVAL);
|
|
9018
|
-
out.push({ kind: "varDecl", localId: tmp.id, init: read, loc });
|
|
9019
|
-
this.lowerBindingPattern(el.name, () => ({ kind: "varRef", localId: tmp.id, type: JSVAL, loc }), JSVAL, isLet, out);
|
|
9020
|
-
continue;
|
|
9021
|
-
}
|
|
9022
|
-
const declared = this.mapTypeOf(this.typeOf(el.name));
|
|
9023
|
-
const primitive = declared &&
|
|
9024
|
-
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string");
|
|
9025
|
-
const value = primitive
|
|
9026
|
-
? { kind: "jsExit", value: read, type: declared, loc }
|
|
9027
|
-
: read;
|
|
9028
|
-
const symbol = this.checker.getSymbolAtLocation(el.name);
|
|
9029
|
-
const g = symbol ? this.globalsBySymbol.get(symbol) : undefined;
|
|
9030
|
-
if (g) {
|
|
9031
|
-
out.push({
|
|
9032
|
-
kind: "assign",
|
|
9033
|
-
localId: g.id,
|
|
9034
|
-
value: this.coerceInto(el.name, value, g.type),
|
|
9035
|
-
loc,
|
|
9036
|
-
});
|
|
9037
|
-
continue;
|
|
9038
|
-
}
|
|
9039
|
-
const local = this.declareLocal(el.name, el.name.text, value.type, isLet);
|
|
9040
|
-
out.push({ kind: "varDecl", localId: local.id, init: value, loc });
|
|
9041
|
-
}
|
|
9042
|
-
return;
|
|
9043
|
-
}
|
|
9044
8556
|
return lowerBindingPattern(this, pattern, srcRef, srcType, isLet, out, dynSpell, allowDynObject);
|
|
9045
8557
|
}
|
|
9046
8558
|
checkBindingElement(el, allowDefault = false) {
|
|
@@ -9053,97 +8565,6 @@ export class Lowerer {
|
|
|
9053
8565
|
return lowerVarDeclList(this, list);
|
|
9054
8566
|
}
|
|
9055
8567
|
lowerVarDecl(decl, isLet) {
|
|
9056
|
-
// ISLAND-HANDLE rescue (--dynamic): `const factory = (await
|
|
9057
|
-
// import("./x.mjs")).default` / `const buf = islandReadFileSync(p)` —
|
|
9058
|
-
// a binding whose DECLARED type either has no static mapping or has
|
|
9059
|
-
// one no island value can EXIT to (bytes, functions, promises), but
|
|
9060
|
-
// whose initializer is an island value. The declared type is a .d.ts
|
|
9061
|
-
// surface over an engine value; the binding stays a HANDLE (jsval
|
|
9062
|
-
// local) and typed use sites go through engine ops and validated
|
|
9063
|
-
// exits like any island value. Exit-CAPABLE declared types (numbers,
|
|
9064
|
-
// strings, JSON-safe composites, their undefined-armed unions) keep
|
|
9065
|
-
// the standard path and its validated-exit machinery; so does
|
|
9066
|
-
// everything non-island — including badType here when the
|
|
9067
|
-
// initializer turns out not to be island-typed, which is exactly
|
|
9068
|
-
// what the standard path would have reported.
|
|
9069
|
-
// Only reference-shaped initializers are candidates (awaits, calls,
|
|
9070
|
-
// member reads, identifiers, casts/parens over those): they are the
|
|
9071
|
-
// island producers, and re-lowering one on the fall-through emits
|
|
9072
|
-
// nothing twice — a lambda or literal initializer would (each
|
|
9073
|
-
// lowering mints a fresh %fn), and is never an island value anyway.
|
|
9074
|
-
const islandCandidate = (e) => {
|
|
9075
|
-
let cur = e;
|
|
9076
|
-
while (ts.isParenthesizedExpression(cur) ||
|
|
9077
|
-
ts.isAsExpression(cur) ||
|
|
9078
|
-
ts.isTypeAssertion(cur) ||
|
|
9079
|
-
ts.isNonNullExpression(cur)) {
|
|
9080
|
-
cur = cur.expression;
|
|
9081
|
-
}
|
|
9082
|
-
if (!ts.isAwaitExpression(cur) &&
|
|
9083
|
-
!ts.isCallExpression(cur) &&
|
|
9084
|
-
!ts.isPropertyAccessExpression(cur) &&
|
|
9085
|
-
!ts.isElementAccessExpression(cur) &&
|
|
9086
|
-
!ts.isIdentifier(cur)) {
|
|
9087
|
-
return false;
|
|
9088
|
-
}
|
|
9089
|
-
// A lambda ANYWHERE inside (a call argument) would emit its %fn
|
|
9090
|
-
// twice across the fall-through's re-lowering — skip those.
|
|
9091
|
-
let lambda = false;
|
|
9092
|
-
const scan = (n) => {
|
|
9093
|
-
if (lambda)
|
|
9094
|
-
return;
|
|
9095
|
-
if (ts.isArrowFunction(n) || ts.isFunctionExpression(n)) {
|
|
9096
|
-
lambda = true;
|
|
9097
|
-
return;
|
|
9098
|
-
}
|
|
9099
|
-
ts.forEachChild(n, scan);
|
|
9100
|
-
};
|
|
9101
|
-
scan(cur);
|
|
9102
|
-
return !lambda;
|
|
9103
|
-
};
|
|
9104
|
-
if (this.dynamic &&
|
|
9105
|
-
ts.isIdentifier(decl.name) &&
|
|
9106
|
-
decl.initializer !== undefined &&
|
|
9107
|
-
// `var` stays out: the rescue's block-positioned jsval local can't
|
|
9108
|
-
// model the function-scoped hoisted binding (a redeclaration or an
|
|
9109
|
-
// out-of-block read would split the variable in two) — vars take the
|
|
9110
|
-
// standard path and its own fences.
|
|
9111
|
-
(ts.getCombinedNodeFlags(decl) & ts.NodeFlags.BlockScoped) !== 0 &&
|
|
9112
|
-
islandCandidate(decl.initializer) &&
|
|
9113
|
-
// createRequire's plumbing decls are COMPILE-TIME erasures (the
|
|
9114
|
-
// require binding and its builtin-namespace bindings) — never
|
|
9115
|
-
// island values; the standard path's skips own them.
|
|
9116
|
-
!createRequireBindingDecl(this, decl.name, decl.initializer) &&
|
|
9117
|
-
!createRequireNamespaceDecl(this, decl.name, decl.initializer)) {
|
|
9118
|
-
const mapped = this.mapTypeOf(this.typeOf(decl.name));
|
|
9119
|
-
const handleOnly = mapped === null ||
|
|
9120
|
-
(mapped.kind !== "jsval" &&
|
|
9121
|
-
mapped.kind !== "void" &&
|
|
9122
|
-
!canExitIslandToType(mapped, (id) => this.shapes.get(id), (id) => this.unions.get(id)));
|
|
9123
|
-
const symbol = this.checker.getSymbolAtLocation(decl.name);
|
|
9124
|
-
if (handleOnly && (!symbol || !this.globalsBySymbol.has(symbol))) {
|
|
9125
|
-
const init = this.lowerExpr(decl.initializer);
|
|
9126
|
-
if (init.type.kind === "jsval") {
|
|
9127
|
-
const local = this.declareLocal(decl.name, decl.name.text, JSVAL, isLet);
|
|
9128
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9129
|
-
}
|
|
9130
|
-
// The CHECKED-DYNAMIC twin of the handle rescue (the runtime-world
|
|
9131
|
-
// local rule): an unmappable declared type over a dyn initializer
|
|
9132
|
-
// (`const first = plugins[0]` — the checker spells 'string |
|
|
9133
|
-
// object' while the read is a dyn keyed read) keeps the binding
|
|
9134
|
-
// dyn; typed use sites ride validated extractions and the routed
|
|
9135
|
-
// engine ops, exactly the JSON.parse-binding story.
|
|
9136
|
-
if (mapped === null && init.type.kind === "dyn") {
|
|
9137
|
-
const local = this.declareLocal(decl.name, decl.name.text, DYN, isLet);
|
|
9138
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9139
|
-
}
|
|
9140
|
-
if (mapped === null)
|
|
9141
|
-
this.badType(decl.name, this.typeOf(decl.name));
|
|
9142
|
-
// A mappable declared type with a non-island initializer: the
|
|
9143
|
-
// standard path owns it (the initializer lowered clean; re-running
|
|
9144
|
-
// it re-produces the same IR with no duplicate diagnostics).
|
|
9145
|
-
}
|
|
9146
|
-
}
|
|
9147
8568
|
return lowerVarDecl(this, decl, isLet);
|
|
9148
8569
|
}
|
|
9149
8570
|
lowerSwitch(stmt) {
|
|
@@ -9205,13 +8626,6 @@ export class Lowerer {
|
|
|
9205
8626
|
nodeTypesOnlySymbol(sym) {
|
|
9206
8627
|
return nodeTypesOnlySymbol(this, sym);
|
|
9207
8628
|
}
|
|
9208
|
-
/** True for an npm package's shipped declaration files — under
|
|
9209
|
-
* node_modules but NOT the standard library (typescript's own lib files
|
|
9210
|
-
* live under node_modules too), or inside a registered workspace-linked
|
|
9211
|
-
* package (a node_modules symlink whose realpath'd files carry no
|
|
9212
|
-
* node_modules segment — workspace-registry.ts). The provenance half of the npm
|
|
9213
|
-
* typing rule (package types are island handles) and of the per-package
|
|
9214
|
-
* requires-dynamic attribution. */
|
|
9215
8629
|
isNpmFile = (sf) => sf.isDeclarationFile &&
|
|
9216
8630
|
(sf.fileName.includes("/node_modules/") || workspacePackageOfPath(sf.fileName) !== null) &&
|
|
9217
8631
|
!this.isStdlibFile(sf);
|
|
@@ -9325,40 +8739,6 @@ export class Lowerer {
|
|
|
9325
8739
|
return lowerTemplate(this, expr);
|
|
9326
8740
|
}
|
|
9327
8741
|
lowerAsExpression(expr) {
|
|
9328
|
-
// ISLAND value cast to a PROMISE type (`factory(opts) as Promise<Mod>`
|
|
9329
|
-
// — the Node-typed async-API shape): promises never have a validated
|
|
9330
|
-
// exit, so instead of refusing the build the cast DEFERS the failure
|
|
9331
|
-
// to runtime — island.castFail evaluates the value (its side effects
|
|
9332
|
-
// are real) and throws a catchable TypeError naming the target, so
|
|
9333
|
-
// typed-but-never-executed code (a wasm decode path behind a
|
|
9334
|
-
// rejecting import) still compiles and a reached cast fails loudly at
|
|
9335
|
-
// the exact site. Claimed only when the source is island-typed by the
|
|
9336
|
-
// checker (jsval, or a promise whose inner is a handle); a source
|
|
9337
|
-
// that lowers to a real static promise keeps erasure — the standard
|
|
9338
|
-
// path's rule for non-island inners. Static builds keep their
|
|
9339
|
-
// per-site diagnostics.
|
|
9340
|
-
if (this.dynamic) {
|
|
9341
|
-
const srcMapped = this.mapTypeOf(this.typeOf(expr.expression));
|
|
9342
|
-
const island = srcMapped?.kind === "jsval" ||
|
|
9343
|
-
(srcMapped?.kind === "promise" && srcMapped.inner.kind === "jsval");
|
|
9344
|
-
if (island) {
|
|
9345
|
-
const targetTs = this.checker.getTypeFromTypeNode(expr.type);
|
|
9346
|
-
const target = this.mapTypeOf(targetTs);
|
|
9347
|
-
if (target?.kind === "promise") {
|
|
9348
|
-
const inner = this.lowerExpr(expr.expression);
|
|
9349
|
-
if (inner.type.kind !== "jsval")
|
|
9350
|
-
return inner; // static promise: erasure
|
|
9351
|
-
const loc = locOf(expr);
|
|
9352
|
-
const name = {
|
|
9353
|
-
kind: "strLit",
|
|
9354
|
-
value: this.fmt(target),
|
|
9355
|
-
type: STRING,
|
|
9356
|
-
loc,
|
|
9357
|
-
};
|
|
9358
|
-
return { kind: "libCall", fn: "island.castFail", args: [inner, name], type: target, loc };
|
|
9359
|
-
}
|
|
9360
|
-
}
|
|
9361
|
-
}
|
|
9362
8742
|
return lowerAsExpression(this, expr);
|
|
9363
8743
|
}
|
|
9364
8744
|
lowerPrefixUnary(expr) {
|
|
@@ -9490,8 +8870,6 @@ export class Lowerer {
|
|
|
9490
8870
|
}
|
|
9491
8871
|
}
|
|
9492
8872
|
lowerCall(expr) {
|
|
9493
|
-
// Ambient fetch (native in static builds, island-backed under
|
|
9494
|
-
// --dynamic) and dynamic import() claim their calls before the general
|
|
9495
8873
|
// dispatch. The general identifier-call paths have no lowering for a
|
|
9496
8874
|
// promise-returning ambient global, and `import` is a keyword callee no
|
|
9497
8875
|
// identifier path matches.
|
|
@@ -9630,33 +9008,6 @@ export class Lowerer {
|
|
|
9630
9008
|
return inheritsBuiltinEmitterCtor(this, info);
|
|
9631
9009
|
}
|
|
9632
9010
|
lowerNew(expr) {
|
|
9633
|
-
// `new Uint8Array(handle)` (and the other typed-array ctors) over an
|
|
9634
|
-
// ISLAND argument: the construction is an ENGINE operation — the
|
|
9635
|
-
// engine's own constructor over the engine's own value (an Emscripten
|
|
9636
|
-
// factory's `wasmBinary: new Uint8Array(buf)` where buf came off an
|
|
9637
|
-
// island readFileSync) — and the instance stays a handle. The static
|
|
9638
|
-
// bytes ctor cannot claim it (bytes never cross the boundary), so
|
|
9639
|
-
// this preempts only when the single argument is island-typed;
|
|
9640
|
-
// every static form keeps the standard path.
|
|
9641
|
-
if (this.dynamic &&
|
|
9642
|
-
ts.isIdentifier(expr.expression) &&
|
|
9643
|
-
expr.arguments?.length === 1 &&
|
|
9644
|
-
!ts.isSpreadElement(expr.arguments[0]) &&
|
|
9645
|
-
/^(Uint8|Uint8Clamped|Int8|Uint16|Int16|Uint32|Int32|Float32|Float64|BigInt64|BigUint64)Array$/.test(expr.expression.text) &&
|
|
9646
|
-
this.isStdlibSymbol(this.resolveValueSymbol(expr.expression) ?? undefined) &&
|
|
9647
|
-
this.isIslandExpr(expr.arguments[0])) {
|
|
9648
|
-
const loc = locOf(expr);
|
|
9649
|
-
const ctor = {
|
|
9650
|
-
kind: "jsOp",
|
|
9651
|
-
op: "globalGet",
|
|
9652
|
-
name: expr.expression.text,
|
|
9653
|
-
args: [],
|
|
9654
|
-
type: JSVAL,
|
|
9655
|
-
loc,
|
|
9656
|
-
};
|
|
9657
|
-
const arg = this.lowerExpr(expr.arguments[0]);
|
|
9658
|
-
return { kind: "jsOp", op: "construct", args: [ctor, arg], type: JSVAL, loc };
|
|
9659
|
-
}
|
|
9660
9011
|
const builtin = lowerAbortControllerNew(this, expr) ??
|
|
9661
9012
|
lowerFetchWebNew(this, expr) ??
|
|
9662
9013
|
lowerResponseNew(this, expr) ??
|
|
@@ -10296,18 +9647,17 @@ export class Lowerer {
|
|
|
10296
9647
|
lowerNumberStaticProperty(expr) {
|
|
10297
9648
|
return lowerNumberStaticProperty(this, expr);
|
|
10298
9649
|
}
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
return requireDynamicApi(this, feature, node, hint);
|
|
9650
|
+
refuseUnsupportedApi(feature, node, hint) {
|
|
9651
|
+
return refuseUnsupportedApi(this, feature, node, hint);
|
|
10302
9652
|
}
|
|
10303
9653
|
lowerMathProperty(expr) {
|
|
10304
9654
|
return lowerMathProperty(this, expr);
|
|
10305
9655
|
}
|
|
10306
|
-
|
|
10307
|
-
return
|
|
9656
|
+
stdlibGlobalFnOf(ident) {
|
|
9657
|
+
return stdlibGlobalFnOf(this, ident);
|
|
10308
9658
|
}
|
|
10309
|
-
|
|
10310
|
-
return
|
|
9659
|
+
lowerStdlibMethodCall(call, access) {
|
|
9660
|
+
return lowerStdlibMethodCall(this, call, access);
|
|
10311
9661
|
}
|
|
10312
9662
|
}
|
|
10313
9663
|
//# sourceMappingURL=lowerer.js.map
|