@scriptc/compiler 0.1.6 → 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 -25
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +28 -5
- 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/debug-symbols.d.ts +8 -0
- package/dist/backend/debug-symbols.js +52 -0
- package/dist/backend/debug-symbols.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 +2 -1
- package/dist/backend/link-plan.js +18 -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 +9 -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 +4 -0
- package/dist/backend/llvm/blocks.js +25 -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.d.ts +32 -0
- package/dist/backend/llvm/debug-info.js +198 -0
- package/dist/backend/llvm/debug-info.js.map +1 -0
- 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 +498 -175
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +598 -1
- package/dist/backend/llvm/emitter.js +739 -409
- 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 +72 -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 +59 -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 +125 -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/split.js +4 -1
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +26 -1
- package/dist/backend/llvm/split.test.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 +89 -219
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +15 -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/source-locations.d.ts +12 -0
- package/dist/backend/source-locations.js +32 -0
- package/dist/backend/source-locations.js.map +1 -0
- package/dist/backend/source-locations.test.d.ts +1 -0
- package/dist/backend/source-locations.test.js +16 -0
- package/dist/backend/source-locations.test.js.map +1 -0
- 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.d.ts +4 -0
- package/dist/diagnostics/diagnostic.js +15 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +33 -10
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +38 -16
- 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 +4 -0
- package/dist/frontend/arguments-usage.js +40 -0
- package/dist/frontend/arguments-usage.js.map +1 -0
- package/dist/frontend/binding-source.d.ts +4 -0
- package/dist/frontend/binding-source.js +18 -0
- package/dist/frontend/binding-source.js.map +1 -0
- 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 +485 -185
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +5 -6
- package/dist/frontend/lowering/expressions/optional-chains.js +27 -14
- 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 +553 -346
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +22 -26
- package/dist/frontend/lowering/lower-calls.js +1373 -380
- 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 +1785 -790
- 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 +252 -38
- 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 +731 -532
- 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 +1033 -663
- 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 +9 -4
- package/dist/frontend/lowering/surfaces.js +98 -35
- 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 +43 -19
- package/dist/frontend/program.js +556 -197
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.d.ts +1 -0
- package/dist/frontend/program.test.js +202 -0
- package/dist/frontend/program.test.js.map +1 -0
- 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 +29 -19
- package/dist/frontend/type-mapper.js +713 -306
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.d.ts +1 -0
- package/dist/frontend/type-mapper.test.js +207 -0
- package/dist/frontend/type-mapper.test.js.map +1 -0
- 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 -197
- package/dist/index.js +369 -1567
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +25 -6
- 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 +309 -164
- package/dist/ir/ir.js +588 -879
- 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 +1956 -1496
- 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/compiler-self-identity.d.ts +1 -1
- package/dist/library/compiler-self-identity.js +31 -15
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.d.ts +1 -0
- package/dist/library/compiler-self-identity.test.js +93 -0
- package/dist/library/compiler-self-identity.test.js.map +1 -0
- 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 +171 -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 -531
- package/dist/backend/c/c-emitter.js +0 -1917
- 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 -8803
- 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 -1084
- 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 -1773
- 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,19 +1,20 @@
|
|
|
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
|
|
4
5
|
* methods), JSON.parse/stringify, process properties/methods and
|
|
5
6
|
* process.env access, and console.log detection. */
|
|
6
7
|
import { builtinModules } from "node:module";
|
|
7
|
-
import { dirname, resolve } from "node:path";
|
|
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";
|
|
14
15
|
import { trackedReadFile } from "../input-tracker.js";
|
|
15
16
|
import { requireResolvePathsRuntime, resolveImportMetaRuntime, resolveRequireRuntime } from "../runtime-resolve.js";
|
|
16
|
-
import { invalidJsonModuleDiag, requiresDynamicImportDiag } from "../../diagnostics/diagnostic.js";
|
|
17
|
+
import { invalidJsonModuleDiag, nativeAddonDiag, requiresDynamicImportDiag } from "../../diagnostics/diagnostic.js";
|
|
17
18
|
import { builtinModuleFnOf, FS_READDIR_DOCUMENTED_OPTIONS, FS_WATCH_DOCUMENTED_OPTIONS, FS_WRITE_FILE_DOCUMENTED_OPTIONS, QS_PARSE_DOCUMENTED_OPTIONS, QS_STRINGIFY_DOCUMENTED_OPTIONS, READLINE_DOCUMENTED_OPTIONS, builtinConstLit, fenceOrDropOptionKey, isChildSurfaceMember, NODE_BUILTIN_MODULES_V24, } from "./surfaces.js";
|
|
18
19
|
import { lowerAbsenceProbe } from "./lower-exprs.js";
|
|
19
20
|
import { conditionalSpreadOf, lowerDynObjectLiteral } from "./expressions/object-literals.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
|
}
|
|
@@ -577,11 +605,22 @@ export function lowerCreateRequireCall(lowerer, call, loc) {
|
|
|
577
605
|
if (spec.startsWith("#")) {
|
|
578
606
|
lowerer.noLowering(`createRequire's require of the '${spec}' project import`, call, "imports-field specifiers have no require lowering yet — import the target statically");
|
|
579
607
|
}
|
|
580
|
-
if (isRelativeSpecifier(spec) || spec
|
|
608
|
+
if (isRelativeSpecifier(spec) || isAbsolute(spec)) {
|
|
581
609
|
if (!spec.endsWith(".json")) {
|
|
610
|
+
// Only refine the existing refusal path: Node resolution detects
|
|
611
|
+
// extensionless addons and directory entries without executing
|
|
612
|
+
// them, and avoids mistaking a .node-named JS directory for one.
|
|
613
|
+
// This probe marks frontend inputs unstable, but every branch
|
|
614
|
+
// here refuses compilation, so successful-build caches keep their
|
|
615
|
+
// existing dependency proofs.
|
|
616
|
+
const resolved = resolveRequireRuntime(cr.baseFile.fileName, spec, lowerer.targetPlatform, undefined, lowerer.frontendServices);
|
|
617
|
+
if (resolved.ok && resolved.value.endsWith(".node")) {
|
|
618
|
+
lowerer.pushDiag(nativeAddonDiag(spec, loc));
|
|
619
|
+
throw new PoisonError();
|
|
620
|
+
}
|
|
582
621
|
lowerer.noLowering(`createRequire's require of '${spec}'`, call, "relative program modules lower when they resolve into the compiled graph; relative .json documents bake at build time");
|
|
583
622
|
}
|
|
584
|
-
const abs = spec
|
|
623
|
+
const abs = isAbsolute(spec)
|
|
585
624
|
? spec
|
|
586
625
|
: resolve(dirname(cr.baseFile.fileName), spec);
|
|
587
626
|
const text = trackedReadFile(abs);
|
|
@@ -673,7 +712,7 @@ export function lowerImportMetaResolveCall(lowerer, call) {
|
|
|
673
712
|
if (specifier === null) {
|
|
674
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");
|
|
675
714
|
}
|
|
676
|
-
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform);
|
|
715
|
+
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
677
716
|
if (result === null) {
|
|
678
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");
|
|
679
718
|
}
|
|
@@ -686,7 +725,7 @@ function requireResolverBaseFile(lowerer, receiver) {
|
|
|
686
725
|
const created = createRequireCalleeFileOf(lowerer, receiver);
|
|
687
726
|
if (created !== null)
|
|
688
727
|
return created;
|
|
689
|
-
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile())
|
|
728
|
+
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile(), lowerer.program)
|
|
690
729
|
? receiver.getSourceFile()
|
|
691
730
|
: null;
|
|
692
731
|
}
|
|
@@ -750,7 +789,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
750
789
|
}
|
|
751
790
|
const loc = locOf(call);
|
|
752
791
|
if (pathsCall) {
|
|
753
|
-
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform);
|
|
792
|
+
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
754
793
|
if (result !== null && !Array.isArray(result)) {
|
|
755
794
|
return runtimeResolveThrow(result, lowerer.irTypeOf(call), loc);
|
|
756
795
|
}
|
|
@@ -768,7 +807,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
768
807
|
if (paths === null) {
|
|
769
808
|
lowerer.noLowering("require.resolve with runtime-computed options", call.arguments[1], "omit options or pass { paths: [\"<static directory>\", ...] }");
|
|
770
809
|
}
|
|
771
|
-
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths);
|
|
810
|
+
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths, lowerer.frontendServices);
|
|
772
811
|
return result.ok
|
|
773
812
|
? { kind: "strLit", value: result.value, type: STRING, loc }
|
|
774
813
|
: runtimeResolveThrow(result.error, STRING, loc);
|
|
@@ -850,6 +889,13 @@ function isPerfHooksPerformanceExpr(lowerer, node) {
|
|
|
850
889
|
}
|
|
851
890
|
return false;
|
|
852
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
|
+
}
|
|
853
899
|
/** The node:perf_hooks spoke: `performance.now()` reads the runtime's
|
|
854
900
|
* monotonic clock anchored at process start — Node's timeOrigin for a
|
|
855
901
|
* compiled program, fractional milliseconds — and
|
|
@@ -1289,6 +1335,31 @@ function lowerZlibModuleCall(lowerer, expr, bi, loc) {
|
|
|
1289
1335
|
}
|
|
1290
1336
|
const syncFn = ZLIB_SYNC_FNS[bi.member];
|
|
1291
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
|
+
}
|
|
1292
1363
|
if (expr.arguments.length !== 1) {
|
|
1293
1364
|
const site = expr.arguments[1] ?? expr;
|
|
1294
1365
|
lowerer.noLowering(`${bi.member} with explicit options`, site, `${bi.member}(data) with Node's default options is supported`);
|
|
@@ -1968,15 +2039,21 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
1968
2039
|
: { kind: "numLit", value: 0, type: F64, loc };
|
|
1969
2040
|
return { kind: "libCall", fn: "fs.accessSync", args: [path, mode], type: VOID, loc };
|
|
1970
2041
|
}
|
|
1971
|
-
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) {
|
|
1972
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
|
+
}
|
|
1973
2050
|
if (dataIr?.kind === "bytes") {
|
|
1974
2051
|
if (dataIr.elem !== "u8") {
|
|
1975
|
-
lowerer.noLowering(
|
|
2052
|
+
lowerer.noLowering(`${bi.member} of '${lowerer.fmt(dataIr)}' data`, expr.arguments[1], "byte writes take Uint8Array/Buffer data");
|
|
1976
2053
|
}
|
|
1977
2054
|
const path = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
1978
2055
|
const data = lowerer.lowerExprExpecting(expr.arguments[1], BYTES_U8);
|
|
1979
|
-
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 };
|
|
1980
2057
|
}
|
|
1981
2058
|
}
|
|
1982
2059
|
// writeFileSync(p, data, options) / fs.promises.writeFile(p, data,
|
|
@@ -2134,6 +2211,27 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2134
2211
|
}
|
|
2135
2212
|
const required = fn.params.length - (fn.defaults?.length ?? 0);
|
|
2136
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
|
+
}
|
|
2137
2235
|
if (hasSpread && bi.module === "url" && bi.member === "fileURLToPath") {
|
|
2138
2236
|
lowerer.noLowering("fileURLToPath with spread arguments", expr, "call fileURLToPath(value) directly so the URL-or-string overload remains statically visible");
|
|
2139
2237
|
}
|
|
@@ -2153,6 +2251,8 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2153
2251
|
// undefined, ...) must narrow first, like everywhere else.
|
|
2154
2252
|
const argNode = expr.arguments[0];
|
|
2155
2253
|
const arg = lowerer.lowerExpr(argNode);
|
|
2254
|
+
if (arg.type.kind === "dyn")
|
|
2255
|
+
return { kind: "libCall", fn: "url.fileURLToPathChecked", args: [arg], type: STRING, loc };
|
|
2156
2256
|
if (arg.type.kind === "url") {
|
|
2157
2257
|
return { kind: "libCall", fn: "url.fileURLToPathUrl", args: [arg], type: STRING, loc };
|
|
2158
2258
|
}
|
|
@@ -3802,20 +3902,20 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3802
3902
|
const loc = locOf(call);
|
|
3803
3903
|
if (name === "getStore" && call.arguments.length === 0) {
|
|
3804
3904
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3805
|
-
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 });
|
|
3806
3906
|
}
|
|
3807
3907
|
if (name === "run" && call.arguments.length >= 2) {
|
|
3808
3908
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3809
3909
|
const value = dcMessageArg(lowerer, call.arguments[0]);
|
|
3810
3910
|
const fn = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
3811
3911
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(2), loc);
|
|
3812
|
-
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 });
|
|
3813
3913
|
}
|
|
3814
3914
|
if (name === "exit" && call.arguments.length >= 1) {
|
|
3815
3915
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3816
3916
|
const fn = dcSubscriberArg(lowerer, call.arguments[0]);
|
|
3817
3917
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(1), loc);
|
|
3818
|
-
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 });
|
|
3819
3919
|
}
|
|
3820
3920
|
if (name === "enterWith" && call.arguments.length === 1) {
|
|
3821
3921
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
@@ -3828,6 +3928,18 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3828
3928
|
}
|
|
3829
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));
|
|
3830
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
|
+
}
|
|
3831
3943
|
/** Property reads on Channel receivers: `.name` (the registration
|
|
3832
3944
|
* string) and `.hasSubscribers` (the publish guard). Null for
|
|
3833
3945
|
* non-Channel receivers and other members (the method fence owns them). */
|
|
@@ -4173,23 +4285,11 @@ export function strdecHelper(lowerer, op, shapeId, loc) {
|
|
|
4173
4285
|
lowerer.liftedFns.push({ name, params, returnType: STRING, locals, body, loc });
|
|
4174
4286
|
return name;
|
|
4175
4287
|
}
|
|
4176
|
-
/**
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
* - stringify → the type-DIRECTED `jsonStringify` node: the lib
|
|
4182
|
-
* signature honestly says `any`, but lowering requires the argument's
|
|
4183
|
-
* STATIC IR type to be JSON-safe — the backend emits a per-type
|
|
4184
|
-
* serializer, never a dynamic walk, so dyn (and closures/class
|
|
4185
|
-
* instances) are rejected here with a specific message. The
|
|
4186
|
-
* `stringify(v, null, space)` pretty-print form compiles when the
|
|
4187
|
-
* replacer is the literal null (or undefined) and the space is a
|
|
4188
|
-
* LITERAL — Node's rules apply at compile time (numbers clamp to 0–10
|
|
4189
|
-
* spaces, strings truncate to 10 code units) and the resolved indent
|
|
4190
|
-
* rides the node to the backend's re-indenter. Function replacers and
|
|
4191
|
-
* non-literal spaces stay fenced.
|
|
4192
|
-
* 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. */
|
|
4193
4293
|
export function lowerJsonMethodCall(lowerer, call, access) {
|
|
4194
4294
|
if (call.questionDotToken)
|
|
4195
4295
|
return null;
|
|
@@ -4197,12 +4297,19 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4197
4297
|
if (member === null)
|
|
4198
4298
|
return null;
|
|
4199
4299
|
const loc = locOf(call);
|
|
4200
|
-
if (member === "parse" && call.arguments.length
|
|
4201
|
-
|
|
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");
|
|
4202
4304
|
}
|
|
4203
4305
|
if (member === "parse") {
|
|
4204
4306
|
const text = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
4205
|
-
|
|
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 };
|
|
4206
4313
|
}
|
|
4207
4314
|
if (member === "stringify") {
|
|
4208
4315
|
const indent = stringifySpaceIndent(lowerer, call);
|
|
@@ -4210,10 +4317,70 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4210
4317
|
return lowerer.wrappedUndefined(lowerer.withUndefinedArm(STRING), loc);
|
|
4211
4318
|
}
|
|
4212
4319
|
const argNode = call.arguments[0];
|
|
4213
|
-
|
|
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
|
+
}
|
|
4214
4366
|
const optionalString = lowerOptionalStringifyRoot(lowerer, value, indent, loc);
|
|
4215
4367
|
if (optionalString)
|
|
4216
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
|
+
}
|
|
4217
4384
|
// An ISLAND value (`JSON.stringify(err)` on a package handle — the
|
|
4218
4385
|
// island error-inspection idiom): the ENGINE's own JSON.stringify
|
|
4219
4386
|
// runs, so key order, nesting, toJSON, and getters match Node by
|
|
@@ -4233,17 +4400,7 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4233
4400
|
const raw = { kind: "jsOp", op: "callMethod", name: "stringify", args, type: JSVAL, loc };
|
|
4234
4401
|
return { kind: "jsOp", op: "toStr", args: [raw], type: STRING, loc };
|
|
4235
4402
|
}
|
|
4236
|
-
|
|
4237
|
-
// `object` slots, the JSON.parse round-trip) serializes with the
|
|
4238
|
-
// runtime's dyn walker instead of a type-directed serializer — the
|
|
4239
|
-
// dyn is JSON-representable by construction (non-JSON values fenced
|
|
4240
|
-
// at their conversion INTO the slot). Two edges, both documented:
|
|
4241
|
-
// a root the stringify drops (runtime undefined) produces the TEXT
|
|
4242
|
-
// "undefined" where Node produces the undefined VALUE (tsc's own lib
|
|
4243
|
-
// types the return `string`, so no static consumer can tell), and a
|
|
4244
|
-
// runtime handle inside the tree throws (Node would walk its own
|
|
4245
|
-
// enumerable props, which the handle does not model).
|
|
4246
|
-
if (!lowerer.jsonStringifySafe(value.type) && value.type.kind !== "dyn") {
|
|
4403
|
+
if (!lowerer.jsonStringifySafe(value.type)) {
|
|
4247
4404
|
// Bare undefined-armed unions get their own wording: Node's
|
|
4248
4405
|
// stringify of bare undefined is not a string at all — per-type
|
|
4249
4406
|
// serialization cannot match that exactly, so the fence is
|
|
@@ -4260,16 +4417,47 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4260
4417
|
`(only number, string, boolean, records, arrays, unions of those, and 'unknown' stringify)`);
|
|
4261
4418
|
}
|
|
4262
4419
|
const node = { kind: "jsonStringify", value, type: STRING, loc };
|
|
4263
|
-
if (indent !== "")
|
|
4264
|
-
// The compile-time-resolved indent rides as an extra property (the
|
|
4265
|
-
// node shape in ir/ir.ts is unchanged); the backend re-indents
|
|
4266
|
-
// the compact serializer output with Node's gap algorithm.
|
|
4420
|
+
if (indent !== "")
|
|
4267
4421
|
node.indent = indent;
|
|
4268
|
-
}
|
|
4269
4422
|
return node;
|
|
4270
4423
|
}
|
|
4271
4424
|
return null; // unknown members are tsc errors before lowering
|
|
4272
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
|
+
}
|
|
4273
4461
|
function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
4274
4462
|
const tags = optionalStringTags(lowerer, value.type);
|
|
4275
4463
|
if (!tags || value.type.kind !== "union")
|
|
@@ -4312,22 +4500,37 @@ function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
|
4312
4500
|
}
|
|
4313
4501
|
return { kind: "call", callee: helper, args: [value], type: resultT, loc };
|
|
4314
4502
|
}
|
|
4315
|
-
/**
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
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. */
|
|
4322
4528
|
function stringifySpaceIndent(lowerer, call) {
|
|
4323
4529
|
const fence = () => lowerer.noLowering("JSON.stringify with replacer/space parameters", call, "the serializer is type-directed — shape the value before stringifying");
|
|
4324
4530
|
if (call.arguments.length <= 1)
|
|
4325
4531
|
return "";
|
|
4326
4532
|
const unwrap = (e) => ts.isParenthesizedExpression(e) ? unwrap(e.expression) : e;
|
|
4327
|
-
const isUndefined = (e) =>
|
|
4328
|
-
const replacer = unwrap(call.arguments[1]);
|
|
4329
|
-
if (replacer.kind !== ts.SyntaxKind.NullKeyword && !isUndefined(replacer))
|
|
4330
|
-
fence();
|
|
4533
|
+
const isUndefined = (e) => jsonNullishArgument(lowerer, e);
|
|
4331
4534
|
if (call.arguments.length === 2)
|
|
4332
4535
|
return "";
|
|
4333
4536
|
const space = unwrap(call.arguments[2]);
|
|
@@ -4370,6 +4573,8 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4370
4573
|
if (ts.isVariableDeclaration(varDecl) && varDecl.initializer !== undefined) {
|
|
4371
4574
|
const spec = requireSpecOf(varDecl.initializer);
|
|
4372
4575
|
if (spec !== null) {
|
|
4576
|
+
if (isNativeFfiRequire(lowerer, varDecl.initializer))
|
|
4577
|
+
return null;
|
|
4373
4578
|
const isBuiltin = spec.startsWith("node:") || builtinModules.includes(spec);
|
|
4374
4579
|
return isBuiltin && canonicalBuiltinModule(spec) === null ? spec : null;
|
|
4375
4580
|
}
|
|
@@ -4377,9 +4582,9 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4377
4582
|
}
|
|
4378
4583
|
let importDecl;
|
|
4379
4584
|
if (ts.isImportSpecifier(decl))
|
|
4380
|
-
importDecl = decl.parent
|
|
4585
|
+
importDecl = decl.parent?.parent?.parent;
|
|
4381
4586
|
else if (ts.isNamespaceImport(decl))
|
|
4382
|
-
importDecl = decl.parent
|
|
4587
|
+
importDecl = decl.parent?.parent;
|
|
4383
4588
|
else if (ts.isImportClause(decl))
|
|
4384
4589
|
importDecl = decl.parent;
|
|
4385
4590
|
else
|
|
@@ -5313,7 +5518,11 @@ export function lowerCryptoHashMethodCall(lowerer, call, access) {
|
|
|
5313
5518
|
lowerer.noLowering(`${receiverType.kind === "cryptoHash" ? "Hash" : "Hmac"}.update with ${call.arguments.length} arguments`, call, "update(stringOrBuffer[, inputEncoding]) is supported");
|
|
5314
5519
|
}
|
|
5315
5520
|
const dataNode = call.arguments[0];
|
|
5316
|
-
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);
|
|
5317
5526
|
const prefix = receiverType.kind === "cryptoHash" ? "crypto.hashUpdate" : "crypto.hmacUpdate";
|
|
5318
5527
|
if (data.type.kind === "bytes" && data.type.elem === "u8") {
|
|
5319
5528
|
if (call.arguments.length !== 1) {
|
|
@@ -5851,6 +6060,13 @@ export function lowerProcStreamMethodCall(lowerer, call, access) {
|
|
|
5851
6060
|
return null;
|
|
5852
6061
|
const name = access.name.text;
|
|
5853
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
|
+
}
|
|
5854
6070
|
if (name === "write" && call.arguments.length === 1) {
|
|
5855
6071
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5856
6072
|
const data = lowerer.lowerExpr(call.arguments[0]);
|
|
@@ -5955,7 +6171,8 @@ export function lowerWatcherMethodCall(lowerer, call, access) {
|
|
|
5955
6171
|
}
|
|
5956
6172
|
lowerer.noLowering(`FSWatcher.${name}`, call, "close() is the supported FSWatcher member", lowerer.checker.getSymbolAtLocation(access.name));
|
|
5957
6173
|
}
|
|
5958
|
-
/** `.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
|
|
5959
6176
|
* member (the fallback declares the same shape): the runtime Error's
|
|
5960
6177
|
* code slot as `string | undefined` — the errno name where a throw site
|
|
5961
6178
|
* stamped one (fs, exec spawn/timeout, process.kill, the spawn 'error'
|
|
@@ -5989,10 +6206,10 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
5989
6206
|
return { kind: "libCall", fn: "error.domCause", args: [receiver], type: DYN, loc: locOf(expr) };
|
|
5990
6207
|
}
|
|
5991
6208
|
}
|
|
5992
|
-
if (expr.name.text !== "code")
|
|
6209
|
+
if (expr.name.text !== "code" && expr.name.text !== "cause" && expr.name.text !== "stack")
|
|
5993
6210
|
return null;
|
|
5994
6211
|
// Error-rooted classes only — builtin or user subclass (both embed the
|
|
5995
|
-
// code
|
|
6212
|
+
// code and cause slots in their layout prefix).
|
|
5996
6213
|
let info = lowerer.classes.get(recvT.className) ?? null;
|
|
5997
6214
|
while (info && info.base)
|
|
5998
6215
|
info = info.base;
|
|
@@ -6003,19 +6220,31 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
6003
6220
|
const receiver = lowerer.lowerExpr(expr.expression);
|
|
6004
6221
|
return {
|
|
6005
6222
|
kind: "libCall",
|
|
6006
|
-
fn: "error.code",
|
|
6223
|
+
fn: expr.name.text === "stack" ? "error.stack" : expr.name.text === "cause" ? "error.cause" : "error.code",
|
|
6007
6224
|
args: [receiver],
|
|
6008
|
-
type: lowerer.envValueType(),
|
|
6225
|
+
type: expr.name.text === "stack" ? STRING : expr.name.text === "cause" ? DYN : lowerer.envValueType(),
|
|
6009
6226
|
loc: locOf(expr),
|
|
6010
6227
|
};
|
|
6011
6228
|
}
|
|
6012
|
-
/**
|
|
6013
|
-
*
|
|
6014
|
-
* 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. */
|
|
6015
6231
|
export function lowerJsonProperty(lowerer, expr) {
|
|
6016
6232
|
const member = lowerer.stdlibGlobalMember(expr, "JSON");
|
|
6017
6233
|
if (member === null)
|
|
6018
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
|
+
}
|
|
6019
6248
|
lowerer.unsupported("SC1090", expr, `JSON methods as values (call '${member}' directly)`);
|
|
6020
6249
|
}
|
|
6021
6250
|
/** `constants.X_OK` where `constants` is a named fs import: the access-
|
|
@@ -6055,6 +6284,16 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6055
6284
|
if (expr.questionDotToken)
|
|
6056
6285
|
return null;
|
|
6057
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
|
+
}
|
|
6058
6297
|
if (member !== "isTTY" && member !== "columns" && member !== "rows")
|
|
6059
6298
|
return null;
|
|
6060
6299
|
let recv = expr.expression;
|
|
@@ -6114,12 +6353,14 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6114
6353
|
* rejected specifically. Null for non-process receivers (the chain keeps
|
|
6115
6354
|
* trying other property lowerings). */
|
|
6116
6355
|
export function lowerProcessProperty(lowerer, expr) {
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
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.
|
|
6123
6364
|
if ((expr.name.text === "node" || expr.name.text === "openssl") &&
|
|
6124
6365
|
!expr.questionDotToken &&
|
|
6125
6366
|
ts.isPropertyAccessExpression(expr.expression) &&
|
|
@@ -6129,34 +6370,30 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6129
6370
|
// "is crypto available" probe, and the crypto module exists here
|
|
6130
6371
|
// (unsupported members fence per site). SEMANTICS.md documents that
|
|
6131
6372
|
// the string names the compat target, not a linked library.
|
|
6132
|
-
const
|
|
6133
|
-
return {
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
//
|
|
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.
|
|
6139
6381
|
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
6140
|
-
lowerer.stdlibGlobalMember(expr.expression, "process") === "versions"
|
|
6141
|
-
|
|
6142
|
-
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
|
+
};
|
|
6143
6388
|
}
|
|
6144
6389
|
// The capability-probe members that honestly DON'T EXIST in a
|
|
6145
6390
|
// compiled binary — each reads undefined (their declared types carry
|
|
6146
6391
|
// the undefined arm), so feature probes take their documented
|
|
6147
|
-
// fallbacks: no
|
|
6148
|
-
// .sqlite), no gyp build config (process.config.variables.* — no ICU,
|
|
6392
|
+
// fallbacks: no gyp build config (process.config.variables.* — no ICU,
|
|
6149
6393
|
// no QUIC — and process.config.target_defaults), no feature flags
|
|
6150
6394
|
// (process.features.* — no inspector, not a debug build).
|
|
6151
6395
|
if (!expr.questionDotToken && ts.isPropertyAccessExpression(expr.expression)) {
|
|
6152
6396
|
const container = lowerer.stdlibGlobalMember(expr.expression, "process");
|
|
6153
|
-
if (container === "versions" && (expr.name.text === "sqlite" || expr.name.text === "bun" || expr.name.text === "deno")) {
|
|
6154
|
-
// versions.bun / versions.deno are the OTHER-runtime probes (a
|
|
6155
|
-
// formatter's config loader picks its package.json reader by
|
|
6156
|
-
// them): a compiled binary is neither, so both read undefined —
|
|
6157
|
-
// exactly Node's own answer.
|
|
6158
|
-
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6159
|
-
}
|
|
6160
6397
|
if (container === "features") {
|
|
6161
6398
|
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6162
6399
|
}
|
|
@@ -6179,6 +6416,18 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6179
6416
|
if (member === null)
|
|
6180
6417
|
return null;
|
|
6181
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
|
+
}
|
|
6182
6431
|
if (member === "argv") {
|
|
6183
6432
|
return { kind: "libCall", fn: "process.argv", args: [], type: arrayOf(STRING), loc };
|
|
6184
6433
|
}
|
|
@@ -6231,6 +6480,9 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6231
6480
|
// procStream scalar, minted as the stream's fd. Member reads
|
|
6232
6481
|
// (`process.stdout.isTTY`, `.write(...)`) never reach here — their
|
|
6233
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
|
+
}
|
|
6234
6486
|
if (member === "stdout" || member === "stderr") {
|
|
6235
6487
|
return { kind: "numLit", value: member === "stdout" ? 1 : 2, type: PROCSTREAM_T, loc };
|
|
6236
6488
|
}
|
|
@@ -6309,9 +6561,12 @@ function lowerFsReaddirTypesCall(lowerer, call, loc, promiseForm) {
|
|
|
6309
6561
|
const callType = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6310
6562
|
if (!callType)
|
|
6311
6563
|
fence();
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6564
|
+
let result = callType;
|
|
6565
|
+
if (promiseForm) {
|
|
6566
|
+
if (callType.kind !== "promise")
|
|
6567
|
+
fence();
|
|
6568
|
+
result = callType.inner;
|
|
6569
|
+
}
|
|
6315
6570
|
if (result?.kind !== "array" || result.elem.kind !== "record")
|
|
6316
6571
|
fence();
|
|
6317
6572
|
const shape = lowerer.shapes.get(result.elem.shapeId);
|
|
@@ -6494,9 +6749,10 @@ function lowerQuerystringParseCall(lowerer, call, loc) {
|
|
|
6494
6749
|
}
|
|
6495
6750
|
if (!sawStr || !sawArr)
|
|
6496
6751
|
fence();
|
|
6497
|
-
const
|
|
6498
|
-
|
|
6499
|
-
|
|
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);
|
|
6500
6756
|
const sep = qsSepEqArg(lowerer, call.arguments[1], "&", "querystring.parse", loc);
|
|
6501
6757
|
const eq = qsSepEqArg(lowerer, call.arguments[2], "=", "querystring.parse", loc);
|
|
6502
6758
|
// The options walk: maxKeys lowers (Node's rule — > 0 caps the pair
|
|
@@ -6668,7 +6924,35 @@ export function lowerProcessEnvGet(lowerer, expr) {
|
|
|
6668
6924
|
export function lowerProcessMethodCall(lowerer, call, access) {
|
|
6669
6925
|
if (call.questionDotToken)
|
|
6670
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
|
+
}
|
|
6671
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
|
+
}
|
|
6672
6956
|
if (directProcessMember === "send")
|
|
6673
6957
|
return lowerProcessIpcSend(lowerer, call);
|
|
6674
6958
|
if (directProcessMember === "disconnect") {
|
|
@@ -6924,7 +7208,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6924
7208
|
if (member === null)
|
|
6925
7209
|
return null;
|
|
6926
7210
|
const loc = locOf(call);
|
|
6927
|
-
// process.on/once/off: the CLI event slice —
|
|
7211
|
+
// process.on/once/off: the CLI event slice — named OS
|
|
6928
7212
|
// signal handlers and the 'exit' hook. Signal listeners run as
|
|
6929
7213
|
// macrotasks at loop turns, replace the default disposition while
|
|
6930
7214
|
// registered (removing the last restores Ctrl-C death), and never
|
|
@@ -6955,12 +7239,17 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6955
7239
|
loc,
|
|
6956
7240
|
};
|
|
6957
7241
|
}
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
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
|
+
}
|
|
6964
7253
|
// 'unhandledRejection': the listener crosses as a dyn function and
|
|
6965
7254
|
// the completed-checkpoint report dispatches it (reason, promise) per
|
|
6966
7255
|
// never-observed rejection instead of printing and exiting 1
|
|
@@ -6996,8 +7285,23 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6996
7285
|
loc,
|
|
6997
7286
|
};
|
|
6998
7287
|
}
|
|
6999
|
-
if (
|
|
7000
|
-
|
|
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]);
|
|
7001
7305
|
}
|
|
7002
7306
|
if (!ts.isExpressionStatement(call.parent)) {
|
|
7003
7307
|
lowerer.unsupported("SC1090", call, "chaining process listener registration (the result is void here — register each listener as its own statement)");
|
|
@@ -7012,7 +7316,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7012
7316
|
// result; a non-function dyn value throws the catchable TypeError
|
|
7013
7317
|
// at REGISTRATION (Node's ERR_INVALID_ARG_TYPE moment).
|
|
7014
7318
|
{
|
|
7015
|
-
const target = funcOf(
|
|
7319
|
+
const target = funcOf([F64], VOID);
|
|
7016
7320
|
const exact = cb.type.kind === "func" &&
|
|
7017
7321
|
cb.type.ret.kind === "void" &&
|
|
7018
7322
|
cb.type.params.length <= 1 &&
|
|
@@ -7037,16 +7341,6 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7037
7341
|
}
|
|
7038
7342
|
const param = cb.type.params[0];
|
|
7039
7343
|
const onceArg = { kind: "boolLit", value: member === "once", type: BOOL, loc };
|
|
7040
|
-
if (signo !== undefined) {
|
|
7041
|
-
if (param !== undefined) {
|
|
7042
|
-
lowerer.unsupported("SC1090", call.arguments[1], "signal listeners with parameters (the signal name argument has no lowering — use ())");
|
|
7043
|
-
}
|
|
7044
|
-
const sig = { kind: "numLit", value: signo, type: F64, loc };
|
|
7045
|
-
if (isOff) {
|
|
7046
|
-
return { kind: "libCall", fn: "process.offSignal", args: [sig, cb], type: VOID, loc };
|
|
7047
|
-
}
|
|
7048
|
-
return { kind: "libCall", fn: "process.onSignal", args: [sig, cb, onceArg], type: VOID, loc };
|
|
7049
|
-
}
|
|
7050
7344
|
if (param !== undefined && param.kind !== "f64") {
|
|
7051
7345
|
lowerer.unsupported("SC1090", call.arguments[1], `exit listeners whose parameter is not 'number' (got '${lowerer.fmt(param)}')`);
|
|
7052
7346
|
}
|
|
@@ -7321,7 +7615,7 @@ const NUMBER_STATIC_PREDICATES = {
|
|
|
7321
7615
|
isSafeInteger: "number.isSafeInteger",
|
|
7322
7616
|
};
|
|
7323
7617
|
/** The Number constants, baked as literals — non-finite ones included
|
|
7324
|
-
* (numLits carry NaN and the infinities;
|
|
7618
|
+
* (numLits carry NaN and the infinities; the backend preserves them). */
|
|
7325
7619
|
const NUMBER_CONSTANTS = {
|
|
7326
7620
|
MAX_SAFE_INTEGER: 9007199254740991,
|
|
7327
7621
|
MIN_SAFE_INTEGER: -9007199254740991,
|
|
@@ -7455,7 +7749,9 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7455
7749
|
if (call.arguments.length !== 0) {
|
|
7456
7750
|
lowerer.noLowering(`Date.prototype.${name} with arguments`, call, DATE_METHOD_HINT);
|
|
7457
7751
|
}
|
|
7458
|
-
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;
|
|
7459
7755
|
if (receiver.type.kind !== "date")
|
|
7460
7756
|
lowerer.badType(access.expression, lowerer.typeOf(access.expression));
|
|
7461
7757
|
if (name === "getTime" || name === "valueOf") {
|
|
@@ -7476,78 +7772,87 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7476
7772
|
}
|
|
7477
7773
|
lowerer.noLowering(`Date.prototype.${name}`, call, DATE_METHOD_HINT, lowerer.checker.getSymbolAtLocation(access.name));
|
|
7478
7774
|
}
|
|
7479
|
-
|
|
7480
|
-
*
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
const
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
const
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
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,
|
|
7499
7800
|
};
|
|
7500
|
-
|
|
7501
|
-
|
|
7801
|
+
return label === null || label.kind === "strLit" ? result : {
|
|
7802
|
+
kind: "seqExpr", stmts: [{ kind: "exprStmt", expr: label, loc }], result, type, loc,
|
|
7502
7803
|
};
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
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
|
-
|
|
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 };
|
|
7551
7856
|
}
|
|
7552
7857
|
/** A direct construction of THE stdlib TextEncoder/TextDecoder, through
|
|
7553
7858
|
* type-only wrappers. Name alone is never enough: a user class with the
|
|
@@ -7568,118 +7873,8 @@ function directTextCodecCtorOf(lowerer, expr) {
|
|
|
7568
7873
|
return null;
|
|
7569
7874
|
return { cls: sym.name, ctor };
|
|
7570
7875
|
}
|
|
7571
|
-
/**
|
|
7572
|
-
*
|
|
7573
|
-
* resolve back to the initializer. TextDecoder's explicit label must be
|
|
7574
|
-
* an actual recognized literal here: accepting an arbitrary expression
|
|
7575
|
-
* merely typed as a label would move or repeat its effects when the
|
|
7576
|
-
* binding is erased. */
|
|
7577
|
-
function erasableTextCodecCtor(info) {
|
|
7578
|
-
const args = info.ctor.arguments ?? [];
|
|
7579
|
-
if (info.cls === "TextEncoder")
|
|
7580
|
-
return args.length === 0;
|
|
7581
|
-
if (args.length === 0)
|
|
7582
|
-
return true;
|
|
7583
|
-
if (args.length !== 1)
|
|
7584
|
-
return false;
|
|
7585
|
-
const label = stripTypeCasts(args[0]);
|
|
7586
|
-
return ts.isStringLiteralLike(label) && staticTextDecoderEncoding(label.text) !== null;
|
|
7587
|
-
}
|
|
7588
|
-
/** `const encoder = new TextEncoder()` / a statically-labelled TextDecoder twin:
|
|
7589
|
-
* compile-time alias plumbing with no runtime object. Calls through the
|
|
7590
|
-
* stable binding are recognized by textCodecReceiverOf below; any other
|
|
7591
|
-
* reached value use keeps the ordinary SC2020 representation fence. Both
|
|
7592
|
-
* declaration walks call this and independently gate on constness. */
|
|
7593
|
-
export function textCodecBindingClassOf(lowerer, nameNode, init) {
|
|
7594
|
-
if (!ts.isIdentifier(nameNode) || init === undefined)
|
|
7595
|
-
return null;
|
|
7596
|
-
const decl = nameNode.parent;
|
|
7597
|
-
if (!ts.isVariableDeclaration(decl) || !ts.isVariableDeclarationList(decl.parent) ||
|
|
7598
|
-
!ts.isVariableStatement(decl.parent.parent)) {
|
|
7599
|
-
return null;
|
|
7600
|
-
}
|
|
7601
|
-
const info = directTextCodecCtorOf(lowerer, init);
|
|
7602
|
-
return info !== null && erasableTextCodecCtor(info) ? info.cls : null;
|
|
7603
|
-
}
|
|
7604
|
-
export function textCodecBindingDecl(lowerer, nameNode, init) {
|
|
7605
|
-
return textCodecBindingClassOf(lowerer, nameNode, init) !== null;
|
|
7606
|
-
}
|
|
7607
|
-
/** The inline composed receiver, or a const identifier whose initializer
|
|
7608
|
-
* is an erasable codec construction in the same execution scope and
|
|
7609
|
-
* after that declaration. Following the declaration instead of
|
|
7610
|
-
* materializing the value is honest for the supported slice: receiver
|
|
7611
|
-
* reads are pure, construction has no effects, and every non-call use
|
|
7612
|
-
* fences because there is deliberately no general value lowering. */
|
|
7613
|
-
function textCodecReceiverOf(lowerer, expr) {
|
|
7614
|
-
const direct = directTextCodecCtorOf(lowerer, expr);
|
|
7615
|
-
if (direct !== null)
|
|
7616
|
-
return direct;
|
|
7617
|
-
const receiver = stripTypeCasts(expr);
|
|
7618
|
-
if (!ts.isIdentifier(receiver))
|
|
7619
|
-
return null;
|
|
7620
|
-
const sym = lowerer.resolveValueSymbol(receiver);
|
|
7621
|
-
const decl = sym ? lowerer.checker.valueDeclarationOf(sym) : undefined;
|
|
7622
|
-
if (!decl || !ts.isVariableDeclaration(decl) || decl.initializer === undefined ||
|
|
7623
|
-
!ts.isVariableDeclarationList(decl.parent) || (decl.parent.flags & ts.NodeFlags.Const) === 0 ||
|
|
7624
|
-
!textCodecBindingDecl(lowerer, decl.name, decl.initializer)) {
|
|
7625
|
-
return null;
|
|
7626
|
-
}
|
|
7627
|
-
// A closure can run before the const initializes (TDZ), and an
|
|
7628
|
-
// imported binding can be observed during a module cycle; both need
|
|
7629
|
-
// real runtime storage rather than this deliberately trivial rewrite.
|
|
7630
|
-
const executionScope = (node) => {
|
|
7631
|
-
let child = node;
|
|
7632
|
-
for (let cur = node.parent;; child = cur, cur = cur.parent) {
|
|
7633
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7634
|
-
return cur;
|
|
7635
|
-
// An instance field initializer runs when an object is constructed,
|
|
7636
|
-
// not when its enclosing class expression evaluates. Treat it like
|
|
7637
|
-
// a closure boundary: a later source position does not prove the
|
|
7638
|
-
// codec declaration ran (a switch can enter a following case and
|
|
7639
|
-
// instantiate the class while the binding is still in its TDZ).
|
|
7640
|
-
if (ts.isPropertyDeclaration(cur) && cur.initializer === child &&
|
|
7641
|
-
(ts.getCombinedModifierFlags(cur) & ts.ModifierFlags.Static) === 0) {
|
|
7642
|
-
return cur;
|
|
7643
|
-
}
|
|
7644
|
-
}
|
|
7645
|
-
};
|
|
7646
|
-
if (executionScope(receiver) !== executionScope(decl) || receiver.getStart() < decl.end)
|
|
7647
|
-
return null;
|
|
7648
|
-
// All switch clauses share one lexical environment, but dispatch can
|
|
7649
|
-
// enter a later clause without executing a const in an earlier one.
|
|
7650
|
-
// TypeScript normally diagnoses the direct read; an @ts-expect-error
|
|
7651
|
-
// can deliberately retain the runtime TDZ shape, so source order alone
|
|
7652
|
-
// is not a sufficient proof. A codec declared in a clause is erasable
|
|
7653
|
-
// only for uses inside that exact clause's subtree (nested switches are
|
|
7654
|
-
// fine; closures and instance initializers already fail executionScope).
|
|
7655
|
-
const switchClauseOf = (node) => {
|
|
7656
|
-
for (let cur = node.parent; cur !== undefined; cur = cur.parent) {
|
|
7657
|
-
if (ts.isCaseClause(cur) || ts.isDefaultClause(cur))
|
|
7658
|
-
return cur;
|
|
7659
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7660
|
-
return null;
|
|
7661
|
-
}
|
|
7662
|
-
return null;
|
|
7663
|
-
};
|
|
7664
|
-
const declClause = switchClauseOf(decl);
|
|
7665
|
-
if (declClause !== null) {
|
|
7666
|
-
let insideDeclClause = false;
|
|
7667
|
-
for (let cur = receiver; cur !== undefined; cur = cur.parent) {
|
|
7668
|
-
if (cur === declClause) {
|
|
7669
|
-
insideDeclClause = true;
|
|
7670
|
-
break;
|
|
7671
|
-
}
|
|
7672
|
-
}
|
|
7673
|
-
if (!insideDeclClause)
|
|
7674
|
-
return null;
|
|
7675
|
-
}
|
|
7676
|
-
return directTextCodecCtorOf(lowerer, decl.initializer);
|
|
7677
|
-
}
|
|
7678
|
-
/** The WHATWG encoder pair, COMPOSED or through an erasable const binding:
|
|
7679
|
-
* `new TextDecoder().decode(bytes)`, `new TextEncoder().encode(s)`, and
|
|
7680
|
-
* the idiomatic store-then-call equivalents. The codec object never
|
|
7681
|
-
* exists (the crypto/Date precedent); bare construction and value uses
|
|
7682
|
-
* 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
|
|
7683
7878
|
* decode for every recognized static label (with BOM handling for the
|
|
7684
7879
|
* Unicode encodings); a zero-argument decode() is "" like the spec's.
|
|
7685
7880
|
* encode IS Buffer.from(s, "utf8") — ScrStr
|
|
@@ -7692,8 +7887,10 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7692
7887
|
const member = access.name.text;
|
|
7693
7888
|
if (member !== "decode" && member !== "encode")
|
|
7694
7889
|
return null;
|
|
7695
|
-
const info =
|
|
7696
|
-
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))
|
|
7697
7894
|
return null;
|
|
7698
7895
|
const { cls, ctor: recv } = info;
|
|
7699
7896
|
if (!(cls === "TextDecoder" && member === "decode") && !(cls === "TextEncoder" && member === "encode")) {
|
|
@@ -7704,7 +7901,7 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7704
7901
|
if (cls === "TextDecoder") {
|
|
7705
7902
|
// The label must be statically known. A literal-typed effectful inline
|
|
7706
7903
|
// expression is accepted, but its evaluation is sequenced before the
|
|
7707
|
-
// decode below
|
|
7904
|
+
// decode below, just as stored decoders evaluate it at construction.
|
|
7708
7905
|
const labelT = ctorArgs.length >= 1 ? lowerer.typeOf(ctorArgs[0]) : null;
|
|
7709
7906
|
const encoding = ctorArgs.length === 0
|
|
7710
7907
|
? { kind: "utf8" }
|
|
@@ -7752,23 +7949,23 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7752
7949
|
if (ctorArgs.length > 0) {
|
|
7753
7950
|
lowerer.noLowering("new TextEncoder with arguments", recv);
|
|
7754
7951
|
}
|
|
7755
|
-
if (call.arguments.length
|
|
7756
|
-
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);
|
|
7757
7954
|
}
|
|
7758
|
-
const s = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
7955
|
+
const s = call.arguments.length === 0 ? strLit("", loc) : lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
7759
7956
|
const enc = { kind: "strLit", value: "utf8", type: STRING, loc };
|
|
7760
7957
|
return { kind: "libCall", fn: "buffer.fromStr", args: [s, enc], type: BYTES_U8, loc };
|
|
7761
7958
|
}
|
|
7762
|
-
/** `String.fromCharCode(...codes)` on THE String global: every argument
|
|
7959
|
+
/** `String.fromCharCode/fromCodePoint(...codes)` on THE String global: every argument
|
|
7763
7960
|
* lowers as a number and packs into ONE f64[] array-literal argument
|
|
7764
7961
|
* (the path.join convention) — or ONE whole-array spread forwards the
|
|
7765
|
-
* array itself.
|
|
7766
|
-
*
|
|
7962
|
+
* array itself. String.raw has its own template path below.
|
|
7963
|
+
* Null for non-String receivers. */
|
|
7767
7964
|
export function lowerStringStaticCall(lowerer, call, access) {
|
|
7768
7965
|
if (call.questionDotToken)
|
|
7769
7966
|
return null;
|
|
7770
7967
|
const member = lowerer.stdlibGlobalMember(access, "String");
|
|
7771
|
-
if (member !== "fromCharCode" && member !== "raw")
|
|
7968
|
+
if (member !== "fromCharCode" && member !== "fromCodePoint" && member !== "raw")
|
|
7772
7969
|
return null;
|
|
7773
7970
|
const loc = locOf(call);
|
|
7774
7971
|
// String.raw(template, ...substitutions): the template's `raw` member
|
|
@@ -7812,7 +8009,7 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7812
8009
|
const spread = call.arguments.find(ts.isSpreadElement);
|
|
7813
8010
|
if (spread) {
|
|
7814
8011
|
if (call.arguments.length !== 1) {
|
|
7815
|
-
lowerer.noLowering(
|
|
8012
|
+
lowerer.noLowering(`String.${member} with a mixed spread call`, call, `spread a whole array (String.${member}(...codes)) or pass plain arguments`);
|
|
7816
8013
|
}
|
|
7817
8014
|
// A typed-array/Buffer spread (String.fromCharCode(...data.slice(4, 8))
|
|
7818
8015
|
// — the magic-number ASCII probe) passes the bytes value through; the
|
|
@@ -7822,14 +8019,14 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7822
8019
|
const packed = lowerer.lowerExpr(spread.expression);
|
|
7823
8020
|
if (packed.type.kind !== "bytes")
|
|
7824
8021
|
lowerer.badType(spread.expression, lowerer.typeOf(spread.expression));
|
|
7825
|
-
return { kind: "libCall", fn:
|
|
8022
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7826
8023
|
}
|
|
7827
8024
|
const packed = lowerer.lowerExprExpecting(spread.expression, arrayOf(F64));
|
|
7828
|
-
return { kind: "libCall", fn:
|
|
8025
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7829
8026
|
}
|
|
7830
8027
|
const elems = call.arguments.map((a) => lowerer.lowerExprExpecting(a, F64));
|
|
7831
8028
|
const packed = { kind: "arrayLit", elems, type: arrayOf(F64), loc };
|
|
7832
|
-
return { kind: "libCall", fn:
|
|
8029
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7833
8030
|
}
|
|
7834
8031
|
/** `s.lastIndexOf(searchValue?, position?)` on string receivers, using UTF-16
|
|
7835
8032
|
* indices. An omitted search value searches for "undefined". Omitted or undefined positions clamp to the string's end;
|
|
@@ -8305,14 +8502,24 @@ export function isConsoleLog(lowerer, call) {
|
|
|
8305
8502
|
* like every stdlib global. Null for anything else (console.table, a
|
|
8306
8503
|
* user's own console binding, ...). */
|
|
8307
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
|
+
}
|
|
8308
8511
|
if (!ts.isPropertyAccessExpression(call.expression))
|
|
8309
8512
|
return null;
|
|
8310
8513
|
const access = call.expression;
|
|
8311
8514
|
if (access.questionDotToken || call.questionDotToken)
|
|
8312
8515
|
return null;
|
|
8313
8516
|
const name = access.name.text;
|
|
8314
|
-
if (name
|
|
8517
|
+
if (!isConsoleOutputMember(name))
|
|
8315
8518
|
return null;
|
|
8316
|
-
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";
|
|
8317
8524
|
}
|
|
8318
8525
|
//# sourceMappingURL=lower-builtins.js.map
|