@scriptc/compiler 0.2.3 → 0.2.5
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 +915 -215
- package/ambient/scriptc-overrides.d.ts +5 -1
- package/ambient/scriptc.d.ts +22 -2
- package/dist/backend/build-cache.d.ts +4 -0
- package/dist/backend/build-cache.js +16 -2
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cycle-analysis.js +17 -5
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +50 -11
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/debug-symbols.js.map +1 -1
- package/dist/backend/executable-features.js +2 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/external-c.d.ts +13 -6
- package/dist/backend/external-c.js +15 -3
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.js +6 -9
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +1 -1
- package/dist/backend/library-pack.js +81 -24
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.js +9 -2
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -1
- package/dist/backend/link-plan.js +4 -5
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/linker.d.ts +1 -1
- package/dist/backend/linker.js +42 -23
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.js +5 -4
- package/dist/backend/literals.js.map +1 -1
- package/dist/backend/literals.test.js +30 -5
- package/dist/backend/literals.test.js.map +1 -1
- package/dist/backend/llvm/blocks.test.js +5 -2
- package/dist/backend/llvm/blocks.test.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.d.ts +15 -0
- package/dist/backend/llvm/borrowed-inputs.js +28 -0
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -0
- package/dist/backend/llvm/borrowed-receivers.js +43 -19
- package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
- package/dist/backend/llvm/byte-numbers.d.ts +10 -0
- package/dist/backend/llvm/byte-numbers.js +240 -0
- package/dist/backend/llvm/byte-numbers.js.map +1 -0
- package/dist/backend/llvm/bytes-bounds.d.ts +9 -0
- package/dist/backend/llvm/bytes-bounds.js +240 -0
- package/dist/backend/llvm/bytes-bounds.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +10 -0
- package/dist/backend/llvm/call-lifetimes.js +83 -20
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +203 -18
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.d.ts +13 -0
- package/dist/backend/llvm/checked-value-lifetimes.js +45 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -0
- package/dist/backend/llvm/classes.js +16 -12
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.js +4 -1
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/counted-loops.d.ts +6 -0
- package/dist/backend/llvm/counted-loops.js +35 -0
- package/dist/backend/llvm/counted-loops.js.map +1 -0
- package/dist/backend/llvm/debug-info.js +33 -13
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/debug-info.test.js +28 -6
- package/dist/backend/llvm/debug-info.test.js.map +1 -1
- package/dist/backend/llvm/dyn.js +68 -22
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +34 -12
- package/dist/backend/llvm/emitter.js +357 -124
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +237 -46
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +28 -8
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +4 -4
- package/dist/backend/llvm/expr-bytes.js +78 -36
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +10 -4
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +40 -21
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +4 -1
- package/dist/backend/llvm/expr-containers.js +157 -76
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +11 -0
- package/dist/backend/llvm/expr-control.js +27 -8
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +3 -1
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +50 -33
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.js +26 -6
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +139 -37
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +43 -1
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +16 -9
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +44 -26
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +51 -14
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +34 -14
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +10 -0
- package/dist/backend/llvm/integer-values.js +52 -0
- package/dist/backend/llvm/integer-values.js.map +1 -0
- package/dist/backend/llvm/integer-views.d.ts +7 -0
- package/dist/backend/llvm/integer-views.js +83 -0
- package/dist/backend/llvm/integer-views.js.map +1 -0
- package/dist/backend/llvm/integer-views.test.d.ts +1 -0
- package/dist/backend/llvm/integer-views.test.js +69 -0
- package/dist/backend/llvm/integer-views.test.js.map +1 -0
- package/dist/backend/llvm/lib-abi.js +13 -4
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-connect.js +7 -1
- package/dist/backend/llvm/lib-connect.js.map +1 -1
- package/dist/backend/llvm/lib-datagram.js +35 -10
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +36 -15
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +38 -23
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +60 -15
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +12 -5
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +97 -31
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +57 -14
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +107 -31
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +33 -14
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +21 -7
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/lib-tls.js +69 -20
- package/dist/backend/llvm/lib-tls.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.d.ts +3 -4
- package/dist/backend/llvm/local-array-reads.js +100 -121
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +379 -71
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +25 -0
- package/dist/backend/llvm/local-union-storage.js +109 -0
- package/dist/backend/llvm/local-union-storage.js.map +1 -0
- package/dist/backend/llvm/local-union-storage.test.d.ts +1 -0
- package/dist/backend/llvm/local-union-storage.test.js +210 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +6 -2
- package/dist/backend/llvm/map-read-lifetimes.js +46 -16
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +93 -17
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.d.ts +23 -0
- package/dist/backend/llvm/reference-effects.js +179 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -0
- package/dist/backend/llvm/reference-effects.test.d.ts +1 -0
- package/dist/backend/llvm/reference-effects.test.js +157 -0
- package/dist/backend/llvm/reference-effects.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +7 -4
- package/dist/backend/llvm/shapes.js +82 -22
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -1
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split.js +4 -4
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +14 -6
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-unions.js +14 -5
- package/dist/backend/llvm/stack-unions.js.map +1 -1
- package/dist/backend/llvm/stack-unions.test.js +172 -32
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.d.ts +10 -0
- package/dist/backend/llvm/string-construction.js +38 -0
- package/dist/backend/llvm/string-construction.js.map +1 -0
- package/dist/backend/llvm/string-construction.test.d.ts +1 -0
- package/dist/backend/llvm/string-construction.test.js +90 -0
- package/dist/backend/llvm/string-construction.test.js.map +1 -0
- package/dist/backend/llvm/string-lifetimes.d.ts +2 -2
- package/dist/backend/llvm/string-lifetimes.js +19 -11
- package/dist/backend/llvm/string-lifetimes.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +127 -32
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.d.ts +9 -0
- package/dist/backend/llvm/switch-dispatch.js +114 -0
- package/dist/backend/llvm/switch-dispatch.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.test.d.ts +1 -0
- package/dist/backend/llvm/switch-dispatch.test.js +83 -0
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -0
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +6 -3
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.js +9 -3
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.js +18 -8
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +118 -22
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.d.ts +39 -0
- package/dist/backend/native/artifact-stamps.js +371 -0
- package/dist/backend/native/artifact-stamps.js.map +1 -0
- package/dist/backend/native/cache-warm.d.ts +24 -0
- package/dist/backend/native/cache-warm.js +80 -0
- package/dist/backend/native/cache-warm.js.map +1 -0
- package/dist/backend/native/compiler-fingerprint.d.ts +19 -0
- package/dist/backend/native/compiler-fingerprint.js +357 -0
- package/dist/backend/native/compiler-fingerprint.js.map +1 -0
- package/dist/backend/native/contracts.d.ts +314 -0
- package/dist/backend/native/contracts.js +2 -0
- package/dist/backend/native/contracts.js.map +1 -0
- package/dist/backend/native/dependency-files.d.ts +5 -0
- package/dist/backend/native/dependency-files.js +83 -0
- package/dist/backend/native/dependency-files.js.map +1 -0
- package/dist/backend/native/driver.d.ts +50 -0
- package/dist/backend/native/driver.js +294 -0
- package/dist/backend/native/driver.js.map +1 -0
- package/dist/backend/native/executable.d.ts +18 -0
- package/dist/backend/native/executable.js +1267 -0
- package/dist/backend/native/executable.js.map +1 -0
- package/dist/backend/native/library.d.ts +2 -0
- package/dist/backend/native/library.js +614 -0
- package/dist/backend/native/library.js.map +1 -0
- package/dist/backend/native/linker-fingerprint.d.ts +8 -0
- package/dist/backend/native/linker-fingerprint.js +174 -0
- package/dist/backend/native/linker-fingerprint.js.map +1 -0
- package/dist/backend/native/object-merge.d.ts +2 -0
- package/dist/backend/native/object-merge.js +154 -0
- package/dist/backend/native/object-merge.js.map +1 -0
- package/dist/backend/native/process.d.ts +17 -0
- package/dist/backend/native/process.js +42 -0
- package/dist/backend/native/process.js.map +1 -0
- package/dist/backend/native/program-shards.d.ts +21 -0
- package/dist/backend/native/program-shards.js +99 -0
- package/dist/backend/native/program-shards.js.map +1 -0
- package/dist/backend/native/runtime-inputs.d.ts +12 -0
- package/dist/backend/native/runtime-inputs.js +163 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -0
- package/dist/backend/native/runtime-inputs.test.d.ts +1 -0
- package/dist/backend/native/runtime-inputs.test.js +64 -0
- package/dist/backend/native/runtime-inputs.test.js.map +1 -0
- package/dist/backend/native/runtime-objects.d.ts +16 -0
- package/dist/backend/native/runtime-objects.js +122 -0
- package/dist/backend/native/runtime-objects.js.map +1 -0
- package/dist/backend/native/session.d.ts +12 -0
- package/dist/backend/native/session.js +31 -0
- package/dist/backend/native/session.js.map +1 -0
- package/dist/backend/native/tool-identity.d.ts +37 -0
- package/dist/backend/native/tool-identity.js +310 -0
- package/dist/backend/native/tool-identity.js.map +1 -0
- package/dist/backend/native/trace-paths.d.ts +12 -0
- package/dist/backend/native/trace-paths.js +73 -0
- package/dist/backend/native/trace-paths.js.map +1 -0
- package/dist/backend/native/vendor.d.ts +1 -0
- package/dist/backend/native/vendor.js +12 -0
- package/dist/backend/native/vendor.js.map +1 -0
- package/dist/backend/native-codegen-core.js +2 -1
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +1 -1
- package/dist/backend/native-codegen.js +24 -13
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +12 -9
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.js +9 -5
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +14 -5
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +58 -13
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +17 -450
- package/dist/backend/native-toolchain.js +17 -3971
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +103 -72
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.js +27 -8
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/object-localize.js +17 -14
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +59 -12
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-pack-core.js +96 -49
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.js +5 -3
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +87 -15
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +1 -1
- package/dist/backend/runtime-pack.js +11 -12
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +40 -24
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/source-locations.js.map +1 -1
- package/dist/backend/source-locations.test.js +7 -2
- package/dist/backend/source-locations.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +44 -14
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +93 -20
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/backend/targets.js +230 -86
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +32 -18
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.js +5 -1
- package/dist/backend/toolchain-environment.js.map +1 -1
- package/dist/backend/vendor-archives.d.ts +2 -2
- package/dist/backend/vendor-archives.js +84 -35
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.js +13 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.d.ts +1 -1
- package/dist/backend/warm-cache.js +33 -9
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +39 -9
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/output-options.js +14 -4
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/paths.js.map +1 -1
- package/dist/cli/wasi-runner.js.map +1 -1
- package/dist/compat/fetch-profile.js +36 -35
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/report.js +16 -17
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +112 -26
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +55 -16
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +1 -1
- package/dist/executable/executable-cache.js +78 -48
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +75 -26
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +2 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/ffi/ffi-manifest.js +78 -20
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.js +96 -16
- package/dist/ffi/ffi-manifest.test.js.map +1 -1
- package/dist/format-integer.js.map +1 -1
- package/dist/frontend/analysis.js +12 -2
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/binding-source.js +9 -3
- package/dist/frontend/binding-source.js.map +1 -1
- package/dist/frontend/builtin-modules.js +46 -2
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-resolve.js +40 -17
- package/dist/frontend/cjs-resolve.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +31 -10
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/comptime-node.test.js +10 -11
- package/dist/frontend/comptime-node.test.js.map +1 -1
- package/dist/frontend/dts-paths.js +7 -3
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +17 -12
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/function-completion.js +11 -6
- package/dist/frontend/function-completion.js.map +1 -1
- package/dist/frontend/helper-tokens.js +53 -6
- package/dist/frontend/helper-tokens.js.map +1 -1
- package/dist/frontend/helper-tokens.test.js +18 -2
- package/dist/frontend/helper-tokens.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.js +32 -12
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +11 -15
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.js +11 -11
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +4 -1
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +38 -9
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.js.map +1 -1
- package/dist/frontend/literal-values.test.js +28 -8
- package/dist/frontend/literal-values.test.js.map +1 -1
- package/dist/frontend/lowering/abstract-equality.js +53 -10
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.d.ts +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +108 -106
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +37 -14
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +50 -0
- package/dist/frontend/lowering/binding-analysis.js +376 -0
- package/dist/frontend/lowering/binding-analysis.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.d.ts +9 -0
- package/dist/frontend/lowering/builtin-calls.js +60 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +43 -0
- package/dist/frontend/lowering/builtins/arguments.js +247 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -0
- package/dist/frontend/lowering/builtins/async-context.d.ts +52 -0
- package/dist/frontend/lowering/builtins/async-context.js +436 -0
- package/dist/frontend/lowering/builtins/async-context.js.map +1 -0
- package/dist/frontend/lowering/builtins/atomics.d.ts +15 -0
- package/dist/frontend/lowering/builtins/atomics.js +46 -0
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -0
- package/dist/frontend/lowering/builtins/callable-aliases.d.ts +13 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js +87 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-async.d.ts +18 -0
- package/dist/frontend/lowering/builtins/child-process-async.js +245 -0
- package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +21 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +362 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +4 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +639 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process.d.ts +55 -0
- package/dist/frontend/lowering/builtins/child-process.js +669 -0
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -0
- package/dist/frontend/lowering/builtins/compression.d.ts +7 -0
- package/dist/frontend/lowering/builtins/compression.js +115 -0
- package/dist/frontend/lowering/builtins/compression.js.map +1 -0
- package/dist/frontend/lowering/builtins/console.d.ts +10 -0
- package/dist/frontend/lowering/builtins/console.js +38 -0
- package/dist/frontend/lowering/builtins/console.js.map +1 -0
- package/dist/frontend/lowering/builtins/constants.d.ts +24 -0
- package/dist/frontend/lowering/builtins/constants.js +141 -0
- package/dist/frontend/lowering/builtins/constants.js.map +1 -0
- package/dist/frontend/lowering/builtins/crypto.d.ts +22 -0
- package/dist/frontend/lowering/builtins/crypto.js +517 -0
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -0
- package/dist/frontend/lowering/builtins/dates.d.ts +7 -0
- package/dist/frontend/lowering/builtins/dates.js +101 -0
- package/dist/frontend/lowering/builtins/dates.js.map +1 -0
- package/dist/frontend/lowering/builtins/environment.d.ts +34 -0
- package/dist/frontend/lowering/builtins/environment.js +95 -0
- package/dist/frontend/lowering/builtins/environment.js.map +1 -0
- package/dist/frontend/lowering/builtins/errors.d.ts +14 -0
- package/dist/frontend/lowering/builtins/errors.js +83 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +32 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +678 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/filesystem.d.ts +108 -0
- package/dist/frontend/lowering/builtins/filesystem.js +1061 -0
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -0
- package/dist/frontend/lowering/builtins/ipc.d.ts +8 -0
- package/dist/frontend/lowering/builtins/ipc.js +76 -0
- package/dist/frontend/lowering/builtins/ipc.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.d.ts +12 -0
- package/dist/frontend/lowering/builtins/json.js +387 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +85 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +346 -0
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-calls.js +303 -0
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +38 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +344 -0
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -0
- package/dist/frontend/lowering/builtins/numbers.d.ts +15 -0
- package/dist/frontend/lowering/builtins/numbers.js +124 -0
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -0
- package/dist/frontend/lowering/builtins/operating-system.d.ts +13 -0
- package/dist/frontend/lowering/builtins/operating-system.js +148 -0
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -0
- package/dist/frontend/lowering/builtins/performance.d.ts +13 -0
- package/dist/frontend/lowering/builtins/performance.js +100 -0
- package/dist/frontend/lowering/builtins/performance.js.map +1 -0
- package/dist/frontend/lowering/builtins/process.d.ts +50 -0
- package/dist/frontend/lowering/builtins/process.js +1138 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -0
- package/dist/frontend/lowering/builtins/promises.d.ts +14 -0
- package/dist/frontend/lowering/builtins/promises.js +356 -0
- package/dist/frontend/lowering/builtins/promises.js.map +1 -0
- package/dist/frontend/lowering/builtins/properties.d.ts +11 -0
- package/dist/frontend/lowering/builtins/properties.js +186 -0
- package/dist/frontend/lowering/builtins/properties.js.map +1 -0
- package/dist/frontend/lowering/builtins/querystring.d.ts +19 -0
- package/dist/frontend/lowering/builtins/querystring.js +150 -0
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -0
- package/dist/frontend/lowering/builtins/readline.d.ts +13 -0
- package/dist/frontend/lowering/builtins/readline.js +138 -0
- package/dist/frontend/lowering/builtins/readline.js.map +1 -0
- package/dist/frontend/lowering/builtins/receiver-types.d.ts +5 -0
- package/dist/frontend/lowering/builtins/receiver-types.js +15 -0
- package/dist/frontend/lowering/builtins/receiver-types.js.map +1 -0
- package/dist/frontend/lowering/builtins/reflection.d.ts +13 -0
- package/dist/frontend/lowering/builtins/reflection.js +95 -0
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -0
- package/dist/frontend/lowering/builtins/strings.d.ts +14 -0
- package/dist/frontend/lowering/builtins/strings.js +121 -0
- package/dist/frontend/lowering/builtins/strings.js.map +1 -0
- package/dist/frontend/lowering/builtins/text-codecs.d.ts +29 -0
- package/dist/frontend/lowering/builtins/text-codecs.js +590 -0
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -0
- package/dist/frontend/lowering/builtins/timers.d.ts +22 -0
- package/dist/frontend/lowering/builtins/timers.js +180 -0
- package/dist/frontend/lowering/builtins/timers.js.map +1 -0
- package/dist/frontend/lowering/builtins/url.d.ts +37 -0
- package/dist/frontend/lowering/builtins/url.js +596 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -0
- package/dist/frontend/lowering/builtins/util-types.d.ts +7 -0
- package/dist/frontend/lowering/builtins/util-types.js +31 -0
- package/dist/frontend/lowering/builtins/util-types.js.map +1 -0
- package/dist/frontend/lowering/call-arguments.d.ts +72 -0
- package/dist/frontend/lowering/call-arguments.js +618 -0
- package/dist/frontend/lowering/call-arguments.js.map +1 -0
- package/dist/frontend/lowering/call-signatures.d.ts +115 -0
- package/dist/frontend/lowering/call-signatures.js +719 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/checked-iterable-spread.js +53 -10
- package/dist/frontend/lowering/checked-iterable-spread.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.js +41 -9
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +1 -1
- package/dist/frontend/lowering/class-callbacks.js +130 -27
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +1 -1
- package/dist/frontend/lowering/class-construction.js +247 -50
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-descriptors.js +109 -29
- package/dist/frontend/lowering/class-descriptors.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +2471 -465
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +284 -44
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-instance-constructor.js +17 -5
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -1
- package/dist/frontend/lowering/class-method-values.js +199 -51
- package/dist/frontend/lowering/class-method-values.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +345 -86
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +1 -1
- package/dist/frontend/lowering/class-runtime-statics.js +80 -17
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-static-data.js +76 -16
- package/dist/frontend/lowering/class-static-data.js.map +1 -1
- package/dist/frontend/lowering/coercions/builders.d.ts +13 -0
- package/dist/frontend/lowering/coercions/builders.js +77 -0
- package/dist/frontend/lowering/coercions/builders.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +58 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +430 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -0
- package/dist/frontend/lowering/coercions/island.d.ts +37 -0
- package/dist/frontend/lowering/coercions/island.js +350 -0
- package/dist/frontend/lowering/coercions/island.js.map +1 -0
- package/dist/frontend/lowering/coercions/state.d.ts +14 -0
- package/dist/frontend/lowering/coercions/state.js +16 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural-plans.d.ts +40 -0
- package/dist/frontend/lowering/coercions/structural-plans.js +447 -0
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural.d.ts +63 -0
- package/dist/frontend/lowering/coercions/structural.js +616 -0
- package/dist/frontend/lowering/coercions/structural.js.map +1 -0
- package/dist/frontend/lowering/coercions/unions.d.ts +65 -0
- package/dist/frontend/lowering/coercions/unions.js +318 -0
- package/dist/frontend/lowering/coercions/unions.js.map +1 -0
- package/dist/frontend/lowering/collection-ingestion.js +359 -67
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +92 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +1646 -0
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -0
- package/dist/frontend/lowering/containers/array-construction.d.ts +42 -0
- package/dist/frontend/lowering/containers/array-construction.js +1044 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -0
- package/dist/frontend/lowering/containers/array-iteration.d.ts +16 -0
- package/dist/frontend/lowering/containers/array-iteration.js +95 -0
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -0
- package/dist/frontend/lowering/containers/array-methods.d.ts +27 -0
- package/dist/frontend/lowering/containers/array-methods.js +1854 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +17 -17
- package/dist/frontend/lowering/containers/bytes.js +419 -105
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +26 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +179 -0
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -0
- package/dist/frontend/lowering/containers/collection-grouping.d.ts +19 -0
- package/dist/frontend/lowering/containers/collection-grouping.js +297 -0
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -0
- package/dist/frontend/lowering/containers/collection-methods.d.ts +57 -0
- package/dist/frontend/lowering/containers/collection-methods.js +1314 -0
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.d.ts +18 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.js +114 -0
- package/dist/frontend/lowering/containers/dynamic-receivers.js.map +1 -0
- package/dist/frontend/lowering/containers/for-of.d.ts +60 -0
- package/dist/frontend/lowering/containers/for-of.js +643 -0
- package/dist/frontend/lowering/containers/for-of.js.map +1 -0
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +132 -0
- package/dist/frontend/lowering/containers/indexed-objects.js +1743 -0
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -0
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +20 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +809 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +585 -157
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +213 -63
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.js +263 -64
- package/dist/frontend/lowering/crypto-tables.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +172 -68
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +41 -8
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/error-methods.js +339 -65
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +3 -2
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/global-symbols.js +2 -1
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +11 -5
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +67 -13
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +589 -162
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +68 -17
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.js +45 -18
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +5 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.d.ts +67 -0
- package/dist/frontend/lowering/function-returns.js +392 -0
- package/dist/frontend/lowering/function-returns.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +1 -1
- package/dist/frontend/lowering/generator-delegation.js +171 -39
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +176 -36
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +274 -0
- package/dist/frontend/lowering/generic-functions.js +1727 -0
- package/dist/frontend/lowering/generic-functions.js.map +1 -0
- package/dist/frontend/lowering/import-meta.d.ts +1 -1
- package/dist/frontend/lowering/import-meta.js +37 -14
- package/dist/frontend/lowering/import-meta.js.map +1 -1
- package/dist/frontend/lowering/indexed-comparison.js +6 -2
- package/dist/frontend/lowering/indexed-comparison.js.map +1 -1
- package/dist/frontend/lowering/iterator-consumption.d.ts +9 -0
- package/dist/frontend/lowering/iterator-consumption.js +91 -0
- package/dist/frontend/lowering/iterator-consumption.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.js +40 -17
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.js +49 -11
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +0 -19
- package/dist/frontend/lowering/lower-array-sort.js +331 -566
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +248 -43
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +71 -16
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +420 -71
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +39 -558
- package/dist/frontend/lowering/lower-calls.js +2593 -5667
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +243 -242
- package/dist/frontend/lowering/lower-classes.js +1704 -727
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +35 -35
- package/dist/frontend/lowering/lower-comptime.js +39 -37
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +59 -31
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -2
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +322 -85
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +19 -7
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +194 -194
- package/dist/frontend/lowering/lower-exprs.js +3455 -1153
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +23 -0
- package/dist/frontend/lowering/lower-functions.js +449 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -0
- package/dist/frontend/lowering/lower-generators.js +121 -32
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.js +15 -4
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +479 -89
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +79 -79
- package/dist/frontend/lowering/lower-island.js +365 -273
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-island.test.js +7 -2
- package/dist/frontend/lowering/lower-island.test.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +17 -8
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +94 -94
- package/dist/frontend/lowering/lower-modules.js +612 -321
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +91 -20
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +25 -8
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.js +115 -34
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +1210 -290
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +148 -148
- package/dist/frontend/lowering/lower-stmts.js +2312 -984
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +13 -5
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +362 -90
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-system-errors.js +30 -8
- package/dist/frontend/lowering/lower-system-errors.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +40 -13
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.d.ts +31 -0
- package/dist/frontend/lowering/lower-timers.js +336 -0
- package/dist/frontend/lowering/lower-timers.js.map +1 -0
- package/dist/frontend/lowering/lower-url.d.ts +1 -1
- package/dist/frontend/lowering/lower-url.js +46 -13
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +21 -351
- package/dist/frontend/lowering/lowerer.js +1031 -2704
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +85 -17
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.js +43 -8
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.d.ts +21 -1
- package/dist/frontend/lowering/native-ffi.js +487 -18
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/object-enumeration-receiver.js +55 -10
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
- package/dist/frontend/lowering/object-factory-new.d.ts +1 -1
- package/dist/frontend/lowering/object-factory-new.js +36 -11
- package/dist/frontend/lowering/object-factory-new.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.js +49 -20
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +66 -14
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.js +3 -1
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.js +4 -1
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +86 -18
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -1
- package/dist/frontend/lowering/static-this.js +13 -6
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.js +32 -10
- package/dist/frontend/lowering/string-index.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +42 -42
- package/dist/frontend/lowering/surfaces.js +1094 -249
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.js +40 -15
- package/dist/frontend/lowering/symbol-fields.js.map +1 -1
- package/dist/frontend/lowering/symbol-methods.js.map +1 -1
- package/dist/frontend/lowering/text-decoder-encoding.js +236 -24
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -1
- package/dist/frontend/lowering/text-decoder-encoding.test.js +84 -12
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -1
- package/dist/frontend/lowering/union-narrow.js +59 -16
- package/dist/frontend/lowering/union-narrow.js.map +1 -1
- package/dist/frontend/lowering/union-narrow.test.js +24 -7
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -1
- package/dist/frontend/lowering/union-retag.js +155 -40
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +131 -33
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -1
- package/dist/frontend/lowering/unregistered-class-types.test.js +34 -8
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -1
- package/dist/frontend/module-syntax.js +21 -8
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/module-syntax.test.js +37 -13
- package/dist/frontend/module-syntax.test.js.map +1 -1
- package/dist/frontend/npm-fetch-analysis.js +13 -4
- package/dist/frontend/npm-fetch-analysis.js.map +1 -1
- package/dist/frontend/npm-fetch-analysis.test.js +33 -10
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -1
- package/dist/frontend/npm-fetch-node.js.map +1 -1
- package/dist/frontend/npm-fetch-syntax.js +4 -9
- package/dist/frontend/npm-fetch-syntax.js.map +1 -1
- package/dist/frontend/npm-node.js +3 -1
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-bundled-cjs.js +88 -29
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -1
- package/dist/frontend/npm-static-bundled-cjs.test.js +29 -10
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -1
- package/dist/frontend/npm-static-declaration-syntax.js +148 -56
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -1
- package/dist/frontend/npm-static-declarations.d.ts +1 -1
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +33 -7
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.js +26 -12
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +17 -3
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.js +2 -3
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +64 -21
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.js +9 -4
- package/dist/frontend/npm-static-subtyping.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.test.js +30 -6
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -1
- package/dist/frontend/npm-static.js +15 -4
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +122 -36
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +30 -10
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.js +25 -8
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +21 -7
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-node.js +5 -3
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +2 -2
- package/dist/frontend/program.js +234 -101
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +27 -27
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +8 -4
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.js +1 -4
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.js +32 -20
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +1 -1
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +13 -4
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +25 -9
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.js +6 -2
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +18 -6
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.js +8 -4
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +6 -2
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/ts7/api.js +12 -4
- package/dist/frontend/ts7/api.js.map +1 -1
- package/dist/frontend/ts7/ast-bytes.js +10 -3
- package/dist/frontend/ts7/ast-bytes.js.map +1 -1
- package/dist/frontend/ts7/ast-bytes.test.js +23 -4
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -1
- package/dist/frontend/ts7/ast-guards.test.js +14 -5
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +484 -164
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +109 -36
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-text.js +13 -3
- package/dist/frontend/ts7/ast-text.js.map +1 -1
- package/dist/frontend/ts7/ast-text.test.js.map +1 -1
- package/dist/frontend/ts7/ast-types.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +1 -1
- package/dist/frontend/ts7/ast-wire.js +55 -20
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.test.js +53 -8
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
- package/dist/frontend/ts7/ast.js +47 -28
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -1
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.js.map +1 -1
- package/dist/frontend/ts7/checker.js +5 -3
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +54 -17
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/enums.test.js +9 -4
- package/dist/frontend/ts7/enums.test.js.map +1 -1
- package/dist/frontend/ts7/native-api.js.map +1 -1
- package/dist/frontend/ts7/native-host.js.map +1 -1
- package/dist/frontend/ts7/native-process.js +9 -3
- package/dist/frontend/ts7/native-process.js.map +1 -1
- package/dist/frontend/ts7/program-adapter.js +1 -1
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.js +7 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +43 -11
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-api.js +3 -1
- package/dist/frontend/ts7/rpc-api.js.map +1 -1
- package/dist/frontend/ts7/rpc-client.js +15 -5
- package/dist/frontend/ts7/rpc-client.js.map +1 -1
- package/dist/frontend/ts7/rpc-client.test.js +26 -8
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.test.js +43 -10
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.js +16 -6
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-wire.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.js +41 -14
- package/dist/frontend/ts7/rpc-wire.js.map +1 -1
- package/dist/frontend/ts7/rpc-wire.test.js +36 -6
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.js +209 -68
- package/dist/frontend/ts7/semantic-checker.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.test.js +29 -14
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.js +7 -1
- package/dist/frontend/ts7/semantic-json.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.test.js +17 -3
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.js +147 -51
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +72 -19
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-types.d.ts +2 -2
- package/dist/frontend/ts7/session-cache.js +10 -3
- package/dist/frontend/ts7/session-cache.js.map +1 -1
- package/dist/frontend/ts7/session-cache.test.js +13 -4
- package/dist/frontend/ts7/session-cache.test.js.map +1 -1
- package/dist/frontend/ts7/session-path.js +25 -10
- package/dist/frontend/ts7/session-path.js.map +1 -1
- package/dist/frontend/ts7/session-path.test.js +47 -4
- package/dist/frontend/ts7/session-path.test.js.map +1 -1
- package/dist/frontend/ts7/session-timing.js +22 -3
- package/dist/frontend/ts7/session-timing.js.map +1 -1
- package/dist/frontend/ts7/session-timing.test.js +12 -3
- package/dist/frontend/ts7/session-timing.test.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +1 -0
- package/dist/frontend/ts7/session.js +109 -35
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/session.test.js +69 -15
- package/dist/frontend/ts7/session.test.js.map +1 -1
- package/dist/frontend/ts7/source-parser.js +17 -6
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +32 -9
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +56 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.d.ts +1 -0
- package/dist/frontend/tsc-codes.test.js +16 -0
- package/dist/frontend/tsc-codes.test.js.map +1 -0
- package/dist/frontend/type-mapper.js +547 -206
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +108 -33
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/union-discriminants.js +8 -2
- package/dist/frontend/union-discriminants.js.map +1 -1
- package/dist/frontend/union-discriminants.test.js +77 -20
- package/dist/frontend/union-discriminants.test.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +150 -81
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +97 -38
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +91 -15
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/api.d.ts +4 -0
- package/dist/ir/api.js +6 -0
- package/dist/ir/api.js.map +1 -0
- package/dist/ir/build.d.ts +7 -0
- package/dist/ir/build.js +27 -1
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.d.ts +9 -0
- package/dist/ir/builtin-effects.js +631 -0
- package/dist/ir/builtin-effects.js.map +1 -0
- package/dist/ir/builtin-signatures.d.ts +15 -0
- package/dist/ir/builtin-signatures.js +3396 -0
- package/dist/ir/builtin-signatures.js.map +1 -0
- package/dist/ir/byte-numbers.d.ts +20 -0
- package/dist/ir/byte-numbers.js +116 -0
- package/dist/ir/byte-numbers.js.map +1 -0
- package/dist/ir/byte-numbers.test.d.ts +1 -0
- package/dist/ir/byte-numbers.test.js +55 -0
- package/dist/ir/byte-numbers.test.js.map +1 -0
- package/dist/ir/constant-tables.js +13 -5
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +47 -7
- package/dist/ir/constant-tables.test.js.map +1 -1
- package/dist/ir/control-flow.js +2 -1
- package/dist/ir/control-flow.js.map +1 -1
- package/dist/ir/control-flow.test.js +35 -11
- package/dist/ir/control-flow.test.js.map +1 -1
- package/dist/ir/initializer-bindings.d.ts +9 -0
- package/dist/ir/initializer-bindings.js +115 -0
- package/dist/ir/initializer-bindings.js.map +1 -0
- package/dist/ir/initializer-bindings.test.d.ts +1 -0
- package/dist/ir/initializer-bindings.test.js +118 -0
- package/dist/ir/initializer-bindings.test.js.map +1 -0
- package/dist/ir/integer-loop-facts.d.ts +12 -0
- package/dist/ir/integer-loop-facts.js +137 -0
- package/dist/ir/integer-loop-facts.js.map +1 -0
- package/dist/ir/integer-loops.d.ts +19 -0
- package/dist/ir/integer-loops.js +172 -11
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +122 -9
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +8 -6
- package/dist/ir/integer-ranges.js +416 -90
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +239 -10
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.d.ts +20 -0
- package/dist/ir/intrinsic-signatures.js +57 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -0
- package/dist/ir/ir.d.ts +14 -2155
- package/dist/ir/ir.js +169 -1394
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +98 -77
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +221 -0
- package/dist/ir/runtime-features.js +551 -0
- package/dist/ir/runtime-features.js.map +1 -0
- package/dist/ir/runtime-features.test.d.ts +1 -0
- package/dist/ir/runtime-features.test.js +98 -0
- package/dist/ir/runtime-features.test.js.map +1 -0
- package/dist/ir/scalar-records.js +130 -40
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +146 -27
- package/dist/ir/scalar-records.test.js.map +1 -1
- package/dist/ir/serialize.js +4 -2
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +44 -9
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/traverse.js +156 -43
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/traverse.test.js +99 -24
- package/dist/ir/traverse.test.js.map +1 -1
- package/dist/ir/validate.d.ts +1 -31
- package/dist/ir/validate.js +826 -1915
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +627 -111
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.js +9 -10
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/cache-reset.test.js +2 -1
- package/dist/library/cache-reset.test.js.map +1 -1
- package/dist/library/compiler-self-identity.js +11 -5
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +10 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/fence-eval.js +24 -7
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/fence-eval.test.js +31 -7
- package/dist/library/fence-eval.test.js.map +1 -1
- package/dist/library/int-infer.js +199 -59
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +133 -57
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/ir-policy.d.ts +27 -0
- package/dist/library/ir-policy.js +232 -0
- package/dist/library/ir-policy.js.map +1 -0
- package/dist/library/library-cache.js +40 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +24 -13
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.js +68 -13
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.js +48 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/library/semantic-source.js +16 -14
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/semantic-source.test.js +9 -14
- package/dist/library/semantic-source.test.js.map +1 -1
- package/dist/library/sidecar-validate.js +53 -12
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.js +85 -24
- package/dist/library/sidecar.js.map +1 -1
- package/dist/library/trap-teaching.js +11 -2
- package/dist/library/trap-teaching.js.map +1 -1
- package/dist/native/cache.js +10 -4
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cli.js +34 -9
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +167 -43
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +129 -32
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/comptime.js +23 -7
- package/dist/native/comptime.js.map +1 -1
- package/dist/native/comptime.test.js +26 -6
- package/dist/native/comptime.test.js.map +1 -1
- package/dist/native/executable-cache.js +77 -27
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/executable-cache.test.js +41 -6
- package/dist/native/executable-cache.test.js.map +1 -1
- package/dist/native/file-identity.js +9 -2
- package/dist/native/file-identity.js.map +1 -1
- package/dist/native/file-identity.test.js.map +1 -1
- package/dist/native/library.js +50 -12
- package/dist/native/library.js.map +1 -1
- package/dist/native/prepare.js +119 -34
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +22 -6
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/runtime-typescript.js +24 -11
- package/dist/native/runtime-typescript.js.map +1 -1
- package/dist/native/runtime-typescript.test.js.map +1 -1
- package/dist/native/sanitizer.js +71 -18
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +77 -20
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/task.js.map +1 -1
- package/dist/native/task.test.js +7 -2
- package/dist/native/task.test.js.map +1 -1
- package/dist/native/toolchain.js +74 -29
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +95 -18
- package/dist/native/toolchain.test.js.map +1 -1
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +1 -1
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +0 -601
- package/dist/frontend/lowering/lower-builtins.js +0 -8984
- package/dist/frontend/lowering/lower-builtins.js.map +0 -1
- package/dist/frontend/lowering/lower-containers.d.ts +0 -382
- package/dist/frontend/lowering/lower-containers.js +0 -7366
- package/dist/frontend/lowering/lower-containers.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dynUndefinedExpr } from "../../ir/build.js";
|
|
1
2
|
import { everyStmtList, everyTypeChild } from "../../ir/traverse.js";
|
|
2
3
|
import { InternalCompilerError } from "../../errors.js";
|
|
3
4
|
/* Module-graph lowering: splitting each source file into its parts, the
|
|
@@ -7,26 +8,30 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
7
8
|
import * as ts from "../ts7/adapter.js";
|
|
8
9
|
import { bindingSource } from "../binding-source.js";
|
|
9
10
|
import { dirname as dirnamePath, isAbsolute, resolve as resolvePath } from "node:path";
|
|
10
|
-
import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal } from "../npm.js";
|
|
11
|
+
import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal, } from "../npm.js";
|
|
11
12
|
import { isNpmStaticPackage } from "../npm-static.js";
|
|
12
13
|
import { isJsSourceFileName } from "../tsc-codes.js";
|
|
13
14
|
import { isRelativeSpecifier } from "../workspace-registry.js";
|
|
14
|
-
import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport } from "../program.js";
|
|
15
|
-
import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag } from "../../diagnostics/diagnostic.js";
|
|
16
|
-
import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType } from "../../ir/ir.js";
|
|
17
|
-
import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType,
|
|
18
|
-
import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf,
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
15
|
+
import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport, } from "../program.js";
|
|
16
|
+
import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag, } from "../../diagnostics/diagnostic.js";
|
|
17
|
+
import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType, } from "../../ir/ir.js";
|
|
18
|
+
import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, importCallHandleType, newFnCtx, staticImportNamespaceType, uncheckedOverloadHandleCall, } from "./lowerer.js";
|
|
19
|
+
import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf, } from "./builtins/module-bindings.js";
|
|
20
|
+
import { isPromisifyCall, registerBuiltinCallableAlias } from "./builtins/callable-aliases.js";
|
|
21
|
+
import { stripTypeCasts } from "./builtins/arguments.js";
|
|
22
|
+
import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, implicitLocalFnInfoOf, implicitLocalFnNodeOf, } from "./generic-functions.js";
|
|
23
|
+
import { bindingNeverReassigned, deadUnmappableBinding, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
|
|
24
|
+
import { funcTypeFromParamShapes, registerOverloadedCallableAlias } from "./call-signatures.js";
|
|
25
|
+
import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl, } from "./lower-stmts.js";
|
|
21
26
|
import { objectFactoryGlobalType } from "./object-factory-new.js";
|
|
22
27
|
import { streamClassAliasDecl } from "./lower-stream.js";
|
|
23
28
|
import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
|
|
24
29
|
import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
|
|
25
|
-
import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf } from "./lower-namespaces.js";
|
|
30
|
+
import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
|
|
26
31
|
import { collectExpandoMembers } from "./lower-expando.js";
|
|
27
32
|
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
28
33
|
import { isUnitOnlyTsType, unitOnlyUnion } from "../type-mapper.js";
|
|
29
|
-
import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType } from "./lower-classes.js";
|
|
34
|
+
import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType, } from "./lower-classes.js";
|
|
30
35
|
import { isMixinFnBinding, mixinResultBindingClassOf } from "./lower-mixins.js";
|
|
31
36
|
import { cjsModuleRef, cjsModuleRegistryPrelude } from "./lower-node-module.js";
|
|
32
37
|
import { forkTargetPaths } from "../fork-target.js";
|
|
@@ -88,10 +93,10 @@ export function appendForkModules(program, order, targets, onCycle) {
|
|
|
88
93
|
order.splice(order.length - 1, 0, ...added);
|
|
89
94
|
}
|
|
90
95
|
/** Splits each file into function/class declarations and the top-level
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
* statements that form its init body. Node's evaluation order (depth-first
|
|
97
|
+
* postorder, entry last), computed by preflight. Single-file programs
|
|
98
|
+
* (tests, coverage on broken files) may arrive with an empty order — fall
|
|
99
|
+
* back to the entry alone. */
|
|
95
100
|
export function splitFiles(lowerer) {
|
|
96
101
|
const files = lowerer.moduleOrder.length > 0 ? lowerer.moduleOrder : [lowerer.entry];
|
|
97
102
|
return files.map((sf) => {
|
|
@@ -123,10 +128,10 @@ export function splitFiles(lowerer) {
|
|
|
123
128
|
});
|
|
124
129
|
}
|
|
125
130
|
/** A source file dynamic `import("<project specifier>")` can host as a COMPILED
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
* module namespace (lowerOwnModuleImport): a non-declaration program file
|
|
132
|
+
* that is not JSON and not CommonJS-flavored (a CJS namespace is built
|
|
133
|
+
* from module.exports through Node's lexer — a different surface with no
|
|
134
|
+
* static story here). Null for everything else. */
|
|
130
135
|
function dynamicImportProgramTargetOf(program, sf, spec) {
|
|
131
136
|
const dep = resolveImport(program, sf, spec);
|
|
132
137
|
if (!dep || dep.isDeclarationFile)
|
|
@@ -138,7 +143,7 @@ function dynamicImportProgramTargetOf(program, sf, spec) {
|
|
|
138
143
|
return dep;
|
|
139
144
|
}
|
|
140
145
|
/** Every distinct program module a file's `import("literal")` sites name
|
|
141
|
-
|
|
146
|
+
* (source order, deduped). */
|
|
142
147
|
function dynamicProgramImportsOf(program, sf) {
|
|
143
148
|
const out = [];
|
|
144
149
|
const seen = new Set();
|
|
@@ -157,21 +162,21 @@ function dynamicProgramImportsOf(program, sf) {
|
|
|
157
162
|
return out;
|
|
158
163
|
}
|
|
159
164
|
/** --dynamic builds: program modules reachable ONLY through dynamic
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
* `import()` join the compiled module graph — appended to `order` (before
|
|
166
|
+
* the entry, which stays last) in depth-first postorder over their own
|
|
167
|
+
* static import edges, exactly like preflight ordered the static graph.
|
|
168
|
+
* NOTHING calls their %init at startup (%main runs only the entry's init,
|
|
169
|
+
* and no static import header names these), so a dynamic-only module
|
|
170
|
+
* still evaluates exactly when Node evaluates it: the import() site's
|
|
171
|
+
* namespace builder calls the guarded init on the engine microtask.
|
|
172
|
+
* Fixpoint: an added module's own import() sites are scanned too. Static
|
|
173
|
+
* cycles inside the added subgraph ride preflight's own admission engine
|
|
174
|
+
* (makeCycleAdmission — preflight only walked the entry's static graph,
|
|
175
|
+
* so it never judged these): benign back edges are Node cache hits the
|
|
176
|
+
* run-once init guards reproduce, and inadmissible ones get preflight's
|
|
177
|
+
* SC1016 with the same narrowed reason via `onCycle`. Idempotent —
|
|
178
|
+
* re-running on an already-extended order adds nothing (both lowering
|
|
179
|
+
* passes share one array). */
|
|
175
180
|
export function appendDynamicImportModules(program, order, onCycle) {
|
|
176
181
|
if (order.length === 0)
|
|
177
182
|
return; // no preflight order — sites keep their fences
|
|
@@ -224,10 +229,10 @@ export function appendDynamicImportModules(program, order, onCycle) {
|
|
|
224
229
|
order.splice(order.length - 1, 0, ...added);
|
|
225
230
|
}
|
|
226
231
|
/** Collect pass over the WHOLE program: signatures, class shapes, and
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
* file-scope globals visible everywhere → hoisting, mutual recursion, and
|
|
233
|
+
* cross-module references fall out for free. Runs in both passes —
|
|
234
|
+
* signatures are cheap and calls resolve against them; only BODY lowering
|
|
235
|
+
* is reachability-gated. */
|
|
231
236
|
export function collectProgram(lowerer, parts) {
|
|
232
237
|
const computed = new Set();
|
|
233
238
|
for (const fp of parts)
|
|
@@ -238,7 +243,9 @@ export function collectProgram(lowerer, parts) {
|
|
|
238
243
|
}
|
|
239
244
|
// Descendants need the computed ancestor's completed layout before
|
|
240
245
|
// their own fields and inherited methods can be collected.
|
|
241
|
-
const computedSymbols = new Set([...computed]
|
|
246
|
+
const computedSymbols = new Set([...computed]
|
|
247
|
+
.map((decl) => declSymbolOf(lowerer, decl))
|
|
248
|
+
.filter((symbol) => symbol !== undefined));
|
|
242
249
|
let expanded = true;
|
|
243
250
|
while (expanded) {
|
|
244
251
|
expanded = false;
|
|
@@ -312,18 +319,39 @@ export function collectProgram(lowerer, parts) {
|
|
|
312
319
|
if (value.type.kind === "dyn" || value.type.kind === "func") {
|
|
313
320
|
const name = `%class.base.${lowerer.classNamer(decl)}`;
|
|
314
321
|
const loc = locOf(expression);
|
|
315
|
-
lowerer.liftedFns.push({
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
lowerer.liftedFns.push({
|
|
323
|
+
name,
|
|
324
|
+
params: [],
|
|
325
|
+
returnType: value.type,
|
|
326
|
+
locals: context.locals,
|
|
327
|
+
body: [{ kind: "return", value, loc }],
|
|
328
|
+
loc,
|
|
329
|
+
});
|
|
330
|
+
lowerer.computedCallableBases.set(decl, {
|
|
331
|
+
kind: "call",
|
|
332
|
+
callee: name,
|
|
333
|
+
args: [],
|
|
334
|
+
type: value.type,
|
|
335
|
+
loc,
|
|
336
|
+
});
|
|
318
337
|
}
|
|
319
338
|
if (value.type.kind === "classval") {
|
|
320
339
|
const classInfo = lowerer.classes.get(value.type.className);
|
|
321
340
|
if (classInfo) {
|
|
322
341
|
const name = `%class.base.${lowerer.classNamer(decl)}`;
|
|
323
342
|
const loc = locOf(expression);
|
|
324
|
-
lowerer.liftedFns.push({
|
|
325
|
-
|
|
326
|
-
|
|
343
|
+
lowerer.liftedFns.push({
|
|
344
|
+
name,
|
|
345
|
+
params: [],
|
|
346
|
+
returnType: value.type,
|
|
347
|
+
locals: context.locals,
|
|
348
|
+
body: [{ kind: "return", value, loc }],
|
|
349
|
+
loc,
|
|
350
|
+
});
|
|
351
|
+
lowerer.computedClassBases.set(lowerer.classNamer(decl), {
|
|
352
|
+
value: { kind: "call", callee: name, args: [], type: value.type, loc },
|
|
353
|
+
classInfo,
|
|
354
|
+
});
|
|
327
355
|
}
|
|
328
356
|
}
|
|
329
357
|
}
|
|
@@ -343,25 +371,28 @@ export function collectProgram(lowerer, parts) {
|
|
|
343
371
|
lowerer.diagSink = previousSink;
|
|
344
372
|
}
|
|
345
373
|
if (symbol && deferred.length) {
|
|
346
|
-
lowerer.deferredDiags.set(symbol, [
|
|
374
|
+
lowerer.deferredDiags.set(symbol, [
|
|
375
|
+
...(lowerer.deferredDiags.get(symbol) ?? []),
|
|
376
|
+
...deferred,
|
|
377
|
+
]);
|
|
347
378
|
lowerer.deferredClassByName.set(lowerer.classNamer(decl), symbol);
|
|
348
379
|
}
|
|
349
380
|
lowerer.collecting = wasCollecting;
|
|
350
381
|
}
|
|
351
382
|
}
|
|
352
383
|
/** The npm-import chokepoint, run once per pass during collection (so
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
384
|
+
* bodies lowered in ANY pass resolve the bindings). In a static build
|
|
385
|
+
* every value-importing npm import reports the requires-dynamic
|
|
386
|
+
* diagnostic naming the package — the package's shipped JS has exactly
|
|
387
|
+
* one execution home, the embedded engine. Under --dynamic each value
|
|
388
|
+
* binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
|
|
389
|
+
* importing the same export share one global) and initialized at the
|
|
390
|
+
* top of the importing module's %init by island.import — the engine's
|
|
391
|
+
* module registry caches, so re-imports are lookups, not re-evaluations.
|
|
392
|
+
* The runtime graph (the package entry plus everything it reaches)
|
|
393
|
+
* builds here too; its failures are ordinary diagnostics at the import
|
|
394
|
+
* site. Type-only imports are free either way: the .d.ts is a type
|
|
395
|
+
* surface, not code. */
|
|
365
396
|
export function collectNpmImports(lowerer, parts) {
|
|
366
397
|
const services = lowerer.frontendServices;
|
|
367
398
|
if (lowerer.dynamic && services === undefined)
|
|
@@ -386,9 +417,12 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
386
417
|
!stmt.moduleSpecifier.text.startsWith("#")
|
|
387
418
|
? stmt.exportClause
|
|
388
419
|
: null;
|
|
389
|
-
if (reexport === null &&
|
|
420
|
+
if (reexport === null &&
|
|
421
|
+
(!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
|
|
390
422
|
continue;
|
|
391
|
-
const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
|
|
423
|
+
const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
|
|
424
|
+
? stmt.moduleSpecifier
|
|
425
|
+
: undefined;
|
|
392
426
|
if (specNode === undefined || !ts.isStringLiteral(specNode))
|
|
393
427
|
continue;
|
|
394
428
|
const clause = ts.isImportDeclaration(stmt) ? stmt.importClause : undefined;
|
|
@@ -559,18 +593,18 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
559
593
|
}
|
|
560
594
|
}
|
|
561
595
|
/** Literal dynamic-import collection: every
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
596
|
+
* `import("literal")` in the file — whatever body it sits in — resolves
|
|
597
|
+
* and embeds AT COLLECTION time, so the per-site lowering later just
|
|
598
|
+
* looks its key up (the emitted tables are assembled once, here; a
|
|
599
|
+
* site lowered in any pass finds its module embedded). Resolution
|
|
600
|
+
* In static builds this records compiled program modules and supported
|
|
601
|
+
* builtins without constructing an npm graph. Dynamic package-resolution
|
|
602
|
+
* failures and unshimmed builtins are diagnostics HERE, at the import
|
|
603
|
+
* expression, exactly like static npm imports at their statements; the
|
|
604
|
+
* lowering poisons those sites without re-reporting. Non-literal
|
|
605
|
+
* specifiers are skipped — the lowering owns that fence (the module
|
|
606
|
+
* graph is a build-time artifact; there is nothing to embed for a
|
|
607
|
+
* runtime-computed name). */
|
|
574
608
|
function collectDynamicImports(lowerer, builder, sf) {
|
|
575
609
|
ts.walkPreorder(sf, (node) => {
|
|
576
610
|
if (ts.isCallExpression(node) &&
|
|
@@ -590,7 +624,10 @@ function collectDynamicImports(lowerer, builder, sf) {
|
|
|
590
624
|
// says so. Only non-declaration source files count; a sibling
|
|
591
625
|
// .d.mts typing shipped JS is the EMBED case, not this one.
|
|
592
626
|
const modSym = lowerer.checker.getSymbolAtLocation(node.arguments[0]);
|
|
593
|
-
const ownModule = modSym !== undefined &&
|
|
627
|
+
const ownModule = modSym !== undefined &&
|
|
628
|
+
lowerer.checker
|
|
629
|
+
.declarationsOf(modSym)
|
|
630
|
+
.some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
|
|
594
631
|
const builtin = canonicalBuiltinModule(spec);
|
|
595
632
|
const res = ownModule
|
|
596
633
|
? { kind: "program-module" }
|
|
@@ -613,14 +650,14 @@ function collectDynamicImports(lowerer, builder, sf) {
|
|
|
613
650
|
});
|
|
614
651
|
}
|
|
615
652
|
/** The createRequire half of the npm chokepoint (--dynamic only): every
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
653
|
+
* `require("bare-literal")` through a createRequire binding — whatever
|
|
654
|
+
* body it sits in — resolves under Node's "require" condition and
|
|
655
|
+
* embeds AT COLLECTION time, so the per-site lowering later just looks
|
|
656
|
+
* its entry up (lowerCreateRequireCall). Builtins, relative documents,
|
|
657
|
+
* "#" specifiers, --npm-static opt-ins, and Node-refused bare names
|
|
658
|
+
* are the lowering's own arms — only resolvable installed packages
|
|
659
|
+
* register here; resolution failures are diagnostics at the call
|
|
660
|
+
* expression, exactly like static npm imports at their statements. */
|
|
624
661
|
function collectCreateRequires(lowerer, builder, sf) {
|
|
625
662
|
const visit = (node) => {
|
|
626
663
|
if (ts.isCallExpression(node)) {
|
|
@@ -654,17 +691,17 @@ function collectCreateRequires(lowerer, builder, sf) {
|
|
|
654
691
|
visit(sf);
|
|
655
692
|
}
|
|
656
693
|
/** JSON module default imports (`import pkg from "../package.json"`):
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
694
|
+
* the document is DATA known at build time, so the binding bakes into a
|
|
695
|
+
* record global — the checker's structural type for the module (thanks
|
|
696
|
+
* to resolveJsonModule) maps to a record shape, the JSON text parses in
|
|
697
|
+
* the compiler, and comptimeValueToIr turns the value into literal IR
|
|
698
|
+
* assigned in the importing module's %init prelude (evaluation order:
|
|
699
|
+
* imports before the importer's body, like npm bindings). Two importers
|
|
700
|
+
* of the same document share one global (keyed by the ALIASED symbol).
|
|
701
|
+
* Shapes outside the bakeable surface (null-valued fields, mixed
|
|
702
|
+
* arrays, ...) report the standard unsupported-type diagnostic at the
|
|
703
|
+
* import site. Preflight already fenced named/namespace JSON imports
|
|
704
|
+
* and kept .json files out of the module order. */
|
|
668
705
|
export function collectJsonImports(lowerer, parts) {
|
|
669
706
|
for (const fp of parts) {
|
|
670
707
|
for (const stmt of fp.sf.statements) {
|
|
@@ -723,14 +760,14 @@ export function collectJsonImports(lowerer, parts) {
|
|
|
723
760
|
}
|
|
724
761
|
}
|
|
725
762
|
/** The classes, records, and unions the emitted module carries: exactly
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
763
|
+
* what the lowered functions and globals reference, closed transitively
|
|
764
|
+
* over record fields, union arms, class field types, base chains, and
|
|
765
|
+
* constructible descendants and their base chains. Registry entries interned while collecting
|
|
766
|
+
* signatures nothing reaches stay out — an unreached type leaves no
|
|
767
|
+
* trace. A referenced class with no registration had its collection
|
|
768
|
+
* deferred: the reference flushes those diagnostics. Methods whose
|
|
769
|
+
* bodies were not lowered leave the def's method list, so vtable slots
|
|
770
|
+
* exist exactly for emitted overrides. */
|
|
734
771
|
export function moduleArtifacts(lowerer, functions) {
|
|
735
772
|
const valueInstanceOfRoots = new Set();
|
|
736
773
|
const classNames = new Set();
|
|
@@ -741,23 +778,30 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
741
778
|
const pendingUnions = [];
|
|
742
779
|
const boxedChild = (type, seen = new Set()) => {
|
|
743
780
|
switch (type.kind) {
|
|
744
|
-
case "child":
|
|
781
|
+
case "child":
|
|
782
|
+
return true;
|
|
745
783
|
case "array":
|
|
746
|
-
case "set":
|
|
747
|
-
|
|
748
|
-
case "
|
|
749
|
-
|
|
784
|
+
case "set":
|
|
785
|
+
return boxedChild(type.elem, seen);
|
|
786
|
+
case "promise":
|
|
787
|
+
return boxedChild(type.inner, seen);
|
|
788
|
+
case "map":
|
|
789
|
+
return boxedChild(type.key, seen) || boxedChild(type.value, seen);
|
|
790
|
+
case "func":
|
|
791
|
+
return boxedChild(type.ret, seen);
|
|
750
792
|
case "record":
|
|
751
793
|
if (seen.has(type.shapeId))
|
|
752
794
|
return false;
|
|
753
795
|
seen.add(type.shapeId);
|
|
754
|
-
return lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
|
|
796
|
+
return (lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
|
|
797
|
+
false);
|
|
755
798
|
case "union":
|
|
756
799
|
if (seen.has(type.unionId))
|
|
757
800
|
return false;
|
|
758
801
|
seen.add(type.unionId);
|
|
759
802
|
return lowerer.unions.get(type.unionId)?.arms.some((arm) => boxedChild(arm, seen)) ?? false;
|
|
760
|
-
default:
|
|
803
|
+
default:
|
|
804
|
+
return false;
|
|
761
805
|
}
|
|
762
806
|
};
|
|
763
807
|
const visitClass = (name) => {
|
|
@@ -903,9 +947,7 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
903
947
|
pendingClasses.push(name);
|
|
904
948
|
}
|
|
905
949
|
}
|
|
906
|
-
while (pendingClasses.length > 0 ||
|
|
907
|
-
pendingShapes.length > 0 ||
|
|
908
|
-
pendingUnions.length > 0) {
|
|
950
|
+
while (pendingClasses.length > 0 || pendingShapes.length > 0 || pendingUnions.length > 0) {
|
|
909
951
|
while (pendingShapes.length > 0) {
|
|
910
952
|
// Declared fields AND the index-signature value type: an
|
|
911
953
|
// overflow-valued shape (`{ [key: string]: {script?: string} }`)
|
|
@@ -987,14 +1029,14 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
987
1029
|
};
|
|
988
1030
|
}
|
|
989
1031
|
/** Registers every DIRECT top-level `const`/`let` of a file as a module
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1032
|
+
* global (stable storage: cross-module live bindings, and functions can
|
|
1033
|
+
* reference them without capture). Block-scoped vars inside nested
|
|
1034
|
+
* statements keep their different symbols and stay locals. */
|
|
993
1035
|
/** JS collection failures defer to runtime fences: the registration's
|
|
994
|
-
* diagnostics move off the build (into lowerer.runtimeFences) — the declaring
|
|
995
|
-
* statement re-fails during init lowering and compiles to the
|
|
996
|
-
* runtimeFence trap there, and every use site cascades to its own trap.
|
|
997
|
-
* TypeScript files keep eager collection reports. */
|
|
1036
|
+
* diagnostics move off the build (into lowerer.runtimeFences) — the declaring
|
|
1037
|
+
* statement re-fails during init lowering and compiles to the
|
|
1038
|
+
* runtimeFence trap there, and every use site cascades to its own trap.
|
|
1039
|
+
* TypeScript files keep eager collection reports. */
|
|
998
1040
|
function deferJsCollectionDiags(lowerer, sf, diagsBefore) {
|
|
999
1041
|
if (!isJsSourceFile(sf))
|
|
1000
1042
|
return;
|
|
@@ -1027,12 +1069,14 @@ function cjsScalarLiteral(e) {
|
|
|
1027
1069
|
function checkedGlobalReference(lowerer, expression) {
|
|
1028
1070
|
if (ts.isIdentifier(expression))
|
|
1029
1071
|
return lowerer.globalOf(expression)?.type.kind === "dyn";
|
|
1030
|
-
if (!ts.isPropertyAccessExpression(expression) ||
|
|
1072
|
+
if (!ts.isPropertyAccessExpression(expression) ||
|
|
1073
|
+
!ts.isIdentifier(expression.name) ||
|
|
1074
|
+
!ts.isIdentifier(expression.expression))
|
|
1031
1075
|
return false;
|
|
1032
1076
|
const root = lowerer.checker.getSymbolAtLocation(expression.expression);
|
|
1033
1077
|
const namespace = root && lowerer.checker.declarationsOf(root).some(ts.isNamespaceImport);
|
|
1034
|
-
return (namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
|
|
1035
|
-
lowerer.globalOf(expression.name)?.type.kind === "dyn";
|
|
1078
|
+
return ((namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
|
|
1079
|
+
lowerer.globalOf(expression.name)?.type.kind === "dyn");
|
|
1036
1080
|
}
|
|
1037
1081
|
function jsDynHoldableInitializer(lowerer, init) {
|
|
1038
1082
|
if (init === undefined)
|
|
@@ -1044,15 +1088,18 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1044
1088
|
e = e.expression;
|
|
1045
1089
|
if (checkedGlobalReference(lowerer, e))
|
|
1046
1090
|
return true;
|
|
1047
|
-
if (ts.isCallExpression(e) &&
|
|
1091
|
+
if (ts.isCallExpression(e) &&
|
|
1092
|
+
ts.isPropertyAccessExpression(e.expression) &&
|
|
1048
1093
|
["freeze", "seal", "preventExtensions"].includes(e.expression.name.text) &&
|
|
1049
|
-
lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
|
|
1094
|
+
lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
|
|
1095
|
+
e.arguments[0] &&
|
|
1050
1096
|
ts.isArrayLiteralExpression(e.arguments[0]))
|
|
1051
1097
|
return true;
|
|
1052
1098
|
// The built-in Array constructor can create an evolving array whose
|
|
1053
1099
|
// inferred element type has no native mapping. Its checked reference
|
|
1054
1100
|
// must remain shared with separately declared functions and aliases.
|
|
1055
|
-
if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
|
|
1101
|
+
if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
|
|
1102
|
+
lowerer.isStdlibGlobal(e.expression, "Array"))
|
|
1056
1103
|
return true;
|
|
1057
1104
|
// JavaScript process streams lower to native checked handles even when
|
|
1058
1105
|
// their declared method overloads prevent a structural type mapping.
|
|
@@ -1061,7 +1108,8 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1061
1108
|
const member = lowerer.stdlibGlobalMember(e, "process");
|
|
1062
1109
|
if (member === "stdin" || member === "stdout" || member === "stderr")
|
|
1063
1110
|
return true;
|
|
1064
|
-
if (e.name.text === "constructor" &&
|
|
1111
|
+
if (e.name.text === "constructor" &&
|
|
1112
|
+
lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
|
|
1065
1113
|
return true;
|
|
1066
1114
|
}
|
|
1067
1115
|
if (e.kind === ts.SyntaxKind.NullKeyword)
|
|
@@ -1069,45 +1117,60 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1069
1117
|
if (ts.isIdentifier(e) && e.text === "undefined")
|
|
1070
1118
|
return true;
|
|
1071
1119
|
if (ts.isConditionalExpression(e)) {
|
|
1072
|
-
return jsDynHoldableInitializer(lowerer, e.whenTrue) &&
|
|
1120
|
+
return (jsDynHoldableInitializer(lowerer, e.whenTrue) &&
|
|
1121
|
+
jsDynHoldableInitializer(lowerer, e.whenFalse));
|
|
1073
1122
|
}
|
|
1074
|
-
if (ts.isBinaryExpression(e) &&
|
|
1075
|
-
e.operatorToken.kind === ts.SyntaxKind.
|
|
1123
|
+
if (ts.isBinaryExpression(e) &&
|
|
1124
|
+
(e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
|
|
1125
|
+
e.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
1126
|
+
e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
|
|
1076
1127
|
return jsDynHoldableInitializer(lowerer, e.left) && jsDynHoldableInitializer(lowerer, e.right);
|
|
1077
1128
|
}
|
|
1078
1129
|
// A member of a checked module value is itself checked, including a
|
|
1079
1130
|
// callable whose inferred overloads cannot describe one native ABI.
|
|
1080
1131
|
if ((ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e)) &&
|
|
1081
|
-
ts.isIdentifier(e.expression) &&
|
|
1132
|
+
ts.isIdentifier(e.expression) &&
|
|
1133
|
+
lowerer.globalOf(e.expression)?.type.kind === "dyn")
|
|
1082
1134
|
return true;
|
|
1083
1135
|
if (ts.isPropertyAccessExpression(e)) {
|
|
1084
1136
|
const member = nsMemberIdentOf(lowerer, e);
|
|
1085
|
-
if (member &&
|
|
1137
|
+
if (member &&
|
|
1138
|
+
(lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
|
|
1086
1139
|
return true;
|
|
1087
1140
|
}
|
|
1088
1141
|
// Optional callable reads (for example descriptor?.get) can be held in
|
|
1089
1142
|
// the same checked slot as a callable. Their nullish arm must remain
|
|
1090
1143
|
// observable by functions declared outside the module initializer.
|
|
1091
|
-
if (ts.isPropertyAccessExpression(e) ||
|
|
1144
|
+
if (ts.isPropertyAccessExpression(e) ||
|
|
1145
|
+
ts.isElementAccessExpression(e) ||
|
|
1146
|
+
ts.isCallExpression(e)) {
|
|
1092
1147
|
const fallback = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
|
|
1093
|
-
if (fallback?.kind === "func" &&
|
|
1148
|
+
if (fallback?.kind === "func" &&
|
|
1149
|
+
canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1094
1150
|
return true;
|
|
1095
1151
|
const arms = fallback?.kind === "union" ? lowerer.unions.get(fallback.unionId)?.arms : undefined;
|
|
1096
|
-
if (arms?.some(arm => arm.kind === "func") &&
|
|
1152
|
+
if (arms?.some((arm) => arm.kind === "func") &&
|
|
1153
|
+
arms.every((arm) => isUnitType(arm) ||
|
|
1154
|
+
(arm.kind === "func" &&
|
|
1155
|
+
canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
|
|
1097
1156
|
return true;
|
|
1098
1157
|
}
|
|
1099
|
-
if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
|
|
1158
|
+
if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
|
|
1159
|
+
!e.typeParameters?.length &&
|
|
1160
|
+
isJsSourceFile(e.getSourceFile()))
|
|
1100
1161
|
return true;
|
|
1101
1162
|
if (ts.isIdentifier(e) || ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
|
|
1102
1163
|
if (ts.isIdentifier(e)) {
|
|
1103
1164
|
if (lowerer.globalOf(e)?.type.kind === "dyn")
|
|
1104
1165
|
return true;
|
|
1105
1166
|
const signature = lowerer.isTopLevelFnSymbol(e) ? lowerer.fnSigOf(e) : null;
|
|
1106
|
-
if (signature &&
|
|
1167
|
+
if (signature &&
|
|
1168
|
+
canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1107
1169
|
return true;
|
|
1108
1170
|
}
|
|
1109
1171
|
const type = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
|
|
1110
|
-
if (type?.kind === "func" &&
|
|
1172
|
+
if (type?.kind === "func" &&
|
|
1173
|
+
canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1111
1174
|
return true;
|
|
1112
1175
|
}
|
|
1113
1176
|
if ((ts.isCallExpression(e) || ts.isPropertyAccessExpression(e) || ts.isIdentifier(e)) &&
|
|
@@ -1192,9 +1255,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1192
1255
|
let inner = stmt.expression;
|
|
1193
1256
|
while (ts.isParenthesizedExpression(inner))
|
|
1194
1257
|
inner = inner.expression;
|
|
1195
|
-
if (ts.isClassExpression(inner) &&
|
|
1258
|
+
if (ts.isClassExpression(inner) &&
|
|
1259
|
+
!isJsSourceFile(sf) &&
|
|
1196
1260
|
inner.typeParameters === undefined &&
|
|
1197
|
-
(decoratorNodesOf(inner).length > 0 ||
|
|
1261
|
+
(decoratorNodesOf(inner).length > 0 ||
|
|
1262
|
+
inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
|
|
1198
1263
|
guaranteedDecorationThrow(lowerer, inner) !== null) {
|
|
1199
1264
|
continue;
|
|
1200
1265
|
}
|
|
@@ -1214,7 +1279,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1214
1279
|
lowerer.badType(stmt.expression, tsType);
|
|
1215
1280
|
// Inferred JavaScript factory exports keep their original value,
|
|
1216
1281
|
// including callable objects decorated with Object.assign.
|
|
1217
|
-
if (isJsSourceFile(sf) &&
|
|
1282
|
+
if (isJsSourceFile(sf) &&
|
|
1283
|
+
ts.isCallExpression(stmt.expression) &&
|
|
1284
|
+
type.kind === "record" &&
|
|
1285
|
+
lowerer.dynConvertible(type))
|
|
1218
1286
|
type = DYN;
|
|
1219
1287
|
// `export default undefined` — the unit-only union, like any
|
|
1220
1288
|
// unit-only binding (`export default null` maps via mapType).
|
|
@@ -1253,7 +1321,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1253
1321
|
// tsgo answers no symbol at the attachment site's NAME (no
|
|
1254
1322
|
// expando synthesis); the module symbol's exports table still
|
|
1255
1323
|
// names the member — the same identity use sites resolve.
|
|
1256
|
-
const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
|
|
1324
|
+
const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
|
|
1325
|
+
lowerer.cjsModuleExportSymbol(sf, name);
|
|
1257
1326
|
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
1258
1327
|
return;
|
|
1259
1328
|
// JS exports whose strict type has no mapping take the
|
|
@@ -1281,7 +1350,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1281
1350
|
lowerer.globalsByDeclNode.set(d, vG);
|
|
1282
1351
|
return;
|
|
1283
1352
|
}
|
|
1284
|
-
const g = {
|
|
1353
|
+
const g = {
|
|
1354
|
+
id: `%g.${tag}%export.${name}`,
|
|
1355
|
+
name,
|
|
1356
|
+
type: vG.type,
|
|
1357
|
+
mutable: false,
|
|
1358
|
+
};
|
|
1285
1359
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1286
1360
|
for (const d of lowerer.checker.declarationsOf(symbol))
|
|
1287
1361
|
lowerer.globalsByDeclNode.set(d, g);
|
|
@@ -1358,7 +1432,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1358
1432
|
if (factoryValued && t?.kind === "record" && lowerer.dynConvertible(t))
|
|
1359
1433
|
t = DYN;
|
|
1360
1434
|
if (t && t.kind !== "void") {
|
|
1361
|
-
const g = {
|
|
1435
|
+
const g = {
|
|
1436
|
+
id: `%g.${tag}exports`,
|
|
1437
|
+
name: "exports",
|
|
1438
|
+
type: t,
|
|
1439
|
+
mutable: false,
|
|
1440
|
+
};
|
|
1362
1441
|
lowerer.globalsByDeclNode.set(cjs.expr, g);
|
|
1363
1442
|
lowerer.globalsList.push(g);
|
|
1364
1443
|
}
|
|
@@ -1399,7 +1478,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1399
1478
|
if (ts.isExternalModuleReference(stmt.moduleReference) || stmt.isTypeOnly)
|
|
1400
1479
|
continue;
|
|
1401
1480
|
const aliasSym = lowerer.checker.getSymbolAtLocation(stmt.name);
|
|
1402
|
-
if (!aliasSym ||
|
|
1481
|
+
if (!aliasSym ||
|
|
1482
|
+
!(aliasSym.flags & ts.SymbolFlags.Alias) ||
|
|
1483
|
+
lowerer.globalsBySymbol.has(aliasSym))
|
|
1403
1484
|
continue;
|
|
1404
1485
|
const target = lowerer.checker.getAliasedSymbol(aliasSym);
|
|
1405
1486
|
const vd = lowerer.checker.valueDeclarationOf(target);
|
|
@@ -1450,10 +1531,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1450
1531
|
// require('node:process')` aliases the global process
|
|
1451
1532
|
// (stdlibGlobalAliasDecl's require form) so reads through the
|
|
1452
1533
|
// binding lower via the process surface.
|
|
1453
|
-
if (isRequireStatement(stmt) &&
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1534
|
+
if (isRequireStatement(stmt) &&
|
|
1535
|
+
!(ts.isVariableStatement(stmt) &&
|
|
1536
|
+
stmt.declarationList.declarations.some((decl) => isNativeFfiRequire(lowerer, decl.initializer)))) {
|
|
1537
|
+
if (ts.isVariableStatement(stmt) && (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
|
|
1457
1538
|
for (const decl of stmt.declarationList.declarations) {
|
|
1458
1539
|
stdlibGlobalAliasDecl(lowerer, decl.name, decl.initializer);
|
|
1459
1540
|
}
|
|
@@ -1657,7 +1738,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1657
1738
|
// statement lowering skips the declaration by the same check. A
|
|
1658
1739
|
// bad promisify target reports here (recorded once; the statement
|
|
1659
1740
|
// lowering poisons too, like every collectGlobals failure).
|
|
1660
|
-
if (ts.isIdentifier(decl.name) &&
|
|
1741
|
+
if (ts.isIdentifier(decl.name) &&
|
|
1742
|
+
decl.initializer &&
|
|
1743
|
+
isPromisifyCall(lowerer, decl.initializer)) {
|
|
1661
1744
|
try {
|
|
1662
1745
|
lowerer.registerPromisifiedBuiltinDecl(decl.name, decl.initializer);
|
|
1663
1746
|
}
|
|
@@ -1728,13 +1811,22 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1728
1811
|
// Checked JavaScript factories can expose inferred callables by
|
|
1729
1812
|
// destructuring. Keep each exported binding in module storage so
|
|
1730
1813
|
// separately lowered functions see the initialized value.
|
|
1731
|
-
if (isJsSourceFile(sf) &&
|
|
1732
|
-
!
|
|
1814
|
+
if (isJsSourceFile(sf) &&
|
|
1815
|
+
!ts.isIdentifier(decl.name) &&
|
|
1816
|
+
decl.initializer &&
|
|
1817
|
+
!decl.type &&
|
|
1818
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1819
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
|
|
1733
1820
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1734
1821
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1735
|
-
const g = {
|
|
1736
|
-
|
|
1737
|
-
|
|
1822
|
+
const g = {
|
|
1823
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1824
|
+
name: nameNode.text,
|
|
1825
|
+
type: DYN,
|
|
1826
|
+
mutable: isLet,
|
|
1827
|
+
source: bindingSource(nameNode),
|
|
1828
|
+
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1829
|
+
};
|
|
1738
1830
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1739
1831
|
lowerer.globalsList.push(g);
|
|
1740
1832
|
if (isVarDeclared(decl))
|
|
@@ -1746,16 +1838,25 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1746
1838
|
// callable ABI. Preserve checked-native values in shared storage;
|
|
1747
1839
|
// adapting the loader to (string) would replace its validation.
|
|
1748
1840
|
const initializer = decl.initializer ? stripTypeCasts(decl.initializer) : undefined;
|
|
1749
|
-
if (isJsSourceFile(sf) &&
|
|
1841
|
+
if (isJsSourceFile(sf) &&
|
|
1842
|
+
nameNode === decl.name &&
|
|
1843
|
+
initializer &&
|
|
1750
1844
|
(isNativeBuiltinValueInitializer(lowerer, initializer) ||
|
|
1751
|
-
(!decl.type &&
|
|
1752
|
-
|
|
1845
|
+
(!decl.type &&
|
|
1846
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1847
|
+
lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
|
|
1848
|
+
(!decl.type &&
|
|
1849
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1850
|
+
checkedGlobalReference(lowerer, initializer)) ||
|
|
1753
1851
|
(!lowerer.dynamic && stdlibGlobalNameOf(lowerer, initializer) === "globalThis"))) {
|
|
1754
1852
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1755
1853
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1756
1854
|
const g = {
|
|
1757
|
-
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1758
|
-
|
|
1855
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1856
|
+
name: nameNode.text,
|
|
1857
|
+
type: DYN,
|
|
1858
|
+
mutable: isLet,
|
|
1859
|
+
source: bindingSource(nameNode),
|
|
1759
1860
|
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1760
1861
|
};
|
|
1761
1862
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
@@ -1774,12 +1875,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1774
1875
|
// storage instead of fencing per reference. Identifier
|
|
1775
1876
|
// declarations only: a destructured array literal binds its
|
|
1776
1877
|
// pieces, not the array.
|
|
1777
|
-
if (isJsSourceFile(sf) &&
|
|
1778
|
-
|
|
1779
|
-
|
|
1878
|
+
if (isJsSourceFile(sf) &&
|
|
1879
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
1880
|
+
ts.isIdentifier(decl.name) &&
|
|
1881
|
+
nameNode === decl.name &&
|
|
1882
|
+
decl.initializer !== undefined &&
|
|
1883
|
+
ts.isArrayLiteralExpression(decl.initializer)) {
|
|
1780
1884
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1781
1885
|
if (symbol) {
|
|
1782
|
-
const g = {
|
|
1886
|
+
const g = {
|
|
1887
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
1888
|
+
name: nameNode.text,
|
|
1889
|
+
type: DYN,
|
|
1890
|
+
mutable: isLet,
|
|
1891
|
+
source: bindingSource(nameNode),
|
|
1892
|
+
};
|
|
1783
1893
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1784
1894
|
lowerer.globalsList.push(g);
|
|
1785
1895
|
}
|
|
@@ -1789,14 +1899,26 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1789
1899
|
// Methods and computed properties require live checked storage:
|
|
1790
1900
|
// symbol identity and a method's receiver cannot be reconstructed
|
|
1791
1901
|
// from a copied, inferred record shape.
|
|
1792
|
-
if (isJsSourceFile(sf) &&
|
|
1793
|
-
|
|
1902
|
+
if (isJsSourceFile(sf) &&
|
|
1903
|
+
ts.isIdentifier(decl.name) &&
|
|
1904
|
+
nameNode === decl.name &&
|
|
1905
|
+
decl.initializer &&
|
|
1906
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1794
1907
|
decl.initializer.properties.some((p) => !ts.isSpreadAssignment(p) &&
|
|
1795
|
-
(ts.isMethodDeclaration(p) ||
|
|
1796
|
-
ts.
|
|
1908
|
+
(ts.isMethodDeclaration(p) ||
|
|
1909
|
+
ts.isAccessor(p) ||
|
|
1910
|
+
ts.isComputedPropertyName(p.name) ||
|
|
1911
|
+
(ts.isShorthandPropertyAssignment(p) &&
|
|
1912
|
+
lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0)))) {
|
|
1797
1913
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1798
1914
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1799
|
-
const g = {
|
|
1915
|
+
const g = {
|
|
1916
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1917
|
+
name: nameNode.text,
|
|
1918
|
+
type: DYN,
|
|
1919
|
+
mutable: isLet,
|
|
1920
|
+
source: bindingSource(nameNode),
|
|
1921
|
+
};
|
|
1800
1922
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1801
1923
|
lowerer.globalsList.push(g);
|
|
1802
1924
|
if (isVarDeclared(decl))
|
|
@@ -1821,21 +1943,31 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1821
1943
|
// Spreads from an existing checked dictionary stay checked too;
|
|
1822
1944
|
// copying its entries must not extract nested callable records.
|
|
1823
1945
|
if (isJsSourceFile(sf) &&
|
|
1824
|
-
ts.isIdentifier(decl.name) &&
|
|
1825
|
-
|
|
1946
|
+
ts.isIdentifier(decl.name) &&
|
|
1947
|
+
nameNode === decl.name &&
|
|
1948
|
+
decl.initializer !== undefined &&
|
|
1949
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1826
1950
|
decl.initializer.properties.every((p) => {
|
|
1827
1951
|
if (ts.isSpreadAssignment(p)) {
|
|
1828
|
-
return ts.isIdentifier(p.expression) &&
|
|
1952
|
+
return (ts.isIdentifier(p.expression) &&
|
|
1953
|
+
lowerer.globalOf(p.expression)?.type.kind === "dyn");
|
|
1829
1954
|
}
|
|
1830
1955
|
if (!ts.isPropertyAssignment(p) || ts.isComputedPropertyName(p.name))
|
|
1831
1956
|
return false;
|
|
1832
1957
|
const mt = lowerer.mapTypeOf(lowerer.typeOf(p.initializer));
|
|
1833
|
-
return mt === null ||
|
|
1834
|
-
|
|
1958
|
+
return (mt === null ||
|
|
1959
|
+
mt.kind === "dyn" ||
|
|
1960
|
+
canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)));
|
|
1835
1961
|
})) {
|
|
1836
1962
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1837
1963
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1838
|
-
const g = {
|
|
1964
|
+
const g = {
|
|
1965
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
1966
|
+
name: nameNode.text,
|
|
1967
|
+
type: DYN,
|
|
1968
|
+
mutable: isLet,
|
|
1969
|
+
source: bindingSource(nameNode),
|
|
1970
|
+
};
|
|
1839
1971
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1840
1972
|
lowerer.globalsList.push(g);
|
|
1841
1973
|
}
|
|
@@ -1854,13 +1986,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1854
1986
|
// decl keeps as an %init local) stay OUT: forcing those into
|
|
1855
1987
|
// the checked-dynamic tree would trade their working typed representation for
|
|
1856
1988
|
// fences.
|
|
1857
|
-
if (isJsSourceFile(sf) &&
|
|
1858
|
-
|
|
1989
|
+
if (isJsSourceFile(sf) &&
|
|
1990
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
1991
|
+
ts.isIdentifier(decl.name) &&
|
|
1992
|
+
nameNode === decl.name &&
|
|
1859
1993
|
jsDynHoldableInitializer(lowerer, decl.initializer) &&
|
|
1860
1994
|
dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode))?.kind === "dyn") {
|
|
1861
1995
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1862
1996
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1863
|
-
const g = {
|
|
1997
|
+
const g = {
|
|
1998
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1999
|
+
name: nameNode.text,
|
|
2000
|
+
type: DYN,
|
|
2001
|
+
mutable: isLet,
|
|
2002
|
+
source: bindingSource(nameNode),
|
|
2003
|
+
};
|
|
1864
2004
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1865
2005
|
lowerer.globalsList.push(g);
|
|
1866
2006
|
// Mutable dyn globals hold the dyn undefined from module
|
|
@@ -1879,13 +2019,23 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1879
2019
|
// the binding holds the HANDLE — a jsval global, so exports
|
|
1880
2020
|
// and separately-declared functions reach the same engine
|
|
1881
2021
|
// object.
|
|
1882
|
-
if (lowerer.dynamic &&
|
|
1883
|
-
|
|
1884
|
-
|
|
2022
|
+
if (lowerer.dynamic &&
|
|
2023
|
+
isJsSourceFile(sf) &&
|
|
2024
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2025
|
+
ts.isIdentifier(decl.name) &&
|
|
2026
|
+
nameNode === decl.name &&
|
|
2027
|
+
decl.initializer !== undefined &&
|
|
2028
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1885
2029
|
decl.initializer.properties.some((p) => ts.isGetAccessorDeclaration(p))) {
|
|
1886
2030
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1887
2031
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1888
|
-
const g = {
|
|
2032
|
+
const g = {
|
|
2033
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2034
|
+
name: nameNode.text,
|
|
2035
|
+
type: JSVAL,
|
|
2036
|
+
mutable: isLet,
|
|
2037
|
+
source: bindingSource(nameNode),
|
|
2038
|
+
};
|
|
1889
2039
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1890
2040
|
lowerer.globalsList.push(g);
|
|
1891
2041
|
}
|
|
@@ -1896,23 +2046,37 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1896
2046
|
// that closure in a checked-value global so class methods and
|
|
1897
2047
|
// other module functions see its declaration-position assignment.
|
|
1898
2048
|
// A var starts undefined; lexical bindings retain the TDZ guard.
|
|
1899
|
-
if (isJsSourceFile(sf) &&
|
|
1900
|
-
|
|
2049
|
+
if (isJsSourceFile(sf) &&
|
|
2050
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2051
|
+
ts.isIdentifier(decl.name) &&
|
|
2052
|
+
nameNode === decl.name &&
|
|
2053
|
+
decl.initializer &&
|
|
1901
2054
|
jsDynHoldableInitializer(lowerer, decl.initializer)) {
|
|
1902
2055
|
const initializer = decl.initializer;
|
|
1903
|
-
const member = ts.isPropertyAccessExpression(initializer)
|
|
2056
|
+
const member = ts.isPropertyAccessExpression(initializer)
|
|
2057
|
+
? nsMemberIdentOf(lowerer, initializer)
|
|
2058
|
+
: null;
|
|
1904
2059
|
const generic = member && lowerer.genericFnOf(member);
|
|
1905
|
-
const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
|
|
2060
|
+
const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
|
|
2061
|
+
!initializer.typeParameters?.length
|
|
1906
2062
|
? lowerer.lambdaSignature(initializer).funcType
|
|
1907
|
-
: member && lowerer.globalOf(member)?.type.kind === "dyn"
|
|
1908
|
-
|
|
2063
|
+
: member && lowerer.globalOf(member)?.type.kind === "dyn"
|
|
2064
|
+
? DYN
|
|
2065
|
+
: member && generic?.implicitParams
|
|
2066
|
+
? lowerer.lowerGenericFnValue(member, generic).type
|
|
1909
2067
|
: dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode));
|
|
1910
2068
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1911
|
-
if (symbol &&
|
|
2069
|
+
if (symbol &&
|
|
2070
|
+
fallback &&
|
|
2071
|
+
(fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") &&
|
|
2072
|
+
lowerer.dynConvertible(fallback)) {
|
|
1912
2073
|
if (!lowerer.globalsBySymbol.has(symbol)) {
|
|
1913
2074
|
const g = {
|
|
1914
|
-
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1915
|
-
|
|
2075
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2076
|
+
name: nameNode.text,
|
|
2077
|
+
type: DYN,
|
|
2078
|
+
mutable: isLet,
|
|
2079
|
+
source: bindingSource(nameNode),
|
|
1916
2080
|
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1917
2081
|
};
|
|
1918
2082
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
@@ -1930,37 +2094,63 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1930
2094
|
// and closures created in the init body capture it normally.
|
|
1931
2095
|
// References from separately-declared functions cascade to
|
|
1932
2096
|
// their own per-site runtime fences.
|
|
1933
|
-
const factoryType = !isLet &&
|
|
1934
|
-
|
|
1935
|
-
|
|
2097
|
+
const factoryType = !isLet &&
|
|
2098
|
+
isJsSourceFile(sf) &&
|
|
2099
|
+
!decl.type &&
|
|
2100
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2101
|
+
ts.isIdentifier(decl.name) &&
|
|
2102
|
+
nameNode === decl.name &&
|
|
2103
|
+
decl.initializer &&
|
|
2104
|
+
ts.isNewExpression(decl.initializer)
|
|
2105
|
+
? (objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined)
|
|
2106
|
+
: undefined;
|
|
1936
2107
|
// `var p1 = import("./m")` at file scope: the global holds the
|
|
1937
2108
|
// island promise/handle — the import expression's only
|
|
1938
2109
|
// production — whatever the checker's namespace type mapped to
|
|
1939
2110
|
// (lowerVarDecl's rule at module scope; the init body assigns
|
|
1940
2111
|
// it).
|
|
1941
2112
|
const handleT = ts.isIdentifier(decl.name) && nameNode === decl.name
|
|
1942
|
-
? (isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
|
|
1943
|
-
(lowerer.dynamic
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2113
|
+
? ((isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
|
|
2114
|
+
(lowerer.dynamic
|
|
2115
|
+
? importCallHandleType(decl.initializer)
|
|
2116
|
+
: staticImportNamespaceType(lowerer, decl.initializer)) ??
|
|
2117
|
+
(lowerer.dynamic
|
|
2118
|
+
? // An unchecked-overload call result stores the handle,
|
|
2119
|
+
// exactly the local rule (uncheckedOverloadHandleCall).
|
|
2120
|
+
uncheckedOverloadHandleCall(lowerer, decl.initializer)
|
|
2121
|
+
? JSVAL
|
|
2122
|
+
: null
|
|
2123
|
+
: null))
|
|
1948
2124
|
: null;
|
|
1949
2125
|
// JavaScript factory results with unmappable annotations still
|
|
1950
2126
|
// need shared storage. Unannotated callable unions also use a
|
|
1951
2127
|
// checked slot; mappable authored annotations keep their layout.
|
|
1952
2128
|
const unannotatedCall = !decl.type && !hasJsTypeAnnotation(decl);
|
|
1953
|
-
const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
|
|
1954
|
-
|
|
2129
|
+
const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
|
|
2130
|
+
decl.initializer &&
|
|
2131
|
+
ts.isCallExpression(decl.initializer)
|
|
2132
|
+
? lowerer.checker.getResolvedSignature(decl.initializer)
|
|
2133
|
+
: undefined;
|
|
1955
2134
|
const callDeclaration = callSignature && lowerer.checker.signatureDeclaration(callSignature);
|
|
1956
2135
|
const callType = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile())
|
|
1957
|
-
? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2136
|
+
? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
|
|
2137
|
+
: null;
|
|
2138
|
+
const inferredJsCall = callDeclaration &&
|
|
2139
|
+
isJsSourceFile(callDeclaration.getSourceFile()) &&
|
|
2140
|
+
(!callType ||
|
|
2141
|
+
(unannotatedCall &&
|
|
2142
|
+
callType.kind === "union" &&
|
|
2143
|
+
lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func")));
|
|
2144
|
+
if (!factoryType &&
|
|
2145
|
+
!inferredJsCall &&
|
|
2146
|
+
isJsSourceFile(sf) &&
|
|
2147
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
|
|
1961
2148
|
continue;
|
|
1962
2149
|
let type = handleT ?? factoryType ?? (inferredJsCall ? DYN : lowerer.irTypeOf(nameNode));
|
|
1963
|
-
if (isJsSourceFile(sf) &&
|
|
2150
|
+
if (isJsSourceFile(sf) &&
|
|
2151
|
+
!decl.type &&
|
|
2152
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2153
|
+
decl.initializer &&
|
|
1964
2154
|
(ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer)) &&
|
|
1965
2155
|
!decl.initializer.typeParameters?.length) {
|
|
1966
2156
|
type = lowerer.lambdaSignature(decl.initializer).funcType;
|
|
@@ -1968,8 +2158,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1968
2158
|
// Namespace aliases of inferred helpers carry the helper's
|
|
1969
2159
|
// settled callable, whose return can differ from checker inference.
|
|
1970
2160
|
// Keep a shared checked slot before any consumer specializes it.
|
|
1971
|
-
if (isJsSourceFile(sf) &&
|
|
1972
|
-
decl.
|
|
2161
|
+
if (isJsSourceFile(sf) &&
|
|
2162
|
+
!decl.type &&
|
|
2163
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2164
|
+
type.kind === "func" &&
|
|
2165
|
+
decl.initializer &&
|
|
2166
|
+
ts.isPropertyAccessExpression(decl.initializer)) {
|
|
1973
2167
|
const member = nsMemberIdentOf(lowerer, decl.initializer);
|
|
1974
2168
|
if (member && lowerer.genericFnOf(member)?.implicitParams)
|
|
1975
2169
|
type = DYN;
|
|
@@ -1979,24 +2173,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1979
2173
|
type = source.type;
|
|
1980
2174
|
}
|
|
1981
2175
|
}
|
|
1982
|
-
if (isJsSourceFile(sf) &&
|
|
1983
|
-
decl.
|
|
2176
|
+
if (isJsSourceFile(sf) &&
|
|
2177
|
+
!decl.type &&
|
|
2178
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2179
|
+
decl.initializer &&
|
|
2180
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2181
|
+
type.kind === "union") {
|
|
1984
2182
|
const arms = lowerer.unions.get(type.unionId)?.arms;
|
|
1985
|
-
if (arms?.some((arm) => arm.kind === "record") &&
|
|
2183
|
+
if (arms?.some((arm) => arm.kind === "record") &&
|
|
2184
|
+
arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
|
|
1986
2185
|
type = DYN;
|
|
1987
2186
|
}
|
|
1988
|
-
if (isJsSourceFile(sf) &&
|
|
1989
|
-
|
|
1990
|
-
!(
|
|
2187
|
+
if (isJsSourceFile(sf) &&
|
|
2188
|
+
!decl.type &&
|
|
2189
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2190
|
+
decl.initializer &&
|
|
2191
|
+
ts.isNewExpression(decl.initializer) &&
|
|
2192
|
+
lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
|
|
2193
|
+
!(ts.isIdentifier(decl.initializer.expression) &&
|
|
2194
|
+
lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
|
|
1991
2195
|
type = DYN;
|
|
1992
2196
|
// Calls through checked function values retain their object
|
|
1993
2197
|
// identity, including symbol keys absent from inferred records.
|
|
1994
|
-
if (isJsSourceFile(sf) &&
|
|
1995
|
-
decl.
|
|
2198
|
+
if (isJsSourceFile(sf) &&
|
|
2199
|
+
!decl.type &&
|
|
2200
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2201
|
+
type.kind === "record" &&
|
|
2202
|
+
decl.initializer &&
|
|
2203
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2204
|
+
lowerer.dynConvertible(type)) {
|
|
1996
2205
|
type = DYN;
|
|
1997
2206
|
}
|
|
1998
|
-
if (isJsSourceFile(sf) &&
|
|
1999
|
-
decl.
|
|
2207
|
+
if (isJsSourceFile(sf) &&
|
|
2208
|
+
!decl.type &&
|
|
2209
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2210
|
+
type.kind === "record" &&
|
|
2211
|
+
decl.initializer &&
|
|
2212
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2000
2213
|
ts.isPropertyAccessExpression(decl.initializer.expression) &&
|
|
2001
2214
|
lowerer.stdlibGlobalMember(decl.initializer.expression, "Object") === "assign" &&
|
|
2002
2215
|
decl.initializer.arguments.some((arg) => ts.isIdentifier(arg) && lowerer.globalOf(arg)?.type.kind === "dyn")) {
|
|
@@ -2005,24 +2218,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2005
2218
|
// Runtime-arity JavaScript callables can be returned by a
|
|
2006
2219
|
// checked factory. Keep that callable boxed instead of asking
|
|
2007
2220
|
// a fixed-signature adapter to reconstruct its hidden rest ABI.
|
|
2008
|
-
if (!decl.type &&
|
|
2221
|
+
if (!decl.type &&
|
|
2222
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2223
|
+
type.kind === "func" &&
|
|
2224
|
+
type.rest === true &&
|
|
2225
|
+
type.restAbi === undefined)
|
|
2009
2226
|
type = DYN;
|
|
2010
|
-
if (isJsSourceFile(sf) &&
|
|
2227
|
+
if (isJsSourceFile(sf) &&
|
|
2228
|
+
isLet &&
|
|
2229
|
+
!decl.type &&
|
|
2230
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2011
2231
|
(type.kind === "object" || jsBindingHasOpenWrites(lowerer, decl)))
|
|
2012
2232
|
type = DYN;
|
|
2013
2233
|
// JavaScript call results may retain a checked array supplied by
|
|
2014
2234
|
// the caller. A typed global here would copy it on extraction.
|
|
2015
|
-
if (isJsSourceFile(sf) &&
|
|
2016
|
-
decl.
|
|
2235
|
+
if (isJsSourceFile(sf) &&
|
|
2236
|
+
!decl.type &&
|
|
2237
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2238
|
+
type.kind === "array" &&
|
|
2239
|
+
decl.initializer &&
|
|
2240
|
+
ts.isCallExpression(decl.initializer))
|
|
2017
2241
|
type = DYN;
|
|
2018
|
-
if (!lowerer.dynamic &&
|
|
2019
|
-
|
|
2242
|
+
if (!lowerer.dynamic &&
|
|
2243
|
+
isJsSourceFile(sf) &&
|
|
2244
|
+
!decl.type &&
|
|
2245
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2246
|
+
decl.initializer &&
|
|
2247
|
+
ts.isNewExpression(decl.initializer) &&
|
|
2248
|
+
lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
|
|
2020
2249
|
(type.kind !== "array" || type.elem.kind === "dyn"))
|
|
2021
2250
|
type = DYN;
|
|
2022
2251
|
// Unannotated JavaScript aliases retain an existing native
|
|
2023
2252
|
// checked object instead of copying it into an inferred record.
|
|
2024
|
-
if (isJsSourceFile(sf) &&
|
|
2025
|
-
decl.
|
|
2253
|
+
if (isJsSourceFile(sf) &&
|
|
2254
|
+
!decl.type &&
|
|
2255
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2256
|
+
decl.initializer &&
|
|
2257
|
+
ts.isIdentifier(decl.initializer) &&
|
|
2026
2258
|
(type.kind === "record" || type.kind === "func")) {
|
|
2027
2259
|
const source = lowerer.globalOf(decl.initializer);
|
|
2028
2260
|
if (source?.type.kind === "dyn")
|
|
@@ -2030,10 +2262,15 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2030
2262
|
}
|
|
2031
2263
|
// JavaScript bind inference can leave an artificial tuple-rest
|
|
2032
2264
|
// signature. Keep the returned callable's runtime arity intact.
|
|
2033
|
-
if (isJsSourceFile(sf) &&
|
|
2034
|
-
|
|
2035
|
-
decl.initializer
|
|
2036
|
-
|
|
2265
|
+
if (isJsSourceFile(sf) &&
|
|
2266
|
+
type.kind === "func" &&
|
|
2267
|
+
decl.initializer &&
|
|
2268
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2269
|
+
ts.isPropertyAccessExpression(decl.initializer.expression) &&
|
|
2270
|
+
decl.initializer.expression.name.text === "bind" &&
|
|
2271
|
+
lowerer.isStdlibMember(decl.initializer.expression) &&
|
|
2272
|
+
decl.type === undefined &&
|
|
2273
|
+
!hasJsTypeAnnotation(decl)) {
|
|
2037
2274
|
type = DYN;
|
|
2038
2275
|
}
|
|
2039
2276
|
// An evolving-`any` array's DERIVED file-scope binding under
|
|
@@ -2046,9 +2283,13 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2046
2283
|
// element array (lowerVarDecl's adoption, the file-scope
|
|
2047
2284
|
// face). Annotated declarations keep the validated-boundary
|
|
2048
2285
|
// fence.
|
|
2049
|
-
if (lowerer.dynamic &&
|
|
2050
|
-
|
|
2051
|
-
|
|
2286
|
+
if (lowerer.dynamic &&
|
|
2287
|
+
ts.isIdentifier(decl.name) &&
|
|
2288
|
+
nameNode === decl.name &&
|
|
2289
|
+
decl.type === undefined &&
|
|
2290
|
+
decl.initializer !== undefined &&
|
|
2291
|
+
type.kind === "array" &&
|
|
2292
|
+
type.elem.kind !== "jsval" &&
|
|
2052
2293
|
handleArrayPreservingCall(lowerer, decl.initializer)) {
|
|
2053
2294
|
type = arrayOf(JSVAL);
|
|
2054
2295
|
}
|
|
@@ -2057,7 +2298,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2057
2298
|
// representation (the record shape maps empty and the width
|
|
2058
2299
|
// copy would drop the class the generic-method calls
|
|
2059
2300
|
// monomorphize against) — see genericIfaceBindingKeepsClass.
|
|
2060
|
-
if (type.kind === "record" &&
|
|
2301
|
+
if (type.kind === "record" &&
|
|
2302
|
+
ts.isIdentifier(decl.name) &&
|
|
2303
|
+
nameNode === decl.name &&
|
|
2061
2304
|
genericIfaceBindingKeepsClass(lowerer, decl, type)) {
|
|
2062
2305
|
const initT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
|
|
2063
2306
|
if (initT?.kind === "object")
|
|
@@ -2073,8 +2316,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2073
2316
|
if (lowerer.dynamic && !ts.isIdentifier(decl.name) && decl.initializer !== undefined) {
|
|
2074
2317
|
const srcT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
|
|
2075
2318
|
const island = srcT !== null &&
|
|
2076
|
-
(srcT.kind === "jsval" ||
|
|
2077
|
-
srcT.kind === "
|
|
2319
|
+
(srcT.kind === "jsval" ||
|
|
2320
|
+
srcT.kind === "f64" ||
|
|
2321
|
+
srcT.kind === "bool" ||
|
|
2322
|
+
srcT.kind === "string" ||
|
|
2323
|
+
isUnitType(srcT));
|
|
2078
2324
|
if (island && type.kind !== "f64" && type.kind !== "bool" && type.kind !== "string") {
|
|
2079
2325
|
type = JSVAL;
|
|
2080
2326
|
}
|
|
@@ -2096,7 +2342,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2096
2342
|
// adapter would re-copy at the assignment.
|
|
2097
2343
|
if (isJsSourceFile(sf) &&
|
|
2098
2344
|
type.kind === "func" &&
|
|
2099
|
-
(type.ret.kind === "date" ||
|
|
2345
|
+
(type.ret.kind === "date" ||
|
|
2346
|
+
(type.ret.kind === "record" && lowerer.dynConvertible(type.ret))) &&
|
|
2100
2347
|
decl.initializer !== undefined &&
|
|
2101
2348
|
(ts.isFunctionExpression(decl.initializer) || ts.isArrowFunction(decl.initializer)) &&
|
|
2102
2349
|
decl.initializer.type === undefined &&
|
|
@@ -2115,13 +2362,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2115
2362
|
// Module vars hold real undefined until their declaration runs.
|
|
2116
2363
|
// Unannotated JS function values need that state too: callers
|
|
2117
2364
|
// before the initializer must see undefined and a TypeError.
|
|
2118
|
-
if (isJsSourceFile(sf) &&
|
|
2365
|
+
if (isJsSourceFile(sf) &&
|
|
2366
|
+
isVarDeclared(decl) &&
|
|
2367
|
+
type.kind === "func" &&
|
|
2368
|
+
lowerer.dynConvertible(type))
|
|
2119
2369
|
type = DYN;
|
|
2120
2370
|
// Codec records keep that state in the ordinary optional union;
|
|
2121
2371
|
// lexical codec declarations retain their separate TDZ guard.
|
|
2122
|
-
const codec = type.kind === "record" &&
|
|
2372
|
+
const codec = type.kind === "record" &&
|
|
2373
|
+
recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
|
|
2123
2374
|
if (codec && isVarDeclared(decl)) {
|
|
2124
|
-
type = {
|
|
2375
|
+
type = {
|
|
2376
|
+
kind: "union",
|
|
2377
|
+
unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
|
|
2378
|
+
};
|
|
2125
2379
|
}
|
|
2126
2380
|
else if (codec && !decl.initializer) {
|
|
2127
2381
|
lowerer.noLowering("uninitialized lexical codec bindings", decl, "initialize let or const TextEncoder/TextDecoder bindings at their declaration");
|
|
@@ -2141,7 +2395,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2141
2395
|
// A function pointer must not be dereferenced before a lexical
|
|
2142
2396
|
// declaration assigns it. The shared pointer TDZ guard handles
|
|
2143
2397
|
// these bindings like stored codec records.
|
|
2144
|
-
...((
|
|
2398
|
+
...((codec || type.kind === "func") && !isVarDeclared(decl)
|
|
2399
|
+
? { tdz: true }
|
|
2400
|
+
: {}),
|
|
2145
2401
|
};
|
|
2146
2402
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
2147
2403
|
lowerer.globalsList.push(g);
|
|
@@ -2167,19 +2423,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2167
2423
|
}
|
|
2168
2424
|
}
|
|
2169
2425
|
/** True iff this initializer's VALUE is a jsval-element array from a
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2426
|
+
* module global already registered as one (the evolving-`any` binding
|
|
2427
|
+
* under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
|
|
2428
|
+
* array-method call chain over it (filter/slice/splice/concat — each
|
|
2429
|
+
* answers the receiver's own array type). Registration runs in source
|
|
2430
|
+
* order, so the root's global — declared above, TDZ-guaranteed — is
|
|
2431
|
+
* already in the table. */
|
|
2176
2432
|
function handleArrayPreservingCall(lowerer, e) {
|
|
2177
2433
|
const PRESERVING = new Set(["filter", "slice", "splice", "concat"]);
|
|
2178
2434
|
let cur = e;
|
|
2179
2435
|
for (;;) {
|
|
2180
2436
|
while (ts.isParenthesizedExpression(cur))
|
|
2181
2437
|
cur = cur.expression;
|
|
2182
|
-
if (ts.isCallExpression(cur) &&
|
|
2438
|
+
if (ts.isCallExpression(cur) &&
|
|
2439
|
+
ts.isPropertyAccessExpression(cur.expression) &&
|
|
2183
2440
|
PRESERVING.has(cur.expression.name.text)) {
|
|
2184
2441
|
cur = cur.expression.expression;
|
|
2185
2442
|
continue;
|
|
@@ -2193,14 +2450,14 @@ function handleArrayPreservingCall(lowerer, e) {
|
|
|
2193
2450
|
return g?.type.kind === "array" && g.type.elem.kind === "jsval";
|
|
2194
2451
|
}
|
|
2195
2452
|
/** Registers the entry-init note for a `var` module global: JS hoists
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2453
|
+
* module vars to `undefined` at module entry, so an undefined-armed slot
|
|
2454
|
+
* must hold the interned undefined arm BEFORE the body runs (a function
|
|
2455
|
+
* called above the declaration statement may read it — lowerFileInit
|
|
2456
|
+
* emits the assigns right after the run-once guard). Checked-dynamic
|
|
2457
|
+
* slots hold the dyn undefined the same way (a NULL dyn is a trap, not
|
|
2458
|
+
* a value). Other types need nothing: tsc's flow analysis rejects their
|
|
2459
|
+
* direct early reads, and closure reads share let's documented
|
|
2460
|
+
* zero/NULL divergence window. */
|
|
2204
2461
|
function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
2205
2462
|
// 'any' globals need the entry init exactly like undefined-armed
|
|
2206
2463
|
// unions: tsc never guards `any` reads, so `var x: any;` is readable
|
|
@@ -2215,25 +2472,31 @@ function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
|
2215
2472
|
lowerer.varGlobalEntryInits.set(sf, inits);
|
|
2216
2473
|
}
|
|
2217
2474
|
/** The nested half of module-scope `var` hoisting: a `var` inside a
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2475
|
+
* top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
|
|
2476
|
+
* JS — other functions in the file read the same binding — so it must
|
|
2477
|
+
* be a module global like its top-level siblings. Walks a top-level
|
|
2478
|
+
* statement's insides for var-flagged declaration lists (statement and
|
|
2479
|
+
* for/for-in/for-of initializer positions), never descending into
|
|
2480
|
+
* function-likes, classes, or static blocks (each hoists to its own
|
|
2481
|
+
* scope). Registration mirrors the main path's identifier story:
|
|
2482
|
+
* JS-unmappable types register nothing (per-site fences own the
|
|
2483
|
+
* references), everything else gets a mutable global. */
|
|
2227
2484
|
function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
2228
2485
|
const lists = [];
|
|
2229
2486
|
// Iterative walk (walkPreorder): this sweep sees every non-var top-level
|
|
2230
2487
|
// statement whole — the binderBinaryExpressionStress bare ~6500-term
|
|
2231
2488
|
// chain sat within ~50 terms of overflowing the recursive form.
|
|
2232
2489
|
ts.walkPreorder(stmt, (node) => {
|
|
2233
|
-
if (ts.isFunctionDeclaration(node) ||
|
|
2234
|
-
ts.
|
|
2235
|
-
ts.
|
|
2236
|
-
ts.
|
|
2490
|
+
if (ts.isFunctionDeclaration(node) ||
|
|
2491
|
+
ts.isFunctionExpression(node) ||
|
|
2492
|
+
ts.isArrowFunction(node) ||
|
|
2493
|
+
ts.isMethodDeclaration(node) ||
|
|
2494
|
+
ts.isConstructorDeclaration(node) ||
|
|
2495
|
+
ts.isGetAccessorDeclaration(node) ||
|
|
2496
|
+
ts.isSetAccessorDeclaration(node) ||
|
|
2497
|
+
ts.isClassStaticBlockDeclaration(node) ||
|
|
2498
|
+
ts.isClassDeclaration(node) ||
|
|
2499
|
+
ts.isClassExpression(node) ||
|
|
2237
2500
|
ts.isModuleDeclaration(node)) {
|
|
2238
2501
|
return "skip";
|
|
2239
2502
|
}
|
|
@@ -2263,13 +2526,23 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
|
2263
2526
|
if (shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple)
|
|
2264
2527
|
type = DYN;
|
|
2265
2528
|
}
|
|
2266
|
-
if (type.kind === "record" &&
|
|
2267
|
-
|
|
2529
|
+
if (type.kind === "record" &&
|
|
2530
|
+
recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
|
|
2531
|
+
type = {
|
|
2532
|
+
kind: "union",
|
|
2533
|
+
unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
|
|
2534
|
+
};
|
|
2268
2535
|
}
|
|
2269
2536
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
2270
2537
|
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
2271
2538
|
continue;
|
|
2272
|
-
const g = {
|
|
2539
|
+
const g = {
|
|
2540
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
2541
|
+
name: nameNode.text,
|
|
2542
|
+
type,
|
|
2543
|
+
mutable: true,
|
|
2544
|
+
source: bindingSource(nameNode),
|
|
2545
|
+
};
|
|
2273
2546
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
2274
2547
|
lowerer.globalsList.push(g);
|
|
2275
2548
|
noteVarGlobalEntryInit(lowerer, sf, g);
|
|
@@ -2284,21 +2557,21 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
|
2284
2557
|
}
|
|
2285
2558
|
}
|
|
2286
2559
|
/** The checker's symbol for a module's default export — the symbol a
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2560
|
+
* default import of this module aliases to (getAliasedSymbol), so keying
|
|
2561
|
+
* the default's global by it makes every importer resolve to the same
|
|
2562
|
+
* storage through the ordinary globalOf path. Null for modules without
|
|
2563
|
+
* a default export (or non-module files). */
|
|
2291
2564
|
export function defaultExportSymbolOf(lowerer, sf) {
|
|
2292
2565
|
const moduleSym = lowerer.checker.getSymbolAtLocation(sf);
|
|
2293
2566
|
return moduleSym?.getExports().get(ts.InternalSymbolName.Default) ?? null;
|
|
2294
2567
|
}
|
|
2295
2568
|
/** The declaration symbol of a top-level function/class declaration,
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2569
|
+
* covering the one legal NAMELESS form: `export default function () {}` /
|
|
2570
|
+
* `export default class {}`. A named declaration answers through its
|
|
2571
|
+
* name node; the anonymous default IS the module's `default` export
|
|
2572
|
+
* symbol (the binder declares it there), so collection, reachability,
|
|
2573
|
+
* and body lowering all key that one identity — which is also what a
|
|
2574
|
+
* default import's alias chain resolves to. */
|
|
2302
2575
|
export function declSymbolOf(lowerer, decl) {
|
|
2303
2576
|
if (decl.name)
|
|
2304
2577
|
return lowerer.checker.getSymbolAtLocation(decl.name);
|
|
@@ -2310,18 +2583,18 @@ export function declSymbolOf(lowerer, decl) {
|
|
|
2310
2583
|
return sym ?? undefined;
|
|
2311
2584
|
}
|
|
2312
2585
|
/** `export default <expr>` in a module's init body: the first (and only)
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2586
|
+
* assignment of the pre-registered `default` global — evaluated at the
|
|
2587
|
+
* statement's source position, exactly where Node runs it (Node's
|
|
2588
|
+
* expression defaults snapshot exactly once, here). ENTITY-NAME defaults
|
|
2589
|
+
* of immutable targets are alias plumbing with no storage of their own:
|
|
2590
|
+
* the statement lowers to nothing — importers' alias-resolved reads
|
|
2591
|
+
* equal the snapshot. MUTABLE entity-name defaults registered snapshot
|
|
2592
|
+
* storage in collection and assign it here like any expression default
|
|
2593
|
+
* (the identifier read takes the let's value at this statement's
|
|
2594
|
+
* position — Node's snapshot). A NON-alias default whose type had no
|
|
2595
|
+
* registration (collection reported the blocker) re-lowers the
|
|
2596
|
+
* expression so the expression's OWN diagnostic wins when it has one,
|
|
2597
|
+
* then poisons. */
|
|
2325
2598
|
export function lowerDefaultExport(lowerer, stmt) {
|
|
2326
2599
|
const symbol = defaultExportSymbolOf(lowerer, stmt.getSourceFile());
|
|
2327
2600
|
if (symbol && symbol.flags & ts.SymbolFlags.Alias && !lowerer.globalsBySymbol.has(symbol))
|
|
@@ -2335,9 +2608,11 @@ export function lowerDefaultExport(lowerer, stmt) {
|
|
|
2335
2608
|
let inner = stmt.expression;
|
|
2336
2609
|
while (ts.isParenthesizedExpression(inner))
|
|
2337
2610
|
inner = inner.expression;
|
|
2338
|
-
if (ts.isClassExpression(inner) &&
|
|
2611
|
+
if (ts.isClassExpression(inner) &&
|
|
2612
|
+
!isJsSourceFile(stmt.getSourceFile()) &&
|
|
2339
2613
|
inner.typeParameters === undefined &&
|
|
2340
|
-
(decoratorNodesOf(inner).length > 0 ||
|
|
2614
|
+
(decoratorNodesOf(inner).length > 0 ||
|
|
2615
|
+
inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
|
|
2341
2616
|
guaranteedDecorationThrow(lowerer, inner) !== null) {
|
|
2342
2617
|
return { kind: "exprStmt", expr: lowerer.lowerExpr(stmt.expression), loc: locOf(stmt) };
|
|
2343
2618
|
}
|
|
@@ -2349,19 +2624,19 @@ export function lowerDefaultExport(lowerer, stmt) {
|
|
|
2349
2624
|
return { kind: "assign", localId: g.id, value, loc: locOf(stmt) };
|
|
2350
2625
|
}
|
|
2351
2626
|
/** One file's top-level statements as its init function — RUN-ONCE like a
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2627
|
+
* Node module body: non-entry inits open with a guard flag test (already
|
|
2628
|
+
* ran → return) and set the flag before anything else, so every caller —
|
|
2629
|
+
* hoisted import headers, inline require statements, diamonds, cache-hit
|
|
2630
|
+
* re-requires — gets Node's module-cache semantics from the same call.
|
|
2631
|
+
* After the guard comes the file's HOISTED module-edge header: one
|
|
2632
|
+
* guarded %init call per imported user module and the island loads for
|
|
2633
|
+
* npm imports, in import order (Node evaluates every imported module
|
|
2634
|
+
* before the importer's body — depth-first postorder falls out of the
|
|
2635
|
+
* nesting). CommonJS requires are NOT in the header: Node runs them at
|
|
2636
|
+
* their statements, so the statement lowering emits their %init calls
|
|
2637
|
+
* inline in the body. JSON-import bindings (pure data) load next; then
|
|
2638
|
+
* the body. Top-level var statements assign the pre-registered globals
|
|
2639
|
+
* instead of declaring locals. */
|
|
2365
2640
|
export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
2366
2641
|
const isAsync = lowerer.asyncInitFiles.has(sf);
|
|
2367
2642
|
const ctx = newFnCtx(false, null, null, VOID);
|
|
@@ -2519,8 +2794,16 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2519
2794
|
// that evaluates them. MIXIN instantiations join by their CALL
|
|
2520
2795
|
// SITE's position instead (below) — their inner class node may
|
|
2521
2796
|
// even live in another file.
|
|
2522
|
-
c.decl &&
|
|
2523
|
-
|
|
2797
|
+
c.decl &&
|
|
2798
|
+
ts.isClassDeclaration(c.decl) &&
|
|
2799
|
+
!c.mixinInstance &&
|
|
2800
|
+
c.decl.getSourceFile() === sf &&
|
|
2801
|
+
(c.callableBase !== undefined ||
|
|
2802
|
+
c.def.baseValueGlobal !== undefined ||
|
|
2803
|
+
c.runtimeStatics !== undefined ||
|
|
2804
|
+
c.staticFields.length > 0 ||
|
|
2805
|
+
(c.staticBlocks?.length ?? 0) > 0 ||
|
|
2806
|
+
c.classDecorators !== undefined))
|
|
2524
2807
|
.map((c) => ({ pos: c.decl.getStart(), info: c }));
|
|
2525
2808
|
// Statics-bearing MIXIN instantiations whose call evaluates in THIS
|
|
2526
2809
|
// file: their declaration-time code runs when the call does — the
|
|
@@ -2581,12 +2864,14 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2581
2864
|
loc: loc0,
|
|
2582
2865
|
},
|
|
2583
2866
|
...(guardId !== undefined
|
|
2584
|
-
? [
|
|
2867
|
+
? [
|
|
2868
|
+
{
|
|
2585
2869
|
kind: "assign",
|
|
2586
2870
|
localId: guardId,
|
|
2587
2871
|
value: { kind: "boolLit", value: false, type: BOOL, loc: loc0 },
|
|
2588
2872
|
loc: loc0,
|
|
2589
|
-
}
|
|
2873
|
+
},
|
|
2874
|
+
]
|
|
2590
2875
|
: []),
|
|
2591
2876
|
{ kind: "rethrow", localId: catchLocal.id, loc: loc0 },
|
|
2592
2877
|
],
|
|
@@ -2615,11 +2900,11 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2615
2900
|
}
|
|
2616
2901
|
}
|
|
2617
2902
|
/** %main is just the entry's %init call: Node's whole module evaluation
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2903
|
+
* order lives in the init functions themselves — each file's hoisted
|
|
2904
|
+
* import header runs its dependencies first (depth-first postorder by
|
|
2905
|
+
* nesting), CommonJS require statements call dependency inits inline in
|
|
2906
|
+
* their bodies, and the run-once guards turn every revisit (diamonds,
|
|
2907
|
+
* re-imports, re-requires) into a cache hit. */
|
|
2623
2908
|
export function buildMain(lowerer) {
|
|
2624
2909
|
const loc = { file: lowerer.entry.fileName, start: 0, end: 0 };
|
|
2625
2910
|
const body = [...cjsModuleRegistryPrelude(lowerer, loc)];
|
|
@@ -2637,11 +2922,13 @@ export function buildMain(lowerer) {
|
|
|
2637
2922
|
type: rootAsync ? { kind: "promise", inner: VOID } : VOID,
|
|
2638
2923
|
loc,
|
|
2639
2924
|
};
|
|
2640
|
-
return [
|
|
2925
|
+
return [
|
|
2926
|
+
{
|
|
2641
2927
|
kind: "exprStmt",
|
|
2642
2928
|
expr: rootAsync ? { kind: "awaitExpr", value: call, type: VOID, loc } : call,
|
|
2643
2929
|
loc,
|
|
2644
|
-
}
|
|
2930
|
+
},
|
|
2931
|
+
];
|
|
2645
2932
|
};
|
|
2646
2933
|
const locals = [];
|
|
2647
2934
|
if (lowerer.forkTargets.length === 0) {
|
|
@@ -2665,7 +2952,8 @@ export function buildMain(lowerer) {
|
|
|
2665
2952
|
const selector = () => ({ kind: "varRef", localId: targetId, type: F64, loc });
|
|
2666
2953
|
let workerBranch = null;
|
|
2667
2954
|
for (let id = lowerer.forkTargets.length - 1; id >= 0; id--) {
|
|
2668
|
-
workerBranch = [
|
|
2955
|
+
workerBranch = [
|
|
2956
|
+
{
|
|
2669
2957
|
kind: "if",
|
|
2670
2958
|
cond: {
|
|
2671
2959
|
kind: "bin",
|
|
@@ -2678,7 +2966,8 @@ export function buildMain(lowerer) {
|
|
|
2678
2966
|
then: callRoot(lowerer.forkTargets[id]),
|
|
2679
2967
|
else_: workerBranch,
|
|
2680
2968
|
loc,
|
|
2681
|
-
}
|
|
2969
|
+
},
|
|
2970
|
+
];
|
|
2682
2971
|
}
|
|
2683
2972
|
body.push({
|
|
2684
2973
|
kind: "if",
|
|
@@ -2710,7 +2999,9 @@ export function buildMain(lowerer) {
|
|
|
2710
2999
|
value: {
|
|
2711
3000
|
kind: "libCall",
|
|
2712
3001
|
fn: "error.new",
|
|
2713
|
-
args: [
|
|
3002
|
+
args: [
|
|
3003
|
+
{ kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc },
|
|
3004
|
+
],
|
|
2714
3005
|
type: { kind: "object", className: lowerer.startupCrash.className },
|
|
2715
3006
|
loc: crashLoc,
|
|
2716
3007
|
},
|