@scriptc/compiler 0.2.4 → 0.2.6
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 +972 -245
- 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 +3 -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.d.ts +2 -0
- package/dist/backend/link-plan-core.js +10 -2
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +7 -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.js.map +1 -1
- 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.js +38 -5
- package/dist/backend/llvm/byte-numbers.js.map +1 -1
- package/dist/backend/llvm/byte-windows.d.ts +31 -0
- package/dist/backend/llvm/byte-windows.js +334 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -0
- package/dist/backend/llvm/byte-windows.test.d.ts +1 -0
- package/dist/backend/llvm/byte-windows.test.js +244 -0
- package/dist/backend/llvm/byte-windows.test.js.map +1 -0
- package/dist/backend/llvm/bytes-bounds.js +73 -22
- package/dist/backend/llvm/bytes-bounds.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +5 -2
- package/dist/backend/llvm/call-lifetimes.js +72 -19
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +159 -28
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.d.ts +4 -0
- package/dist/backend/llvm/checked-value-lifetimes.js +14 -4
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +14 -1
- package/dist/backend/llvm/classes.js +94 -19
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.d.ts +1 -0
- package/dist/backend/llvm/classes.test.js +99 -0
- package/dist/backend/llvm/classes.test.js.map +1 -0
- package/dist/backend/llvm/common.js +4 -1
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +11 -0
- package/dist/backend/llvm/constant-callbacks.js +213 -0
- package/dist/backend/llvm/constant-callbacks.js.map +1 -0
- package/dist/backend/llvm/constant-callbacks.test.d.ts +1 -0
- package/dist/backend/llvm/constant-callbacks.test.js +124 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -0
- package/dist/backend/llvm/counted-loops.js +10 -3
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- 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.d.ts +1 -1
- package/dist/backend/llvm/dyn.js +75 -56
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +28 -3
- package/dist/backend/llvm/emitter.js +506 -145
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +247 -50
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +25 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +24 -4
- 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 +110 -31
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +2 -0
- package/dist/backend/llvm/expr-containers.js +112 -41
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +1 -3
- 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 +55 -7
- 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 +95 -19
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +44 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +10 -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-remainder.d.ts +7 -0
- package/dist/backend/llvm/integer-remainder.js +26 -0
- package/dist/backend/llvm/integer-remainder.js.map +1 -0
- package/dist/backend/llvm/integer-values.js +15 -4
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/integer-views.js +23 -7
- package/dist/backend/llvm/integer-views.js.map +1 -1
- package/dist/backend/llvm/integer-views.test.js +42 -7
- package/dist/backend/llvm/integer-views.test.js.map +1 -1
- package/dist/backend/llvm/layouts.js +1 -1
- package/dist/backend/llvm/layouts.js.map +1 -1
- package/dist/backend/llvm/lib-abi.js +20 -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 +42 -38
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +33 -18
- 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 +122 -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 +9 -2
- package/dist/backend/llvm/local-array-reads.js +176 -89
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +394 -62
- 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/loop-array-borrows.d.ts +11 -0
- package/dist/backend/llvm/loop-array-borrows.js +70 -0
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.d.ts +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.js +145 -0
- package/dist/backend/llvm/loop-array-borrows.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +11 -2
- package/dist/backend/llvm/map-read-lifetimes.js +64 -19
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +89 -17
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.d.ts +5 -3
- package/dist/backend/llvm/reference-effects.js +74 -36
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-effects.test.js +92 -9
- package/dist/backend/llvm/reference-effects.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -1
- package/dist/backend/llvm/shapes.js +82 -24
- 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-loops.d.ts +48 -0
- package/dist/backend/llvm/split-loops.js +183 -0
- package/dist/backend/llvm/split-loops.js.map +1 -0
- package/dist/backend/llvm/split.js +4 -11
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +80 -8
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-callbacks.d.ts +14 -0
- package/dist/backend/llvm/stack-callbacks.js +73 -0
- package/dist/backend/llvm/stack-callbacks.js.map +1 -0
- package/dist/backend/llvm/stack-captures.d.ts +25 -0
- package/dist/backend/llvm/stack-captures.js +150 -0
- package/dist/backend/llvm/stack-captures.js.map +1 -0
- 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 +151 -32
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +32 -7
- package/dist/backend/llvm/string-construction.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.js +14 -8
- package/dist/backend/llvm/string-lifetimes.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +119 -29
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-slices.d.ts +20 -0
- package/dist/backend/llvm/string-slices.js +87 -0
- package/dist/backend/llvm/string-slices.js.map +1 -0
- package/dist/backend/llvm/string-slices.test.d.ts +1 -0
- package/dist/backend/llvm/string-slices.test.js +98 -0
- package/dist/backend/llvm/string-slices.test.js.map +1 -0
- 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.d.ts +4 -14
- package/dist/backend/llvm/walkers.js +58 -313
- 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 +119 -23
- 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 +316 -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 +1275 -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 +165 -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.d.ts +6 -0
- package/dist/backend/native-codegen-core.js +23 -1
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +5 -1
- package/dist/backend/native-codegen.js +52 -25
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +59 -11
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- 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.d.ts +3 -1
- package/dist/backend/native-tools.js +30 -9
- 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-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +104 -50
- 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 +126 -17
- 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 +51 -25
- 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 +2 -1
- package/dist/executable/executable-cache.js +79 -48
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +90 -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.d.ts +5 -0
- package/dist/frontend/fork-target.js +55 -18
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.d.ts +1 -0
- package/dist/frontend/fork-target.test.js +59 -0
- package/dist/frontend/fork-target.test.js.map +1 -0
- 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 +6 -0
- package/dist/frontend/lowering/builtins/atomics.js +82 -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 +35 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +725 -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 +308 -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/builtins/workers.d.ts +5 -0
- package/dist/frontend/lowering/builtins/workers.js +65 -0
- package/dist/frontend/lowering/builtins/workers.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-assertions.d.ts +7 -0
- package/dist/frontend/lowering/class-assertions.js +96 -0
- package/dist/frontend/lowering/class-assertions.js.map +1 -0
- 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-protocols.d.ts +17 -0
- package/dist/frontend/lowering/class-protocols.js +126 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -0
- 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 +355 -72
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +88 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +1611 -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 +430 -138
- 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 +601 -160
- 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 +588 -165
- 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 +271 -0
- package/dist/frontend/lowering/generic-functions.js +1730 -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/instantiation-path.d.ts +8 -0
- package/dist/frontend/lowering/instantiation-path.js +10 -0
- package/dist/frontend/lowering/instantiation-path.js.map +1 -0
- package/dist/frontend/lowering/instantiation-path.test.d.ts +1 -0
- package/dist/frontend/lowering/instantiation-path.test.js +23 -0
- package/dist/frontend/lowering/instantiation-path.test.js.map +1 -0
- 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 +430 -77
- 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 +2628 -5669
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +248 -242
- package/dist/frontend/lowering/lower-classes.js +1820 -775
- 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 +323 -86
- 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 +3473 -1160
- 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 +366 -274
- 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 +95 -94
- package/dist/frontend/lowering/lower-modules.js +655 -329
- 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 +2324 -994
- 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 +363 -91
- 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 +34 -352
- package/dist/frontend/lowering/lowerer.js +1074 -2712
- 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/split-consumers.d.ts +7 -0
- package/dist/frontend/lowering/split-consumers.js +64 -0
- package/dist/frontend/lowering/split-consumers.js.map +1 -0
- 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 +45 -46
- package/dist/frontend/lowering/surfaces.js +1129 -256
- 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-source-candidates.d.ts +10 -0
- package/dist/frontend/module-source-candidates.js +40 -0
- package/dist/frontend/module-source-candidates.js.map +1 -0
- package/dist/frontend/module-source-candidates.test.d.ts +1 -0
- package/dist/frontend/module-source-candidates.test.js +53 -0
- package/dist/frontend/module-source-candidates.test.js.map +1 -0
- 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-analysis.d.ts +2 -0
- package/dist/frontend/program-analysis.js +2 -0
- package/dist/frontend/program-analysis.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 +248 -127
- 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 +490 -172
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +150 -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 +5 -1
- package/dist/frontend/ts7/ast-wire.js +83 -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.d.ts +2 -1
- package/dist/frontend/ts7/ast.js +53 -30
- 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.d.ts +8 -2
- package/dist/frontend/ts7/checker.js +46 -8
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +96 -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.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +33 -6
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +72 -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.d.ts +3 -0
- package/dist/frontend/type-mapper.js +589 -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/frontend/worker-target.d.ts +6 -0
- package/dist/frontend/worker-target.js +108 -0
- package/dist/frontend/worker-target.js.map +1 -0
- package/dist/frontend/worker-target.test.d.ts +1 -0
- package/dist/frontend/worker-target.test.js +71 -0
- package/dist/frontend/worker-target.test.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +174 -88
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +95 -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 +643 -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 +3397 -0
- package/dist/ir/builtin-signatures.js.map +1 -0
- package/dist/ir/byte-numbers.js +67 -16
- package/dist/ir/byte-numbers.js.map +1 -1
- package/dist/ir/byte-numbers.test.js +17 -4
- package/dist/ir/byte-numbers.test.js.map +1 -1
- 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.js +85 -30
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +76 -13
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.js +93 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +199 -21
- 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 +15 -2160
- package/dist/ir/ir.js +160 -1396
- 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/numeric-call-specialization.d.ts +8 -0
- package/dist/ir/numeric-call-specialization.js +198 -0
- package/dist/ir/numeric-call-specialization.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +221 -0
- package/dist/ir/runtime-features.js +552 -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.d.ts +1 -1
- package/dist/ir/serialize.js +7 -5
- 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 +869 -1910
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +697 -114
- 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 +137 -61
- 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 +234 -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 +29 -18
- 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 +191 -54
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +134 -33
- 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 +121 -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 +78 -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 +68 -26
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +59 -20
- 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 +30 -2
- package/dist/frontend/lowering/lower-builtins.d.ts +0 -601
- package/dist/frontend/lowering/lower-builtins.js +0 -8986
- 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 -7344
- 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,29 +8,34 @@ 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";
|
|
38
|
+
import { workerTargetPaths } from "../worker-target.js";
|
|
33
39
|
import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
|
|
34
40
|
/** Program modules selected by statically resolved child_process.fork()
|
|
35
41
|
* calls join the compiled graph without becoming startup dependencies of
|
|
@@ -37,9 +43,15 @@ import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
|
|
|
37
43
|
* in a re-executed fork child. `targets` is append-only so ids stay stable
|
|
38
44
|
* across the dynamic-import/fork discovery fixpoint. */
|
|
39
45
|
export function appendForkModules(program, order, targets, onCycle) {
|
|
46
|
+
appendEntryModules(program, order, targets, forkTargetPaths(program, order), onCycle);
|
|
47
|
+
}
|
|
48
|
+
export function appendWorkerModules(program, order, targets, onCycle) {
|
|
49
|
+
appendEntryModules(program, order, targets, workerTargetPaths(program, order), onCycle);
|
|
50
|
+
}
|
|
51
|
+
function appendEntryModules(program, order, targets, paths, onCycle) {
|
|
40
52
|
if (order.length === 0)
|
|
41
53
|
return;
|
|
42
|
-
const byPath = new Map(program.
|
|
54
|
+
const byPath = new Map(program.getImplementationSourceFiles().map((sf) => [resolvePath(sf.fileName), sf]));
|
|
43
55
|
const state = new Map();
|
|
44
56
|
for (const sf of order)
|
|
45
57
|
state.set(sf, "done");
|
|
@@ -74,7 +86,7 @@ export function appendForkModules(program, order, targets, onCycle) {
|
|
|
74
86
|
added.push(sf);
|
|
75
87
|
};
|
|
76
88
|
const knownTargets = new Set(targets);
|
|
77
|
-
for (const path of
|
|
89
|
+
for (const path of paths) {
|
|
78
90
|
const target = byPath.get(resolvePath(path));
|
|
79
91
|
if (!target || target.isDeclarationFile || target.fileName.endsWith(".json"))
|
|
80
92
|
continue;
|
|
@@ -88,10 +100,10 @@ export function appendForkModules(program, order, targets, onCycle) {
|
|
|
88
100
|
order.splice(order.length - 1, 0, ...added);
|
|
89
101
|
}
|
|
90
102
|
/** Splits each file into function/class declarations and the top-level
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
* statements that form its init body. Node's evaluation order (depth-first
|
|
104
|
+
* postorder, entry last), computed by preflight. Single-file programs
|
|
105
|
+
* (tests, coverage on broken files) may arrive with an empty order — fall
|
|
106
|
+
* back to the entry alone. */
|
|
95
107
|
export function splitFiles(lowerer) {
|
|
96
108
|
const files = lowerer.moduleOrder.length > 0 ? lowerer.moduleOrder : [lowerer.entry];
|
|
97
109
|
return files.map((sf) => {
|
|
@@ -123,10 +135,10 @@ export function splitFiles(lowerer) {
|
|
|
123
135
|
});
|
|
124
136
|
}
|
|
125
137
|
/** A source file dynamic `import("<project specifier>")` can host as a COMPILED
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
138
|
+
* module namespace (lowerOwnModuleImport): a non-declaration program file
|
|
139
|
+
* that is not JSON and not CommonJS-flavored (a CJS namespace is built
|
|
140
|
+
* from module.exports through Node's lexer — a different surface with no
|
|
141
|
+
* static story here). Null for everything else. */
|
|
130
142
|
function dynamicImportProgramTargetOf(program, sf, spec) {
|
|
131
143
|
const dep = resolveImport(program, sf, spec);
|
|
132
144
|
if (!dep || dep.isDeclarationFile)
|
|
@@ -138,7 +150,7 @@ function dynamicImportProgramTargetOf(program, sf, spec) {
|
|
|
138
150
|
return dep;
|
|
139
151
|
}
|
|
140
152
|
/** Every distinct program module a file's `import("literal")` sites name
|
|
141
|
-
|
|
153
|
+
* (source order, deduped). */
|
|
142
154
|
function dynamicProgramImportsOf(program, sf) {
|
|
143
155
|
const out = [];
|
|
144
156
|
const seen = new Set();
|
|
@@ -157,21 +169,21 @@ function dynamicProgramImportsOf(program, sf) {
|
|
|
157
169
|
return out;
|
|
158
170
|
}
|
|
159
171
|
/** --dynamic builds: program modules reachable ONLY through dynamic
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
* `import()` join the compiled module graph — appended to `order` (before
|
|
173
|
+
* the entry, which stays last) in depth-first postorder over their own
|
|
174
|
+
* static import edges, exactly like preflight ordered the static graph.
|
|
175
|
+
* NOTHING calls their %init at startup (%main runs only the entry's init,
|
|
176
|
+
* and no static import header names these), so a dynamic-only module
|
|
177
|
+
* still evaluates exactly when Node evaluates it: the import() site's
|
|
178
|
+
* namespace builder calls the guarded init on the engine microtask.
|
|
179
|
+
* Fixpoint: an added module's own import() sites are scanned too. Static
|
|
180
|
+
* cycles inside the added subgraph ride preflight's own admission engine
|
|
181
|
+
* (makeCycleAdmission — preflight only walked the entry's static graph,
|
|
182
|
+
* so it never judged these): benign back edges are Node cache hits the
|
|
183
|
+
* run-once init guards reproduce, and inadmissible ones get preflight's
|
|
184
|
+
* SC1016 with the same narrowed reason via `onCycle`. Idempotent —
|
|
185
|
+
* re-running on an already-extended order adds nothing (both lowering
|
|
186
|
+
* passes share one array). */
|
|
175
187
|
export function appendDynamicImportModules(program, order, onCycle) {
|
|
176
188
|
if (order.length === 0)
|
|
177
189
|
return; // no preflight order — sites keep their fences
|
|
@@ -224,10 +236,10 @@ export function appendDynamicImportModules(program, order, onCycle) {
|
|
|
224
236
|
order.splice(order.length - 1, 0, ...added);
|
|
225
237
|
}
|
|
226
238
|
/** Collect pass over the WHOLE program: signatures, class shapes, and
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
239
|
+
* file-scope globals visible everywhere → hoisting, mutual recursion, and
|
|
240
|
+
* cross-module references fall out for free. Runs in both passes —
|
|
241
|
+
* signatures are cheap and calls resolve against them; only BODY lowering
|
|
242
|
+
* is reachability-gated. */
|
|
231
243
|
export function collectProgram(lowerer, parts) {
|
|
232
244
|
const computed = new Set();
|
|
233
245
|
for (const fp of parts)
|
|
@@ -238,7 +250,9 @@ export function collectProgram(lowerer, parts) {
|
|
|
238
250
|
}
|
|
239
251
|
// Descendants need the computed ancestor's completed layout before
|
|
240
252
|
// their own fields and inherited methods can be collected.
|
|
241
|
-
const computedSymbols = new Set([...computed]
|
|
253
|
+
const computedSymbols = new Set([...computed]
|
|
254
|
+
.map((decl) => declSymbolOf(lowerer, decl))
|
|
255
|
+
.filter((symbol) => symbol !== undefined));
|
|
242
256
|
let expanded = true;
|
|
243
257
|
while (expanded) {
|
|
244
258
|
expanded = false;
|
|
@@ -312,18 +326,39 @@ export function collectProgram(lowerer, parts) {
|
|
|
312
326
|
if (value.type.kind === "dyn" || value.type.kind === "func") {
|
|
313
327
|
const name = `%class.base.${lowerer.classNamer(decl)}`;
|
|
314
328
|
const loc = locOf(expression);
|
|
315
|
-
lowerer.liftedFns.push({
|
|
316
|
-
|
|
317
|
-
|
|
329
|
+
lowerer.liftedFns.push({
|
|
330
|
+
name,
|
|
331
|
+
params: [],
|
|
332
|
+
returnType: value.type,
|
|
333
|
+
locals: context.locals,
|
|
334
|
+
body: [{ kind: "return", value, loc }],
|
|
335
|
+
loc,
|
|
336
|
+
});
|
|
337
|
+
lowerer.computedCallableBases.set(decl, {
|
|
338
|
+
kind: "call",
|
|
339
|
+
callee: name,
|
|
340
|
+
args: [],
|
|
341
|
+
type: value.type,
|
|
342
|
+
loc,
|
|
343
|
+
});
|
|
318
344
|
}
|
|
319
345
|
if (value.type.kind === "classval") {
|
|
320
346
|
const classInfo = lowerer.classes.get(value.type.className);
|
|
321
347
|
if (classInfo) {
|
|
322
348
|
const name = `%class.base.${lowerer.classNamer(decl)}`;
|
|
323
349
|
const loc = locOf(expression);
|
|
324
|
-
lowerer.liftedFns.push({
|
|
325
|
-
|
|
326
|
-
|
|
350
|
+
lowerer.liftedFns.push({
|
|
351
|
+
name,
|
|
352
|
+
params: [],
|
|
353
|
+
returnType: value.type,
|
|
354
|
+
locals: context.locals,
|
|
355
|
+
body: [{ kind: "return", value, loc }],
|
|
356
|
+
loc,
|
|
357
|
+
});
|
|
358
|
+
lowerer.computedClassBases.set(lowerer.classNamer(decl), {
|
|
359
|
+
value: { kind: "call", callee: name, args: [], type: value.type, loc },
|
|
360
|
+
classInfo,
|
|
361
|
+
});
|
|
327
362
|
}
|
|
328
363
|
}
|
|
329
364
|
}
|
|
@@ -343,25 +378,28 @@ export function collectProgram(lowerer, parts) {
|
|
|
343
378
|
lowerer.diagSink = previousSink;
|
|
344
379
|
}
|
|
345
380
|
if (symbol && deferred.length) {
|
|
346
|
-
lowerer.deferredDiags.set(symbol, [
|
|
381
|
+
lowerer.deferredDiags.set(symbol, [
|
|
382
|
+
...(lowerer.deferredDiags.get(symbol) ?? []),
|
|
383
|
+
...deferred,
|
|
384
|
+
]);
|
|
347
385
|
lowerer.deferredClassByName.set(lowerer.classNamer(decl), symbol);
|
|
348
386
|
}
|
|
349
387
|
lowerer.collecting = wasCollecting;
|
|
350
388
|
}
|
|
351
389
|
}
|
|
352
390
|
/** The npm-import chokepoint, run once per pass during collection (so
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
391
|
+
* bodies lowered in ANY pass resolve the bindings). In a static build
|
|
392
|
+
* every value-importing npm import reports the requires-dynamic
|
|
393
|
+
* diagnostic naming the package — the package's shipped JS has exactly
|
|
394
|
+
* one execution home, the embedded engine. Under --dynamic each value
|
|
395
|
+
* binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
|
|
396
|
+
* importing the same export share one global) and initialized at the
|
|
397
|
+
* top of the importing module's %init by island.import — the engine's
|
|
398
|
+
* module registry caches, so re-imports are lookups, not re-evaluations.
|
|
399
|
+
* The runtime graph (the package entry plus everything it reaches)
|
|
400
|
+
* builds here too; its failures are ordinary diagnostics at the import
|
|
401
|
+
* site. Type-only imports are free either way: the .d.ts is a type
|
|
402
|
+
* surface, not code. */
|
|
365
403
|
export function collectNpmImports(lowerer, parts) {
|
|
366
404
|
const services = lowerer.frontendServices;
|
|
367
405
|
if (lowerer.dynamic && services === undefined)
|
|
@@ -386,9 +424,12 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
386
424
|
!stmt.moduleSpecifier.text.startsWith("#")
|
|
387
425
|
? stmt.exportClause
|
|
388
426
|
: null;
|
|
389
|
-
if (reexport === null &&
|
|
427
|
+
if (reexport === null &&
|
|
428
|
+
(!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
|
|
390
429
|
continue;
|
|
391
|
-
const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
|
|
430
|
+
const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
|
|
431
|
+
? stmt.moduleSpecifier
|
|
432
|
+
: undefined;
|
|
392
433
|
if (specNode === undefined || !ts.isStringLiteral(specNode))
|
|
393
434
|
continue;
|
|
394
435
|
const clause = ts.isImportDeclaration(stmt) ? stmt.importClause : undefined;
|
|
@@ -559,18 +600,18 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
559
600
|
}
|
|
560
601
|
}
|
|
561
602
|
/** Literal dynamic-import collection: every
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
603
|
+
* `import("literal")` in the file — whatever body it sits in — resolves
|
|
604
|
+
* and embeds AT COLLECTION time, so the per-site lowering later just
|
|
605
|
+
* looks its key up (the emitted tables are assembled once, here; a
|
|
606
|
+
* site lowered in any pass finds its module embedded). Resolution
|
|
607
|
+
* In static builds this records compiled program modules and supported
|
|
608
|
+
* builtins without constructing an npm graph. Dynamic package-resolution
|
|
609
|
+
* failures and unshimmed builtins are diagnostics HERE, at the import
|
|
610
|
+
* expression, exactly like static npm imports at their statements; the
|
|
611
|
+
* lowering poisons those sites without re-reporting. Non-literal
|
|
612
|
+
* specifiers are skipped — the lowering owns that fence (the module
|
|
613
|
+
* graph is a build-time artifact; there is nothing to embed for a
|
|
614
|
+
* runtime-computed name). */
|
|
574
615
|
function collectDynamicImports(lowerer, builder, sf) {
|
|
575
616
|
ts.walkPreorder(sf, (node) => {
|
|
576
617
|
if (ts.isCallExpression(node) &&
|
|
@@ -590,7 +631,10 @@ function collectDynamicImports(lowerer, builder, sf) {
|
|
|
590
631
|
// says so. Only non-declaration source files count; a sibling
|
|
591
632
|
// .d.mts typing shipped JS is the EMBED case, not this one.
|
|
592
633
|
const modSym = lowerer.checker.getSymbolAtLocation(node.arguments[0]);
|
|
593
|
-
const ownModule = modSym !== undefined &&
|
|
634
|
+
const ownModule = modSym !== undefined &&
|
|
635
|
+
lowerer.checker
|
|
636
|
+
.declarationsOf(modSym)
|
|
637
|
+
.some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
|
|
594
638
|
const builtin = canonicalBuiltinModule(spec);
|
|
595
639
|
const res = ownModule
|
|
596
640
|
? { kind: "program-module" }
|
|
@@ -613,14 +657,14 @@ function collectDynamicImports(lowerer, builder, sf) {
|
|
|
613
657
|
});
|
|
614
658
|
}
|
|
615
659
|
/** The createRequire half of the npm chokepoint (--dynamic only): every
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
660
|
+
* `require("bare-literal")` through a createRequire binding — whatever
|
|
661
|
+
* body it sits in — resolves under Node's "require" condition and
|
|
662
|
+
* embeds AT COLLECTION time, so the per-site lowering later just looks
|
|
663
|
+
* its entry up (lowerCreateRequireCall). Builtins, relative documents,
|
|
664
|
+
* "#" specifiers, --npm-static opt-ins, and Node-refused bare names
|
|
665
|
+
* are the lowering's own arms — only resolvable installed packages
|
|
666
|
+
* register here; resolution failures are diagnostics at the call
|
|
667
|
+
* expression, exactly like static npm imports at their statements. */
|
|
624
668
|
function collectCreateRequires(lowerer, builder, sf) {
|
|
625
669
|
const visit = (node) => {
|
|
626
670
|
if (ts.isCallExpression(node)) {
|
|
@@ -654,17 +698,17 @@ function collectCreateRequires(lowerer, builder, sf) {
|
|
|
654
698
|
visit(sf);
|
|
655
699
|
}
|
|
656
700
|
/** JSON module default imports (`import pkg from "../package.json"`):
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
701
|
+
* the document is DATA known at build time, so the binding bakes into a
|
|
702
|
+
* record global — the checker's structural type for the module (thanks
|
|
703
|
+
* to resolveJsonModule) maps to a record shape, the JSON text parses in
|
|
704
|
+
* the compiler, and comptimeValueToIr turns the value into literal IR
|
|
705
|
+
* assigned in the importing module's %init prelude (evaluation order:
|
|
706
|
+
* imports before the importer's body, like npm bindings). Two importers
|
|
707
|
+
* of the same document share one global (keyed by the ALIASED symbol).
|
|
708
|
+
* Shapes outside the bakeable surface (null-valued fields, mixed
|
|
709
|
+
* arrays, ...) report the standard unsupported-type diagnostic at the
|
|
710
|
+
* import site. Preflight already fenced named/namespace JSON imports
|
|
711
|
+
* and kept .json files out of the module order. */
|
|
668
712
|
export function collectJsonImports(lowerer, parts) {
|
|
669
713
|
for (const fp of parts) {
|
|
670
714
|
for (const stmt of fp.sf.statements) {
|
|
@@ -723,14 +767,14 @@ export function collectJsonImports(lowerer, parts) {
|
|
|
723
767
|
}
|
|
724
768
|
}
|
|
725
769
|
/** The classes, records, and unions the emitted module carries: exactly
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
770
|
+
* what the lowered functions and globals reference, closed transitively
|
|
771
|
+
* over record fields, union arms, class field types, base chains, and
|
|
772
|
+
* constructible descendants and their base chains. Registry entries interned while collecting
|
|
773
|
+
* signatures nothing reaches stay out — an unreached type leaves no
|
|
774
|
+
* trace. A referenced class with no registration had its collection
|
|
775
|
+
* deferred: the reference flushes those diagnostics. Methods whose
|
|
776
|
+
* bodies were not lowered leave the def's method list, so vtable slots
|
|
777
|
+
* exist exactly for emitted overrides. */
|
|
734
778
|
export function moduleArtifacts(lowerer, functions) {
|
|
735
779
|
const valueInstanceOfRoots = new Set();
|
|
736
780
|
const classNames = new Set();
|
|
@@ -741,23 +785,30 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
741
785
|
const pendingUnions = [];
|
|
742
786
|
const boxedChild = (type, seen = new Set()) => {
|
|
743
787
|
switch (type.kind) {
|
|
744
|
-
case "child":
|
|
788
|
+
case "child":
|
|
789
|
+
return true;
|
|
745
790
|
case "array":
|
|
746
|
-
case "set":
|
|
747
|
-
|
|
748
|
-
case "
|
|
749
|
-
|
|
791
|
+
case "set":
|
|
792
|
+
return boxedChild(type.elem, seen);
|
|
793
|
+
case "promise":
|
|
794
|
+
return boxedChild(type.inner, seen);
|
|
795
|
+
case "map":
|
|
796
|
+
return boxedChild(type.key, seen) || boxedChild(type.value, seen);
|
|
797
|
+
case "func":
|
|
798
|
+
return boxedChild(type.ret, seen);
|
|
750
799
|
case "record":
|
|
751
800
|
if (seen.has(type.shapeId))
|
|
752
801
|
return false;
|
|
753
802
|
seen.add(type.shapeId);
|
|
754
|
-
return lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
|
|
803
|
+
return (lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
|
|
804
|
+
false);
|
|
755
805
|
case "union":
|
|
756
806
|
if (seen.has(type.unionId))
|
|
757
807
|
return false;
|
|
758
808
|
seen.add(type.unionId);
|
|
759
809
|
return lowerer.unions.get(type.unionId)?.arms.some((arm) => boxedChild(arm, seen)) ?? false;
|
|
760
|
-
default:
|
|
810
|
+
default:
|
|
811
|
+
return false;
|
|
761
812
|
}
|
|
762
813
|
};
|
|
763
814
|
const visitClass = (name) => {
|
|
@@ -903,9 +954,7 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
903
954
|
pendingClasses.push(name);
|
|
904
955
|
}
|
|
905
956
|
}
|
|
906
|
-
while (pendingClasses.length > 0 ||
|
|
907
|
-
pendingShapes.length > 0 ||
|
|
908
|
-
pendingUnions.length > 0) {
|
|
957
|
+
while (pendingClasses.length > 0 || pendingShapes.length > 0 || pendingUnions.length > 0) {
|
|
909
958
|
while (pendingShapes.length > 0) {
|
|
910
959
|
// Declared fields AND the index-signature value type: an
|
|
911
960
|
// overflow-valued shape (`{ [key: string]: {script?: string} }`)
|
|
@@ -937,6 +986,8 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
937
986
|
visitType(field.type);
|
|
938
987
|
if (info.base)
|
|
939
988
|
visitClass(info.base.def.name);
|
|
989
|
+
if (info.def.genericOf)
|
|
990
|
+
visitClass(info.def.genericOf);
|
|
940
991
|
if (lowerer.inHierarchy(info)) {
|
|
941
992
|
let root = info;
|
|
942
993
|
while (root.base)
|
|
@@ -987,14 +1038,14 @@ export function moduleArtifacts(lowerer, functions) {
|
|
|
987
1038
|
};
|
|
988
1039
|
}
|
|
989
1040
|
/** Registers every DIRECT top-level `const`/`let` of a file as a module
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1041
|
+
* global (stable storage: cross-module live bindings, and functions can
|
|
1042
|
+
* reference them without capture). Block-scoped vars inside nested
|
|
1043
|
+
* statements keep their different symbols and stay locals. */
|
|
993
1044
|
/** 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. */
|
|
1045
|
+
* diagnostics move off the build (into lowerer.runtimeFences) — the declaring
|
|
1046
|
+
* statement re-fails during init lowering and compiles to the
|
|
1047
|
+
* runtimeFence trap there, and every use site cascades to its own trap.
|
|
1048
|
+
* TypeScript files keep eager collection reports. */
|
|
998
1049
|
function deferJsCollectionDiags(lowerer, sf, diagsBefore) {
|
|
999
1050
|
if (!isJsSourceFile(sf))
|
|
1000
1051
|
return;
|
|
@@ -1027,12 +1078,14 @@ function cjsScalarLiteral(e) {
|
|
|
1027
1078
|
function checkedGlobalReference(lowerer, expression) {
|
|
1028
1079
|
if (ts.isIdentifier(expression))
|
|
1029
1080
|
return lowerer.globalOf(expression)?.type.kind === "dyn";
|
|
1030
|
-
if (!ts.isPropertyAccessExpression(expression) ||
|
|
1081
|
+
if (!ts.isPropertyAccessExpression(expression) ||
|
|
1082
|
+
!ts.isIdentifier(expression.name) ||
|
|
1083
|
+
!ts.isIdentifier(expression.expression))
|
|
1031
1084
|
return false;
|
|
1032
1085
|
const root = lowerer.checker.getSymbolAtLocation(expression.expression);
|
|
1033
1086
|
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";
|
|
1087
|
+
return ((namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
|
|
1088
|
+
lowerer.globalOf(expression.name)?.type.kind === "dyn");
|
|
1036
1089
|
}
|
|
1037
1090
|
function jsDynHoldableInitializer(lowerer, init) {
|
|
1038
1091
|
if (init === undefined)
|
|
@@ -1044,15 +1097,18 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1044
1097
|
e = e.expression;
|
|
1045
1098
|
if (checkedGlobalReference(lowerer, e))
|
|
1046
1099
|
return true;
|
|
1047
|
-
if (ts.isCallExpression(e) &&
|
|
1100
|
+
if (ts.isCallExpression(e) &&
|
|
1101
|
+
ts.isPropertyAccessExpression(e.expression) &&
|
|
1048
1102
|
["freeze", "seal", "preventExtensions"].includes(e.expression.name.text) &&
|
|
1049
|
-
lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
|
|
1103
|
+
lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
|
|
1104
|
+
e.arguments[0] &&
|
|
1050
1105
|
ts.isArrayLiteralExpression(e.arguments[0]))
|
|
1051
1106
|
return true;
|
|
1052
1107
|
// The built-in Array constructor can create an evolving array whose
|
|
1053
1108
|
// inferred element type has no native mapping. Its checked reference
|
|
1054
1109
|
// must remain shared with separately declared functions and aliases.
|
|
1055
|
-
if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
|
|
1110
|
+
if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
|
|
1111
|
+
lowerer.isStdlibGlobal(e.expression, "Array"))
|
|
1056
1112
|
return true;
|
|
1057
1113
|
// JavaScript process streams lower to native checked handles even when
|
|
1058
1114
|
// their declared method overloads prevent a structural type mapping.
|
|
@@ -1061,7 +1117,8 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1061
1117
|
const member = lowerer.stdlibGlobalMember(e, "process");
|
|
1062
1118
|
if (member === "stdin" || member === "stdout" || member === "stderr")
|
|
1063
1119
|
return true;
|
|
1064
|
-
if (e.name.text === "constructor" &&
|
|
1120
|
+
if (e.name.text === "constructor" &&
|
|
1121
|
+
lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
|
|
1065
1122
|
return true;
|
|
1066
1123
|
}
|
|
1067
1124
|
if (e.kind === ts.SyntaxKind.NullKeyword)
|
|
@@ -1069,45 +1126,60 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1069
1126
|
if (ts.isIdentifier(e) && e.text === "undefined")
|
|
1070
1127
|
return true;
|
|
1071
1128
|
if (ts.isConditionalExpression(e)) {
|
|
1072
|
-
return jsDynHoldableInitializer(lowerer, e.whenTrue) &&
|
|
1129
|
+
return (jsDynHoldableInitializer(lowerer, e.whenTrue) &&
|
|
1130
|
+
jsDynHoldableInitializer(lowerer, e.whenFalse));
|
|
1073
1131
|
}
|
|
1074
|
-
if (ts.isBinaryExpression(e) &&
|
|
1075
|
-
e.operatorToken.kind === ts.SyntaxKind.
|
|
1132
|
+
if (ts.isBinaryExpression(e) &&
|
|
1133
|
+
(e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
|
|
1134
|
+
e.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
1135
|
+
e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
|
|
1076
1136
|
return jsDynHoldableInitializer(lowerer, e.left) && jsDynHoldableInitializer(lowerer, e.right);
|
|
1077
1137
|
}
|
|
1078
1138
|
// A member of a checked module value is itself checked, including a
|
|
1079
1139
|
// callable whose inferred overloads cannot describe one native ABI.
|
|
1080
1140
|
if ((ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e)) &&
|
|
1081
|
-
ts.isIdentifier(e.expression) &&
|
|
1141
|
+
ts.isIdentifier(e.expression) &&
|
|
1142
|
+
lowerer.globalOf(e.expression)?.type.kind === "dyn")
|
|
1082
1143
|
return true;
|
|
1083
1144
|
if (ts.isPropertyAccessExpression(e)) {
|
|
1084
1145
|
const member = nsMemberIdentOf(lowerer, e);
|
|
1085
|
-
if (member &&
|
|
1146
|
+
if (member &&
|
|
1147
|
+
(lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
|
|
1086
1148
|
return true;
|
|
1087
1149
|
}
|
|
1088
1150
|
// Optional callable reads (for example descriptor?.get) can be held in
|
|
1089
1151
|
// the same checked slot as a callable. Their nullish arm must remain
|
|
1090
1152
|
// observable by functions declared outside the module initializer.
|
|
1091
|
-
if (ts.isPropertyAccessExpression(e) ||
|
|
1153
|
+
if (ts.isPropertyAccessExpression(e) ||
|
|
1154
|
+
ts.isElementAccessExpression(e) ||
|
|
1155
|
+
ts.isCallExpression(e)) {
|
|
1092
1156
|
const fallback = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
|
|
1093
|
-
if (fallback?.kind === "func" &&
|
|
1157
|
+
if (fallback?.kind === "func" &&
|
|
1158
|
+
canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1094
1159
|
return true;
|
|
1095
1160
|
const arms = fallback?.kind === "union" ? lowerer.unions.get(fallback.unionId)?.arms : undefined;
|
|
1096
|
-
if (arms?.some(arm => arm.kind === "func") &&
|
|
1161
|
+
if (arms?.some((arm) => arm.kind === "func") &&
|
|
1162
|
+
arms.every((arm) => isUnitType(arm) ||
|
|
1163
|
+
(arm.kind === "func" &&
|
|
1164
|
+
canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
|
|
1097
1165
|
return true;
|
|
1098
1166
|
}
|
|
1099
|
-
if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
|
|
1167
|
+
if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
|
|
1168
|
+
!e.typeParameters?.length &&
|
|
1169
|
+
isJsSourceFile(e.getSourceFile()))
|
|
1100
1170
|
return true;
|
|
1101
1171
|
if (ts.isIdentifier(e) || ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
|
|
1102
1172
|
if (ts.isIdentifier(e)) {
|
|
1103
1173
|
if (lowerer.globalOf(e)?.type.kind === "dyn")
|
|
1104
1174
|
return true;
|
|
1105
1175
|
const signature = lowerer.isTopLevelFnSymbol(e) ? lowerer.fnSigOf(e) : null;
|
|
1106
|
-
if (signature &&
|
|
1176
|
+
if (signature &&
|
|
1177
|
+
canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1107
1178
|
return true;
|
|
1108
1179
|
}
|
|
1109
1180
|
const type = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
|
|
1110
|
-
if (type?.kind === "func" &&
|
|
1181
|
+
if (type?.kind === "func" &&
|
|
1182
|
+
canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
1111
1183
|
return true;
|
|
1112
1184
|
}
|
|
1113
1185
|
if ((ts.isCallExpression(e) || ts.isPropertyAccessExpression(e) || ts.isIdentifier(e)) &&
|
|
@@ -1192,9 +1264,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1192
1264
|
let inner = stmt.expression;
|
|
1193
1265
|
while (ts.isParenthesizedExpression(inner))
|
|
1194
1266
|
inner = inner.expression;
|
|
1195
|
-
if (ts.isClassExpression(inner) &&
|
|
1267
|
+
if (ts.isClassExpression(inner) &&
|
|
1268
|
+
!isJsSourceFile(sf) &&
|
|
1196
1269
|
inner.typeParameters === undefined &&
|
|
1197
|
-
(decoratorNodesOf(inner).length > 0 ||
|
|
1270
|
+
(decoratorNodesOf(inner).length > 0 ||
|
|
1271
|
+
inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
|
|
1198
1272
|
guaranteedDecorationThrow(lowerer, inner) !== null) {
|
|
1199
1273
|
continue;
|
|
1200
1274
|
}
|
|
@@ -1214,7 +1288,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1214
1288
|
lowerer.badType(stmt.expression, tsType);
|
|
1215
1289
|
// Inferred JavaScript factory exports keep their original value,
|
|
1216
1290
|
// including callable objects decorated with Object.assign.
|
|
1217
|
-
if (isJsSourceFile(sf) &&
|
|
1291
|
+
if (isJsSourceFile(sf) &&
|
|
1292
|
+
ts.isCallExpression(stmt.expression) &&
|
|
1293
|
+
type.kind === "record" &&
|
|
1294
|
+
lowerer.dynConvertible(type))
|
|
1218
1295
|
type = DYN;
|
|
1219
1296
|
// `export default undefined` — the unit-only union, like any
|
|
1220
1297
|
// unit-only binding (`export default null` maps via mapType).
|
|
@@ -1253,7 +1330,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1253
1330
|
// tsgo answers no symbol at the attachment site's NAME (no
|
|
1254
1331
|
// expando synthesis); the module symbol's exports table still
|
|
1255
1332
|
// names the member — the same identity use sites resolve.
|
|
1256
|
-
const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
|
|
1333
|
+
const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
|
|
1334
|
+
lowerer.cjsModuleExportSymbol(sf, name);
|
|
1257
1335
|
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
1258
1336
|
return;
|
|
1259
1337
|
// JS exports whose strict type has no mapping take the
|
|
@@ -1281,7 +1359,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1281
1359
|
lowerer.globalsByDeclNode.set(d, vG);
|
|
1282
1360
|
return;
|
|
1283
1361
|
}
|
|
1284
|
-
const g = {
|
|
1362
|
+
const g = {
|
|
1363
|
+
id: `%g.${tag}%export.${name}`,
|
|
1364
|
+
name,
|
|
1365
|
+
type: vG.type,
|
|
1366
|
+
mutable: false,
|
|
1367
|
+
};
|
|
1285
1368
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1286
1369
|
for (const d of lowerer.checker.declarationsOf(symbol))
|
|
1287
1370
|
lowerer.globalsByDeclNode.set(d, g);
|
|
@@ -1358,7 +1441,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1358
1441
|
if (factoryValued && t?.kind === "record" && lowerer.dynConvertible(t))
|
|
1359
1442
|
t = DYN;
|
|
1360
1443
|
if (t && t.kind !== "void") {
|
|
1361
|
-
const g = {
|
|
1444
|
+
const g = {
|
|
1445
|
+
id: `%g.${tag}exports`,
|
|
1446
|
+
name: "exports",
|
|
1447
|
+
type: t,
|
|
1448
|
+
mutable: false,
|
|
1449
|
+
};
|
|
1362
1450
|
lowerer.globalsByDeclNode.set(cjs.expr, g);
|
|
1363
1451
|
lowerer.globalsList.push(g);
|
|
1364
1452
|
}
|
|
@@ -1399,7 +1487,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1399
1487
|
if (ts.isExternalModuleReference(stmt.moduleReference) || stmt.isTypeOnly)
|
|
1400
1488
|
continue;
|
|
1401
1489
|
const aliasSym = lowerer.checker.getSymbolAtLocation(stmt.name);
|
|
1402
|
-
if (!aliasSym ||
|
|
1490
|
+
if (!aliasSym ||
|
|
1491
|
+
!(aliasSym.flags & ts.SymbolFlags.Alias) ||
|
|
1492
|
+
lowerer.globalsBySymbol.has(aliasSym))
|
|
1403
1493
|
continue;
|
|
1404
1494
|
const target = lowerer.checker.getAliasedSymbol(aliasSym);
|
|
1405
1495
|
const vd = lowerer.checker.valueDeclarationOf(target);
|
|
@@ -1450,10 +1540,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1450
1540
|
// require('node:process')` aliases the global process
|
|
1451
1541
|
// (stdlibGlobalAliasDecl's require form) so reads through the
|
|
1452
1542
|
// binding lower via the process surface.
|
|
1453
|
-
if (isRequireStatement(stmt) &&
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1543
|
+
if (isRequireStatement(stmt) &&
|
|
1544
|
+
!(ts.isVariableStatement(stmt) &&
|
|
1545
|
+
stmt.declarationList.declarations.some((decl) => isNativeFfiRequire(lowerer, decl.initializer)))) {
|
|
1546
|
+
if (ts.isVariableStatement(stmt) && (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
|
|
1457
1547
|
for (const decl of stmt.declarationList.declarations) {
|
|
1458
1548
|
stdlibGlobalAliasDecl(lowerer, decl.name, decl.initializer);
|
|
1459
1549
|
}
|
|
@@ -1657,7 +1747,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1657
1747
|
// statement lowering skips the declaration by the same check. A
|
|
1658
1748
|
// bad promisify target reports here (recorded once; the statement
|
|
1659
1749
|
// lowering poisons too, like every collectGlobals failure).
|
|
1660
|
-
if (ts.isIdentifier(decl.name) &&
|
|
1750
|
+
if (ts.isIdentifier(decl.name) &&
|
|
1751
|
+
decl.initializer &&
|
|
1752
|
+
isPromisifyCall(lowerer, decl.initializer)) {
|
|
1661
1753
|
try {
|
|
1662
1754
|
lowerer.registerPromisifiedBuiltinDecl(decl.name, decl.initializer);
|
|
1663
1755
|
}
|
|
@@ -1728,13 +1820,22 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1728
1820
|
// Checked JavaScript factories can expose inferred callables by
|
|
1729
1821
|
// destructuring. Keep each exported binding in module storage so
|
|
1730
1822
|
// separately lowered functions see the initialized value.
|
|
1731
|
-
if (isJsSourceFile(sf) &&
|
|
1732
|
-
!
|
|
1823
|
+
if (isJsSourceFile(sf) &&
|
|
1824
|
+
!ts.isIdentifier(decl.name) &&
|
|
1825
|
+
decl.initializer &&
|
|
1826
|
+
!decl.type &&
|
|
1827
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1828
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
|
|
1733
1829
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1734
1830
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1735
|
-
const g = {
|
|
1736
|
-
|
|
1737
|
-
|
|
1831
|
+
const g = {
|
|
1832
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1833
|
+
name: nameNode.text,
|
|
1834
|
+
type: DYN,
|
|
1835
|
+
mutable: isLet,
|
|
1836
|
+
source: bindingSource(nameNode),
|
|
1837
|
+
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1838
|
+
};
|
|
1738
1839
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1739
1840
|
lowerer.globalsList.push(g);
|
|
1740
1841
|
if (isVarDeclared(decl))
|
|
@@ -1746,16 +1847,25 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1746
1847
|
// callable ABI. Preserve checked-native values in shared storage;
|
|
1747
1848
|
// adapting the loader to (string) would replace its validation.
|
|
1748
1849
|
const initializer = decl.initializer ? stripTypeCasts(decl.initializer) : undefined;
|
|
1749
|
-
if (isJsSourceFile(sf) &&
|
|
1850
|
+
if (isJsSourceFile(sf) &&
|
|
1851
|
+
nameNode === decl.name &&
|
|
1852
|
+
initializer &&
|
|
1750
1853
|
(isNativeBuiltinValueInitializer(lowerer, initializer) ||
|
|
1751
|
-
(!decl.type &&
|
|
1752
|
-
|
|
1854
|
+
(!decl.type &&
|
|
1855
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1856
|
+
lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
|
|
1857
|
+
(!decl.type &&
|
|
1858
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1859
|
+
checkedGlobalReference(lowerer, initializer)) ||
|
|
1753
1860
|
(!lowerer.dynamic && stdlibGlobalNameOf(lowerer, initializer) === "globalThis"))) {
|
|
1754
1861
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1755
1862
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1756
1863
|
const g = {
|
|
1757
|
-
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1758
|
-
|
|
1864
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1865
|
+
name: nameNode.text,
|
|
1866
|
+
type: DYN,
|
|
1867
|
+
mutable: isLet,
|
|
1868
|
+
source: bindingSource(nameNode),
|
|
1759
1869
|
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1760
1870
|
};
|
|
1761
1871
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
@@ -1774,12 +1884,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1774
1884
|
// storage instead of fencing per reference. Identifier
|
|
1775
1885
|
// declarations only: a destructured array literal binds its
|
|
1776
1886
|
// pieces, not the array.
|
|
1777
|
-
if (isJsSourceFile(sf) &&
|
|
1778
|
-
|
|
1779
|
-
|
|
1887
|
+
if (isJsSourceFile(sf) &&
|
|
1888
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
1889
|
+
ts.isIdentifier(decl.name) &&
|
|
1890
|
+
nameNode === decl.name &&
|
|
1891
|
+
decl.initializer !== undefined &&
|
|
1892
|
+
ts.isArrayLiteralExpression(decl.initializer)) {
|
|
1780
1893
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1781
1894
|
if (symbol) {
|
|
1782
|
-
const g = {
|
|
1895
|
+
const g = {
|
|
1896
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
1897
|
+
name: nameNode.text,
|
|
1898
|
+
type: DYN,
|
|
1899
|
+
mutable: isLet,
|
|
1900
|
+
source: bindingSource(nameNode),
|
|
1901
|
+
};
|
|
1783
1902
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1784
1903
|
lowerer.globalsList.push(g);
|
|
1785
1904
|
}
|
|
@@ -1789,14 +1908,26 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1789
1908
|
// Methods and computed properties require live checked storage:
|
|
1790
1909
|
// symbol identity and a method's receiver cannot be reconstructed
|
|
1791
1910
|
// from a copied, inferred record shape.
|
|
1792
|
-
if (isJsSourceFile(sf) &&
|
|
1793
|
-
|
|
1911
|
+
if (isJsSourceFile(sf) &&
|
|
1912
|
+
ts.isIdentifier(decl.name) &&
|
|
1913
|
+
nameNode === decl.name &&
|
|
1914
|
+
decl.initializer &&
|
|
1915
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1794
1916
|
decl.initializer.properties.some((p) => !ts.isSpreadAssignment(p) &&
|
|
1795
|
-
(ts.isMethodDeclaration(p) ||
|
|
1796
|
-
ts.
|
|
1917
|
+
(ts.isMethodDeclaration(p) ||
|
|
1918
|
+
ts.isAccessor(p) ||
|
|
1919
|
+
ts.isComputedPropertyName(p.name) ||
|
|
1920
|
+
(ts.isShorthandPropertyAssignment(p) &&
|
|
1921
|
+
lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0)))) {
|
|
1797
1922
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1798
1923
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1799
|
-
const g = {
|
|
1924
|
+
const g = {
|
|
1925
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1926
|
+
name: nameNode.text,
|
|
1927
|
+
type: DYN,
|
|
1928
|
+
mutable: isLet,
|
|
1929
|
+
source: bindingSource(nameNode),
|
|
1930
|
+
};
|
|
1800
1931
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1801
1932
|
lowerer.globalsList.push(g);
|
|
1802
1933
|
if (isVarDeclared(decl))
|
|
@@ -1821,21 +1952,31 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1821
1952
|
// Spreads from an existing checked dictionary stay checked too;
|
|
1822
1953
|
// copying its entries must not extract nested callable records.
|
|
1823
1954
|
if (isJsSourceFile(sf) &&
|
|
1824
|
-
ts.isIdentifier(decl.name) &&
|
|
1825
|
-
|
|
1955
|
+
ts.isIdentifier(decl.name) &&
|
|
1956
|
+
nameNode === decl.name &&
|
|
1957
|
+
decl.initializer !== undefined &&
|
|
1958
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1826
1959
|
decl.initializer.properties.every((p) => {
|
|
1827
1960
|
if (ts.isSpreadAssignment(p)) {
|
|
1828
|
-
return ts.isIdentifier(p.expression) &&
|
|
1961
|
+
return (ts.isIdentifier(p.expression) &&
|
|
1962
|
+
lowerer.globalOf(p.expression)?.type.kind === "dyn");
|
|
1829
1963
|
}
|
|
1830
1964
|
if (!ts.isPropertyAssignment(p) || ts.isComputedPropertyName(p.name))
|
|
1831
1965
|
return false;
|
|
1832
1966
|
const mt = lowerer.mapTypeOf(lowerer.typeOf(p.initializer));
|
|
1833
|
-
return mt === null ||
|
|
1834
|
-
|
|
1967
|
+
return (mt === null ||
|
|
1968
|
+
mt.kind === "dyn" ||
|
|
1969
|
+
canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)));
|
|
1835
1970
|
})) {
|
|
1836
1971
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1837
1972
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1838
|
-
const g = {
|
|
1973
|
+
const g = {
|
|
1974
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
1975
|
+
name: nameNode.text,
|
|
1976
|
+
type: DYN,
|
|
1977
|
+
mutable: isLet,
|
|
1978
|
+
source: bindingSource(nameNode),
|
|
1979
|
+
};
|
|
1839
1980
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1840
1981
|
lowerer.globalsList.push(g);
|
|
1841
1982
|
}
|
|
@@ -1854,13 +1995,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1854
1995
|
// decl keeps as an %init local) stay OUT: forcing those into
|
|
1855
1996
|
// the checked-dynamic tree would trade their working typed representation for
|
|
1856
1997
|
// fences.
|
|
1857
|
-
if (isJsSourceFile(sf) &&
|
|
1858
|
-
|
|
1998
|
+
if (isJsSourceFile(sf) &&
|
|
1999
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2000
|
+
ts.isIdentifier(decl.name) &&
|
|
2001
|
+
nameNode === decl.name &&
|
|
1859
2002
|
jsDynHoldableInitializer(lowerer, decl.initializer) &&
|
|
1860
2003
|
dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode))?.kind === "dyn") {
|
|
1861
2004
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1862
2005
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1863
|
-
const g = {
|
|
2006
|
+
const g = {
|
|
2007
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2008
|
+
name: nameNode.text,
|
|
2009
|
+
type: DYN,
|
|
2010
|
+
mutable: isLet,
|
|
2011
|
+
source: bindingSource(nameNode),
|
|
2012
|
+
};
|
|
1864
2013
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1865
2014
|
lowerer.globalsList.push(g);
|
|
1866
2015
|
// Mutable dyn globals hold the dyn undefined from module
|
|
@@ -1879,13 +2028,23 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1879
2028
|
// the binding holds the HANDLE — a jsval global, so exports
|
|
1880
2029
|
// and separately-declared functions reach the same engine
|
|
1881
2030
|
// object.
|
|
1882
|
-
if (lowerer.dynamic &&
|
|
1883
|
-
|
|
1884
|
-
|
|
2031
|
+
if (lowerer.dynamic &&
|
|
2032
|
+
isJsSourceFile(sf) &&
|
|
2033
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2034
|
+
ts.isIdentifier(decl.name) &&
|
|
2035
|
+
nameNode === decl.name &&
|
|
2036
|
+
decl.initializer !== undefined &&
|
|
2037
|
+
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
1885
2038
|
decl.initializer.properties.some((p) => ts.isGetAccessorDeclaration(p))) {
|
|
1886
2039
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1887
2040
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1888
|
-
const g = {
|
|
2041
|
+
const g = {
|
|
2042
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2043
|
+
name: nameNode.text,
|
|
2044
|
+
type: JSVAL,
|
|
2045
|
+
mutable: isLet,
|
|
2046
|
+
source: bindingSource(nameNode),
|
|
2047
|
+
};
|
|
1889
2048
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1890
2049
|
lowerer.globalsList.push(g);
|
|
1891
2050
|
}
|
|
@@ -1896,23 +2055,37 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1896
2055
|
// that closure in a checked-value global so class methods and
|
|
1897
2056
|
// other module functions see its declaration-position assignment.
|
|
1898
2057
|
// A var starts undefined; lexical bindings retain the TDZ guard.
|
|
1899
|
-
if (isJsSourceFile(sf) &&
|
|
1900
|
-
|
|
2058
|
+
if (isJsSourceFile(sf) &&
|
|
2059
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2060
|
+
ts.isIdentifier(decl.name) &&
|
|
2061
|
+
nameNode === decl.name &&
|
|
2062
|
+
decl.initializer &&
|
|
1901
2063
|
jsDynHoldableInitializer(lowerer, decl.initializer)) {
|
|
1902
2064
|
const initializer = decl.initializer;
|
|
1903
|
-
const member = ts.isPropertyAccessExpression(initializer)
|
|
2065
|
+
const member = ts.isPropertyAccessExpression(initializer)
|
|
2066
|
+
? nsMemberIdentOf(lowerer, initializer)
|
|
2067
|
+
: null;
|
|
1904
2068
|
const generic = member && lowerer.genericFnOf(member);
|
|
1905
|
-
const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
|
|
2069
|
+
const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
|
|
2070
|
+
!initializer.typeParameters?.length
|
|
1906
2071
|
? lowerer.lambdaSignature(initializer).funcType
|
|
1907
|
-
: member && lowerer.globalOf(member)?.type.kind === "dyn"
|
|
1908
|
-
|
|
2072
|
+
: member && lowerer.globalOf(member)?.type.kind === "dyn"
|
|
2073
|
+
? DYN
|
|
2074
|
+
: member && generic?.implicitParams
|
|
2075
|
+
? lowerer.lowerGenericFnValue(member, generic).type
|
|
1909
2076
|
: dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode));
|
|
1910
2077
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1911
|
-
if (symbol &&
|
|
2078
|
+
if (symbol &&
|
|
2079
|
+
fallback &&
|
|
2080
|
+
(fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") &&
|
|
2081
|
+
lowerer.dynConvertible(fallback)) {
|
|
1912
2082
|
if (!lowerer.globalsBySymbol.has(symbol)) {
|
|
1913
2083
|
const g = {
|
|
1914
|
-
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
1915
|
-
|
|
2084
|
+
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2085
|
+
name: nameNode.text,
|
|
2086
|
+
type: DYN,
|
|
2087
|
+
mutable: isLet,
|
|
2088
|
+
source: bindingSource(nameNode),
|
|
1916
2089
|
...(!isVarDeclared(decl) ? { tdz: true } : {}),
|
|
1917
2090
|
};
|
|
1918
2091
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
@@ -1930,37 +2103,63 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1930
2103
|
// and closures created in the init body capture it normally.
|
|
1931
2104
|
// References from separately-declared functions cascade to
|
|
1932
2105
|
// their own per-site runtime fences.
|
|
1933
|
-
const factoryType = !isLet &&
|
|
1934
|
-
|
|
1935
|
-
|
|
2106
|
+
const factoryType = !isLet &&
|
|
2107
|
+
isJsSourceFile(sf) &&
|
|
2108
|
+
!decl.type &&
|
|
2109
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2110
|
+
ts.isIdentifier(decl.name) &&
|
|
2111
|
+
nameNode === decl.name &&
|
|
2112
|
+
decl.initializer &&
|
|
2113
|
+
ts.isNewExpression(decl.initializer)
|
|
2114
|
+
? (objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined)
|
|
2115
|
+
: undefined;
|
|
1936
2116
|
// `var p1 = import("./m")` at file scope: the global holds the
|
|
1937
2117
|
// island promise/handle — the import expression's only
|
|
1938
2118
|
// production — whatever the checker's namespace type mapped to
|
|
1939
2119
|
// (lowerVarDecl's rule at module scope; the init body assigns
|
|
1940
2120
|
// it).
|
|
1941
2121
|
const handleT = ts.isIdentifier(decl.name) && nameNode === decl.name
|
|
1942
|
-
? (isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
|
|
1943
|
-
(lowerer.dynamic
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2122
|
+
? ((isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
|
|
2123
|
+
(lowerer.dynamic
|
|
2124
|
+
? importCallHandleType(decl.initializer)
|
|
2125
|
+
: staticImportNamespaceType(lowerer, decl.initializer)) ??
|
|
2126
|
+
(lowerer.dynamic
|
|
2127
|
+
? // An unchecked-overload call result stores the handle,
|
|
2128
|
+
// exactly the local rule (uncheckedOverloadHandleCall).
|
|
2129
|
+
uncheckedOverloadHandleCall(lowerer, decl.initializer)
|
|
2130
|
+
? JSVAL
|
|
2131
|
+
: null
|
|
2132
|
+
: null))
|
|
1948
2133
|
: null;
|
|
1949
2134
|
// JavaScript factory results with unmappable annotations still
|
|
1950
2135
|
// need shared storage. Unannotated callable unions also use a
|
|
1951
2136
|
// checked slot; mappable authored annotations keep their layout.
|
|
1952
2137
|
const unannotatedCall = !decl.type && !hasJsTypeAnnotation(decl);
|
|
1953
|
-
const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
|
|
1954
|
-
|
|
2138
|
+
const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
|
|
2139
|
+
decl.initializer &&
|
|
2140
|
+
ts.isCallExpression(decl.initializer)
|
|
2141
|
+
? lowerer.checker.getResolvedSignature(decl.initializer)
|
|
2142
|
+
: undefined;
|
|
1955
2143
|
const callDeclaration = callSignature && lowerer.checker.signatureDeclaration(callSignature);
|
|
1956
2144
|
const callType = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile())
|
|
1957
|
-
? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2145
|
+
? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
|
|
2146
|
+
: null;
|
|
2147
|
+
const inferredJsCall = callDeclaration &&
|
|
2148
|
+
isJsSourceFile(callDeclaration.getSourceFile()) &&
|
|
2149
|
+
(!callType ||
|
|
2150
|
+
(unannotatedCall &&
|
|
2151
|
+
callType.kind === "union" &&
|
|
2152
|
+
lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func")));
|
|
2153
|
+
if (!factoryType &&
|
|
2154
|
+
!inferredJsCall &&
|
|
2155
|
+
isJsSourceFile(sf) &&
|
|
2156
|
+
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
|
|
1961
2157
|
continue;
|
|
1962
2158
|
let type = handleT ?? factoryType ?? (inferredJsCall ? DYN : lowerer.irTypeOf(nameNode));
|
|
1963
|
-
if (isJsSourceFile(sf) &&
|
|
2159
|
+
if (isJsSourceFile(sf) &&
|
|
2160
|
+
!decl.type &&
|
|
2161
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2162
|
+
decl.initializer &&
|
|
1964
2163
|
(ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer)) &&
|
|
1965
2164
|
!decl.initializer.typeParameters?.length) {
|
|
1966
2165
|
type = lowerer.lambdaSignature(decl.initializer).funcType;
|
|
@@ -1968,8 +2167,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1968
2167
|
// Namespace aliases of inferred helpers carry the helper's
|
|
1969
2168
|
// settled callable, whose return can differ from checker inference.
|
|
1970
2169
|
// Keep a shared checked slot before any consumer specializes it.
|
|
1971
|
-
if (isJsSourceFile(sf) &&
|
|
1972
|
-
decl.
|
|
2170
|
+
if (isJsSourceFile(sf) &&
|
|
2171
|
+
!decl.type &&
|
|
2172
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2173
|
+
type.kind === "func" &&
|
|
2174
|
+
decl.initializer &&
|
|
2175
|
+
ts.isPropertyAccessExpression(decl.initializer)) {
|
|
1973
2176
|
const member = nsMemberIdentOf(lowerer, decl.initializer);
|
|
1974
2177
|
if (member && lowerer.genericFnOf(member)?.implicitParams)
|
|
1975
2178
|
type = DYN;
|
|
@@ -1979,24 +2182,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1979
2182
|
type = source.type;
|
|
1980
2183
|
}
|
|
1981
2184
|
}
|
|
1982
|
-
if (isJsSourceFile(sf) &&
|
|
1983
|
-
decl.
|
|
2185
|
+
if (isJsSourceFile(sf) &&
|
|
2186
|
+
!decl.type &&
|
|
2187
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2188
|
+
decl.initializer &&
|
|
2189
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2190
|
+
type.kind === "union") {
|
|
1984
2191
|
const arms = lowerer.unions.get(type.unionId)?.arms;
|
|
1985
|
-
if (arms?.some((arm) => arm.kind === "record") &&
|
|
2192
|
+
if (arms?.some((arm) => arm.kind === "record") &&
|
|
2193
|
+
arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
|
|
1986
2194
|
type = DYN;
|
|
1987
2195
|
}
|
|
1988
|
-
if (isJsSourceFile(sf) &&
|
|
1989
|
-
|
|
1990
|
-
!(
|
|
2196
|
+
if (isJsSourceFile(sf) &&
|
|
2197
|
+
!decl.type &&
|
|
2198
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2199
|
+
decl.initializer &&
|
|
2200
|
+
ts.isNewExpression(decl.initializer) &&
|
|
2201
|
+
lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
|
|
2202
|
+
!(ts.isIdentifier(decl.initializer.expression) &&
|
|
2203
|
+
lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
|
|
1991
2204
|
type = DYN;
|
|
1992
2205
|
// Calls through checked function values retain their object
|
|
1993
2206
|
// identity, including symbol keys absent from inferred records.
|
|
1994
|
-
if (isJsSourceFile(sf) &&
|
|
1995
|
-
decl.
|
|
2207
|
+
if (isJsSourceFile(sf) &&
|
|
2208
|
+
!decl.type &&
|
|
2209
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2210
|
+
type.kind === "record" &&
|
|
2211
|
+
decl.initializer &&
|
|
2212
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2213
|
+
lowerer.dynConvertible(type)) {
|
|
1996
2214
|
type = DYN;
|
|
1997
2215
|
}
|
|
1998
|
-
if (isJsSourceFile(sf) &&
|
|
1999
|
-
decl.
|
|
2216
|
+
if (isJsSourceFile(sf) &&
|
|
2217
|
+
!decl.type &&
|
|
2218
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2219
|
+
type.kind === "record" &&
|
|
2220
|
+
decl.initializer &&
|
|
2221
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2000
2222
|
ts.isPropertyAccessExpression(decl.initializer.expression) &&
|
|
2001
2223
|
lowerer.stdlibGlobalMember(decl.initializer.expression, "Object") === "assign" &&
|
|
2002
2224
|
decl.initializer.arguments.some((arg) => ts.isIdentifier(arg) && lowerer.globalOf(arg)?.type.kind === "dyn")) {
|
|
@@ -2005,24 +2227,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2005
2227
|
// Runtime-arity JavaScript callables can be returned by a
|
|
2006
2228
|
// checked factory. Keep that callable boxed instead of asking
|
|
2007
2229
|
// a fixed-signature adapter to reconstruct its hidden rest ABI.
|
|
2008
|
-
if (!decl.type &&
|
|
2230
|
+
if (!decl.type &&
|
|
2231
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2232
|
+
type.kind === "func" &&
|
|
2233
|
+
type.rest === true &&
|
|
2234
|
+
type.restAbi === undefined)
|
|
2009
2235
|
type = DYN;
|
|
2010
|
-
if (isJsSourceFile(sf) &&
|
|
2236
|
+
if (isJsSourceFile(sf) &&
|
|
2237
|
+
isLet &&
|
|
2238
|
+
!decl.type &&
|
|
2239
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2011
2240
|
(type.kind === "object" || jsBindingHasOpenWrites(lowerer, decl)))
|
|
2012
2241
|
type = DYN;
|
|
2013
2242
|
// JavaScript call results may retain a checked array supplied by
|
|
2014
2243
|
// the caller. A typed global here would copy it on extraction.
|
|
2015
|
-
if (isJsSourceFile(sf) &&
|
|
2016
|
-
decl.
|
|
2244
|
+
if (isJsSourceFile(sf) &&
|
|
2245
|
+
!decl.type &&
|
|
2246
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2247
|
+
type.kind === "array" &&
|
|
2248
|
+
decl.initializer &&
|
|
2249
|
+
ts.isCallExpression(decl.initializer))
|
|
2017
2250
|
type = DYN;
|
|
2018
|
-
if (!lowerer.dynamic &&
|
|
2019
|
-
|
|
2251
|
+
if (!lowerer.dynamic &&
|
|
2252
|
+
isJsSourceFile(sf) &&
|
|
2253
|
+
!decl.type &&
|
|
2254
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2255
|
+
decl.initializer &&
|
|
2256
|
+
ts.isNewExpression(decl.initializer) &&
|
|
2257
|
+
lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
|
|
2020
2258
|
(type.kind !== "array" || type.elem.kind === "dyn"))
|
|
2021
2259
|
type = DYN;
|
|
2022
2260
|
// Unannotated JavaScript aliases retain an existing native
|
|
2023
2261
|
// checked object instead of copying it into an inferred record.
|
|
2024
|
-
if (isJsSourceFile(sf) &&
|
|
2025
|
-
decl.
|
|
2262
|
+
if (isJsSourceFile(sf) &&
|
|
2263
|
+
!decl.type &&
|
|
2264
|
+
!hasJsTypeAnnotation(decl) &&
|
|
2265
|
+
decl.initializer &&
|
|
2266
|
+
ts.isIdentifier(decl.initializer) &&
|
|
2026
2267
|
(type.kind === "record" || type.kind === "func")) {
|
|
2027
2268
|
const source = lowerer.globalOf(decl.initializer);
|
|
2028
2269
|
if (source?.type.kind === "dyn")
|
|
@@ -2030,10 +2271,15 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2030
2271
|
}
|
|
2031
2272
|
// JavaScript bind inference can leave an artificial tuple-rest
|
|
2032
2273
|
// signature. Keep the returned callable's runtime arity intact.
|
|
2033
|
-
if (isJsSourceFile(sf) &&
|
|
2034
|
-
|
|
2035
|
-
decl.initializer
|
|
2036
|
-
|
|
2274
|
+
if (isJsSourceFile(sf) &&
|
|
2275
|
+
type.kind === "func" &&
|
|
2276
|
+
decl.initializer &&
|
|
2277
|
+
ts.isCallExpression(decl.initializer) &&
|
|
2278
|
+
ts.isPropertyAccessExpression(decl.initializer.expression) &&
|
|
2279
|
+
decl.initializer.expression.name.text === "bind" &&
|
|
2280
|
+
lowerer.isStdlibMember(decl.initializer.expression) &&
|
|
2281
|
+
decl.type === undefined &&
|
|
2282
|
+
!hasJsTypeAnnotation(decl)) {
|
|
2037
2283
|
type = DYN;
|
|
2038
2284
|
}
|
|
2039
2285
|
// An evolving-`any` array's DERIVED file-scope binding under
|
|
@@ -2046,18 +2292,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2046
2292
|
// element array (lowerVarDecl's adoption, the file-scope
|
|
2047
2293
|
// face). Annotated declarations keep the validated-boundary
|
|
2048
2294
|
// fence.
|
|
2049
|
-
if (lowerer.dynamic &&
|
|
2050
|
-
|
|
2051
|
-
|
|
2295
|
+
if (lowerer.dynamic &&
|
|
2296
|
+
ts.isIdentifier(decl.name) &&
|
|
2297
|
+
nameNode === decl.name &&
|
|
2298
|
+
decl.type === undefined &&
|
|
2299
|
+
decl.initializer !== undefined &&
|
|
2300
|
+
type.kind === "array" &&
|
|
2301
|
+
type.elem.kind !== "jsval" &&
|
|
2052
2302
|
handleArrayPreservingCall(lowerer, decl.initializer)) {
|
|
2053
2303
|
type = arrayOf(JSVAL);
|
|
2054
2304
|
}
|
|
2055
|
-
//
|
|
2056
|
-
//
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
if (type.kind === "record" && ts.isIdentifier(decl.name) && nameNode === decl.name &&
|
|
2305
|
+
// An exact class behind a generic interface keeps its native
|
|
2306
|
+
// representation so generic calls can specialize against its body.
|
|
2307
|
+
if ((type.kind === "record" || type.kind === "dyn") &&
|
|
2308
|
+
ts.isIdentifier(decl.name) &&
|
|
2309
|
+
nameNode === decl.name &&
|
|
2061
2310
|
genericIfaceBindingKeepsClass(lowerer, decl, type)) {
|
|
2062
2311
|
const initT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
|
|
2063
2312
|
if (initT?.kind === "object")
|
|
@@ -2073,8 +2322,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2073
2322
|
if (lowerer.dynamic && !ts.isIdentifier(decl.name) && decl.initializer !== undefined) {
|
|
2074
2323
|
const srcT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
|
|
2075
2324
|
const island = srcT !== null &&
|
|
2076
|
-
(srcT.kind === "jsval" ||
|
|
2077
|
-
srcT.kind === "
|
|
2325
|
+
(srcT.kind === "jsval" ||
|
|
2326
|
+
srcT.kind === "f64" ||
|
|
2327
|
+
srcT.kind === "bool" ||
|
|
2328
|
+
srcT.kind === "string" ||
|
|
2329
|
+
isUnitType(srcT));
|
|
2078
2330
|
if (island && type.kind !== "f64" && type.kind !== "bool" && type.kind !== "string") {
|
|
2079
2331
|
type = JSVAL;
|
|
2080
2332
|
}
|
|
@@ -2096,7 +2348,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2096
2348
|
// adapter would re-copy at the assignment.
|
|
2097
2349
|
if (isJsSourceFile(sf) &&
|
|
2098
2350
|
type.kind === "func" &&
|
|
2099
|
-
(type.ret.kind === "date" ||
|
|
2351
|
+
(type.ret.kind === "date" ||
|
|
2352
|
+
(type.ret.kind === "record" && lowerer.dynConvertible(type.ret))) &&
|
|
2100
2353
|
decl.initializer !== undefined &&
|
|
2101
2354
|
(ts.isFunctionExpression(decl.initializer) || ts.isArrowFunction(decl.initializer)) &&
|
|
2102
2355
|
decl.initializer.type === undefined &&
|
|
@@ -2115,13 +2368,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2115
2368
|
// Module vars hold real undefined until their declaration runs.
|
|
2116
2369
|
// Unannotated JS function values need that state too: callers
|
|
2117
2370
|
// before the initializer must see undefined and a TypeError.
|
|
2118
|
-
if (isJsSourceFile(sf) &&
|
|
2371
|
+
if (isJsSourceFile(sf) &&
|
|
2372
|
+
isVarDeclared(decl) &&
|
|
2373
|
+
type.kind === "func" &&
|
|
2374
|
+
lowerer.dynConvertible(type))
|
|
2119
2375
|
type = DYN;
|
|
2120
2376
|
// Codec records keep that state in the ordinary optional union;
|
|
2121
2377
|
// lexical codec declarations retain their separate TDZ guard.
|
|
2122
|
-
const codec = type.kind === "record" &&
|
|
2378
|
+
const codec = type.kind === "record" &&
|
|
2379
|
+
recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
|
|
2123
2380
|
if (codec && isVarDeclared(decl)) {
|
|
2124
|
-
type = {
|
|
2381
|
+
type = {
|
|
2382
|
+
kind: "union",
|
|
2383
|
+
unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
|
|
2384
|
+
};
|
|
2125
2385
|
}
|
|
2126
2386
|
else if (codec && !decl.initializer) {
|
|
2127
2387
|
lowerer.noLowering("uninitialized lexical codec bindings", decl, "initialize let or const TextEncoder/TextDecoder bindings at their declaration");
|
|
@@ -2141,7 +2401,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2141
2401
|
// A function pointer must not be dereferenced before a lexical
|
|
2142
2402
|
// declaration assigns it. The shared pointer TDZ guard handles
|
|
2143
2403
|
// these bindings like stored codec records.
|
|
2144
|
-
...((
|
|
2404
|
+
...((codec || type.kind === "func") && !isVarDeclared(decl)
|
|
2405
|
+
? { tdz: true }
|
|
2406
|
+
: {}),
|
|
2145
2407
|
};
|
|
2146
2408
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
2147
2409
|
lowerer.globalsList.push(g);
|
|
@@ -2167,19 +2429,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2167
2429
|
}
|
|
2168
2430
|
}
|
|
2169
2431
|
/** True iff this initializer's VALUE is a jsval-element array from a
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2432
|
+
* module global already registered as one (the evolving-`any` binding
|
|
2433
|
+
* under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
|
|
2434
|
+
* array-method call chain over it (filter/slice/splice/concat — each
|
|
2435
|
+
* answers the receiver's own array type). Registration runs in source
|
|
2436
|
+
* order, so the root's global — declared above, TDZ-guaranteed — is
|
|
2437
|
+
* already in the table. */
|
|
2176
2438
|
function handleArrayPreservingCall(lowerer, e) {
|
|
2177
2439
|
const PRESERVING = new Set(["filter", "slice", "splice", "concat"]);
|
|
2178
2440
|
let cur = e;
|
|
2179
2441
|
for (;;) {
|
|
2180
2442
|
while (ts.isParenthesizedExpression(cur))
|
|
2181
2443
|
cur = cur.expression;
|
|
2182
|
-
if (ts.isCallExpression(cur) &&
|
|
2444
|
+
if (ts.isCallExpression(cur) &&
|
|
2445
|
+
ts.isPropertyAccessExpression(cur.expression) &&
|
|
2183
2446
|
PRESERVING.has(cur.expression.name.text)) {
|
|
2184
2447
|
cur = cur.expression.expression;
|
|
2185
2448
|
continue;
|
|
@@ -2193,14 +2456,14 @@ function handleArrayPreservingCall(lowerer, e) {
|
|
|
2193
2456
|
return g?.type.kind === "array" && g.type.elem.kind === "jsval";
|
|
2194
2457
|
}
|
|
2195
2458
|
/** Registers the entry-init note for a `var` module global: JS hoists
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2459
|
+
* module vars to `undefined` at module entry, so an undefined-armed slot
|
|
2460
|
+
* must hold the interned undefined arm BEFORE the body runs (a function
|
|
2461
|
+
* called above the declaration statement may read it — lowerFileInit
|
|
2462
|
+
* emits the assigns right after the run-once guard). Checked-dynamic
|
|
2463
|
+
* slots hold the dyn undefined the same way (a NULL dyn is a trap, not
|
|
2464
|
+
* a value). Other types need nothing: tsc's flow analysis rejects their
|
|
2465
|
+
* direct early reads, and closure reads share let's documented
|
|
2466
|
+
* zero/NULL divergence window. */
|
|
2204
2467
|
function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
2205
2468
|
// 'any' globals need the entry init exactly like undefined-armed
|
|
2206
2469
|
// unions: tsc never guards `any` reads, so `var x: any;` is readable
|
|
@@ -2215,25 +2478,31 @@ function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
|
2215
2478
|
lowerer.varGlobalEntryInits.set(sf, inits);
|
|
2216
2479
|
}
|
|
2217
2480
|
/** The nested half of module-scope `var` hoisting: a `var` inside a
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2481
|
+
* top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
|
|
2482
|
+
* JS — other functions in the file read the same binding — so it must
|
|
2483
|
+
* be a module global like its top-level siblings. Walks a top-level
|
|
2484
|
+
* statement's insides for var-flagged declaration lists (statement and
|
|
2485
|
+
* for/for-in/for-of initializer positions), never descending into
|
|
2486
|
+
* function-likes, classes, or static blocks (each hoists to its own
|
|
2487
|
+
* scope). Registration mirrors the main path's identifier story:
|
|
2488
|
+
* JS-unmappable types register nothing (per-site fences own the
|
|
2489
|
+
* references), everything else gets a mutable global. */
|
|
2227
2490
|
function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
2228
2491
|
const lists = [];
|
|
2229
2492
|
// Iterative walk (walkPreorder): this sweep sees every non-var top-level
|
|
2230
2493
|
// statement whole — the binderBinaryExpressionStress bare ~6500-term
|
|
2231
2494
|
// chain sat within ~50 terms of overflowing the recursive form.
|
|
2232
2495
|
ts.walkPreorder(stmt, (node) => {
|
|
2233
|
-
if (ts.isFunctionDeclaration(node) ||
|
|
2234
|
-
ts.
|
|
2235
|
-
ts.
|
|
2236
|
-
ts.
|
|
2496
|
+
if (ts.isFunctionDeclaration(node) ||
|
|
2497
|
+
ts.isFunctionExpression(node) ||
|
|
2498
|
+
ts.isArrowFunction(node) ||
|
|
2499
|
+
ts.isMethodDeclaration(node) ||
|
|
2500
|
+
ts.isConstructorDeclaration(node) ||
|
|
2501
|
+
ts.isGetAccessorDeclaration(node) ||
|
|
2502
|
+
ts.isSetAccessorDeclaration(node) ||
|
|
2503
|
+
ts.isClassStaticBlockDeclaration(node) ||
|
|
2504
|
+
ts.isClassDeclaration(node) ||
|
|
2505
|
+
ts.isClassExpression(node) ||
|
|
2237
2506
|
ts.isModuleDeclaration(node)) {
|
|
2238
2507
|
return "skip";
|
|
2239
2508
|
}
|
|
@@ -2263,13 +2532,23 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
|
2263
2532
|
if (shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple)
|
|
2264
2533
|
type = DYN;
|
|
2265
2534
|
}
|
|
2266
|
-
if (type.kind === "record" &&
|
|
2267
|
-
|
|
2535
|
+
if (type.kind === "record" &&
|
|
2536
|
+
recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
|
|
2537
|
+
type = {
|
|
2538
|
+
kind: "union",
|
|
2539
|
+
unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
|
|
2540
|
+
};
|
|
2268
2541
|
}
|
|
2269
2542
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
2270
2543
|
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
2271
2544
|
continue;
|
|
2272
|
-
const g = {
|
|
2545
|
+
const g = {
|
|
2546
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
2547
|
+
name: nameNode.text,
|
|
2548
|
+
type,
|
|
2549
|
+
mutable: true,
|
|
2550
|
+
source: bindingSource(nameNode),
|
|
2551
|
+
};
|
|
2273
2552
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
2274
2553
|
lowerer.globalsList.push(g);
|
|
2275
2554
|
noteVarGlobalEntryInit(lowerer, sf, g);
|
|
@@ -2284,21 +2563,21 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
|
2284
2563
|
}
|
|
2285
2564
|
}
|
|
2286
2565
|
/** The checker's symbol for a module's default export — the symbol a
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2566
|
+
* default import of this module aliases to (getAliasedSymbol), so keying
|
|
2567
|
+
* the default's global by it makes every importer resolve to the same
|
|
2568
|
+
* storage through the ordinary globalOf path. Null for modules without
|
|
2569
|
+
* a default export (or non-module files). */
|
|
2291
2570
|
export function defaultExportSymbolOf(lowerer, sf) {
|
|
2292
2571
|
const moduleSym = lowerer.checker.getSymbolAtLocation(sf);
|
|
2293
2572
|
return moduleSym?.getExports().get(ts.InternalSymbolName.Default) ?? null;
|
|
2294
2573
|
}
|
|
2295
2574
|
/** The declaration symbol of a top-level function/class declaration,
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2575
|
+
* covering the one legal NAMELESS form: `export default function () {}` /
|
|
2576
|
+
* `export default class {}`. A named declaration answers through its
|
|
2577
|
+
* name node; the anonymous default IS the module's `default` export
|
|
2578
|
+
* symbol (the binder declares it there), so collection, reachability,
|
|
2579
|
+
* and body lowering all key that one identity — which is also what a
|
|
2580
|
+
* default import's alias chain resolves to. */
|
|
2302
2581
|
export function declSymbolOf(lowerer, decl) {
|
|
2303
2582
|
if (decl.name)
|
|
2304
2583
|
return lowerer.checker.getSymbolAtLocation(decl.name);
|
|
@@ -2310,18 +2589,18 @@ export function declSymbolOf(lowerer, decl) {
|
|
|
2310
2589
|
return sym ?? undefined;
|
|
2311
2590
|
}
|
|
2312
2591
|
/** `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
|
-
|
|
2592
|
+
* assignment of the pre-registered `default` global — evaluated at the
|
|
2593
|
+
* statement's source position, exactly where Node runs it (Node's
|
|
2594
|
+
* expression defaults snapshot exactly once, here). ENTITY-NAME defaults
|
|
2595
|
+
* of immutable targets are alias plumbing with no storage of their own:
|
|
2596
|
+
* the statement lowers to nothing — importers' alias-resolved reads
|
|
2597
|
+
* equal the snapshot. MUTABLE entity-name defaults registered snapshot
|
|
2598
|
+
* storage in collection and assign it here like any expression default
|
|
2599
|
+
* (the identifier read takes the let's value at this statement's
|
|
2600
|
+
* position — Node's snapshot). A NON-alias default whose type had no
|
|
2601
|
+
* registration (collection reported the blocker) re-lowers the
|
|
2602
|
+
* expression so the expression's OWN diagnostic wins when it has one,
|
|
2603
|
+
* then poisons. */
|
|
2325
2604
|
export function lowerDefaultExport(lowerer, stmt) {
|
|
2326
2605
|
const symbol = defaultExportSymbolOf(lowerer, stmt.getSourceFile());
|
|
2327
2606
|
if (symbol && symbol.flags & ts.SymbolFlags.Alias && !lowerer.globalsBySymbol.has(symbol))
|
|
@@ -2335,9 +2614,11 @@ export function lowerDefaultExport(lowerer, stmt) {
|
|
|
2335
2614
|
let inner = stmt.expression;
|
|
2336
2615
|
while (ts.isParenthesizedExpression(inner))
|
|
2337
2616
|
inner = inner.expression;
|
|
2338
|
-
if (ts.isClassExpression(inner) &&
|
|
2617
|
+
if (ts.isClassExpression(inner) &&
|
|
2618
|
+
!isJsSourceFile(stmt.getSourceFile()) &&
|
|
2339
2619
|
inner.typeParameters === undefined &&
|
|
2340
|
-
(decoratorNodesOf(inner).length > 0 ||
|
|
2620
|
+
(decoratorNodesOf(inner).length > 0 ||
|
|
2621
|
+
inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
|
|
2341
2622
|
guaranteedDecorationThrow(lowerer, inner) !== null) {
|
|
2342
2623
|
return { kind: "exprStmt", expr: lowerer.lowerExpr(stmt.expression), loc: locOf(stmt) };
|
|
2343
2624
|
}
|
|
@@ -2349,19 +2630,19 @@ export function lowerDefaultExport(lowerer, stmt) {
|
|
|
2349
2630
|
return { kind: "assign", localId: g.id, value, loc: locOf(stmt) };
|
|
2350
2631
|
}
|
|
2351
2632
|
/** 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
|
-
|
|
2633
|
+
* Node module body: non-entry inits open with a guard flag test (already
|
|
2634
|
+
* ran → return) and set the flag before anything else, so every caller —
|
|
2635
|
+
* hoisted import headers, inline require statements, diamonds, cache-hit
|
|
2636
|
+
* re-requires — gets Node's module-cache semantics from the same call.
|
|
2637
|
+
* After the guard comes the file's HOISTED module-edge header: one
|
|
2638
|
+
* guarded %init call per imported user module and the island loads for
|
|
2639
|
+
* npm imports, in import order (Node evaluates every imported module
|
|
2640
|
+
* before the importer's body — depth-first postorder falls out of the
|
|
2641
|
+
* nesting). CommonJS requires are NOT in the header: Node runs them at
|
|
2642
|
+
* their statements, so the statement lowering emits their %init calls
|
|
2643
|
+
* inline in the body. JSON-import bindings (pure data) load next; then
|
|
2644
|
+
* the body. Top-level var statements assign the pre-registered globals
|
|
2645
|
+
* instead of declaring locals. */
|
|
2365
2646
|
export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
2366
2647
|
const isAsync = lowerer.asyncInitFiles.has(sf);
|
|
2367
2648
|
const ctx = newFnCtx(false, null, null, VOID);
|
|
@@ -2519,8 +2800,16 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2519
2800
|
// that evaluates them. MIXIN instantiations join by their CALL
|
|
2520
2801
|
// SITE's position instead (below) — their inner class node may
|
|
2521
2802
|
// even live in another file.
|
|
2522
|
-
c.decl &&
|
|
2523
|
-
|
|
2803
|
+
c.decl &&
|
|
2804
|
+
ts.isClassDeclaration(c.decl) &&
|
|
2805
|
+
!c.mixinInstance &&
|
|
2806
|
+
c.decl.getSourceFile() === sf &&
|
|
2807
|
+
(c.callableBase !== undefined ||
|
|
2808
|
+
c.def.baseValueGlobal !== undefined ||
|
|
2809
|
+
c.runtimeStatics !== undefined ||
|
|
2810
|
+
c.staticFields.length > 0 ||
|
|
2811
|
+
(c.staticBlocks?.length ?? 0) > 0 ||
|
|
2812
|
+
c.classDecorators !== undefined))
|
|
2524
2813
|
.map((c) => ({ pos: c.decl.getStart(), info: c }));
|
|
2525
2814
|
// Statics-bearing MIXIN instantiations whose call evaluates in THIS
|
|
2526
2815
|
// file: their declaration-time code runs when the call does — the
|
|
@@ -2581,12 +2870,14 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2581
2870
|
loc: loc0,
|
|
2582
2871
|
},
|
|
2583
2872
|
...(guardId !== undefined
|
|
2584
|
-
? [
|
|
2873
|
+
? [
|
|
2874
|
+
{
|
|
2585
2875
|
kind: "assign",
|
|
2586
2876
|
localId: guardId,
|
|
2587
2877
|
value: { kind: "boolLit", value: false, type: BOOL, loc: loc0 },
|
|
2588
2878
|
loc: loc0,
|
|
2589
|
-
}
|
|
2879
|
+
},
|
|
2880
|
+
]
|
|
2590
2881
|
: []),
|
|
2591
2882
|
{ kind: "rethrow", localId: catchLocal.id, loc: loc0 },
|
|
2592
2883
|
],
|
|
@@ -2615,15 +2906,15 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2615
2906
|
}
|
|
2616
2907
|
}
|
|
2617
2908
|
/** %main is just the entry's %init call: Node's whole module evaluation
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2909
|
+
* order lives in the init functions themselves — each file's hoisted
|
|
2910
|
+
* import header runs its dependencies first (depth-first postorder by
|
|
2911
|
+
* nesting), CommonJS require statements call dependency inits inline in
|
|
2912
|
+
* their bodies, and the run-once guards turn every revisit (diamonds,
|
|
2913
|
+
* re-imports, re-requires) into a cache hit. */
|
|
2623
2914
|
export function buildMain(lowerer) {
|
|
2624
2915
|
const loc = { file: lowerer.entry.fileName, start: 0, end: 0 };
|
|
2625
2916
|
const body = [...cjsModuleRegistryPrelude(lowerer, loc)];
|
|
2626
|
-
const roots = [lowerer.entry, ...lowerer.forkTargets];
|
|
2917
|
+
const roots = [lowerer.entry, ...lowerer.forkTargets, ...lowerer.workerTargets];
|
|
2627
2918
|
const isAsync = roots.some((root) => lowerer.asyncInitFiles.has(root));
|
|
2628
2919
|
const callRoot = (root) => {
|
|
2629
2920
|
const init = lowerer.initNameOf.get(root);
|
|
@@ -2637,11 +2928,13 @@ export function buildMain(lowerer) {
|
|
|
2637
2928
|
type: rootAsync ? { kind: "promise", inner: VOID } : VOID,
|
|
2638
2929
|
loc,
|
|
2639
2930
|
};
|
|
2640
|
-
return [
|
|
2931
|
+
return [
|
|
2932
|
+
{
|
|
2641
2933
|
kind: "exprStmt",
|
|
2642
2934
|
expr: rootAsync ? { kind: "awaitExpr", value: call, type: VOID, loc } : call,
|
|
2643
2935
|
loc,
|
|
2644
|
-
}
|
|
2936
|
+
},
|
|
2937
|
+
];
|
|
2645
2938
|
};
|
|
2646
2939
|
const locals = [];
|
|
2647
2940
|
if (lowerer.forkTargets.length === 0) {
|
|
@@ -2665,7 +2958,8 @@ export function buildMain(lowerer) {
|
|
|
2665
2958
|
const selector = () => ({ kind: "varRef", localId: targetId, type: F64, loc });
|
|
2666
2959
|
let workerBranch = null;
|
|
2667
2960
|
for (let id = lowerer.forkTargets.length - 1; id >= 0; id--) {
|
|
2668
|
-
workerBranch = [
|
|
2961
|
+
workerBranch = [
|
|
2962
|
+
{
|
|
2669
2963
|
kind: "if",
|
|
2670
2964
|
cond: {
|
|
2671
2965
|
kind: "bin",
|
|
@@ -2678,7 +2972,8 @@ export function buildMain(lowerer) {
|
|
|
2678
2972
|
then: callRoot(lowerer.forkTargets[id]),
|
|
2679
2973
|
else_: workerBranch,
|
|
2680
2974
|
loc,
|
|
2681
|
-
}
|
|
2975
|
+
},
|
|
2976
|
+
];
|
|
2682
2977
|
}
|
|
2683
2978
|
body.push({
|
|
2684
2979
|
kind: "if",
|
|
@@ -2695,6 +2990,35 @@ export function buildMain(lowerer) {
|
|
|
2695
2990
|
loc,
|
|
2696
2991
|
});
|
|
2697
2992
|
}
|
|
2993
|
+
if (lowerer.workerTargets.length > 0) {
|
|
2994
|
+
const mainBody = body.splice(0);
|
|
2995
|
+
let workerBody = null;
|
|
2996
|
+
for (let id = lowerer.workerTargets.length - 1; id >= 0; id--) {
|
|
2997
|
+
workerBody = [
|
|
2998
|
+
{
|
|
2999
|
+
kind: "if",
|
|
3000
|
+
cond: {
|
|
3001
|
+
kind: "bin",
|
|
3002
|
+
op: "===",
|
|
3003
|
+
left: { kind: "libCall", fn: "worker.root", args: [], type: F64, loc },
|
|
3004
|
+
right: { kind: "numLit", value: id, type: F64, loc },
|
|
3005
|
+
type: BOOL,
|
|
3006
|
+
loc,
|
|
3007
|
+
},
|
|
3008
|
+
then: callRoot(lowerer.workerTargets[id]),
|
|
3009
|
+
else_: workerBody,
|
|
3010
|
+
loc,
|
|
3011
|
+
},
|
|
3012
|
+
];
|
|
3013
|
+
}
|
|
3014
|
+
body.push({
|
|
3015
|
+
kind: "if",
|
|
3016
|
+
cond: { kind: "libCall", fn: "worker.isMainThread", args: [], type: BOOL, loc },
|
|
3017
|
+
then: mainBody,
|
|
3018
|
+
else_: [...cjsModuleRegistryPrelude(lowerer, loc), ...(workerBody ?? [])],
|
|
3019
|
+
loc,
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
2698
3022
|
// Node's startup refusal (a resolution the graph carries that Node
|
|
2699
3023
|
// rejects — preflight's Node-order resolution walk — or a module-LINK
|
|
2700
3024
|
// SyntaxError from either named-import checker): the graph is refused
|
|
@@ -2710,7 +3034,9 @@ export function buildMain(lowerer) {
|
|
|
2710
3034
|
value: {
|
|
2711
3035
|
kind: "libCall",
|
|
2712
3036
|
fn: "error.new",
|
|
2713
|
-
args: [
|
|
3037
|
+
args: [
|
|
3038
|
+
{ kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc },
|
|
3039
|
+
],
|
|
2714
3040
|
type: { kind: "object", className: lowerer.startupCrash.className },
|
|
2715
3041
|
loc: crashLoc,
|
|
2716
3042
|
},
|