@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,3 +1,4 @@
|
|
|
1
|
+
import { staticTextDecoderEncoding } from "./text-decoder-encoding.js";
|
|
1
2
|
import { InternalCompilerError } from "../../errors.js";
|
|
2
3
|
/* Builtin-surface lowering: node builtin-module calls (fs, path, os, url,
|
|
3
4
|
* crypto, child_process spawn/spawnSync and child/stats/spawn-result
|
|
@@ -7,7 +8,7 @@ import { builtinModules } from "node:module";
|
|
|
7
8
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
8
9
|
import * as ts from "../ts7/adapter.js";
|
|
9
10
|
import { PoisonError, dynUndefinedExpr, ladderFenceExpr, nodeThrowExpr, own } from "./lowerer.js";
|
|
10
|
-
import { canonicalBuiltinModule, isJsSourceFile, isNodeEsmFile, locOf, npmStaticDepSf7, requireSpecOf, resolveImport } from "../program.js";
|
|
11
|
+
import { canonicalBuiltinModule, isCreateRequireBinding7, isJsSourceFile, isNodeEsmFile, locOf, npmStaticDepSf7, requireSpecOf, resolveImport } from "../program.js";
|
|
11
12
|
import { isRelativeSpecifier } from "../workspace-registry.js";
|
|
12
13
|
import { probeNodeRequireRefusal } from "../npm.js";
|
|
13
14
|
import { isNpmStaticPackage } from "../npm-static.js";
|
|
@@ -24,11 +25,14 @@ import { CRYPTO_CIPHERS, CRYPTO_CONSTANTS, CRYPTO_CURVES, CRYPTO_HASHES } from "
|
|
|
24
25
|
import { generatorMeta, timerStyleCallback } from "./lower-calls.js";
|
|
25
26
|
import { registerHttpClientFnBinding, voidizedCallback } from "./lower-server.js";
|
|
26
27
|
import { pairsSnapshotHelper } from "./pairs-snapshot.js";
|
|
28
|
+
import { isJsonStringifyDynamicType } from "../../ir/ir.js";
|
|
27
29
|
import { bufEncoding } from "./containers/bytes.js";
|
|
28
30
|
import { BOOL, BYTES_U8, CHILD_T, CHILDSTREAM_T, CHILDWRITER_T, CRYPTOHASH_T, CRYPTOHMAC_T, DYN, F64, FILEHANDLE_T, FSWATCHER_T, PROCSTREAM_T, JSVAL, NULL_T, SEARCH_PARAMS_T, SPAWNRES_T, STRING, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, funcOf, isUnitType, typeEquals, typeKey } from "../../ir/ir.js";
|
|
29
31
|
import { boolLit, countedFor, numLit, strLit, varRef } from "../../ir/build.js";
|
|
30
32
|
import { staticForkModulePath } from "../fork-target.js";
|
|
31
33
|
import { tsgoPath } from "../dts-paths.js";
|
|
34
|
+
import { lowerFfiMemoryModule } from "./native-ffi.js";
|
|
35
|
+
import { lowerBuiltinLoaderValue } from "./lower-builtin-values.js";
|
|
32
36
|
function optionalStringTags(lowerer, type) {
|
|
33
37
|
if (type.kind !== "union")
|
|
34
38
|
return null;
|
|
@@ -122,14 +126,16 @@ function checkedOptionalBuiltinArm(lowerer, value, target) {
|
|
|
122
126
|
: null;
|
|
123
127
|
}
|
|
124
128
|
function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
// Number predicates do not coerce. In a mixed union only the numeric
|
|
130
|
+
// arm runs the predicate; every other arm answers false after evaluating
|
|
131
|
+
// the argument once. This includes the undefined added by array reads.
|
|
132
|
+
const widened = value.type;
|
|
133
|
+
if (widened.kind !== "union" && widened.kind !== "dyn")
|
|
127
134
|
return null;
|
|
128
|
-
const numberTag = lowerer.armTag(widened.unionId, F64);
|
|
129
|
-
|
|
130
|
-
if (numberTag < 0 || undefinedTag < 0)
|
|
135
|
+
const numberTag = widened.kind === "union" ? lowerer.armTag(widened.unionId, F64) : -1;
|
|
136
|
+
if (widened.kind === "union" && numberTag < 0)
|
|
131
137
|
return null;
|
|
132
|
-
const key = `number.optionalPredicate:${fn}:${widened
|
|
138
|
+
const key = `number.optionalPredicate:${fn}:${typeKey(widened)}`;
|
|
133
139
|
let helper = lowerer.widthHelpers.get(key);
|
|
134
140
|
if (!helper) {
|
|
135
141
|
helper = `%number.optionalPredicate.${lowerer.widthHelpers.size}`;
|
|
@@ -143,7 +149,9 @@ function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
|
143
149
|
body: [
|
|
144
150
|
{
|
|
145
151
|
kind: "if",
|
|
146
|
-
cond:
|
|
152
|
+
cond: widened.kind === "dyn"
|
|
153
|
+
? { kind: "dynTest", test: "number", negated: true, value: input, type: BOOL, loc }
|
|
154
|
+
: { kind: "unionIsTag", unionId: widened.unionId, tag: numberTag, negated: true, value: input, type: BOOL, loc },
|
|
147
155
|
then: [{ kind: "return", value: boolLit(false, loc), loc }],
|
|
148
156
|
else_: null,
|
|
149
157
|
loc,
|
|
@@ -153,7 +161,9 @@ function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
|
153
161
|
value: {
|
|
154
162
|
kind: "libCall",
|
|
155
163
|
fn,
|
|
156
|
-
args: [
|
|
164
|
+
args: [widened.kind === "dyn"
|
|
165
|
+
? { kind: "dynCheck", value: input, type: F64, loc }
|
|
166
|
+
: { kind: "unionNarrow", unionId: widened.unionId, tag: numberTag, value: input, type: F64, loc }],
|
|
157
167
|
type: BOOL,
|
|
158
168
|
loc,
|
|
159
169
|
},
|
|
@@ -198,7 +208,9 @@ function lowerBuiltinOptionalDefault(lowerer, node, expected, dflt, nullIsDefaul
|
|
|
198
208
|
* declaration is not an import specifier. Returns the CANONICAL module
|
|
199
209
|
* name and the EXPORTED member name (not the local alias). */
|
|
200
210
|
export function builtinImportOf(lowerer, ident) {
|
|
201
|
-
const symbol =
|
|
211
|
+
const symbol = ts.isShorthandPropertyAssignment(ident.parent) && ident.parent.name === ident
|
|
212
|
+
? lowerer.checker.getShorthandAssignmentValueSymbol(ident.parent)
|
|
213
|
+
: lowerer.checker.getSymbolAtLocation(ident);
|
|
202
214
|
const decl = symbol ? lowerer.checker.declarationsOf(symbol)[0] : undefined;
|
|
203
215
|
if (!decl)
|
|
204
216
|
return null;
|
|
@@ -206,7 +218,7 @@ export function builtinImportOf(lowerer, ident) {
|
|
|
206
218
|
// binding (`const { readFileSync } = require("fs")`, renames via
|
|
207
219
|
// `{ readFileSync: rf }`) keys the same tables.
|
|
208
220
|
if (ts.isBindingElement(decl) && decl.name !== undefined && ts.isIdentifier(decl.name)) {
|
|
209
|
-
const varDecl = decl.parent
|
|
221
|
+
const varDecl = decl.parent?.parent;
|
|
210
222
|
if (ts.isObjectBindingPattern(decl.parent) &&
|
|
211
223
|
ts.isVariableDeclaration(varDecl) &&
|
|
212
224
|
varDecl.initializer !== undefined) {
|
|
@@ -246,7 +258,7 @@ export function builtinImportOf(lowerer, ident) {
|
|
|
246
258
|
if (!ts.isImportSpecifier(decl) && !ts.isExportSpecifier(decl))
|
|
247
259
|
return null;
|
|
248
260
|
if (ts.isImportSpecifier(decl)) {
|
|
249
|
-
const importDecl = decl.parent
|
|
261
|
+
const importDecl = decl.parent?.parent?.parent;
|
|
250
262
|
if (!ts.isImportDeclaration(importDecl) || !ts.isStringLiteral(importDecl.moduleSpecifier)) {
|
|
251
263
|
return null;
|
|
252
264
|
}
|
|
@@ -370,7 +382,7 @@ function createRequireBaseCallOf(lowerer, expr) {
|
|
|
370
382
|
if (e.arguments.length !== 1)
|
|
371
383
|
return null;
|
|
372
384
|
const base = stripTypeCasts(e.arguments[0]);
|
|
373
|
-
if (ts.isIdentifier(base) && base
|
|
385
|
+
if (ts.isIdentifier(base) && lowerer.isStdlibGlobal(base, "__filename"))
|
|
374
386
|
return e;
|
|
375
387
|
if (ts.isPropertyAccessExpression(base) &&
|
|
376
388
|
!base.questionDotToken &&
|
|
@@ -384,15 +396,22 @@ function createRequireBaseCallOf(lowerer, expr) {
|
|
|
384
396
|
/** True for `const require = createRequire(import.meta.url)` — the
|
|
385
397
|
* binding is compile-time plumbing (each call through it resolves per
|
|
386
398
|
* site) with no storage and no code; both declaration walks skip by
|
|
387
|
-
* this test.
|
|
388
|
-
*
|
|
399
|
+
* this test. Top-level let/var bindings also qualify when preflight's
|
|
400
|
+
* shared proof rules out writes, escapes, and use before initialization. */
|
|
389
401
|
export function createRequireBindingDecl(lowerer, nameNode, init) {
|
|
390
|
-
if (!ts.isIdentifier(nameNode) || init === undefined)
|
|
402
|
+
if (!ts.isIdentifier(nameNode) || init === undefined || createRequireBaseCallOf(lowerer, init) === null)
|
|
391
403
|
return false;
|
|
392
|
-
|
|
404
|
+
// Preserve const loaders acquired through CommonJS member/destructure
|
|
405
|
+
// aliases, which builtinImportOf also recognizes. Mutable syntax uses
|
|
406
|
+
// preflight's narrower import provenance and whole-file stability proof.
|
|
407
|
+
const decl = nameNode.parent;
|
|
408
|
+
if (ts.isVariableDeclaration(decl) && ts.isVariableDeclarationList(decl.parent) &&
|
|
409
|
+
(decl.parent.flags & ts.NodeFlags.Const) !== 0)
|
|
410
|
+
return true;
|
|
411
|
+
return isCreateRequireBinding7(lowerer.program, nameNode);
|
|
393
412
|
}
|
|
394
413
|
/** The declaring source file when `callee` denotes a createRequire-made
|
|
395
|
-
* require: a
|
|
414
|
+
* require: a stable binding over createRequire(import.meta.url) (the
|
|
396
415
|
* binding's own file anchors resolution) or the inline
|
|
397
416
|
* `createRequire(import.meta.url)(...)` spelling (the call's file).
|
|
398
417
|
* Null off the pattern, so call chains keep trying. */
|
|
@@ -407,9 +426,7 @@ export function createRequireCalleeFileOf(lowerer, callee) {
|
|
|
407
426
|
const decl = symbol ? lowerer.checker.declarationsOf(symbol)[0] : undefined;
|
|
408
427
|
if (!decl || !ts.isVariableDeclaration(decl) || decl.initializer === undefined)
|
|
409
428
|
return null;
|
|
410
|
-
|
|
411
|
-
return null;
|
|
412
|
-
return createRequireBaseCallOf(lowerer, decl.initializer) !== null ? decl.getSourceFile() : null;
|
|
429
|
+
return createRequireBindingDecl(lowerer, decl.name, decl.initializer) ? decl.getSourceFile() : null;
|
|
413
430
|
}
|
|
414
431
|
/** The static require of `R("spec")` through a createRequire binding:
|
|
415
432
|
* the literal specifier plus the file anchoring relative resolution.
|
|
@@ -428,6 +445,14 @@ export function createRequireSpecOf(lowerer, call) {
|
|
|
428
445
|
const a = call.arguments[0];
|
|
429
446
|
return { spec: ts.isStringLiteralLike(a) ? a.text : null, baseFile };
|
|
430
447
|
}
|
|
448
|
+
/** node:ffi is a checked native module value, so its require binding needs
|
|
449
|
+
* storage even when the createRequire loader is named `require`. */
|
|
450
|
+
export function isNativeFfiRequire(lowerer, expr) {
|
|
451
|
+
if (expr === undefined)
|
|
452
|
+
return false;
|
|
453
|
+
const call = stripTypeCasts(expr);
|
|
454
|
+
return ts.isCallExpression(call) && createRequireSpecOf(lowerer, call)?.spec === "node:ffi";
|
|
455
|
+
}
|
|
431
456
|
/** True for `const fs = require("node:fs")` through a createRequire
|
|
432
457
|
* binding — a builtin namespace import in const clothing: alias
|
|
433
458
|
* plumbing with no storage (uses resolve through
|
|
@@ -456,7 +481,7 @@ export function createRequireProgramModuleOf(lowerer, expr) {
|
|
|
456
481
|
if (cr === null || cr.spec === null || canonicalBuiltinModule(cr.spec) !== null)
|
|
457
482
|
return null;
|
|
458
483
|
const dep = resolveImport(lowerer.program, cr.baseFile, cr.spec) ??
|
|
459
|
-
npmStaticDepSf7(lowerer.program, cr.baseFile, cr.spec);
|
|
484
|
+
npmStaticDepSf7(lowerer.program, cr.baseFile, cr.spec, "require");
|
|
460
485
|
if (dep === null || dep.fileName.endsWith(".json"))
|
|
461
486
|
return null;
|
|
462
487
|
return { spec: cr.spec, baseFile: cr.baseFile, dep };
|
|
@@ -567,6 +592,9 @@ export function lowerCreateRequireCall(lowerer, call, loc) {
|
|
|
567
592
|
lowerer.noLowering("createRequire's require with this argument shape", call, "the compiled module graph is fixed at build time — the one lowered form is require(\"<static string literal>\")");
|
|
568
593
|
}
|
|
569
594
|
const spec = cr.spec;
|
|
595
|
+
if (spec === "node:ffi") {
|
|
596
|
+
return lowerFfiMemoryModule(lowerer, loc);
|
|
597
|
+
}
|
|
570
598
|
if (canonicalBuiltinModule(spec) !== null) {
|
|
571
599
|
lowerer.unsupported("SC1090", call, `module namespace objects as values (bind it first: const m = require("${spec}"), then access members through the binding)`);
|
|
572
600
|
}
|
|
@@ -585,7 +613,7 @@ export function lowerCreateRequireCall(lowerer, call, loc) {
|
|
|
585
613
|
// This probe marks frontend inputs unstable, but every branch
|
|
586
614
|
// here refuses compilation, so successful-build caches keep their
|
|
587
615
|
// existing dependency proofs.
|
|
588
|
-
const resolved = resolveRequireRuntime(cr.baseFile.fileName, spec, lowerer.targetPlatform);
|
|
616
|
+
const resolved = resolveRequireRuntime(cr.baseFile.fileName, spec, lowerer.targetPlatform, undefined, lowerer.frontendServices);
|
|
589
617
|
if (resolved.ok && resolved.value.endsWith(".node")) {
|
|
590
618
|
lowerer.pushDiag(nativeAddonDiag(spec, loc));
|
|
591
619
|
throw new PoisonError();
|
|
@@ -684,7 +712,7 @@ export function lowerImportMetaResolveCall(lowerer, call) {
|
|
|
684
712
|
if (specifier === null) {
|
|
685
713
|
lowerer.noLowering("import.meta.resolve with a runtime-computed specifier", call.arguments[0], "a compiled binary has a fixed module graph — pass a string literal");
|
|
686
714
|
}
|
|
687
|
-
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform);
|
|
715
|
+
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
688
716
|
if (result === null) {
|
|
689
717
|
lowerer.noLowering(`import.meta.resolve of '${specifier}'`, call, "relative paths, URL-like names, builtins, and installed package names are supported; package-import aliases remain unsupported");
|
|
690
718
|
}
|
|
@@ -697,7 +725,7 @@ function requireResolverBaseFile(lowerer, receiver) {
|
|
|
697
725
|
const created = createRequireCalleeFileOf(lowerer, receiver);
|
|
698
726
|
if (created !== null)
|
|
699
727
|
return created;
|
|
700
|
-
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile())
|
|
728
|
+
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile(), lowerer.program)
|
|
701
729
|
? receiver.getSourceFile()
|
|
702
730
|
: null;
|
|
703
731
|
}
|
|
@@ -761,7 +789,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
761
789
|
}
|
|
762
790
|
const loc = locOf(call);
|
|
763
791
|
if (pathsCall) {
|
|
764
|
-
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform);
|
|
792
|
+
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
765
793
|
if (result !== null && !Array.isArray(result)) {
|
|
766
794
|
return runtimeResolveThrow(result, lowerer.irTypeOf(call), loc);
|
|
767
795
|
}
|
|
@@ -779,7 +807,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
779
807
|
if (paths === null) {
|
|
780
808
|
lowerer.noLowering("require.resolve with runtime-computed options", call.arguments[1], "omit options or pass { paths: [\"<static directory>\", ...] }");
|
|
781
809
|
}
|
|
782
|
-
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths);
|
|
810
|
+
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths, lowerer.frontendServices);
|
|
783
811
|
return result.ok
|
|
784
812
|
? { kind: "strLit", value: result.value, type: STRING, loc }
|
|
785
813
|
: runtimeResolveThrow(result.error, STRING, loc);
|
|
@@ -861,6 +889,13 @@ function isPerfHooksPerformanceExpr(lowerer, node) {
|
|
|
861
889
|
}
|
|
862
890
|
return false;
|
|
863
891
|
}
|
|
892
|
+
/** Presence probes do not extract an unbound Performance method value. */
|
|
893
|
+
export function lowerPerfHooksTypeof(lowerer, expression) {
|
|
894
|
+
const value = isPerfHooksPerformanceExpr(lowerer, expression) ? "object" :
|
|
895
|
+
ts.isPropertyAccessExpression(expression) && !expression.questionDotToken && expression.name.text === "now" &&
|
|
896
|
+
isPerfHooksPerformanceExpr(lowerer, expression.expression) ? "function" : null;
|
|
897
|
+
return value === null ? null : { kind: "strLit", value, type: STRING, loc: locOf(expression) };
|
|
898
|
+
}
|
|
864
899
|
/** The node:perf_hooks spoke: `performance.now()` reads the runtime's
|
|
865
900
|
* monotonic clock anchored at process start — Node's timeOrigin for a
|
|
866
901
|
* compiled program, fractional milliseconds — and
|
|
@@ -1300,6 +1335,31 @@ function lowerZlibModuleCall(lowerer, expr, bi, loc) {
|
|
|
1300
1335
|
}
|
|
1301
1336
|
const syncFn = ZLIB_SYNC_FNS[bi.member];
|
|
1302
1337
|
if (syncFn !== undefined) {
|
|
1338
|
+
if (expr.arguments.length === 2 &&
|
|
1339
|
+
(bi.member === "deflateSync" || bi.member === "deflateRawSync" || bi.member === "gzipSync")) {
|
|
1340
|
+
const options = expr.arguments[1];
|
|
1341
|
+
// A literal level is enough for build-time compression in the native
|
|
1342
|
+
// emitters. Other options retain the explicit refusal: silently
|
|
1343
|
+
// dropping strategy/windowBits/dictionaries changes the wire bytes.
|
|
1344
|
+
if (ts.isObjectLiteralExpression(options) && options.properties.length === 1) {
|
|
1345
|
+
const prop = options.properties[0];
|
|
1346
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
1347
|
+
(ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name)) && prop.name.text === "level") {
|
|
1348
|
+
const value = prop.initializer;
|
|
1349
|
+
const level = ts.isNumericLiteral(value) ? Number(value.text)
|
|
1350
|
+
: ts.isPrefixUnaryExpression(value) && value.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(value.operand)
|
|
1351
|
+
? -Number(value.operand.text) : NaN;
|
|
1352
|
+
if (Number.isInteger(level) && level >= -1 && level <= 9) {
|
|
1353
|
+
return {
|
|
1354
|
+
kind: "libCall", fn: "zlib.deflateLevelSync",
|
|
1355
|
+
args: [zlibInputBytes(lowerer, expr.arguments[0], loc), numLit(bi.member === "deflateSync" ? 0 : bi.member === "deflateRawSync" ? 1 : 2, loc), numLit(level, loc)],
|
|
1356
|
+
type: BYTES_U8, loc,
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
lowerer.noLowering(`${bi.member} with these options`, options, "the static compression options form is { level: <integer literal from -1 through 9> }");
|
|
1362
|
+
}
|
|
1303
1363
|
if (expr.arguments.length !== 1) {
|
|
1304
1364
|
const site = expr.arguments[1] ?? expr;
|
|
1305
1365
|
lowerer.noLowering(`${bi.member} with explicit options`, site, `${bi.member}(data) with Node's default options is supported`);
|
|
@@ -1979,15 +2039,21 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
1979
2039
|
: { kind: "numLit", value: 0, type: F64, loc };
|
|
1980
2040
|
return { kind: "libCall", fn: "fs.accessSync", args: [path, mode], type: VOID, loc };
|
|
1981
2041
|
}
|
|
1982
|
-
if (bi.module === "fs" && bi.member === "writeFileSync" && expr.arguments.length === 2) {
|
|
2042
|
+
if (bi.module === "fs" && (bi.member === "writeFileSync" || bi.member === "appendFileSync") && expr.arguments.length === 2) {
|
|
1983
2043
|
const dataIr = lowerer.mapTypeOf(lowerer.typeOf(expr.arguments[1]));
|
|
2044
|
+
if (dataIr?.kind === "union") {
|
|
2045
|
+
const arms = lowerer.unions.get(dataIr.unionId)?.arms;
|
|
2046
|
+
if (arms && arms.every((arm) => arm.kind === "string" || (arm.kind === "bytes" && arm.elem === "u8"))) {
|
|
2047
|
+
return lowerStringOrBytesWrite(lowerer, expr, dataIr, arms, bi.member === "appendFileSync");
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
1984
2050
|
if (dataIr?.kind === "bytes") {
|
|
1985
2051
|
if (dataIr.elem !== "u8") {
|
|
1986
|
-
lowerer.noLowering(
|
|
2052
|
+
lowerer.noLowering(`${bi.member} of '${lowerer.fmt(dataIr)}' data`, expr.arguments[1], "byte writes take Uint8Array/Buffer data");
|
|
1987
2053
|
}
|
|
1988
2054
|
const path = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
1989
2055
|
const data = lowerer.lowerExprExpecting(expr.arguments[1], BYTES_U8);
|
|
1990
|
-
return { kind: "libCall", fn: "fs.writeFileSyncBytes", args: [path, data], type: VOID, loc };
|
|
2056
|
+
return { kind: "libCall", fn: bi.member === "appendFileSync" ? "fs.appendFileSyncBytes" : "fs.writeFileSyncBytes", args: [path, data], type: VOID, loc };
|
|
1991
2057
|
}
|
|
1992
2058
|
}
|
|
1993
2059
|
// writeFileSync(p, data, options) / fs.promises.writeFile(p, data,
|
|
@@ -2145,6 +2211,27 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2145
2211
|
}
|
|
2146
2212
|
const required = fn.params.length - (fn.defaults?.length ?? 0);
|
|
2147
2213
|
const hasSpread = expr.arguments.some(ts.isSpreadElement);
|
|
2214
|
+
if (!hasSpread && bi.module === "url" && bi.member === "pathToFileURL" && expr.arguments.length === 2) {
|
|
2215
|
+
let options = expr.arguments[1];
|
|
2216
|
+
while (ts.isParenthesizedExpression(options) || ts.isSatisfiesExpression(options))
|
|
2217
|
+
options = options.expression;
|
|
2218
|
+
if (!ts.isObjectLiteralExpression(options) || options.properties.length > 1) {
|
|
2219
|
+
lowerer.noLowering("pathToFileURL with these options", options, "use a literal { windows: boolean } options object");
|
|
2220
|
+
}
|
|
2221
|
+
let windowsNode = null;
|
|
2222
|
+
const property = options.properties[0];
|
|
2223
|
+
if (property) {
|
|
2224
|
+
if ((!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) ||
|
|
2225
|
+
(!ts.isIdentifier(property.name) && !ts.isStringLiteral(property.name)) || property.name.text !== "windows") {
|
|
2226
|
+
lowerer.noLowering("pathToFileURL with these options", property, "use a literal { windows: boolean } options object");
|
|
2227
|
+
}
|
|
2228
|
+
windowsNode = ts.isPropertyAssignment(property) ? property.initializer : property.name;
|
|
2229
|
+
}
|
|
2230
|
+
const path = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
2231
|
+
const defaultWindows = { kind: "boolLit", value: lowerer.targetPlatform === "win32", type: BOOL, loc };
|
|
2232
|
+
const windows = windowsNode ? lowerOptionalArgument(lowerer, windowsNode, BOOL, defaultWindows) : defaultWindows;
|
|
2233
|
+
return { kind: "libCall", fn: "url.pathToFileURLPlatform", args: [path, windows], type: fn.result, loc };
|
|
2234
|
+
}
|
|
2148
2235
|
if (hasSpread && bi.module === "url" && bi.member === "fileURLToPath") {
|
|
2149
2236
|
lowerer.noLowering("fileURLToPath with spread arguments", expr, "call fileURLToPath(value) directly so the URL-or-string overload remains statically visible");
|
|
2150
2237
|
}
|
|
@@ -2164,6 +2251,8 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2164
2251
|
// undefined, ...) must narrow first, like everywhere else.
|
|
2165
2252
|
const argNode = expr.arguments[0];
|
|
2166
2253
|
const arg = lowerer.lowerExpr(argNode);
|
|
2254
|
+
if (arg.type.kind === "dyn")
|
|
2255
|
+
return { kind: "libCall", fn: "url.fileURLToPathChecked", args: [arg], type: STRING, loc };
|
|
2167
2256
|
if (arg.type.kind === "url") {
|
|
2168
2257
|
return { kind: "libCall", fn: "url.fileURLToPathUrl", args: [arg], type: STRING, loc };
|
|
2169
2258
|
}
|
|
@@ -3813,20 +3902,20 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3813
3902
|
const loc = locOf(call);
|
|
3814
3903
|
if (name === "getStore" && call.arguments.length === 0) {
|
|
3815
3904
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3816
|
-
return { kind: "libCall", fn: "als.get", args: [receiver], type: DYN, loc };
|
|
3905
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.get", args: [receiver], type: DYN, loc });
|
|
3817
3906
|
}
|
|
3818
3907
|
if (name === "run" && call.arguments.length >= 2) {
|
|
3819
3908
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3820
3909
|
const value = dcMessageArg(lowerer, call.arguments[0]);
|
|
3821
3910
|
const fn = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
3822
3911
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(2), loc);
|
|
3823
|
-
return { kind: "libCall", fn: "als.run", args: [receiver, value, fn, rest], type: DYN, loc };
|
|
3912
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.run", args: [receiver, value, fn, rest], type: DYN, loc });
|
|
3824
3913
|
}
|
|
3825
3914
|
if (name === "exit" && call.arguments.length >= 1) {
|
|
3826
3915
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3827
3916
|
const fn = dcSubscriberArg(lowerer, call.arguments[0]);
|
|
3828
3917
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(1), loc);
|
|
3829
|
-
return { kind: "libCall", fn: "als.exitRun", args: [receiver, fn, rest], type: DYN, loc };
|
|
3918
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.exitRun", args: [receiver, fn, rest], type: DYN, loc });
|
|
3830
3919
|
}
|
|
3831
3920
|
if (name === "enterWith" && call.arguments.length === 1) {
|
|
3832
3921
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
@@ -3839,6 +3928,18 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3839
3928
|
}
|
|
3840
3929
|
lowerer.noLowering(`AsyncLocalStorage.${name}`, call, "run(store, fn, ...args), exit(fn, ...args), getStore(), enterWith(store), and disable() are the supported AsyncLocalStorage members", lowerer.checker.getSymbolAtLocation(access.name));
|
|
3841
3930
|
}
|
|
3931
|
+
/** The runtime carries a tagged value, while a typed ALS call promises
|
|
3932
|
+
* its generic store/callback result. Convert at that boundary so inferred
|
|
3933
|
+
* locals and immediate method calls share the same checked representation.
|
|
3934
|
+
* Untyped JS and unknown stores keep the original dynamic value. */
|
|
3935
|
+
function alsTypedResult(lowerer, call, value) {
|
|
3936
|
+
const expected = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
3937
|
+
// Promises already use the runtime's dynamic async path; unlike class
|
|
3938
|
+
// capsules, boxed typed promises do not have a checked extraction ABI.
|
|
3939
|
+
if (!expected || expected.kind === "dyn" || expected.kind === "void" || expected.kind === "promise")
|
|
3940
|
+
return value;
|
|
3941
|
+
return lowerer.coerceInto(call, value, expected);
|
|
3942
|
+
}
|
|
3842
3943
|
/** Property reads on Channel receivers: `.name` (the registration
|
|
3843
3944
|
* string) and `.hasSubscribers` (the publish guard). Null for
|
|
3844
3945
|
* non-Channel receivers and other members (the method fence owns them). */
|
|
@@ -4184,23 +4285,11 @@ export function strdecHelper(lowerer, op, shapeId, loc) {
|
|
|
4184
4285
|
lowerer.liftedFns.push({ name, params, returnType: STRING, locals, body, loc });
|
|
4185
4286
|
return name;
|
|
4186
4287
|
}
|
|
4187
|
-
/**
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
* - stringify → the type-DIRECTED `jsonStringify` node: the lib
|
|
4193
|
-
* signature honestly says `any`, but lowering requires the argument's
|
|
4194
|
-
* STATIC IR type to be JSON-safe — the backend emits a per-type
|
|
4195
|
-
* serializer, never a dynamic walk, so dyn (and closures/class
|
|
4196
|
-
* instances) are rejected here with a specific message. The
|
|
4197
|
-
* `stringify(v, null, space)` pretty-print form compiles when the
|
|
4198
|
-
* replacer is the literal null (or undefined) and the space is a
|
|
4199
|
-
* LITERAL — Node's rules apply at compile time (numbers clamp to 0–10
|
|
4200
|
-
* spaces, strings truncate to 10 code units) and the resolved indent
|
|
4201
|
-
* rides the node to the backend's re-indenter. Function replacers and
|
|
4202
|
-
* non-literal spaces stay fenced.
|
|
4203
|
-
* Null when this isn't a JSON member call. */
|
|
4288
|
+
/** JSON parse produces checked-dynamic data; a native reviver walks it
|
|
4289
|
+
* bottom-up before any checked cast. Stringify without a callback keeps
|
|
4290
|
+
* its type-directed fast path. A function replacer boxes the input and
|
|
4291
|
+
* walks it before primitive normalization. Both paths share literal gap
|
|
4292
|
+
* rules, and callback failures use ordinary native exception unwinding. */
|
|
4204
4293
|
export function lowerJsonMethodCall(lowerer, call, access) {
|
|
4205
4294
|
if (call.questionDotToken)
|
|
4206
4295
|
return null;
|
|
@@ -4208,12 +4297,19 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4208
4297
|
if (member === null)
|
|
4209
4298
|
return null;
|
|
4210
4299
|
const loc = locOf(call);
|
|
4211
|
-
if (member === "parse" && call.arguments.length
|
|
4212
|
-
|
|
4300
|
+
if ((member === "parse" && (call.arguments.length < 1 || call.arguments.length > 2)) ||
|
|
4301
|
+
(member === "stringify" && call.arguments.length > 3) ||
|
|
4302
|
+
call.arguments.some(ts.isSpreadElement)) {
|
|
4303
|
+
lowerer.noLowering(`JSON.${member} with extra or spread arguments`, call, "pass the JSON arguments explicitly");
|
|
4213
4304
|
}
|
|
4214
4305
|
if (member === "parse") {
|
|
4215
4306
|
const text = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
4216
|
-
|
|
4307
|
+
const reviver = call.arguments[1];
|
|
4308
|
+
if (!reviver || jsonNullishArgument(lowerer, reviver)) {
|
|
4309
|
+
return { kind: "libCall", fn: "json.parse", args: [text], type: DYN, loc };
|
|
4310
|
+
}
|
|
4311
|
+
const callback = lowerJsonCallback(lowerer, reviver, "reviver");
|
|
4312
|
+
return { kind: "libCall", fn: "json.parseReviver", args: [text, callback], type: DYN, loc };
|
|
4217
4313
|
}
|
|
4218
4314
|
if (member === "stringify") {
|
|
4219
4315
|
const indent = stringifySpaceIndent(lowerer, call);
|
|
@@ -4221,10 +4317,70 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4221
4317
|
return lowerer.wrappedUndefined(lowerer.withUndefinedArm(STRING), loc);
|
|
4222
4318
|
}
|
|
4223
4319
|
const argNode = call.arguments[0];
|
|
4224
|
-
|
|
4320
|
+
let value = lowerer.lowerExpr(argNode);
|
|
4321
|
+
// Optional Map/array reads and partially narrowed unions keep their
|
|
4322
|
+
// storage representation when lowered as ordinary arguments. Select
|
|
4323
|
+
// the JSON walker from the proven use-site type, using a checked
|
|
4324
|
+
// conversion so a stale capture cannot read an impossible payload.
|
|
4325
|
+
// Optional strings have a serializer that preserves a missing root;
|
|
4326
|
+
// an unchecked array read can still be absent despite its checker type.
|
|
4327
|
+
if (value.type.kind === "union" && optionalStringTags(lowerer, value.type) === null) {
|
|
4328
|
+
const narrowed = lowerer.mapTypeOf(lowerer.typeOf(argNode));
|
|
4329
|
+
if (narrowed && !isUnitType(narrowed) && narrowed.kind !== "void") {
|
|
4330
|
+
const helper = narrowed.kind === "union"
|
|
4331
|
+
? lowerer.narrowedRetagHelper(argNode, value.type.unionId, narrowed.unionId, loc)
|
|
4332
|
+
: lowerer.narrowedArmHelper(value.type.unionId, narrowed, loc);
|
|
4333
|
+
if (helper)
|
|
4334
|
+
value = { kind: "call", callee: helper, args: [value], type: narrowed, loc };
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
const replacer = call.arguments[1];
|
|
4338
|
+
if (replacer && !jsonNullishArgument(lowerer, replacer)) {
|
|
4339
|
+
const callback = lowerJsonCallback(lowerer, replacer, "replacer");
|
|
4340
|
+
if (value.type.kind === "undefinedT" || value.type.kind === "nullT")
|
|
4341
|
+
value = lowerer.coerceToExpected(value, DYN);
|
|
4342
|
+
// Evaluate the original arguments before taking a typed snapshot.
|
|
4343
|
+
// Creating the callback can itself mutate the input object.
|
|
4344
|
+
const inputSlot = lowerer.declareHiddenLocal("%jsonInput", value.type);
|
|
4345
|
+
const callbackSlot = lowerer.declareHiddenLocal("%jsonCallback", DYN);
|
|
4346
|
+
const boxed = lowerer.coerceToExpected(varRef(inputSlot.id, value.type, loc), DYN);
|
|
4347
|
+
if (boxed.type.kind !== "dyn") {
|
|
4348
|
+
lowerer.unsupported("SC1090", argNode, `JSON.stringify callback input of type '${lowerer.fmt(value.type)}' (the value must cross the checked-dynamic boundary)`);
|
|
4349
|
+
}
|
|
4350
|
+
const raw = {
|
|
4351
|
+
kind: "libCall", fn: "json.stringifyReplacer",
|
|
4352
|
+
args: [boxed, varRef(callbackSlot.id, DYN, loc), { kind: "strLit", value: indent, type: STRING, loc }],
|
|
4353
|
+
type: DYN, loc,
|
|
4354
|
+
};
|
|
4355
|
+
// A replacer can omit even the root. Preserve actual undefined;
|
|
4356
|
+
// an inferred binding adopts this union, while a required string
|
|
4357
|
+
// consumer uses the ordinary checked optional-value boundary.
|
|
4358
|
+
const result = { kind: "dynCheck", value: raw, type: lowerer.withUndefinedArm(STRING), loc };
|
|
4359
|
+
return {
|
|
4360
|
+
kind: "seqExpr", stmts: [
|
|
4361
|
+
{ kind: "varDecl", localId: inputSlot.id, init: value, loc },
|
|
4362
|
+
{ kind: "varDecl", localId: callbackSlot.id, init: callback, loc },
|
|
4363
|
+
], result, type: result.type, loc,
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4225
4366
|
const optionalString = lowerOptionalStringifyRoot(lowerer, value, indent, loc);
|
|
4226
4367
|
if (optionalString)
|
|
4227
4368
|
return optionalString;
|
|
4369
|
+
if (value.type.kind === "dyn" || isJsonStringifyDynamicType(value.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4370
|
+
// Keep the original containers live while the runtime visits them:
|
|
4371
|
+
// a toJSON callback can mutate a later field, and shared/cyclic
|
|
4372
|
+
// references must retain their identities throughout traversal.
|
|
4373
|
+
const boxed = value.type.kind === "dyn" ? value : { kind: "dynFrom", value, liveRef: true, type: DYN, loc };
|
|
4374
|
+
const raw = {
|
|
4375
|
+
kind: "libCall", fn: "json.stringifyReplacer",
|
|
4376
|
+
args: [boxed, dynUndefinedExpr(loc), { kind: "strLit", value: indent, type: STRING, loc }],
|
|
4377
|
+
type: DYN, loc,
|
|
4378
|
+
};
|
|
4379
|
+
// Preserve the existing dyn-root string ABI, including its textual
|
|
4380
|
+
// "undefined" result, while letting the runtime honor toJSON hooks.
|
|
4381
|
+
return value.type.kind === "dyn" ? { kind: "toString", operand: raw, type: STRING, loc }
|
|
4382
|
+
: { kind: "dynCheck", value: raw, type: lowerer.withUndefinedArm(STRING), loc };
|
|
4383
|
+
}
|
|
4228
4384
|
// An ISLAND value (`JSON.stringify(err)` on a package handle — the
|
|
4229
4385
|
// island error-inspection idiom): the ENGINE's own JSON.stringify
|
|
4230
4386
|
// runs, so key order, nesting, toJSON, and getters match Node by
|
|
@@ -4244,17 +4400,7 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4244
4400
|
const raw = { kind: "jsOp", op: "callMethod", name: "stringify", args, type: JSVAL, loc };
|
|
4245
4401
|
return { kind: "jsOp", op: "toStr", args: [raw], type: STRING, loc };
|
|
4246
4402
|
}
|
|
4247
|
-
|
|
4248
|
-
// `object` slots, the JSON.parse round-trip) serializes with the
|
|
4249
|
-
// runtime's dyn walker instead of a type-directed serializer — the
|
|
4250
|
-
// dyn is JSON-representable by construction (non-JSON values fenced
|
|
4251
|
-
// at their conversion INTO the slot). Two edges, both documented:
|
|
4252
|
-
// a root the stringify drops (runtime undefined) produces the TEXT
|
|
4253
|
-
// "undefined" where Node produces the undefined VALUE (tsc's own lib
|
|
4254
|
-
// types the return `string`, so no static consumer can tell), and a
|
|
4255
|
-
// runtime handle inside the tree throws (Node would walk its own
|
|
4256
|
-
// enumerable props, which the handle does not model).
|
|
4257
|
-
if (!lowerer.jsonStringifySafe(value.type) && value.type.kind !== "dyn") {
|
|
4403
|
+
if (!lowerer.jsonStringifySafe(value.type)) {
|
|
4258
4404
|
// Bare undefined-armed unions get their own wording: Node's
|
|
4259
4405
|
// stringify of bare undefined is not a string at all — per-type
|
|
4260
4406
|
// serialization cannot match that exactly, so the fence is
|
|
@@ -4271,16 +4417,47 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4271
4417
|
`(only number, string, boolean, records, arrays, unions of those, and 'unknown' stringify)`);
|
|
4272
4418
|
}
|
|
4273
4419
|
const node = { kind: "jsonStringify", value, type: STRING, loc };
|
|
4274
|
-
if (indent !== "")
|
|
4275
|
-
// The compile-time-resolved indent rides as an extra property (the
|
|
4276
|
-
// node shape in ir/ir.ts is unchanged); the backend re-indents
|
|
4277
|
-
// the compact serializer output with Node's gap algorithm.
|
|
4420
|
+
if (indent !== "")
|
|
4278
4421
|
node.indent = indent;
|
|
4279
|
-
}
|
|
4280
4422
|
return node;
|
|
4281
4423
|
}
|
|
4282
4424
|
return null; // unknown members are tsc errors before lowering
|
|
4283
4425
|
}
|
|
4426
|
+
/** A valid string/byte overload must select its runtime entry from the live
|
|
4427
|
+
* union tag. Coercing the whole argument to the string overload loses bytes. */
|
|
4428
|
+
function lowerStringOrBytesWrite(lowerer, call, dataType, arms, append) {
|
|
4429
|
+
const loc = locOf(call);
|
|
4430
|
+
const key = `fs.${append ? "append" : "write"}:${dataType.unionId}`;
|
|
4431
|
+
let helper = lowerer.widthHelpers.get(key);
|
|
4432
|
+
if (!helper) {
|
|
4433
|
+
helper = `%fs.writeData.${lowerer.widthHelpers.size}`;
|
|
4434
|
+
lowerer.widthHelpers.set(key, helper);
|
|
4435
|
+
const body = [];
|
|
4436
|
+
for (let tag = 0; tag < arms.length; tag++) {
|
|
4437
|
+
const arm = arms[tag];
|
|
4438
|
+
const fn = arm.kind === "bytes"
|
|
4439
|
+
? append ? "fs.appendFileSyncBytes" : "fs.writeFileSyncBytes"
|
|
4440
|
+
: append ? "fs.appendFileSync" : "fs.writeFileSync";
|
|
4441
|
+
body.push({ kind: "if", loc,
|
|
4442
|
+
cond: { kind: "unionIsTag", unionId: dataType.unionId, tag, negated: false,
|
|
4443
|
+
value: varRef("data.0", dataType, loc), type: BOOL, loc },
|
|
4444
|
+
then: [
|
|
4445
|
+
{ kind: "exprStmt", expr: { kind: "libCall", fn, args: [varRef("path.0", STRING, loc),
|
|
4446
|
+
{ kind: "unionNarrow", unionId: dataType.unionId, tag, value: varRef("data.0", dataType, loc), type: arm, loc }], type: VOID, loc }, loc },
|
|
4447
|
+
{ kind: "return", value: null, loc },
|
|
4448
|
+
], else_: null,
|
|
4449
|
+
});
|
|
4450
|
+
}
|
|
4451
|
+
body.push({ kind: "return", value: null, loc });
|
|
4452
|
+
lowerer.liftedFns.push({ name: helper, returnType: VOID, loc,
|
|
4453
|
+
params: [{ localId: "path.0", name: "path", type: STRING }, { localId: "data.0", name: "data", type: dataType }],
|
|
4454
|
+
locals: [{ id: "path.0", name: "path", type: STRING, mutable: false }, { id: "data.0", name: "data", type: dataType, mutable: false }],
|
|
4455
|
+
body,
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
return { kind: "call", callee: helper, args: [lowerer.lowerExprExpecting(call.arguments[0], STRING),
|
|
4459
|
+
lowerer.lowerExprExpecting(call.arguments[1], dataType)], type: VOID, loc };
|
|
4460
|
+
}
|
|
4284
4461
|
function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
4285
4462
|
const tags = optionalStringTags(lowerer, value.type);
|
|
4286
4463
|
if (!tags || value.type.kind !== "union")
|
|
@@ -4323,22 +4500,37 @@ function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
|
4323
4500
|
}
|
|
4324
4501
|
return { kind: "call", callee: helper, args: [value], type: resultT, loc };
|
|
4325
4502
|
}
|
|
4326
|
-
/**
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4503
|
+
/** Only explicit null/undefined select the no-callback path. */
|
|
4504
|
+
function jsonNullishArgument(lowerer, node) {
|
|
4505
|
+
if (ts.isParenthesizedExpression(node))
|
|
4506
|
+
return jsonNullishArgument(lowerer, node.expression);
|
|
4507
|
+
if (node.kind === ts.SyntaxKind.NullKeyword)
|
|
4508
|
+
return true;
|
|
4509
|
+
if (!ts.isIdentifier(node) || node.text !== "undefined")
|
|
4510
|
+
return false;
|
|
4511
|
+
const symbol = lowerer.checker.getSymbolAtLocation(node);
|
|
4512
|
+
return symbol !== undefined && lowerer.checker.declarationsOf(symbol).every((decl) => lowerer.isStdlibFile(decl.getSourceFile()));
|
|
4513
|
+
}
|
|
4514
|
+
/** JSON callbacks cross the same checked native function boundary as other
|
|
4515
|
+
* runtime callbacks. Reviver source contexts need parser source tracking;
|
|
4516
|
+
* refuse signatures that request one until that protocol is implemented. */
|
|
4517
|
+
function lowerJsonCallback(lowerer, node, role) {
|
|
4518
|
+
const callback = lowerer.lowerExpr(node);
|
|
4519
|
+
if (callback.type.kind === "func" && callback.type.params.length <= 2 &&
|
|
4520
|
+
(role !== "reviver" || (!callback.type.rest && !callback.type.argumentsAll)) &&
|
|
4521
|
+
canBoxFuncIntoDyn(callback.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4522
|
+
return { kind: "dynFrom", value: callback, type: DYN, loc: locOf(node) };
|
|
4523
|
+
}
|
|
4524
|
+
lowerer.noLowering(`JSON ${role} of type '${lowerer.fmt(callback.type)}'`, node, "use a native function taking key and value; replacer arrays and reviver source contexts are not supported yet");
|
|
4525
|
+
}
|
|
4526
|
+
/** Compile-time Node gap rules: numbers clamp to 0–10 spaces and strings
|
|
4527
|
+
* truncate to ten UTF-16 code units. Callback validation is independent. */
|
|
4333
4528
|
function stringifySpaceIndent(lowerer, call) {
|
|
4334
4529
|
const fence = () => lowerer.noLowering("JSON.stringify with replacer/space parameters", call, "the serializer is type-directed — shape the value before stringifying");
|
|
4335
4530
|
if (call.arguments.length <= 1)
|
|
4336
4531
|
return "";
|
|
4337
4532
|
const unwrap = (e) => ts.isParenthesizedExpression(e) ? unwrap(e.expression) : e;
|
|
4338
|
-
const isUndefined = (e) =>
|
|
4339
|
-
const replacer = unwrap(call.arguments[1]);
|
|
4340
|
-
if (replacer.kind !== ts.SyntaxKind.NullKeyword && !isUndefined(replacer))
|
|
4341
|
-
fence();
|
|
4533
|
+
const isUndefined = (e) => jsonNullishArgument(lowerer, e);
|
|
4342
4534
|
if (call.arguments.length === 2)
|
|
4343
4535
|
return "";
|
|
4344
4536
|
const space = unwrap(call.arguments[2]);
|
|
@@ -4381,6 +4573,8 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4381
4573
|
if (ts.isVariableDeclaration(varDecl) && varDecl.initializer !== undefined) {
|
|
4382
4574
|
const spec = requireSpecOf(varDecl.initializer);
|
|
4383
4575
|
if (spec !== null) {
|
|
4576
|
+
if (isNativeFfiRequire(lowerer, varDecl.initializer))
|
|
4577
|
+
return null;
|
|
4384
4578
|
const isBuiltin = spec.startsWith("node:") || builtinModules.includes(spec);
|
|
4385
4579
|
return isBuiltin && canonicalBuiltinModule(spec) === null ? spec : null;
|
|
4386
4580
|
}
|
|
@@ -4388,9 +4582,9 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4388
4582
|
}
|
|
4389
4583
|
let importDecl;
|
|
4390
4584
|
if (ts.isImportSpecifier(decl))
|
|
4391
|
-
importDecl = decl.parent
|
|
4585
|
+
importDecl = decl.parent?.parent?.parent;
|
|
4392
4586
|
else if (ts.isNamespaceImport(decl))
|
|
4393
|
-
importDecl = decl.parent
|
|
4587
|
+
importDecl = decl.parent?.parent;
|
|
4394
4588
|
else if (ts.isImportClause(decl))
|
|
4395
4589
|
importDecl = decl.parent;
|
|
4396
4590
|
else
|
|
@@ -5324,7 +5518,11 @@ export function lowerCryptoHashMethodCall(lowerer, call, access) {
|
|
|
5324
5518
|
lowerer.noLowering(`${receiverType.kind === "cryptoHash" ? "Hash" : "Hmac"}.update with ${call.arguments.length} arguments`, call, "update(stringOrBuffer[, inputEncoding]) is supported");
|
|
5325
5519
|
}
|
|
5326
5520
|
const dataNode = call.arguments[0];
|
|
5327
|
-
const
|
|
5521
|
+
const dataType = lowerer.mapTypeOf(lowerer.typeOf(dataNode));
|
|
5522
|
+
// Indexed reads can retain optional storage after a nullish fallback
|
|
5523
|
+
// or narrowing. Use the proven argument type through a checked coercion.
|
|
5524
|
+
const data = dataType?.kind === "string" || dataType?.kind === "bytes"
|
|
5525
|
+
? lowerer.lowerExprExpecting(dataNode, dataType) : lowerer.lowerExpr(dataNode);
|
|
5328
5526
|
const prefix = receiverType.kind === "cryptoHash" ? "crypto.hashUpdate" : "crypto.hmacUpdate";
|
|
5329
5527
|
if (data.type.kind === "bytes" && data.type.elem === "u8") {
|
|
5330
5528
|
if (call.arguments.length !== 1) {
|
|
@@ -5862,6 +6060,13 @@ export function lowerProcStreamMethodCall(lowerer, call, access) {
|
|
|
5862
6060
|
return null;
|
|
5863
6061
|
const name = access.name.text;
|
|
5864
6062
|
const loc = locOf(call);
|
|
6063
|
+
if (isJsSourceFile(call.getSourceFile())) {
|
|
6064
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
6065
|
+
if (receiver.type.kind === "dyn") {
|
|
6066
|
+
return { kind: "dynInvoke", recv: receiver, method: name, calleeName: call.expression.getText(),
|
|
6067
|
+
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), type: DYN, loc };
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
5865
6070
|
if (name === "write" && call.arguments.length === 1) {
|
|
5866
6071
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5867
6072
|
const data = lowerer.lowerExpr(call.arguments[0]);
|
|
@@ -5966,7 +6171,8 @@ export function lowerWatcherMethodCall(lowerer, call, access) {
|
|
|
5966
6171
|
}
|
|
5967
6172
|
lowerer.noLowering(`FSWatcher.${name}`, call, "close() is the supported FSWatcher member", lowerer.checker.getSymbolAtLocation(access.name));
|
|
5968
6173
|
}
|
|
5969
|
-
/** `.code` on an error-hierarchy receiver
|
|
6174
|
+
/** `.code` and `.cause` on an error-hierarchy receiver. The latter reads
|
|
6175
|
+
* the hidden dyn slot installed by constructor options. The former is NodeJS.ErrnoException's
|
|
5970
6176
|
* member (the fallback declares the same shape): the runtime Error's
|
|
5971
6177
|
* code slot as `string | undefined` — the errno name where a throw site
|
|
5972
6178
|
* stamped one (fs, exec spawn/timeout, process.kill, the spawn 'error'
|
|
@@ -6000,10 +6206,10 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
6000
6206
|
return { kind: "libCall", fn: "error.domCause", args: [receiver], type: DYN, loc: locOf(expr) };
|
|
6001
6207
|
}
|
|
6002
6208
|
}
|
|
6003
|
-
if (expr.name.text !== "code")
|
|
6209
|
+
if (expr.name.text !== "code" && expr.name.text !== "cause" && expr.name.text !== "stack")
|
|
6004
6210
|
return null;
|
|
6005
6211
|
// Error-rooted classes only — builtin or user subclass (both embed the
|
|
6006
|
-
// code
|
|
6212
|
+
// code and cause slots in their layout prefix).
|
|
6007
6213
|
let info = lowerer.classes.get(recvT.className) ?? null;
|
|
6008
6214
|
while (info && info.base)
|
|
6009
6215
|
info = info.base;
|
|
@@ -6014,19 +6220,31 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
6014
6220
|
const receiver = lowerer.lowerExpr(expr.expression);
|
|
6015
6221
|
return {
|
|
6016
6222
|
kind: "libCall",
|
|
6017
|
-
fn: "error.code",
|
|
6223
|
+
fn: expr.name.text === "stack" ? "error.stack" : expr.name.text === "cause" ? "error.cause" : "error.code",
|
|
6018
6224
|
args: [receiver],
|
|
6019
|
-
type: lowerer.envValueType(),
|
|
6225
|
+
type: expr.name.text === "stack" ? STRING : expr.name.text === "cause" ? DYN : lowerer.envValueType(),
|
|
6020
6226
|
loc: locOf(expr),
|
|
6021
6227
|
};
|
|
6022
6228
|
}
|
|
6023
|
-
/**
|
|
6024
|
-
*
|
|
6025
|
-
* receivers (the property chain keeps trying other lowerings). */
|
|
6229
|
+
/** Stored stringify uses the same native serializer and keeps omitted roots
|
|
6230
|
+
* as undefined. Other JSON method values retain a named refusal. */
|
|
6026
6231
|
export function lowerJsonProperty(lowerer, expr) {
|
|
6027
6232
|
const member = lowerer.stdlibGlobalMember(expr, "JSON");
|
|
6028
6233
|
if (member === null)
|
|
6029
6234
|
return null;
|
|
6235
|
+
if (member === "stringify") {
|
|
6236
|
+
const loc = locOf(expr);
|
|
6237
|
+
const name = "%builtin.JSON.stringify";
|
|
6238
|
+
if (!lowerer.builtinCallableValueFns.has(name)) {
|
|
6239
|
+
lowerer.builtinCallableValueFns.set(name, name);
|
|
6240
|
+
const params = ["value", "replacer", "space"].map((name) => ({ localId: name, name, type: DYN }));
|
|
6241
|
+
lowerer.liftedFns.push({ name, params, returnType: DYN,
|
|
6242
|
+
locals: params.map((p) => ({ id: p.localId, name: p.name, type: DYN, mutable: false })), loc,
|
|
6243
|
+
body: [{ kind: "return", value: { kind: "libCall", fn: "json.stringifyValue", args: params.map((p) => varRef(p.localId, DYN, loc)), type: DYN, loc }, loc }],
|
|
6244
|
+
});
|
|
6245
|
+
}
|
|
6246
|
+
return { kind: "dynFrom", value: { kind: "closure", fnName: name, captures: [], type: { kind: "func", params: [DYN, DYN, DYN], ret: DYN }, loc }, fnName: "stringify", type: DYN, loc };
|
|
6247
|
+
}
|
|
6030
6248
|
lowerer.unsupported("SC1090", expr, `JSON methods as values (call '${member}' directly)`);
|
|
6031
6249
|
}
|
|
6032
6250
|
/** `constants.X_OK` where `constants` is a named fs import: the access-
|
|
@@ -6066,6 +6284,16 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6066
6284
|
if (expr.questionDotToken)
|
|
6067
6285
|
return null;
|
|
6068
6286
|
const member = expr.name.text;
|
|
6287
|
+
const direct = ts.isPropertyAccessExpression(expr.expression) ? lowerer.stdlibGlobalMember(expr.expression, "process") : null;
|
|
6288
|
+
if (isJsSourceFile(expr.getSourceFile()) &&
|
|
6289
|
+
(direct === "stdin" || direct === "stdout" || direct === "stderr" ||
|
|
6290
|
+
lowerer.mapTypeOf(lowerer.typeOf(expr.expression))?.kind === "procStream")) {
|
|
6291
|
+
const value = lowerer.lowerExpr(expr.expression);
|
|
6292
|
+
if (value.type.kind === "dyn")
|
|
6293
|
+
return {
|
|
6294
|
+
kind: "dynKeyGet", value, key: strLit(member, locOf(expr.name)), type: DYN, loc: locOf(expr),
|
|
6295
|
+
};
|
|
6296
|
+
}
|
|
6069
6297
|
if (member !== "isTTY" && member !== "columns" && member !== "rows")
|
|
6070
6298
|
return null;
|
|
6071
6299
|
let recv = expr.expression;
|
|
@@ -6125,12 +6353,14 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6125
6353
|
* rejected specifically. Null for non-process receivers (the chain keeps
|
|
6126
6354
|
* trying other property lowerings). */
|
|
6127
6355
|
export function lowerProcessProperty(lowerer, expr) {
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6356
|
+
if (!expr.questionDotToken && expr.name.text === "bigint" && ts.isPropertyAccessExpression(expr.expression) &&
|
|
6357
|
+
lowerer.stdlibGlobalMember(expr.expression, "process") === "hrtime") {
|
|
6358
|
+
const loc = locOf(expr);
|
|
6359
|
+
return { kind: "dynKeyGet", value: { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc },
|
|
6360
|
+
key: { kind: "strLit", value: "bigint", type: STRING, loc }, type: DYN, loc };
|
|
6361
|
+
}
|
|
6362
|
+
// node and openssl name the compatibility target, not linked engines.
|
|
6363
|
+
// Read the stable object so descriptor edits through aliases stay visible.
|
|
6134
6364
|
if ((expr.name.text === "node" || expr.name.text === "openssl") &&
|
|
6135
6365
|
!expr.questionDotToken &&
|
|
6136
6366
|
ts.isPropertyAccessExpression(expr.expression) &&
|
|
@@ -6140,34 +6370,30 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6140
6370
|
// "is crypto available" probe, and the crypto module exists here
|
|
6141
6371
|
// (unsupported members fence per site). SEMANTICS.md documents that
|
|
6142
6372
|
// the string names the compat target, not a linked library.
|
|
6143
|
-
const
|
|
6144
|
-
return {
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
//
|
|
6373
|
+
const loc = locOf(expr);
|
|
6374
|
+
return lowerer.coerceToExpected({
|
|
6375
|
+
kind: "dynKeyGet", key: { kind: "strLit", value: expr.name.text, type: STRING, loc },
|
|
6376
|
+
value: { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc }, type: DYN, loc,
|
|
6377
|
+
}, STRING);
|
|
6378
|
+
}
|
|
6379
|
+
// Other components begin absent. Consult the same object even for the
|
|
6380
|
+
// capability probes: users can define or delete their own entries.
|
|
6150
6381
|
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
6151
|
-
lowerer.stdlibGlobalMember(expr.expression, "process") === "versions"
|
|
6152
|
-
|
|
6153
|
-
return {
|
|
6382
|
+
lowerer.stdlibGlobalMember(expr.expression, "process") === "versions") {
|
|
6383
|
+
const loc = locOf(expr);
|
|
6384
|
+
return {
|
|
6385
|
+
kind: "dynKeyGet", key: { kind: "strLit", value: expr.name.text, type: STRING, loc },
|
|
6386
|
+
value: { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc }, type: DYN, loc,
|
|
6387
|
+
};
|
|
6154
6388
|
}
|
|
6155
6389
|
// The capability-probe members that honestly DON'T EXIST in a
|
|
6156
6390
|
// compiled binary — each reads undefined (their declared types carry
|
|
6157
6391
|
// the undefined arm), so feature probes take their documented
|
|
6158
|
-
// fallbacks: no
|
|
6159
|
-
// .sqlite), no gyp build config (process.config.variables.* — no ICU,
|
|
6392
|
+
// fallbacks: no gyp build config (process.config.variables.* — no ICU,
|
|
6160
6393
|
// no QUIC — and process.config.target_defaults), no feature flags
|
|
6161
6394
|
// (process.features.* — no inspector, not a debug build).
|
|
6162
6395
|
if (!expr.questionDotToken && ts.isPropertyAccessExpression(expr.expression)) {
|
|
6163
6396
|
const container = lowerer.stdlibGlobalMember(expr.expression, "process");
|
|
6164
|
-
if (container === "versions" && (expr.name.text === "sqlite" || expr.name.text === "bun" || expr.name.text === "deno")) {
|
|
6165
|
-
// versions.bun / versions.deno are the OTHER-runtime probes (a
|
|
6166
|
-
// formatter's config loader picks its package.json reader by
|
|
6167
|
-
// them): a compiled binary is neither, so both read undefined —
|
|
6168
|
-
// exactly Node's own answer.
|
|
6169
|
-
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6170
|
-
}
|
|
6171
6397
|
if (container === "features") {
|
|
6172
6398
|
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6173
6399
|
}
|
|
@@ -6190,6 +6416,18 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6190
6416
|
if (member === null)
|
|
6191
6417
|
return null;
|
|
6192
6418
|
const loc = locOf(expr);
|
|
6419
|
+
if (member === "versions") {
|
|
6420
|
+
return { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc };
|
|
6421
|
+
}
|
|
6422
|
+
if (member === "hrtime") {
|
|
6423
|
+
return { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc };
|
|
6424
|
+
}
|
|
6425
|
+
if (member === "getBuiltinModule") {
|
|
6426
|
+
// Keep the native loader's argument validation when the function is
|
|
6427
|
+
// stored. The declaration's string signature must not insert a checked
|
|
6428
|
+
// adapter before the loader gets to report Node's invalid-id error.
|
|
6429
|
+
return { kind: "dynFrom", value: lowerBuiltinLoaderValue(lowerer, loc), type: DYN, loc };
|
|
6430
|
+
}
|
|
6193
6431
|
if (member === "argv") {
|
|
6194
6432
|
return { kind: "libCall", fn: "process.argv", args: [], type: arrayOf(STRING), loc };
|
|
6195
6433
|
}
|
|
@@ -6242,6 +6480,9 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6242
6480
|
// procStream scalar, minted as the stream's fd. Member reads
|
|
6243
6481
|
// (`process.stdout.isTTY`, `.write(...)`) never reach here — their
|
|
6244
6482
|
// OUTER expressions dispatch first.
|
|
6483
|
+
if (member === "stdin" || ((member === "stdout" || member === "stderr") && isJsSourceFile(expr.getSourceFile()))) {
|
|
6484
|
+
return { kind: "libCall", fn: "process.stdio", args: [numLit(member === "stdin" ? 0 : member === "stdout" ? 1 : 2, loc)], type: DYN, loc };
|
|
6485
|
+
}
|
|
6245
6486
|
if (member === "stdout" || member === "stderr") {
|
|
6246
6487
|
return { kind: "numLit", value: member === "stdout" ? 1 : 2, type: PROCSTREAM_T, loc };
|
|
6247
6488
|
}
|
|
@@ -6320,9 +6561,12 @@ function lowerFsReaddirTypesCall(lowerer, call, loc, promiseForm) {
|
|
|
6320
6561
|
const callType = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6321
6562
|
if (!callType)
|
|
6322
6563
|
fence();
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6564
|
+
let result = callType;
|
|
6565
|
+
if (promiseForm) {
|
|
6566
|
+
if (callType.kind !== "promise")
|
|
6567
|
+
fence();
|
|
6568
|
+
result = callType.inner;
|
|
6569
|
+
}
|
|
6326
6570
|
if (result?.kind !== "array" || result.elem.kind !== "record")
|
|
6327
6571
|
fence();
|
|
6328
6572
|
const shape = lowerer.shapes.get(result.elem.shapeId);
|
|
@@ -6505,9 +6749,10 @@ function lowerQuerystringParseCall(lowerer, call, loc) {
|
|
|
6505
6749
|
}
|
|
6506
6750
|
if (!sawStr || !sawArr)
|
|
6507
6751
|
fence();
|
|
6508
|
-
const
|
|
6509
|
-
|
|
6510
|
-
|
|
6752
|
+
const argument = call.arguments[0];
|
|
6753
|
+
if (!argument)
|
|
6754
|
+
lowerer.noLowering("querystring.parse without a query string", call);
|
|
6755
|
+
const str = lowerer.lowerExprExpecting(argument, STRING);
|
|
6511
6756
|
const sep = qsSepEqArg(lowerer, call.arguments[1], "&", "querystring.parse", loc);
|
|
6512
6757
|
const eq = qsSepEqArg(lowerer, call.arguments[2], "=", "querystring.parse", loc);
|
|
6513
6758
|
// The options walk: maxKeys lowers (Node's rule — > 0 caps the pair
|
|
@@ -6679,7 +6924,35 @@ export function lowerProcessEnvGet(lowerer, expr) {
|
|
|
6679
6924
|
export function lowerProcessMethodCall(lowerer, call, access) {
|
|
6680
6925
|
if (call.questionDotToken)
|
|
6681
6926
|
return null;
|
|
6927
|
+
if (isJsSourceFile(call.getSourceFile()) && ts.isPropertyAccessExpression(access.expression)) {
|
|
6928
|
+
const stream = lowerer.stdlibGlobalMember(access.expression, "process");
|
|
6929
|
+
if (stream === "stdin" || stream === "stdout" || stream === "stderr") {
|
|
6930
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
6931
|
+
lowerer.noLowering("process stream spread arguments", call);
|
|
6932
|
+
return { kind: "dynInvoke", recv: lowerer.lowerExpr(access.expression), method: access.name.text,
|
|
6933
|
+
calleeName: access.getText(), args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), type: DYN, loc: locOf(call) };
|
|
6934
|
+
}
|
|
6935
|
+
}
|
|
6682
6936
|
const directProcessMember = lowerer.stdlibGlobalMember(access, "process");
|
|
6937
|
+
if (directProcessMember === "hrtime") {
|
|
6938
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
6939
|
+
lowerer.noLowering("process.hrtime with spread arguments", call);
|
|
6940
|
+
const loc = locOf(call);
|
|
6941
|
+
return { kind: "dynCall", callee: { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc },
|
|
6942
|
+
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), calleeName: "process.hrtime", type: DYN, loc };
|
|
6943
|
+
}
|
|
6944
|
+
if (directProcessMember === "getBuiltinModule") {
|
|
6945
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
6946
|
+
lowerer.noLowering("process.getBuiltinModule with spread arguments", call);
|
|
6947
|
+
const loc = locOf(call);
|
|
6948
|
+
const id = call.arguments[0] ? lowerer.lowerExprExpecting(call.arguments[0], DYN)
|
|
6949
|
+
: { kind: "dynFrom", value: { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc }, type: DYN, loc };
|
|
6950
|
+
const binding = lowerer.declareHiddenLocal("%builtinId", DYN);
|
|
6951
|
+
return { kind: "seqExpr", stmts: [
|
|
6952
|
+
{ kind: "varDecl", localId: binding.id, init: id, loc },
|
|
6953
|
+
...call.arguments.slice(1).map((arg) => ({ kind: "exprStmt", expr: lowerer.lowerExpr(arg), loc: locOf(arg) })),
|
|
6954
|
+
], result: { kind: "callValue", callee: lowerBuiltinLoaderValue(lowerer, loc), args: [varRef(binding.id, DYN, loc)], type: DYN, loc }, type: DYN, loc };
|
|
6955
|
+
}
|
|
6683
6956
|
if (directProcessMember === "send")
|
|
6684
6957
|
return lowerProcessIpcSend(lowerer, call);
|
|
6685
6958
|
if (directProcessMember === "disconnect") {
|
|
@@ -6935,7 +7208,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6935
7208
|
if (member === null)
|
|
6936
7209
|
return null;
|
|
6937
7210
|
const loc = locOf(call);
|
|
6938
|
-
// process.on/once/off: the CLI event slice —
|
|
7211
|
+
// process.on/once/off: the CLI event slice — named OS
|
|
6939
7212
|
// signal handlers and the 'exit' hook. Signal listeners run as
|
|
6940
7213
|
// macrotasks at loop turns, replace the default disposition while
|
|
6941
7214
|
// registered (removing the last restores Ctrl-C death), and never
|
|
@@ -6966,12 +7239,17 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6966
7239
|
loc,
|
|
6967
7240
|
};
|
|
6968
7241
|
}
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
7242
|
+
if (event === "uncaughtException" || event === "uncaughtExceptionMonitor") {
|
|
7243
|
+
if (!ts.isExpressionStatement(call.parent)) {
|
|
7244
|
+
lowerer.unsupported("SC1090", call, "chaining process exception listener registration");
|
|
7245
|
+
}
|
|
7246
|
+
const cb = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
7247
|
+
const monitor = boolLit(event === "uncaughtExceptionMonitor", loc);
|
|
7248
|
+
return {
|
|
7249
|
+
kind: "libCall", fn: isOff ? "process.offUncaughtException" : "process.onUncaughtException",
|
|
7250
|
+
args: isOff ? [cb, monitor] : [cb, boolLit(member === "once", loc), monitor], type: VOID, loc,
|
|
7251
|
+
};
|
|
7252
|
+
}
|
|
6975
7253
|
// 'unhandledRejection': the listener crosses as a dyn function and
|
|
6976
7254
|
// the completed-checkpoint report dispatches it (reason, promise) per
|
|
6977
7255
|
// never-observed rejection instead of printing and exiting 1
|
|
@@ -7007,8 +7285,23 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7007
7285
|
loc,
|
|
7008
7286
|
};
|
|
7009
7287
|
}
|
|
7010
|
-
if (
|
|
7011
|
-
|
|
7288
|
+
if (event === null || event.startsWith("SIG")) {
|
|
7289
|
+
if (!ts.isExpressionStatement(call.parent)) {
|
|
7290
|
+
lowerer.unsupported("SC1090", call, "chaining process signal listener registration");
|
|
7291
|
+
}
|
|
7292
|
+
const name = lowerer.coerceToExpected(lowerer.lowerExpr(call.arguments[0]), STRING);
|
|
7293
|
+
if (name.type.kind !== "string" && name.type.kind !== "dyn") {
|
|
7294
|
+
lowerer.noLowering("process signal event name that is not a string", call.arguments[0]);
|
|
7295
|
+
}
|
|
7296
|
+
const signal = name.type.kind === "string" ? name : { kind: "dynCheck", value: name, type: STRING, loc };
|
|
7297
|
+
const cb = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
7298
|
+
return {
|
|
7299
|
+
kind: "libCall", fn: isOff ? "process.offSignal" : "process.onSignal",
|
|
7300
|
+
args: isOff ? [signal, cb] : [signal, cb, boolLit(member === "once", loc)], type: VOID, loc,
|
|
7301
|
+
};
|
|
7302
|
+
}
|
|
7303
|
+
if (event !== "exit") {
|
|
7304
|
+
lowerer.noLowering(`process.${member}("${event}", ...)`, call.arguments[0]);
|
|
7012
7305
|
}
|
|
7013
7306
|
if (!ts.isExpressionStatement(call.parent)) {
|
|
7014
7307
|
lowerer.unsupported("SC1090", call, "chaining process listener registration (the result is void here — register each listener as its own statement)");
|
|
@@ -7023,7 +7316,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7023
7316
|
// result; a non-function dyn value throws the catchable TypeError
|
|
7024
7317
|
// at REGISTRATION (Node's ERR_INVALID_ARG_TYPE moment).
|
|
7025
7318
|
{
|
|
7026
|
-
const target = funcOf(
|
|
7319
|
+
const target = funcOf([F64], VOID);
|
|
7027
7320
|
const exact = cb.type.kind === "func" &&
|
|
7028
7321
|
cb.type.ret.kind === "void" &&
|
|
7029
7322
|
cb.type.params.length <= 1 &&
|
|
@@ -7048,16 +7341,6 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7048
7341
|
}
|
|
7049
7342
|
const param = cb.type.params[0];
|
|
7050
7343
|
const onceArg = { kind: "boolLit", value: member === "once", type: BOOL, loc };
|
|
7051
|
-
if (signo !== undefined) {
|
|
7052
|
-
if (param !== undefined) {
|
|
7053
|
-
lowerer.unsupported("SC1090", call.arguments[1], "signal listeners with parameters (the signal name argument has no lowering — use ())");
|
|
7054
|
-
}
|
|
7055
|
-
const sig = { kind: "numLit", value: signo, type: F64, loc };
|
|
7056
|
-
if (isOff) {
|
|
7057
|
-
return { kind: "libCall", fn: "process.offSignal", args: [sig, cb], type: VOID, loc };
|
|
7058
|
-
}
|
|
7059
|
-
return { kind: "libCall", fn: "process.onSignal", args: [sig, cb, onceArg], type: VOID, loc };
|
|
7060
|
-
}
|
|
7061
7344
|
if (param !== undefined && param.kind !== "f64") {
|
|
7062
7345
|
lowerer.unsupported("SC1090", call.arguments[1], `exit listeners whose parameter is not 'number' (got '${lowerer.fmt(param)}')`);
|
|
7063
7346
|
}
|
|
@@ -7332,7 +7615,7 @@ const NUMBER_STATIC_PREDICATES = {
|
|
|
7332
7615
|
isSafeInteger: "number.isSafeInteger",
|
|
7333
7616
|
};
|
|
7334
7617
|
/** The Number constants, baked as literals — non-finite ones included
|
|
7335
|
-
* (numLits carry NaN and the infinities;
|
|
7618
|
+
* (numLits carry NaN and the infinities; the backend preserves them). */
|
|
7336
7619
|
const NUMBER_CONSTANTS = {
|
|
7337
7620
|
MAX_SAFE_INTEGER: 9007199254740991,
|
|
7338
7621
|
MIN_SAFE_INTEGER: -9007199254740991,
|
|
@@ -7466,7 +7749,9 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7466
7749
|
if (call.arguments.length !== 0) {
|
|
7467
7750
|
lowerer.noLowering(`Date.prototype.${name} with arguments`, call, DATE_METHOD_HINT);
|
|
7468
7751
|
}
|
|
7469
|
-
const
|
|
7752
|
+
const raw = lowerer.lowerExpr(access.expression);
|
|
7753
|
+
const receiver = raw.type.kind === "dyn"
|
|
7754
|
+
? { kind: "libCall", fn: "date.checkedValue", args: [raw], type: { kind: "date" }, loc } : raw;
|
|
7470
7755
|
if (receiver.type.kind !== "date")
|
|
7471
7756
|
lowerer.badType(access.expression, lowerer.typeOf(access.expression));
|
|
7472
7757
|
if (name === "getTime" || name === "valueOf") {
|
|
@@ -7487,78 +7772,87 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7487
7772
|
}
|
|
7488
7773
|
lowerer.noLowering(`Date.prototype.${name}`, call, DATE_METHOD_HINT, lowerer.checker.getSymbolAtLocation(access.name));
|
|
7489
7774
|
}
|
|
7490
|
-
|
|
7491
|
-
*
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
const
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
const
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7775
|
+
/** Box a codec's immutable encoding in an owned record. Unlike erased
|
|
7776
|
+
* aliases, this value can live in fields, arguments, and closure captures. */
|
|
7777
|
+
export function lowerTextCodecNew(lowerer, ctor, cls) {
|
|
7778
|
+
const args = ctor.arguments ?? [];
|
|
7779
|
+
const loc = locOf(ctor);
|
|
7780
|
+
let encoding = -1;
|
|
7781
|
+
let label = null;
|
|
7782
|
+
if (cls === "TextEncoder") {
|
|
7783
|
+
if (args.length !== 0)
|
|
7784
|
+
lowerer.noLowering("new TextEncoder with arguments", ctor);
|
|
7785
|
+
}
|
|
7786
|
+
else if (args.length !== 0) {
|
|
7787
|
+
const labelT = lowerer.typeOf(args[0]);
|
|
7788
|
+
const parsed = labelT.isStringLiteralType() ? staticTextDecoderEncoding(labelT.value) : null;
|
|
7789
|
+
if (args.length !== 1 || parsed === null) {
|
|
7790
|
+
lowerer.noLowering("new TextDecoder with runtime-valued options or an unknown label", ctor, "a recognized literal WHATWG label with default options compiles");
|
|
7791
|
+
}
|
|
7792
|
+
encoding = parsed.kind === "utf8" ? -1 : parsed.id;
|
|
7793
|
+
label = lowerer.lowerExprExpecting(args[0], STRING);
|
|
7794
|
+
}
|
|
7795
|
+
const type = lowerer.mapTypeOf(lowerer.typeOf(ctor));
|
|
7796
|
+
if (type?.kind !== "record")
|
|
7797
|
+
lowerer.badType(ctor, lowerer.typeOf(ctor));
|
|
7798
|
+
const result = {
|
|
7799
|
+
kind: "recordLit", fields: [{ name: `%${cls}`, value: { kind: "numLit", value: encoding, type: F64, loc } }], type, loc,
|
|
7510
7800
|
};
|
|
7511
|
-
|
|
7512
|
-
|
|
7801
|
+
return label === null || label.kind === "strLit" ? result : {
|
|
7802
|
+
kind: "seqExpr", stmts: [{ kind: "exprStmt", expr: label, loc }], result, type, loc,
|
|
7513
7803
|
};
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
.
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7804
|
+
}
|
|
7805
|
+
function storedTextCodecClassOf(lowerer, expr) {
|
|
7806
|
+
const sym = lowerer.typeOf(expr).getSymbol();
|
|
7807
|
+
if (!sym || (sym.name !== "TextEncoder" && sym.name !== "TextDecoder"))
|
|
7808
|
+
return null;
|
|
7809
|
+
return lowerer.checker.declarationsOf(sym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && lowerer.isStdlibFile(d.getSourceFile())) ? sym.name : null;
|
|
7810
|
+
}
|
|
7811
|
+
function lowerStoredTextCodecCall(lowerer, call, access) {
|
|
7812
|
+
const cls = storedTextCodecClassOf(lowerer, access.expression);
|
|
7813
|
+
if (cls === null || !lowerer.isStdlibMember(access))
|
|
7814
|
+
return null;
|
|
7815
|
+
if (access.name.text !== (cls === "TextEncoder" ? "encode" : "decode"))
|
|
7816
|
+
return null;
|
|
7817
|
+
if (call.arguments.length > 1) {
|
|
7818
|
+
lowerer.noLowering(cls === "TextDecoder" ? "decode with a stream option" : "TextEncoder.encode with extra arguments", call);
|
|
7819
|
+
}
|
|
7820
|
+
const loc = locOf(call);
|
|
7821
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
7822
|
+
if (receiver.type.kind !== "record")
|
|
7823
|
+
lowerer.badType(access.expression, lowerer.typeOf(access.expression));
|
|
7824
|
+
const arg = call.arguments.length === 0
|
|
7825
|
+
? cls === "TextEncoder" ? strLit("", loc)
|
|
7826
|
+
: { kind: "bytesNew", source: null, type: BYTES_U8, loc }
|
|
7827
|
+
: cls === "TextEncoder" ? lowerer.lowerExprExpecting(call.arguments[0], STRING) : lowerer.lowerExpr(call.arguments[0]);
|
|
7828
|
+
if (cls === "TextDecoder" && !(arg.type.kind === "bytes" && arg.type.elem === "u8")) {
|
|
7829
|
+
lowerer.noLowering(`TextDecoder.decode of '${lowerer.fmt(arg.type)}' values`, call, "Uint8Array/Buffer input decodes (ArrayBuffer values have no representation)");
|
|
7830
|
+
}
|
|
7831
|
+
const key = `textCodec.${cls}.${receiver.type.shapeId}`;
|
|
7832
|
+
let name = lowerer.widthHelpers.get(key);
|
|
7833
|
+
if (!name) {
|
|
7834
|
+
name = `%${key}`;
|
|
7835
|
+
lowerer.widthHelpers.set(key, name);
|
|
7836
|
+
const recT = receiver.type;
|
|
7837
|
+
const input = varRef("input.0", arg.type, loc);
|
|
7838
|
+
const result = cls === "TextEncoder"
|
|
7839
|
+
? { kind: "libCall", fn: "buffer.fromStr", args: [input, { kind: "strLit", value: "utf8", type: STRING, loc }], type: BYTES_U8, loc }
|
|
7840
|
+
: {
|
|
7841
|
+
kind: "ternary",
|
|
7842
|
+
cond: { kind: "bin", op: "<", left: { kind: "recordGet", obj: varRef("codec.0", recT, loc), shapeId: recT.shapeId, field: "%TextDecoder", type: F64, loc }, right: { kind: "numLit", value: 0, type: F64, loc }, type: BOOL, loc },
|
|
7843
|
+
then: { kind: "libCall", fn: "text.decode", args: [input], type: STRING, loc },
|
|
7844
|
+
else_: { kind: "libCall", fn: "text.decodeLegacy", args: [input, { kind: "recordGet", obj: varRef("codec.0", recT, loc), shapeId: recT.shapeId, field: "%TextDecoder", type: F64, loc }], type: STRING, loc },
|
|
7845
|
+
type: STRING, loc,
|
|
7846
|
+
};
|
|
7847
|
+
lowerer.liftedFns.push({
|
|
7848
|
+
name,
|
|
7849
|
+
params: [{ localId: "codec.0", name: "codec", type: recT }, { localId: "input.0", name: "input", type: arg.type }],
|
|
7850
|
+
returnType: result.type,
|
|
7851
|
+
locals: [{ id: "codec.0", name: "codec", type: recT, mutable: false }, { id: "input.0", name: "input", type: arg.type, mutable: false }],
|
|
7852
|
+
body: [{ kind: "return", value: result, loc }], loc,
|
|
7853
|
+
});
|
|
7854
|
+
}
|
|
7855
|
+
return { kind: "call", callee: name, args: [receiver, arg], type: cls === "TextEncoder" ? BYTES_U8 : STRING, loc };
|
|
7562
7856
|
}
|
|
7563
7857
|
/** A direct construction of THE stdlib TextEncoder/TextDecoder, through
|
|
7564
7858
|
* type-only wrappers. Name alone is never enough: a user class with the
|
|
@@ -7579,118 +7873,8 @@ function directTextCodecCtorOf(lowerer, expr) {
|
|
|
7579
7873
|
return null;
|
|
7580
7874
|
return { cls: sym.name, ctor };
|
|
7581
7875
|
}
|
|
7582
|
-
/**
|
|
7583
|
-
*
|
|
7584
|
-
* resolve back to the initializer. TextDecoder's explicit label must be
|
|
7585
|
-
* an actual recognized literal here: accepting an arbitrary expression
|
|
7586
|
-
* merely typed as a label would move or repeat its effects when the
|
|
7587
|
-
* binding is erased. */
|
|
7588
|
-
function erasableTextCodecCtor(info) {
|
|
7589
|
-
const args = info.ctor.arguments ?? [];
|
|
7590
|
-
if (info.cls === "TextEncoder")
|
|
7591
|
-
return args.length === 0;
|
|
7592
|
-
if (args.length === 0)
|
|
7593
|
-
return true;
|
|
7594
|
-
if (args.length !== 1)
|
|
7595
|
-
return false;
|
|
7596
|
-
const label = stripTypeCasts(args[0]);
|
|
7597
|
-
return ts.isStringLiteralLike(label) && staticTextDecoderEncoding(label.text) !== null;
|
|
7598
|
-
}
|
|
7599
|
-
/** `const encoder = new TextEncoder()` / a statically-labelled TextDecoder twin:
|
|
7600
|
-
* compile-time alias plumbing with no runtime object. Calls through the
|
|
7601
|
-
* stable binding are recognized by textCodecReceiverOf below; any other
|
|
7602
|
-
* reached value use keeps the ordinary SC2020 representation fence. Both
|
|
7603
|
-
* declaration walks call this and independently gate on constness. */
|
|
7604
|
-
export function textCodecBindingClassOf(lowerer, nameNode, init) {
|
|
7605
|
-
if (!ts.isIdentifier(nameNode) || init === undefined)
|
|
7606
|
-
return null;
|
|
7607
|
-
const decl = nameNode.parent;
|
|
7608
|
-
if (!ts.isVariableDeclaration(decl) || !ts.isVariableDeclarationList(decl.parent) ||
|
|
7609
|
-
!ts.isVariableStatement(decl.parent.parent)) {
|
|
7610
|
-
return null;
|
|
7611
|
-
}
|
|
7612
|
-
const info = directTextCodecCtorOf(lowerer, init);
|
|
7613
|
-
return info !== null && erasableTextCodecCtor(info) ? info.cls : null;
|
|
7614
|
-
}
|
|
7615
|
-
export function textCodecBindingDecl(lowerer, nameNode, init) {
|
|
7616
|
-
return textCodecBindingClassOf(lowerer, nameNode, init) !== null;
|
|
7617
|
-
}
|
|
7618
|
-
/** The inline composed receiver, or a const identifier whose initializer
|
|
7619
|
-
* is an erasable codec construction in the same execution scope and
|
|
7620
|
-
* after that declaration. Following the declaration instead of
|
|
7621
|
-
* materializing the value is honest for the supported slice: receiver
|
|
7622
|
-
* reads are pure, construction has no effects, and every non-call use
|
|
7623
|
-
* fences because there is deliberately no general value lowering. */
|
|
7624
|
-
function textCodecReceiverOf(lowerer, expr) {
|
|
7625
|
-
const direct = directTextCodecCtorOf(lowerer, expr);
|
|
7626
|
-
if (direct !== null)
|
|
7627
|
-
return direct;
|
|
7628
|
-
const receiver = stripTypeCasts(expr);
|
|
7629
|
-
if (!ts.isIdentifier(receiver))
|
|
7630
|
-
return null;
|
|
7631
|
-
const sym = lowerer.resolveValueSymbol(receiver);
|
|
7632
|
-
const decl = sym ? lowerer.checker.valueDeclarationOf(sym) : undefined;
|
|
7633
|
-
if (!decl || !ts.isVariableDeclaration(decl) || decl.initializer === undefined ||
|
|
7634
|
-
!ts.isVariableDeclarationList(decl.parent) || (decl.parent.flags & ts.NodeFlags.Const) === 0 ||
|
|
7635
|
-
!textCodecBindingDecl(lowerer, decl.name, decl.initializer)) {
|
|
7636
|
-
return null;
|
|
7637
|
-
}
|
|
7638
|
-
// A closure can run before the const initializes (TDZ), and an
|
|
7639
|
-
// imported binding can be observed during a module cycle; both need
|
|
7640
|
-
// real runtime storage rather than this deliberately trivial rewrite.
|
|
7641
|
-
const executionScope = (node) => {
|
|
7642
|
-
let child = node;
|
|
7643
|
-
for (let cur = node.parent;; child = cur, cur = cur.parent) {
|
|
7644
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7645
|
-
return cur;
|
|
7646
|
-
// An instance field initializer runs when an object is constructed,
|
|
7647
|
-
// not when its enclosing class expression evaluates. Treat it like
|
|
7648
|
-
// a closure boundary: a later source position does not prove the
|
|
7649
|
-
// codec declaration ran (a switch can enter a following case and
|
|
7650
|
-
// instantiate the class while the binding is still in its TDZ).
|
|
7651
|
-
if (ts.isPropertyDeclaration(cur) && cur.initializer === child &&
|
|
7652
|
-
(ts.getCombinedModifierFlags(cur) & ts.ModifierFlags.Static) === 0) {
|
|
7653
|
-
return cur;
|
|
7654
|
-
}
|
|
7655
|
-
}
|
|
7656
|
-
};
|
|
7657
|
-
if (executionScope(receiver) !== executionScope(decl) || receiver.getStart() < decl.end)
|
|
7658
|
-
return null;
|
|
7659
|
-
// All switch clauses share one lexical environment, but dispatch can
|
|
7660
|
-
// enter a later clause without executing a const in an earlier one.
|
|
7661
|
-
// TypeScript normally diagnoses the direct read; an @ts-expect-error
|
|
7662
|
-
// can deliberately retain the runtime TDZ shape, so source order alone
|
|
7663
|
-
// is not a sufficient proof. A codec declared in a clause is erasable
|
|
7664
|
-
// only for uses inside that exact clause's subtree (nested switches are
|
|
7665
|
-
// fine; closures and instance initializers already fail executionScope).
|
|
7666
|
-
const switchClauseOf = (node) => {
|
|
7667
|
-
for (let cur = node.parent; cur !== undefined; cur = cur.parent) {
|
|
7668
|
-
if (ts.isCaseClause(cur) || ts.isDefaultClause(cur))
|
|
7669
|
-
return cur;
|
|
7670
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7671
|
-
return null;
|
|
7672
|
-
}
|
|
7673
|
-
return null;
|
|
7674
|
-
};
|
|
7675
|
-
const declClause = switchClauseOf(decl);
|
|
7676
|
-
if (declClause !== null) {
|
|
7677
|
-
let insideDeclClause = false;
|
|
7678
|
-
for (let cur = receiver; cur !== undefined; cur = cur.parent) {
|
|
7679
|
-
if (cur === declClause) {
|
|
7680
|
-
insideDeclClause = true;
|
|
7681
|
-
break;
|
|
7682
|
-
}
|
|
7683
|
-
}
|
|
7684
|
-
if (!insideDeclClause)
|
|
7685
|
-
return null;
|
|
7686
|
-
}
|
|
7687
|
-
return directTextCodecCtorOf(lowerer, decl.initializer);
|
|
7688
|
-
}
|
|
7689
|
-
/** The WHATWG encoder pair, COMPOSED or through an erasable const binding:
|
|
7690
|
-
* `new TextDecoder().decode(bytes)`, `new TextEncoder().encode(s)`, and
|
|
7691
|
-
* the idiomatic store-then-call equivalents. The codec object never
|
|
7692
|
-
* exists (the crypto/Date precedent); bare construction and value uses
|
|
7693
|
-
* are fenced with the composed hint. decode is the runtime's WHATWG
|
|
7876
|
+
/** Inline codec calls avoid allocating a receiver; stored receivers use
|
|
7877
|
+
* the owned record path above. decode is the runtime's WHATWG
|
|
7694
7878
|
* decode for every recognized static label (with BOM handling for the
|
|
7695
7879
|
* Unicode encodings); a zero-argument decode() is "" like the spec's.
|
|
7696
7880
|
* encode IS Buffer.from(s, "utf8") — ScrStr
|
|
@@ -7703,8 +7887,10 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7703
7887
|
const member = access.name.text;
|
|
7704
7888
|
if (member !== "decode" && member !== "encode")
|
|
7705
7889
|
return null;
|
|
7706
|
-
const info =
|
|
7707
|
-
if (info === null
|
|
7890
|
+
const info = directTextCodecCtorOf(lowerer, access.expression);
|
|
7891
|
+
if (info === null)
|
|
7892
|
+
return lowerStoredTextCodecCall(lowerer, call, access);
|
|
7893
|
+
if (!lowerer.isStdlibMember(access))
|
|
7708
7894
|
return null;
|
|
7709
7895
|
const { cls, ctor: recv } = info;
|
|
7710
7896
|
if (!(cls === "TextDecoder" && member === "decode") && !(cls === "TextEncoder" && member === "encode")) {
|
|
@@ -7715,7 +7901,7 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7715
7901
|
if (cls === "TextDecoder") {
|
|
7716
7902
|
// The label must be statically known. A literal-typed effectful inline
|
|
7717
7903
|
// expression is accepted, but its evaluation is sequenced before the
|
|
7718
|
-
// decode below
|
|
7904
|
+
// decode below, just as stored decoders evaluate it at construction.
|
|
7719
7905
|
const labelT = ctorArgs.length >= 1 ? lowerer.typeOf(ctorArgs[0]) : null;
|
|
7720
7906
|
const encoding = ctorArgs.length === 0
|
|
7721
7907
|
? { kind: "utf8" }
|
|
@@ -7763,23 +7949,23 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7763
7949
|
if (ctorArgs.length > 0) {
|
|
7764
7950
|
lowerer.noLowering("new TextEncoder with arguments", recv);
|
|
7765
7951
|
}
|
|
7766
|
-
if (call.arguments.length
|
|
7767
|
-
lowerer.noLowering(`TextEncoder.encode with ${call.arguments.length} arguments`, call
|
|
7952
|
+
if (call.arguments.length > 1) {
|
|
7953
|
+
lowerer.noLowering(`TextEncoder.encode with ${call.arguments.length} arguments`, call);
|
|
7768
7954
|
}
|
|
7769
|
-
const s = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
7955
|
+
const s = call.arguments.length === 0 ? strLit("", loc) : lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
7770
7956
|
const enc = { kind: "strLit", value: "utf8", type: STRING, loc };
|
|
7771
7957
|
return { kind: "libCall", fn: "buffer.fromStr", args: [s, enc], type: BYTES_U8, loc };
|
|
7772
7958
|
}
|
|
7773
|
-
/** `String.fromCharCode(...codes)` on THE String global: every argument
|
|
7959
|
+
/** `String.fromCharCode/fromCodePoint(...codes)` on THE String global: every argument
|
|
7774
7960
|
* lowers as a number and packs into ONE f64[] array-literal argument
|
|
7775
7961
|
* (the path.join convention) — or ONE whole-array spread forwards the
|
|
7776
|
-
* array itself.
|
|
7777
|
-
*
|
|
7962
|
+
* array itself. String.raw has its own template path below.
|
|
7963
|
+
* Null for non-String receivers. */
|
|
7778
7964
|
export function lowerStringStaticCall(lowerer, call, access) {
|
|
7779
7965
|
if (call.questionDotToken)
|
|
7780
7966
|
return null;
|
|
7781
7967
|
const member = lowerer.stdlibGlobalMember(access, "String");
|
|
7782
|
-
if (member !== "fromCharCode" && member !== "raw")
|
|
7968
|
+
if (member !== "fromCharCode" && member !== "fromCodePoint" && member !== "raw")
|
|
7783
7969
|
return null;
|
|
7784
7970
|
const loc = locOf(call);
|
|
7785
7971
|
// String.raw(template, ...substitutions): the template's `raw` member
|
|
@@ -7823,7 +8009,7 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7823
8009
|
const spread = call.arguments.find(ts.isSpreadElement);
|
|
7824
8010
|
if (spread) {
|
|
7825
8011
|
if (call.arguments.length !== 1) {
|
|
7826
|
-
lowerer.noLowering(
|
|
8012
|
+
lowerer.noLowering(`String.${member} with a mixed spread call`, call, `spread a whole array (String.${member}(...codes)) or pass plain arguments`);
|
|
7827
8013
|
}
|
|
7828
8014
|
// A typed-array/Buffer spread (String.fromCharCode(...data.slice(4, 8))
|
|
7829
8015
|
// — the magic-number ASCII probe) passes the bytes value through; the
|
|
@@ -7833,14 +8019,14 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7833
8019
|
const packed = lowerer.lowerExpr(spread.expression);
|
|
7834
8020
|
if (packed.type.kind !== "bytes")
|
|
7835
8021
|
lowerer.badType(spread.expression, lowerer.typeOf(spread.expression));
|
|
7836
|
-
return { kind: "libCall", fn:
|
|
8022
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7837
8023
|
}
|
|
7838
8024
|
const packed = lowerer.lowerExprExpecting(spread.expression, arrayOf(F64));
|
|
7839
|
-
return { kind: "libCall", fn:
|
|
8025
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7840
8026
|
}
|
|
7841
8027
|
const elems = call.arguments.map((a) => lowerer.lowerExprExpecting(a, F64));
|
|
7842
8028
|
const packed = { kind: "arrayLit", elems, type: arrayOf(F64), loc };
|
|
7843
|
-
return { kind: "libCall", fn:
|
|
8029
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7844
8030
|
}
|
|
7845
8031
|
/** `s.lastIndexOf(searchValue?, position?)` on string receivers, using UTF-16
|
|
7846
8032
|
* indices. An omitted search value searches for "undefined". Omitted or undefined positions clamp to the string's end;
|
|
@@ -8316,14 +8502,24 @@ export function isConsoleLog(lowerer, call) {
|
|
|
8316
8502
|
* like every stdlib global. Null for anything else (console.table, a
|
|
8317
8503
|
* user's own console binding, ...). */
|
|
8318
8504
|
export function consoleCallMember(lowerer, call) {
|
|
8505
|
+
if (call.questionDotToken)
|
|
8506
|
+
return null;
|
|
8507
|
+
if (ts.isIdentifier(call.expression)) {
|
|
8508
|
+
const imported = builtinImportOf(lowerer, call.expression);
|
|
8509
|
+
return imported?.module === "console" && isConsoleOutputMember(imported.member) ? imported.member : null;
|
|
8510
|
+
}
|
|
8319
8511
|
if (!ts.isPropertyAccessExpression(call.expression))
|
|
8320
8512
|
return null;
|
|
8321
8513
|
const access = call.expression;
|
|
8322
8514
|
if (access.questionDotToken || call.questionDotToken)
|
|
8323
8515
|
return null;
|
|
8324
8516
|
const name = access.name.text;
|
|
8325
|
-
if (name
|
|
8517
|
+
if (!isConsoleOutputMember(name))
|
|
8326
8518
|
return null;
|
|
8327
|
-
return lowerer.isStdlibGlobal(access.expression, "console")
|
|
8519
|
+
return lowerer.isStdlibGlobal(access.expression, "console") ||
|
|
8520
|
+
lowerer.builtinNamespaceModuleOf(access.expression) === "console" ? name : null;
|
|
8521
|
+
}
|
|
8522
|
+
function isConsoleOutputMember(name) {
|
|
8523
|
+
return name === "log" || name === "info" || name === "debug" || name === "error" || name === "warn";
|
|
8328
8524
|
}
|
|
8329
8525
|
//# sourceMappingURL=lower-builtins.js.map
|