@scriptc/compiler 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +98 -39
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +15 -0
- package/dist/backend/build-cache.d.ts +1 -3
- package/dist/backend/build-cache.js +3 -22
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +3 -0
- package/dist/backend/cache-root.js +23 -0
- package/dist/backend/cache-root.js.map +1 -0
- package/dist/backend/cycle-analysis.d.ts +15 -0
- package/dist/backend/cycle-analysis.js +108 -0
- package/dist/backend/cycle-analysis.js.map +1 -0
- package/dist/backend/cycle-analysis.test.js +124 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -0
- package/dist/backend/executable-features.d.ts +4 -0
- package/dist/backend/executable-features.js +42 -0
- package/dist/backend/executable-features.js.map +1 -0
- package/dist/backend/external-c.d.ts +5 -27
- package/dist/backend/external-c.js +5 -40
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +2 -3
- package/dist/backend/ffi-callbacks.js +2 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.d.ts +4 -9
- package/dist/backend/library-identity-markers.js +11 -49
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +5 -0
- package/dist/backend/library-pack.js +123 -0
- package/dist/backend/library-pack.js.map +1 -0
- package/dist/backend/link-plan-core.d.ts +20 -0
- package/dist/backend/link-plan-core.js +18 -0
- package/dist/backend/link-plan-core.js.map +1 -0
- package/dist/backend/link-plan.d.ts +1 -1
- package/dist/backend/link-plan.js +16 -17
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/link-trace.d.ts +2 -0
- package/dist/backend/link-trace.js +24 -0
- package/dist/backend/link-trace.js.map +1 -0
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.d.ts +9 -0
- package/dist/backend/literals.js +35 -0
- package/dist/backend/literals.js.map +1 -0
- package/dist/backend/literals.test.d.ts +1 -0
- package/dist/backend/literals.test.js +53 -0
- package/dist/backend/literals.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +9 -4
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.d.ts +1 -0
- package/dist/backend/llvm/blocks.test.js +91 -0
- package/dist/backend/llvm/blocks.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +14 -8
- package/dist/backend/llvm/classes.js +88 -30
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +5 -1
- package/dist/backend/llvm/common.js +45 -4
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/debug-info.js +2 -7
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/debug-info.test.d.ts +1 -0
- package/dist/backend/llvm/debug-info.test.js +110 -0
- package/dist/backend/llvm/debug-info.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +21 -2
- package/dist/backend/llvm/dyn.js +647 -251
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +596 -1
- package/dist/backend/llvm/emitter.js +769 -425
- 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 +2 -2
- package/dist/backend/llvm/expr-bytes.js +60 -31
- 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 +10 -6
- 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 +78 -81
- 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 +62 -31
- 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 +54 -7
- 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 +220 -131
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +19 -0
- package/dist/backend/llvm/layouts.js +12 -0
- package/dist/backend/llvm/layouts.js.map +1 -0
- package/dist/backend/llvm/lib-abi.d.ts +19 -0
- package/dist/backend/llvm/lib-abi.js +82 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -0
- package/dist/backend/llvm/lib-connect.d.ts +2 -0
- package/dist/backend/llvm/lib-connect.js +51 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.d.ts +2 -0
- package/dist/backend/llvm/lib-datagram.js +135 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +50 -6
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +30 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +2 -0
- package/dist/backend/llvm/lib-http2.js +215 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -0
- package/dist/backend/llvm/lib-lookup.d.ts +2 -0
- package/dist/backend/llvm/lib-lookup.js +39 -0
- package/dist/backend/llvm/lib-lookup.js.map +1 -0
- package/dist/backend/llvm/lib-network.js +25 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +44 -19
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +162 -3
- 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 +42 -131
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.d.ts +1 -0
- package/dist/backend/llvm/unsupported.js +1 -2
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -7
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.d.ts +2 -2
- package/dist/backend/mangle.js +16 -5
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
- package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
- package/dist/backend/may-throw.js.map +1 -0
- package/dist/backend/may-throw.test.d.ts +1 -0
- package/dist/backend/may-throw.test.js +58 -0
- package/dist/backend/may-throw.test.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +22 -0
- package/dist/backend/native-codegen-core.js +44 -0
- package/dist/backend/native-codegen-core.js.map +1 -0
- package/dist/backend/native-codegen.d.ts +3 -19
- package/dist/backend/native-codegen.js +5 -44
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +94 -0
- package/dist/backend/native-link-info-core.js +62 -0
- package/dist/backend/native-link-info-core.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +3 -88
- package/dist/backend/native-link-info.js +12 -243
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +41 -146
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +12 -30
- package/dist/backend/native-toolchain.js +83 -233
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +77 -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 +73 -0
- package/dist/backend/runtime-pack-native.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +3 -83
- package/dist/backend/runtime-pack.js +8 -151
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +24 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +22 -0
- package/dist/backend/target-diagnostics.js +108 -0
- package/dist/backend/target-diagnostics.js.map +1 -0
- package/dist/backend/target-platform.d.ts +15 -0
- package/dist/backend/target-platform.js +72 -0
- package/dist/backend/target-platform.js.map +1 -0
- package/dist/backend/targets.d.ts +13 -4
- package/dist/backend/targets.js +103 -34
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +72 -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 +37 -7
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +162 -0
- package/dist/compile-types.js +2 -0
- package/dist/compile-types.js.map +1 -0
- package/dist/coverage/report.js +11 -5
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +5 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +5 -10
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +5 -6
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +16 -17
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +14 -0
- package/dist/executable/prepare.js +66 -0
- package/dist/executable/prepare.js.map +1 -0
- package/dist/ffi/ffi-manifest.d.ts +11 -4
- package/dist/ffi/ffi-manifest.js +170 -58
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.d.ts +1 -0
- package/dist/ffi/ffi-manifest.test.js +111 -0
- package/dist/ffi/ffi-manifest.test.js.map +1 -0
- package/dist/format-integer.d.ts +3 -0
- package/dist/format-integer.js +14 -0
- package/dist/format-integer.js.map +1 -0
- package/dist/frontend/analysis.d.ts +5 -0
- package/dist/frontend/analysis.js +88 -0
- package/dist/frontend/analysis.js.map +1 -0
- package/dist/frontend/arguments-usage.d.ts +1 -3
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -1
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-lexer.d.ts +4 -25
- package/dist/frontend/cjs-lexer.js +6 -806
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/cjs-resolve.d.ts +5 -0
- package/dist/frontend/cjs-resolve.js +429 -0
- package/dist/frontend/cjs-resolve.js.map +1 -0
- package/dist/frontend/cjs-syntax.d.ts +26 -0
- package/dist/frontend/cjs-syntax.js +806 -0
- package/dist/frontend/cjs-syntax.js.map +1 -0
- package/dist/frontend/comptime-node.d.ts +4 -0
- package/dist/frontend/comptime-node.js +16 -0
- package/dist/frontend/comptime-node.js.map +1 -0
- package/dist/frontend/comptime-node.test.d.ts +1 -0
- package/dist/frontend/comptime-node.test.js +37 -0
- package/dist/frontend/comptime-node.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +3 -4
- package/dist/frontend/dts-paths.js +15 -8
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +2 -2
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/helper-tokens.d.ts +1 -0
- package/dist/frontend/helper-tokens.js +147 -0
- package/dist/frontend/helper-tokens.js.map +1 -0
- package/dist/frontend/helper-tokens.test.d.ts +1 -0
- package/dist/frontend/helper-tokens.test.js +35 -0
- package/dist/frontend/helper-tokens.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
- package/dist/frontend/inferred-js-diagnostics.js +69 -0
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +5 -2
- package/dist/frontend/input-tracker.js +24 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +23 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +32 -24
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.d.ts +4 -0
- package/dist/frontend/literal-values.js +21 -0
- package/dist/frontend/literal-values.js.map +1 -0
- package/dist/frontend/literal-values.test.d.ts +1 -0
- package/dist/frontend/literal-values.test.js +91 -0
- package/dist/frontend/literal-values.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
- package/dist/frontend/lowering/abstract-equality.js +3 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -1
- package/dist/frontend/lowering/array-values.js +43 -1
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
- package/dist/frontend/lowering/class-callbacks.js +74 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-construction.d.ts +12 -0
- package/dist/frontend/lowering/class-construction.js +156 -0
- package/dist/frontend/lowering/class-construction.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +10 -0
- package/dist/frontend/lowering/class-descriptors.js +114 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +51 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1158 -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 +93 -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 +67 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +13 -0
- package/dist/frontend/lowering/class-method-values.js +235 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +19 -0
- package/dist/frontend/lowering/class-prototypes.js +242 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +66 -0
- package/dist/frontend/lowering/class-runtime-statics.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 +208 -163
- 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 +58 -63
- 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 +14 -0
- package/dist/frontend/lowering/error-methods.js +177 -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 +51 -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 +132 -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 +509 -183
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +3 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +88 -24
- 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 +101 -0
- package/dist/frontend/lowering/function-context.js +109 -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 +11 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +143 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +4 -1
- package/dist/frontend/lowering/lib-boundary.js +112 -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 +18 -0
- package/dist/frontend/lowering/lower-builtin-values.js +249 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +33 -46
- package/dist/frontend/lowering/lower-builtins.js +676 -365
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +28 -22
- package/dist/frontend/lowering/lower-calls.js +1660 -412
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +95 -57
- package/dist/frontend/lowering/lower-classes.js +1491 -404
- 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 +36 -32
- package/dist/frontend/lowering/lower-containers.js +925 -181
- 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 +3 -2
- 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 +37 -13
- package/dist/frontend/lowering/lower-exprs.js +2163 -863
- 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 +88 -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 +7 -8
- package/dist/frontend/lowering/lower-island.js +66 -33
- 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 +445 -39
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-modules.test.js +39 -0
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -0
- 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 +17 -17
- package/dist/frontend/lowering/lower-stmts.js +855 -514
- 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 +20 -11
- 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 +140 -190
- package/dist/frontend/lowering/lowerer.js +1193 -712
- 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 +172 -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 +10 -3
- package/dist/frontend/lowering/surfaces.js +86 -37
- 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 +12 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +82 -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 +121 -38
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +9 -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 +39 -20
- package/dist/frontend/program.js +393 -189
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +105 -2
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +9 -0
- package/dist/frontend/provenance-core.js +435 -0
- package/dist/frontend/provenance-core.js.map +1 -0
- package/dist/frontend/provenance.d.ts +0 -4
- package/dist/frontend/provenance.js +4 -459
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +3 -1
- package/dist/frontend/resolve.js +6 -3
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +4 -3
- package/dist/frontend/runtime-resolve.js +22 -18
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +53 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +5 -0
- package/dist/frontend/services-node.js +19 -0
- package/dist/frontend/services-node.js.map +1 -0
- package/dist/frontend/services-node.test.d.ts +1 -0
- package/dist/frontend/services-node.test.js +70 -0
- package/dist/frontend/services-node.test.js.map +1 -0
- package/dist/frontend/services.d.ts +44 -0
- package/dist/frontend/services.js +90 -0
- package/dist/frontend/services.js.map +1 -0
- package/dist/frontend/services.test.d.ts +1 -0
- package/dist/frontend/services.test.js +174 -0
- package/dist/frontend/services.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +3 -3
- package/dist/frontend/ts7/adapter.js +14 -31
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/api.d.ts +16 -0
- package/dist/frontend/ts7/api.js +24 -0
- package/dist/frontend/ts7/api.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
- package/dist/frontend/ts7/ast-bytes.js +137 -0
- package/dist/frontend/ts7/ast-bytes.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-bytes.test.js +73 -0
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
- package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-guards.test.js +43 -0
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +194 -0
- package/dist/frontend/ts7/ast-node.js +448 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -0
- package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-node.test.js +266 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -0
- package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
- package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
- package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-text.d.ts +6 -0
- package/dist/frontend/ts7/ast-text.js +124 -0
- package/dist/frontend/ts7/ast-text.js.map +1 -0
- package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-text.test.js +38 -0
- package/dist/frontend/ts7/ast-text.test.js.map +1 -0
- package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
- package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
- package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.d.ts +42 -0
- package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
- package/dist/frontend/ts7/ast-types.generated.js +5 -0
- package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.js +3 -0
- package/dist/frontend/ts7/ast-types.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +58 -0
- package/dist/frontend/ts7/ast-wire.js +267 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire.test.js +151 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +14 -14
- package/dist/frontend/ts7/ast.js +25 -18
- 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 +47 -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 +34 -18
- package/dist/frontend/type-mapper.js +552 -131
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +146 -2
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/union-discriminants.d.ts +16 -0
- package/dist/frontend/union-discriminants.js +98 -0
- package/dist/frontend/union-discriminants.js.map +1 -0
- package/dist/frontend/union-discriminants.test.d.ts +1 -0
- package/dist/frontend/union-discriminants.test.js +182 -0
- package/dist/frontend/union-discriminants.test.js.map +1 -0
- package/dist/index.d.ts +7 -198
- package/dist/index.js +369 -1572
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +23 -4
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.js +67 -49
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/control-flow.d.ts +6 -0
- package/dist/ir/control-flow.js +142 -0
- package/dist/ir/control-flow.js.map +1 -0
- package/dist/ir/control-flow.test.d.ts +1 -0
- package/dist/ir/control-flow.test.js +113 -0
- package/dist/ir/control-flow.test.js.map +1 -0
- package/dist/ir/integer-loops.js +7 -18
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.js +53 -27
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +334 -176
- package/dist/ir/ir.js +710 -903
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +162 -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 +33 -14
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +57 -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 +2018 -1498
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +536 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +2 -3
- package/dist/library/cache-primitives.js +4 -6
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/fence-eval.js +2 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.js +7 -6
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.d.ts +3 -2
- package/dist/library/library-cache.js +5 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +54 -41
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.d.ts +3 -1
- package/dist/library/library-profile.js +15 -6
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.d.ts +15 -0
- package/dist/library/prepare.js +584 -0
- package/dist/library/prepare.js.map +1 -0
- package/dist/library/semantic-source.d.ts +1 -1
- package/dist/library/semantic-source.js +8 -6
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar-validate.js +4 -4
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +2 -0
- package/dist/library/sidecar.js +10 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/cache.d.ts +11 -0
- package/dist/native/cache.js +113 -0
- package/dist/native/cache.js.map +1 -0
- package/dist/native/cache.test.d.ts +1 -0
- package/dist/native/cache.test.js +66 -0
- package/dist/native/cache.test.js.map +1 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +112 -0
- package/dist/native/cli.js.map +1 -0
- package/dist/native/compiler.d.ts +15 -0
- package/dist/native/compiler.js +336 -0
- package/dist/native/compiler.js.map +1 -0
- package/dist/native/compiler.test.d.ts +1 -0
- package/dist/native/compiler.test.js +174 -0
- package/dist/native/compiler.test.js.map +1 -0
- package/dist/native/comptime.d.ts +5 -0
- package/dist/native/comptime.js +73 -0
- package/dist/native/comptime.js.map +1 -0
- package/dist/native/comptime.test.d.ts +1 -0
- package/dist/native/comptime.test.js +65 -0
- package/dist/native/comptime.test.js.map +1 -0
- package/dist/native/executable-cache.d.ts +26 -0
- package/dist/native/executable-cache.js +228 -0
- package/dist/native/executable-cache.js.map +1 -0
- package/dist/native/executable-cache.test.d.ts +1 -0
- package/dist/native/executable-cache.test.js +151 -0
- package/dist/native/executable-cache.test.js.map +1 -0
- package/dist/native/file-identity.d.ts +4 -0
- package/dist/native/file-identity.js +14 -0
- package/dist/native/file-identity.js.map +1 -0
- package/dist/native/file-identity.test.d.ts +1 -0
- package/dist/native/file-identity.test.js +43 -0
- package/dist/native/file-identity.test.js.map +1 -0
- package/dist/native/library.d.ts +22 -0
- package/dist/native/library.js +83 -0
- package/dist/native/library.js.map +1 -0
- package/dist/native/prepare.d.ts +21 -0
- package/dist/native/prepare.js +174 -0
- package/dist/native/prepare.js.map +1 -0
- package/dist/native/prepare.test.d.ts +1 -0
- package/dist/native/prepare.test.js +70 -0
- package/dist/native/prepare.test.js.map +1 -0
- package/dist/native/sanitizer.d.ts +11 -0
- package/dist/native/sanitizer.js +137 -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 +94 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +85 -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 +107 -98
- package/dist/backend/c/async.d.ts +0 -171
- package/dist/backend/c/async.js +0 -1317
- package/dist/backend/c/async.js.map +0 -1
- package/dist/backend/c/c-emitter.d.ts +0 -536
- package/dist/backend/c/c-emitter.js +0 -1932
- package/dist/backend/c/c-emitter.js.map +0 -1
- package/dist/backend/c/exprs.d.ts +0 -15
- package/dist/backend/c/exprs.js +0 -8847
- package/dist/backend/c/exprs.js.map +0 -1
- package/dist/backend/c/island.d.ts +0 -45
- package/dist/backend/c/island.js +0 -281
- package/dist/backend/c/island.js.map +0 -1
- package/dist/backend/c/may-throw.js.map +0 -1
- package/dist/backend/c/shapes.d.ts +0 -142
- package/dist/backend/c/shapes.js +0 -603
- package/dist/backend/c/shapes.js.map +0 -1
- package/dist/backend/c/stmts.d.ts +0 -76
- package/dist/backend/c/stmts.js +0 -1108
- package/dist/backend/c/stmts.js.map +0 -1
- package/dist/backend/c/types.d.ts +0 -71
- package/dist/backend/c/types.js +0 -459
- package/dist/backend/c/types.js.map +0 -1
- package/dist/backend/c/types.test.js +0 -32
- package/dist/backend/c/types.test.js.map +0 -1
- package/dist/backend/c/walkers.d.ts +0 -134
- package/dist/backend/c/walkers.js +0 -1772
- package/dist/backend/c/walkers.js.map +0 -1
- /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { staticTextDecoderEncoding } from "./text-decoder-encoding.js";
|
|
1
2
|
import { InternalCompilerError } from "../../errors.js";
|
|
2
3
|
/* Builtin-surface lowering: node builtin-module calls (fs, path, os, url,
|
|
3
4
|
* crypto, child_process spawn/spawnSync and child/stats/spawn-result
|
|
@@ -6,8 +7,9 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
6
7
|
import { builtinModules } from "node:module";
|
|
7
8
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
8
9
|
import * as ts from "../ts7/adapter.js";
|
|
10
|
+
import { lowerCheckedPredicateValue } from "./lower-builtin-values.js";
|
|
9
11
|
import { PoisonError, dynUndefinedExpr, ladderFenceExpr, nodeThrowExpr, own } from "./lowerer.js";
|
|
10
|
-
import { canonicalBuiltinModule, isJsSourceFile, isNodeEsmFile, locOf, npmStaticDepSf7, requireSpecOf, resolveImport } from "../program.js";
|
|
12
|
+
import { canonicalBuiltinModule, isCreateRequireBinding7, isJsSourceFile, isNodeEsmFile, locOf, npmStaticDepSf7, requireSpecOf, resolveImport } from "../program.js";
|
|
11
13
|
import { isRelativeSpecifier } from "../workspace-registry.js";
|
|
12
14
|
import { probeNodeRequireRefusal } from "../npm.js";
|
|
13
15
|
import { isNpmStaticPackage } from "../npm-static.js";
|
|
@@ -24,11 +26,14 @@ import { CRYPTO_CIPHERS, CRYPTO_CONSTANTS, CRYPTO_CURVES, CRYPTO_HASHES } from "
|
|
|
24
26
|
import { generatorMeta, timerStyleCallback } from "./lower-calls.js";
|
|
25
27
|
import { registerHttpClientFnBinding, voidizedCallback } from "./lower-server.js";
|
|
26
28
|
import { pairsSnapshotHelper } from "./pairs-snapshot.js";
|
|
29
|
+
import { isJsonStringifyDynamicType } from "../../ir/ir.js";
|
|
27
30
|
import { bufEncoding } from "./containers/bytes.js";
|
|
28
31
|
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
32
|
import { boolLit, countedFor, numLit, strLit, varRef } from "../../ir/build.js";
|
|
30
33
|
import { staticForkModulePath } from "../fork-target.js";
|
|
31
34
|
import { tsgoPath } from "../dts-paths.js";
|
|
35
|
+
import { lowerFfiMemoryModule } from "./native-ffi.js";
|
|
36
|
+
import { lowerBuiltinLoaderValue } from "./lower-builtin-values.js";
|
|
32
37
|
function optionalStringTags(lowerer, type) {
|
|
33
38
|
if (type.kind !== "union")
|
|
34
39
|
return null;
|
|
@@ -122,14 +127,16 @@ function checkedOptionalBuiltinArm(lowerer, value, target) {
|
|
|
122
127
|
: null;
|
|
123
128
|
}
|
|
124
129
|
function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
// Number predicates do not coerce. In a mixed union only the numeric
|
|
131
|
+
// arm runs the predicate; every other arm answers false after evaluating
|
|
132
|
+
// the argument once. This includes the undefined added by array reads.
|
|
133
|
+
const widened = value.type;
|
|
134
|
+
if (widened.kind !== "union" && widened.kind !== "dyn")
|
|
127
135
|
return null;
|
|
128
|
-
const numberTag = lowerer.armTag(widened.unionId, F64);
|
|
129
|
-
|
|
130
|
-
if (numberTag < 0 || undefinedTag < 0)
|
|
136
|
+
const numberTag = widened.kind === "union" ? lowerer.armTag(widened.unionId, F64) : -1;
|
|
137
|
+
if (widened.kind === "union" && numberTag < 0)
|
|
131
138
|
return null;
|
|
132
|
-
const key = `number.optionalPredicate:${fn}:${widened
|
|
139
|
+
const key = `number.optionalPredicate:${fn}:${typeKey(widened)}`;
|
|
133
140
|
let helper = lowerer.widthHelpers.get(key);
|
|
134
141
|
if (!helper) {
|
|
135
142
|
helper = `%number.optionalPredicate.${lowerer.widthHelpers.size}`;
|
|
@@ -143,7 +150,9 @@ function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
|
143
150
|
body: [
|
|
144
151
|
{
|
|
145
152
|
kind: "if",
|
|
146
|
-
cond:
|
|
153
|
+
cond: widened.kind === "dyn"
|
|
154
|
+
? { kind: "dynTest", test: "number", negated: true, value: input, type: BOOL, loc }
|
|
155
|
+
: { kind: "unionIsTag", unionId: widened.unionId, tag: numberTag, negated: true, value: input, type: BOOL, loc },
|
|
147
156
|
then: [{ kind: "return", value: boolLit(false, loc), loc }],
|
|
148
157
|
else_: null,
|
|
149
158
|
loc,
|
|
@@ -153,7 +162,9 @@ function lowerOptionalNumberPredicate(lowerer, value, fn, loc) {
|
|
|
153
162
|
value: {
|
|
154
163
|
kind: "libCall",
|
|
155
164
|
fn,
|
|
156
|
-
args: [
|
|
165
|
+
args: [widened.kind === "dyn"
|
|
166
|
+
? { kind: "dynCheck", value: input, type: F64, loc }
|
|
167
|
+
: { kind: "unionNarrow", unionId: widened.unionId, tag: numberTag, value: input, type: F64, loc }],
|
|
157
168
|
type: BOOL,
|
|
158
169
|
loc,
|
|
159
170
|
},
|
|
@@ -198,7 +209,9 @@ function lowerBuiltinOptionalDefault(lowerer, node, expected, dflt, nullIsDefaul
|
|
|
198
209
|
* declaration is not an import specifier. Returns the CANONICAL module
|
|
199
210
|
* name and the EXPORTED member name (not the local alias). */
|
|
200
211
|
export function builtinImportOf(lowerer, ident) {
|
|
201
|
-
const symbol =
|
|
212
|
+
const symbol = ts.isShorthandPropertyAssignment(ident.parent) && ident.parent.name === ident
|
|
213
|
+
? lowerer.checker.getShorthandAssignmentValueSymbol(ident.parent)
|
|
214
|
+
: lowerer.checker.getSymbolAtLocation(ident);
|
|
202
215
|
const decl = symbol ? lowerer.checker.declarationsOf(symbol)[0] : undefined;
|
|
203
216
|
if (!decl)
|
|
204
217
|
return null;
|
|
@@ -206,7 +219,7 @@ export function builtinImportOf(lowerer, ident) {
|
|
|
206
219
|
// binding (`const { readFileSync } = require("fs")`, renames via
|
|
207
220
|
// `{ readFileSync: rf }`) keys the same tables.
|
|
208
221
|
if (ts.isBindingElement(decl) && decl.name !== undefined && ts.isIdentifier(decl.name)) {
|
|
209
|
-
const varDecl = decl.parent
|
|
222
|
+
const varDecl = decl.parent?.parent;
|
|
210
223
|
if (ts.isObjectBindingPattern(decl.parent) &&
|
|
211
224
|
ts.isVariableDeclaration(varDecl) &&
|
|
212
225
|
varDecl.initializer !== undefined) {
|
|
@@ -246,7 +259,7 @@ export function builtinImportOf(lowerer, ident) {
|
|
|
246
259
|
if (!ts.isImportSpecifier(decl) && !ts.isExportSpecifier(decl))
|
|
247
260
|
return null;
|
|
248
261
|
if (ts.isImportSpecifier(decl)) {
|
|
249
|
-
const importDecl = decl.parent
|
|
262
|
+
const importDecl = decl.parent?.parent?.parent;
|
|
250
263
|
if (!ts.isImportDeclaration(importDecl) || !ts.isStringLiteral(importDecl.moduleSpecifier)) {
|
|
251
264
|
return null;
|
|
252
265
|
}
|
|
@@ -370,7 +383,7 @@ function createRequireBaseCallOf(lowerer, expr) {
|
|
|
370
383
|
if (e.arguments.length !== 1)
|
|
371
384
|
return null;
|
|
372
385
|
const base = stripTypeCasts(e.arguments[0]);
|
|
373
|
-
if (ts.isIdentifier(base) && base
|
|
386
|
+
if (ts.isIdentifier(base) && lowerer.isStdlibGlobal(base, "__filename"))
|
|
374
387
|
return e;
|
|
375
388
|
if (ts.isPropertyAccessExpression(base) &&
|
|
376
389
|
!base.questionDotToken &&
|
|
@@ -384,15 +397,22 @@ function createRequireBaseCallOf(lowerer, expr) {
|
|
|
384
397
|
/** True for `const require = createRequire(import.meta.url)` — the
|
|
385
398
|
* binding is compile-time plumbing (each call through it resolves per
|
|
386
399
|
* site) with no storage and no code; both declaration walks skip by
|
|
387
|
-
* this test.
|
|
388
|
-
*
|
|
400
|
+
* this test. Top-level let/var bindings also qualify when preflight's
|
|
401
|
+
* shared proof rules out writes, escapes, and use before initialization. */
|
|
389
402
|
export function createRequireBindingDecl(lowerer, nameNode, init) {
|
|
390
|
-
if (!ts.isIdentifier(nameNode) || init === undefined)
|
|
403
|
+
if (!ts.isIdentifier(nameNode) || init === undefined || createRequireBaseCallOf(lowerer, init) === null)
|
|
391
404
|
return false;
|
|
392
|
-
|
|
405
|
+
// Preserve const loaders acquired through CommonJS member/destructure
|
|
406
|
+
// aliases, which builtinImportOf also recognizes. Mutable syntax uses
|
|
407
|
+
// preflight's narrower import provenance and whole-file stability proof.
|
|
408
|
+
const decl = nameNode.parent;
|
|
409
|
+
if (ts.isVariableDeclaration(decl) && ts.isVariableDeclarationList(decl.parent) &&
|
|
410
|
+
(decl.parent.flags & ts.NodeFlags.Const) !== 0)
|
|
411
|
+
return true;
|
|
412
|
+
return isCreateRequireBinding7(lowerer.program, nameNode);
|
|
393
413
|
}
|
|
394
414
|
/** The declaring source file when `callee` denotes a createRequire-made
|
|
395
|
-
* require: a
|
|
415
|
+
* require: a stable binding over createRequire(import.meta.url) (the
|
|
396
416
|
* binding's own file anchors resolution) or the inline
|
|
397
417
|
* `createRequire(import.meta.url)(...)` spelling (the call's file).
|
|
398
418
|
* Null off the pattern, so call chains keep trying. */
|
|
@@ -407,9 +427,7 @@ export function createRequireCalleeFileOf(lowerer, callee) {
|
|
|
407
427
|
const decl = symbol ? lowerer.checker.declarationsOf(symbol)[0] : undefined;
|
|
408
428
|
if (!decl || !ts.isVariableDeclaration(decl) || decl.initializer === undefined)
|
|
409
429
|
return null;
|
|
410
|
-
|
|
411
|
-
return null;
|
|
412
|
-
return createRequireBaseCallOf(lowerer, decl.initializer) !== null ? decl.getSourceFile() : null;
|
|
430
|
+
return createRequireBindingDecl(lowerer, decl.name, decl.initializer) ? decl.getSourceFile() : null;
|
|
413
431
|
}
|
|
414
432
|
/** The static require of `R("spec")` through a createRequire binding:
|
|
415
433
|
* the literal specifier plus the file anchoring relative resolution.
|
|
@@ -428,6 +446,14 @@ export function createRequireSpecOf(lowerer, call) {
|
|
|
428
446
|
const a = call.arguments[0];
|
|
429
447
|
return { spec: ts.isStringLiteralLike(a) ? a.text : null, baseFile };
|
|
430
448
|
}
|
|
449
|
+
/** node:ffi is a checked native module value, so its require binding needs
|
|
450
|
+
* storage even when the createRequire loader is named `require`. */
|
|
451
|
+
export function isNativeFfiRequire(lowerer, expr) {
|
|
452
|
+
if (expr === undefined)
|
|
453
|
+
return false;
|
|
454
|
+
const call = stripTypeCasts(expr);
|
|
455
|
+
return ts.isCallExpression(call) && createRequireSpecOf(lowerer, call)?.spec === "node:ffi";
|
|
456
|
+
}
|
|
431
457
|
/** True for `const fs = require("node:fs")` through a createRequire
|
|
432
458
|
* binding — a builtin namespace import in const clothing: alias
|
|
433
459
|
* plumbing with no storage (uses resolve through
|
|
@@ -455,8 +481,8 @@ export function createRequireProgramModuleOf(lowerer, expr) {
|
|
|
455
481
|
const cr = createRequireSpecOf(lowerer, call);
|
|
456
482
|
if (cr === null || cr.spec === null || canonicalBuiltinModule(cr.spec) !== null)
|
|
457
483
|
return null;
|
|
458
|
-
const dep = resolveImport(lowerer.program, cr.baseFile, cr.spec) ??
|
|
459
|
-
npmStaticDepSf7(lowerer.program, cr.baseFile, cr.spec);
|
|
484
|
+
const dep = resolveImport(lowerer.program, cr.baseFile, cr.spec, "require") ??
|
|
485
|
+
npmStaticDepSf7(lowerer.program, cr.baseFile, cr.spec, "require");
|
|
460
486
|
if (dep === null || dep.fileName.endsWith(".json"))
|
|
461
487
|
return null;
|
|
462
488
|
return { spec: cr.spec, baseFile: cr.baseFile, dep };
|
|
@@ -567,6 +593,9 @@ export function lowerCreateRequireCall(lowerer, call, loc) {
|
|
|
567
593
|
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
594
|
}
|
|
569
595
|
const spec = cr.spec;
|
|
596
|
+
if (spec === "node:ffi") {
|
|
597
|
+
return lowerFfiMemoryModule(lowerer, loc);
|
|
598
|
+
}
|
|
570
599
|
if (canonicalBuiltinModule(spec) !== null) {
|
|
571
600
|
lowerer.unsupported("SC1090", call, `module namespace objects as values (bind it first: const m = require("${spec}"), then access members through the binding)`);
|
|
572
601
|
}
|
|
@@ -585,7 +614,7 @@ export function lowerCreateRequireCall(lowerer, call, loc) {
|
|
|
585
614
|
// This probe marks frontend inputs unstable, but every branch
|
|
586
615
|
// here refuses compilation, so successful-build caches keep their
|
|
587
616
|
// existing dependency proofs.
|
|
588
|
-
const resolved = resolveRequireRuntime(cr.baseFile.fileName, spec, lowerer.targetPlatform);
|
|
617
|
+
const resolved = resolveRequireRuntime(cr.baseFile.fileName, spec, lowerer.targetPlatform, undefined, lowerer.frontendServices);
|
|
589
618
|
if (resolved.ok && resolved.value.endsWith(".node")) {
|
|
590
619
|
lowerer.pushDiag(nativeAddonDiag(spec, loc));
|
|
591
620
|
throw new PoisonError();
|
|
@@ -684,7 +713,7 @@ export function lowerImportMetaResolveCall(lowerer, call) {
|
|
|
684
713
|
if (specifier === null) {
|
|
685
714
|
lowerer.noLowering("import.meta.resolve with a runtime-computed specifier", call.arguments[0], "a compiled binary has a fixed module graph — pass a string literal");
|
|
686
715
|
}
|
|
687
|
-
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform);
|
|
716
|
+
const result = resolveImportMetaRuntime(call.getSourceFile().fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
688
717
|
if (result === null) {
|
|
689
718
|
lowerer.noLowering(`import.meta.resolve of '${specifier}'`, call, "relative paths, URL-like names, builtins, and installed package names are supported; package-import aliases remain unsupported");
|
|
690
719
|
}
|
|
@@ -697,7 +726,7 @@ function requireResolverBaseFile(lowerer, receiver) {
|
|
|
697
726
|
const created = createRequireCalleeFileOf(lowerer, receiver);
|
|
698
727
|
if (created !== null)
|
|
699
728
|
return created;
|
|
700
|
-
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile())
|
|
729
|
+
return lowerer.isStdlibGlobal(receiver, "require") && !isNodeEsmFile(receiver.getSourceFile(), lowerer.program)
|
|
701
730
|
? receiver.getSourceFile()
|
|
702
731
|
: null;
|
|
703
732
|
}
|
|
@@ -761,7 +790,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
761
790
|
}
|
|
762
791
|
const loc = locOf(call);
|
|
763
792
|
if (pathsCall) {
|
|
764
|
-
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform);
|
|
793
|
+
const result = requireResolvePathsRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, lowerer.frontendServices);
|
|
765
794
|
if (result !== null && !Array.isArray(result)) {
|
|
766
795
|
return runtimeResolveThrow(result, lowerer.irTypeOf(call), loc);
|
|
767
796
|
}
|
|
@@ -779,7 +808,7 @@ export function lowerRequireResolveCall(lowerer, call) {
|
|
|
779
808
|
if (paths === null) {
|
|
780
809
|
lowerer.noLowering("require.resolve with runtime-computed options", call.arguments[1], "omit options or pass { paths: [\"<static directory>\", ...] }");
|
|
781
810
|
}
|
|
782
|
-
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths);
|
|
811
|
+
const result = resolveRequireRuntime(baseFile.fileName, specifier, lowerer.targetPlatform, paths, lowerer.frontendServices);
|
|
783
812
|
return result.ok
|
|
784
813
|
? { kind: "strLit", value: result.value, type: STRING, loc }
|
|
785
814
|
: runtimeResolveThrow(result.error, STRING, loc);
|
|
@@ -861,6 +890,13 @@ function isPerfHooksPerformanceExpr(lowerer, node) {
|
|
|
861
890
|
}
|
|
862
891
|
return false;
|
|
863
892
|
}
|
|
893
|
+
/** Presence probes do not extract an unbound Performance method value. */
|
|
894
|
+
export function lowerPerfHooksTypeof(lowerer, expression) {
|
|
895
|
+
const value = isPerfHooksPerformanceExpr(lowerer, expression) ? "object" :
|
|
896
|
+
ts.isPropertyAccessExpression(expression) && !expression.questionDotToken && expression.name.text === "now" &&
|
|
897
|
+
isPerfHooksPerformanceExpr(lowerer, expression.expression) ? "function" : null;
|
|
898
|
+
return value === null ? null : { kind: "strLit", value, type: STRING, loc: locOf(expression) };
|
|
899
|
+
}
|
|
864
900
|
/** The node:perf_hooks spoke: `performance.now()` reads the runtime's
|
|
865
901
|
* monotonic clock anchored at process start — Node's timeOrigin for a
|
|
866
902
|
* compiled program, fractional milliseconds — and
|
|
@@ -1126,6 +1162,9 @@ export function lowerFsToUnixTimestampCall(lowerer, expr, bi, loc) {
|
|
|
1126
1162
|
* after every validation passes, exactly Node's order. Null when this
|
|
1127
1163
|
* is not a claimed member/shape (the table or fence path stands). */
|
|
1128
1164
|
export function lowerFsLadderCall(lowerer, expr, bi, loc) {
|
|
1165
|
+
if (bi.module === "fs" && bi.member !== "rename" && builtinModuleFnOf(lowerer, bi.module, bi.member)?.fn === "fs.callbackCall") {
|
|
1166
|
+
return lowerer.lowerBuiltinModuleCall(expr, bi, { fn: "fs.callbackCall", params: [], result: DYN }, loc);
|
|
1167
|
+
}
|
|
1129
1168
|
if (bi.module !== "fs" && bi.module !== "fs/promises")
|
|
1130
1169
|
return null;
|
|
1131
1170
|
if (!isJsSourceFile(expr.getSourceFile()))
|
|
@@ -1300,6 +1339,31 @@ function lowerZlibModuleCall(lowerer, expr, bi, loc) {
|
|
|
1300
1339
|
}
|
|
1301
1340
|
const syncFn = ZLIB_SYNC_FNS[bi.member];
|
|
1302
1341
|
if (syncFn !== undefined) {
|
|
1342
|
+
if (expr.arguments.length === 2 &&
|
|
1343
|
+
(bi.member === "deflateSync" || bi.member === "deflateRawSync" || bi.member === "gzipSync")) {
|
|
1344
|
+
const options = expr.arguments[1];
|
|
1345
|
+
// A literal level is enough for build-time compression in the native
|
|
1346
|
+
// emitters. Other options retain the explicit refusal: silently
|
|
1347
|
+
// dropping strategy/windowBits/dictionaries changes the wire bytes.
|
|
1348
|
+
if (ts.isObjectLiteralExpression(options) && options.properties.length === 1) {
|
|
1349
|
+
const prop = options.properties[0];
|
|
1350
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
1351
|
+
(ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name)) && prop.name.text === "level") {
|
|
1352
|
+
const value = prop.initializer;
|
|
1353
|
+
const level = ts.isNumericLiteral(value) ? Number(value.text)
|
|
1354
|
+
: ts.isPrefixUnaryExpression(value) && value.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(value.operand)
|
|
1355
|
+
? -Number(value.operand.text) : NaN;
|
|
1356
|
+
if (Number.isInteger(level) && level >= -1 && level <= 9) {
|
|
1357
|
+
return {
|
|
1358
|
+
kind: "libCall", fn: "zlib.deflateLevelSync",
|
|
1359
|
+
args: [zlibInputBytes(lowerer, expr.arguments[0], loc), numLit(bi.member === "deflateSync" ? 0 : bi.member === "deflateRawSync" ? 1 : 2, loc), numLit(level, loc)],
|
|
1360
|
+
type: BYTES_U8, loc,
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
lowerer.noLowering(`${bi.member} with these options`, options, "the static compression options form is { level: <integer literal from -1 through 9> }");
|
|
1366
|
+
}
|
|
1303
1367
|
if (expr.arguments.length !== 1) {
|
|
1304
1368
|
const site = expr.arguments[1] ?? expr;
|
|
1305
1369
|
lowerer.noLowering(`${bi.member} with explicit options`, site, `${bi.member}(data) with Node's default options is supported`);
|
|
@@ -1350,6 +1414,12 @@ function lowerZlibModuleCall(lowerer, expr, bi, loc) {
|
|
|
1350
1414
|
}
|
|
1351
1415
|
export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
1352
1416
|
const name = expr.expression.getText();
|
|
1417
|
+
if (fn.fn === "fs.callbackCall" && bi.member !== "rename") {
|
|
1418
|
+
if (expr.arguments.some(ts.isSpreadElement))
|
|
1419
|
+
lowerer.noLowering("filesystem callback call with spread arguments", expr);
|
|
1420
|
+
const args = { kind: "dynArrLit", elems: expr.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), type: DYN, loc };
|
|
1421
|
+
return { kind: "libCall", fn: "fs.callbackCall", args: [{ kind: "strLit", value: bi.member, type: STRING, loc }, args], type: DYN, loc };
|
|
1422
|
+
}
|
|
1353
1423
|
// Numeric open flags are interpreted symbolically at the call site. The
|
|
1354
1424
|
// O_* bit values differ between Darwin and Linux, so emit a stable mask
|
|
1355
1425
|
// and let the target runtime select its own native constants.
|
|
@@ -1979,15 +2049,21 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
1979
2049
|
: { kind: "numLit", value: 0, type: F64, loc };
|
|
1980
2050
|
return { kind: "libCall", fn: "fs.accessSync", args: [path, mode], type: VOID, loc };
|
|
1981
2051
|
}
|
|
1982
|
-
if (bi.module === "fs" && bi.member === "writeFileSync" && expr.arguments.length === 2) {
|
|
2052
|
+
if (bi.module === "fs" && (bi.member === "writeFileSync" || bi.member === "appendFileSync") && expr.arguments.length === 2) {
|
|
1983
2053
|
const dataIr = lowerer.mapTypeOf(lowerer.typeOf(expr.arguments[1]));
|
|
2054
|
+
if (dataIr?.kind === "union") {
|
|
2055
|
+
const arms = lowerer.unions.get(dataIr.unionId)?.arms;
|
|
2056
|
+
if (arms && arms.every((arm) => arm.kind === "string" || (arm.kind === "bytes" && arm.elem === "u8"))) {
|
|
2057
|
+
return lowerStringOrBytesWrite(lowerer, expr, dataIr, arms, bi.member === "appendFileSync");
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
1984
2060
|
if (dataIr?.kind === "bytes") {
|
|
1985
2061
|
if (dataIr.elem !== "u8") {
|
|
1986
|
-
lowerer.noLowering(
|
|
2062
|
+
lowerer.noLowering(`${bi.member} of '${lowerer.fmt(dataIr)}' data`, expr.arguments[1], "byte writes take Uint8Array/Buffer data");
|
|
1987
2063
|
}
|
|
1988
2064
|
const path = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
1989
2065
|
const data = lowerer.lowerExprExpecting(expr.arguments[1], BYTES_U8);
|
|
1990
|
-
return { kind: "libCall", fn: "fs.writeFileSyncBytes", args: [path, data], type: VOID, loc };
|
|
2066
|
+
return { kind: "libCall", fn: bi.member === "appendFileSync" ? "fs.appendFileSyncBytes" : "fs.writeFileSyncBytes", args: [path, data], type: VOID, loc };
|
|
1991
2067
|
}
|
|
1992
2068
|
}
|
|
1993
2069
|
// writeFileSync(p, data, options) / fs.promises.writeFile(p, data,
|
|
@@ -2145,6 +2221,27 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2145
2221
|
}
|
|
2146
2222
|
const required = fn.params.length - (fn.defaults?.length ?? 0);
|
|
2147
2223
|
const hasSpread = expr.arguments.some(ts.isSpreadElement);
|
|
2224
|
+
if (!hasSpread && bi.module === "url" && bi.member === "pathToFileURL" && expr.arguments.length === 2) {
|
|
2225
|
+
let options = expr.arguments[1];
|
|
2226
|
+
while (ts.isParenthesizedExpression(options) || ts.isSatisfiesExpression(options))
|
|
2227
|
+
options = options.expression;
|
|
2228
|
+
if (!ts.isObjectLiteralExpression(options) || options.properties.length > 1) {
|
|
2229
|
+
lowerer.noLowering("pathToFileURL with these options", options, "use a literal { windows: boolean } options object");
|
|
2230
|
+
}
|
|
2231
|
+
let windowsNode = null;
|
|
2232
|
+
const property = options.properties[0];
|
|
2233
|
+
if (property) {
|
|
2234
|
+
if ((!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) ||
|
|
2235
|
+
(!ts.isIdentifier(property.name) && !ts.isStringLiteral(property.name)) || property.name.text !== "windows") {
|
|
2236
|
+
lowerer.noLowering("pathToFileURL with these options", property, "use a literal { windows: boolean } options object");
|
|
2237
|
+
}
|
|
2238
|
+
windowsNode = ts.isPropertyAssignment(property) ? property.initializer : property.name;
|
|
2239
|
+
}
|
|
2240
|
+
const path = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
2241
|
+
const defaultWindows = { kind: "boolLit", value: lowerer.targetPlatform === "win32", type: BOOL, loc };
|
|
2242
|
+
const windows = windowsNode ? lowerOptionalArgument(lowerer, windowsNode, BOOL, defaultWindows) : defaultWindows;
|
|
2243
|
+
return { kind: "libCall", fn: "url.pathToFileURLPlatform", args: [path, windows], type: fn.result, loc };
|
|
2244
|
+
}
|
|
2148
2245
|
if (hasSpread && bi.module === "url" && bi.member === "fileURLToPath") {
|
|
2149
2246
|
lowerer.noLowering("fileURLToPath with spread arguments", expr, "call fileURLToPath(value) directly so the URL-or-string overload remains statically visible");
|
|
2150
2247
|
}
|
|
@@ -2164,6 +2261,8 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2164
2261
|
// undefined, ...) must narrow first, like everywhere else.
|
|
2165
2262
|
const argNode = expr.arguments[0];
|
|
2166
2263
|
const arg = lowerer.lowerExpr(argNode);
|
|
2264
|
+
if (arg.type.kind === "dyn")
|
|
2265
|
+
return { kind: "libCall", fn: "url.fileURLToPathChecked", args: [arg], type: STRING, loc };
|
|
2167
2266
|
if (arg.type.kind === "url") {
|
|
2168
2267
|
return { kind: "libCall", fn: "url.fileURLToPathUrl", args: [arg], type: STRING, loc };
|
|
2169
2268
|
}
|
|
@@ -2229,15 +2328,20 @@ export function lowerBuiltinModuleCall(lowerer, expr, bi, fn, loc) {
|
|
|
2229
2328
|
}
|
|
2230
2329
|
return { kind: "libCall", fn: fn.fn, args, type: fn.result, loc };
|
|
2231
2330
|
}
|
|
2232
|
-
/** Reflect.
|
|
2331
|
+
/** Reflect.ownKeys uses native computed-key reflection. Reflect.apply(target,
|
|
2332
|
+
* thisArg, argsList) where the TARGET is a builtin
|
|
2233
2333
|
* rest-parameter table fn (path.join / path.resolve — test/common
|
|
2234
2334
|
* fixtures.js's fixturesPath forwards its rest args exactly this way):
|
|
2235
2335
|
* the packed libCall over a validated string[] extraction of argsList.
|
|
2236
2336
|
* The builtins ignore the receiver, so thisArg must be an effect-free
|
|
2237
2337
|
* spelling (`this`, an identifier, a unit literal) whose dropped
|
|
2238
2338
|
* evaluation is unobservable; every other Reflect.apply keeps the
|
|
2239
|
-
* fence. Null when this isn't a Reflect
|
|
2240
|
-
export function
|
|
2339
|
+
* fence. Null when this isn't a supported Reflect call. */
|
|
2340
|
+
export function lowerReflectCall(lowerer, call, access) {
|
|
2341
|
+
if (!call.questionDotToken && !access.questionDotToken && lowerer.stdlibGlobalMember(access, "Reflect") === "ownKeys" &&
|
|
2342
|
+
call.arguments.length === 1 && !ts.isSpreadElement(call.arguments[0])) {
|
|
2343
|
+
return { kind: "libCall", fn: "dyn.ownKeys", args: [lowerer.lowerExprExpecting(call.arguments[0], DYN)], type: DYN, loc: locOf(call) };
|
|
2344
|
+
}
|
|
2241
2345
|
if (call.questionDotToken)
|
|
2242
2346
|
return null;
|
|
2243
2347
|
if (lowerer.stdlibGlobalMember(access, "Reflect") !== "apply")
|
|
@@ -2251,7 +2355,10 @@ export function lowerReflectApplyCall(lowerer, call, access) {
|
|
|
2251
2355
|
const bi = ts.isPropertyAccessExpression(targetNode) ? lowerer.builtinMemberOf(targetNode) : null;
|
|
2252
2356
|
const fn = bi ? builtinModuleFnOf(lowerer, bi.module, bi.member) : null;
|
|
2253
2357
|
if (!fn || fn.variadicPack !== true) {
|
|
2254
|
-
|
|
2358
|
+
const target = lowerer.lowerExprExpecting(targetNode, DYN);
|
|
2359
|
+
const receiver = lowerer.lowerExprExpecting(call.arguments[1], DYN);
|
|
2360
|
+
const argumentsList = lowerer.lowerExprExpecting(call.arguments[2], DYN);
|
|
2361
|
+
return { kind: "libCall", fn: "dyn.reflectApply", args: [target, receiver, argumentsList], type: DYN, loc };
|
|
2255
2362
|
}
|
|
2256
2363
|
const thisNode = call.arguments[1];
|
|
2257
2364
|
const effectFree = thisNode.kind === ts.SyntaxKind.ThisKeyword ||
|
|
@@ -2435,8 +2542,8 @@ export function lowerSpawnSyncCall(lowerer, expr, loc) {
|
|
|
2435
2542
|
};
|
|
2436
2543
|
}
|
|
2437
2544
|
/** `spawn(command, args?, options)` → one cp.spawn / cp.spawnOpts
|
|
2438
|
-
* libCall.
|
|
2439
|
-
*
|
|
2545
|
+
* libCall. Computed options use native runtime normalization. Inline
|
|
2546
|
+
* stdio accepts "ignore", "inherit", or "pipe" as the scalar,
|
|
2440
2547
|
* or the 3-tuple whose stdin pipe becomes child.stdin, stdout/stderr
|
|
2441
2548
|
* pipes become child.stdout/child.stderr, and output slots may also be
|
|
2442
2549
|
* number fds. Omitting stdio uses Node's default: all three piped. The
|
|
@@ -2470,7 +2577,11 @@ export function lowerSpawnCall(lowerer, expr, loc) {
|
|
|
2470
2577
|
optsNode = second;
|
|
2471
2578
|
}
|
|
2472
2579
|
if (optsNode !== undefined && !ts.isObjectLiteralExpression(optsNode)) {
|
|
2473
|
-
|
|
2580
|
+
return {
|
|
2581
|
+
kind: "libCall", fn: "cp.spawnDynamic",
|
|
2582
|
+
args: [cmd, lowerer.lowerChildArgsArg(argsNode, loc), lowerer.lowerExprExpecting(optsNode, DYN)],
|
|
2583
|
+
type: CHILD_T, loc,
|
|
2584
|
+
};
|
|
2474
2585
|
}
|
|
2475
2586
|
const emptyStr = { kind: "strLit", value: "", type: STRING, loc };
|
|
2476
2587
|
// Per-slot stdio modes (scr_child.c: 0 ignore, 1 inherit, 2 fd) and
|
|
@@ -3813,20 +3924,20 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3813
3924
|
const loc = locOf(call);
|
|
3814
3925
|
if (name === "getStore" && call.arguments.length === 0) {
|
|
3815
3926
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3816
|
-
return { kind: "libCall", fn: "als.get", args: [receiver], type: DYN, loc };
|
|
3927
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.get", args: [receiver], type: DYN, loc });
|
|
3817
3928
|
}
|
|
3818
3929
|
if (name === "run" && call.arguments.length >= 2) {
|
|
3819
3930
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3820
3931
|
const value = dcMessageArg(lowerer, call.arguments[0]);
|
|
3821
3932
|
const fn = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
3822
3933
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(2), loc);
|
|
3823
|
-
return { kind: "libCall", fn: "als.run", args: [receiver, value, fn, rest], type: DYN, loc };
|
|
3934
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.run", args: [receiver, value, fn, rest], type: DYN, loc });
|
|
3824
3935
|
}
|
|
3825
3936
|
if (name === "exit" && call.arguments.length >= 1) {
|
|
3826
3937
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
3827
3938
|
const fn = dcSubscriberArg(lowerer, call.arguments[0]);
|
|
3828
3939
|
const rest = dcTraceArgsArr(lowerer, call.arguments.slice(1), loc);
|
|
3829
|
-
return { kind: "libCall", fn: "als.exitRun", args: [receiver, fn, rest], type: DYN, loc };
|
|
3940
|
+
return alsTypedResult(lowerer, call, { kind: "libCall", fn: "als.exitRun", args: [receiver, fn, rest], type: DYN, loc });
|
|
3830
3941
|
}
|
|
3831
3942
|
if (name === "enterWith" && call.arguments.length === 1) {
|
|
3832
3943
|
const receiver = lowerer.lowerExprExpecting(access.expression, F64);
|
|
@@ -3839,6 +3950,18 @@ export function lowerAlsMethodCall(lowerer, call, access) {
|
|
|
3839
3950
|
}
|
|
3840
3951
|
lowerer.noLowering(`AsyncLocalStorage.${name}`, call, "run(store, fn, ...args), exit(fn, ...args), getStore(), enterWith(store), and disable() are the supported AsyncLocalStorage members", lowerer.checker.getSymbolAtLocation(access.name));
|
|
3841
3952
|
}
|
|
3953
|
+
/** The runtime carries a tagged value, while a typed ALS call promises
|
|
3954
|
+
* its generic store/callback result. Convert at that boundary so inferred
|
|
3955
|
+
* locals and immediate method calls share the same checked representation.
|
|
3956
|
+
* Untyped JS and unknown stores keep the original dynamic value. */
|
|
3957
|
+
function alsTypedResult(lowerer, call, value) {
|
|
3958
|
+
const expected = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
3959
|
+
// Promises already use the runtime's dynamic async path; unlike class
|
|
3960
|
+
// capsules, boxed typed promises do not have a checked extraction ABI.
|
|
3961
|
+
if (!expected || expected.kind === "dyn" || expected.kind === "void" || expected.kind === "promise")
|
|
3962
|
+
return value;
|
|
3963
|
+
return lowerer.coerceInto(call, value, expected);
|
|
3964
|
+
}
|
|
3842
3965
|
/** Property reads on Channel receivers: `.name` (the registration
|
|
3843
3966
|
* string) and `.hasSubscribers` (the publish guard). Null for
|
|
3844
3967
|
* non-Channel receivers and other members (the method fence owns them). */
|
|
@@ -4184,23 +4307,11 @@ export function strdecHelper(lowerer, op, shapeId, loc) {
|
|
|
4184
4307
|
lowerer.liftedFns.push({ name, params, returnType: STRING, locals, body, loc });
|
|
4185
4308
|
return name;
|
|
4186
4309
|
}
|
|
4187
|
-
/**
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
* - stringify → the type-DIRECTED `jsonStringify` node: the lib
|
|
4193
|
-
* signature honestly says `any`, but lowering requires the argument's
|
|
4194
|
-
* STATIC IR type to be JSON-safe — the backend emits a per-type
|
|
4195
|
-
* serializer, never a dynamic walk, so dyn (and closures/class
|
|
4196
|
-
* instances) are rejected here with a specific message. The
|
|
4197
|
-
* `stringify(v, null, space)` pretty-print form compiles when the
|
|
4198
|
-
* replacer is the literal null (or undefined) and the space is a
|
|
4199
|
-
* LITERAL — Node's rules apply at compile time (numbers clamp to 0–10
|
|
4200
|
-
* spaces, strings truncate to 10 code units) and the resolved indent
|
|
4201
|
-
* rides the node to the backend's re-indenter. Function replacers and
|
|
4202
|
-
* non-literal spaces stay fenced.
|
|
4203
|
-
* Null when this isn't a JSON member call. */
|
|
4310
|
+
/** JSON parse produces checked-dynamic data; a native reviver walks it
|
|
4311
|
+
* bottom-up before any checked cast. Stringify without a callback keeps
|
|
4312
|
+
* its type-directed fast path. A function replacer boxes the input and
|
|
4313
|
+
* walks it before primitive normalization. Both paths share literal gap
|
|
4314
|
+
* rules, and callback failures use ordinary native exception unwinding. */
|
|
4204
4315
|
export function lowerJsonMethodCall(lowerer, call, access) {
|
|
4205
4316
|
if (call.questionDotToken)
|
|
4206
4317
|
return null;
|
|
@@ -4208,23 +4319,102 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4208
4319
|
if (member === null)
|
|
4209
4320
|
return null;
|
|
4210
4321
|
const loc = locOf(call);
|
|
4211
|
-
if (member === "parse" && call.arguments.length
|
|
4212
|
-
|
|
4322
|
+
if ((member === "parse" && (call.arguments.length < 1 || call.arguments.length > 2)) ||
|
|
4323
|
+
(member === "stringify" && call.arguments.length > 3) ||
|
|
4324
|
+
call.arguments.some(ts.isSpreadElement)) {
|
|
4325
|
+
lowerer.noLowering(`JSON.${member} with extra or spread arguments`, call, "pass the JSON arguments explicitly");
|
|
4213
4326
|
}
|
|
4214
4327
|
if (member === "parse") {
|
|
4215
4328
|
const text = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
4216
|
-
|
|
4329
|
+
const reviver = call.arguments[1];
|
|
4330
|
+
if (!reviver || jsonNullishArgument(lowerer, reviver)) {
|
|
4331
|
+
return { kind: "libCall", fn: "json.parse", args: [text], type: DYN, loc };
|
|
4332
|
+
}
|
|
4333
|
+
const callback = lowerJsonCallback(lowerer, reviver, "reviver");
|
|
4334
|
+
return { kind: "libCall", fn: "json.parseReviver", args: [text, callback], type: DYN, loc };
|
|
4217
4335
|
}
|
|
4218
4336
|
if (member === "stringify") {
|
|
4337
|
+
const replacerNode = call.arguments[1];
|
|
4338
|
+
const spaceNode = call.arguments[2];
|
|
4339
|
+
const runtimeOptions = replacerNode && !jsonNullishArgument(lowerer, replacerNode) &&
|
|
4340
|
+
lowerer.mapTypeOf(lowerer.typeOf(replacerNode))?.kind === "dyn" ||
|
|
4341
|
+
spaceNode && !jsonNullishArgument(lowerer, spaceNode) &&
|
|
4342
|
+
!ts.isNumericLiteral(spaceNode) && !ts.isStringLiteral(spaceNode) && !ts.isNoSubstitutionTemplateLiteral(spaceNode) &&
|
|
4343
|
+
!(ts.isPrefixUnaryExpression(spaceNode) && ts.isNumericLiteral(spaceNode.operand));
|
|
4344
|
+
if (runtimeOptions && call.arguments[0]) {
|
|
4345
|
+
const args = [0, 1, 2].map((index) => call.arguments[index]
|
|
4346
|
+
? lowerer.lowerExprExpecting(call.arguments[index], DYN) : dynUndefinedExpr(loc));
|
|
4347
|
+
return { kind: "libCall", fn: "json.stringifyValue", args, type: DYN, loc };
|
|
4348
|
+
}
|
|
4219
4349
|
const indent = stringifySpaceIndent(lowerer, call);
|
|
4220
4350
|
if (call.arguments.length === 0) {
|
|
4221
4351
|
return lowerer.wrappedUndefined(lowerer.withUndefinedArm(STRING), loc);
|
|
4222
4352
|
}
|
|
4223
4353
|
const argNode = call.arguments[0];
|
|
4224
|
-
|
|
4354
|
+
let value = lowerer.lowerExpr(argNode);
|
|
4355
|
+
// Optional Map/array reads and partially narrowed unions keep their
|
|
4356
|
+
// storage representation when lowered as ordinary arguments. Select
|
|
4357
|
+
// the JSON walker from the proven use-site type, using a checked
|
|
4358
|
+
// conversion so a stale capture cannot read an impossible payload.
|
|
4359
|
+
// Optional strings have a serializer that preserves a missing root;
|
|
4360
|
+
// an unchecked array read can still be absent despite its checker type.
|
|
4361
|
+
if (value.type.kind === "union" && optionalStringTags(lowerer, value.type) === null) {
|
|
4362
|
+
const narrowed = lowerer.mapTypeOf(lowerer.typeOf(argNode));
|
|
4363
|
+
if (narrowed && !isUnitType(narrowed) && narrowed.kind !== "void") {
|
|
4364
|
+
const helper = narrowed.kind === "union"
|
|
4365
|
+
? lowerer.narrowedRetagHelper(argNode, value.type.unionId, narrowed.unionId, loc)
|
|
4366
|
+
: lowerer.narrowedArmHelper(value.type.unionId, narrowed, loc);
|
|
4367
|
+
if (helper)
|
|
4368
|
+
value = { kind: "call", callee: helper, args: [value], type: narrowed, loc };
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
const replacer = call.arguments[1];
|
|
4372
|
+
if (replacer && !jsonNullishArgument(lowerer, replacer)) {
|
|
4373
|
+
const callback = lowerJsonCallback(lowerer, replacer, "replacer");
|
|
4374
|
+
if (value.type.kind === "undefinedT" || value.type.kind === "nullT")
|
|
4375
|
+
value = lowerer.coerceToExpected(value, DYN);
|
|
4376
|
+
// Evaluate the original arguments before taking a typed snapshot.
|
|
4377
|
+
// Creating the callback can itself mutate the input object.
|
|
4378
|
+
const inputSlot = lowerer.declareHiddenLocal("%jsonInput", value.type);
|
|
4379
|
+
const callbackSlot = lowerer.declareHiddenLocal("%jsonCallback", DYN);
|
|
4380
|
+
const boxed = lowerer.coerceToExpected(varRef(inputSlot.id, value.type, loc), DYN);
|
|
4381
|
+
if (boxed.type.kind !== "dyn") {
|
|
4382
|
+
lowerer.unsupported("SC1090", argNode, `JSON.stringify callback input of type '${lowerer.fmt(value.type)}' (the value must cross the checked-dynamic boundary)`);
|
|
4383
|
+
}
|
|
4384
|
+
const raw = {
|
|
4385
|
+
kind: "libCall", fn: "json.stringifyReplacer",
|
|
4386
|
+
args: [boxed, varRef(callbackSlot.id, DYN, loc), { kind: "strLit", value: indent, type: STRING, loc }],
|
|
4387
|
+
type: DYN, loc,
|
|
4388
|
+
};
|
|
4389
|
+
// A replacer can omit even the root. Preserve actual undefined;
|
|
4390
|
+
// an inferred binding adopts this union, while a required string
|
|
4391
|
+
// consumer uses the ordinary checked optional-value boundary.
|
|
4392
|
+
const result = { kind: "dynCheck", value: raw, type: lowerer.withUndefinedArm(STRING), loc };
|
|
4393
|
+
return {
|
|
4394
|
+
kind: "seqExpr", stmts: [
|
|
4395
|
+
{ kind: "varDecl", localId: inputSlot.id, init: value, loc },
|
|
4396
|
+
{ kind: "varDecl", localId: callbackSlot.id, init: callback, loc },
|
|
4397
|
+
], result, type: result.type, loc,
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4225
4400
|
const optionalString = lowerOptionalStringifyRoot(lowerer, value, indent, loc);
|
|
4226
4401
|
if (optionalString)
|
|
4227
4402
|
return optionalString;
|
|
4403
|
+
if (value.type.kind === "dyn" || isJsonStringifyDynamicType(value.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4404
|
+
// Keep the original containers live while the runtime visits them:
|
|
4405
|
+
// a toJSON callback can mutate a later field, and shared/cyclic
|
|
4406
|
+
// references must retain their identities throughout traversal.
|
|
4407
|
+
const boxed = value.type.kind === "dyn" ? value : { kind: "dynFrom", value, liveRef: true, type: DYN, loc };
|
|
4408
|
+
const raw = {
|
|
4409
|
+
kind: "libCall", fn: "json.stringifyReplacer",
|
|
4410
|
+
args: [boxed, dynUndefinedExpr(loc), { kind: "strLit", value: indent, type: STRING, loc }],
|
|
4411
|
+
type: DYN, loc,
|
|
4412
|
+
};
|
|
4413
|
+
// Preserve the existing dyn-root string ABI, including its textual
|
|
4414
|
+
// "undefined" result, while letting the runtime honor toJSON hooks.
|
|
4415
|
+
return value.type.kind === "dyn" ? { kind: "toString", operand: raw, type: STRING, loc }
|
|
4416
|
+
: { kind: "dynCheck", value: raw, type: lowerer.withUndefinedArm(STRING), loc };
|
|
4417
|
+
}
|
|
4228
4418
|
// An ISLAND value (`JSON.stringify(err)` on a package handle — the
|
|
4229
4419
|
// island error-inspection idiom): the ENGINE's own JSON.stringify
|
|
4230
4420
|
// runs, so key order, nesting, toJSON, and getters match Node by
|
|
@@ -4244,17 +4434,7 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4244
4434
|
const raw = { kind: "jsOp", op: "callMethod", name: "stringify", args, type: JSVAL, loc };
|
|
4245
4435
|
return { kind: "jsOp", op: "toStr", args: [raw], type: STRING, loc };
|
|
4246
4436
|
}
|
|
4247
|
-
|
|
4248
|
-
// `object` slots, the JSON.parse round-trip) serializes with the
|
|
4249
|
-
// runtime's dyn walker instead of a type-directed serializer — the
|
|
4250
|
-
// dyn is JSON-representable by construction (non-JSON values fenced
|
|
4251
|
-
// at their conversion INTO the slot). Two edges, both documented:
|
|
4252
|
-
// a root the stringify drops (runtime undefined) produces the TEXT
|
|
4253
|
-
// "undefined" where Node produces the undefined VALUE (tsc's own lib
|
|
4254
|
-
// types the return `string`, so no static consumer can tell), and a
|
|
4255
|
-
// runtime handle inside the tree throws (Node would walk its own
|
|
4256
|
-
// enumerable props, which the handle does not model).
|
|
4257
|
-
if (!lowerer.jsonStringifySafe(value.type) && value.type.kind !== "dyn") {
|
|
4437
|
+
if (!lowerer.jsonStringifySafe(value.type)) {
|
|
4258
4438
|
// Bare undefined-armed unions get their own wording: Node's
|
|
4259
4439
|
// stringify of bare undefined is not a string at all — per-type
|
|
4260
4440
|
// serialization cannot match that exactly, so the fence is
|
|
@@ -4271,16 +4451,47 @@ export function lowerJsonMethodCall(lowerer, call, access) {
|
|
|
4271
4451
|
`(only number, string, boolean, records, arrays, unions of those, and 'unknown' stringify)`);
|
|
4272
4452
|
}
|
|
4273
4453
|
const node = { kind: "jsonStringify", value, type: STRING, loc };
|
|
4274
|
-
if (indent !== "")
|
|
4275
|
-
// The compile-time-resolved indent rides as an extra property (the
|
|
4276
|
-
// node shape in ir/ir.ts is unchanged); the backend re-indents
|
|
4277
|
-
// the compact serializer output with Node's gap algorithm.
|
|
4454
|
+
if (indent !== "")
|
|
4278
4455
|
node.indent = indent;
|
|
4279
|
-
}
|
|
4280
4456
|
return node;
|
|
4281
4457
|
}
|
|
4282
4458
|
return null; // unknown members are tsc errors before lowering
|
|
4283
4459
|
}
|
|
4460
|
+
/** A valid string/byte overload must select its runtime entry from the live
|
|
4461
|
+
* union tag. Coercing the whole argument to the string overload loses bytes. */
|
|
4462
|
+
function lowerStringOrBytesWrite(lowerer, call, dataType, arms, append) {
|
|
4463
|
+
const loc = locOf(call);
|
|
4464
|
+
const key = `fs.${append ? "append" : "write"}:${dataType.unionId}`;
|
|
4465
|
+
let helper = lowerer.widthHelpers.get(key);
|
|
4466
|
+
if (!helper) {
|
|
4467
|
+
helper = `%fs.writeData.${lowerer.widthHelpers.size}`;
|
|
4468
|
+
lowerer.widthHelpers.set(key, helper);
|
|
4469
|
+
const body = [];
|
|
4470
|
+
for (let tag = 0; tag < arms.length; tag++) {
|
|
4471
|
+
const arm = arms[tag];
|
|
4472
|
+
const fn = arm.kind === "bytes"
|
|
4473
|
+
? append ? "fs.appendFileSyncBytes" : "fs.writeFileSyncBytes"
|
|
4474
|
+
: append ? "fs.appendFileSync" : "fs.writeFileSync";
|
|
4475
|
+
body.push({ kind: "if", loc,
|
|
4476
|
+
cond: { kind: "unionIsTag", unionId: dataType.unionId, tag, negated: false,
|
|
4477
|
+
value: varRef("data.0", dataType, loc), type: BOOL, loc },
|
|
4478
|
+
then: [
|
|
4479
|
+
{ kind: "exprStmt", expr: { kind: "libCall", fn, args: [varRef("path.0", STRING, loc),
|
|
4480
|
+
{ kind: "unionNarrow", unionId: dataType.unionId, tag, value: varRef("data.0", dataType, loc), type: arm, loc }], type: VOID, loc }, loc },
|
|
4481
|
+
{ kind: "return", value: null, loc },
|
|
4482
|
+
], else_: null,
|
|
4483
|
+
});
|
|
4484
|
+
}
|
|
4485
|
+
body.push({ kind: "return", value: null, loc });
|
|
4486
|
+
lowerer.liftedFns.push({ name: helper, returnType: VOID, loc,
|
|
4487
|
+
params: [{ localId: "path.0", name: "path", type: STRING }, { localId: "data.0", name: "data", type: dataType }],
|
|
4488
|
+
locals: [{ id: "path.0", name: "path", type: STRING, mutable: false }, { id: "data.0", name: "data", type: dataType, mutable: false }],
|
|
4489
|
+
body,
|
|
4490
|
+
});
|
|
4491
|
+
}
|
|
4492
|
+
return { kind: "call", callee: helper, args: [lowerer.lowerExprExpecting(call.arguments[0], STRING),
|
|
4493
|
+
lowerer.lowerExprExpecting(call.arguments[1], dataType)], type: VOID, loc };
|
|
4494
|
+
}
|
|
4284
4495
|
function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
4285
4496
|
const tags = optionalStringTags(lowerer, value.type);
|
|
4286
4497
|
if (!tags || value.type.kind !== "union")
|
|
@@ -4323,22 +4534,43 @@ function lowerOptionalStringifyRoot(lowerer, value, indent, loc) {
|
|
|
4323
4534
|
}
|
|
4324
4535
|
return { kind: "call", callee: helper, args: [value], type: resultT, loc };
|
|
4325
4536
|
}
|
|
4326
|
-
/**
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4537
|
+
/** Only explicit null/undefined select the no-callback path. */
|
|
4538
|
+
function jsonNullishArgument(lowerer, node) {
|
|
4539
|
+
if (ts.isParenthesizedExpression(node))
|
|
4540
|
+
return jsonNullishArgument(lowerer, node.expression);
|
|
4541
|
+
if (node.kind === ts.SyntaxKind.NullKeyword)
|
|
4542
|
+
return true;
|
|
4543
|
+
if (!ts.isIdentifier(node) || node.text !== "undefined")
|
|
4544
|
+
return false;
|
|
4545
|
+
const symbol = lowerer.checker.getSymbolAtLocation(node);
|
|
4546
|
+
return symbol !== undefined && lowerer.checker.declarationsOf(symbol).every((decl) => lowerer.isStdlibFile(decl.getSourceFile()));
|
|
4547
|
+
}
|
|
4548
|
+
/** JSON callbacks cross the same checked native function boundary as other
|
|
4549
|
+
* runtime callbacks. Reviver source contexts need parser source tracking;
|
|
4550
|
+
* refuse signatures that request one until that protocol is implemented. */
|
|
4551
|
+
function lowerJsonCallback(lowerer, node, role) {
|
|
4552
|
+
const callback = lowerer.lowerExpr(node);
|
|
4553
|
+
if (callback.type.kind === "dyn")
|
|
4554
|
+
return callback;
|
|
4555
|
+
if (callback.type.kind === "union" && lowerer.dynConvertible(callback.type) &&
|
|
4556
|
+
lowerer.unions.get(callback.type.unionId)?.arms.every((arm) => isUnitType(arm) || arm.kind === "func" &&
|
|
4557
|
+
arm.params.length <= 2 && (role !== "reviver" || (!arm.rest && !arm.argumentsAll))))
|
|
4558
|
+
return lowerer.coerceToExpected(callback, DYN);
|
|
4559
|
+
if (callback.type.kind === "func" && callback.type.params.length <= 2 &&
|
|
4560
|
+
(role !== "reviver" || (!callback.type.rest && !callback.type.argumentsAll)) &&
|
|
4561
|
+
canBoxFuncIntoDyn(callback.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4562
|
+
return { kind: "dynFrom", value: callback, type: DYN, loc: locOf(node) };
|
|
4563
|
+
}
|
|
4564
|
+
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");
|
|
4565
|
+
}
|
|
4566
|
+
/** Compile-time Node gap rules: numbers clamp to 0–10 spaces and strings
|
|
4567
|
+
* truncate to ten UTF-16 code units. Callback validation is independent. */
|
|
4333
4568
|
function stringifySpaceIndent(lowerer, call) {
|
|
4334
4569
|
const fence = () => lowerer.noLowering("JSON.stringify with replacer/space parameters", call, "the serializer is type-directed — shape the value before stringifying");
|
|
4335
4570
|
if (call.arguments.length <= 1)
|
|
4336
4571
|
return "";
|
|
4337
4572
|
const unwrap = (e) => ts.isParenthesizedExpression(e) ? unwrap(e.expression) : e;
|
|
4338
|
-
const isUndefined = (e) =>
|
|
4339
|
-
const replacer = unwrap(call.arguments[1]);
|
|
4340
|
-
if (replacer.kind !== ts.SyntaxKind.NullKeyword && !isUndefined(replacer))
|
|
4341
|
-
fence();
|
|
4573
|
+
const isUndefined = (e) => jsonNullishArgument(lowerer, e);
|
|
4342
4574
|
if (call.arguments.length === 2)
|
|
4343
4575
|
return "";
|
|
4344
4576
|
const space = unwrap(call.arguments[2]);
|
|
@@ -4381,6 +4613,8 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4381
4613
|
if (ts.isVariableDeclaration(varDecl) && varDecl.initializer !== undefined) {
|
|
4382
4614
|
const spec = requireSpecOf(varDecl.initializer);
|
|
4383
4615
|
if (spec !== null) {
|
|
4616
|
+
if (isNativeFfiRequire(lowerer, varDecl.initializer))
|
|
4617
|
+
return null;
|
|
4384
4618
|
const isBuiltin = spec.startsWith("node:") || builtinModules.includes(spec);
|
|
4385
4619
|
return isBuiltin && canonicalBuiltinModule(spec) === null ? spec : null;
|
|
4386
4620
|
}
|
|
@@ -4388,9 +4622,9 @@ export function fencedBuiltinImportOf(lowerer, ident) {
|
|
|
4388
4622
|
}
|
|
4389
4623
|
let importDecl;
|
|
4390
4624
|
if (ts.isImportSpecifier(decl))
|
|
4391
|
-
importDecl = decl.parent
|
|
4625
|
+
importDecl = decl.parent?.parent?.parent;
|
|
4392
4626
|
else if (ts.isNamespaceImport(decl))
|
|
4393
|
-
importDecl = decl.parent
|
|
4627
|
+
importDecl = decl.parent?.parent;
|
|
4394
4628
|
else if (ts.isImportClause(decl))
|
|
4395
4629
|
importDecl = decl.parent;
|
|
4396
4630
|
else
|
|
@@ -4765,6 +4999,9 @@ export function lowerSearchParamsNew(lowerer, expr, loc) {
|
|
|
4765
4999
|
return acc;
|
|
4766
5000
|
}
|
|
4767
5001
|
const init = lowerer.lowerExpr(arg);
|
|
5002
|
+
if (init.type.kind === "dyn") {
|
|
5003
|
+
return { kind: "libCall", fn: "sp.newChecked", args: [init], type: SEARCH_PARAMS_T, loc };
|
|
5004
|
+
}
|
|
4768
5005
|
if (init.type.kind === "string") {
|
|
4769
5006
|
return { kind: "libCall", fn: "sp.parse", args: [init], type: SEARCH_PARAMS_T, loc };
|
|
4770
5007
|
}
|
|
@@ -5324,7 +5561,11 @@ export function lowerCryptoHashMethodCall(lowerer, call, access) {
|
|
|
5324
5561
|
lowerer.noLowering(`${receiverType.kind === "cryptoHash" ? "Hash" : "Hmac"}.update with ${call.arguments.length} arguments`, call, "update(stringOrBuffer[, inputEncoding]) is supported");
|
|
5325
5562
|
}
|
|
5326
5563
|
const dataNode = call.arguments[0];
|
|
5327
|
-
const
|
|
5564
|
+
const dataType = lowerer.mapTypeOf(lowerer.typeOf(dataNode));
|
|
5565
|
+
// Indexed reads can retain optional storage after a nullish fallback
|
|
5566
|
+
// or narrowing. Use the proven argument type through a checked coercion.
|
|
5567
|
+
const data = dataType?.kind === "string" || dataType?.kind === "bytes"
|
|
5568
|
+
? lowerer.lowerExprExpecting(dataNode, dataType) : lowerer.lowerExpr(dataNode);
|
|
5328
5569
|
const prefix = receiverType.kind === "cryptoHash" ? "crypto.hashUpdate" : "crypto.hmacUpdate";
|
|
5329
5570
|
if (data.type.kind === "bytes" && data.type.elem === "u8") {
|
|
5330
5571
|
if (call.arguments.length !== 1) {
|
|
@@ -5619,7 +5860,7 @@ export function lowerChildMethodCall(lowerer, call, access) {
|
|
|
5619
5860
|
if ((name === "on" || name === "once") && call.arguments.length === 2) {
|
|
5620
5861
|
const evT = lowerer.typeOf(call.arguments[0]);
|
|
5621
5862
|
const event = evT.isStringLiteralType() ? evT.value : null;
|
|
5622
|
-
if (event !== "exit" && event !== "close" && event !== "error" && event !== "message" && event !== "disconnect") {
|
|
5863
|
+
if (event !== "spawn" && event !== "exit" && event !== "close" && event !== "error" && event !== "message" && event !== "disconnect") {
|
|
5623
5864
|
lowerer.noLowering(`child.${name}(${event === null ? "non-literal event" : `"${event}"`}, ...)`, call.arguments[0], '"exit", "close", "error", "message", and "disconnect" are the supported child events (as literals)');
|
|
5624
5865
|
}
|
|
5625
5866
|
if (!ts.isExpressionStatement(call.parent)) {
|
|
@@ -5645,7 +5886,33 @@ export function lowerChildMethodCall(lowerer, call, access) {
|
|
|
5645
5886
|
loc,
|
|
5646
5887
|
};
|
|
5647
5888
|
}
|
|
5889
|
+
const listenerNode = stripTypeCasts(call.arguments[1]);
|
|
5890
|
+
if (isJsSourceFile(listenerNode.getSourceFile()) &&
|
|
5891
|
+
(ts.isArrowFunction(listenerNode) || ts.isFunctionExpression(listenerNode)) &&
|
|
5892
|
+
listenerNode.parameters.some((param) => param.dotDotDotToken) &&
|
|
5893
|
+
listenerNode.parameters.every((param) => !param.type) &&
|
|
5894
|
+
!/@(?:param|type)\b/.test(listenerNode.getSourceFile().text.slice(listenerNode.pos, listenerNode.getStart()))) {
|
|
5895
|
+
for (const param of listenerNode.parameters)
|
|
5896
|
+
lowerer.checkedCallbackParams.add(param);
|
|
5897
|
+
}
|
|
5648
5898
|
const cb = lowerer.lowerExpr(call.arguments[1]);
|
|
5899
|
+
if (cb.type.kind === "func" && cb.type.rest) {
|
|
5900
|
+
if (!canBoxFuncIntoDyn(cb.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
5901
|
+
lowerer.noLowering("child event rest listeners with non-representable parameters", call.arguments[1]);
|
|
5902
|
+
}
|
|
5903
|
+
return {
|
|
5904
|
+
kind: "libCall", fn: "child.onDyn",
|
|
5905
|
+
args: [receiver, { kind: "strLit", value: event, type: STRING, loc },
|
|
5906
|
+
{ kind: "dynFrom", value: cb, type: DYN, loc }],
|
|
5907
|
+
type: VOID, loc,
|
|
5908
|
+
};
|
|
5909
|
+
}
|
|
5910
|
+
if (event === "spawn") {
|
|
5911
|
+
if (cb.type.kind !== "func" || cb.type.params.length !== 0 || cb.type.ret.kind !== "void") {
|
|
5912
|
+
lowerer.noLowering("spawn event listeners with parameters or a returned value", call.arguments[1]);
|
|
5913
|
+
}
|
|
5914
|
+
return { kind: "libCall", fn: "child.onSpawn", args: [receiver, cb], type: VOID, loc };
|
|
5915
|
+
}
|
|
5649
5916
|
if (cb.type.kind !== "func" || cb.type.params.length > (event === "error" ? 1 : 2)) {
|
|
5650
5917
|
lowerer.unsupported("SC1090", call.arguments[1], event !== "error"
|
|
5651
5918
|
? `${event} listeners with more than two parameters (use (code, signal), (code), or ())`
|
|
@@ -5720,9 +5987,9 @@ export function lowerChildMethodCall(lowerer, call, access) {
|
|
|
5720
5987
|
// child.unref(): drops the child from the event loop's keep-alive set
|
|
5721
5988
|
// (the process may exit while the child runs — Node's semantics; the
|
|
5722
5989
|
// child is still reaped while the loop runs for other reasons).
|
|
5723
|
-
if (name === "unref" && call.arguments.length === 0) {
|
|
5990
|
+
if ((name === "unref" || name === "ref") && call.arguments.length === 0) {
|
|
5724
5991
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5725
|
-
return { kind: "libCall", fn: "child.unref", args: [receiver], type: VOID, loc };
|
|
5992
|
+
return { kind: "libCall", fn: name === "ref" ? "child.ref" : "child.unref", args: [receiver], type: VOID, loc };
|
|
5726
5993
|
}
|
|
5727
5994
|
lowerer.noLowering(`ChildProcess.${name}`, call, "send(), connected, disconnect(), on/once(\"message\" | \"disconnect\" | \"exit\" | \"close\" | \"error\", cb), pid, exitCode, killed, kill(signal?), and unref() are supported", lowerer.checker.getSymbolAtLocation(access.name));
|
|
5728
5995
|
}
|
|
@@ -5862,6 +6129,13 @@ export function lowerProcStreamMethodCall(lowerer, call, access) {
|
|
|
5862
6129
|
return null;
|
|
5863
6130
|
const name = access.name.text;
|
|
5864
6131
|
const loc = locOf(call);
|
|
6132
|
+
if (isJsSourceFile(call.getSourceFile())) {
|
|
6133
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
6134
|
+
if (receiver.type.kind === "dyn") {
|
|
6135
|
+
return { kind: "dynInvoke", recv: receiver, method: name, calleeName: call.expression.getText(),
|
|
6136
|
+
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), type: DYN, loc };
|
|
6137
|
+
}
|
|
6138
|
+
}
|
|
5865
6139
|
if (name === "write" && call.arguments.length === 1) {
|
|
5866
6140
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5867
6141
|
const data = lowerer.lowerExpr(call.arguments[0]);
|
|
@@ -5966,7 +6240,8 @@ export function lowerWatcherMethodCall(lowerer, call, access) {
|
|
|
5966
6240
|
}
|
|
5967
6241
|
lowerer.noLowering(`FSWatcher.${name}`, call, "close() is the supported FSWatcher member", lowerer.checker.getSymbolAtLocation(access.name));
|
|
5968
6242
|
}
|
|
5969
|
-
/** `.code` on an error-hierarchy receiver
|
|
6243
|
+
/** `.code` and `.cause` on an error-hierarchy receiver. The latter reads
|
|
6244
|
+
* the hidden dyn slot installed by constructor options. The former is NodeJS.ErrnoException's
|
|
5970
6245
|
* member (the fallback declares the same shape): the runtime Error's
|
|
5971
6246
|
* code slot as `string | undefined` — the errno name where a throw site
|
|
5972
6247
|
* stamped one (fs, exec spawn/timeout, process.kill, the spawn 'error'
|
|
@@ -6000,10 +6275,10 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
6000
6275
|
return { kind: "libCall", fn: "error.domCause", args: [receiver], type: DYN, loc: locOf(expr) };
|
|
6001
6276
|
}
|
|
6002
6277
|
}
|
|
6003
|
-
if (expr.name.text !== "code")
|
|
6278
|
+
if (expr.name.text !== "code" && expr.name.text !== "cause" && expr.name.text !== "stack")
|
|
6004
6279
|
return null;
|
|
6005
6280
|
// Error-rooted classes only — builtin or user subclass (both embed the
|
|
6006
|
-
// code
|
|
6281
|
+
// code and cause slots in their layout prefix).
|
|
6007
6282
|
let info = lowerer.classes.get(recvT.className) ?? null;
|
|
6008
6283
|
while (info && info.base)
|
|
6009
6284
|
info = info.base;
|
|
@@ -6014,19 +6289,31 @@ export function lowerErrorCodeProperty(lowerer, expr) {
|
|
|
6014
6289
|
const receiver = lowerer.lowerExpr(expr.expression);
|
|
6015
6290
|
return {
|
|
6016
6291
|
kind: "libCall",
|
|
6017
|
-
fn: "error.code",
|
|
6292
|
+
fn: expr.name.text === "stack" ? "error.stack" : expr.name.text === "cause" ? "error.cause" : "error.code",
|
|
6018
6293
|
args: [receiver],
|
|
6019
|
-
type: lowerer.envValueType(),
|
|
6294
|
+
type: expr.name.text === "stack" ? STRING : expr.name.text === "cause" ? DYN : lowerer.envValueType(),
|
|
6020
6295
|
loc: locOf(expr),
|
|
6021
6296
|
};
|
|
6022
6297
|
}
|
|
6023
|
-
/**
|
|
6024
|
-
*
|
|
6025
|
-
* receivers (the property chain keeps trying other lowerings). */
|
|
6298
|
+
/** Stored stringify uses the same native serializer and keeps omitted roots
|
|
6299
|
+
* as undefined. Other JSON method values retain a named refusal. */
|
|
6026
6300
|
export function lowerJsonProperty(lowerer, expr) {
|
|
6027
6301
|
const member = lowerer.stdlibGlobalMember(expr, "JSON");
|
|
6028
6302
|
if (member === null)
|
|
6029
6303
|
return null;
|
|
6304
|
+
if (member === "stringify") {
|
|
6305
|
+
const loc = locOf(expr);
|
|
6306
|
+
const name = "%builtin.JSON.stringify";
|
|
6307
|
+
if (!lowerer.builtinCallableValueFns.has(name)) {
|
|
6308
|
+
lowerer.builtinCallableValueFns.set(name, name);
|
|
6309
|
+
const params = ["value", "replacer", "space"].map((name) => ({ localId: name, name, type: DYN }));
|
|
6310
|
+
lowerer.liftedFns.push({ name, params, returnType: DYN,
|
|
6311
|
+
locals: params.map((p) => ({ id: p.localId, name: p.name, type: DYN, mutable: false })), loc,
|
|
6312
|
+
body: [{ kind: "return", value: { kind: "libCall", fn: "json.stringifyValue", args: params.map((p) => varRef(p.localId, DYN, loc)), type: DYN, loc }, loc }],
|
|
6313
|
+
});
|
|
6314
|
+
}
|
|
6315
|
+
return { kind: "dynFrom", value: { kind: "closure", fnName: name, captures: [], type: { kind: "func", params: [DYN, DYN, DYN], ret: DYN }, loc }, fnName: "stringify", type: DYN, loc };
|
|
6316
|
+
}
|
|
6030
6317
|
lowerer.unsupported("SC1090", expr, `JSON methods as values (call '${member}' directly)`);
|
|
6031
6318
|
}
|
|
6032
6319
|
/** `constants.X_OK` where `constants` is a named fs import: the access-
|
|
@@ -6041,10 +6328,10 @@ export function lowerFsConstantsProperty(lowerer, expr) {
|
|
|
6041
6328
|
const bi = lowerer.builtinImportOf(expr.expression);
|
|
6042
6329
|
if (!bi || bi.module !== "fs" || bi.member !== "constants")
|
|
6043
6330
|
return null;
|
|
6044
|
-
const MODES = { F_OK: 0, X_OK: 1, W_OK: 2, R_OK: 4 };
|
|
6331
|
+
const MODES = { F_OK: 0, X_OK: 1, W_OK: 2, R_OK: 4, COPYFILE_EXCL: 1, COPYFILE_FICLONE: 2, COPYFILE_FICLONE_FORCE: 4 };
|
|
6045
6332
|
const value = own(MODES, expr.name.text);
|
|
6046
6333
|
if (value === undefined) {
|
|
6047
|
-
lowerer.noLowering(`fs.constants.${expr.name.text}`, expr, "F_OK, R_OK, W_OK, and
|
|
6334
|
+
lowerer.noLowering(`fs.constants.${expr.name.text}`, expr, "F_OK, R_OK, W_OK, X_OK, and COPYFILE_* are the lowered constants");
|
|
6048
6335
|
}
|
|
6049
6336
|
return { kind: "numLit", value, type: F64, loc: locOf(expr) };
|
|
6050
6337
|
}
|
|
@@ -6066,6 +6353,16 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6066
6353
|
if (expr.questionDotToken)
|
|
6067
6354
|
return null;
|
|
6068
6355
|
const member = expr.name.text;
|
|
6356
|
+
const direct = ts.isPropertyAccessExpression(expr.expression) ? lowerer.stdlibGlobalMember(expr.expression, "process") : null;
|
|
6357
|
+
if (isJsSourceFile(expr.getSourceFile()) &&
|
|
6358
|
+
(direct === "stdin" || direct === "stdout" || direct === "stderr" ||
|
|
6359
|
+
lowerer.mapTypeOf(lowerer.typeOf(expr.expression))?.kind === "procStream")) {
|
|
6360
|
+
const value = lowerer.lowerExpr(expr.expression);
|
|
6361
|
+
if (value.type.kind === "dyn")
|
|
6362
|
+
return {
|
|
6363
|
+
kind: "dynKeyGet", value, key: strLit(member, locOf(expr.name)), type: DYN, loc: locOf(expr),
|
|
6364
|
+
};
|
|
6365
|
+
}
|
|
6069
6366
|
if (member !== "isTTY" && member !== "columns" && member !== "rows")
|
|
6070
6367
|
return null;
|
|
6071
6368
|
let recv = expr.expression;
|
|
@@ -6125,12 +6422,14 @@ export function lowerProcessStreamProperty(lowerer, expr) {
|
|
|
6125
6422
|
* rejected specifically. Null for non-process receivers (the chain keeps
|
|
6126
6423
|
* trying other property lowerings). */
|
|
6127
6424
|
export function lowerProcessProperty(lowerer, expr) {
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6425
|
+
if (!expr.questionDotToken && expr.name.text === "bigint" && ts.isPropertyAccessExpression(expr.expression) &&
|
|
6426
|
+
lowerer.stdlibGlobalMember(expr.expression, "process") === "hrtime") {
|
|
6427
|
+
const loc = locOf(expr);
|
|
6428
|
+
return { kind: "dynKeyGet", value: { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc },
|
|
6429
|
+
key: { kind: "strLit", value: "bigint", type: STRING, loc }, type: DYN, loc };
|
|
6430
|
+
}
|
|
6431
|
+
// node and openssl name the compatibility target, not linked engines.
|
|
6432
|
+
// Read the stable object so descriptor edits through aliases stay visible.
|
|
6134
6433
|
if ((expr.name.text === "node" || expr.name.text === "openssl") &&
|
|
6135
6434
|
!expr.questionDotToken &&
|
|
6136
6435
|
ts.isPropertyAccessExpression(expr.expression) &&
|
|
@@ -6140,34 +6439,30 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6140
6439
|
// "is crypto available" probe, and the crypto module exists here
|
|
6141
6440
|
// (unsupported members fence per site). SEMANTICS.md documents that
|
|
6142
6441
|
// the string names the compat target, not a linked library.
|
|
6143
|
-
const
|
|
6144
|
-
return {
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
//
|
|
6442
|
+
const loc = locOf(expr);
|
|
6443
|
+
return lowerer.coerceToExpected({
|
|
6444
|
+
kind: "dynKeyGet", key: { kind: "strLit", value: expr.name.text, type: STRING, loc },
|
|
6445
|
+
value: { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc }, type: DYN, loc,
|
|
6446
|
+
}, STRING);
|
|
6447
|
+
}
|
|
6448
|
+
// Other components begin absent. Consult the same object even for the
|
|
6449
|
+
// capability probes: users can define or delete their own entries.
|
|
6150
6450
|
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
6151
|
-
lowerer.stdlibGlobalMember(expr.expression, "process") === "versions"
|
|
6152
|
-
|
|
6153
|
-
return {
|
|
6451
|
+
lowerer.stdlibGlobalMember(expr.expression, "process") === "versions") {
|
|
6452
|
+
const loc = locOf(expr);
|
|
6453
|
+
return {
|
|
6454
|
+
kind: "dynKeyGet", key: { kind: "strLit", value: expr.name.text, type: STRING, loc },
|
|
6455
|
+
value: { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc }, type: DYN, loc,
|
|
6456
|
+
};
|
|
6154
6457
|
}
|
|
6155
6458
|
// The capability-probe members that honestly DON'T EXIST in a
|
|
6156
6459
|
// compiled binary — each reads undefined (their declared types carry
|
|
6157
6460
|
// the undefined arm), so feature probes take their documented
|
|
6158
|
-
// fallbacks: no
|
|
6159
|
-
// .sqlite), no gyp build config (process.config.variables.* — no ICU,
|
|
6461
|
+
// fallbacks: no gyp build config (process.config.variables.* — no ICU,
|
|
6160
6462
|
// no QUIC — and process.config.target_defaults), no feature flags
|
|
6161
6463
|
// (process.features.* — no inspector, not a debug build).
|
|
6162
6464
|
if (!expr.questionDotToken && ts.isPropertyAccessExpression(expr.expression)) {
|
|
6163
6465
|
const container = lowerer.stdlibGlobalMember(expr.expression, "process");
|
|
6164
|
-
if (container === "versions" && (expr.name.text === "sqlite" || expr.name.text === "bun" || expr.name.text === "deno")) {
|
|
6165
|
-
// versions.bun / versions.deno are the OTHER-runtime probes (a
|
|
6166
|
-
// formatter's config loader picks its package.json reader by
|
|
6167
|
-
// them): a compiled binary is neither, so both read undefined —
|
|
6168
|
-
// exactly Node's own answer.
|
|
6169
|
-
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6170
|
-
}
|
|
6171
6466
|
if (container === "features") {
|
|
6172
6467
|
return { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc: locOf(expr) };
|
|
6173
6468
|
}
|
|
@@ -6190,6 +6485,18 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6190
6485
|
if (member === null)
|
|
6191
6486
|
return null;
|
|
6192
6487
|
const loc = locOf(expr);
|
|
6488
|
+
if (member === "versions") {
|
|
6489
|
+
return { kind: "libCall", fn: "process.versions", args: [], type: DYN, loc };
|
|
6490
|
+
}
|
|
6491
|
+
if (member === "hrtime") {
|
|
6492
|
+
return { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc };
|
|
6493
|
+
}
|
|
6494
|
+
if (member === "getBuiltinModule") {
|
|
6495
|
+
// Keep the native loader's argument validation when the function is
|
|
6496
|
+
// stored. The declaration's string signature must not insert a checked
|
|
6497
|
+
// adapter before the loader gets to report Node's invalid-id error.
|
|
6498
|
+
return { kind: "dynFrom", value: lowerBuiltinLoaderValue(lowerer, loc), type: DYN, loc };
|
|
6499
|
+
}
|
|
6193
6500
|
if (member === "argv") {
|
|
6194
6501
|
return { kind: "libCall", fn: "process.argv", args: [], type: arrayOf(STRING), loc };
|
|
6195
6502
|
}
|
|
@@ -6242,6 +6549,9 @@ export function lowerProcessProperty(lowerer, expr) {
|
|
|
6242
6549
|
// procStream scalar, minted as the stream's fd. Member reads
|
|
6243
6550
|
// (`process.stdout.isTTY`, `.write(...)`) never reach here — their
|
|
6244
6551
|
// OUTER expressions dispatch first.
|
|
6552
|
+
if (member === "stdin" || ((member === "stdout" || member === "stderr") && isJsSourceFile(expr.getSourceFile()))) {
|
|
6553
|
+
return { kind: "libCall", fn: "process.stdio", args: [numLit(member === "stdin" ? 0 : member === "stdout" ? 1 : 2, loc)], type: DYN, loc };
|
|
6554
|
+
}
|
|
6245
6555
|
if (member === "stdout" || member === "stderr") {
|
|
6246
6556
|
return { kind: "numLit", value: member === "stdout" ? 1 : 2, type: PROCSTREAM_T, loc };
|
|
6247
6557
|
}
|
|
@@ -6320,9 +6630,12 @@ function lowerFsReaddirTypesCall(lowerer, call, loc, promiseForm) {
|
|
|
6320
6630
|
const callType = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6321
6631
|
if (!callType)
|
|
6322
6632
|
fence();
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6633
|
+
let result = callType;
|
|
6634
|
+
if (promiseForm) {
|
|
6635
|
+
if (callType.kind !== "promise")
|
|
6636
|
+
fence();
|
|
6637
|
+
result = callType.inner;
|
|
6638
|
+
}
|
|
6326
6639
|
if (result?.kind !== "array" || result.elem.kind !== "record")
|
|
6327
6640
|
fence();
|
|
6328
6641
|
const shape = lowerer.shapes.get(result.elem.shapeId);
|
|
@@ -6505,9 +6818,10 @@ function lowerQuerystringParseCall(lowerer, call, loc) {
|
|
|
6505
6818
|
}
|
|
6506
6819
|
if (!sawStr || !sawArr)
|
|
6507
6820
|
fence();
|
|
6508
|
-
const
|
|
6509
|
-
|
|
6510
|
-
|
|
6821
|
+
const argument = call.arguments[0];
|
|
6822
|
+
if (!argument)
|
|
6823
|
+
lowerer.noLowering("querystring.parse without a query string", call);
|
|
6824
|
+
const str = lowerer.lowerExprExpecting(argument, STRING);
|
|
6511
6825
|
const sep = qsSepEqArg(lowerer, call.arguments[1], "&", "querystring.parse", loc);
|
|
6512
6826
|
const eq = qsSepEqArg(lowerer, call.arguments[2], "=", "querystring.parse", loc);
|
|
6513
6827
|
// The options walk: maxKeys lowers (Node's rule — > 0 caps the pair
|
|
@@ -6679,7 +6993,35 @@ export function lowerProcessEnvGet(lowerer, expr) {
|
|
|
6679
6993
|
export function lowerProcessMethodCall(lowerer, call, access) {
|
|
6680
6994
|
if (call.questionDotToken)
|
|
6681
6995
|
return null;
|
|
6996
|
+
if (isJsSourceFile(call.getSourceFile()) && ts.isPropertyAccessExpression(access.expression)) {
|
|
6997
|
+
const stream = lowerer.stdlibGlobalMember(access.expression, "process");
|
|
6998
|
+
if (stream === "stdin" || stream === "stdout" || stream === "stderr") {
|
|
6999
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
7000
|
+
lowerer.noLowering("process stream spread arguments", call);
|
|
7001
|
+
return { kind: "dynInvoke", recv: lowerer.lowerExpr(access.expression), method: access.name.text,
|
|
7002
|
+
calleeName: access.getText(), args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), type: DYN, loc: locOf(call) };
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
6682
7005
|
const directProcessMember = lowerer.stdlibGlobalMember(access, "process");
|
|
7006
|
+
if (directProcessMember === "hrtime") {
|
|
7007
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
7008
|
+
lowerer.noLowering("process.hrtime with spread arguments", call);
|
|
7009
|
+
const loc = locOf(call);
|
|
7010
|
+
return { kind: "dynCall", callee: { kind: "libCall", fn: "process.hrtimeValue", args: [], type: DYN, loc },
|
|
7011
|
+
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), calleeName: "process.hrtime", type: DYN, loc };
|
|
7012
|
+
}
|
|
7013
|
+
if (directProcessMember === "getBuiltinModule") {
|
|
7014
|
+
if (call.arguments.some(ts.isSpreadElement))
|
|
7015
|
+
lowerer.noLowering("process.getBuiltinModule with spread arguments", call);
|
|
7016
|
+
const loc = locOf(call);
|
|
7017
|
+
const id = call.arguments[0] ? lowerer.lowerExprExpecting(call.arguments[0], DYN)
|
|
7018
|
+
: { kind: "dynFrom", value: { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc }, type: DYN, loc };
|
|
7019
|
+
const binding = lowerer.declareHiddenLocal("%builtinId", DYN);
|
|
7020
|
+
return { kind: "seqExpr", stmts: [
|
|
7021
|
+
{ kind: "varDecl", localId: binding.id, init: id, loc },
|
|
7022
|
+
...call.arguments.slice(1).map((arg) => ({ kind: "exprStmt", expr: lowerer.lowerExpr(arg), loc: locOf(arg) })),
|
|
7023
|
+
], result: { kind: "callValue", callee: lowerBuiltinLoaderValue(lowerer, loc), args: [varRef(binding.id, DYN, loc)], type: DYN, loc }, type: DYN, loc };
|
|
7024
|
+
}
|
|
6683
7025
|
if (directProcessMember === "send")
|
|
6684
7026
|
return lowerProcessIpcSend(lowerer, call);
|
|
6685
7027
|
if (directProcessMember === "disconnect") {
|
|
@@ -6935,7 +7277,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6935
7277
|
if (member === null)
|
|
6936
7278
|
return null;
|
|
6937
7279
|
const loc = locOf(call);
|
|
6938
|
-
// process.on/once/off: the CLI event slice —
|
|
7280
|
+
// process.on/once/off: the CLI event slice — named OS
|
|
6939
7281
|
// signal handlers and the 'exit' hook. Signal listeners run as
|
|
6940
7282
|
// macrotasks at loop turns, replace the default disposition while
|
|
6941
7283
|
// registered (removing the last restores Ctrl-C death), and never
|
|
@@ -6966,12 +7308,17 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
6966
7308
|
loc,
|
|
6967
7309
|
};
|
|
6968
7310
|
}
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
7311
|
+
if (event === "uncaughtException" || event === "uncaughtExceptionMonitor") {
|
|
7312
|
+
if (!ts.isExpressionStatement(call.parent)) {
|
|
7313
|
+
lowerer.unsupported("SC1090", call, "chaining process exception listener registration");
|
|
7314
|
+
}
|
|
7315
|
+
const cb = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
7316
|
+
const monitor = boolLit(event === "uncaughtExceptionMonitor", loc);
|
|
7317
|
+
return {
|
|
7318
|
+
kind: "libCall", fn: isOff ? "process.offUncaughtException" : "process.onUncaughtException",
|
|
7319
|
+
args: isOff ? [cb, monitor] : [cb, boolLit(member === "once", loc), monitor], type: VOID, loc,
|
|
7320
|
+
};
|
|
7321
|
+
}
|
|
6975
7322
|
// 'unhandledRejection': the listener crosses as a dyn function and
|
|
6976
7323
|
// the completed-checkpoint report dispatches it (reason, promise) per
|
|
6977
7324
|
// never-observed rejection instead of printing and exiting 1
|
|
@@ -7007,8 +7354,23 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7007
7354
|
loc,
|
|
7008
7355
|
};
|
|
7009
7356
|
}
|
|
7010
|
-
if (
|
|
7011
|
-
|
|
7357
|
+
if (event === null || event.startsWith("SIG")) {
|
|
7358
|
+
if (!ts.isExpressionStatement(call.parent)) {
|
|
7359
|
+
lowerer.unsupported("SC1090", call, "chaining process signal listener registration");
|
|
7360
|
+
}
|
|
7361
|
+
const name = lowerer.coerceToExpected(lowerer.lowerExpr(call.arguments[0]), STRING);
|
|
7362
|
+
if (name.type.kind !== "string" && name.type.kind !== "dyn") {
|
|
7363
|
+
lowerer.noLowering("process signal event name that is not a string", call.arguments[0]);
|
|
7364
|
+
}
|
|
7365
|
+
const signal = name.type.kind === "string" ? name : { kind: "dynCheck", value: name, type: STRING, loc };
|
|
7366
|
+
const cb = dcSubscriberArg(lowerer, call.arguments[1]);
|
|
7367
|
+
return {
|
|
7368
|
+
kind: "libCall", fn: isOff ? "process.offSignal" : "process.onSignal",
|
|
7369
|
+
args: isOff ? [signal, cb] : [signal, cb, boolLit(member === "once", loc)], type: VOID, loc,
|
|
7370
|
+
};
|
|
7371
|
+
}
|
|
7372
|
+
if (event !== "exit") {
|
|
7373
|
+
lowerer.noLowering(`process.${member}("${event}", ...)`, call.arguments[0]);
|
|
7012
7374
|
}
|
|
7013
7375
|
if (!ts.isExpressionStatement(call.parent)) {
|
|
7014
7376
|
lowerer.unsupported("SC1090", call, "chaining process listener registration (the result is void here — register each listener as its own statement)");
|
|
@@ -7023,7 +7385,7 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7023
7385
|
// result; a non-function dyn value throws the catchable TypeError
|
|
7024
7386
|
// at REGISTRATION (Node's ERR_INVALID_ARG_TYPE moment).
|
|
7025
7387
|
{
|
|
7026
|
-
const target = funcOf(
|
|
7388
|
+
const target = funcOf([F64], VOID);
|
|
7027
7389
|
const exact = cb.type.kind === "func" &&
|
|
7028
7390
|
cb.type.ret.kind === "void" &&
|
|
7029
7391
|
cb.type.params.length <= 1 &&
|
|
@@ -7048,16 +7410,6 @@ export function lowerProcessMethodCall(lowerer, call, access) {
|
|
|
7048
7410
|
}
|
|
7049
7411
|
const param = cb.type.params[0];
|
|
7050
7412
|
const onceArg = { kind: "boolLit", value: member === "once", type: BOOL, loc };
|
|
7051
|
-
if (signo !== undefined) {
|
|
7052
|
-
if (param !== undefined) {
|
|
7053
|
-
lowerer.unsupported("SC1090", call.arguments[1], "signal listeners with parameters (the signal name argument has no lowering — use ())");
|
|
7054
|
-
}
|
|
7055
|
-
const sig = { kind: "numLit", value: signo, type: F64, loc };
|
|
7056
|
-
if (isOff) {
|
|
7057
|
-
return { kind: "libCall", fn: "process.offSignal", args: [sig, cb], type: VOID, loc };
|
|
7058
|
-
}
|
|
7059
|
-
return { kind: "libCall", fn: "process.onSignal", args: [sig, cb, onceArg], type: VOID, loc };
|
|
7060
|
-
}
|
|
7061
7413
|
if (param !== undefined && param.kind !== "f64") {
|
|
7062
7414
|
lowerer.unsupported("SC1090", call.arguments[1], `exit listeners whose parameter is not 'number' (got '${lowerer.fmt(param)}')`);
|
|
7063
7415
|
}
|
|
@@ -7332,7 +7684,7 @@ const NUMBER_STATIC_PREDICATES = {
|
|
|
7332
7684
|
isSafeInteger: "number.isSafeInteger",
|
|
7333
7685
|
};
|
|
7334
7686
|
/** The Number constants, baked as literals — non-finite ones included
|
|
7335
|
-
* (numLits carry NaN and the infinities;
|
|
7687
|
+
* (numLits carry NaN and the infinities; the backend preserves them). */
|
|
7336
7688
|
const NUMBER_CONSTANTS = {
|
|
7337
7689
|
MAX_SAFE_INTEGER: 9007199254740991,
|
|
7338
7690
|
MIN_SAFE_INTEGER: -9007199254740991,
|
|
@@ -7466,7 +7818,9 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7466
7818
|
if (call.arguments.length !== 0) {
|
|
7467
7819
|
lowerer.noLowering(`Date.prototype.${name} with arguments`, call, DATE_METHOD_HINT);
|
|
7468
7820
|
}
|
|
7469
|
-
const
|
|
7821
|
+
const raw = lowerer.lowerExpr(access.expression);
|
|
7822
|
+
const receiver = raw.type.kind === "dyn"
|
|
7823
|
+
? { kind: "libCall", fn: "date.checkedValue", args: [raw], type: { kind: "date" }, loc } : raw;
|
|
7470
7824
|
if (receiver.type.kind !== "date")
|
|
7471
7825
|
lowerer.badType(access.expression, lowerer.typeOf(access.expression));
|
|
7472
7826
|
if (name === "getTime" || name === "valueOf") {
|
|
@@ -7487,78 +7841,124 @@ export function lowerDateCall(lowerer, call, access) {
|
|
|
7487
7841
|
}
|
|
7488
7842
|
lowerer.noLowering(`Date.prototype.${name}`, call, DATE_METHOD_HINT, lowerer.checker.getSymbolAtLocation(access.name));
|
|
7489
7843
|
}
|
|
7490
|
-
|
|
7491
|
-
*
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
const
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
const
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7844
|
+
/** Box a codec's immutable encoding in an owned record. Unlike erased
|
|
7845
|
+
* aliases, this value can live in fields, arguments, and closure captures. */
|
|
7846
|
+
export function lowerTextCodecNew(lowerer, ctor, cls) {
|
|
7847
|
+
const args = ctor.arguments ?? [];
|
|
7848
|
+
const loc = locOf(ctor);
|
|
7849
|
+
let encoding = { kind: "numLit", value: -1, type: F64, loc };
|
|
7850
|
+
let label = null;
|
|
7851
|
+
if (cls === "TextEncoder") {
|
|
7852
|
+
if (args.length !== 0)
|
|
7853
|
+
lowerer.noLowering("new TextEncoder with arguments", ctor);
|
|
7854
|
+
}
|
|
7855
|
+
else if (args.length !== 0) {
|
|
7856
|
+
const labelT = lowerer.typeOf(args[0]);
|
|
7857
|
+
const parsed = labelT.isStringLiteralType() ? staticTextDecoderEncoding(labelT.value) : null;
|
|
7858
|
+
if (args.length > 2)
|
|
7859
|
+
lowerer.noLowering("new TextDecoder with extra arguments", ctor);
|
|
7860
|
+
if (parsed === null) {
|
|
7861
|
+
encoding = { kind: "libCall", fn: "text.decoderEncoding", args: [lowerer.lowerExprExpecting(args[0], DYN)], type: F64, loc };
|
|
7862
|
+
}
|
|
7863
|
+
else {
|
|
7864
|
+
encoding = { kind: "numLit", value: parsed.kind === "utf8" ? -1 : parsed.id, type: F64, loc };
|
|
7865
|
+
label = lowerer.lowerExprExpecting(args[0], STRING);
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
const options = args[1] ? stripTypeCasts(args[1]) : null;
|
|
7869
|
+
const flags = new Map();
|
|
7870
|
+
for (const name of ["fatal", "ignoreBOM"])
|
|
7871
|
+
flags.set(name, { kind: "boolLit", value: false, type: BOOL, loc });
|
|
7872
|
+
if (options) {
|
|
7873
|
+
if (!ts.isObjectLiteralExpression(options))
|
|
7874
|
+
lowerer.noLowering("TextDecoder options outside an object literal", options);
|
|
7875
|
+
for (const property of options.properties) {
|
|
7876
|
+
if ((!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) ||
|
|
7877
|
+
!ts.isIdentifier(property.name) || !flags.has(property.name.text))
|
|
7878
|
+
lowerer.noLowering("unknown TextDecoder option", property);
|
|
7879
|
+
const value = ts.isPropertyAssignment(property) ? property.initializer : property.name;
|
|
7880
|
+
flags.set(property.name.text, lowerer.lowerExprExpecting(value, BOOL));
|
|
7881
|
+
}
|
|
7882
|
+
}
|
|
7883
|
+
const type = lowerer.mapTypeOf(lowerer.typeOf(ctor));
|
|
7884
|
+
if (type?.kind !== "record")
|
|
7885
|
+
lowerer.badType(ctor, lowerer.typeOf(ctor));
|
|
7886
|
+
const result = {
|
|
7887
|
+
kind: "recordLit", fields: [{ name: `%${cls}`, value: encoding }, ...(cls === "TextDecoder" ? [
|
|
7888
|
+
...[...flags].map(([name, value]) => ({ name: `%${name}`, value })),
|
|
7889
|
+
{ name: "%state", value: { kind: "dynObjLit", fields: [], type: DYN, loc } },
|
|
7890
|
+
] : [])], type, loc,
|
|
7510
7891
|
};
|
|
7511
|
-
|
|
7512
|
-
|
|
7892
|
+
return label === null || label.kind === "strLit" ? result : {
|
|
7893
|
+
kind: "seqExpr", stmts: [{ kind: "exprStmt", expr: label, loc }], result, type, loc,
|
|
7513
7894
|
};
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
if (
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7895
|
+
}
|
|
7896
|
+
function storedTextCodecClassOf(lowerer, expr) {
|
|
7897
|
+
const sym = lowerer.typeOf(expr).getSymbol();
|
|
7898
|
+
if (!sym || (sym.name !== "TextEncoder" && sym.name !== "TextDecoder"))
|
|
7899
|
+
return null;
|
|
7900
|
+
return lowerer.checker.declarationsOf(sym).some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) && lowerer.isStdlibFile(d.getSourceFile())) ? sym.name : null;
|
|
7901
|
+
}
|
|
7902
|
+
function lowerStoredTextCodecCall(lowerer, call, access) {
|
|
7903
|
+
const cls = storedTextCodecClassOf(lowerer, access.expression);
|
|
7904
|
+
if (cls === null || !lowerer.isStdlibMember(access))
|
|
7905
|
+
return null;
|
|
7906
|
+
if (access.name.text !== (cls === "TextEncoder" ? "encode" : "decode"))
|
|
7907
|
+
return null;
|
|
7908
|
+
if (call.arguments.length > (cls === "TextDecoder" ? 2 : 1)) {
|
|
7909
|
+
lowerer.noLowering(`${cls}.${access.name.text} with extra arguments`, call);
|
|
7910
|
+
}
|
|
7911
|
+
const loc = locOf(call);
|
|
7912
|
+
let stream = { kind: "boolLit", value: false, type: BOOL, loc };
|
|
7913
|
+
if (cls === "TextDecoder" && call.arguments[1]) {
|
|
7914
|
+
const options = stripTypeCasts(call.arguments[1]);
|
|
7915
|
+
if (!ts.isObjectLiteralExpression(options))
|
|
7916
|
+
lowerer.noLowering("TextDecoder.decode options outside an object literal", options);
|
|
7917
|
+
for (const property of options.properties) {
|
|
7918
|
+
if ((!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) ||
|
|
7919
|
+
!ts.isIdentifier(property.name) || property.name.text !== "stream")
|
|
7920
|
+
lowerer.noLowering("unknown TextDecoder.decode option", property);
|
|
7921
|
+
stream = lowerer.lowerExprExpecting(ts.isPropertyAssignment(property) ? property.initializer : property.name, BOOL);
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
7925
|
+
if (receiver.type.kind !== "record")
|
|
7926
|
+
lowerer.badType(access.expression, lowerer.typeOf(access.expression));
|
|
7927
|
+
let arg = call.arguments.length === 0
|
|
7928
|
+
? cls === "TextEncoder" ? strLit("", loc)
|
|
7929
|
+
: { kind: "bytesNew", source: null, type: BYTES_U8, loc }
|
|
7930
|
+
: cls === "TextEncoder" ? lowerer.lowerExprExpecting(call.arguments[0], STRING) : lowerer.lowerExpr(call.arguments[0]);
|
|
7931
|
+
if (cls === "TextDecoder" && (arg.type.kind === "dyn" || arg.type.kind === "bytes" && arg.type.elem !== "u8")) {
|
|
7932
|
+
arg = { kind: "libCall", fn: "bytes.bufferSource", args: [lowerer.coerceInto(call.arguments[0], arg, DYN)], type: BYTES_U8, loc };
|
|
7933
|
+
}
|
|
7934
|
+
if (cls === "TextDecoder" && !(arg.type.kind === "bytes" && arg.type.elem === "u8")) {
|
|
7935
|
+
lowerer.noLowering(`TextDecoder.decode of '${lowerer.fmt(arg.type)}' values`, call, "Uint8Array/Buffer input decodes (ArrayBuffer values have no representation)");
|
|
7936
|
+
}
|
|
7937
|
+
const key = `textCodec.${cls}.${receiver.type.shapeId}`;
|
|
7938
|
+
let name = lowerer.widthHelpers.get(key);
|
|
7939
|
+
if (!name) {
|
|
7940
|
+
name = `%${key}`;
|
|
7941
|
+
lowerer.widthHelpers.set(key, name);
|
|
7942
|
+
const recT = receiver.type;
|
|
7943
|
+
const input = varRef("input.0", arg.type, loc);
|
|
7944
|
+
const result = cls === "TextEncoder"
|
|
7945
|
+
? { kind: "libCall", fn: "buffer.fromStr", args: [input, { kind: "strLit", value: "utf8", type: STRING, loc }], type: BYTES_U8, loc }
|
|
7946
|
+
: { kind: "libCall", fn: "text.decodeStream", args: [
|
|
7947
|
+
{ kind: "recordGet", obj: varRef("codec.0", recT, loc), shapeId: recT.shapeId, field: "%state", type: DYN, loc },
|
|
7948
|
+
input,
|
|
7949
|
+
{ kind: "recordGet", obj: varRef("codec.0", recT, loc), shapeId: recT.shapeId, field: "%TextDecoder", type: F64, loc },
|
|
7950
|
+
...["%fatal", "%ignoreBOM"].map((field) => ({ kind: "recordGet", obj: varRef("codec.0", recT, loc), shapeId: recT.shapeId, field, type: BOOL, loc })),
|
|
7951
|
+
varRef("stream.0", BOOL, loc),
|
|
7952
|
+
], type: STRING, loc };
|
|
7953
|
+
lowerer.liftedFns.push({
|
|
7954
|
+
name,
|
|
7955
|
+
params: [{ localId: "codec.0", name: "codec", type: recT }, { localId: "input.0", name: "input", type: arg.type }, { localId: "stream.0", name: "stream", type: BOOL }],
|
|
7956
|
+
returnType: result.type,
|
|
7957
|
+
locals: [{ id: "codec.0", name: "codec", type: recT, mutable: false }, { id: "input.0", name: "input", type: arg.type, mutable: false }, { id: "stream.0", name: "stream", type: BOOL, mutable: false }],
|
|
7958
|
+
body: [{ kind: "return", value: result, loc }], loc,
|
|
7959
|
+
});
|
|
7960
|
+
}
|
|
7961
|
+
return { kind: "call", callee: name, args: [receiver, arg, stream], type: cls === "TextEncoder" ? BYTES_U8 : STRING, loc };
|
|
7562
7962
|
}
|
|
7563
7963
|
/** A direct construction of THE stdlib TextEncoder/TextDecoder, through
|
|
7564
7964
|
* type-only wrappers. Name alone is never enough: a user class with the
|
|
@@ -7579,118 +7979,8 @@ function directTextCodecCtorOf(lowerer, expr) {
|
|
|
7579
7979
|
return null;
|
|
7580
7980
|
return { cls: sym.name, ctor };
|
|
7581
7981
|
}
|
|
7582
|
-
/**
|
|
7583
|
-
*
|
|
7584
|
-
* resolve back to the initializer. TextDecoder's explicit label must be
|
|
7585
|
-
* an actual recognized literal here: accepting an arbitrary expression
|
|
7586
|
-
* merely typed as a label would move or repeat its effects when the
|
|
7587
|
-
* binding is erased. */
|
|
7588
|
-
function erasableTextCodecCtor(info) {
|
|
7589
|
-
const args = info.ctor.arguments ?? [];
|
|
7590
|
-
if (info.cls === "TextEncoder")
|
|
7591
|
-
return args.length === 0;
|
|
7592
|
-
if (args.length === 0)
|
|
7593
|
-
return true;
|
|
7594
|
-
if (args.length !== 1)
|
|
7595
|
-
return false;
|
|
7596
|
-
const label = stripTypeCasts(args[0]);
|
|
7597
|
-
return ts.isStringLiteralLike(label) && staticTextDecoderEncoding(label.text) !== null;
|
|
7598
|
-
}
|
|
7599
|
-
/** `const encoder = new TextEncoder()` / a statically-labelled TextDecoder twin:
|
|
7600
|
-
* compile-time alias plumbing with no runtime object. Calls through the
|
|
7601
|
-
* stable binding are recognized by textCodecReceiverOf below; any other
|
|
7602
|
-
* reached value use keeps the ordinary SC2020 representation fence. Both
|
|
7603
|
-
* declaration walks call this and independently gate on constness. */
|
|
7604
|
-
export function textCodecBindingClassOf(lowerer, nameNode, init) {
|
|
7605
|
-
if (!ts.isIdentifier(nameNode) || init === undefined)
|
|
7606
|
-
return null;
|
|
7607
|
-
const decl = nameNode.parent;
|
|
7608
|
-
if (!ts.isVariableDeclaration(decl) || !ts.isVariableDeclarationList(decl.parent) ||
|
|
7609
|
-
!ts.isVariableStatement(decl.parent.parent)) {
|
|
7610
|
-
return null;
|
|
7611
|
-
}
|
|
7612
|
-
const info = directTextCodecCtorOf(lowerer, init);
|
|
7613
|
-
return info !== null && erasableTextCodecCtor(info) ? info.cls : null;
|
|
7614
|
-
}
|
|
7615
|
-
export function textCodecBindingDecl(lowerer, nameNode, init) {
|
|
7616
|
-
return textCodecBindingClassOf(lowerer, nameNode, init) !== null;
|
|
7617
|
-
}
|
|
7618
|
-
/** The inline composed receiver, or a const identifier whose initializer
|
|
7619
|
-
* is an erasable codec construction in the same execution scope and
|
|
7620
|
-
* after that declaration. Following the declaration instead of
|
|
7621
|
-
* materializing the value is honest for the supported slice: receiver
|
|
7622
|
-
* reads are pure, construction has no effects, and every non-call use
|
|
7623
|
-
* fences because there is deliberately no general value lowering. */
|
|
7624
|
-
function textCodecReceiverOf(lowerer, expr) {
|
|
7625
|
-
const direct = directTextCodecCtorOf(lowerer, expr);
|
|
7626
|
-
if (direct !== null)
|
|
7627
|
-
return direct;
|
|
7628
|
-
const receiver = stripTypeCasts(expr);
|
|
7629
|
-
if (!ts.isIdentifier(receiver))
|
|
7630
|
-
return null;
|
|
7631
|
-
const sym = lowerer.resolveValueSymbol(receiver);
|
|
7632
|
-
const decl = sym ? lowerer.checker.valueDeclarationOf(sym) : undefined;
|
|
7633
|
-
if (!decl || !ts.isVariableDeclaration(decl) || decl.initializer === undefined ||
|
|
7634
|
-
!ts.isVariableDeclarationList(decl.parent) || (decl.parent.flags & ts.NodeFlags.Const) === 0 ||
|
|
7635
|
-
!textCodecBindingDecl(lowerer, decl.name, decl.initializer)) {
|
|
7636
|
-
return null;
|
|
7637
|
-
}
|
|
7638
|
-
// A closure can run before the const initializes (TDZ), and an
|
|
7639
|
-
// imported binding can be observed during a module cycle; both need
|
|
7640
|
-
// real runtime storage rather than this deliberately trivial rewrite.
|
|
7641
|
-
const executionScope = (node) => {
|
|
7642
|
-
let child = node;
|
|
7643
|
-
for (let cur = node.parent;; child = cur, cur = cur.parent) {
|
|
7644
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7645
|
-
return cur;
|
|
7646
|
-
// An instance field initializer runs when an object is constructed,
|
|
7647
|
-
// not when its enclosing class expression evaluates. Treat it like
|
|
7648
|
-
// a closure boundary: a later source position does not prove the
|
|
7649
|
-
// codec declaration ran (a switch can enter a following case and
|
|
7650
|
-
// instantiate the class while the binding is still in its TDZ).
|
|
7651
|
-
if (ts.isPropertyDeclaration(cur) && cur.initializer === child &&
|
|
7652
|
-
(ts.getCombinedModifierFlags(cur) & ts.ModifierFlags.Static) === 0) {
|
|
7653
|
-
return cur;
|
|
7654
|
-
}
|
|
7655
|
-
}
|
|
7656
|
-
};
|
|
7657
|
-
if (executionScope(receiver) !== executionScope(decl) || receiver.getStart() < decl.end)
|
|
7658
|
-
return null;
|
|
7659
|
-
// All switch clauses share one lexical environment, but dispatch can
|
|
7660
|
-
// enter a later clause without executing a const in an earlier one.
|
|
7661
|
-
// TypeScript normally diagnoses the direct read; an @ts-expect-error
|
|
7662
|
-
// can deliberately retain the runtime TDZ shape, so source order alone
|
|
7663
|
-
// is not a sufficient proof. A codec declared in a clause is erasable
|
|
7664
|
-
// only for uses inside that exact clause's subtree (nested switches are
|
|
7665
|
-
// fine; closures and instance initializers already fail executionScope).
|
|
7666
|
-
const switchClauseOf = (node) => {
|
|
7667
|
-
for (let cur = node.parent; cur !== undefined; cur = cur.parent) {
|
|
7668
|
-
if (ts.isCaseClause(cur) || ts.isDefaultClause(cur))
|
|
7669
|
-
return cur;
|
|
7670
|
-
if (ts.isFunctionLike(cur) || ts.isSourceFile(cur))
|
|
7671
|
-
return null;
|
|
7672
|
-
}
|
|
7673
|
-
return null;
|
|
7674
|
-
};
|
|
7675
|
-
const declClause = switchClauseOf(decl);
|
|
7676
|
-
if (declClause !== null) {
|
|
7677
|
-
let insideDeclClause = false;
|
|
7678
|
-
for (let cur = receiver; cur !== undefined; cur = cur.parent) {
|
|
7679
|
-
if (cur === declClause) {
|
|
7680
|
-
insideDeclClause = true;
|
|
7681
|
-
break;
|
|
7682
|
-
}
|
|
7683
|
-
}
|
|
7684
|
-
if (!insideDeclClause)
|
|
7685
|
-
return null;
|
|
7686
|
-
}
|
|
7687
|
-
return directTextCodecCtorOf(lowerer, decl.initializer);
|
|
7688
|
-
}
|
|
7689
|
-
/** The WHATWG encoder pair, COMPOSED or through an erasable const binding:
|
|
7690
|
-
* `new TextDecoder().decode(bytes)`, `new TextEncoder().encode(s)`, and
|
|
7691
|
-
* the idiomatic store-then-call equivalents. The codec object never
|
|
7692
|
-
* exists (the crypto/Date precedent); bare construction and value uses
|
|
7693
|
-
* are fenced with the composed hint. decode is the runtime's WHATWG
|
|
7982
|
+
/** Inline codec calls avoid allocating a receiver; stored receivers use
|
|
7983
|
+
* the owned record path above. decode is the runtime's WHATWG
|
|
7694
7984
|
* decode for every recognized static label (with BOM handling for the
|
|
7695
7985
|
* Unicode encodings); a zero-argument decode() is "" like the spec's.
|
|
7696
7986
|
* encode IS Buffer.from(s, "utf8") — ScrStr
|
|
@@ -7703,10 +7993,14 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7703
7993
|
const member = access.name.text;
|
|
7704
7994
|
if (member !== "decode" && member !== "encode")
|
|
7705
7995
|
return null;
|
|
7706
|
-
const info =
|
|
7707
|
-
if (info === null
|
|
7996
|
+
const info = directTextCodecCtorOf(lowerer, access.expression);
|
|
7997
|
+
if (info === null)
|
|
7998
|
+
return lowerStoredTextCodecCall(lowerer, call, access);
|
|
7999
|
+
if (!lowerer.isStdlibMember(access))
|
|
7708
8000
|
return null;
|
|
7709
8001
|
const { cls, ctor: recv } = info;
|
|
8002
|
+
if (cls === "TextDecoder" && ((recv.arguments?.length ?? 0) > 1 || call.arguments.length > 1))
|
|
8003
|
+
return lowerStoredTextCodecCall(lowerer, call, access);
|
|
7710
8004
|
if (!(cls === "TextDecoder" && member === "decode") && !(cls === "TextEncoder" && member === "encode")) {
|
|
7711
8005
|
return null;
|
|
7712
8006
|
}
|
|
@@ -7715,7 +8009,7 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7715
8009
|
if (cls === "TextDecoder") {
|
|
7716
8010
|
// The label must be statically known. A literal-typed effectful inline
|
|
7717
8011
|
// expression is accepted, but its evaluation is sequenced before the
|
|
7718
|
-
// decode below
|
|
8012
|
+
// decode below, just as stored decoders evaluate it at construction.
|
|
7719
8013
|
const labelT = ctorArgs.length >= 1 ? lowerer.typeOf(ctorArgs[0]) : null;
|
|
7720
8014
|
const encoding = ctorArgs.length === 0
|
|
7721
8015
|
? { kind: "utf8" }
|
|
@@ -7723,7 +8017,7 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7723
8017
|
? staticTextDecoderEncoding(labelT.value)
|
|
7724
8018
|
: null;
|
|
7725
8019
|
if (ctorArgs.length > 1 || encoding === null) {
|
|
7726
|
-
lowerer
|
|
8020
|
+
return lowerStoredTextCodecCall(lowerer, call, access);
|
|
7727
8021
|
}
|
|
7728
8022
|
const labelEffect = ctorArgs.length === 1
|
|
7729
8023
|
? lowerer.lowerExprExpecting(ctorArgs[0], STRING)
|
|
@@ -7745,7 +8039,10 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7745
8039
|
lowerer.noLowering("decode with a stream option", call, "streaming decode has no lowering — decode whole buffers");
|
|
7746
8040
|
}
|
|
7747
8041
|
const argNode = call.arguments[0];
|
|
7748
|
-
|
|
8042
|
+
let arg = lowerer.lowerExpr(argNode);
|
|
8043
|
+
if (arg.type.kind === "dyn" || arg.type.kind === "bytes" && arg.type.elem !== "u8") {
|
|
8044
|
+
arg = { kind: "libCall", fn: "bytes.bufferSource", args: [lowerer.coerceInto(argNode, arg, DYN)], type: BYTES_U8, loc };
|
|
8045
|
+
}
|
|
7749
8046
|
if (!(arg.type.kind === "bytes" && arg.type.elem === "u8")) {
|
|
7750
8047
|
lowerer.noLowering(`TextDecoder.decode of '${lowerer.fmt(arg.type)}' values`, argNode, "Uint8Array/Buffer input decodes (ArrayBuffer values have no representation)");
|
|
7751
8048
|
}
|
|
@@ -7763,23 +8060,23 @@ export function lowerTextCodecCall(lowerer, call, access) {
|
|
|
7763
8060
|
if (ctorArgs.length > 0) {
|
|
7764
8061
|
lowerer.noLowering("new TextEncoder with arguments", recv);
|
|
7765
8062
|
}
|
|
7766
|
-
if (call.arguments.length
|
|
7767
|
-
lowerer.noLowering(`TextEncoder.encode with ${call.arguments.length} arguments`, call
|
|
8063
|
+
if (call.arguments.length > 1) {
|
|
8064
|
+
lowerer.noLowering(`TextEncoder.encode with ${call.arguments.length} arguments`, call);
|
|
7768
8065
|
}
|
|
7769
|
-
const s = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
8066
|
+
const s = call.arguments.length === 0 ? strLit("", loc) : lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
7770
8067
|
const enc = { kind: "strLit", value: "utf8", type: STRING, loc };
|
|
7771
8068
|
return { kind: "libCall", fn: "buffer.fromStr", args: [s, enc], type: BYTES_U8, loc };
|
|
7772
8069
|
}
|
|
7773
|
-
/** `String.fromCharCode(...codes)` on THE String global: every argument
|
|
8070
|
+
/** `String.fromCharCode/fromCodePoint(...codes)` on THE String global: every argument
|
|
7774
8071
|
* lowers as a number and packs into ONE f64[] array-literal argument
|
|
7775
8072
|
* (the path.join convention) — or ONE whole-array spread forwards the
|
|
7776
|
-
* array itself.
|
|
7777
|
-
*
|
|
8073
|
+
* array itself. String.raw has its own template path below.
|
|
8074
|
+
* Null for non-String receivers. */
|
|
7778
8075
|
export function lowerStringStaticCall(lowerer, call, access) {
|
|
7779
8076
|
if (call.questionDotToken)
|
|
7780
8077
|
return null;
|
|
7781
8078
|
const member = lowerer.stdlibGlobalMember(access, "String");
|
|
7782
|
-
if (member !== "fromCharCode" && member !== "raw")
|
|
8079
|
+
if (member !== "fromCharCode" && member !== "fromCodePoint" && member !== "raw")
|
|
7783
8080
|
return null;
|
|
7784
8081
|
const loc = locOf(call);
|
|
7785
8082
|
// String.raw(template, ...substitutions): the template's `raw` member
|
|
@@ -7823,7 +8120,7 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7823
8120
|
const spread = call.arguments.find(ts.isSpreadElement);
|
|
7824
8121
|
if (spread) {
|
|
7825
8122
|
if (call.arguments.length !== 1) {
|
|
7826
|
-
lowerer.noLowering(
|
|
8123
|
+
lowerer.noLowering(`String.${member} with a mixed spread call`, call, `spread a whole array (String.${member}(...codes)) or pass plain arguments`);
|
|
7827
8124
|
}
|
|
7828
8125
|
// A typed-array/Buffer spread (String.fromCharCode(...data.slice(4, 8))
|
|
7829
8126
|
// — the magic-number ASCII probe) passes the bytes value through; the
|
|
@@ -7833,14 +8130,14 @@ export function lowerStringStaticCall(lowerer, call, access) {
|
|
|
7833
8130
|
const packed = lowerer.lowerExpr(spread.expression);
|
|
7834
8131
|
if (packed.type.kind !== "bytes")
|
|
7835
8132
|
lowerer.badType(spread.expression, lowerer.typeOf(spread.expression));
|
|
7836
|
-
return { kind: "libCall", fn:
|
|
8133
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7837
8134
|
}
|
|
7838
8135
|
const packed = lowerer.lowerExprExpecting(spread.expression, arrayOf(F64));
|
|
7839
|
-
return { kind: "libCall", fn:
|
|
8136
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7840
8137
|
}
|
|
7841
8138
|
const elems = call.arguments.map((a) => lowerer.lowerExprExpecting(a, F64));
|
|
7842
8139
|
const packed = { kind: "arrayLit", elems, type: arrayOf(F64), loc };
|
|
7843
|
-
return { kind: "libCall", fn:
|
|
8140
|
+
return { kind: "libCall", fn: `string.${member}`, args: [packed], type: STRING, loc };
|
|
7844
8141
|
}
|
|
7845
8142
|
/** `s.lastIndexOf(searchValue?, position?)` on string receivers, using UTF-16
|
|
7846
8143
|
* indices. An omitted search value searches for "undefined". Omitted or undefined positions clamp to the string's end;
|
|
@@ -7973,7 +8270,7 @@ export function lowerPromiseStaticCall(lowerer, call, access) {
|
|
|
7973
8270
|
// reads are the routed keyed ops). All-static tuples keep the
|
|
7974
8271
|
// typed fence hint below. --dynamic only by construction: jsval
|
|
7975
8272
|
// entries exist only there.
|
|
7976
|
-
if (elems.some((e) => e.type.kind === "jsval")) {
|
|
8273
|
+
if (lowerer.dynamic && elems.some((e) => e.type.kind === "jsval" || e.type.kind === "dyn")) {
|
|
7977
8274
|
const diagsBefore = lowerer.diags.length;
|
|
7978
8275
|
try {
|
|
7979
8276
|
const marshaled = argNode.elements.map((el, i) => lowerer.jsvalIn(elems[i], el));
|
|
@@ -8006,7 +8303,7 @@ export function lowerPromiseStaticCall(lowerer, call, access) {
|
|
|
8006
8303
|
// marshaled array (an 'any' value passes through; an `any[]` value
|
|
8007
8304
|
// lifts per element by reference), the result staying an island
|
|
8008
8305
|
// value the static side awaits through the island→static bridge.
|
|
8009
|
-
if (entries.type.kind === "jsval" ||
|
|
8306
|
+
if (entries.type.kind === "jsval" || lowerer.dynamic && entries.type.kind === "dyn" ||
|
|
8010
8307
|
(entries.type.kind === "array" && entries.type.elem.kind === "jsval")) {
|
|
8011
8308
|
const diagsBefore = lowerer.diags.length;
|
|
8012
8309
|
try {
|
|
@@ -8182,11 +8479,12 @@ export function lowerPromiseStaticCall(lowerer, call, access) {
|
|
|
8182
8479
|
return { kind: "intrinsic", name: "promise.resolve", args: [], type: { kind: "promise", inner: VOID }, loc };
|
|
8183
8480
|
}
|
|
8184
8481
|
if (resultT.inner.kind === "void") {
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8482
|
+
return {
|
|
8483
|
+
kind: "seqExpr",
|
|
8484
|
+
stmts: [lowerer.lowerExprStatement(argNode)],
|
|
8485
|
+
result: { kind: "intrinsic", name: "promise.resolve", args: [], type: resultT, loc },
|
|
8486
|
+
type: resultT, loc,
|
|
8487
|
+
};
|
|
8190
8488
|
}
|
|
8191
8489
|
if (isUnitType(resultT.inner)) {
|
|
8192
8490
|
// A unit payload (Promise<undefined>/Promise<null>) has no
|
|
@@ -8206,6 +8504,9 @@ export function lowerNumberStaticProperty(lowerer, expr) {
|
|
|
8206
8504
|
const member = lowerer.stdlibGlobalMember(expr, "Number");
|
|
8207
8505
|
if (member === null)
|
|
8208
8506
|
return null;
|
|
8507
|
+
const predicate = own(NUMBER_STATIC_PREDICATES, member);
|
|
8508
|
+
if (predicate)
|
|
8509
|
+
return lowerCheckedPredicateValue(lowerer, `Number.${member}`, "number", locOf(expr), predicate);
|
|
8209
8510
|
const value = own(NUMBER_CONSTANTS, member);
|
|
8210
8511
|
if (value === undefined)
|
|
8211
8512
|
return null;
|
|
@@ -8316,14 +8617,24 @@ export function isConsoleLog(lowerer, call) {
|
|
|
8316
8617
|
* like every stdlib global. Null for anything else (console.table, a
|
|
8317
8618
|
* user's own console binding, ...). */
|
|
8318
8619
|
export function consoleCallMember(lowerer, call) {
|
|
8620
|
+
if (call.questionDotToken)
|
|
8621
|
+
return null;
|
|
8622
|
+
if (ts.isIdentifier(call.expression)) {
|
|
8623
|
+
const imported = builtinImportOf(lowerer, call.expression);
|
|
8624
|
+
return imported?.module === "console" && isConsoleOutputMember(imported.member) ? imported.member : null;
|
|
8625
|
+
}
|
|
8319
8626
|
if (!ts.isPropertyAccessExpression(call.expression))
|
|
8320
8627
|
return null;
|
|
8321
8628
|
const access = call.expression;
|
|
8322
8629
|
if (access.questionDotToken || call.questionDotToken)
|
|
8323
8630
|
return null;
|
|
8324
8631
|
const name = access.name.text;
|
|
8325
|
-
if (name
|
|
8632
|
+
if (!isConsoleOutputMember(name))
|
|
8326
8633
|
return null;
|
|
8327
|
-
return lowerer.isStdlibGlobal(access.expression, "console")
|
|
8634
|
+
return lowerer.isStdlibGlobal(access.expression, "console") ||
|
|
8635
|
+
lowerer.builtinNamespaceModuleOf(access.expression) === "console" ? name : null;
|
|
8636
|
+
}
|
|
8637
|
+
function isConsoleOutputMember(name) {
|
|
8638
|
+
return name === "log" || name === "info" || name === "debug" || name === "error" || name === "warn";
|
|
8328
8639
|
}
|
|
8329
8640
|
//# sourceMappingURL=lower-builtins.js.map
|