@scriptc/compiler 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +73 -24
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +15 -0
- package/dist/backend/build-cache.d.ts +1 -3
- package/dist/backend/build-cache.js +3 -22
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +3 -0
- package/dist/backend/cache-root.js +23 -0
- package/dist/backend/cache-root.js.map +1 -0
- package/dist/backend/cycle-analysis.d.ts +15 -0
- package/dist/backend/cycle-analysis.js +107 -0
- package/dist/backend/cycle-analysis.js.map +1 -0
- package/dist/backend/cycle-analysis.test.js +124 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -0
- package/dist/backend/executable-features.d.ts +4 -0
- package/dist/backend/executable-features.js +42 -0
- package/dist/backend/executable-features.js.map +1 -0
- package/dist/backend/external-c.d.ts +5 -27
- package/dist/backend/external-c.js +5 -40
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +2 -3
- package/dist/backend/ffi-callbacks.js +2 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.d.ts +4 -9
- package/dist/backend/library-identity-markers.js +11 -49
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +5 -0
- package/dist/backend/library-pack.js +123 -0
- package/dist/backend/library-pack.js.map +1 -0
- package/dist/backend/link-plan-core.d.ts +20 -0
- package/dist/backend/link-plan-core.js +18 -0
- package/dist/backend/link-plan-core.js.map +1 -0
- package/dist/backend/link-plan.d.ts +1 -1
- package/dist/backend/link-plan.js +16 -17
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/link-trace.d.ts +2 -0
- package/dist/backend/link-trace.js +24 -0
- package/dist/backend/link-trace.js.map +1 -0
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.d.ts +9 -0
- package/dist/backend/literals.js +35 -0
- package/dist/backend/literals.js.map +1 -0
- package/dist/backend/literals.test.d.ts +1 -0
- package/dist/backend/literals.test.js +53 -0
- package/dist/backend/literals.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +9 -4
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.d.ts +1 -0
- package/dist/backend/llvm/blocks.test.js +91 -0
- package/dist/backend/llvm/blocks.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +14 -8
- package/dist/backend/llvm/classes.js +70 -28
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +5 -1
- package/dist/backend/llvm/common.js +45 -4
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/debug-info.js +2 -7
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/debug-info.test.d.ts +1 -0
- package/dist/backend/llvm/debug-info.test.js +110 -0
- package/dist/backend/llvm/debug-info.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +16 -2
- package/dist/backend/llvm/dyn.js +494 -165
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +596 -1
- package/dist/backend/llvm/emitter.js +695 -410
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.d.ts +1 -0
- package/dist/backend/llvm/emitter.test.js +179 -0
- package/dist/backend/llvm/emitter.test.js.map +1 -0
- package/dist/backend/llvm/expr-async.js +23 -14
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +32 -14
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-callbacks.js +25 -22
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +136 -35
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +1 -1
- package/dist/backend/llvm/expr-containers.js +43 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +5 -260
- package/dist/backend/llvm/expr-control.js +9 -5
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -1
- package/dist/backend/llvm/expr-dispatch.js +2 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +62 -74
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.d.ts +1 -1
- package/dist/backend/llvm/expr-island.js +11 -7
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +51 -30
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-records.d.ts +5 -1
- package/dist/backend/llvm/expr-records.js +43 -4
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js +102 -121
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +19 -0
- package/dist/backend/llvm/layouts.js +12 -0
- package/dist/backend/llvm/layouts.js.map +1 -0
- package/dist/backend/llvm/lib-abi.d.ts +19 -0
- package/dist/backend/llvm/lib-abi.js +82 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -0
- package/dist/backend/llvm/lib-connect.d.ts +2 -0
- package/dist/backend/llvm/lib-connect.js +51 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.d.ts +2 -0
- package/dist/backend/llvm/lib-datagram.js +135 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +50 -6
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +30 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +2 -0
- package/dist/backend/llvm/lib-http2.js +215 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -0
- package/dist/backend/llvm/lib-lookup.d.ts +2 -0
- package/dist/backend/llvm/lib-lookup.js +39 -0
- package/dist/backend/llvm/lib-lookup.js.map +1 -0
- package/dist/backend/llvm/lib-network.js +25 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +21 -16
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +117 -1
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +3 -2
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.d.ts +2 -0
- package/dist/backend/llvm/lib-test.js +34 -0
- package/dist/backend/llvm/lib-test.js.map +1 -0
- package/dist/backend/llvm/lib-tls.d.ts +2 -0
- package/dist/backend/llvm/lib-tls.js +82 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +10 -9
- package/dist/backend/llvm/shapes.js +35 -130
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.d.ts +1 -0
- package/dist/backend/llvm/unsupported.js +1 -2
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -7
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.d.ts +2 -2
- package/dist/backend/mangle.js +16 -5
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
- package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
- package/dist/backend/may-throw.js.map +1 -0
- package/dist/backend/may-throw.test.d.ts +1 -0
- package/dist/backend/may-throw.test.js +58 -0
- package/dist/backend/may-throw.test.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +22 -0
- package/dist/backend/native-codegen-core.js +44 -0
- package/dist/backend/native-codegen-core.js.map +1 -0
- package/dist/backend/native-codegen.d.ts +3 -19
- package/dist/backend/native-codegen.js +5 -44
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +94 -0
- package/dist/backend/native-link-info-core.js +62 -0
- package/dist/backend/native-link-info-core.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +3 -88
- package/dist/backend/native-link-info.js +12 -243
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +41 -146
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +10 -25
- package/dist/backend/native-toolchain.js +31 -211
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +5 -5
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +24 -0
- package/dist/backend/native-tools.js +33 -0
- package/dist/backend/native-tools.js.map +1 -0
- package/dist/backend/object-localize.js +19 -8
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +22 -0
- package/dist/backend/object-localize.test.js.map +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 +101 -0
- package/dist/backend/runtime-pack-core.js +172 -0
- package/dist/backend/runtime-pack-core.js.map +1 -0
- package/dist/backend/runtime-pack-native.d.ts +21 -0
- package/dist/backend/runtime-pack-native.js +70 -0
- package/dist/backend/runtime-pack-native.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +3 -83
- package/dist/backend/runtime-pack.js +8 -151
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +24 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +22 -0
- package/dist/backend/target-diagnostics.js +108 -0
- package/dist/backend/target-diagnostics.js.map +1 -0
- package/dist/backend/target-platform.d.ts +15 -0
- package/dist/backend/target-platform.js +72 -0
- package/dist/backend/target-platform.js.map +1 -0
- package/dist/backend/targets.d.ts +13 -4
- package/dist/backend/targets.js +95 -30
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +65 -4
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.d.ts +6 -0
- package/dist/backend/toolchain-environment.js +99 -0
- package/dist/backend/toolchain-environment.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +1 -9
- package/dist/backend/vendor-archives.js +2 -9
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +9 -0
- package/dist/backend/vendor-inputs.js +10 -0
- package/dist/backend/vendor-inputs.js.map +1 -0
- package/dist/backend/warm-cache.d.ts +3 -0
- package/dist/backend/warm-cache.js +41 -0
- package/dist/backend/warm-cache.js.map +1 -0
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.js +328 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/host.d.ts +24 -0
- package/dist/cli/host.js +2 -0
- package/dist/cli/host.js.map +1 -0
- package/dist/cli/output-options.d.ts +26 -0
- package/dist/cli/output-options.js +60 -0
- package/dist/cli/output-options.js.map +1 -0
- package/dist/cli/paths.d.ts +12 -0
- package/dist/cli/paths.js +42 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/usage.d.ts +74 -0
- package/dist/cli/usage.js +86 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli/wasi-paths.d.ts +8 -0
- package/dist/cli/wasi-paths.js +41 -0
- package/dist/cli/wasi-paths.js.map +1 -0
- package/dist/cli/wasi-runner.d.ts +2 -0
- package/dist/cli/wasi-runner.js +28 -0
- package/dist/cli/wasi-runner.js.map +1 -0
- package/dist/compat/fetch-profile.js +3 -3
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +162 -0
- package/dist/compile-types.js +2 -0
- package/dist/compile-types.js.map +1 -0
- package/dist/coverage/report.js +11 -5
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +5 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +3 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +5 -6
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +16 -17
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +14 -0
- package/dist/executable/prepare.js +66 -0
- package/dist/executable/prepare.js.map +1 -0
- package/dist/ffi/ffi-manifest.d.ts +11 -4
- package/dist/ffi/ffi-manifest.js +170 -58
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.d.ts +1 -0
- package/dist/ffi/ffi-manifest.test.js +111 -0
- package/dist/ffi/ffi-manifest.test.js.map +1 -0
- package/dist/format-integer.d.ts +3 -0
- package/dist/format-integer.js +14 -0
- package/dist/format-integer.js.map +1 -0
- package/dist/frontend/analysis.d.ts +5 -0
- package/dist/frontend/analysis.js +88 -0
- package/dist/frontend/analysis.js.map +1 -0
- package/dist/frontend/arguments-usage.d.ts +1 -3
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -1
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-lexer.d.ts +4 -25
- package/dist/frontend/cjs-lexer.js +6 -806
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/cjs-resolve.d.ts +5 -0
- package/dist/frontend/cjs-resolve.js +429 -0
- package/dist/frontend/cjs-resolve.js.map +1 -0
- package/dist/frontend/cjs-syntax.d.ts +26 -0
- package/dist/frontend/cjs-syntax.js +806 -0
- package/dist/frontend/cjs-syntax.js.map +1 -0
- package/dist/frontend/comptime-node.d.ts +4 -0
- package/dist/frontend/comptime-node.js +16 -0
- package/dist/frontend/comptime-node.js.map +1 -0
- package/dist/frontend/comptime-node.test.d.ts +1 -0
- package/dist/frontend/comptime-node.test.js +37 -0
- package/dist/frontend/comptime-node.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +3 -4
- package/dist/frontend/dts-paths.js +15 -8
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +2 -2
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/helper-tokens.d.ts +1 -0
- package/dist/frontend/helper-tokens.js +147 -0
- package/dist/frontend/helper-tokens.js.map +1 -0
- package/dist/frontend/helper-tokens.test.d.ts +1 -0
- package/dist/frontend/helper-tokens.test.js +35 -0
- package/dist/frontend/helper-tokens.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
- package/dist/frontend/inferred-js-diagnostics.js +69 -0
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +5 -2
- package/dist/frontend/input-tracker.js +24 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +23 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +32 -24
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.d.ts +4 -0
- package/dist/frontend/literal-values.js +21 -0
- package/dist/frontend/literal-values.js.map +1 -0
- package/dist/frontend/literal-values.test.d.ts +1 -0
- package/dist/frontend/literal-values.test.js +91 -0
- package/dist/frontend/literal-values.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
- package/dist/frontend/lowering/abstract-equality.js +3 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -1
- package/dist/frontend/lowering/array-values.js +43 -1
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
- package/dist/frontend/lowering/class-callbacks.js +63 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +9 -0
- package/dist/frontend/lowering/class-descriptors.js +73 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +41 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +803 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +92 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
- package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
- package/dist/frontend/lowering/class-instance-constructor.js +64 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +10 -0
- package/dist/frontend/lowering/class-method-values.js +170 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +16 -0
- package/dist/frontend/lowering/class-prototypes.js +134 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-static-data.d.ts +6 -0
- package/dist/frontend/lowering/class-static-data.js +56 -0
- package/dist/frontend/lowering/class-static-data.js.map +1 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
- package/dist/frontend/lowering/containers/bytes.js +164 -155
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +39 -16
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
- package/dist/frontend/lowering/containers/string-replacement.js +217 -0
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
- package/dist/frontend/lowering/error-methods.d.ts +11 -0
- package/dist/frontend/lowering/error-methods.js +78 -0
- package/dist/frontend/lowering/error-methods.js.map +1 -0
- package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
- package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
- package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
- package/dist/frontend/lowering/expressions/native-proxy.js +49 -0
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +124 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
- package/dist/frontend/lowering/expressions/object-literals.js +473 -178
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +20 -8
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
- package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
- package/dist/frontend/lowering/function-context.d.ts +93 -0
- package/dist/frontend/lowering/function-context.js +103 -0
- package/dist/frontend/lowering/function-context.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
- package/dist/frontend/lowering/generator-delegation.js +85 -0
- package/dist/frontend/lowering/generator-delegation.js.map +1 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +10 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +105 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +2 -1
- package/dist/frontend/lowering/lib-boundary.js +59 -20
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
- package/dist/frontend/lowering/lib-boundary.test.js +45 -0
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +139 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +27 -41
- package/dist/frontend/lowering/lower-builtins.js +539 -343
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +20 -17
- package/dist/frontend/lowering/lower-calls.js +1236 -353
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +83 -45
- package/dist/frontend/lowering/lower-classes.js +952 -339
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +23 -32
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +27 -32
- package/dist/frontend/lowering/lower-containers.js +796 -151
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +1 -1
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
- package/dist/frontend/lowering/lower-event-emitter.js +58 -26
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +7 -1
- package/dist/frontend/lowering/lower-expando.js +14 -6
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +35 -11
- package/dist/frontend/lowering/lower-exprs.js +1674 -779
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +2 -5
- package/dist/frontend/lowering/lower-generators.js +77 -46
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
- package/dist/frontend/lowering/lower-global-value.js +17 -0
- package/dist/frontend/lowering/lower-global-value.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +17 -8
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +5 -8
- package/dist/frontend/lowering/lower-island.js +34 -23
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
- package/dist/frontend/lowering/lower-mixins.js +5 -3
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +233 -30
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
- package/dist/frontend/lowering/lower-node-module.js +13 -10
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +6 -10
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +10 -14
- package/dist/frontend/lowering/lower-stmts.js +728 -496
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -1
- package/dist/frontend/lowering/lower-stream.js +19 -10
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +1 -1
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-url.d.ts +6 -0
- package/dist/frontend/lowering/lower-url.js +77 -0
- package/dist/frontend/lowering/lower-url.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +113 -189
- package/dist/frontend/lowering/lowerer.js +1031 -672
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
- package/dist/frontend/lowering/lowerer.test.js +26 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -0
- package/dist/frontend/lowering/native-ffi.d.ts +5 -0
- package/dist/frontend/lowering/native-ffi.js +40 -0
- package/dist/frontend/lowering/native-ffi.js.map +1 -0
- package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
- package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
- package/dist/frontend/lowering/object-factory-new.js +68 -0
- package/dist/frontend/lowering/object-factory-new.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +6 -1
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +2 -1
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
- package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
- package/dist/frontend/lowering/sanitize-class-types.js +79 -0
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +5 -1
- package/dist/frontend/lowering/static-this.js +28 -2
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.d.ts +7 -0
- package/dist/frontend/lowering/string-index.js +39 -0
- package/dist/frontend/lowering/string-index.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +8 -3
- package/dist/frontend/lowering/surfaces.js +61 -29
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
- package/dist/frontend/lowering/symbol-fields.js +183 -0
- package/dist/frontend/lowering/symbol-fields.js.map +1 -0
- package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
- package/dist/frontend/lowering/symbol-methods.js +30 -0
- package/dist/frontend/lowering/symbol-methods.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.d.ts +10 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +77 -0
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.d.ts +9 -0
- package/dist/frontend/lowering/union-narrow.js +59 -0
- package/dist/frontend/lowering/union-narrow.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
- package/dist/frontend/lowering/union-narrow.test.js +72 -0
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
- package/dist/frontend/lowering/union-retag.d.ts +43 -0
- package/dist/frontend/lowering/union-retag.js +259 -0
- package/dist/frontend/lowering/union-retag.js.map +1 -0
- package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
- package/dist/frontend/lowering/union-retag.test.js +405 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
- package/dist/frontend/lowering/unregistered-class-types.js +94 -0
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +40 -0
- package/dist/frontend/lowering/width-lift.js +2 -0
- package/dist/frontend/lowering/width-lift.js.map +1 -0
- package/dist/frontend/module-syntax.d.ts +58 -0
- package/dist/frontend/module-syntax.js +123 -0
- package/dist/frontend/module-syntax.js.map +1 -0
- package/dist/frontend/module-syntax.test.d.ts +1 -0
- package/dist/frontend/module-syntax.test.js +78 -0
- package/dist/frontend/module-syntax.test.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
- package/dist/frontend/npm-fetch-analysis.js +100 -0
- package/dist/frontend/npm-fetch-analysis.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
- package/dist/frontend/npm-fetch-analysis.test.js +107 -0
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
- package/dist/frontend/npm-fetch-node.d.ts +2 -0
- package/dist/frontend/npm-fetch-node.js +12 -0
- package/dist/frontend/npm-fetch-node.js.map +1 -0
- package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
- package/dist/frontend/npm-fetch-syntax.js +207 -0
- package/dist/frontend/npm-fetch-syntax.js.map +1 -0
- package/dist/frontend/npm-node.d.ts +10 -0
- package/dist/frontend/npm-node.js +14 -0
- package/dist/frontend/npm-node.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
- package/dist/frontend/npm-static-bundled-cjs.js +236 -0
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
- package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
- package/dist/frontend/npm-static-declaration-syntax.js +944 -0
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
- package/dist/frontend/npm-static-declarations.d.ts +11 -39
- package/dist/frontend/npm-static-declarations.js +22 -561
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +245 -6
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.d.ts +1 -1
- package/dist/frontend/npm-static-prune.js +5 -4
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +1 -1
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
- package/dist/frontend/npm-static-rewrite-host.js +179 -0
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
- package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
- package/dist/frontend/npm-static-rewrite.d.ts +0 -5
- package/dist/frontend/npm-static-rewrite.js +2 -1079
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.d.ts +5 -0
- package/dist/frontend/npm-static-subtyping.js +55 -0
- package/dist/frontend/npm-static-subtyping.js.map +1 -0
- package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
- package/dist/frontend/npm-static-subtyping.test.js +58 -0
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +7 -15
- package/dist/frontend/npm-static.js +19 -28
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +8 -69
- package/dist/frontend/npm.js +21 -361
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -2
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.d.ts +6 -0
- package/dist/frontend/pipeline-native.js +32 -0
- package/dist/frontend/pipeline-native.js.map +1 -0
- package/dist/frontend/pipeline.d.ts +54 -0
- package/dist/frontend/pipeline.js +382 -0
- package/dist/frontend/pipeline.js.map +1 -0
- package/dist/frontend/pipeline.test.d.ts +1 -0
- package/dist/frontend/pipeline.test.js +77 -0
- package/dist/frontend/pipeline.test.js.map +1 -0
- package/dist/frontend/program-analysis.d.ts +10 -0
- package/dist/frontend/program-analysis.js +14 -0
- package/dist/frontend/program-analysis.js.map +1 -0
- package/dist/frontend/program-node.d.ts +9 -0
- package/dist/frontend/program-node.js +48 -0
- package/dist/frontend/program-node.js.map +1 -0
- package/dist/frontend/program.d.ts +38 -19
- package/dist/frontend/program.js +344 -169
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +87 -2
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +9 -0
- package/dist/frontend/provenance-core.js +435 -0
- package/dist/frontend/provenance-core.js.map +1 -0
- package/dist/frontend/provenance.d.ts +0 -4
- package/dist/frontend/provenance.js +4 -459
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +3 -1
- package/dist/frontend/resolve.js +6 -3
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +4 -3
- package/dist/frontend/runtime-resolve.js +22 -18
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +53 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +5 -0
- package/dist/frontend/services-node.js +19 -0
- package/dist/frontend/services-node.js.map +1 -0
- package/dist/frontend/services-node.test.d.ts +1 -0
- package/dist/frontend/services-node.test.js +70 -0
- package/dist/frontend/services-node.test.js.map +1 -0
- package/dist/frontend/services.d.ts +44 -0
- package/dist/frontend/services.js +90 -0
- package/dist/frontend/services.js.map +1 -0
- package/dist/frontend/services.test.d.ts +1 -0
- package/dist/frontend/services.test.js +174 -0
- package/dist/frontend/services.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +3 -3
- package/dist/frontend/ts7/adapter.js +14 -31
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/api.d.ts +16 -0
- package/dist/frontend/ts7/api.js +24 -0
- package/dist/frontend/ts7/api.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
- package/dist/frontend/ts7/ast-bytes.js +137 -0
- package/dist/frontend/ts7/ast-bytes.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-bytes.test.js +73 -0
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
- package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-guards.test.js +43 -0
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +194 -0
- package/dist/frontend/ts7/ast-node.js +448 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -0
- package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-node.test.js +266 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -0
- package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
- package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
- package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-text.d.ts +6 -0
- package/dist/frontend/ts7/ast-text.js +124 -0
- package/dist/frontend/ts7/ast-text.js.map +1 -0
- package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-text.test.js +38 -0
- package/dist/frontend/ts7/ast-text.test.js.map +1 -0
- package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
- package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
- package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.d.ts +42 -0
- package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
- package/dist/frontend/ts7/ast-types.generated.js +5 -0
- package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.js +3 -0
- package/dist/frontend/ts7/ast-types.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +58 -0
- package/dist/frontend/ts7/ast-wire.js +267 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire.test.js +151 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +14 -14
- package/dist/frontend/ts7/ast.js +21 -15
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -0
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.d.ts +48 -0
- package/dist/frontend/ts7/checker-cache.js +92 -0
- package/dist/frontend/ts7/checker-cache.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +19 -46
- package/dist/frontend/ts7/checker.js +231 -161
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.d.ts +1 -0
- package/dist/frontend/ts7/checker.test.js +335 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +4 -27
- package/dist/frontend/ts7/enums.generated.d.ts +878 -0
- package/dist/frontend/ts7/enums.generated.js +1313 -0
- package/dist/frontend/ts7/enums.generated.js.map +1 -0
- package/dist/frontend/ts7/enums.js +4 -45
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/enums.test.d.ts +1 -0
- package/dist/frontend/ts7/enums.test.js +48 -0
- package/dist/frontend/ts7/enums.test.js.map +1 -0
- package/dist/frontend/ts7/native-api.d.ts +10 -0
- package/dist/frontend/ts7/native-api.js +10 -0
- package/dist/frontend/ts7/native-api.js.map +1 -0
- package/dist/frontend/ts7/native-host.d.ts +2 -0
- package/dist/frontend/ts7/native-host.js +11 -0
- package/dist/frontend/ts7/native-host.js.map +1 -0
- package/dist/frontend/ts7/native-process.d.ts +14 -0
- package/dist/frontend/ts7/native-process.js +62 -0
- package/dist/frontend/ts7/native-process.js.map +1 -0
- package/dist/frontend/ts7/program-adapter.d.ts +10 -98
- package/dist/frontend/ts7/program-adapter.js +16 -310
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +115 -0
- package/dist/frontend/ts7/program-host.js +347 -0
- package/dist/frontend/ts7/program-host.js.map +1 -0
- package/dist/frontend/ts7/program-host.test.d.ts +1 -0
- package/dist/frontend/ts7/program-host.test.js +207 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-api.d.ts +12 -0
- package/dist/frontend/ts7/rpc-api.js +23 -0
- package/dist/frontend/ts7/rpc-api.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.d.ts +27 -0
- package/dist/frontend/ts7/rpc-client.js +102 -0
- package/dist/frontend/ts7/rpc-client.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-client.test.js +133 -0
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
- package/dist/frontend/ts7/rpc-filesystem.js +42 -0
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.d.ts +2 -0
- package/dist/frontend/ts7/rpc-process.js +148 -0
- package/dist/frontend/ts7/rpc-process.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-process.test.js +29 -0
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
- package/dist/frontend/ts7/rpc-wire.js +195 -0
- package/dist/frontend/ts7/rpc-wire.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.test.js +168 -0
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
- package/dist/frontend/ts7/semantic-checker.js +221 -0
- package/dist/frontend/ts7/semantic-checker.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-checker.test.js +119 -0
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.d.ts +5 -0
- package/dist/frontend/ts7/semantic-json.js +52 -0
- package/dist/frontend/ts7/semantic-json.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-json.test.js +42 -0
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.d.ts +222 -0
- package/dist/frontend/ts7/semantic-model.js +423 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-model.test.js +322 -0
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
- package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
- package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/semantic-types.d.ts +5 -0
- package/dist/frontend/ts7/semantic-types.js +2 -0
- package/dist/frontend/ts7/semantic-types.js.map +1 -0
- package/dist/frontend/ts7/session-cache.d.ts +17 -0
- package/dist/frontend/ts7/session-cache.js +97 -0
- package/dist/frontend/ts7/session-cache.js.map +1 -0
- package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
- package/dist/frontend/ts7/session-cache.test.js +87 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -0
- package/dist/frontend/ts7/session-path.d.ts +18 -0
- package/dist/frontend/ts7/session-path.js +203 -0
- package/dist/frontend/ts7/session-path.js.map +1 -0
- package/dist/frontend/ts7/session-path.test.d.ts +1 -0
- package/dist/frontend/ts7/session-path.test.js +34 -0
- package/dist/frontend/ts7/session-path.test.js.map +1 -0
- package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
- package/dist/frontend/ts7/session-schema.generated.js +5 -0
- package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/session-timing.d.ts +50 -0
- package/dist/frontend/ts7/session-timing.js +61 -0
- package/dist/frontend/ts7/session-timing.js.map +1 -0
- package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
- package/dist/frontend/ts7/session-timing.test.js +52 -0
- package/dist/frontend/ts7/session-timing.test.js.map +1 -0
- package/dist/frontend/ts7/session.d.ts +105 -0
- package/dist/frontend/ts7/session.js +233 -0
- package/dist/frontend/ts7/session.js.map +1 -0
- package/dist/frontend/ts7/session.test.d.ts +1 -0
- package/dist/frontend/ts7/session.test.js +215 -0
- package/dist/frontend/ts7/session.test.js.map +1 -0
- package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
- package/dist/frontend/ts7/source-parser-node.js +15 -0
- package/dist/frontend/ts7/source-parser-node.js.map +1 -0
- package/dist/frontend/ts7/source-parser.d.ts +25 -0
- package/dist/frontend/ts7/source-parser.js +96 -0
- package/dist/frontend/ts7/source-parser.js.map +1 -0
- package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
- package/dist/frontend/ts7/source-parser.test.js +151 -0
- package/dist/frontend/ts7/source-parser.test.js.map +1 -0
- package/dist/frontend/ts7/syntax.d.ts +3 -0
- package/dist/frontend/ts7/syntax.js +4 -0
- package/dist/frontend/ts7/syntax.js.map +1 -0
- package/dist/frontend/tsc-codes.js +3 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +25 -17
- package/dist/frontend/type-mapper.js +465 -121
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +123 -2
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/union-discriminants.d.ts +16 -0
- package/dist/frontend/union-discriminants.js +98 -0
- package/dist/frontend/union-discriminants.js.map +1 -0
- package/dist/frontend/union-discriminants.test.d.ts +1 -0
- package/dist/frontend/union-discriminants.test.js +182 -0
- package/dist/frontend/union-discriminants.test.js.map +1 -0
- package/dist/index.d.ts +7 -198
- package/dist/index.js +369 -1572
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +21 -4
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.js +67 -49
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/control-flow.d.ts +6 -0
- package/dist/ir/control-flow.js +142 -0
- package/dist/ir/control-flow.js.map +1 -0
- package/dist/ir/control-flow.test.d.ts +1 -0
- package/dist/ir/control-flow.test.js +113 -0
- package/dist/ir/control-flow.test.js.map +1 -0
- package/dist/ir/integer-loops.js +7 -18
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.js +53 -27
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +291 -152
- package/dist/ir/ir.js +588 -881
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +127 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/scalar-records.js +165 -134
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +4 -2
- package/dist/ir/serialize.js +19 -12
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +53 -0
- package/dist/ir/serialize.test.js.map +1 -0
- package/dist/ir/traverse.d.ts +41 -0
- package/dist/ir/traverse.js +660 -0
- package/dist/ir/traverse.js.map +1 -0
- package/dist/ir/traverse.test.d.ts +1 -0
- package/dist/ir/traverse.test.js +242 -0
- package/dist/ir/traverse.test.js.map +1 -0
- package/dist/ir/validate.js +1942 -1491
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +476 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +2 -3
- package/dist/library/cache-primitives.js +4 -6
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/fence-eval.js +2 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.js +7 -6
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.d.ts +3 -2
- package/dist/library/library-cache.js +5 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +54 -41
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.d.ts +3 -1
- package/dist/library/library-profile.js +15 -6
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.d.ts +15 -0
- package/dist/library/prepare.js +584 -0
- package/dist/library/prepare.js.map +1 -0
- package/dist/library/semantic-source.d.ts +1 -1
- package/dist/library/semantic-source.js +8 -6
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar-validate.js +4 -4
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +2 -0
- package/dist/library/sidecar.js +10 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/cache.d.ts +11 -0
- package/dist/native/cache.js +113 -0
- package/dist/native/cache.js.map +1 -0
- package/dist/native/cache.test.d.ts +1 -0
- package/dist/native/cache.test.js +66 -0
- package/dist/native/cache.test.js.map +1 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +112 -0
- package/dist/native/cli.js.map +1 -0
- package/dist/native/compiler.d.ts +15 -0
- package/dist/native/compiler.js +336 -0
- package/dist/native/compiler.js.map +1 -0
- package/dist/native/compiler.test.d.ts +1 -0
- package/dist/native/compiler.test.js +174 -0
- package/dist/native/compiler.test.js.map +1 -0
- package/dist/native/comptime.d.ts +5 -0
- package/dist/native/comptime.js +73 -0
- package/dist/native/comptime.js.map +1 -0
- package/dist/native/comptime.test.d.ts +1 -0
- package/dist/native/comptime.test.js +65 -0
- package/dist/native/comptime.test.js.map +1 -0
- package/dist/native/executable-cache.d.ts +26 -0
- package/dist/native/executable-cache.js +228 -0
- package/dist/native/executable-cache.js.map +1 -0
- package/dist/native/executable-cache.test.d.ts +1 -0
- package/dist/native/executable-cache.test.js +151 -0
- package/dist/native/executable-cache.test.js.map +1 -0
- package/dist/native/file-identity.d.ts +4 -0
- package/dist/native/file-identity.js +14 -0
- package/dist/native/file-identity.js.map +1 -0
- package/dist/native/file-identity.test.d.ts +1 -0
- package/dist/native/file-identity.test.js +43 -0
- package/dist/native/file-identity.test.js.map +1 -0
- package/dist/native/library.d.ts +22 -0
- package/dist/native/library.js +83 -0
- package/dist/native/library.js.map +1 -0
- package/dist/native/prepare.d.ts +21 -0
- package/dist/native/prepare.js +174 -0
- package/dist/native/prepare.js.map +1 -0
- package/dist/native/prepare.test.d.ts +1 -0
- package/dist/native/prepare.test.js +70 -0
- package/dist/native/prepare.test.js.map +1 -0
- package/dist/native/sanitizer.d.ts +11 -0
- package/dist/native/sanitizer.js +135 -0
- package/dist/native/sanitizer.js.map +1 -0
- package/dist/native/sanitizer.test.d.ts +1 -0
- package/dist/native/sanitizer.test.js +58 -0
- package/dist/native/sanitizer.test.js.map +1 -0
- package/dist/native/task.d.ts +4 -0
- package/dist/native/task.js +16 -0
- package/dist/native/task.js.map +1 -0
- package/dist/native/task.test.d.ts +1 -0
- package/dist/native/task.test.js +17 -0
- package/dist/native/task.test.js.map +1 -0
- package/dist/native/toolchain.d.ts +45 -0
- package/dist/native/toolchain.js +74 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +33 -0
- package/dist/native/toolchain.test.js.map +1 -0
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +2 -5
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.d.ts +4 -0
- package/dist/timing.js +19 -0
- package/dist/timing.js.map +1 -0
- package/dist/wasi-paths.js +10 -7
- package/dist/wasi-paths.js.map +1 -1
- package/package.json +28 -19
- package/surface-manifest.json +52 -18
- package/dist/backend/c/async.d.ts +0 -171
- package/dist/backend/c/async.js +0 -1317
- package/dist/backend/c/async.js.map +0 -1
- package/dist/backend/c/c-emitter.d.ts +0 -536
- package/dist/backend/c/c-emitter.js +0 -1932
- package/dist/backend/c/c-emitter.js.map +0 -1
- package/dist/backend/c/exprs.d.ts +0 -15
- package/dist/backend/c/exprs.js +0 -8847
- package/dist/backend/c/exprs.js.map +0 -1
- package/dist/backend/c/island.d.ts +0 -45
- package/dist/backend/c/island.js +0 -281
- package/dist/backend/c/island.js.map +0 -1
- package/dist/backend/c/may-throw.js.map +0 -1
- package/dist/backend/c/shapes.d.ts +0 -142
- package/dist/backend/c/shapes.js +0 -603
- package/dist/backend/c/shapes.js.map +0 -1
- package/dist/backend/c/stmts.d.ts +0 -76
- package/dist/backend/c/stmts.js +0 -1108
- package/dist/backend/c/stmts.js.map +0 -1
- package/dist/backend/c/types.d.ts +0 -71
- package/dist/backend/c/types.js +0 -459
- package/dist/backend/c/types.js.map +0 -1
- package/dist/backend/c/types.test.js +0 -32
- package/dist/backend/c/types.test.js.map +0 -1
- package/dist/backend/c/walkers.d.ts +0 -134
- package/dist/backend/c/walkers.js +0 -1772
- package/dist/backend/c/walkers.js.map +0 -1
- /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { InternalCompilerError } from "../errors.js";
|
|
2
2
|
import * as ts from "./ts7/adapter.js";
|
|
3
3
|
import { bodyReadsArguments } from "./arguments-usage.js";
|
|
4
|
-
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/ir.js";
|
|
4
|
+
import { BYTES_ELEMENT_NAME, arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, unionContainerArmsOk, UNDEFINED_T, VOID } from "../ir/ir.js";
|
|
5
5
|
import { BIGINT_T } from "../ir/ir.js";
|
|
6
|
+
import { literalValues } from "./literal-values.js";
|
|
7
|
+
import { remapUnionDiscriminant } from "./union-discriminants.js";
|
|
6
8
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
7
|
-
import { accessorSlotProp } from "../ir/ir.js";
|
|
9
|
+
import { accessorSlotProp, recordTextCodecClass } from "../ir/ir.js";
|
|
8
10
|
// typeKey moved to ir/ir.ts (the backend needs it too, for per-type
|
|
9
11
|
// helper interning); re-exported here so frontend call sites keep their
|
|
10
12
|
// import path.
|
|
11
13
|
export { typeKey };
|
|
14
|
+
/** Empty JS object inference describes no fixed layout. Keep these values
|
|
15
|
+
* in checked storage across fields, parameters and function signatures. */
|
|
16
|
+
export function jsOpenObjectType(decl, type, shapes, unions) {
|
|
17
|
+
if (!decl || !isJsSourceFile(decl.getSourceFile()))
|
|
18
|
+
return type;
|
|
19
|
+
const arms = type.kind === "union" ? unions.get(type.unionId)?.arms : [type];
|
|
20
|
+
const present = arms?.filter((arm) => arm.kind !== "undefinedT");
|
|
21
|
+
if (present?.length !== 1 || present[0].kind !== "record")
|
|
22
|
+
return type;
|
|
23
|
+
const shape = shapes.get(present[0].shapeId);
|
|
24
|
+
return shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple ? DYN : type;
|
|
25
|
+
}
|
|
12
26
|
/** The ambient TYPE names of the fetch slice. Under --dynamic their
|
|
13
27
|
* values live in the embedded engine and map to island handles (jsval).
|
|
14
28
|
* Static fetch gives Response, RequestInit, AbortController/AbortSignal, response
|
|
@@ -67,7 +81,7 @@ export function isParseArgsDynTypeName(name) {
|
|
|
67
81
|
return PARSE_ARGS_DYN_TYPES.has(name);
|
|
68
82
|
}
|
|
69
83
|
function priorityRank(priority) {
|
|
70
|
-
return
|
|
84
|
+
return Array.isArray(priority) ? priority : priority.rank;
|
|
71
85
|
}
|
|
72
86
|
function comparePriority(left, right) {
|
|
73
87
|
const a = priorityRank(left);
|
|
@@ -294,10 +308,9 @@ export class ShapeRegistry {
|
|
|
294
308
|
}
|
|
295
309
|
}
|
|
296
310
|
/** The frontend's union interner — mirrors ShapeRegistry. A union's
|
|
297
|
-
* canonical identity
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* the Lowerer; threaded through mapType exactly like ShapeRegistry. */
|
|
311
|
+
* canonical identity includes its typeKey-sorted arms and literal
|
|
312
|
+
* discriminator contract. An arm's index in that list IS its runtime tag.
|
|
313
|
+
* Owned by the Lowerer; threaded through mapType like ShapeRegistry. */
|
|
301
314
|
export class UnionRegistry {
|
|
302
315
|
byKey = new Map();
|
|
303
316
|
byId = new Map();
|
|
@@ -343,34 +356,39 @@ export class UnionRegistry {
|
|
|
343
356
|
}
|
|
344
357
|
/** Completes a recursive placeholder with its canonical arm list and
|
|
345
358
|
* registers the structural key (first writer wins, like shapes). */
|
|
346
|
-
finalizeRecursive(t, arms) {
|
|
359
|
+
finalizeRecursive(t, arms, discriminant) {
|
|
347
360
|
const id = this.recIds.get(t);
|
|
348
361
|
if (id === undefined)
|
|
349
362
|
throw new InternalCompilerError("union registry bug: finalizeRecursive without a placeholder");
|
|
350
363
|
if (this.pendingRec.has(id)) {
|
|
351
364
|
const def = this.byId.get(id);
|
|
352
365
|
def.arms.push(...arms);
|
|
366
|
+
if (discriminant)
|
|
367
|
+
def.discriminant = discriminant;
|
|
353
368
|
this.pendingRec.delete(id);
|
|
354
|
-
const key = JSON.stringify(arms.map(typeKey));
|
|
369
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
355
370
|
if (!this.byKey.has(key))
|
|
356
371
|
this.byKey.set(key, id);
|
|
357
372
|
}
|
|
358
373
|
return id;
|
|
359
374
|
}
|
|
360
|
-
/** Interns
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const key = JSON.stringify(arms.map(typeKey));
|
|
375
|
+
/** Interns canonical arms and discriminator cases, returning their unionId. */
|
|
376
|
+
intern(arms, discriminant) {
|
|
377
|
+
const key = JSON.stringify([arms.map(typeKey), discriminant]);
|
|
364
378
|
let id = this.byKey.get(key);
|
|
365
379
|
if (id === undefined) {
|
|
366
380
|
id = `u${this.unions.length}`;
|
|
367
|
-
const def = { id, arms };
|
|
381
|
+
const def = { id, arms, ...(discriminant ? { discriminant } : {}) };
|
|
368
382
|
this.byKey.set(key, id);
|
|
369
383
|
this.byId.set(id, def);
|
|
370
384
|
this.unions.push(def);
|
|
371
385
|
}
|
|
372
386
|
return id;
|
|
373
387
|
}
|
|
388
|
+
/** An exact arm transformation keeps the source's semantic variants. */
|
|
389
|
+
transform(source, arms) {
|
|
390
|
+
return this.intern(arms, remapUnionDiscriminant(source, arms));
|
|
391
|
+
}
|
|
374
392
|
get(unionId) {
|
|
375
393
|
return this.byId.get(unionId);
|
|
376
394
|
}
|
|
@@ -442,7 +460,7 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
442
460
|
case "bytes":
|
|
443
461
|
// The u8 kind reads as Uint8Array (Buffer maps here too — one
|
|
444
462
|
// runtime representation; the message stays honest either way).
|
|
445
|
-
return append(t.elem
|
|
463
|
+
return append(BYTES_ELEMENT_NAME[t.elem]);
|
|
446
464
|
case "map":
|
|
447
465
|
append("Map<");
|
|
448
466
|
child(t.key);
|
|
@@ -471,6 +489,9 @@ export function formatIrType(t, shapes, unions, seen = new Set()) {
|
|
|
471
489
|
const shape = shapes.get(t.shapeId);
|
|
472
490
|
if (!shape)
|
|
473
491
|
return append(`{ /* unknown shape ${t.shapeId} */ }`);
|
|
492
|
+
const codec = recordTextCodecClass(shape);
|
|
493
|
+
if (codec !== null)
|
|
494
|
+
return append(codec);
|
|
474
495
|
if (seen.has(t.shapeId))
|
|
475
496
|
return append("..."); // the recursive knot
|
|
476
497
|
seen.add(t.shapeId);
|
|
@@ -704,8 +725,8 @@ export function containsUnion(t) {
|
|
|
704
725
|
* - next: void/undefined/never mean valueless resumes (the undefined
|
|
705
726
|
* unit); any/unknown ride dyn; else the mapped type (`.next(v)` then
|
|
706
727
|
* requires its argument — fenced at the call site).
|
|
707
|
-
* Mixed dyn/concrete value channels
|
|
708
|
-
* record's value slot
|
|
728
|
+
* Mixed dyn/concrete value channels both use checked values because the
|
|
729
|
+
* shared result record's value slot has one representation. */
|
|
709
730
|
function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
710
731
|
if (!yieldTs)
|
|
711
732
|
return null;
|
|
@@ -736,7 +757,7 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
|
|
|
736
757
|
const dynMix = (yieldT.kind === "dyn" && retT.kind !== "dyn" && retT.kind !== "void") ||
|
|
737
758
|
(retT.kind === "dyn" && yieldT.kind !== "dyn" && yieldT.kind !== "void");
|
|
738
759
|
if (dynMix)
|
|
739
|
-
return
|
|
760
|
+
return { yieldT: DYN, retT: DYN, nextT };
|
|
740
761
|
return { yieldT, retT, nextT };
|
|
741
762
|
}
|
|
742
763
|
/** SELF-REFERENTIAL types recurse through mapType with no structural floor:
|
|
@@ -788,16 +809,10 @@ export function mapType(type, ctx) {
|
|
|
788
809
|
mapTypeDepth--;
|
|
789
810
|
}
|
|
790
811
|
}
|
|
791
|
-
/**
|
|
792
|
-
*
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
* naming a struct that will never be emitted is the invalid-C escape
|
|
796
|
-
* family (every SITE using the value already carries its own fence). */
|
|
797
|
-
function classExprNeverRegisters(decl) {
|
|
798
|
-
if (!ts.isClassExpression(decl))
|
|
799
|
-
return false;
|
|
800
|
-
for (let p = decl.parent; !ts.isSourceFile(p); p = p.parent) {
|
|
812
|
+
/** Local class types need the enclosing specialization's registered layout.
|
|
813
|
+
* Static-block classes are sent through the same hook for an explicit fence. */
|
|
814
|
+
function classExprNeedsContext(decl) {
|
|
815
|
+
for (let p = decl.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
801
816
|
if (ts.isFunctionLike(p) || ts.isClassStaticBlockDeclaration(p))
|
|
802
817
|
return true;
|
|
803
818
|
}
|
|
@@ -805,6 +820,11 @@ function classExprNeverRegisters(decl) {
|
|
|
805
820
|
}
|
|
806
821
|
function mapTypeInner(type, ctx) {
|
|
807
822
|
const { checker, unions, classNamer, resolveTypeParam } = ctx;
|
|
823
|
+
// TypeScript's intrinsic globalThis symbol has no declaration. A stored
|
|
824
|
+
// reference needs native object identity, including var's undefined state.
|
|
825
|
+
const intrinsic = type.getSymbol();
|
|
826
|
+
if (!ctx.dynamic && intrinsic?.name === "globalThis" && checker.declarationsOf(intrinsic).length === 0)
|
|
827
|
+
return DYN;
|
|
808
828
|
if (!ctx.dynamic) {
|
|
809
829
|
const moduleId = ctx.moduleNamespaceId?.(type) ?? null;
|
|
810
830
|
if (moduleId !== null)
|
|
@@ -866,6 +886,15 @@ function mapTypeInner(type, ctx) {
|
|
|
866
886
|
return STRING;
|
|
867
887
|
if (flags & ts.TypeFlags.Boolean || flags & ts.TypeFlags.BooleanLiteral)
|
|
868
888
|
return BOOL;
|
|
889
|
+
// ErrorOptions carries a presence-sensitive unknown value. A fixed
|
|
890
|
+
// optional field cannot distinguish {} from { cause: undefined }; the
|
|
891
|
+
// checked-dynamic object retains that distinction through forwarding
|
|
892
|
+
// constructors. Only the standard library's interface gets this ABI.
|
|
893
|
+
const errorOptionsSymbol = widened.getSymbol();
|
|
894
|
+
if (errorOptionsSymbol?.name === "ErrorOptions" &&
|
|
895
|
+
checker.declarationsOf(errorOptionsSymbol).some((d) => ctx.isStdlibFile(d.getSourceFile()))) {
|
|
896
|
+
return DYN;
|
|
897
|
+
}
|
|
869
898
|
// node:util.parseArgs config/results are declaration-heavy conditional
|
|
870
899
|
// and discriminated-union types over a value that is naturally a checked-
|
|
871
900
|
// dynamic tree. Keep the named public surface (plus @types/node's private
|
|
@@ -876,12 +905,29 @@ function mapTypeInner(type, ctx) {
|
|
|
876
905
|
// user aliases with the same names on the normal structural path.
|
|
877
906
|
{
|
|
878
907
|
const parseArgsSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
908
|
+
const belongs = (declaration) => {
|
|
909
|
+
if (!ctx.isStdlibFile(declaration.getSourceFile()))
|
|
910
|
+
return false;
|
|
911
|
+
let family = false;
|
|
912
|
+
for (let node = declaration; node; node = node.parent) {
|
|
913
|
+
if ((ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) &&
|
|
914
|
+
PARSE_ARGS_DYN_TYPES.has(node.name.text))
|
|
915
|
+
family = true;
|
|
916
|
+
if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name)) {
|
|
917
|
+
return family && (node.name.text === "util" || node.name.text === "node:util");
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
};
|
|
922
|
+
if (parseArgsSym && PARSE_ARGS_DYN_TYPES.has(parseArgsSym.name) &&
|
|
923
|
+
checker.declarationsOf(parseArgsSym).some(belongs))
|
|
924
|
+
return DYN;
|
|
925
|
+
// ReturnType and instantiated conditional types can erase the alias.
|
|
926
|
+
// Require every member to retain the util declaration provenance so
|
|
927
|
+
// unrelated records with similar property names keep their own layout.
|
|
928
|
+
const members = checker.getPropertiesOfType(widened);
|
|
929
|
+
if (members.length > 0 && members.every((member) => checker.declarationsOf(member).some(belongs)))
|
|
883
930
|
return DYN;
|
|
884
|
-
}
|
|
885
931
|
}
|
|
886
932
|
// The lib's BOXED wrapper interfaces used as TYPES (`const n: Number =
|
|
887
933
|
// 5`): every value such a slot can hold IS the primitive — `new
|
|
@@ -933,6 +979,21 @@ function mapTypeInner(type, ctx) {
|
|
|
933
979
|
// position knows it wants a value; this mapping cannot.
|
|
934
980
|
if (flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined))
|
|
935
981
|
return VOID;
|
|
982
|
+
// Generic visitors can instantiate `T | undefined` as `void | undefined`.
|
|
983
|
+
// It has the same return convention as standalone void; value positions
|
|
984
|
+
// still substitute the unit-only slot through isUnitOnlyTsType below.
|
|
985
|
+
if (widened.isUnionType() && ts.constituentTypes(widened).every((part) => {
|
|
986
|
+
if ((part.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined)) !== 0)
|
|
987
|
+
return true;
|
|
988
|
+
// A forwarding generic call keeps its caller's symbolic T in the
|
|
989
|
+
// resolved signature. Its current instantiation can still be void.
|
|
990
|
+
if ((part.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(part)?.kind === "void") {
|
|
991
|
+
contextResolutions++;
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
994
|
+
return false;
|
|
995
|
+
}))
|
|
996
|
+
return VOID;
|
|
936
997
|
// Standalone `null` (a `const x = null` binding, a `{ value: null }`
|
|
937
998
|
// field, a `(): null` return): the unit-only union — the value is always
|
|
938
999
|
// THE interned null instance, comparisons are tag tests, JSON serializes
|
|
@@ -1047,7 +1108,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1047
1108
|
// function VALUE is one ScrClosure for its whole life — top-level
|
|
1048
1109
|
// declarations intern one immortal closure, and inner closures are
|
|
1049
1110
|
// allocated once at their definition's evaluation and flow by
|
|
1050
|
-
// reference, exactly JS's function identity.
|
|
1111
|
+
// reference, exactly JS's function identity. Maps and Sets use their
|
|
1112
|
+
// typed RC/trace adapters; RegExp values use immutable REF storage. URL and
|
|
1051
1113
|
// Date (scalar-backed but identity-bearing in JS) and the other opaque
|
|
1052
1114
|
// handles stay unsupported as array elements; ordinary Date locals,
|
|
1053
1115
|
// params, fixed record/tuple fields, and promise payloads are supported.
|
|
@@ -1059,7 +1121,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1059
1121
|
// `undefined[]` (sparse literals — `[,]` — and explicit annotations):
|
|
1060
1122
|
// the element rides the unit-only union like a record field would; the
|
|
1061
1123
|
// VOID mapping is a return-position artifact, not a value.
|
|
1062
|
-
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs))
|
|
1124
|
+
if (elem?.kind === "void" && isUnitOnlyTsType(elemTs, ctx.resolveTypeParam))
|
|
1063
1125
|
elem = unitOnlyUnion(unions);
|
|
1064
1126
|
// A jsval element ABSORBS the array — with one carve-out. An array
|
|
1065
1127
|
// type entangled with package-declared ('npm-jsval') elements
|
|
@@ -1077,15 +1139,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1077
1139
|
// A dyn ELEMENT makes the WHOLE array the checked-dynamic value:
|
|
1078
1140
|
// `unknown[]`, `object[]`, and the collapsed `(string | object)[]`
|
|
1079
1141
|
// (the plugins-slot shape) — the checked-dynamic tree has real arrays, so length/
|
|
1080
|
-
// index/push/iteration ride the keyed-dyn paths
|
|
1081
|
-
//
|
|
1082
|
-
//
|
|
1142
|
+
// index/push/iteration ride the keyed-dyn paths. Native dyn-element
|
|
1143
|
+
// vectors are reserved for collection seeds and drains, rather than
|
|
1144
|
+
// changing this public representation. This is dynFallbackType's JS stance promoted into
|
|
1083
1145
|
// the mapping itself; construction sites build dynArrLit (the checked-dynamic tree
|
|
1084
1146
|
// array literal) and typed sources convert per element at the slot.
|
|
1085
1147
|
if (elem.kind === "dyn")
|
|
1086
1148
|
return DYN;
|
|
1087
1149
|
// The shared predicate is the runtime/backend storage contract. In
|
|
1088
|
-
// particular, valid standalone values such as
|
|
1150
|
+
// particular, valid standalone values such as Date and opaque
|
|
1089
1151
|
// handles do not automatically have an array element representation.
|
|
1090
1152
|
if (!isSupportedArrayElem(elem))
|
|
1091
1153
|
return null;
|
|
@@ -1142,7 +1204,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1142
1204
|
let et = mapType(args[i], ctx);
|
|
1143
1205
|
// A unit-only element (`[number, undefined]`) rides the unit-only
|
|
1144
1206
|
// union, the record-field rule.
|
|
1145
|
-
if (et?.kind === "void" && isUnitOnlyTsType(args[i]))
|
|
1207
|
+
if (et?.kind === "void" && isUnitOnlyTsType(args[i], ctx.resolveTypeParam))
|
|
1146
1208
|
et = unitOnlyUnion(unions);
|
|
1147
1209
|
// dyn ELEMENTS map now — `[string, unknown]`, the Object.entries
|
|
1148
1210
|
// tuple over an `unknown`-valued index signature (the pricing-table
|
|
@@ -1170,8 +1232,6 @@ function mapTypeInner(type, ctx) {
|
|
|
1170
1232
|
if (brandedPrimitive)
|
|
1171
1233
|
return brandedPrimitive;
|
|
1172
1234
|
}
|
|
1173
|
-
// Class instances: the type's symbol is a class declared in the user's
|
|
1174
|
-
// file. The class NAME as a value has the *constructor* type — same
|
|
1175
1235
|
// REFINED handle intersections — @types/node's idioms: `ServerResponse<
|
|
1176
1236
|
// IncomingMessage> & { req: IncomingMessage }` (RequestListener's
|
|
1177
1237
|
// inferred res param — every unannotated http.createServer handler) and
|
|
@@ -1223,8 +1283,11 @@ function mapTypeInner(type, ctx) {
|
|
|
1223
1283
|
}
|
|
1224
1284
|
}
|
|
1225
1285
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1286
|
+
const classView = mapClassView(widened, ctx);
|
|
1287
|
+
if (classView !== undefined)
|
|
1288
|
+
return classView;
|
|
1289
|
+
// Class instances name a program class. The same symbol with construct
|
|
1290
|
+
// signatures names its static side, mapped to classval below.
|
|
1228
1291
|
const widenedSym = widened.getSymbol();
|
|
1229
1292
|
const classDecl = widenedSym ? checker.valueDeclarationOf(widenedSym) : undefined;
|
|
1230
1293
|
if (classDecl &&
|
|
@@ -1251,17 +1314,17 @@ function mapTypeInner(type, ctx) {
|
|
|
1251
1314
|
return viaMixin;
|
|
1252
1315
|
}
|
|
1253
1316
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1317
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1318
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1319
|
+
if (local)
|
|
1320
|
+
contextResolutions++;
|
|
1321
|
+
return local ?? null;
|
|
1322
|
+
}
|
|
1258
1323
|
// A GENERIC class's instance type (`Box<number>`) maps to the concrete
|
|
1259
1324
|
// INSTANTIATION's class (`Box%0`), registered on demand — the Lowerer
|
|
1260
1325
|
// hook owns the instance table (monomorphization by flow).
|
|
1261
1326
|
if (classDecl.typeParameters) {
|
|
1262
|
-
const instance = ctx.genericClassInstance
|
|
1263
|
-
? ctx.genericClassInstance(classDecl, widened)
|
|
1264
|
-
: null;
|
|
1327
|
+
const instance = ctx.genericClassInstance?.(classDecl, widened, (argument) => mapType(argument, ctx)) ?? null;
|
|
1265
1328
|
// Before the generic declaration's collection turn, the hook can only
|
|
1266
1329
|
// return its family shell; after collection the same checker type names
|
|
1267
1330
|
// a concrete registered instance. Never memoize either phase's answer.
|
|
@@ -1289,8 +1352,14 @@ function mapTypeInner(type, ctx) {
|
|
|
1289
1352
|
return { kind: "classval", className: viaMixin.className };
|
|
1290
1353
|
}
|
|
1291
1354
|
}
|
|
1292
|
-
if (
|
|
1355
|
+
if (classExprNeedsContext(classDecl)) {
|
|
1356
|
+
const local = ctx.localClassInstance?.(classDecl);
|
|
1357
|
+
if (local?.kind === "object") {
|
|
1358
|
+
contextResolutions++;
|
|
1359
|
+
return { kind: "classval", className: local.className };
|
|
1360
|
+
}
|
|
1293
1361
|
return null;
|
|
1362
|
+
}
|
|
1294
1363
|
// A GENERIC class's static side: only an INSTANTIATED one maps — an
|
|
1295
1364
|
// instantiation expression's type (`Box<number>` as a value) carries a
|
|
1296
1365
|
// construct signature returning the concrete instance, which maps to
|
|
@@ -1335,8 +1404,7 @@ function mapTypeInner(type, ctx) {
|
|
|
1335
1404
|
const psym = widened.getSymbol();
|
|
1336
1405
|
const isStdlibInterface = (name) => psym?.name === name &&
|
|
1337
1406
|
checker.declarationsOf(psym).some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()));
|
|
1338
|
-
// The builtin Error classes: references to the
|
|
1339
|
-
// RangeError/SyntaxError interfaces map to the runtime-provided class
|
|
1407
|
+
// The builtin Error classes: references to the lib's Error interfaces map to the runtime-provided class
|
|
1340
1408
|
// hierarchy (provenance, not the name — a user's own `class Error`
|
|
1341
1409
|
// resolved through the class-instance branch above, and a user
|
|
1342
1410
|
// `interface Error` maps as a record). The '%'-prefixed IR names are the
|
|
@@ -1421,6 +1489,15 @@ function mapTypeInner(type, ctx) {
|
|
|
1421
1489
|
isDeclaredInAmbientModule(d, "diagnostics_channel"))) {
|
|
1422
1490
|
return F64;
|
|
1423
1491
|
}
|
|
1492
|
+
// WHATWG codec instances have ordinary reference identity and ownership.
|
|
1493
|
+
// Their private encoding slot is omitted from enumeration and JSON.
|
|
1494
|
+
if ((psym?.name === "TextEncoder" || psym?.name === "TextDecoder") &&
|
|
1495
|
+
checker.declarationsOf(psym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && ctx.isStdlibFile(d.getSourceFile()))) {
|
|
1496
|
+
return {
|
|
1497
|
+
kind: "record",
|
|
1498
|
+
shapeId: ctx.shapes.intern([{ name: `%${psym.name}`, type: F64 }], false, undefined, []),
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1424
1501
|
// string_decoder.StringDecoder: the decoder value is a two-field record
|
|
1425
1502
|
// — the CANONICAL encoding name (construction normalizes aliases; the
|
|
1426
1503
|
// `.encoding` property reads it) and the f64 packing the pending
|
|
@@ -1449,9 +1526,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1449
1526
|
// record-holding binding forms compile. User-declared literals with
|
|
1450
1527
|
// these member names keep the ordinary record path (their declarations
|
|
1451
1528
|
// are not in declaration files).
|
|
1529
|
+
const promiseDeclarations = psym ? checker.declarationsOf(psym) : [];
|
|
1452
1530
|
if (flags & ts.TypeFlags.Object &&
|
|
1453
|
-
|
|
1454
|
-
|
|
1531
|
+
promiseDeclarations.length > 0 &&
|
|
1532
|
+
promiseDeclarations.every((d) => d.getSourceFile().isDeclarationFile)) {
|
|
1455
1533
|
const props = checker.getPropertiesOfType(widened);
|
|
1456
1534
|
if (props.length === 3 &&
|
|
1457
1535
|
["promise", "resolve", "reject"].every((n) => props.some((p) => p.name === n))) {
|
|
@@ -1544,26 +1622,33 @@ function mapTypeInner(type, ctx) {
|
|
|
1544
1622
|
const args = checker.getTypeArguments(widened);
|
|
1545
1623
|
if (args.length !== 2)
|
|
1546
1624
|
return null;
|
|
1547
|
-
const key = mapType(args[0], ctx);
|
|
1548
|
-
if (!key || !isSupportedMapKey(key))
|
|
1625
|
+
const key = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1626
|
+
if (!key || !isSupportedMapKey(key, key.kind === "union" ? ctx.unions.get(key.unionId)?.arms : undefined))
|
|
1549
1627
|
return null;
|
|
1550
|
-
const value = mapType(args[1], ctx);
|
|
1628
|
+
const value = !ctx.dynamic && (args[1].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[1], ctx);
|
|
1551
1629
|
if (!value || !isSupportedMapValue(value))
|
|
1552
1630
|
return null;
|
|
1553
1631
|
return mapOf(key, value);
|
|
1554
1632
|
}
|
|
1555
|
-
//
|
|
1556
|
-
//
|
|
1633
|
+
// Native WeakMap keeps reference identities in checked-dynamic storage.
|
|
1634
|
+
// The runtime rejects reference kinds without a weak lifetime contract.
|
|
1635
|
+
if (isStdlibInterface("WeakMap") || isStdlibInterface("WeakSet"))
|
|
1636
|
+
return ctx.dynamic ? JSVAL : DYN;
|
|
1637
|
+
// Set<T>: Map's sibling — same provenance rule and key domain.
|
|
1638
|
+
// Anything else stays unmapped;
|
|
1557
1639
|
// the `new Set` lowering names the offending element type specifically.
|
|
1558
1640
|
if (isStdlibInterface("Set") || isStdlibInterface("ReadonlySet")) {
|
|
1559
1641
|
const args = checker.getTypeArguments(widened);
|
|
1560
1642
|
if (args.length !== 1)
|
|
1561
1643
|
return null;
|
|
1562
|
-
const elem = mapType(args[0], ctx);
|
|
1563
|
-
if (!elem || !isSupportedSetElem(elem))
|
|
1644
|
+
const elem = !ctx.dynamic && (args[0].flags & ts.TypeFlags.Any) !== 0 ? DYN : mapType(args[0], ctx);
|
|
1645
|
+
if (!elem || !isSupportedSetElem(elem, elem.kind === "union" ? ctx.unions.get(elem.unionId)?.arms : undefined))
|
|
1564
1646
|
return null;
|
|
1565
1647
|
return setOf(elem);
|
|
1566
1648
|
}
|
|
1649
|
+
const collectionView = mapCollectionView(widened, ctx);
|
|
1650
|
+
if (collectionView)
|
|
1651
|
+
return collectionView;
|
|
1567
1652
|
// Date: a TimeClip'd epoch-millisecond scalar in the static runtime.
|
|
1568
1653
|
// This supports stored/passed values and the read-only getter slice;
|
|
1569
1654
|
// identity and mutation stay fenced because the scalar deliberately
|
|
@@ -1577,6 +1662,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1577
1662
|
if (isStdlibInterface("RegExp")) {
|
|
1578
1663
|
return { kind: "regex" };
|
|
1579
1664
|
}
|
|
1665
|
+
if (isStdlibInterface("Segmenter") || isStdlibInterface("Segments") || isStdlibInterface("SegmentData"))
|
|
1666
|
+
return DYN;
|
|
1580
1667
|
// Typed arrays: references to the lib's Uint8Array/Uint32Array/
|
|
1581
1668
|
// Float32Array/Float64Array interfaces (provenance, not names). The es2022+ lib
|
|
1582
1669
|
// declares them generic over the backing buffer (`Uint8Array<ArrayBuffer>`
|
|
@@ -1616,10 +1703,20 @@ function mapTypeInner(type, ctx) {
|
|
|
1616
1703
|
// space, so clearTimeout of an Immediate no-ops like Node.
|
|
1617
1704
|
if (isStdlibInterface("Immediate"))
|
|
1618
1705
|
return F64;
|
|
1706
|
+
if (isStdlibInterface("ArrayBuffer") || isStdlibInterface("PropertyDescriptor") || isStdlibInterface("ProcessVersions"))
|
|
1707
|
+
return DYN;
|
|
1619
1708
|
if (isStdlibInterface("Uint8Array"))
|
|
1620
1709
|
return bytesOf("u8");
|
|
1621
1710
|
if (isStdlibInterface("Uint32Array"))
|
|
1622
1711
|
return bytesOf("u32");
|
|
1712
|
+
if (isStdlibInterface("Uint8ClampedArray"))
|
|
1713
|
+
return bytesOf("u8c");
|
|
1714
|
+
if (isStdlibInterface("Int8Array"))
|
|
1715
|
+
return bytesOf("i8");
|
|
1716
|
+
if (isStdlibInterface("Uint16Array"))
|
|
1717
|
+
return bytesOf("u16");
|
|
1718
|
+
if (isStdlibInterface("Int16Array"))
|
|
1719
|
+
return bytesOf("i16");
|
|
1623
1720
|
// Int32Array: the signed 32-bit kind (element reads sign-extend, writes
|
|
1624
1721
|
// ToInt32-wrap) — the Atomics.wait sleep idiom constructs one over a
|
|
1625
1722
|
// SharedArrayBuffer, and the i32 semantics hold for every other use.
|
|
@@ -1972,8 +2069,8 @@ function mapTypeInner(type, ctx) {
|
|
|
1972
2069
|
// boxes; the yield expression reads checked-dynamic);
|
|
1973
2070
|
// else the mapped type (`.next(v)` requires its
|
|
1974
2071
|
// argument — fenced at the call).
|
|
1975
|
-
// Mixed dyn/concrete channels
|
|
1976
|
-
//
|
|
2072
|
+
// Mixed dyn/concrete value channels share checked storage, so either
|
|
2073
|
+
// branch of the result record has the same representation.
|
|
1977
2074
|
if (isStdlibInterface("Generator") || isStdlibInterface("AsyncGenerator") || isStdlibInterface("IterableIterator")) {
|
|
1978
2075
|
const args = checker.getTypeArguments(widened);
|
|
1979
2076
|
const channels = genChannels(args[0], args[1], args[2], ctx);
|
|
@@ -2313,10 +2410,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2313
2410
|
ts.isParameter(decl) &&
|
|
2314
2411
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
2315
2412
|
let pt = mapType(checker.getTypeOfSymbol(p), ctx);
|
|
2413
|
+
if (pt)
|
|
2414
|
+
pt = jsOpenObjectType(decl, pt, ctx.shapes, ctx.unions);
|
|
2316
2415
|
// Belt and braces for non-strict type worlds: an optional param's
|
|
2317
2416
|
// ABI slot is always the undefined-armed union (strictNullChecks
|
|
2318
2417
|
// already spells it that way; arm it here if the world didn't).
|
|
2319
|
-
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval") {
|
|
2418
|
+
if (optional && pt && pt.kind !== "void" && pt.kind !== "jsval" && pt.kind !== "dyn") {
|
|
2320
2419
|
const armed = withUndefinedArm(pt, ctx.unions);
|
|
2321
2420
|
if (!armed)
|
|
2322
2421
|
return null;
|
|
@@ -2338,8 +2437,13 @@ function mapTypeInner(type, ctx) {
|
|
|
2338
2437
|
const retT = checker.getReturnTypeOfSignature(sig);
|
|
2339
2438
|
// `() => never` (a throw-only lambda's inferred type) is assignable to
|
|
2340
2439
|
// `() => void` and its calls never produce a value — map the return
|
|
2341
|
-
// like declaredReturnType does for declarations.
|
|
2342
|
-
|
|
2440
|
+
// like declaredReturnType does for declarations. JS null/undefined
|
|
2441
|
+
// returns can read mutable fields, so callable values use the same
|
|
2442
|
+
// checked-native return ABI as their implementations.
|
|
2443
|
+
const sigDecl = checker.signatureDeclaration(sig);
|
|
2444
|
+
const jsUnitReturn = sigDecl !== undefined && isJsSourceFile(sigDecl.getSourceFile()) &&
|
|
2445
|
+
(retT.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0;
|
|
2446
|
+
const ret = jsUnitReturn ? DYN : retT.flags & ts.TypeFlags.Never ? VOID : mapType(retT, ctx);
|
|
2343
2447
|
if (!ret)
|
|
2344
2448
|
return null;
|
|
2345
2449
|
return typedRest
|
|
@@ -2430,7 +2534,7 @@ function mapTypeInner(type, ctx) {
|
|
|
2430
2534
|
// literal unions like `"a" | "b"` — parts that map to the SAME IR type
|
|
2431
2535
|
// collapse (deduplicated by typeKey), so a single surviving arm is just
|
|
2432
2536
|
// that type. Two or more distinct arms become a TAGGED union: the
|
|
2433
|
-
// typeKey-sorted arm list
|
|
2537
|
+
// typeKey-sorted arm list and discriminator are interned, and an arm's index
|
|
2434
2538
|
// in that list is its runtime tag. `undefined` and `null` PARTS become
|
|
2435
2539
|
// the unit arms undefinedT/nullT — strictNullChecks spells optionality
|
|
2436
2540
|
// as exactly these unions (`string | undefined`, `number | null`), and
|
|
@@ -2454,7 +2558,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2454
2558
|
const sensitivityAtEntry = contextResolutions;
|
|
2455
2559
|
try {
|
|
2456
2560
|
const byKey = new Map();
|
|
2561
|
+
const recordParts = [];
|
|
2457
2562
|
for (const part of ts.constituentTypes(widened)) {
|
|
2563
|
+
// TypeScript's client can retain impossible intersections in a
|
|
2564
|
+
// distributed union. They have no inhabitants and no runtime tag.
|
|
2565
|
+
if (checker.isNeverType(part))
|
|
2566
|
+
continue;
|
|
2458
2567
|
// A `void` PART is inhabited only by undefined (`Promise<void> |
|
|
2459
2568
|
// void` return types, `string | void`): it becomes the undefinedT
|
|
2460
2569
|
// unit arm, exactly like an undefined part — the value either
|
|
@@ -2489,9 +2598,17 @@ function mapTypeInner(type, ctx) {
|
|
|
2489
2598
|
}
|
|
2490
2599
|
return null;
|
|
2491
2600
|
}
|
|
2601
|
+
if (mapped.kind === "void") {
|
|
2602
|
+
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2603
|
+
continue;
|
|
2604
|
+
}
|
|
2492
2605
|
byKey.set(typeKey(mapped), mapped);
|
|
2606
|
+
if (mapped.kind === "record")
|
|
2607
|
+
recordParts.push({ source: part, mapped });
|
|
2493
2608
|
}
|
|
2494
2609
|
const arms = [...byKey.values()];
|
|
2610
|
+
if (arms.length === 0)
|
|
2611
|
+
return F64; // same unreachable placeholder as standalone never
|
|
2495
2612
|
// A single surviving UNIT arm cannot stand alone (degenerate — the
|
|
2496
2613
|
// checker collapsed everything else away); anything else single is
|
|
2497
2614
|
// just that type. A single arm UNDER A MINTED PLACEHOLDER cannot
|
|
@@ -2531,29 +2648,12 @@ function mapTypeInner(type, ctx) {
|
|
|
2531
2648
|
return DYN;
|
|
2532
2649
|
}
|
|
2533
2650
|
if (arms.some((a) => a.kind === "void" || a.kind === "union" ||
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
// arms map: `x instanceof RegExp` is their narrowing test
|
|
2537
|
-
// (the skip-utility `string | RegExp` shape), and the arm
|
|
2538
|
-
// rides the ref machinery like array regex elements.
|
|
2539
|
-
a.kind === "map" || a.kind === "set" || a.kind === "date" || a.kind === "dyn" ||
|
|
2540
|
-
// Generator arms follow the map/set rule: no narrowing test.
|
|
2541
|
-
a.kind === "generator" ||
|
|
2542
|
-
// Func arms map beside ANY sibling: `typeof x === "function"`
|
|
2543
|
-
// is the narrowing against data arms (typeofAnswer knows every
|
|
2544
|
-
// arm kind), unit TAG tests cover the nullable-callback shape
|
|
2545
|
-
// (cb !== null, cb ?? f, cb?.()), and against FUNC siblings
|
|
2546
|
-
// (`StringConstructor | NumberConstructor` — the option-table
|
|
2547
|
-
// field) closures compare by pointer identity per tag
|
|
2548
|
-
// (unionEq), so `x === String` narrows. No restriction left.
|
|
2549
|
-
// Promise arms follow the func rule (typeof gives no test
|
|
2550
|
-
// against sibling data arms): only the promise-or-absent shape
|
|
2551
|
-
// maps — `Promise<T> | undefined`, and `Promise<T> | void`
|
|
2552
|
-
// return types whose void part became the undefined arm above.
|
|
2553
|
-
(a.kind === "promise" && !arms.every((b) => b === a || isUnitType(b))))) {
|
|
2651
|
+
a.kind === "date" || a.kind === "dyn" ||
|
|
2652
|
+
a.kind === "generator") || !unionContainerArmsOk(arms)) {
|
|
2554
2653
|
return null;
|
|
2555
2654
|
}
|
|
2556
2655
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2656
|
+
const discriminant = unionDiscriminant(recordParts, arms, ctx);
|
|
2557
2657
|
if (unions.recursivePending(widened)) {
|
|
2558
2658
|
// The knot closed through this union. A frame that resolved
|
|
2559
2659
|
// through context-sensitive hooks (generic type parameters, mixin
|
|
@@ -2562,9 +2662,9 @@ function mapTypeInner(type, ctx) {
|
|
|
2562
2662
|
// recursive generic-open unions stay fenced.
|
|
2563
2663
|
if (contextResolutions !== sensitivityAtEntry)
|
|
2564
2664
|
return null;
|
|
2565
|
-
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms) };
|
|
2665
|
+
return { kind: "union", unionId: unions.finalizeRecursive(widened, arms, discriminant) };
|
|
2566
2666
|
}
|
|
2567
|
-
return { kind: "union", unionId: unions.intern(arms) };
|
|
2667
|
+
return { kind: "union", unionId: unions.intern(arms, discriminant) };
|
|
2568
2668
|
}
|
|
2569
2669
|
finally {
|
|
2570
2670
|
unions.inProgress.delete(widened);
|
|
@@ -2572,6 +2672,231 @@ function mapTypeInner(type, ctx) {
|
|
|
2572
2672
|
}
|
|
2573
2673
|
return null;
|
|
2574
2674
|
}
|
|
2675
|
+
/** Retain a literal discriminator before widening erases its values. A
|
|
2676
|
+
* structural match alone is insufficient: `{ kind: "loop", body: ... }`
|
|
2677
|
+
* also fits a smaller `{ kind: "empty" }` record. Choosing that layout
|
|
2678
|
+
* makes a later switch on kind read fields outside the allocated object.
|
|
2679
|
+
*
|
|
2680
|
+
* Require one common, required data property with finite literal values.
|
|
2681
|
+
* Values may repeat within a single storage arm (several variants share a
|
|
2682
|
+
* shape), but never select different arms. Non-record arms keep their
|
|
2683
|
+
* ordinary kind checks. Types without an unambiguous discriminator retain
|
|
2684
|
+
* their structural boundary behavior. */
|
|
2685
|
+
function unionDiscriminant(parts, arms, ctx) {
|
|
2686
|
+
if (arms.filter((arm) => arm.kind === "record").length < 2 || parts.length < 2)
|
|
2687
|
+
return undefined;
|
|
2688
|
+
const { checker } = ctx;
|
|
2689
|
+
for (const candidate of checker.getPropertiesOfType(parts[0].source)) {
|
|
2690
|
+
if (candidate.name.startsWith("__@"))
|
|
2691
|
+
continue;
|
|
2692
|
+
const byTag = new Map();
|
|
2693
|
+
const owner = new Map();
|
|
2694
|
+
let complete = true;
|
|
2695
|
+
for (const part of parts) {
|
|
2696
|
+
const prop = checker.getPropertyOfType(part.source, candidate.name);
|
|
2697
|
+
if (!prop || prop.flags & (ts.SymbolFlags.Optional | ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor)) {
|
|
2698
|
+
complete = false;
|
|
2699
|
+
break;
|
|
2700
|
+
}
|
|
2701
|
+
const values = literalValues(checker.getTypeOfSymbol(prop));
|
|
2702
|
+
if (!values) {
|
|
2703
|
+
complete = false;
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
const tag = arms.findIndex((arm) => typeEquals(arm, part.mapped));
|
|
2707
|
+
const grouped = byTag.get(tag) ?? [];
|
|
2708
|
+
for (const value of values) {
|
|
2709
|
+
const key = JSON.stringify(value);
|
|
2710
|
+
const previous = owner.get(key);
|
|
2711
|
+
if (previous !== undefined && previous !== tag) {
|
|
2712
|
+
complete = false;
|
|
2713
|
+
break;
|
|
2714
|
+
}
|
|
2715
|
+
owner.set(key, tag);
|
|
2716
|
+
if (!grouped.includes(value))
|
|
2717
|
+
grouped.push(value);
|
|
2718
|
+
}
|
|
2719
|
+
if (!complete)
|
|
2720
|
+
break;
|
|
2721
|
+
byTag.set(tag, grouped);
|
|
2722
|
+
}
|
|
2723
|
+
if (complete) {
|
|
2724
|
+
return {
|
|
2725
|
+
field: candidate.name,
|
|
2726
|
+
cases: [...byTag].sort(([a], [b]) => a - b).map(([tag, values]) => ({
|
|
2727
|
+
tag, values: values.sort((a, b) => JSON.stringify(a) < JSON.stringify(b) ? -1 : JSON.stringify(a) > JSON.stringify(b) ? 1 : 0),
|
|
2728
|
+
})),
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
return undefined;
|
|
2733
|
+
}
|
|
2734
|
+
/** A class-derived interface or intersection can refine existing members
|
|
2735
|
+
* without changing the object's layout. Keep the unique program class as
|
|
2736
|
+
* its representation; structural lookalikes without a class base do not
|
|
2737
|
+
* qualify. Construction and coercion must still supply that actual class.
|
|
2738
|
+
* Undefined means no class view, while null is a recognized but unsupported
|
|
2739
|
+
* view: do not fall through and copy an identity-bearing object to a record. */
|
|
2740
|
+
function mapClassView(type, ctx, seen = new Set()) {
|
|
2741
|
+
const { checker } = ctx;
|
|
2742
|
+
if (seen.has(type) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2743
|
+
return null;
|
|
2744
|
+
let bases;
|
|
2745
|
+
let viewCtx = ctx;
|
|
2746
|
+
if (type.isIntersectionType()) {
|
|
2747
|
+
bases = ts.constituentTypes(type);
|
|
2748
|
+
}
|
|
2749
|
+
else {
|
|
2750
|
+
const symbol = type.getSymbol();
|
|
2751
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2752
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2753
|
+
return undefined;
|
|
2754
|
+
const target = type.isTypeReference() ? type.getTarget() : type;
|
|
2755
|
+
if (target === undefined || !target.isClassOrInterface())
|
|
2756
|
+
return undefined;
|
|
2757
|
+
bases = checker.getBaseTypes(target);
|
|
2758
|
+
if (type.isTypeReference() && target.isTypeReference()) {
|
|
2759
|
+
const params = checker.getTypeArguments(target);
|
|
2760
|
+
const args = checker.getTypeArguments(type);
|
|
2761
|
+
viewCtx = {
|
|
2762
|
+
...ctx,
|
|
2763
|
+
canMemoizeType: () => false,
|
|
2764
|
+
resolveTypeParam: (param) => {
|
|
2765
|
+
const index = params.indexOf(param);
|
|
2766
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2767
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2768
|
+
},
|
|
2769
|
+
resolveTypeParamTs: (param) => {
|
|
2770
|
+
const index = params.indexOf(param);
|
|
2771
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2772
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2773
|
+
},
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
seen.add(type);
|
|
2778
|
+
try {
|
|
2779
|
+
let baseType;
|
|
2780
|
+
let representation;
|
|
2781
|
+
for (const base of bases) {
|
|
2782
|
+
const symbol = base.getSymbol();
|
|
2783
|
+
const declaration = symbol ? checker.valueDeclarationOf(symbol) : undefined;
|
|
2784
|
+
const classBase = declaration && (ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration)) &&
|
|
2785
|
+
!declaration.getSourceFile().isDeclarationFile;
|
|
2786
|
+
const mapped = classBase ? mapType(base, viewCtx) : mapClassView(base, viewCtx, seen);
|
|
2787
|
+
if (mapped === null)
|
|
2788
|
+
return null;
|
|
2789
|
+
if (mapped === undefined)
|
|
2790
|
+
continue;
|
|
2791
|
+
if (mapped.kind !== "object" || (representation && !typeEquals(representation, mapped)))
|
|
2792
|
+
return null;
|
|
2793
|
+
baseType = base;
|
|
2794
|
+
representation = mapped;
|
|
2795
|
+
}
|
|
2796
|
+
if (!representation || !baseType)
|
|
2797
|
+
return undefined;
|
|
2798
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2799
|
+
checker.getIndexInfosOfType(type).length)
|
|
2800
|
+
return null;
|
|
2801
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2802
|
+
const original = checker.getPropertyOfType(baseType, property.name);
|
|
2803
|
+
if (!original)
|
|
2804
|
+
return null;
|
|
2805
|
+
if (original === property)
|
|
2806
|
+
continue;
|
|
2807
|
+
const originalDeclarations = checker.declarationsOf(original);
|
|
2808
|
+
const declarations = checker.declarationsOf(property);
|
|
2809
|
+
// Instantiating an inherited member can create a new symbol without
|
|
2810
|
+
// changing its declaration or ABI. Only refinements need validation.
|
|
2811
|
+
if (declarations.length > 0 && declarations.length === originalDeclarations.length &&
|
|
2812
|
+
declarations.every((declaration, index) => declaration === originalDeclarations[index]))
|
|
2813
|
+
continue;
|
|
2814
|
+
const before = checker.getTypeOfSymbol(original);
|
|
2815
|
+
const after = checker.getTypeOfSymbol(property);
|
|
2816
|
+
if (checker.getCallSignatures(before).length || checker.getCallSignatures(after).length) {
|
|
2817
|
+
const from = mapType(before, viewCtx);
|
|
2818
|
+
const to = mapType(after, viewCtx);
|
|
2819
|
+
if (!from || !to || !typeEquals(from, to))
|
|
2820
|
+
return null;
|
|
2821
|
+
}
|
|
2822
|
+
else if (!checker.isTypeAssignableTo(after, before)) {
|
|
2823
|
+
return null;
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
return representation;
|
|
2827
|
+
}
|
|
2828
|
+
finally {
|
|
2829
|
+
seen.delete(type);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
/** Interface views of native collections may inherit their runtime surface
|
|
2833
|
+
* and refine `has` into a type predicate. Keep declaration provenance and
|
|
2834
|
+
* require the same call ABI; extra fields or replacement methods need a
|
|
2835
|
+
* different representation. Value construction/coercion still has to prove
|
|
2836
|
+
* a native Map/Set, so structural mocks cannot acquire a native handle. */
|
|
2837
|
+
function mapCollectionView(type, ctx, seen = new Set()) {
|
|
2838
|
+
if (!type.isTypeReference())
|
|
2839
|
+
return null;
|
|
2840
|
+
const { checker } = ctx;
|
|
2841
|
+
const symbol = type.getSymbol();
|
|
2842
|
+
const declarations = symbol ? checker.declarationsOf(symbol) : [];
|
|
2843
|
+
if (declarations.length === 0 || !declarations.every((decl) => ts.isInterfaceDeclaration(decl) && !ctx.isStdlibFile(decl.getSourceFile())))
|
|
2844
|
+
return null;
|
|
2845
|
+
const target = type.getTarget();
|
|
2846
|
+
if (target === undefined || !target.isClassOrInterface() || seen.has(target) || seen.size >= MAP_TYPE_MAX_DEPTH)
|
|
2847
|
+
return null;
|
|
2848
|
+
const bases = checker.getBaseTypes(target);
|
|
2849
|
+
if (bases.length !== 1)
|
|
2850
|
+
return null;
|
|
2851
|
+
if (checker.getCallSignatures(type).length || checker.getConstructSignatures(type).length ||
|
|
2852
|
+
checker.getIndexInfosOfType(type).length)
|
|
2853
|
+
return null;
|
|
2854
|
+
// Base declarations contain the interface's parameters, even when this
|
|
2855
|
+
// reference is instantiated. Resolve those through this reference before
|
|
2856
|
+
// mapping the base; never cache a template under one instantiation's ABI.
|
|
2857
|
+
const params = checker.getTypeArguments(target);
|
|
2858
|
+
const args = checker.getTypeArguments(type);
|
|
2859
|
+
const baseCtx = {
|
|
2860
|
+
...ctx,
|
|
2861
|
+
canMemoizeType: () => false,
|
|
2862
|
+
resolveTypeParam: (param) => {
|
|
2863
|
+
const index = params.indexOf(param);
|
|
2864
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2865
|
+
return arg && arg !== param ? mapType(arg, ctx) : ctx.resolveTypeParam?.(param) ?? null;
|
|
2866
|
+
},
|
|
2867
|
+
resolveTypeParamTs: (param) => {
|
|
2868
|
+
const index = params.indexOf(param);
|
|
2869
|
+
const arg = index >= 0 ? args[index] : undefined;
|
|
2870
|
+
return arg && arg !== param ? ctx.resolveTypeParamTs?.(arg) ?? arg : ctx.resolveTypeParamTs?.(param) ?? null;
|
|
2871
|
+
},
|
|
2872
|
+
};
|
|
2873
|
+
seen.add(target);
|
|
2874
|
+
try {
|
|
2875
|
+
const base = bases[0];
|
|
2876
|
+
const baseSymbol = base.getSymbol();
|
|
2877
|
+
const native = baseSymbol && ["Map", "ReadonlyMap", "Set", "ReadonlySet"].includes(baseSymbol.name) &&
|
|
2878
|
+
checker.declarationsOf(baseSymbol).some((decl) => ts.isInterfaceDeclaration(decl) && ctx.isStdlibFile(decl.getSourceFile()));
|
|
2879
|
+
const mapped = native ? mapType(base, baseCtx) : mapCollectionView(base, baseCtx, seen);
|
|
2880
|
+
if (mapped?.kind !== "map" && mapped?.kind !== "set")
|
|
2881
|
+
return null;
|
|
2882
|
+
const hasType = funcOf([mapped.kind === "map" ? mapped.key : mapped.elem], BOOL);
|
|
2883
|
+
for (const property of checker.getPropertiesOfType(type)) {
|
|
2884
|
+
const own = checker.declarationsOf(property).filter((decl) => !ctx.isStdlibFile(decl.getSourceFile()));
|
|
2885
|
+
if (own.length === 0)
|
|
2886
|
+
continue;
|
|
2887
|
+
if (property.name !== "has" || (property.flags & ts.SymbolFlags.Optional) ||
|
|
2888
|
+
!own.every((decl) => decl.kind === ts.SyntaxKind.MethodSignature))
|
|
2889
|
+
return null;
|
|
2890
|
+
const method = mapType(checker.getTypeOfSymbol(property), ctx);
|
|
2891
|
+
if (!method || !typeEquals(method, hasType))
|
|
2892
|
+
return null;
|
|
2893
|
+
}
|
|
2894
|
+
return mapped;
|
|
2895
|
+
}
|
|
2896
|
+
finally {
|
|
2897
|
+
seen.delete(target);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2575
2900
|
/** The narrowed-type-parameter recognizer behind mapType's early return:
|
|
2576
2901
|
* a union/intersection over exactly ONE type parameter whose companions
|
|
2577
2902
|
* are all `{}`-empty shapes or the null/undefined units. Returns the
|
|
@@ -2651,7 +2976,7 @@ function mapBoundIndexedAccess(type, ctx) {
|
|
|
2651
2976
|
const { checker, resolveTypeParamTs } = ctx;
|
|
2652
2977
|
if (!resolveTypeParamTs || !type.isIndexedAccessType())
|
|
2653
2978
|
return null;
|
|
2654
|
-
const resolveSide = (t) => t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
2979
|
+
const resolveSide = (t) => t === undefined ? null : t.flags & ts.TypeFlags.TypeParameter ? resolveTypeParamTs(t) : t;
|
|
2655
2980
|
const objT = resolveSide(type.getObjectType());
|
|
2656
2981
|
const idxT = resolveSide(type.getIndexType());
|
|
2657
2982
|
if (!objT || !idxT)
|
|
@@ -2768,7 +3093,7 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2768
3093
|
if (!resolveTypeParam || !type.isIndexedAccessType())
|
|
2769
3094
|
return null;
|
|
2770
3095
|
const obj = type.getObjectType();
|
|
2771
|
-
if (!(obj.flags & ts.TypeFlags.TypeParameter))
|
|
3096
|
+
if (obj === undefined || !(obj.flags & ts.TypeFlags.TypeParameter))
|
|
2772
3097
|
return null;
|
|
2773
3098
|
const bound = resolveTypeParam(obj);
|
|
2774
3099
|
if (!bound || bound.kind !== "record")
|
|
@@ -2777,13 +3102,15 @@ function mapGenericIndexedAccess(type, ctx) {
|
|
|
2777
3102
|
if (!shape || shape.tuple)
|
|
2778
3103
|
return null;
|
|
2779
3104
|
const idx = type.getIndexType();
|
|
3105
|
+
if (idx === undefined)
|
|
3106
|
+
return null;
|
|
2780
3107
|
let covered = null;
|
|
2781
3108
|
if (idx.isStringLiteralType()) {
|
|
2782
3109
|
const f = shape.fields.find((x) => x.name === idx.value);
|
|
2783
3110
|
covered = f ? [f.type] : shape.indexValue ? [shape.indexValue] : null;
|
|
2784
3111
|
}
|
|
2785
3112
|
else {
|
|
2786
|
-
const allKeys = (idx.flags & ts.TypeFlags.TypeParameter && resolveTypeParam(idx)?.kind === "string") ||
|
|
3113
|
+
const allKeys = ((idx.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam(idx)?.kind === "string") ||
|
|
2787
3114
|
(idx.isIndexType() && idx.getTarget() === obj);
|
|
2788
3115
|
if (allKeys) {
|
|
2789
3116
|
covered = shape.fields.map((f) => f.type);
|
|
@@ -2864,8 +3191,8 @@ export function unitOnlyUnion(unions) {
|
|
|
2864
3191
|
* answers undefined). ONE shape per channel pair — `g.next()`'s lowering,
|
|
2865
3192
|
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
2866
3193
|
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
2867
|
-
* Null when the combined union would be illegal (a
|
|
2868
|
-
* data arms, a
|
|
3194
|
+
* Null when the combined union would be illegal (a container arm beside
|
|
3195
|
+
* data arms, a regex/Date arm — kinds with no narrowing test here): such
|
|
2869
3196
|
* generators stay unmapped. */
|
|
2870
3197
|
export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
2871
3198
|
let valueT;
|
|
@@ -2882,7 +3209,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2882
3209
|
byKey.set(typeKey(a), a);
|
|
2883
3210
|
return true;
|
|
2884
3211
|
}
|
|
2885
|
-
if (t.kind === "
|
|
3212
|
+
if (t.kind === "regex" || t.kind === "date" ||
|
|
2886
3213
|
t.kind === "jsval" || t.kind === "generator") {
|
|
2887
3214
|
return false; // no legal union arm exists for these kinds
|
|
2888
3215
|
}
|
|
@@ -2893,9 +3220,9 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2893
3220
|
return null;
|
|
2894
3221
|
byKey.set(typeKey(UNDEFINED_T), UNDEFINED_T);
|
|
2895
3222
|
const arms = [...byKey.values()];
|
|
2896
|
-
//
|
|
2897
|
-
//
|
|
2898
|
-
if (arms.some((a) =>
|
|
3223
|
+
// Containers keep the shared nullable-only rule. Generator function
|
|
3224
|
+
// payloads retain their existing unit-only boundary too.
|
|
3225
|
+
if (!unionContainerArmsOk(arms) || arms.some((a) => a.kind === "func" && !arms.every((b) => b === a || isUnitType(b)))) {
|
|
2899
3226
|
return null;
|
|
2900
3227
|
}
|
|
2901
3228
|
if (arms.every(isUnitType) && arms.length < 2) {
|
|
@@ -2922,37 +3249,45 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
|
|
|
2922
3249
|
* fields, tuple/array elements, variable slots) substitute unitOnlyUnion
|
|
2923
3250
|
* for these; RETURN positions keep the VOID mapping (a void return is not
|
|
2924
3251
|
* a value). */
|
|
2925
|
-
export function isUnitOnlyTsType(t) {
|
|
3252
|
+
export function isUnitOnlyTsType(t, resolveTypeParam) {
|
|
2926
3253
|
const UNIT = ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.Null;
|
|
2927
3254
|
const parts = t.isUnionType() ? ts.constituentTypes(t) : [t];
|
|
2928
|
-
return parts.every((p) => (p.flags & UNIT) !== 0
|
|
3255
|
+
return parts.every((p) => (p.flags & UNIT) !== 0 ||
|
|
3256
|
+
((p.flags & ts.TypeFlags.TypeParameter) !== 0 && resolveTypeParam?.(p)?.kind === "void"));
|
|
2929
3257
|
}
|
|
2930
3258
|
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
2931
|
-
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
2932
|
-
*
|
|
3259
|
+
* ts-union branch of mapType (typeKey-sorted arms, deduplicated;
|
|
3260
|
+
* Date/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
2933
3261
|
* result is exactly the nullable-callback shape mapType's union branch
|
|
2934
3262
|
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
2935
3263
|
* to what mapping the checker's own `T | undefined` produces. */
|
|
2936
3264
|
export function withUndefinedArm(t, unions) {
|
|
3265
|
+
return withUnitArm(t, "undefinedT", unions);
|
|
3266
|
+
}
|
|
3267
|
+
/** Preserve a nullish runtime value that JavaScript inference omitted. */
|
|
3268
|
+
export function withUnitArm(t, kind, unions) {
|
|
3269
|
+
const unit = { kind };
|
|
3270
|
+
if (t.kind === "jsval")
|
|
3271
|
+
return t;
|
|
2937
3272
|
if (t.kind === "union") {
|
|
2938
3273
|
const def = unions.get(t.unionId);
|
|
2939
3274
|
if (!def)
|
|
2940
3275
|
return null;
|
|
2941
3276
|
if (def.arms.some((a) => a.kind === "date"))
|
|
2942
3277
|
return null;
|
|
2943
|
-
if (def.arms.some((a) => a.kind ===
|
|
3278
|
+
if (def.arms.some((a) => a.kind === kind))
|
|
2944
3279
|
return t;
|
|
2945
|
-
const arms = [...def.arms,
|
|
3280
|
+
const arms = [...def.arms, unit];
|
|
2946
3281
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2947
|
-
return { kind: "union", unionId: unions.
|
|
3282
|
+
return { kind: "union", unionId: unions.transform(def, arms) };
|
|
2948
3283
|
}
|
|
2949
|
-
if (t.kind === "void" || t.kind === "
|
|
3284
|
+
if (t.kind === "void" || t.kind === "date" || t.kind === "dyn" ||
|
|
2950
3285
|
// A bare unit field type cannot occur (units live only inside unions),
|
|
2951
3286
|
// but guard against constructing a single-arm union from one.
|
|
2952
3287
|
isUnitType(t)) {
|
|
2953
3288
|
return null;
|
|
2954
3289
|
}
|
|
2955
|
-
const arms = [t,
|
|
3290
|
+
const arms = [t, unit];
|
|
2956
3291
|
arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
|
|
2957
3292
|
return { kind: "union", unionId: unions.intern(arms) };
|
|
2958
3293
|
}
|
|
@@ -3200,6 +3535,15 @@ function mapRecordType(widened, ctx) {
|
|
|
3200
3535
|
shapeId: shapes.finalizeRecursive(widened, inner.fields, inner.indexValue, inner.declaredOrder),
|
|
3201
3536
|
};
|
|
3202
3537
|
}
|
|
3538
|
+
// A record with no typed payload contract is a view of an existing
|
|
3539
|
+
// object, including across parameters and returns. Building a native
|
|
3540
|
+
// struct for it would copy a checked-dynamic object at each boundary
|
|
3541
|
+
// and sever mutation/identity. Keep the same representation as unknown;
|
|
3542
|
+
// constrained records and tuples retain their native layouts.
|
|
3543
|
+
if ((inner.fields.length > 0 || inner.indexValue !== undefined) &&
|
|
3544
|
+
inner.fields.every((field) => field.type.kind === "dyn") &&
|
|
3545
|
+
(inner.indexValue === undefined || inner.indexValue.kind === "dyn"))
|
|
3546
|
+
return DYN;
|
|
3203
3547
|
return { kind: "record", shapeId: shapes.intern(inner.fields, false, inner.indexValue, inner.declaredOrder) };
|
|
3204
3548
|
}
|
|
3205
3549
|
finally {
|
|
@@ -3467,7 +3811,7 @@ function mapRecordTypeInner(widened, ctx) {
|
|
|
3467
3811
|
// absent-field idiom — and `{ p: undefined }` spellings): the
|
|
3468
3812
|
// unit-only union. The runtime value is the interned unit, JSON
|
|
3469
3813
|
// omits the undefined arm exactly like an omitted optional.
|
|
3470
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
3814
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3471
3815
|
pt = unitOnlyUnion(ctx.unions);
|
|
3472
3816
|
// dyn FIELDS map now (`{ v: unknown }`, `[string, unknown]` tuples):
|
|
3473
3817
|
// the slot carries a dyn value exactly like an `unknown`-valued
|
|
@@ -3556,15 +3900,15 @@ function armHasUnionHome(arm, siblingCount) {
|
|
|
3556
3900
|
switch (arm.kind) {
|
|
3557
3901
|
case "void":
|
|
3558
3902
|
case "union":
|
|
3559
|
-
case "map":
|
|
3560
|
-
case "set":
|
|
3561
3903
|
case "regex":
|
|
3562
3904
|
case "date":
|
|
3563
3905
|
case "generator":
|
|
3564
3906
|
case "dyn":
|
|
3565
3907
|
return false;
|
|
3566
|
-
//
|
|
3567
|
-
//
|
|
3908
|
+
// Containers map only beside unit siblings; data siblings have no
|
|
3909
|
+
// supported runtime narrowing test against them.
|
|
3910
|
+
case "map":
|
|
3911
|
+
case "set":
|
|
3568
3912
|
case "promise":
|
|
3569
3913
|
return siblingCount === 0;
|
|
3570
3914
|
default:
|
|
@@ -3598,14 +3942,14 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3598
3942
|
if (!mapped) {
|
|
3599
3943
|
return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile`;
|
|
3600
3944
|
}
|
|
3601
|
-
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped)) {
|
|
3602
|
-
return `the ${container} shape is supported, but
|
|
3945
|
+
if ((container === "Map" || container === "ReadonlyMap") && i === 0 && !isSupportedMapKey(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
3946
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported key domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3603
3947
|
}
|
|
3604
3948
|
if ((container === "Map" || container === "ReadonlyMap") && i === 1 && !isSupportedMapValue(mapped)) {
|
|
3605
|
-
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet
|
|
3949
|
+
return `the ${container} shape is supported, but '${text(arg)}' values have no Map slot yet`;
|
|
3606
3950
|
}
|
|
3607
|
-
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped)) {
|
|
3608
|
-
return `the ${container} shape is supported, but
|
|
3951
|
+
if ((container === "Set" || container === "ReadonlySet") && !isSupportedSetElem(mapped, mapped.kind === "union" ? ctx.unions.get(mapped.unionId)?.arms : undefined)) {
|
|
3952
|
+
return `the ${container} shape is supported, but '${text(arg)}' is outside its supported element domain (numbers, strings, identity references, or unions of identity references)`;
|
|
3609
3953
|
}
|
|
3610
3954
|
}
|
|
3611
3955
|
// Every argument passed the per-slot checks and the type still failed:
|
|
@@ -3631,7 +3975,7 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3631
3975
|
if (checker.isTupleType(widened)) {
|
|
3632
3976
|
for (const arg of checker.getTypeArguments(widened)) {
|
|
3633
3977
|
const et = mapType(arg, ctx);
|
|
3634
|
-
if (et?.kind === "void" && isUnitOnlyTsType(arg))
|
|
3978
|
+
if (et?.kind === "void" && isUnitOnlyTsType(arg, ctx.resolveTypeParam))
|
|
3635
3979
|
continue;
|
|
3636
3980
|
if (!et || et.kind === "void") {
|
|
3637
3981
|
return `the tuple shape is supported, but its element type '${text(arg)}' does not compile`;
|
|
@@ -3745,7 +4089,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
|
|
|
3745
4089
|
if (isGenericCallableMemberType(fieldTs, checker))
|
|
3746
4090
|
continue;
|
|
3747
4091
|
let pt = mapType(fieldTs, ctx);
|
|
3748
|
-
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs))
|
|
4092
|
+
if (pt?.kind === "void" && isUnitOnlyTsType(fieldTs, ctx.resolveTypeParam))
|
|
3749
4093
|
pt = unitOnlyUnion(ctx.unions);
|
|
3750
4094
|
if (!pt || pt.kind === "void") {
|
|
3751
4095
|
return `the record shape is supported, but its member '${p.name}' has type '${checker.typeToString(fieldTs)}', which does not compile`;
|