@scriptc/compiler 0.2.10 → 0.3.1
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 +7 -38
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.test.js +1 -1
- package/dist/backend/cycle-mutability.d.ts +1 -1
- package/dist/backend/cycle-mutability.js +1 -18
- 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 +1 -1
- package/dist/backend/immutability.js +1 -1
- package/dist/backend/immutability.test.js +1 -1
- 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/bigint-wrap.d.ts +4 -0
- package/dist/backend/llvm/bigint-wrap.js +590 -0
- package/dist/backend/llvm/bigint-wrap.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +4 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +15 -4
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +14 -3
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +2 -2
- package/dist/backend/llvm/checked-narrows.test.js.map +1 -1
- package/dist/backend/llvm/classes.js +60 -21
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +11 -11
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +7 -5
- package/dist/backend/llvm/common.js +7 -5
- 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 +13 -31
- 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 +133 -45
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +54 -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 +4 -73
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +123 -23
- package/dist/backend/llvm/emitter.js +729 -258
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +17 -10
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +120 -43
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +2 -2
- package/dist/backend/llvm/expr-async.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +51 -36
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +72 -3
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +1 -1
- package/dist/backend/llvm/expr-calls.js +159 -30
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-calls.test.js +132 -0
- package/dist/backend/llvm/expr-calls.test.js.map +1 -0
- package/dist/backend/llvm/expr-containers.js +25 -8
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +2 -0
- 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 +3 -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 +39 -31
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +7 -0
- package/dist/backend/llvm/expr-primitives.js +80 -22
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +97 -7
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +9 -0
- package/dist/backend/llvm/expr-records.js +134 -16
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +80 -1
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +51 -2
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/int32-abi.d.ts +31 -0
- package/dist/backend/llvm/int32-abi.js +62 -0
- package/dist/backend/llvm/int32-abi.js.map +1 -0
- package/dist/backend/llvm/int32-abi.test.js +107 -0
- package/dist/backend/llvm/int32-abi.test.js.map +1 -0
- package/dist/backend/llvm/int32-locals.d.ts +30 -0
- package/dist/backend/llvm/int32-locals.js +95 -0
- package/dist/backend/llvm/int32-locals.js.map +1 -0
- package/dist/backend/llvm/integer-values.d.ts +4 -0
- package/dist/backend/llvm/integer-values.js +30 -1
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/integer-views.d.ts +8 -1
- package/dist/backend/llvm/integer-views.js +47 -2
- package/dist/backend/llvm/integer-views.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.d.ts +16 -0
- package/dist/backend/llvm/lazy-captures.js +88 -2
- package/dist/backend/llvm/lazy-captures.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.test.js +48 -0
- package/dist/backend/llvm/lazy-captures.test.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +14 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +3 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +7 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +21 -2
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +4 -3
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +3 -3
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +7 -0
- package/dist/backend/llvm/map-number-lookup.js +16 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.js +7 -1
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +25 -8
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +2 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +3 -0
- package/dist/backend/llvm/reference-writes.js +10 -2
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.d.ts +39 -0
- package/dist/backend/llvm/regex-matchers.js +1649 -0
- package/dist/backend/llvm/regex-matchers.js.map +1 -0
- package/dist/backend/llvm/regex-matchers.test.js +96 -0
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +36 -1
- package/dist/backend/llvm/shapes.js +128 -16
- 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 +2 -2
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +3 -3
- package/dist/backend/llvm/string-construction.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +6 -6
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-literal-equality.d.ts +22 -0
- package/dist/backend/llvm/string-literal-equality.js +78 -0
- package/dist/backend/llvm/string-literal-equality.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.js +59 -13
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +72 -7
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/union-retype.test.d.ts +1 -0
- package/dist/backend/llvm/union-retype.test.js +229 -0
- package/dist/backend/llvm/union-retype.test.js.map +1 -0
- package/dist/backend/llvm/wrapping-sums.d.ts +17 -0
- package/dist/backend/llvm/wrapping-sums.js +113 -0
- package/dist/backend/llvm/wrapping-sums.js.map +1 -0
- package/dist/backend/loop-polls.js +1 -0
- package/dist/backend/loop-polls.js.map +1 -1
- package/dist/backend/mangle.d.ts +9 -0
- package/dist/backend/mangle.js +15 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.js +6 -12
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +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.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.js +6 -6
- package/dist/contracts/check.js.map +1 -1
- 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 +5 -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/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.d.ts +14 -0
- package/dist/frontend/lowering/array-values.js +33 -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.js +0 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +49 -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/array-pipelines.d.ts +54 -0
- package/dist/frontend/lowering/containers/array-pipelines.js +1827 -0
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -0
- 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/exec-result-uses.d.ts +10 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js +88 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js.map +1 -0
- 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 +17 -17
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +2 -1
- package/dist/frontend/lowering/containers/string-replacement.js +32 -136
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/devirtualize.d.ts +33 -0
- package/dist/frontend/lowering/devirtualize.js +199 -0
- package/dist/frontend/lowering/devirtualize.js.map +1 -0
- 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 +55 -8
- 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 +3 -66
- 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/identifier-uses.d.ts +7 -0
- package/dist/frontend/lowering/identifier-uses.js +23 -0
- package/dist/frontend/lowering/identifier-uses.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.js +51 -3
- package/dist/frontend/lowering/iterator-adapters.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 +14 -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 +111 -493
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +12 -60
- 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-console.d.ts +14 -0
- package/dist/frontend/lowering/lower-console.js +195 -0
- package/dist/frontend/lowering/lower-console.js.map +1 -0
- 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 +180 -905
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +9 -8
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +10 -0
- package/dist/frontend/lowering/lower-generators.js +108 -41
- package/dist/frontend/lowering/lower-generators.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 +29 -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 +14 -13
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +42 -155
- package/dist/frontend/lowering/lowerer.js +192 -816
- 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/nan-coded-reads.d.ts +16 -0
- package/dist/frontend/lowering/nan-coded-reads.js +108 -1
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.js +1 -1
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-bounds.d.ts +4 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js +2 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-bounds.test.js +27 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/split-consumers.js +2 -18
- package/dist/frontend/lowering/split-consumers.js.map +1 -1
- 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 +8 -73
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +6 -1
- package/dist/frontend/lowering/union-retag.js +64 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +46 -0
- package/dist/frontend/lowering/union-retag.test.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 +12 -97
- 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 +58 -156
- 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 +2 -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 +13 -56
- 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/function-references.d.ts +12 -0
- package/dist/ir/function-references.js +29 -0
- package/dist/ir/function-references.js.map +1 -0
- package/dist/ir/function-references.test.d.ts +1 -0
- package/dist/ir/function-references.test.js +276 -0
- package/dist/ir/function-references.test.js.map +1 -0
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +10 -7
- package/dist/ir/int32-slots.js +219 -68
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +39 -2
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +4 -4
- package/dist/ir/integer-ranges.js +89 -64
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +71 -9
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +1 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +64 -290
- package/dist/ir/ir.js +11 -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 +8 -43
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +3 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +4 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.test.js +1 -1
- package/dist/ir/validate.js +66 -213
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +31 -13
- package/dist/ir/validate.test.js.map +1 -1
- 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 +5 -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 -104
- 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/llvm/expr-calls.test.d.ts} +0 -0
- /package/dist/{frontend/npm-fetch-analysis.test.d.ts → backend/llvm/int32-abi.test.d.ts} +0 -0
- /package/dist/{native/runtime-typescript.test.d.ts → backend/llvm/regex-matchers.test.d.ts} +0 -0
|
@@ -14,9 +14,8 @@ 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 { devirtualizeVirtualCalls } from "./devirtualize.js";
|
|
20
19
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
21
20
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
22
21
|
import { NarrowingStability } from "./narrowing-stability.js";
|
|
@@ -57,12 +56,12 @@ import { tsgoPath } from "../dts-paths.js";
|
|
|
57
56
|
import * as ts from "../ts7/adapter.js";
|
|
58
57
|
import { literalValues } from "../literal-values.js";
|
|
59
58
|
import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
|
|
60
|
-
import {
|
|
61
|
-
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";
|
|
62
61
|
import { provenanceActive } from "../provenance-registry.js";
|
|
63
62
|
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
64
|
-
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType,
|
|
65
|
-
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";
|
|
66
65
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
67
66
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
68
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";
|
|
@@ -78,12 +77,13 @@ import { lowerCall, lowerPromiseMethodCall, lowerFilterNarrowCall } from "./lowe
|
|
|
78
77
|
import { lowerFfiCall, validateFfiImports } from "./native-ffi.js";
|
|
79
78
|
import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, } from "./lower-functions.js";
|
|
80
79
|
import { lowerArrayMethodCall } from "./containers/array-methods.js";
|
|
80
|
+
import { fuseArrayPipelines } from "./containers/array-pipelines.js";
|
|
81
81
|
import { lowerMapMethodCall, lowerMapForEachCall, lowerSetMethodCall, lowerSetForEachCall, } from "./containers/collection-methods.js";
|
|
82
82
|
import { lowerEnvToPairsHelper } from "./containers/indexed-objects.js";
|
|
83
83
|
import { lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew } from "./containers/bytes.js";
|
|
84
84
|
import { lowerRegexMethodCall, lowerStringMethodCall } from "./containers/string-and-regexp.js";
|
|
85
85
|
import { lowerEmitOverrideSpec, } from "./lower-event-emitter.js";
|
|
86
|
-
import { builtinImportOf,
|
|
86
|
+
import { builtinImportOf, createRequireProgramModuleOf, createRequireSpecOf, fencedBuiltinImportOf, } from "./builtins/module-bindings.js";
|
|
87
87
|
import { stripTypeCasts } from "./builtins/arguments.js";
|
|
88
88
|
import { lowerBuiltinModuleCall } from "./builtins/module-calls.js";
|
|
89
89
|
import { lowerTimersPromisesSetInterval, lowerTimeoutMethodCall } from "./builtins/timers.js";
|
|
@@ -105,12 +105,13 @@ import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, low
|
|
|
105
105
|
import { lowerErrorCodeProperty } from "./builtins/errors.js";
|
|
106
106
|
import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
|
|
107
107
|
import { isConsoleLog, consoleCallMember } from "./builtins/console.js";
|
|
108
|
+
import { lowerConsoleNew } from "./lower-console.js";
|
|
108
109
|
import { lowerNumberStaticCall, lowerNumberStaticProperty } from "./builtins/numbers.js";
|
|
109
110
|
import { lowerDateCall } from "./builtins/dates.js";
|
|
110
111
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
111
112
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
112
113
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
113
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember,
|
|
114
|
+
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";
|
|
114
115
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
115
116
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
116
117
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -118,7 +119,7 @@ import { lowerAssertModuleCall, lowerAssertDirectCall } from "./lower-assert.js"
|
|
|
118
119
|
import { lowerUtilModuleCall } from "./lower-inspect.js";
|
|
119
120
|
import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
|
|
120
121
|
import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
|
|
121
|
-
import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern,
|
|
122
|
+
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";
|
|
122
123
|
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";
|
|
123
124
|
import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
|
|
124
125
|
import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
|
|
@@ -139,35 +140,6 @@ export class PoisonError extends Error {
|
|
|
139
140
|
export function own(table, key) {
|
|
140
141
|
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
141
142
|
}
|
|
142
|
-
/** IrStmt discriminants — the island walk below must not descend into
|
|
143
|
-
* NESTED statements (each is counted individually by its own lowerStmts
|
|
144
|
-
* visit; descending would attribute a nested island statement to every
|
|
145
|
-
* enclosing construct too). The top-level statement object itself is
|
|
146
|
-
* always visited. */
|
|
147
|
-
const IR_STMT_KINDS = new Set([
|
|
148
|
-
"varDecl",
|
|
149
|
-
"assign",
|
|
150
|
-
"exprStmt",
|
|
151
|
-
"if",
|
|
152
|
-
"while",
|
|
153
|
-
"doWhile",
|
|
154
|
-
"switch",
|
|
155
|
-
"arraySet",
|
|
156
|
-
"arraySetLength",
|
|
157
|
-
"arraySetUndefined",
|
|
158
|
-
"arrayDelete",
|
|
159
|
-
"forOf",
|
|
160
|
-
"return",
|
|
161
|
-
"fieldSet",
|
|
162
|
-
"recordSet",
|
|
163
|
-
"break",
|
|
164
|
-
"continue",
|
|
165
|
-
"block",
|
|
166
|
-
"tryCatch",
|
|
167
|
-
"throw",
|
|
168
|
-
"rethrow",
|
|
169
|
-
"runtimeFence",
|
|
170
|
-
]);
|
|
171
143
|
/** Every identifier a binding name binds: the identifier itself, or all
|
|
172
144
|
* identifiers of a (possibly nested) destructuring pattern in source
|
|
173
145
|
* order. */
|
|
@@ -184,28 +156,6 @@ export function boundIdentifiersOf(name) {
|
|
|
184
156
|
}
|
|
185
157
|
return out;
|
|
186
158
|
}
|
|
187
|
-
/** Inspect executable children directly, without boxing the statement tree
|
|
188
|
-
* into checked-dynamic storage just to calculate coverage. */
|
|
189
|
-
export function stmtUsesIsland(stmts) {
|
|
190
|
-
// Keep the accounting boundary at the source statement: nested statement
|
|
191
|
-
// lists are counted by their own lowerStmts invocation.
|
|
192
|
-
const nested = (stmt) => IR_STMT_KINDS.has(stmt.kind) || everyStmtChild(stmt, expr, nested);
|
|
193
|
-
const expr = (node) => {
|
|
194
|
-
if (node.kind === "jsOp" ||
|
|
195
|
-
node.kind === "jsExit" ||
|
|
196
|
-
node.kind === "jsBridgePromise" ||
|
|
197
|
-
(node.kind === "libCall" &&
|
|
198
|
-
(node.fn === "island.eval" ||
|
|
199
|
-
node.fn === "island.import" ||
|
|
200
|
-
node.fn === "island.importDyn" ||
|
|
201
|
-
node.fn === "island.castFail")))
|
|
202
|
-
return false;
|
|
203
|
-
return everyExprChild(node, expr, nested);
|
|
204
|
-
};
|
|
205
|
-
if (Array.isArray(stmts))
|
|
206
|
-
return !stmts.every((stmt) => everyStmtChild(stmt, expr, nested));
|
|
207
|
-
return !everyStmtChild(stmts, expr, nested);
|
|
208
|
-
}
|
|
209
159
|
/** Statements a never-lowered body would have contributed to the coverage
|
|
210
160
|
* totals: every element of a statement list (blocks, case clauses), plus
|
|
211
161
|
* the single-statement bodies of control flow, nested functions included —
|
|
@@ -286,13 +236,12 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
286
236
|
process.stderr.write(`scriptc lowering ${JSON.stringify(event)}\n`);
|
|
287
237
|
phaseLast = now;
|
|
288
238
|
};
|
|
289
|
-
const dynamic = options.dynamic ?? false;
|
|
290
239
|
const targetPlatform = options.targetPlatform ?? process.platform;
|
|
291
240
|
const startupCrash = options.startupCrash ?? null;
|
|
292
241
|
// Modules reachable only through literal import() of the program's own
|
|
293
242
|
// files join the compiled graph here, ONCE, before any
|
|
294
243
|
// pass constructs (nothing calls their %init at startup — the import()
|
|
295
|
-
// site's namespace builder does, on the
|
|
244
|
+
// site's namespace builder does, on the native microtask, Node's
|
|
296
245
|
// evaluation point for them). Inadmissible static cycles inside the
|
|
297
246
|
// added subgraph are minted here and handed to reachable emit after this
|
|
298
247
|
// extension of the shared array; no later pass re-walks the subgraph.
|
|
@@ -321,7 +270,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
321
270
|
const libraryCallbacks = options.libraryCallbacks ?? false;
|
|
322
271
|
const externalTypes = options.externalTypes ?? new Map();
|
|
323
272
|
const externalTypeSpecifiersByFile = options.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(externalTypes);
|
|
324
|
-
const validation = new Lowerer(program, entry, moduleOrder,
|
|
273
|
+
const validation = new Lowerer(program, entry, moduleOrder, {
|
|
325
274
|
frontendServices: options.frontendServices,
|
|
326
275
|
targetPlatform,
|
|
327
276
|
startupCrash,
|
|
@@ -341,7 +290,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
341
290
|
// lowerer because validation is an immediate no-op there.
|
|
342
291
|
const reachableEmit = ffiImports.length === 0
|
|
343
292
|
? validation
|
|
344
|
-
: new Lowerer(program, entry, moduleOrder,
|
|
293
|
+
: new Lowerer(program, entry, moduleOrder, {
|
|
345
294
|
frontendServices: options.frontendServices,
|
|
346
295
|
targetPlatform,
|
|
347
296
|
startupCrash,
|
|
@@ -370,7 +319,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
370
319
|
// historical compiler. This is a rare compatibility fallback; programs
|
|
371
320
|
// without such a settled fence retain checker-backed IR exactly once.
|
|
372
321
|
if (reachableEmit.requiresHistoricalOrderRelower) {
|
|
373
|
-
const emit = new Lowerer(program, entry, moduleOrder,
|
|
322
|
+
const emit = new Lowerer(program, entry, moduleOrder, {
|
|
374
323
|
frontendServices: options.frontendServices,
|
|
375
324
|
reachable,
|
|
376
325
|
targetPlatform,
|
|
@@ -432,7 +381,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
432
381
|
result = { ...result, contracts };
|
|
433
382
|
if (options.coverage !== true)
|
|
434
383
|
return result;
|
|
435
|
-
const remainder = new Lowerer(program, entry, moduleOrder,
|
|
384
|
+
const remainder = new Lowerer(program, entry, moduleOrder, {
|
|
436
385
|
frontendServices: options.frontendServices,
|
|
437
386
|
reachable,
|
|
438
387
|
remainder: true,
|
|
@@ -459,40 +408,13 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
459
408
|
},
|
|
460
409
|
};
|
|
461
410
|
}
|
|
462
|
-
/** The island-handle type a `import(...)` initializer gives a binding
|
|
463
|
-
* whose DECLARED type has no static mapping (`Promise<typeof
|
|
464
|
-
* import("./m")>` — module-namespace types don't map): the direct form
|
|
465
|
-
* holds the static promise-of-handle, the awaited form holds the handle
|
|
466
|
-
* itself. Null for every other initializer shape. */
|
|
467
|
-
export function importCallHandleType(expr) {
|
|
468
|
-
if (!expr)
|
|
469
|
-
return null;
|
|
470
|
-
let e = expr;
|
|
471
|
-
let awaited = false;
|
|
472
|
-
for (;;) {
|
|
473
|
-
if (ts.isParenthesizedExpression(e)) {
|
|
474
|
-
e = e.expression;
|
|
475
|
-
}
|
|
476
|
-
else if (ts.isAwaitExpression(e)) {
|
|
477
|
-
awaited = true;
|
|
478
|
-
e = e.expression;
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
if (ts.isCallExpression(e) && e.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
485
|
-
return awaited ? JSVAL : { kind: "promise", inner: JSVAL };
|
|
486
|
-
}
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
411
|
/** The native namespace type produced by a literal static import() of a
|
|
490
412
|
* compiled program module or supported Node builtin. This syntax-level
|
|
491
413
|
* fallback is used where the checker exposes an anonymous builtin-module
|
|
492
414
|
* object type with no stable module symbol (locals/globals are still
|
|
493
415
|
* represented nominally by the value they actually receive). */
|
|
494
416
|
export function staticImportNamespaceType(lowerer, expr) {
|
|
495
|
-
if (!expr
|
|
417
|
+
if (!expr)
|
|
496
418
|
return null;
|
|
497
419
|
let e = expr;
|
|
498
420
|
let awaited = false;
|
|
@@ -531,48 +453,8 @@ export function staticImportNamespaceType(lowerer, expr) {
|
|
|
531
453
|
const ns = { kind: "moduleNs", moduleId };
|
|
532
454
|
return awaited ? ns : { kind: "promise", inner: ns };
|
|
533
455
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
* (`any` under --dynamic): tsc never checks overload return types against
|
|
537
|
-
* the body — only the implementation signature is checked — so the
|
|
538
|
-
* overload's return is an unverifiable claim about an island value. The
|
|
539
|
-
* binding stores the HANDLE instead of trap-extracting the claimed type
|
|
540
|
-
* (reconcileOverloadReturn keeps the call jsval by the same rule), and
|
|
541
|
-
* uses dispatch to engine ops — exactly the value Node's binding holds.
|
|
542
|
-
* Ambient (.d.ts) declarations never reach this: they have no compiled
|
|
543
|
-
* implementation, so their calls lower through the island/builtin paths
|
|
544
|
-
* whose validated exits keep the checker-trust trap. */
|
|
545
|
-
export function uncheckedOverloadHandleCall(lowerer, expr) {
|
|
546
|
-
if (!lowerer.dynamic || !expr)
|
|
547
|
-
return false;
|
|
548
|
-
let e = expr;
|
|
549
|
-
while (ts.isParenthesizedExpression(e))
|
|
550
|
-
e = e.expression;
|
|
551
|
-
// Tagged templates are calls too (tag(strings, ...values)) and resolve
|
|
552
|
-
// overload sets the same way — foo1`${1}` against a TemplateStringsArray
|
|
553
|
-
// overload of an any-returning implementation stores the handle.
|
|
554
|
-
if (!ts.isCallExpression(e) && !ts.isTaggedTemplateExpression(e))
|
|
555
|
-
return false;
|
|
556
|
-
const rsig = lowerer.checker.getResolvedSignature(e);
|
|
557
|
-
const rdecl = rsig ? lowerer.checker.signatureDeclaration(rsig) : undefined;
|
|
558
|
-
if (!rsig || !rdecl)
|
|
559
|
-
return false;
|
|
560
|
-
if (!(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) || rdecl.body)
|
|
561
|
-
return false;
|
|
562
|
-
const name = rdecl.name;
|
|
563
|
-
const symbol = name ? lowerer.checker.getSymbolAtLocation(name) : undefined;
|
|
564
|
-
if (!symbol)
|
|
565
|
-
return false;
|
|
566
|
-
const impl = lowerer.checker
|
|
567
|
-
.declarationsOf(symbol)
|
|
568
|
-
.find((d) => (ts.isFunctionDeclaration(d) || ts.isMethodDeclaration(d)) &&
|
|
569
|
-
d.body !== undefined);
|
|
570
|
-
if (!impl)
|
|
571
|
-
return false;
|
|
572
|
-
const implSig = lowerer.checker.getSignatureFromDeclaration(impl);
|
|
573
|
-
if (!implSig)
|
|
574
|
-
return false;
|
|
575
|
-
return lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(implSig))?.kind === "jsval";
|
|
456
|
+
export function uncheckedOverloadHandleCall(_lowerer, _expr) {
|
|
457
|
+
return false;
|
|
576
458
|
}
|
|
577
459
|
/** The JavaScript declaration fallback for unmappable binding types (see
|
|
578
460
|
* irTypeOf): `any` and every other inference residue is the checked-
|
|
@@ -628,29 +510,6 @@ export function ladderFenceExpr(lowerer, surface, node, hint) {
|
|
|
628
510
|
loc,
|
|
629
511
|
};
|
|
630
512
|
}
|
|
631
|
-
/** The checked-dynamic declaration fallback for unmappable binding types
|
|
632
|
-
* (see irTypeOf), two gates over one story:
|
|
633
|
-
*
|
|
634
|
-
* JAVASCRIPT files: `any` and every other inference residue is the
|
|
635
|
-
* checked-dynamic 'unknown' kind, and array types keep their array-ness
|
|
636
|
-
* with the fallback applied to the ELEMENT (any[]/never[] evolving arrays
|
|
637
|
-
* become unknown[], so length/push/index still lower).
|
|
638
|
-
*
|
|
639
|
-
* TYPESCRIPT files: genuine checker-`any` residue ONLY — a bare `any`
|
|
640
|
-
* binding (`flags & Any`), or a single-call-signature function type whose
|
|
641
|
-
* only unmappable pieces are `any` (`(value: any) => value is string` —
|
|
642
|
-
* the arrow the binding holds lowers those params to dyn, so the binding
|
|
643
|
-
* keeps its func-ness with the same per-piece fallback). The honest
|
|
644
|
-
* static subset of `any` is a binding whose VALUES are dyn-representable:
|
|
645
|
-
* the binding is 'unknown' storage with the boundary conversions
|
|
646
|
-
* coerceToExpected already applies (dynFrom into the slot, validated
|
|
647
|
-
* dynCheck out) and per-site SC2011 fences for the operations the checked-dynamic tree
|
|
648
|
-
* cannot carry JS-exactly (the island still lifts those). Every OTHER
|
|
649
|
-
* unmappable TS type keeps its own diagnostic — annotations exist there,
|
|
650
|
-
* and the fence names the real blocker. `--dynamic` builds never reach
|
|
651
|
-
* this fallback for `any` (mapType answers jsval first).
|
|
652
|
-
*
|
|
653
|
-
* Null for void (no value exists to represent). */
|
|
654
513
|
export function dynFallbackType(lowerer, node, t) {
|
|
655
514
|
if (t.flags & ts.TypeFlags.Void)
|
|
656
515
|
return null;
|
|
@@ -806,10 +665,7 @@ function jsFallbackFunctionType(lowerer, node, t) {
|
|
|
806
665
|
const optional = decl !== undefined &&
|
|
807
666
|
ts.isParameter(decl) &&
|
|
808
667
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
809
|
-
if (optional &&
|
|
810
|
-
mapped.kind !== "dyn" &&
|
|
811
|
-
mapped.kind !== "jsval" &&
|
|
812
|
-
!lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
668
|
+
if (optional && mapped.kind !== "dyn" && !lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
813
669
|
mapped = lowerer.withUndefinedArm(mapped);
|
|
814
670
|
}
|
|
815
671
|
return mapped;
|
|
@@ -988,7 +844,6 @@ export class Lowerer {
|
|
|
988
844
|
program;
|
|
989
845
|
entry;
|
|
990
846
|
moduleOrder;
|
|
991
|
-
dynamic;
|
|
992
847
|
frontendServices;
|
|
993
848
|
checker;
|
|
994
849
|
diags = [];
|
|
@@ -1514,7 +1369,7 @@ export class Lowerer {
|
|
|
1514
1369
|
runtimeOptionalType(t) {
|
|
1515
1370
|
if (t.kind === "union")
|
|
1516
1371
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
1517
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
1372
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
1518
1373
|
return t;
|
|
1519
1374
|
return this.withUndefinedArm(t);
|
|
1520
1375
|
}
|
|
@@ -1618,6 +1473,9 @@ export class Lowerer {
|
|
|
1618
1473
|
/** Synthetic array-HOF loop functions (map/filter/forEach desugar),
|
|
1619
1474
|
* interned per method + element/callback-result type: key → fn name. */
|
|
1620
1475
|
arrHofHelpers = new Map();
|
|
1476
|
+
/** What each array-HOF helper computes, keyed by helper name: the chain
|
|
1477
|
+
* fusion pass reads it to recognize pipelines of helper calls. */
|
|
1478
|
+
arrHofInfo = new Map();
|
|
1621
1479
|
/** Per-arm calls through union-typed class receivers, interned by the
|
|
1622
1480
|
* receiver union, member, completed argument ABI, and result type. */
|
|
1623
1481
|
unionCallHelpers = new Map();
|
|
@@ -1770,43 +1628,21 @@ export class Lowerer {
|
|
|
1770
1628
|
* falls back through the shared node (collectGlobals registers both). */
|
|
1771
1629
|
globalsByDeclNode = new Map();
|
|
1772
1630
|
globalsList = [];
|
|
1773
|
-
/** npm-import init statements (--dynamic), keyed by file AND import
|
|
1774
|
-
* declaration: the island.import assignments/side-effect loads for that
|
|
1775
|
-
* statement. lowerFileInit splices them into the importing file's %init
|
|
1776
|
-
* header at the statement's position — Node evaluates each imported
|
|
1777
|
-
* module (island packages included) where the import appears, so an
|
|
1778
|
-
* `import "polyfill"` before an `import "./app.js"` runs the package
|
|
1779
|
-
* top-level BEFORE app's init, not after. */
|
|
1780
1631
|
npmInitActions = new Map();
|
|
1781
1632
|
/** Per-file %init PRELUDE statements for JSON imports: bakeable DATA
|
|
1782
1633
|
* assignments with no observable evaluation order of their own —
|
|
1783
1634
|
* prepended by lowerFileInit so the bindings are live before any
|
|
1784
1635
|
* top-level statement runs. */
|
|
1785
1636
|
jsonInitActions = new Map();
|
|
1786
|
-
/** The embedded npm runtime graph (collectNpmImports), attached to the
|
|
1787
|
-
* emitted module. Null without npm imports or without --dynamic. */
|
|
1788
|
-
npmEmbedded = null;
|
|
1789
|
-
npmBuiltins = null;
|
|
1790
|
-
npmLazyTraps = null;
|
|
1791
1637
|
/** Dynamic `import("literal")` resolutions, keyed
|
|
1792
1638
|
* `fileName\u0000specifier` (collectDynamicImports fills it during npm
|
|
1793
1639
|
* collection; lowerDynamicImportCall reads it per site). */
|
|
1794
1640
|
dynImports = new Map();
|
|
1795
|
-
/** createRequire-require resolutions of BARE npm specifiers, keyed
|
|
1796
|
-
* `fileName\u0000specifier` (collectCreateRequires fills it during npm
|
|
1797
|
-
* collection under --dynamic — the require-condition entry key plus its
|
|
1798
|
-
* embedded format; lowerCreateRequireCall reads it per site; "" marks a
|
|
1799
|
-
* failed resolution already reported at collection). */
|
|
1800
1641
|
createRequireImports = new Map();
|
|
1801
1642
|
/** Module → the name of its synthesized namespace-BUILDER function
|
|
1802
1643
|
* (lowerOwnModuleImport): every `import()` of the same program module
|
|
1803
1644
|
* shares one builder. */
|
|
1804
1645
|
dynNsBuilders = new Map();
|
|
1805
|
-
/** Parameters forced to the island-handle type (jsval) regardless of
|
|
1806
|
-
* their checker type: then-handler params whose settled value is an
|
|
1807
|
-
* engine handle (a dynamic import's namespace object) — paramShape's
|
|
1808
|
-
* early-out. */
|
|
1809
|
-
jsvalParamOverrides = new Set();
|
|
1810
1646
|
checkedCallbackParams = new Set();
|
|
1811
1647
|
/** Inline Promise.then parameters whose contextual type is a builtin
|
|
1812
1648
|
* module namespace anonymous object. The settled native token is the
|
|
@@ -1892,7 +1728,6 @@ export class Lowerer {
|
|
|
1892
1728
|
stats = {
|
|
1893
1729
|
statementsTotal: 0,
|
|
1894
1730
|
statementsFailed: 0,
|
|
1895
|
-
statementsIsland: 0,
|
|
1896
1731
|
functionsSkipped: 0,
|
|
1897
1732
|
};
|
|
1898
1733
|
/** Reachability edge sink: every resolution of
|
|
@@ -1946,6 +1781,9 @@ export class Lowerer {
|
|
|
1946
1781
|
* can contain any retained descendant, but importing its declaration
|
|
1947
1782
|
* alone does not make every descendant constructible. */
|
|
1948
1783
|
constructedClasses = null;
|
|
1784
|
+
/** Set while a subclass constructor's super() call notes its base
|
|
1785
|
+
* constructor edge: that edge does not instantiate the base exactly. */
|
|
1786
|
+
superConstructorEdge = false;
|
|
1949
1787
|
virtualEdges = new Map();
|
|
1950
1788
|
classCanBeConstructed(info) {
|
|
1951
1789
|
return (this.constructedClasses === null ||
|
|
@@ -2026,19 +1864,16 @@ export class Lowerer {
|
|
|
2026
1864
|
return;
|
|
2027
1865
|
let s = this.statsByFile.get(file);
|
|
2028
1866
|
if (!s)
|
|
2029
|
-
this.statsByFile.set(file, (s = { total: 0, failed: 0
|
|
1867
|
+
this.statsByFile.set(file, (s = { total: 0, failed: 0 }));
|
|
2030
1868
|
if (kind === "total")
|
|
2031
1869
|
s.total += 1;
|
|
2032
1870
|
else if (kind === "failed")
|
|
2033
1871
|
s.failed += 1;
|
|
2034
|
-
else
|
|
2035
|
-
s.island += 1;
|
|
2036
1872
|
}
|
|
2037
|
-
constructor(program, entry, moduleOrder,
|
|
1873
|
+
constructor(program, entry, moduleOrder, mode = {}) {
|
|
2038
1874
|
this.program = program;
|
|
2039
1875
|
this.entry = entry;
|
|
2040
1876
|
this.moduleOrder = moduleOrder;
|
|
2041
|
-
this.dynamic = dynamic;
|
|
2042
1877
|
this.frontendServices = mode.frontendServices;
|
|
2043
1878
|
this.reachable = mode.reachable ?? null;
|
|
2044
1879
|
this.remainder = mode.remainder ?? false;
|
|
@@ -2121,7 +1956,6 @@ export class Lowerer {
|
|
|
2121
1956
|
isStdlibFile: this.isStdlibFile,
|
|
2122
1957
|
isNpmFile: this.isNpmFile,
|
|
2123
1958
|
isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
|
|
2124
|
-
dynamic: this.dynamic,
|
|
2125
1959
|
typeMemo: this.typeMemo,
|
|
2126
1960
|
canMemoizeType: () => this.typeParamBindings === null &&
|
|
2127
1961
|
this.typeParamTsBindings === null &&
|
|
@@ -3135,7 +2969,6 @@ export class Lowerer {
|
|
|
3135
2969
|
const signatureBySymbol = new Map();
|
|
3136
2970
|
const methodFamilies = new Map();
|
|
3137
2971
|
const familyBySymbol = new Map();
|
|
3138
|
-
const optionalMethodFamilies = new Set();
|
|
3139
2972
|
for (const [symbol, sig] of this.fnSigsBySymbol)
|
|
3140
2973
|
signatureBySymbol.set(symbol, { params: sig.params, returnType: sig.returnType, top: sig });
|
|
3141
2974
|
for (const decl of fnDecls) {
|
|
@@ -3310,7 +3143,6 @@ export class Lowerer {
|
|
|
3310
3143
|
if (!element ||
|
|
3311
3144
|
element.kind === "void" ||
|
|
3312
3145
|
element.kind === "dyn" ||
|
|
3313
|
-
element.kind === "jsval" ||
|
|
3314
3146
|
element.kind === "generator")
|
|
3315
3147
|
return null;
|
|
3316
3148
|
return e;
|
|
@@ -3344,12 +3176,12 @@ export class Lowerer {
|
|
|
3344
3176
|
return false;
|
|
3345
3177
|
const object = init.arguments[0];
|
|
3346
3178
|
const objectType = object ? this.mapTypeOf(this.typeOf(object)) : null;
|
|
3347
|
-
return objectType?.kind === "dyn"
|
|
3179
|
+
return objectType?.kind === "dyn";
|
|
3348
3180
|
};
|
|
3349
3181
|
const addUndefined = (t) => {
|
|
3350
3182
|
if (t.kind === "union")
|
|
3351
3183
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
3352
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
3184
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
3353
3185
|
return t;
|
|
3354
3186
|
return this.withUndefinedArm(t);
|
|
3355
3187
|
};
|
|
@@ -3427,6 +3259,11 @@ export class Lowerer {
|
|
|
3427
3259
|
const symbol = symbolOf(e.name);
|
|
3428
3260
|
if (symbol && optionalSymbols.has(symbol))
|
|
3429
3261
|
return true;
|
|
3262
|
+
// A getter read is a call of its body.
|
|
3263
|
+
if (symbol &&
|
|
3264
|
+
(symbol.flags & ts.SymbolFlags.GetAccessor) !== 0 &&
|
|
3265
|
+
optionalReturns.has(symbol))
|
|
3266
|
+
return true;
|
|
3430
3267
|
}
|
|
3431
3268
|
if (ts.isCallExpression(e) && ts.isIdentifier(e.expression)) {
|
|
3432
3269
|
const symbol = callableSymbolOf(e.expression);
|
|
@@ -3501,6 +3338,27 @@ export class Lowerer {
|
|
|
3501
3338
|
return null;
|
|
3502
3339
|
return { kind: "union", unionId: this.unions.intern([F64, STRING]) };
|
|
3503
3340
|
};
|
|
3341
|
+
/** The union of primitive result types, or null when any is missing or
|
|
3342
|
+
* not a number, string or boolean (or a union of them). */
|
|
3343
|
+
const joinPrimitiveTypes = (types) => {
|
|
3344
|
+
const arms = new Map();
|
|
3345
|
+
for (const type of types) {
|
|
3346
|
+
if (!type)
|
|
3347
|
+
return null;
|
|
3348
|
+
const parts = type.kind === "union" ? this.unions.get(type.unionId)?.arms : [type];
|
|
3349
|
+
if (!parts)
|
|
3350
|
+
return null;
|
|
3351
|
+
for (const arm of parts) {
|
|
3352
|
+
if (arm.kind !== "f64" && arm.kind !== "string" && arm.kind !== "bool")
|
|
3353
|
+
return null;
|
|
3354
|
+
arms.set(typeKey(arm), arm);
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
const sorted = [...arms.entries()].sort(([a], [b]) => (a < b ? -1 : 1)).map(([, t]) => t);
|
|
3358
|
+
if (sorted.length === 1)
|
|
3359
|
+
return sorted[0];
|
|
3360
|
+
return { kind: "union", unionId: this.unions.intern(sorted) };
|
|
3361
|
+
};
|
|
3504
3362
|
const noteField = (decl, name) => {
|
|
3505
3363
|
if (!ts.isIdentifier(decl.name))
|
|
3506
3364
|
return false;
|
|
@@ -3591,10 +3449,7 @@ export class Lowerer {
|
|
|
3591
3449
|
// checker. The array's element ABI describes every value a
|
|
3592
3450
|
// position may hold after that call, so bind from that type.
|
|
3593
3451
|
const mapped = sourceType.elem;
|
|
3594
|
-
if (mapped &&
|
|
3595
|
-
mapped.kind !== "void" &&
|
|
3596
|
-
mapped.kind !== "dyn" &&
|
|
3597
|
-
mapped.kind !== "jsval") {
|
|
3452
|
+
if (mapped && mapped.kind !== "void" && mapped.kind !== "dyn") {
|
|
3598
3453
|
const widened = mapped.kind === "union"
|
|
3599
3454
|
? this.withUndefinedArmOf(mapped)
|
|
3600
3455
|
: this.withUndefinedArm(mapped);
|
|
@@ -3961,7 +3816,7 @@ export class Lowerer {
|
|
|
3961
3816
|
if (mapped?.kind === "promise")
|
|
3962
3817
|
mapped = mapped.inner;
|
|
3963
3818
|
const anyElements = mapped?.kind === "array"
|
|
3964
|
-
? mapped.elem.kind === "dyn"
|
|
3819
|
+
? mapped.elem.kind === "dyn"
|
|
3965
3820
|
: mapped === null &&
|
|
3966
3821
|
this.checker.isArrayType(checkerType) &&
|
|
3967
3822
|
!this.checker.isTupleType(checkerType) &&
|
|
@@ -4141,7 +3996,6 @@ export class Lowerer {
|
|
|
4141
3996
|
mapped.kind === "record" ||
|
|
4142
3997
|
mapped.kind === "object" ||
|
|
4143
3998
|
mapped.kind === "dyn" ||
|
|
4144
|
-
mapped.kind === "jsval" ||
|
|
4145
3999
|
mapped.kind === "union");
|
|
4146
4000
|
},
|
|
4147
4001
|
restKeys: (call) => {
|
|
@@ -4512,9 +4366,6 @@ export class Lowerer {
|
|
|
4512
4366
|
if (arg &&
|
|
4513
4367
|
(this.typeOf(arg).flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Void)) === 0)
|
|
4514
4368
|
continue;
|
|
4515
|
-
const family = familyBySymbol.get(symbol);
|
|
4516
|
-
if (family)
|
|
4517
|
-
optionalMethodFamilies.add(family);
|
|
4518
4369
|
for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
|
|
4519
4370
|
const shape = signatureBySymbol.get(target)?.params[i];
|
|
4520
4371
|
if (!shape || shape.mode !== "required")
|
|
@@ -4539,10 +4390,7 @@ export class Lowerer {
|
|
|
4539
4390
|
}
|
|
4540
4391
|
}
|
|
4541
4392
|
}
|
|
4542
|
-
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" ||
|
|
4543
|
-
shape.mode === "dynRest" ||
|
|
4544
|
-
shape.mode === "islandRest" ||
|
|
4545
|
-
shape.mode === "arguments");
|
|
4393
|
+
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" || shape.mode === "dynRest" || shape.mode === "arguments");
|
|
4546
4394
|
node.arguments.forEach((arg, argumentIndex) => {
|
|
4547
4395
|
const i = restAt >= 0 && argumentIndex >= restAt ? restAt : argumentIndex;
|
|
4548
4396
|
const shape = sig.params[i];
|
|
@@ -4634,8 +4482,6 @@ export class Lowerer {
|
|
|
4634
4482
|
// Promote every implementation and its parameter bindings so
|
|
4635
4483
|
// downstream calls and returns see the same optional value.
|
|
4636
4484
|
const family = familyBySymbol.get(symbol);
|
|
4637
|
-
if (family)
|
|
4638
|
-
optionalMethodFamilies.add(family);
|
|
4639
4485
|
for (const target of family ?? [symbol]) {
|
|
4640
4486
|
const parameterShape = signatureBySymbol.get(target)?.params[i];
|
|
4641
4487
|
if (!parameterShape)
|
|
@@ -4762,18 +4608,35 @@ export class Lowerer {
|
|
|
4762
4608
|
changed = true;
|
|
4763
4609
|
}
|
|
4764
4610
|
}
|
|
4765
|
-
// Every implementation of a virtual slot must retain the same ABI
|
|
4766
|
-
//
|
|
4767
|
-
|
|
4768
|
-
|
|
4611
|
+
// Every implementation of a virtual slot must retain the same ABI:
|
|
4612
|
+
// when one body can return undefined at runtime (an unchecked element
|
|
4613
|
+
// read, a forwarded omitted parameter), the abstract or base
|
|
4614
|
+
// declaration and every override return the widened type too.
|
|
4615
|
+
for (const family of methodFamilies.values()) {
|
|
4616
|
+
if (family.length < 2)
|
|
4769
4617
|
continue;
|
|
4770
|
-
|
|
4618
|
+
const optional = family.some((symbol) => optionalReturns.has(symbol));
|
|
4619
|
+
for (const symbol of optional ? family : []) {
|
|
4771
4620
|
if (!optionalReturns.has(symbol)) {
|
|
4772
4621
|
optionalReturns.add(symbol);
|
|
4773
4622
|
provenance?.note("return", functionDeclBySymbol.get(symbol), undefined, "(override family)");
|
|
4774
4623
|
changed = true;
|
|
4775
4624
|
}
|
|
4776
4625
|
}
|
|
4626
|
+
// A primitive-widened result (`names[i] + 1` is NaN for a missing
|
|
4627
|
+
// string) likewise becomes the slot's result for every member.
|
|
4628
|
+
if (!family.some((symbol) => arithmeticReturns.has(symbol)))
|
|
4629
|
+
continue;
|
|
4630
|
+
const joined = joinPrimitiveTypes(family.map((symbol) => arithmeticReturns.get(symbol) ?? signatureBySymbol.get(symbol)?.returnType));
|
|
4631
|
+
if (!joined)
|
|
4632
|
+
continue;
|
|
4633
|
+
for (const symbol of family) {
|
|
4634
|
+
const previous = arithmeticReturns.get(symbol);
|
|
4635
|
+
if (previous && typeEquals(previous, joined))
|
|
4636
|
+
continue;
|
|
4637
|
+
arithmeticReturns.set(symbol, joined);
|
|
4638
|
+
changed = true;
|
|
4639
|
+
}
|
|
4777
4640
|
}
|
|
4778
4641
|
}
|
|
4779
4642
|
// NaN-coded slots convert optional values on entry instead of holding
|
|
@@ -5038,8 +4901,7 @@ export class Lowerer {
|
|
|
5038
4901
|
}
|
|
5039
4902
|
}
|
|
5040
4903
|
// Each file's top-level statements form its run-once init function.
|
|
5041
|
-
// %main calls only the
|
|
5042
|
-
// runs its dependencies (npm island loads at their import positions),
|
|
4904
|
+
// %main calls only the entry's init. Hoisted imports call their inits;
|
|
5043
4905
|
// inline require statements call theirs mid-body, and the guards make
|
|
5044
4906
|
// revisits cache hits — Node's evaluation order over the WHOLE graph
|
|
5045
4907
|
// falls out of the nesting. The coverage remainder skips them — they
|
|
@@ -5111,7 +4973,7 @@ export class Lowerer {
|
|
|
5111
4973
|
!this.remainder &&
|
|
5112
4974
|
classDispatch.process(this, [...functions, ...this.liftedFns, ...this.implicitFns]);
|
|
5113
4975
|
}
|
|
5114
|
-
classDispatch.finalize();
|
|
4976
|
+
classDispatch.finalize(this);
|
|
5115
4977
|
}
|
|
5116
4978
|
// Lambdas lifted while lowering any of the above (plus synthetic
|
|
5117
4979
|
// array-HOF loop functions, which ride the same list), and the
|
|
@@ -5135,8 +4997,6 @@ export class Lowerer {
|
|
|
5135
4997
|
stats: this.stats,
|
|
5136
4998
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5137
4999
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5138
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5139
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5140
5000
|
};
|
|
5141
5001
|
}
|
|
5142
5002
|
return this.finishModule(functions);
|
|
@@ -5144,6 +5004,8 @@ export class Lowerer {
|
|
|
5144
5004
|
/** Final retention, pruning, and module assembly shared by ordinary emit
|
|
5145
5005
|
* and the retained reachability worklist. */
|
|
5146
5006
|
finishModule(functions) {
|
|
5007
|
+
if (this.diags.length === 0)
|
|
5008
|
+
fuseArrayPipelines(this, functions);
|
|
5147
5009
|
finalizeClassMethodValues(this, functions);
|
|
5148
5010
|
trackClassFieldCreation(this, functions);
|
|
5149
5011
|
// Globals typed by a class that never REGISTERED (a JS class whose
|
|
@@ -5236,14 +5098,13 @@ export class Lowerer {
|
|
|
5236
5098
|
const module = this.diags.length > 0
|
|
5237
5099
|
? null
|
|
5238
5100
|
: {
|
|
5239
|
-
irVersion:
|
|
5101
|
+
irVersion: 16,
|
|
5240
5102
|
sourceFile: this.entry.fileName,
|
|
5241
5103
|
functions,
|
|
5242
5104
|
classes: artifacts.classes,
|
|
5243
5105
|
records: artifacts.records,
|
|
5244
5106
|
unions: artifacts.unions,
|
|
5245
5107
|
globals: this.globalsList,
|
|
5246
|
-
...(this.npmEmbedded ? { embedded: this.npmEmbedded } : {}),
|
|
5247
5108
|
entry: ENTRY_NAME,
|
|
5248
5109
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
5249
5110
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
@@ -5260,8 +5121,6 @@ export class Lowerer {
|
|
|
5260
5121
|
stats: this.stats,
|
|
5261
5122
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5262
5123
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5263
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5264
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5265
5124
|
};
|
|
5266
5125
|
}
|
|
5267
5126
|
/** True when `t` (recursively) names a class instance type with no
|
|
@@ -5531,11 +5390,17 @@ export class Lowerer {
|
|
|
5531
5390
|
};
|
|
5532
5391
|
const reachable = new Set();
|
|
5533
5392
|
this.constructedClasses = new Set();
|
|
5393
|
+
// Every constructor edge except super() may create an instance of
|
|
5394
|
+
// exactly that class (`new C`, class values, library roots, dynamic
|
|
5395
|
+
// construction, ...).
|
|
5396
|
+
const instantiated = new Set();
|
|
5534
5397
|
const queue = [];
|
|
5535
5398
|
const loweredUnits = new Map();
|
|
5536
5399
|
const initFunctions = [];
|
|
5537
5400
|
const instanceFunctions = [];
|
|
5538
5401
|
this.onEdge = (name) => {
|
|
5402
|
+
if (!this.superConstructorEdge && name.endsWith(".constructor"))
|
|
5403
|
+
instantiated.add(name.slice(1, -".constructor".length));
|
|
5539
5404
|
if (reachable.has(name))
|
|
5540
5405
|
return;
|
|
5541
5406
|
reachable.add(name);
|
|
@@ -5723,7 +5588,7 @@ export class Lowerer {
|
|
|
5723
5588
|
this.restoreGenericInstanceOrder(instLowered);
|
|
5724
5589
|
this.restoreGenericClassInstanceOrder(clsInstLowered);
|
|
5725
5590
|
}
|
|
5726
|
-
classDispatch.finalize();
|
|
5591
|
+
classDispatch.finalize(this);
|
|
5727
5592
|
const orderedUnits = [...loweredUnits]
|
|
5728
5593
|
.sort(([left], [right]) => units.get(left).order - units.get(right).order)
|
|
5729
5594
|
.map(([, fn]) => fn);
|
|
@@ -5741,35 +5606,14 @@ export class Lowerer {
|
|
|
5741
5606
|
...this.liftedFns,
|
|
5742
5607
|
...this.implicitFns,
|
|
5743
5608
|
];
|
|
5744
|
-
// The worklist can leave a virtual site with
|
|
5609
|
+
// The worklist can leave a virtual site with a single implementation.
|
|
5745
5610
|
// Devirtualize after construction/override reachability has settled.
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
const info = this.classes.get(expression.className);
|
|
5753
|
-
const method = info && this.findMethodOn(info, expression.method);
|
|
5754
|
-
if (!method ||
|
|
5755
|
-
method.sig.abstract ||
|
|
5756
|
-
[...this.classes.values()].some((candidate) => this.isSubclassOf(candidate.def.name, expression.className) &&
|
|
5757
|
-
candidate.def.name !== expression.className &&
|
|
5758
|
-
candidate.methods.has(expression.method) &&
|
|
5759
|
-
reachable.has(`%${candidate.def.name}.${expression.method}`)))
|
|
5760
|
-
return expression;
|
|
5761
|
-
return {
|
|
5762
|
-
kind: "call",
|
|
5763
|
-
callee: `%${method.declarer.def.name}.${expression.method}`,
|
|
5764
|
-
args: [
|
|
5765
|
-
this.upcastTo(expression.args[0], method.declarer.def.name),
|
|
5766
|
-
...expression.args.slice(1),
|
|
5767
|
-
],
|
|
5768
|
-
type: expression.type,
|
|
5769
|
-
loc: expression.loc,
|
|
5770
|
-
};
|
|
5771
|
-
},
|
|
5772
|
-
});
|
|
5611
|
+
devirtualizeVirtualCalls(this, functions, {
|
|
5612
|
+
reachable,
|
|
5613
|
+
instantiated,
|
|
5614
|
+
library: extraRoots !== undefined,
|
|
5615
|
+
files: parts.map((fp) => fp.sf),
|
|
5616
|
+
});
|
|
5773
5617
|
this.reachableForArtifacts = reachable;
|
|
5774
5618
|
return { reachable, result: this.finishModule(functions) };
|
|
5775
5619
|
}
|
|
@@ -5779,6 +5623,17 @@ export class Lowerer {
|
|
|
5779
5623
|
if (this.onEdge)
|
|
5780
5624
|
this.onEdge(name);
|
|
5781
5625
|
}
|
|
5626
|
+
/** A subclass constructor's super() edge: the base constructor runs, but
|
|
5627
|
+
* no instance of exactly the base class is created. */
|
|
5628
|
+
noteSuperConstructorEdge(name) {
|
|
5629
|
+
this.superConstructorEdge = true;
|
|
5630
|
+
try {
|
|
5631
|
+
this.noteEdge(name);
|
|
5632
|
+
}
|
|
5633
|
+
finally {
|
|
5634
|
+
this.superConstructorEdge = false;
|
|
5635
|
+
}
|
|
5636
|
+
}
|
|
5782
5637
|
/** Discovery hook for virtual dispatch: a virtualCall on `info`'s static
|
|
5783
5638
|
* class reaches the nearest declaration at/above it plus every override
|
|
5784
5639
|
* on a STRICT descendant (receivers of sibling branches can't flow into
|
|
@@ -5903,22 +5758,13 @@ export class Lowerer {
|
|
|
5903
5758
|
? `values from the '${specifier}' external host module (types supplied by --external-types, but no runtime implementation or scriptc lowering was provided)`
|
|
5904
5759
|
: `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`);
|
|
5905
5760
|
}
|
|
5906
|
-
/** The dynamic-family fence for an OPERATION on an `any`-origin
|
|
5907
|
-
* checked-dynamic value that only the engine can execute (operators,
|
|
5908
|
-
* iteration, computed member names, ...). Carries SC2011 — the same
|
|
5909
|
-
* code as the `any` type fence — so the coverage report groups it with
|
|
5910
|
-
* the dynamic-capable family and the two-tier retry knows the island
|
|
5911
|
-
* lifts the site. Use exactly when the blocking operand IS dyn-typed
|
|
5912
|
-
* and its checker type is `any`-flavored; genuine `unknown` keeps the
|
|
5913
|
-
* SC1100-family fences (tsc constrains what unknown can do, so those
|
|
5914
|
-
* sites are checker-error territory, not engine territory). */
|
|
5915
5761
|
anyOpFence(feature, node) {
|
|
5916
|
-
this.pushDiag(
|
|
5762
|
+
this.pushDiag(unsupportedAnyOperationDiag(feature, locOf(node)));
|
|
5917
5763
|
throw new PoisonError();
|
|
5918
5764
|
}
|
|
5919
5765
|
/** True when this expression's CHECKER type is `any`-flavored — the
|
|
5920
5766
|
* gate anyOpFence's call sites use to tell `any`-origin dyn values
|
|
5921
|
-
*
|
|
5767
|
+
* with an unsupported operation from genuine `unknown` ones. */
|
|
5922
5768
|
anyOrigin(node) {
|
|
5923
5769
|
return (this.typeOf(node).flags & ts.TypeFlags.Any) !== 0;
|
|
5924
5770
|
}
|
|
@@ -5940,11 +5786,10 @@ export class Lowerer {
|
|
|
5940
5786
|
// SC2012 rather than the generic supported-types recitation. Native
|
|
5941
5787
|
// fetch values map earlier to checked-dynamic handles and do not reach
|
|
5942
5788
|
// here; constructor objects such as Headers still can.
|
|
5943
|
-
if (
|
|
5944
|
-
typeSym &&
|
|
5945
|
-
ISLAND_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5789
|
+
if (typeSym &&
|
|
5790
|
+
FETCH_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5946
5791
|
this.isStdlibSymbol(typeSym)) {
|
|
5947
|
-
this.pushDiag(
|
|
5792
|
+
this.pushDiag(unsupportedNativeApiDiag(`a value of type '${typeSym.name}'`, locOf(node)));
|
|
5948
5793
|
throw new PoisonError();
|
|
5949
5794
|
}
|
|
5950
5795
|
// ENUM OBJECTS (`typeof e` — a numeric enum's type carries the
|
|
@@ -5983,30 +5828,14 @@ export class Lowerer {
|
|
|
5983
5828
|
this.pushDiag(noLoweringDiag(this.checker.typeToString(type), locOf(node)));
|
|
5984
5829
|
throw new PoisonError();
|
|
5985
5830
|
}
|
|
5986
|
-
// The MEASURED island probe, same mechanism as the general dynamic
|
|
5987
|
-
// reroute below: an index-signature shape the dynamic mapping
|
|
5988
|
-
// accepts (an `any`-valued signature absorbing into an island
|
|
5989
|
-
// object, jsval-entangled members) reports the retry-eligible
|
|
5990
|
-
// SC2011 choice instead of the static recitation.
|
|
5991
|
-
if (!this.dynamic &&
|
|
5992
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
5993
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
5994
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5995
|
-
throw new PoisonError();
|
|
5996
|
-
}
|
|
5997
5831
|
this.pushDiag(indexSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5998
5832
|
throw new PoisonError();
|
|
5999
5833
|
}
|
|
6000
|
-
//
|
|
6001
|
-
|
|
6002
|
-
// report's one-line-per-package attribution). Under --dynamic these
|
|
6003
|
-
// types map to jsval, so reaching here means the type is genuinely
|
|
6004
|
-
// unrepresentable (a jsval union arm, a jsval array element) — the
|
|
6005
|
-
// generic type message tells that story better.
|
|
6006
|
-
if (!this.dynamic) {
|
|
5834
|
+
// Attribute an unsupported package type to its package.
|
|
5835
|
+
{
|
|
6007
5836
|
const pkg = this.npmPackageOf(widened);
|
|
6008
5837
|
if (pkg) {
|
|
6009
|
-
this.pushDiag(
|
|
5838
|
+
this.pushDiag(unsupportedPackageValueDiag(pkg, locOf(node)));
|
|
6010
5839
|
throw new PoisonError();
|
|
6011
5840
|
}
|
|
6012
5841
|
}
|
|
@@ -6023,24 +5852,6 @@ export class Lowerer {
|
|
|
6023
5852
|
throw new PoisonError();
|
|
6024
5853
|
}
|
|
6025
5854
|
}
|
|
6026
|
-
// A type the DYNAMIC mapping accepts (`any[]`, records/functions with
|
|
6027
|
-
// `any`-typed members, .d.ts-declared shapes whose values are island
|
|
6028
|
-
// handles): the honest per-site story is the dynamic-family choice, not
|
|
6029
|
-
// the supported-types recitation — proved by re-running mapType with
|
|
6030
|
-
// `dynamic: true`, never guessed from the type text. Probing is safe
|
|
6031
|
-
// here: a diagnostic means this build already failed, so anything the
|
|
6032
|
-
// probe interns or registers on the way is never emitted. Checked LAST
|
|
6033
|
-
// so every more specific story above (island ambients, index
|
|
6034
|
-
// signatures, per-package attribution, generic signatures) keeps its
|
|
6035
|
-
// own fence class. Bare `any` is excepted: unsupportedTypeDiag's own
|
|
6036
|
-
// SC2011 arm tells that story with the stronger stay-static remedy
|
|
6037
|
-
// ('unknown' + a checked cast).
|
|
6038
|
-
if (!this.dynamic &&
|
|
6039
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
6040
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
6041
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
6042
|
-
throw new PoisonError();
|
|
6043
|
-
}
|
|
6044
5855
|
// STANDARD-LIBRARY nominal provenance, decided once: interface/class
|
|
6045
5856
|
// declarations in the lib's own files (Date, ArrayBuffer, WeakMap, the
|
|
6046
5857
|
// iterator/constructor interfaces). Such types report the SC2020 story
|
|
@@ -6147,12 +5958,6 @@ export class Lowerer {
|
|
|
6147
5958
|
fenceFetchObjectAssignment(target, source) {
|
|
6148
5959
|
return fenceFetchObjectAssignment(this, target, source);
|
|
6149
5960
|
}
|
|
6150
|
-
lowerDynamicHeadersIteratorCall(call, access) {
|
|
6151
|
-
return lowerDynamicHeadersIteratorCall(this, call, access);
|
|
6152
|
-
}
|
|
6153
|
-
lowerDynamicHeadersSpread(node, type) {
|
|
6154
|
-
return lowerDynamicHeadersSpread(this, node, type);
|
|
6155
|
-
}
|
|
6156
5961
|
fenceStaticReadableStreamMember(access, use) {
|
|
6157
5962
|
return fenceStaticReadableStreamMember(this, access, use);
|
|
6158
5963
|
}
|
|
@@ -6344,23 +6149,6 @@ export class Lowerer {
|
|
|
6344
6149
|
bareUndefinedArmedUnion(t) {
|
|
6345
6150
|
return isUndefinedArmedUnion(t, (id) => this.unions.get(id));
|
|
6346
6151
|
}
|
|
6347
|
-
/** canCrossIslandBoundary with this Lowerer's registries — THE test
|
|
6348
|
-
* behind every marshal/exit decision (the implicit coercions, jsvalIn,
|
|
6349
|
-
* the checked island-exit cast). Rejections that follow a false answer
|
|
6350
|
-
* speak through boundaryIntoIslandMsg / boundaryOutOfIslandMsg. */
|
|
6351
|
-
boundarySafe(t) {
|
|
6352
|
-
return canCrossIslandBoundary(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6353
|
-
}
|
|
6354
|
-
/** canExitIslandToType with this Lowerer's registries — the EXIT
|
|
6355
|
-
* direction's slightly wider test (bare undefined-armed unions of
|
|
6356
|
-
* JSON-safe data arms exit; the engine's undefined takes the undefined
|
|
6357
|
-
* arm before the JSON round trip). */
|
|
6358
|
-
boundaryExitSafe(t) {
|
|
6359
|
-
return canExitIslandToType(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6360
|
-
}
|
|
6361
|
-
isIslandExpr(node) {
|
|
6362
|
-
return isIslandExpr(this, node);
|
|
6363
|
-
}
|
|
6364
6152
|
/** True when this node's CHECKER type is proven `any[]`/`unknown[]`,
|
|
6365
6153
|
* directly or through the intersection tsc builds for a readonly tuple
|
|
6366
6154
|
* union (`(Model | readonly [Model, Command]) & any[]`; TS7 distributes
|
|
@@ -6492,14 +6280,6 @@ export class Lowerer {
|
|
|
6492
6280
|
}
|
|
6493
6281
|
this.unsupported("SC1101", node);
|
|
6494
6282
|
}
|
|
6495
|
-
// jsval mismatches surviving coerceToExpected involve a type with no
|
|
6496
|
-
// island representation (in) or no validated exit (out).
|
|
6497
|
-
if (actual.kind === "jsval") {
|
|
6498
|
-
this.unsupported("SC1090", node, boundaryOutOfIslandMsg(this.fmt(expected)));
|
|
6499
|
-
}
|
|
6500
|
-
if (expected.kind === "jsval") {
|
|
6501
|
-
this.unsupported("SC1090", node, boundaryIntoIslandMsg(this.fmt(actual)));
|
|
6502
|
-
}
|
|
6503
6283
|
// Class-value mismatches: the pointed stories — a widening whose
|
|
6504
6284
|
// constructor ABIs differ (construction through the slot would
|
|
6505
6285
|
// dispatch a mismatched signature), or a structural flow between
|
|
@@ -6648,98 +6428,12 @@ export class Lowerer {
|
|
|
6648
6428
|
if (adapted)
|
|
6649
6429
|
return adapted;
|
|
6650
6430
|
}
|
|
6651
|
-
// Island boundary, both directions. IN: any static value flowing into
|
|
6652
6431
|
// an any-typed slot marshals implicitly (tsc allows the assignment;
|
|
6653
6432
|
// the marshal is where its semantics live). OUT: an 'any' value
|
|
6654
6433
|
// flowing into a typed slot compiles to a VALIDATED exit — like every
|
|
6655
6434
|
// dyn→static edge, trust-but-verify: a lying `any` throws a catchable
|
|
6656
6435
|
// TypeError instead of corrupting memory (SEMANTICS.md). Unmarshalable
|
|
6657
6436
|
// and unextractable types fall through to requireExactShape's fences.
|
|
6658
|
-
if (expected.kind === "jsval" && expr.type.kind !== "jsval") {
|
|
6659
|
-
// Bare unit literals: the engine's own undefined/null (units have no
|
|
6660
|
-
// other producers, so dropping the operand loses nothing).
|
|
6661
|
-
if (isUnitType(expr.type)) {
|
|
6662
|
-
return {
|
|
6663
|
-
kind: "jsOp",
|
|
6664
|
-
op: expr.type.kind === "undefinedT" ? "undefLit" : "nullLit",
|
|
6665
|
-
args: [],
|
|
6666
|
-
type: JSVAL,
|
|
6667
|
-
loc: expr.loc,
|
|
6668
|
-
};
|
|
6669
|
-
}
|
|
6670
|
-
// A CHECKED-DYNAMIC (dyn/'unknown') value entering the island (the
|
|
6671
|
-
// `isJson ? JSON.parse(text) : islandParser(text)` config ternary):
|
|
6672
|
-
// the dyn tree deep-copies into engine values — data kinds only; a
|
|
6673
|
-
// dyn carrying a boxed function/handle/promise throws the catchable
|
|
6674
|
-
// TypeError at runtime (trust-but-verify, like every boundary).
|
|
6675
|
-
if (expr.type.kind === "dyn") {
|
|
6676
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6677
|
-
}
|
|
6678
|
-
if (this.boundarySafe(expr.type)) {
|
|
6679
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6680
|
-
}
|
|
6681
|
-
// Closures cross as host functions when their signature marshals —
|
|
6682
|
-
// the same shapes jsvalIn admits at call arguments (`const f: any =
|
|
6683
|
-
// (x: number) => x * 3` is the declaration-slot spelling of the
|
|
6684
|
-
// package-callback pattern).
|
|
6685
|
-
if (expr.type.kind === "func" &&
|
|
6686
|
-
canMarshalTypedFuncIntoIsland(expr.type, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
|
|
6687
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6688
|
-
}
|
|
6689
|
-
// jsval-BEARING composites (a record holding `any` fields, an array
|
|
6690
|
-
// of such records) have no JSON marshal but an honest per-field
|
|
6691
|
-
// island construction — see jsvalLiftExpr.
|
|
6692
|
-
if (this.jsvalLiftable(expr.type)) {
|
|
6693
|
-
return this.jsvalLiftExpr(expr, expr.loc);
|
|
6694
|
-
}
|
|
6695
|
-
// A RegExp flowing into an 'any' slot: the fresh-engine-RegExp
|
|
6696
|
-
// rebuild (see jsvalIn's regex rule); computed regex values fall
|
|
6697
|
-
// through to requireExactShape's fence.
|
|
6698
|
-
if (expr.type.kind === "regex") {
|
|
6699
|
-
const re = islandRegexpOf(expr);
|
|
6700
|
-
if (re)
|
|
6701
|
-
return re;
|
|
6702
|
-
}
|
|
6703
|
-
return expr;
|
|
6704
|
-
}
|
|
6705
|
-
if (expr.type.kind === "jsval" && expected.kind !== "jsval") {
|
|
6706
|
-
// The jsval→dyn crossing (the world unification's engine-handle
|
|
6707
|
-
// kind): an 'any'-typed engine value flowing into an 'unknown'/
|
|
6708
|
-
// 'object'/JS-residue slot wraps BY REFERENCE as the checked-dynamic tree's island
|
|
6709
|
-
// kind — engine scalars normalize to native dyn kinds at wrap time,
|
|
6710
|
-
// typeof/truthiness/String()/=== route to the engine, un-armed dyn
|
|
6711
|
-
// walks fence loudly, and the value unwraps back identity-preserved
|
|
6712
|
-
// (scr_jsval_from_dyn). Monotone under evolution/widening: a value
|
|
6713
|
-
// wraps once at its first dyn edge and stays valid through every
|
|
6714
|
-
// subsequent dyn slot; narrowing never changes representation.
|
|
6715
|
-
// This wrap RETIRES the silent-wrong-answer fence-closure box for
|
|
6716
|
-
// jsval members of dyn object literals (lowerDynObjectLiteral's
|
|
6717
|
-
// coercion lands here first).
|
|
6718
|
-
if (expected.kind === "dyn") {
|
|
6719
|
-
return { kind: "dynFromJsval", value: expr, type: DYN, loc: expr.loc };
|
|
6720
|
-
}
|
|
6721
|
-
// An island value flowing into a PROMISE-typed slot (the inferred
|
|
6722
|
-
// `loadPlugins` return — `Promise.all(...)` lowered engine-side
|
|
6723
|
-
// against a Promise<any[]> inference): the island→static promise
|
|
6724
|
-
// bridge — the engine promise settles a fresh static promise (void
|
|
6725
|
-
// fulfillments drop, `any[]`-declared fulfillments exit
|
|
6726
|
-
// Array.isArray-gated by reference at the settle, 'any' parks as an
|
|
6727
|
-
// island handle). Only inner shapes the bridge can deliver take the
|
|
6728
|
-
// arm; the rest keep the exit fence with the type named.
|
|
6729
|
-
if (expected.kind === "promise" &&
|
|
6730
|
-
(expected.inner.kind === "void" ||
|
|
6731
|
-
expected.inner.kind === "jsval" ||
|
|
6732
|
-
(expected.inner.kind === "array" && expected.inner.elem.kind === "jsval"))) {
|
|
6733
|
-
return { kind: "jsBridgePromise", value: expr, type: expected, loc: expr.loc };
|
|
6734
|
-
}
|
|
6735
|
-
// The exit set: everything round-trippable, plus bare undefined-armed
|
|
6736
|
-
// unions of JSON-safe data arms (the engine's undefined takes the
|
|
6737
|
-
// undefined arm before the JSON detour) — canExitIslandToType.
|
|
6738
|
-
if (this.boundaryExitSafe(expected)) {
|
|
6739
|
-
return { kind: "jsExit", value: expr, type: expected, loc: expr.loc };
|
|
6740
|
-
}
|
|
6741
|
-
return expr;
|
|
6742
|
-
}
|
|
6743
6437
|
// A TYPED value flowing into an 'unknown' slot (`const u: unknown = 5`,
|
|
6744
6438
|
// an unknown-typed param/return, a dyn-valued index slot): the
|
|
6745
6439
|
// static→dyn conversion — dynFrom, a DEEP COPY (the jsMarshal aliasing
|
|
@@ -6822,8 +6516,7 @@ export class Lowerer {
|
|
|
6822
6516
|
// A dyn ('unknown') ACTUAL flowing into a typed slot the checker
|
|
6823
6517
|
// approved (an assertion function's narrowing, the error-any world's
|
|
6824
6518
|
// forgiven chains): the VALIDATED extraction — dynCheck, the
|
|
6825
|
-
// checked-cast machinery, applied automatically.
|
|
6826
|
-
// exactly the island exit's stance: a value that doesn't match the
|
|
6519
|
+
// checked-cast machinery, applied automatically. A value outside the
|
|
6827
6520
|
// slot's type throws a catchable TypeError instead of misreading the
|
|
6828
6521
|
// payload. Only dynCheck's own domain (JSON-representable types,
|
|
6829
6522
|
// undefined-armed unions of those, bytes<u8>, the %Error root)
|
|
@@ -7114,17 +6807,15 @@ export class Lowerer {
|
|
|
7114
6807
|
return this.applyWidthLift(lift, expr, expected, expr.loc);
|
|
7115
6808
|
// Arms OUTSIDE widthLiftPlan's domain keep the historic per-arm
|
|
7116
6809
|
// widthCoerce probe (first match): index-signature record arms (the
|
|
7117
|
-
// overflow CAPTURE helper owns their reshapes)
|
|
7118
|
-
//
|
|
7119
|
-
//
|
|
7120
|
-
// never undone by a first-match fallback.
|
|
6810
|
+
// overflow CAPTURE helper owns their reshapes). Exclude shapes
|
|
6811
|
+
// already owned by the plan so first-match fallback cannot undo
|
|
6812
|
+
// its ambiguity rule for record/array lifts.
|
|
7121
6813
|
{
|
|
7122
6814
|
const def = this.unions.get(expected.unionId);
|
|
7123
6815
|
if (def) {
|
|
7124
6816
|
for (let i = 0; i < def.arms.length; i++) {
|
|
7125
6817
|
const arm = def.arms[i];
|
|
7126
|
-
const boundaryArm =
|
|
7127
|
-
(arm.kind === "array" && arm.elem.kind === "jsval");
|
|
6818
|
+
const boundaryArm = arm.kind === "record" && this.shapes.get(arm.shapeId)?.indexValue !== undefined;
|
|
7128
6819
|
if (!boundaryArm)
|
|
7129
6820
|
continue;
|
|
7130
6821
|
const w = this.widthCoerce(expr, arm);
|
|
@@ -7259,27 +6950,6 @@ export class Lowerer {
|
|
|
7259
6950
|
deferredReadHelper(fromId, target, loc) {
|
|
7260
6951
|
return deferredReadHelper(this, fromId, target, loc);
|
|
7261
6952
|
}
|
|
7262
|
-
jsvalLiftable(t, visiting = new Set()) {
|
|
7263
|
-
return jsvalLiftable(this, t, visiting);
|
|
7264
|
-
}
|
|
7265
|
-
jsvalLiftExpr(e, loc) {
|
|
7266
|
-
return jsvalLiftExpr(this, e, loc);
|
|
7267
|
-
}
|
|
7268
|
-
unionToJsvalHelper(unionId, loc) {
|
|
7269
|
-
return unionToJsvalHelper(this, unionId, loc);
|
|
7270
|
-
}
|
|
7271
|
-
recordToJsvalHelper(shapeId, loc) {
|
|
7272
|
-
return recordToJsvalHelper(this, shapeId, loc);
|
|
7273
|
-
}
|
|
7274
|
-
arrayToJsvalHelper(elem, loc) {
|
|
7275
|
-
return arrayToJsvalHelper(this, elem, loc);
|
|
7276
|
-
}
|
|
7277
|
-
arrayToJsvalArrayHelper(fromElem, loc) {
|
|
7278
|
-
return arrayToJsvalArrayHelper(this, fromElem, loc);
|
|
7279
|
-
}
|
|
7280
|
-
jsvalIn(e, node) {
|
|
7281
|
-
return jsvalIn(this, e, node);
|
|
7282
|
-
}
|
|
7283
6953
|
/** THE coercion path for values flowing into a typed slot: union arms
|
|
7284
6954
|
* wrap implicitly (coerceToExpected), then the exact-type fence runs
|
|
7285
6955
|
* (SC2002 for record shapes, SC2003 for unions). Every slot-directed
|
|
@@ -7341,17 +7011,7 @@ export class Lowerer {
|
|
|
7341
7011
|
}
|
|
7342
7012
|
}
|
|
7343
7013
|
}
|
|
7344
|
-
let e = this.
|
|
7345
|
-
expr.type.kind === "dyn" &&
|
|
7346
|
-
expected.kind === "array" &&
|
|
7347
|
-
expected.elem.kind === "jsval"
|
|
7348
|
-
? {
|
|
7349
|
-
kind: "jsExit",
|
|
7350
|
-
value: this.jsvalIn(expr, node),
|
|
7351
|
-
type: expected,
|
|
7352
|
-
loc: expr.loc,
|
|
7353
|
-
}
|
|
7354
|
-
: this.coerceToExpected(expr, expected);
|
|
7014
|
+
let e = this.coerceToExpected(expr, expected);
|
|
7355
7015
|
// Keep storage intact when ordinary widening already accepts it. Only
|
|
7356
7016
|
// a destination needing a more specific class layout uses the site's
|
|
7357
7017
|
// refinement and checked extraction.
|
|
@@ -7375,24 +7035,6 @@ export class Lowerer {
|
|
|
7375
7035
|
e.value.type.kind === "array") {
|
|
7376
7036
|
e = { ...e, liveRef: true };
|
|
7377
7037
|
}
|
|
7378
|
-
// An 'any' value PROVABLY null/undefined (the unit literal itself, or
|
|
7379
|
-
// a read of a binding nothing ever assigns a non-unit value) flowing
|
|
7380
|
-
// implicitly into a primitive slot: the validated exit refuses units
|
|
7381
|
-
// unconditionally, so every run would throw the boundary TypeError
|
|
7382
|
-
// where Node proceeds silently. A failure certain at compile time is
|
|
7383
|
-
// a fence, not a runtime surprise. Explicit casts keep their runtime
|
|
7384
|
-
// checked-cast semantics (the cast lowering builds its own jsExit
|
|
7385
|
-
// before this runs, so `e !== expr` skips them), and union/composite
|
|
7386
|
-
// targets keep the runtime exit (an undefined-armed union ACCEPTS the
|
|
7387
|
-
// engine's undefined; composite validation is dynCheck's business).
|
|
7388
|
-
if (e !== expr &&
|
|
7389
|
-
e.kind === "jsExit" &&
|
|
7390
|
-
(e.type.kind === "f64" || e.type.kind === "string" || e.type.kind === "bool")) {
|
|
7391
|
-
const unit = this.provenUnitAnyOf(node, e.value);
|
|
7392
|
-
if (unit !== null) {
|
|
7393
|
-
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'`);
|
|
7394
|
-
}
|
|
7395
|
-
}
|
|
7396
7038
|
// A closure that just BOXED into dyn takes its best-effort JS name
|
|
7397
7039
|
// from the source node (identifier reads, named function expressions,
|
|
7398
7040
|
// NamedEvaluation through a variable initializer) — inspect prints
|
|
@@ -7428,34 +7070,12 @@ export class Lowerer {
|
|
|
7428
7070
|
}
|
|
7429
7071
|
}
|
|
7430
7072
|
}
|
|
7431
|
-
// A JS FUNC value outside the island marshal set flowing into a
|
|
7432
|
-
// jsval slot (`withPlugins(getSupportInfoWithoutPlugins, 0)` — a
|
|
7433
|
-
// wrapper built at module init around a function the run may never
|
|
7434
|
-
// call): the crossing defers to a call-time fence closure instead of
|
|
7435
|
-
// stopping the statement — jsvalIn's deferral, the implicit-coercion
|
|
7436
|
-
// spelling.
|
|
7437
|
-
if (expected.kind === "jsval" && e.type.kind === "func" && !typeEquals(e.type, expected)) {
|
|
7438
|
-
const diagsBefore = this.diags.length;
|
|
7439
|
-
try {
|
|
7440
|
-
this.requireExactShape(node, e.type, expected);
|
|
7441
|
-
}
|
|
7442
|
-
catch (err) {
|
|
7443
|
-
if (!(err instanceof PoisonError))
|
|
7444
|
-
throw err;
|
|
7445
|
-
const fence = islandFuncValueFence(this, diagsBefore, node);
|
|
7446
|
-
if (fence)
|
|
7447
|
-
return fence;
|
|
7448
|
-
throw err;
|
|
7449
|
-
}
|
|
7450
|
-
return e;
|
|
7451
|
-
}
|
|
7452
7073
|
this.requireExactShape(node, e.type, expected);
|
|
7453
7074
|
return e;
|
|
7454
7075
|
}
|
|
7455
7076
|
/** The unit an 'any' expression PROVABLY holds on every run, or null
|
|
7456
|
-
* when no proof exists.
|
|
7457
|
-
*
|
|
7458
|
-
* or the node is an identifier whose every declaration is a plain,
|
|
7077
|
+
* when no proof exists. The node must be an identifier whose every
|
|
7078
|
+
* declaration is a plain,
|
|
7459
7079
|
* non-ambient `var`/`let`/`const` declarator under a variable STATEMENT
|
|
7460
7080
|
* (catch bindings, for-of/for-in cursors, parameters, and imports all
|
|
7461
7081
|
* fail this shape test — each receives values from elsewhere), each
|
|
@@ -7466,13 +7086,7 @@ export class Lowerer {
|
|
|
7466
7086
|
* bindings are read-only, so cross-file writes don't exist). A hoisted
|
|
7467
7087
|
* `var` read before its unit-initialized statement holds undefined —
|
|
7468
7088
|
* also a unit — so the mixed case reports both names. */
|
|
7469
|
-
provenUnitAnyOf(node,
|
|
7470
|
-
if (value.kind === "jsOp" && value.args.length === 0) {
|
|
7471
|
-
if (value.op === "undefLit")
|
|
7472
|
-
return "undefined";
|
|
7473
|
-
if (value.op === "nullLit")
|
|
7474
|
-
return "null";
|
|
7475
|
-
}
|
|
7089
|
+
provenUnitAnyOf(node, _value) {
|
|
7476
7090
|
let n = node;
|
|
7477
7091
|
while (ts.isParenthesizedExpression(n))
|
|
7478
7092
|
n = n.expression;
|
|
@@ -7580,7 +7194,6 @@ export class Lowerer {
|
|
|
7580
7194
|
const from = this.mapTypeOf(this.typeOf(asserted.expression));
|
|
7581
7195
|
const to = this.mapTypeOf(this.checker.getTypeFromTypeNode(asserted.type));
|
|
7582
7196
|
if (from?.kind === "dyn" ||
|
|
7583
|
-
from?.kind === "jsval" ||
|
|
7584
7197
|
(from?.kind === "record" && to?.kind === "record" && !typeEquals(from, to))) {
|
|
7585
7198
|
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");
|
|
7586
7199
|
}
|
|
@@ -7594,7 +7207,7 @@ export class Lowerer {
|
|
|
7594
7207
|
(from.kind === "object" &&
|
|
7595
7208
|
to.kind === "object" &&
|
|
7596
7209
|
this.isSubclassOf(from.className, to.className))));
|
|
7597
|
-
if (!preservesIdentity || value.kind === "dynCheck"
|
|
7210
|
+
if (!preservesIdentity || value.kind === "dynCheck") {
|
|
7598
7211
|
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");
|
|
7599
7212
|
}
|
|
7600
7213
|
return this.coerceInto(node, value, expected);
|
|
@@ -7786,11 +7399,6 @@ export class Lowerer {
|
|
|
7786
7399
|
if (value.kind === "unitLit") {
|
|
7787
7400
|
return { kind: "dynFrom", value, type: DYN, loc: value.loc };
|
|
7788
7401
|
}
|
|
7789
|
-
// An ISLAND ('any') value: the by-reference jsval→dyn wrap — the same
|
|
7790
|
-
// edge coerceToExpected converts (dyn slots accept engine values).
|
|
7791
|
-
if (value.type.kind === "jsval") {
|
|
7792
|
-
return { kind: "dynFromJsval", value, type: DYN, loc: value.loc };
|
|
7793
|
-
}
|
|
7794
7402
|
if (!this.dynConvertible(value.type)) {
|
|
7795
7403
|
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)`);
|
|
7796
7404
|
}
|
|
@@ -7826,10 +7434,10 @@ export class Lowerer {
|
|
|
7826
7434
|
}
|
|
7827
7435
|
/** The value of a `return` statement. In an async function `return p`
|
|
7828
7436
|
* where p is a promise flattens (JS: the returned promise's settlement
|
|
7829
|
-
* becomes the async function's result)
|
|
7830
|
-
*
|
|
7831
|
-
*
|
|
7832
|
-
*
|
|
7437
|
+
* becomes the async function's result) through an adopting awaitExpr,
|
|
7438
|
+
* which parks the fiber and re-throws rejections after the adoption's
|
|
7439
|
+
* then-job turn. Everything else flows into the function's return slot
|
|
7440
|
+
* through the usual coercion path. */
|
|
7833
7441
|
/** The value of `return <expr>` against the context's declared return —
|
|
7834
7442
|
* or NULL for a bare return: `return undefined`/`return null` in a
|
|
7835
7443
|
* void-returning function (`{ bar() { return undefined } }`, inferred
|
|
@@ -7860,11 +7468,38 @@ export class Lowerer {
|
|
|
7860
7468
|
if (expected.kind === "void" && e.kind === "unitLit")
|
|
7861
7469
|
return null;
|
|
7862
7470
|
if (this.ctx.isAsync && e.type.kind === "promise" && expected.kind !== "promise") {
|
|
7863
|
-
const awaited =
|
|
7471
|
+
const awaited = this.returnedPromiseAwait(e);
|
|
7864
7472
|
return this.coerceInto(node, awaited, expected);
|
|
7865
7473
|
}
|
|
7866
7474
|
return this.coerceInto(node, e, expected);
|
|
7867
7475
|
}
|
|
7476
|
+
/** Whether a promise returned here resolves the function's own promise
|
|
7477
|
+
* by adoption (async functions; async generators await their return
|
|
7478
|
+
* operand instead). */
|
|
7479
|
+
adoptsReturnedPromise() {
|
|
7480
|
+
return this.ctx.isAsync === true && !this.ctx.generator;
|
|
7481
|
+
}
|
|
7482
|
+
/** `return p` of a promise into a non-promise result `R` (a void result
|
|
7483
|
+
* drops the settled value; widening keeps the adopting await the return's
|
|
7484
|
+
* own value). */
|
|
7485
|
+
adoptingReturn(e, R, coerce) {
|
|
7486
|
+
const loc = e.loc;
|
|
7487
|
+
if (R.kind !== "void")
|
|
7488
|
+
return { kind: "return", value: coerce(this.returnedPromiseAwait(e)), loc };
|
|
7489
|
+
const widened = e.type.kind === "promise" && e.type.inner.kind !== "void"
|
|
7490
|
+
? { kind: "promiseVoidWiden", value: e, type: { kind: "promise", inner: VOID }, loc }
|
|
7491
|
+
: e;
|
|
7492
|
+
return { kind: "return", value: this.returnedPromiseAwait(widened), loc };
|
|
7493
|
+
}
|
|
7494
|
+
/** The await a returned promise `e` lowers to: adopting in async
|
|
7495
|
+
* functions (one then-job turn first, outside the function's handlers). */
|
|
7496
|
+
returnedPromiseAwait(e) {
|
|
7497
|
+
if (e.type.kind !== "promise")
|
|
7498
|
+
throw new InternalCompilerError("returned-promise await of a non-promise");
|
|
7499
|
+
if (!this.adoptsReturnedPromise())
|
|
7500
|
+
return { kind: "awaitExpr", value: e, type: e.type.inner, loc: e.loc };
|
|
7501
|
+
return { kind: "awaitExpr", value: e, type: e.type.inner, adopt: true, loc: e.loc };
|
|
7502
|
+
}
|
|
7868
7503
|
/** `return <expr>` lowered as a STATEMENT against the declared return.
|
|
7869
7504
|
* Void-returning contexts get the JS drop: a contextually void-typed
|
|
7870
7505
|
* function may return a value (`fv = function() { return 0; }` into a
|
|
@@ -7876,7 +7511,9 @@ export class Lowerer {
|
|
|
7876
7511
|
if (expected.kind === "void") {
|
|
7877
7512
|
let e = this.lowerExpr(node);
|
|
7878
7513
|
if (this.ctx.isAsync && e.type.kind === "promise") {
|
|
7879
|
-
|
|
7514
|
+
if (this.adoptsReturnedPromise())
|
|
7515
|
+
return this.adoptingReturn(e, VOID, (x) => x);
|
|
7516
|
+
e = this.returnedPromiseAwait(e);
|
|
7880
7517
|
}
|
|
7881
7518
|
if (e.kind === "unitLit")
|
|
7882
7519
|
return { kind: "return", value: null, loc };
|
|
@@ -7987,18 +7624,7 @@ export class Lowerer {
|
|
|
7987
7624
|
}
|
|
7988
7625
|
return { kind: "boolLit", value: true, type: BOOL, loc };
|
|
7989
7626
|
}
|
|
7990
|
-
/** The entry value of a binding JS initializes to `undefined` (an
|
|
7991
|
-
* initializer-less declaration, a hoisted `var` before its statement):
|
|
7992
|
-
* undefined-armed unions hold the interned undefined arm, and 'any'
|
|
7993
|
-
* slots hold the ENGINE's undefined — tsc's definite-assignment
|
|
7994
|
-
* analysis never guards `any` reads, so a jsval slot IS readable before
|
|
7995
|
-
* any assignment and must never stay a C-level NULL (a validated exit
|
|
7996
|
-
* or engine op on NULL is memory-unsafe, not a TypeError). Null for
|
|
7997
|
-
* every other type: tsc rejects their pre-assignment reads. */
|
|
7998
7627
|
unassignedSlotInit(type, loc) {
|
|
7999
|
-
if (type.kind === "jsval") {
|
|
8000
|
-
return { kind: "jsOp", op: "undefLit", args: [], type: JSVAL, loc };
|
|
8001
|
-
}
|
|
8002
7628
|
return this.wrappedUndefined(type, loc);
|
|
8003
7629
|
}
|
|
8004
7630
|
undefinedArgFor(type, loc, blame) {
|
|
@@ -8524,24 +8150,19 @@ export class Lowerer {
|
|
|
8524
8150
|
// identifier-param prologue's ternary), then destructure the
|
|
8525
8151
|
// picked value.
|
|
8526
8152
|
const abi = shape.type;
|
|
8527
|
-
if (abi.kind === "dyn"
|
|
8528
|
-
//
|
|
8529
|
-
//
|
|
8530
|
-
// dynamic dyn): the slot holds its tier's undefined directly,
|
|
8531
|
-
// so the default test is the runtime undefined test — then
|
|
8532
|
-
// the pattern destructures the picked value.
|
|
8153
|
+
if (abi.kind === "dyn") {
|
|
8154
|
+
// The checked-value slot holds native undefined directly.
|
|
8155
|
+
// Test it at runtime, then destructure the selected value.
|
|
8533
8156
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8534
8157
|
const src = this.declareHiddenLocal("%psrc", abi);
|
|
8535
8158
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8536
|
-
const isUndef =
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
}
|
|
8544
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8159
|
+
const isUndef = {
|
|
8160
|
+
kind: "dynTest",
|
|
8161
|
+
test: "undefined",
|
|
8162
|
+
value: inRef(),
|
|
8163
|
+
type: BOOL,
|
|
8164
|
+
loc,
|
|
8165
|
+
};
|
|
8545
8166
|
prologue.push({
|
|
8546
8167
|
kind: "varDecl",
|
|
8547
8168
|
localId: src.id,
|
|
@@ -8641,24 +8262,20 @@ export class Lowerer {
|
|
|
8641
8262
|
const name = decl.name.text;
|
|
8642
8263
|
if (shape.mode === "omittable" && shape.bodyType && decl.initializer) {
|
|
8643
8264
|
const abi = shape.type;
|
|
8644
|
-
if (abi.kind === "dyn"
|
|
8645
|
-
//
|
|
8646
|
-
//
|
|
8647
|
-
// dynamic dyn): the slot holds its tier's undefined directly —
|
|
8648
|
-
// the body local picks the default on the runtime test.
|
|
8265
|
+
if (abi.kind === "dyn") {
|
|
8266
|
+
// The checked-value slot holds native undefined directly;
|
|
8267
|
+
// the body local selects the default with a runtime test.
|
|
8649
8268
|
const loc = locOf(decl);
|
|
8650
8269
|
const slot = this.declareHiddenLocal(name, abi);
|
|
8651
8270
|
params.push({ localId: slot.id, name, type: abi });
|
|
8652
8271
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8653
|
-
const isUndef =
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
}
|
|
8661
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8272
|
+
const isUndef = {
|
|
8273
|
+
kind: "dynTest",
|
|
8274
|
+
test: "undefined",
|
|
8275
|
+
value: inRef(),
|
|
8276
|
+
type: BOOL,
|
|
8277
|
+
loc,
|
|
8278
|
+
};
|
|
8662
8279
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8663
8280
|
const body = this.declareLocal(decl.name, name, abi, true);
|
|
8664
8281
|
prologue.push({
|
|
@@ -8841,13 +8458,6 @@ export class Lowerer {
|
|
|
8841
8458
|
resolveThis() {
|
|
8842
8459
|
return this.resolveKey(undefined);
|
|
8843
8460
|
}
|
|
8844
|
-
/** READ-ONLY twin of resolveLocal for PROBES (isIslandExpr): answers
|
|
8845
|
-
* the nearest binding entry without boxing, threading, or predeclaring.
|
|
8846
|
-
* resolveKey mutates capture state as a side effect, and a speculative
|
|
8847
|
-
* island-ness query through a context that takes no captures (a plain
|
|
8848
|
-
* declared function between the origin and the reference) was an ICE —
|
|
8849
|
-
* the REAL lowering path still resolves (and diagnoses) the reference
|
|
8850
|
-
* itself. */
|
|
8851
8461
|
peekLocal(ident) {
|
|
8852
8462
|
let symbol = this.checker.getSymbolAtLocation(ident);
|
|
8853
8463
|
if (ident.parent &&
|
|
@@ -9015,79 +8625,6 @@ export class Lowerer {
|
|
|
9015
8625
|
allowDynObject ||=
|
|
9016
8626
|
srcType.kind === "dyn" && isParseArgsDynCheckerType(this, this.typeOf(pattern));
|
|
9017
8627
|
}
|
|
9018
|
-
// An ISLAND source (`const { readFileSync } = await import("fs")` —
|
|
9019
|
-
// a namespace handle, or any 'any'-typed object): each bound name is
|
|
9020
|
-
// an engine property read, mirroring the island property-read rule —
|
|
9021
|
-
// a member the .d.ts declares as a primitive exits eagerly to the
|
|
9022
|
-
// static type; everything else (including members whose declared
|
|
9023
|
-
// types have no static mapping, like @types/node's function types)
|
|
9024
|
-
// stays a HANDLE, and its use sites dispatch to engine ops. Patterns
|
|
9025
|
-
// the element-wise walk cannot spell — ARRAY patterns (the iterator
|
|
9026
|
-
// protocol), empty patterns (the coercion checks), holes, rest,
|
|
9027
|
-
// defaults — run the REAL pattern in a synthesized engine function
|
|
9028
|
-
// instead (lowerJsvalBindingPattern).
|
|
9029
|
-
const elementWise = srcType.kind === "jsval" &&
|
|
9030
|
-
ts.isObjectBindingPattern(pattern) &&
|
|
9031
|
-
pattern.elements.length > 0 &&
|
|
9032
|
-
pattern.elements.every((el) => !el.dotDotDotToken &&
|
|
9033
|
-
!el.initializer &&
|
|
9034
|
-
el.name !== undefined &&
|
|
9035
|
-
ts.isIdentifier(el.propertyName ?? el.name));
|
|
9036
|
-
if (srcType.kind === "jsval" && !elementWise) {
|
|
9037
|
-
if (lowerJsvalBindingPattern(this, pattern, srcRef, isLet, out))
|
|
9038
|
-
return;
|
|
9039
|
-
// No engine form (computed keys, untransportable defaults): fall
|
|
9040
|
-
// through to the static fences below.
|
|
9041
|
-
}
|
|
9042
|
-
if (srcType.kind === "jsval" && ts.isObjectBindingPattern(pattern)) {
|
|
9043
|
-
for (const el of pattern.elements) {
|
|
9044
|
-
this.checkBindingElement(el);
|
|
9045
|
-
// 7's BindingElement declares name optional (array elisions are
|
|
9046
|
-
// nameless there); object-pattern elements always carry one.
|
|
9047
|
-
if (el.name === undefined)
|
|
9048
|
-
continue;
|
|
9049
|
-
const prop = el.propertyName ?? el.name;
|
|
9050
|
-
if (!ts.isIdentifier(prop)) {
|
|
9051
|
-
this.unsupported("SC1031", el, "destructuring with computed or non-identifier keys");
|
|
9052
|
-
}
|
|
9053
|
-
const loc = locOf(el);
|
|
9054
|
-
const read = {
|
|
9055
|
-
kind: "jsOp",
|
|
9056
|
-
op: "getProp",
|
|
9057
|
-
name: prop.text,
|
|
9058
|
-
args: [srcRef()],
|
|
9059
|
-
type: JSVAL,
|
|
9060
|
-
loc,
|
|
9061
|
-
};
|
|
9062
|
-
if (!ts.isIdentifier(el.name)) {
|
|
9063
|
-
// A nested pattern reads through its own handle temp.
|
|
9064
|
-
const tmp = this.declareHiddenLocal("%destr", JSVAL);
|
|
9065
|
-
out.push({ kind: "varDecl", localId: tmp.id, init: read, loc });
|
|
9066
|
-
this.lowerBindingPattern(el.name, () => ({ kind: "varRef", localId: tmp.id, type: JSVAL, loc }), JSVAL, isLet, out);
|
|
9067
|
-
continue;
|
|
9068
|
-
}
|
|
9069
|
-
const declared = this.mapTypeOf(this.typeOf(el.name));
|
|
9070
|
-
const primitive = declared &&
|
|
9071
|
-
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string");
|
|
9072
|
-
const value = primitive
|
|
9073
|
-
? { kind: "jsExit", value: read, type: declared, loc }
|
|
9074
|
-
: read;
|
|
9075
|
-
const symbol = this.checker.getSymbolAtLocation(el.name);
|
|
9076
|
-
const g = symbol ? this.globalsBySymbol.get(symbol) : undefined;
|
|
9077
|
-
if (g) {
|
|
9078
|
-
out.push({
|
|
9079
|
-
kind: "assign",
|
|
9080
|
-
localId: g.id,
|
|
9081
|
-
value: this.coerceInto(el.name, value, g.type),
|
|
9082
|
-
loc,
|
|
9083
|
-
});
|
|
9084
|
-
continue;
|
|
9085
|
-
}
|
|
9086
|
-
const local = this.declareLocal(el.name, el.name.text, value.type, isLet);
|
|
9087
|
-
out.push({ kind: "varDecl", localId: local.id, init: value, loc });
|
|
9088
|
-
}
|
|
9089
|
-
return;
|
|
9090
|
-
}
|
|
9091
8628
|
return lowerBindingPattern(this, pattern, srcRef, srcType, isLet, out, dynSpell, allowDynObject);
|
|
9092
8629
|
}
|
|
9093
8630
|
checkBindingElement(el, allowDefault = false) {
|
|
@@ -9100,97 +8637,6 @@ export class Lowerer {
|
|
|
9100
8637
|
return lowerVarDeclList(this, list);
|
|
9101
8638
|
}
|
|
9102
8639
|
lowerVarDecl(decl, isLet) {
|
|
9103
|
-
// ISLAND-HANDLE rescue (--dynamic): `const factory = (await
|
|
9104
|
-
// import("./x.mjs")).default` / `const buf = islandReadFileSync(p)` —
|
|
9105
|
-
// a binding whose DECLARED type either has no static mapping or has
|
|
9106
|
-
// one no island value can EXIT to (bytes, functions, promises), but
|
|
9107
|
-
// whose initializer is an island value. The declared type is a .d.ts
|
|
9108
|
-
// surface over an engine value; the binding stays a HANDLE (jsval
|
|
9109
|
-
// local) and typed use sites go through engine ops and validated
|
|
9110
|
-
// exits like any island value. Exit-CAPABLE declared types (numbers,
|
|
9111
|
-
// strings, JSON-safe composites, their undefined-armed unions) keep
|
|
9112
|
-
// the standard path and its validated-exit machinery; so does
|
|
9113
|
-
// everything non-island — including badType here when the
|
|
9114
|
-
// initializer turns out not to be island-typed, which is exactly
|
|
9115
|
-
// what the standard path would have reported.
|
|
9116
|
-
// Only reference-shaped initializers are candidates (awaits, calls,
|
|
9117
|
-
// member reads, identifiers, casts/parens over those): they are the
|
|
9118
|
-
// island producers, and re-lowering one on the fall-through emits
|
|
9119
|
-
// nothing twice — a lambda or literal initializer would (each
|
|
9120
|
-
// lowering mints a fresh %fn), and is never an island value anyway.
|
|
9121
|
-
const islandCandidate = (e) => {
|
|
9122
|
-
let cur = e;
|
|
9123
|
-
while (ts.isParenthesizedExpression(cur) ||
|
|
9124
|
-
ts.isAsExpression(cur) ||
|
|
9125
|
-
ts.isTypeAssertion(cur) ||
|
|
9126
|
-
ts.isNonNullExpression(cur)) {
|
|
9127
|
-
cur = cur.expression;
|
|
9128
|
-
}
|
|
9129
|
-
if (!ts.isAwaitExpression(cur) &&
|
|
9130
|
-
!ts.isCallExpression(cur) &&
|
|
9131
|
-
!ts.isPropertyAccessExpression(cur) &&
|
|
9132
|
-
!ts.isElementAccessExpression(cur) &&
|
|
9133
|
-
!ts.isIdentifier(cur)) {
|
|
9134
|
-
return false;
|
|
9135
|
-
}
|
|
9136
|
-
// A lambda ANYWHERE inside (a call argument) would emit its %fn
|
|
9137
|
-
// twice across the fall-through's re-lowering — skip those.
|
|
9138
|
-
let lambda = false;
|
|
9139
|
-
const scan = (n) => {
|
|
9140
|
-
if (lambda)
|
|
9141
|
-
return;
|
|
9142
|
-
if (ts.isArrowFunction(n) || ts.isFunctionExpression(n)) {
|
|
9143
|
-
lambda = true;
|
|
9144
|
-
return;
|
|
9145
|
-
}
|
|
9146
|
-
ts.forEachChild(n, scan);
|
|
9147
|
-
};
|
|
9148
|
-
scan(cur);
|
|
9149
|
-
return !lambda;
|
|
9150
|
-
};
|
|
9151
|
-
if (this.dynamic &&
|
|
9152
|
-
ts.isIdentifier(decl.name) &&
|
|
9153
|
-
decl.initializer !== undefined &&
|
|
9154
|
-
// `var` stays out: the rescue's block-positioned jsval local can't
|
|
9155
|
-
// model the function-scoped hoisted binding (a redeclaration or an
|
|
9156
|
-
// out-of-block read would split the variable in two) — vars take the
|
|
9157
|
-
// standard path and its own fences.
|
|
9158
|
-
(ts.getCombinedNodeFlags(decl) & ts.NodeFlags.BlockScoped) !== 0 &&
|
|
9159
|
-
islandCandidate(decl.initializer) &&
|
|
9160
|
-
// createRequire's plumbing decls are COMPILE-TIME erasures (the
|
|
9161
|
-
// require binding and its builtin-namespace bindings) — never
|
|
9162
|
-
// island values; the standard path's skips own them.
|
|
9163
|
-
!createRequireBindingDecl(this, decl.name, decl.initializer) &&
|
|
9164
|
-
!createRequireNamespaceDecl(this, decl.name, decl.initializer)) {
|
|
9165
|
-
const mapped = this.mapTypeOf(this.typeOf(decl.name));
|
|
9166
|
-
const handleOnly = mapped === null ||
|
|
9167
|
-
(mapped.kind !== "jsval" &&
|
|
9168
|
-
mapped.kind !== "void" &&
|
|
9169
|
-
!canExitIslandToType(mapped, (id) => this.shapes.get(id), (id) => this.unions.get(id)));
|
|
9170
|
-
const symbol = this.checker.getSymbolAtLocation(decl.name);
|
|
9171
|
-
if (handleOnly && (!symbol || !this.globalsBySymbol.has(symbol))) {
|
|
9172
|
-
const init = this.lowerExpr(decl.initializer);
|
|
9173
|
-
if (init.type.kind === "jsval") {
|
|
9174
|
-
const local = this.declareLocal(decl.name, decl.name.text, JSVAL, isLet);
|
|
9175
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9176
|
-
}
|
|
9177
|
-
// The CHECKED-DYNAMIC twin of the handle rescue (the runtime-world
|
|
9178
|
-
// local rule): an unmappable declared type over a dyn initializer
|
|
9179
|
-
// (`const first = plugins[0]` — the checker spells 'string |
|
|
9180
|
-
// object' while the read is a dyn keyed read) keeps the binding
|
|
9181
|
-
// dyn; typed use sites ride validated extractions and the routed
|
|
9182
|
-
// engine ops, exactly the JSON.parse-binding story.
|
|
9183
|
-
if (mapped === null && init.type.kind === "dyn") {
|
|
9184
|
-
const local = this.declareLocal(decl.name, decl.name.text, DYN, isLet);
|
|
9185
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9186
|
-
}
|
|
9187
|
-
if (mapped === null)
|
|
9188
|
-
this.badType(decl.name, this.typeOf(decl.name));
|
|
9189
|
-
// A mappable declared type with a non-island initializer: the
|
|
9190
|
-
// standard path owns it (the initializer lowered clean; re-running
|
|
9191
|
-
// it re-produces the same IR with no duplicate diagnostics).
|
|
9192
|
-
}
|
|
9193
|
-
}
|
|
9194
8640
|
return lowerVarDecl(this, decl, isLet);
|
|
9195
8641
|
}
|
|
9196
8642
|
lowerSwitch(stmt) {
|
|
@@ -9252,13 +8698,6 @@ export class Lowerer {
|
|
|
9252
8698
|
nodeTypesOnlySymbol(sym) {
|
|
9253
8699
|
return nodeTypesOnlySymbol(this, sym);
|
|
9254
8700
|
}
|
|
9255
|
-
/** True for an npm package's shipped declaration files — under
|
|
9256
|
-
* node_modules but NOT the standard library (typescript's own lib files
|
|
9257
|
-
* live under node_modules too), or inside a registered workspace-linked
|
|
9258
|
-
* package (a node_modules symlink whose realpath'd files carry no
|
|
9259
|
-
* node_modules segment — workspace-registry.ts). The provenance half of the npm
|
|
9260
|
-
* typing rule (package types are island handles) and of the per-package
|
|
9261
|
-
* requires-dynamic attribution. */
|
|
9262
8701
|
isNpmFile = (sf) => sf.isDeclarationFile &&
|
|
9263
8702
|
(sf.fileName.includes("/node_modules/") || workspacePackageOfPath(sf.fileName) !== null) &&
|
|
9264
8703
|
!this.isStdlibFile(sf);
|
|
@@ -9372,40 +8811,6 @@ export class Lowerer {
|
|
|
9372
8811
|
return lowerTemplate(this, expr);
|
|
9373
8812
|
}
|
|
9374
8813
|
lowerAsExpression(expr) {
|
|
9375
|
-
// ISLAND value cast to a PROMISE type (`factory(opts) as Promise<Mod>`
|
|
9376
|
-
// — the Node-typed async-API shape): promises never have a validated
|
|
9377
|
-
// exit, so instead of refusing the build the cast DEFERS the failure
|
|
9378
|
-
// to runtime — island.castFail evaluates the value (its side effects
|
|
9379
|
-
// are real) and throws a catchable TypeError naming the target, so
|
|
9380
|
-
// typed-but-never-executed code (a wasm decode path behind a
|
|
9381
|
-
// rejecting import) still compiles and a reached cast fails loudly at
|
|
9382
|
-
// the exact site. Claimed only when the source is island-typed by the
|
|
9383
|
-
// checker (jsval, or a promise whose inner is a handle); a source
|
|
9384
|
-
// that lowers to a real static promise keeps erasure — the standard
|
|
9385
|
-
// path's rule for non-island inners. Static builds keep their
|
|
9386
|
-
// per-site diagnostics.
|
|
9387
|
-
if (this.dynamic) {
|
|
9388
|
-
const srcMapped = this.mapTypeOf(this.typeOf(expr.expression));
|
|
9389
|
-
const island = srcMapped?.kind === "jsval" ||
|
|
9390
|
-
(srcMapped?.kind === "promise" && srcMapped.inner.kind === "jsval");
|
|
9391
|
-
if (island) {
|
|
9392
|
-
const targetTs = this.checker.getTypeFromTypeNode(expr.type);
|
|
9393
|
-
const target = this.mapTypeOf(targetTs);
|
|
9394
|
-
if (target?.kind === "promise") {
|
|
9395
|
-
const inner = this.lowerExpr(expr.expression);
|
|
9396
|
-
if (inner.type.kind !== "jsval")
|
|
9397
|
-
return inner; // static promise: erasure
|
|
9398
|
-
const loc = locOf(expr);
|
|
9399
|
-
const name = {
|
|
9400
|
-
kind: "strLit",
|
|
9401
|
-
value: this.fmt(target),
|
|
9402
|
-
type: STRING,
|
|
9403
|
-
loc,
|
|
9404
|
-
};
|
|
9405
|
-
return { kind: "libCall", fn: "island.castFail", args: [inner, name], type: target, loc };
|
|
9406
|
-
}
|
|
9407
|
-
}
|
|
9408
|
-
}
|
|
9409
8814
|
return lowerAsExpression(this, expr);
|
|
9410
8815
|
}
|
|
9411
8816
|
lowerPrefixUnary(expr) {
|
|
@@ -9537,8 +8942,6 @@ export class Lowerer {
|
|
|
9537
8942
|
}
|
|
9538
8943
|
}
|
|
9539
8944
|
lowerCall(expr) {
|
|
9540
|
-
// Ambient fetch (native in static builds, island-backed under
|
|
9541
|
-
// --dynamic) and dynamic import() claim their calls before the general
|
|
9542
8945
|
// dispatch. The general identifier-call paths have no lowering for a
|
|
9543
8946
|
// promise-returning ambient global, and `import` is a keyword callee no
|
|
9544
8947
|
// identifier path matches.
|
|
@@ -9677,37 +9080,11 @@ export class Lowerer {
|
|
|
9677
9080
|
return inheritsBuiltinEmitterCtor(this, info);
|
|
9678
9081
|
}
|
|
9679
9082
|
lowerNew(expr) {
|
|
9680
|
-
// `new Uint8Array(handle)` (and the other typed-array ctors) over an
|
|
9681
|
-
// ISLAND argument: the construction is an ENGINE operation — the
|
|
9682
|
-
// engine's own constructor over the engine's own value (an Emscripten
|
|
9683
|
-
// factory's `wasmBinary: new Uint8Array(buf)` where buf came off an
|
|
9684
|
-
// island readFileSync) — and the instance stays a handle. The static
|
|
9685
|
-
// bytes ctor cannot claim it (bytes never cross the boundary), so
|
|
9686
|
-
// this preempts only when the single argument is island-typed;
|
|
9687
|
-
// every static form keeps the standard path.
|
|
9688
|
-
if (this.dynamic &&
|
|
9689
|
-
ts.isIdentifier(expr.expression) &&
|
|
9690
|
-
expr.arguments?.length === 1 &&
|
|
9691
|
-
!ts.isSpreadElement(expr.arguments[0]) &&
|
|
9692
|
-
/^(Uint8|Uint8Clamped|Int8|Uint16|Int16|Uint32|Int32|Float32|Float64|BigInt64|BigUint64)Array$/.test(expr.expression.text) &&
|
|
9693
|
-
this.isStdlibSymbol(this.resolveValueSymbol(expr.expression) ?? undefined) &&
|
|
9694
|
-
this.isIslandExpr(expr.arguments[0])) {
|
|
9695
|
-
const loc = locOf(expr);
|
|
9696
|
-
const ctor = {
|
|
9697
|
-
kind: "jsOp",
|
|
9698
|
-
op: "globalGet",
|
|
9699
|
-
name: expr.expression.text,
|
|
9700
|
-
args: [],
|
|
9701
|
-
type: JSVAL,
|
|
9702
|
-
loc,
|
|
9703
|
-
};
|
|
9704
|
-
const arg = this.lowerExpr(expr.arguments[0]);
|
|
9705
|
-
return { kind: "jsOp", op: "construct", args: [ctor, arg], type: JSVAL, loc };
|
|
9706
|
-
}
|
|
9707
9083
|
const builtin = lowerAbortControllerNew(this, expr) ??
|
|
9708
9084
|
lowerFetchWebNew(this, expr) ??
|
|
9709
9085
|
lowerResponseNew(this, expr) ??
|
|
9710
|
-
lowerStaticReadableStreamNew(this, expr)
|
|
9086
|
+
lowerStaticReadableStreamNew(this, expr) ??
|
|
9087
|
+
lowerConsoleNew(this, expr);
|
|
9711
9088
|
return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
|
|
9712
9089
|
}
|
|
9713
9090
|
lowerFieldRead(expr) {
|
|
@@ -10343,18 +9720,17 @@ export class Lowerer {
|
|
|
10343
9720
|
lowerNumberStaticProperty(expr) {
|
|
10344
9721
|
return lowerNumberStaticProperty(this, expr);
|
|
10345
9722
|
}
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
return requireDynamicApi(this, feature, node, hint);
|
|
9723
|
+
refuseUnsupportedApi(feature, node, hint) {
|
|
9724
|
+
return refuseUnsupportedApi(this, feature, node, hint);
|
|
10349
9725
|
}
|
|
10350
9726
|
lowerMathProperty(expr) {
|
|
10351
9727
|
return lowerMathProperty(this, expr);
|
|
10352
9728
|
}
|
|
10353
|
-
|
|
10354
|
-
return
|
|
9729
|
+
stdlibGlobalFnOf(ident) {
|
|
9730
|
+
return stdlibGlobalFnOf(this, ident);
|
|
10355
9731
|
}
|
|
10356
|
-
|
|
10357
|
-
return
|
|
9732
|
+
lowerStdlibMethodCall(call, access) {
|
|
9733
|
+
return lowerStdlibMethodCall(this, call, access);
|
|
10358
9734
|
}
|
|
10359
9735
|
}
|
|
10360
9736
|
//# sourceMappingURL=lowerer.js.map
|