@scriptc/compiler 0.3.6 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +717 -55
- package/ambient/scriptc.d.ts +134 -0
- package/dist/backend/cycle-analysis.d.ts +1 -1
- package/dist/backend/cycle-analysis.js +1 -0
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +13 -1
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.js +16 -5
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.js +20 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.test.js +1 -1
- package/dist/backend/library-pack.js +9 -0
- 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 +2 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +1 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +41 -4
- package/dist/backend/llvm/alloc.js +138 -7
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +30 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.test.js +1 -1
- package/dist/backend/llvm/array-search.js +3 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/array-search.test.js +1 -1
- package/dist/backend/llvm/blocks.d.ts +8 -0
- package/dist/backend/llvm/blocks.js +43 -1
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.js +22 -1
- package/dist/backend/llvm/blocks.test.js.map +1 -1
- package/dist/backend/llvm/byte-numbers.js +15 -5
- package/dist/backend/llvm/byte-numbers.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.d.ts +14 -0
- package/dist/backend/llvm/bytes-alias.js +20 -0
- package/dist/backend/llvm/bytes-alias.js.map +1 -0
- package/dist/backend/llvm/bytes-loop-versions.d.ts +86 -0
- package/dist/backend/llvm/bytes-loop-versions.js +506 -0
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -0
- package/dist/backend/llvm/bytes-loop-versions.test.d.ts +1 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js +244 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.js +50 -1
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +34 -0
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +4 -1
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +38 -1
- package/dist/backend/llvm/classes.js +185 -35
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +79 -17
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +21 -3
- package/dist/backend/llvm/common.js +51 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +5 -1
- package/dist/backend/llvm/constant-callbacks.js +55 -12
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +88 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/counted-loops.d.ts +4 -0
- package/dist/backend/llvm/counted-loops.js +37 -0
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +15 -4
- package/dist/backend/llvm/dense-array-access.js +125 -44
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +63 -3
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.d.ts +51 -0
- package/dist/backend/llvm/dense-array-loops.js +162 -0
- package/dist/backend/llvm/dense-array-loops.js.map +1 -0
- package/dist/backend/llvm/dense-array-loops.test.d.ts +1 -0
- package/dist/backend/llvm/dense-array-loops.test.js +128 -0
- package/dist/backend/llvm/dense-array-loops.test.js.map +1 -0
- package/dist/backend/llvm/dyn-handle-tags.test.d.ts +1 -0
- package/dist/backend/llvm/dyn-handle-tags.test.js +38 -0
- package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +37 -4
- package/dist/backend/llvm/dyn.js +354 -183
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.d.ts +64 -0
- package/dist/backend/llvm/emit-function.js +1193 -0
- package/dist/backend/llvm/emit-function.js.map +1 -0
- package/dist/backend/llvm/emit-module.d.ts +24 -0
- package/dist/backend/llvm/emit-module.js +1557 -0
- package/dist/backend/llvm/emit-module.js.map +1 -0
- package/dist/backend/llvm/emit-statements.d.ts +59 -0
- package/dist/backend/llvm/emit-statements.js +2041 -0
- package/dist/backend/llvm/emit-statements.js.map +1 -0
- package/dist/backend/llvm/emitter.d.ts +566 -291
- package/dist/backend/llvm/emitter.js +728 -4671
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +57 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +73 -46
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +2 -0
- package/dist/backend/llvm/expr-bytes.js +76 -29
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +6 -2
- package/dist/backend/llvm/expr-callbacks.js +48 -11
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +1 -1
- package/dist/backend/llvm/expr-calls.js +87 -56
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-calls.test.js +1 -1
- package/dist/backend/llvm/expr-containers.js +45 -24
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +16 -16
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +3 -0
- package/dist/backend/llvm/expr-dynamic.js +113 -66
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +124 -28
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +57 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +32 -11
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +65 -27
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +2 -2
- package/dist/backend/llvm/expr-stream-callbacks.js +22 -1
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/int32-abi.test.js +2 -2
- package/dist/backend/llvm/integer-clones.js +3 -3
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/integer-clones.test.js +3 -3
- package/dist/backend/llvm/integer-remainder.d.ts +34 -13
- package/dist/backend/llvm/integer-remainder.js +156 -22
- package/dist/backend/llvm/integer-remainder.js.map +1 -1
- package/dist/backend/llvm/intern-tables.test.js +1 -1
- package/dist/backend/llvm/js-ic.d.ts +18 -0
- package/dist/backend/llvm/js-ic.js +712 -0
- package/dist/backend/llvm/js-ic.js.map +1 -0
- package/dist/backend/llvm/jsval-encoding.d.ts +21 -0
- package/dist/backend/llvm/jsval-encoding.js +20 -0
- package/dist/backend/llvm/jsval-encoding.js.map +1 -0
- package/dist/backend/llvm/jsval.d.ts +12 -0
- package/dist/backend/llvm/jsval.js +616 -0
- package/dist/backend/llvm/jsval.js.map +1 -0
- package/dist/backend/llvm/lazy-captures.d.ts +12 -2
- package/dist/backend/llvm/lazy-captures.js +39 -17
- package/dist/backend/llvm/lazy-captures.js.map +1 -1
- package/dist/backend/llvm/lib-abi.js +1 -1
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-connect.js +1 -1
- package/dist/backend/llvm/lib-connect.js.map +1 -1
- package/dist/backend/llvm/lib-datagram.js +14 -8
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +189 -23
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +42 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +3 -3
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +2 -2
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +56 -22
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +94 -53
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.d.ts +12 -0
- package/dist/backend/llvm/lib-shared.js +209 -6
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +46 -16
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +43 -7
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/lib-tls.js +4 -9
- package/dist/backend/llvm/lib-tls.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +42 -33
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-extents.d.ts +19 -0
- package/dist/backend/llvm/local-extents.js +169 -0
- package/dist/backend/llvm/local-extents.js.map +1 -0
- package/dist/backend/llvm/local-extents.test.d.ts +1 -0
- package/dist/backend/llvm/local-extents.test.js +92 -0
- package/dist/backend/llvm/local-extents.test.js.map +1 -0
- package/dist/backend/llvm/local-union-storage.js +7 -7
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +2 -2
- package/dist/backend/llvm/map-entry-fusion.test.js +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -4
- package/dist/backend/llvm/map-number-lookup.js +45 -9
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +2 -2
- package/dist/backend/llvm/map-read-lifetimes.test.js +2 -2
- package/dist/backend/llvm/narrow-guards.d.ts +38 -0
- package/dist/backend/llvm/narrow-guards.js +215 -0
- package/dist/backend/llvm/narrow-guards.js.map +1 -0
- package/dist/backend/llvm/nullable-unions.d.ts +64 -6
- package/dist/backend/llvm/nullable-unions.js +103 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.d.ts +1 -0
- package/dist/backend/llvm/nullable-unions.test.js +65 -0
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -0
- package/dist/backend/llvm/publish.d.ts +7 -0
- package/dist/backend/llvm/publish.js +50 -19
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/publish.test.js +1 -1
- package/dist/backend/llvm/receivers.d.ts +31 -0
- package/dist/backend/llvm/receivers.js +395 -0
- package/dist/backend/llvm/receivers.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +12 -1
- package/dist/backend/llvm/record-results.js +64 -4
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +9 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +4 -0
- package/dist/backend/llvm/reference-writes.js +142 -6
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/reference-writes.test.d.ts +1 -0
- package/dist/backend/llvm/reference-writes.test.js +88 -0
- package/dist/backend/llvm/reference-writes.test.js.map +1 -0
- package/dist/backend/llvm/regex-matchers.d.ts +8 -0
- package/dist/backend/llvm/regex-matchers.js +33 -0
- package/dist/backend/llvm/regex-matchers.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.test.js +23 -1
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -1
- package/dist/backend/llvm/regions.d.ts +1 -1
- package/dist/backend/llvm/regions.js +10 -7
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/regions.test.js +8 -2
- package/dist/backend/llvm/regions.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +74 -45
- package/dist/backend/llvm/shapes.js +289 -28
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +37 -3
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +20 -1
- package/dist/backend/llvm/speculative-integers.js +94 -6
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.test.js +55 -1
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.js +2 -2
- package/dist/backend/llvm/split-loops.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +26 -6
- package/dist/backend/llvm/stack-objects.js +133 -10
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/stack-objects.test.js +55 -1
- package/dist/backend/llvm/stack-objects.test.js.map +1 -1
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +15 -14
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +4 -4
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/string-slices.d.ts +25 -0
- package/dist/backend/llvm/string-slices.js +207 -1
- package/dist/backend/llvm/string-slices.js.map +1 -1
- package/dist/backend/llvm/string-slices.test.js +139 -2
- package/dist/backend/llvm/string-slices.test.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +2 -2
- package/dist/backend/llvm/thread-slots.d.ts +5 -0
- package/dist/backend/llvm/thread-slots.js +142 -0
- package/dist/backend/llvm/thread-slots.js.map +1 -0
- package/dist/backend/llvm/thread-slots.test.d.ts +1 -0
- package/dist/backend/llvm/thread-slots.test.js +111 -0
- package/dist/backend/llvm/thread-slots.test.js.map +1 -0
- package/dist/backend/llvm/union-repr.d.ts +7 -7
- package/dist/backend/llvm/union-repr.js +18 -2
- package/dist/backend/llvm/union-repr.js.map +1 -1
- package/dist/backend/llvm/union-retype.test.js +17 -3
- package/dist/backend/llvm/union-retype.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -2
- package/dist/backend/llvm/walkers.js +51 -26
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wasm-modules.d.ts +16 -0
- package/dist/backend/llvm/wasm-modules.js +66 -0
- package/dist/backend/llvm/wasm-modules.js.map +1 -0
- package/dist/backend/llvm/wrapping-sums.d.ts +7 -0
- package/dist/backend/llvm/wrapping-sums.js +11 -3
- package/dist/backend/llvm/wrapping-sums.js.map +1 -1
- package/dist/backend/mangle.d.ts +12 -0
- package/dist/backend/mangle.js +18 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.d.ts +3 -0
- package/dist/backend/may-throw.js +4 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +1 -1
- package/dist/backend/native/contracts.d.ts +57 -0
- package/dist/backend/native/executable.js +211 -139
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +2 -0
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +6 -0
- package/dist/backend/native-codegen.js +19 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +27 -0
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +48 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +32 -0
- package/dist/backend/native-profile.js +39 -0
- package/dist/backend/native-profile.js.map +1 -0
- package/dist/backend/native-profile.test.d.ts +1 -0
- package/dist/backend/native-profile.test.js +58 -0
- package/dist/backend/native-profile.test.js.map +1 -0
- package/dist/backend/native-tools.d.ts +14 -0
- package/dist/backend/native-tools.js +13 -0
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/publication.test.js +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 +13 -1
- package/dist/backend/runtime-pack-core.js +14 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.js +1 -1
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.d.ts +1 -0
- package/dist/backend/runtime-pack-native.test.js +31 -0
- package/dist/backend/runtime-pack-native.test.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +9 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +9 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/stack-observations.d.ts +22 -0
- package/dist/backend/stack-observations.js +382 -0
- package/dist/backend/stack-observations.js.map +1 -0
- package/dist/backend/stack-observations.test.d.ts +1 -0
- package/dist/backend/stack-observations.test.js +233 -0
- package/dist/backend/stack-observations.test.js.map +1 -0
- package/dist/backend/target-diagnostics.js +15 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/warm-cache.js +8 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/backend/young-nursery.d.ts +7 -0
- package/dist/backend/young-nursery.js +10 -0
- package/dist/backend/young-nursery.js.map +1 -0
- package/dist/cli/command.js +106 -4
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +2 -0
- package/dist/cli/output-options.js +9 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +21 -1
- package/dist/cli/usage.js +43 -1
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.js +10 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +22 -0
- package/dist/contracts/check.js +25 -8
- package/dist/contracts/check.js.map +1 -1
- package/dist/contracts/int32-elements.d.ts +115 -0
- package/dist/contracts/int32-elements.js +1179 -0
- package/dist/contracts/int32-elements.js.map +1 -0
- package/dist/coverage/report.d.ts +16 -0
- package/dist/coverage/report.js +182 -1
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -3
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +2 -0
- package/dist/coverage/verdict-cache.js +12 -0
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/coverage/verdict-cache.test.js +2 -1
- package/dist/coverage/verdict-cache.test.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +10 -6
- package/dist/diagnostics/diagnostic.js +29 -21
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +39 -2
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/render.d.ts +7 -0
- package/dist/diagnostics/render.js +50 -13
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/diagnostics/render.test.d.ts +1 -0
- package/dist/diagnostics/render.test.js +49 -0
- package/dist/diagnostics/render.test.js.map +1 -0
- package/dist/executable/executable-cache.d.ts +27 -0
- package/dist/executable/executable-cache.js +19 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +12 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +2 -1
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +6 -1
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/arguments-usage.d.ts +8 -0
- package/dist/frontend/arguments-usage.js +98 -0
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/arguments-usage.test.d.ts +1 -0
- package/dist/frontend/arguments-usage.test.js +32 -0
- package/dist/frontend/arguments-usage.test.js.map +1 -0
- package/dist/frontend/builtin-modules.d.ts +16 -2
- package/dist/frontend/builtin-modules.js +40 -7
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/builtin-package-aliases.d.ts +24 -0
- package/dist/frontend/builtin-package-aliases.js +133 -0
- package/dist/frontend/builtin-package-aliases.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
- package/dist/frontend/builtin-package-aliases.test.js +48 -0
- package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
- package/dist/frontend/cjs-syntax.js +52 -51
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/contract-types.d.ts +3 -0
- package/dist/frontend/contract-types.js +36 -7
- package/dist/frontend/contract-types.js.map +1 -1
- package/dist/frontend/dts-paths.d.ts +4 -0
- package/dist/frontend/dts-paths.js +9 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/experimental-import.d.ts +5 -1
- package/dist/frontend/experimental-import.js +26 -7
- package/dist/frontend/experimental-import.js.map +1 -1
- package/dist/frontend/fork-target.js +20 -22
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.js +2 -1
- package/dist/frontend/fork-target.test.js.map +1 -1
- package/dist/frontend/function-completion.js +6 -6
- package/dist/frontend/function-completion.js.map +1 -1
- package/dist/frontend/helper-tokens.js +15 -3
- package/dist/frontend/helper-tokens.js.map +1 -1
- package/dist/frontend/helper-tokens.test.js +7 -1
- package/dist/frontend/helper-tokens.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.js +14 -17
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +3 -0
- package/dist/frontend/input-tracker.js +32 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/lib-contract.js +36 -32
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lib-exports.js +3 -3
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +8 -3
- package/dist/frontend/lowering/array-values.js +60 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/assert-instances.js +4 -4
- package/dist/frontend/lowering/assert-instances.js.map +1 -1
- package/dist/frontend/lowering/assertion-identity.d.ts +12 -0
- package/dist/frontend/lowering/assertion-identity.js +70 -0
- package/dist/frontend/lowering/assertion-identity.js.map +1 -0
- package/dist/frontend/lowering/assertion-members.d.ts +28 -0
- package/dist/frontend/lowering/assertion-members.js +185 -0
- package/dist/frontend/lowering/assertion-members.js.map +1 -0
- package/dist/frontend/lowering/binding-analysis.js +27 -20
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.js +63 -5
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-function-fences.d.ts +14 -0
- package/dist/frontend/lowering/builtin-function-fences.js +42 -0
- package/dist/frontend/lowering/builtin-function-fences.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.js +1 -1
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/async-context.js +53 -52
- package/dist/frontend/lowering/builtins/async-context.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.js +6 -6
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/blob.js +8 -6
- package/dist/frontend/lowering/builtins/blob.js.map +1 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.d.ts +31 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js +205 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js +17 -5
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-async.js +7 -7
- package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +6 -4
- package/dist/frontend/lowering/builtins/child-process-methods.js +310 -57
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js +16 -10
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +6 -4
- package/dist/frontend/lowering/builtins/child-process.js +85 -61
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/class-values.d.ts +60 -0
- package/dist/frontend/lowering/builtins/class-values.js +226 -0
- package/dist/frontend/lowering/builtins/class-values.js.map +1 -0
- package/dist/frontend/lowering/builtins/compression.d.ts +9 -0
- package/dist/frontend/lowering/builtins/compression.js +107 -44
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.d.ts +9 -1
- package/dist/frontend/lowering/builtins/constants.js +28 -7
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +22 -0
- package/dist/frontend/lowering/builtins/crypto.js +215 -38
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +7 -1
- package/dist/frontend/lowering/builtins/dates.js +92 -16
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/disposable-stack.d.ts +18 -0
- package/dist/frontend/lowering/builtins/disposable-stack.js +137 -0
- package/dist/frontend/lowering/builtins/disposable-stack.js.map +1 -0
- package/dist/frontend/lowering/builtins/ecdh.d.ts +10 -0
- package/dist/frontend/lowering/builtins/ecdh.js +208 -0
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
- package/dist/frontend/lowering/builtins/environment.js +3 -3
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.d.ts +14 -10
- package/dist/frontend/lowering/builtins/errors.js +169 -3
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js +128 -116
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.js +77 -77
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-glob.js +3 -3
- package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-streams.js +10 -11
- package/dist/frontend/lowering/builtins/fs-streams.js.map +1 -1
- package/dist/frontend/lowering/builtins/ipc.js +45 -8
- package/dist/frontend/lowering/builtins/ipc.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +284 -24
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/key-object.js +4 -4
- package/dist/frontend/lowering/builtins/key-object.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +71 -22
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +55 -44
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +4 -3
- package/dist/frontend/lowering/builtins/module-resolution.js +24 -23
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/navigator.d.ts +13 -0
- package/dist/frontend/lowering/builtins/navigator.js +40 -0
- package/dist/frontend/lowering/builtins/navigator.js.map +1 -0
- package/dist/frontend/lowering/builtins/net-address.d.ts +19 -0
- package/dist/frontend/lowering/builtins/net-address.js +156 -0
- package/dist/frontend/lowering/builtins/net-address.js.map +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +25 -9
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +4 -0
- package/dist/frontend/lowering/builtins/operating-system.js +25 -12
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.d.ts +12 -0
- package/dist/frontend/lowering/builtins/performance.js +259 -8
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +41 -1
- package/dist/frontend/lowering/builtins/process.js +505 -99
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.d.ts +5 -1
- package/dist/frontend/lowering/builtins/promises.js +326 -43
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.d.ts +40 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js +338 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -0
- package/dist/frontend/lowering/builtins/properties.js +37 -1
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.js +14 -14
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +12 -2
- package/dist/frontend/lowering/builtins/readline.js +136 -39
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/receiver-types.js +3 -5
- package/dist/frontend/lowering/builtins/receiver-types.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +42 -14
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/runtime-constructor.d.ts +26 -0
- package/dist/frontend/lowering/builtins/runtime-constructor.js +165 -0
- package/dist/frontend/lowering/builtins/runtime-constructor.js.map +1 -0
- package/dist/frontend/lowering/builtins/strings.js +101 -12
- package/dist/frontend/lowering/builtins/strings.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +41 -38
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/timers.js +79 -30
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
- package/dist/frontend/lowering/builtins/url.d.ts +3 -0
- package/dist/frontend/lowering/builtins/url.js +120 -17
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/util-types.js +20 -4
- package/dist/frontend/lowering/builtins/util-types.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +11 -0
- package/dist/frontend/lowering/builtins/v8.js +105 -0
- package/dist/frontend/lowering/builtins/v8.js.map +1 -0
- package/dist/frontend/lowering/builtins/webassembly.d.ts +33 -0
- package/dist/frontend/lowering/builtins/webassembly.js +388 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -0
- package/dist/frontend/lowering/builtins/webcrypto.d.ts +20 -0
- package/dist/frontend/lowering/builtins/webcrypto.js +112 -0
- package/dist/frontend/lowering/builtins/webcrypto.js.map +1 -0
- package/dist/frontend/lowering/builtins/workers.d.ts +12 -0
- package/dist/frontend/lowering/builtins/workers.js +193 -8
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +69 -14
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +23 -1
- package/dist/frontend/lowering/call-signatures.js +379 -55
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.d.ts +3 -0
- package/dist/frontend/lowering/checked-promise-all.js +1 -1
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +53 -0
- package/dist/frontend/lowering/cjs-exports-object.js +561 -0
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -0
- package/dist/frontend/lowering/cjs-inline-require.d.ts +86 -0
- package/dist/frontend/lowering/cjs-inline-require.js +314 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -0
- package/dist/frontend/lowering/cjs-tsc-interop.d.ts +28 -0
- package/dist/frontend/lowering/cjs-tsc-interop.js +208 -0
- package/dist/frontend/lowering/cjs-tsc-interop.js.map +1 -0
- package/dist/frontend/lowering/class-attributes.d.ts +19 -0
- package/dist/frontend/lowering/class-attributes.js +378 -0
- package/dist/frontend/lowering/class-attributes.js.map +1 -0
- package/dist/frontend/lowering/class-callbacks.d.ts +3 -1
- package/dist/frontend/lowering/class-callbacks.js +21 -10
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-construction.js +49 -4
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-descriptors.d.ts +2 -0
- package/dist/frontend/lowering/class-descriptors.js +8 -8
- package/dist/frontend/lowering/class-descriptors.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +64 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1124 -90
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-instance-constructor.js +1 -1
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -1
- package/dist/frontend/lowering/class-iterables.d.ts +11 -0
- package/dist/frontend/lowering/class-iterables.js +31 -0
- package/dist/frontend/lowering/class-iterables.js.map +1 -0
- package/dist/frontend/lowering/class-method-mutations.js +73 -35
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-method-values.js +56 -10
- package/dist/frontend/lowering/class-method-values.js.map +1 -1
- package/dist/frontend/lowering/class-protocol-dispatch.js +24 -22
- package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +10 -0
- package/dist/frontend/lowering/class-protocols.js +76 -45
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.d.ts +6 -0
- package/dist/frontend/lowering/class-prototypes.js +86 -19
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.js +1 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-static-data.js +2 -2
- package/dist/frontend/lowering/class-static-data.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +25 -0
- package/dist/frontend/lowering/class-to-primitive.js +264 -0
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -0
- package/dist/frontend/lowering/class-unions.d.ts +25 -0
- package/dist/frontend/lowering/class-unions.js +102 -1
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/code-generation.d.ts +14 -0
- package/dist/frontend/lowering/code-generation.js +127 -0
- package/dist/frontend/lowering/code-generation.js.map +1 -0
- package/dist/frontend/lowering/coercions/fresh-spread.d.ts +13 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +16 -2
- package/dist/frontend/lowering/coercions/function-adapters.js +239 -68
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +25 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +35 -3
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +15 -0
- package/dist/frontend/lowering/coercions/unions.js +57 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/collection-ingestion.js +2 -2
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/collection-narrowing.js +2 -4
- package/dist/frontend/lowering/collection-narrowing.js.map +1 -1
- package/dist/frontend/lowering/construction-escapes.js +8 -8
- package/dist/frontend/lowering/construction-escapes.js.map +1 -1
- package/dist/frontend/lowering/construction-escapes.test.js +4 -4
- package/dist/frontend/lowering/construction-escapes.test.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +61 -0
- package/dist/frontend/lowering/constructor-returns.js +477 -0
- package/dist/frontend/lowering/constructor-returns.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callback-call.js +1 -1
- package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +17 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +287 -118
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.js +1 -1
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.d.ts +0 -1
- package/dist/frontend/lowering/containers/array-construction.js +58 -13
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.d.ts +6 -5
- package/dist/frontend/lowering/containers/array-from-async.js +159 -14
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +94 -77
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +1 -0
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +9 -0
- package/dist/frontend/lowering/containers/bytes.js +649 -113
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +9 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +55 -5
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.d.ts +7 -8
- package/dist/frontend/lowering/containers/collection-grouping.js +217 -26
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +126 -28
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/dynamic-receivers.js +1 -1
- package/dist/frontend/lowering/containers/dynamic-receivers.js.map +1 -1
- package/dist/frontend/lowering/containers/exec-result-uses.js +2 -2
- package/dist/frontend/lowering/containers/exec-result-uses.js.map +1 -1
- package/dist/frontend/lowering/containers/for-of.d.ts +6 -0
- package/dist/frontend/lowering/containers/for-of.js +19 -19
- package/dist/frontend/lowering/containers/for-of.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +142 -57
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +53 -4
- package/dist/frontend/lowering/containers/iterator-helpers.js +1581 -462
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/match-row-uses.d.ts +17 -0
- package/dist/frontend/lowering/containers/match-row-uses.js +264 -0
- package/dist/frontend/lowering/containers/match-row-uses.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +14 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +455 -30
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +30 -10
- package/dist/frontend/lowering/cycle-initialization.js +191 -35
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +47 -43
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/devirtualize.d.ts +1 -1
- package/dist/frontend/lowering/devirtualize.js +27 -7
- package/dist/frontend/lowering/devirtualize.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +0 -5
- package/dist/frontend/lowering/divergences.js +62 -125
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/dyn-streams.d.ts +25 -0
- package/dist/frontend/lowering/dyn-streams.js +257 -0
- package/dist/frontend/lowering/dyn-streams.js.map +1 -0
- package/dist/frontend/lowering/error-methods.js +4 -1
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/error-name-order.d.ts +19 -0
- package/dist/frontend/lowering/error-name-order.js +93 -0
- package/dist/frontend/lowering/error-name-order.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +21 -0
- package/dist/frontend/lowering/expressions/array-literals.js +723 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -0
- package/dist/frontend/lowering/expressions/binary.d.ts +35 -0
- package/dist/frontend/lowering/expressions/binary.js +2557 -0
- package/dist/frontend/lowering/expressions/binary.js.map +1 -0
- package/dist/frontend/lowering/expressions/element-access.d.ts +31 -0
- package/dist/frontend/lowering/expressions/element-access.js +1804 -0
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.js +4 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +38 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +160 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -0
- package/dist/frontend/lowering/expressions/identifiers.d.ts +4 -0
- package/dist/frontend/lowering/expressions/identifiers.js +830 -0
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -0
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +52 -0
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +307 -0
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -0
- package/dist/frontend/lowering/expressions/narrowing.d.ts +37 -0
- package/dist/frontend/lowering/expressions/narrowing.js +1337 -0
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -0
- package/dist/frontend/lowering/expressions/native-proxy.js +4 -4
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +45 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -0
- package/dist/frontend/lowering/expressions/object-literals.js +301 -86
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +3 -2
- package/dist/frontend/lowering/expressions/optional-chains.js +103 -17
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +115 -0
- package/dist/frontend/lowering/expressions/property-access.js +3787 -0
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -0
- package/dist/frontend/lowering/expressions/relational.d.ts +28 -0
- package/dist/frontend/lowering/expressions/relational.js +1724 -0
- package/dist/frontend/lowering/expressions/relational.js.map +1 -0
- package/dist/frontend/lowering/expressions/typeof.d.ts +22 -0
- package/dist/frontend/lowering/expressions/typeof.js +551 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -0
- package/dist/frontend/lowering/expressions/union-fields.js +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.d.ts +21 -0
- package/dist/frontend/lowering/expressions/updates.js +780 -0
- package/dist/frontend/lowering/expressions/updates.js.map +1 -0
- package/dist/frontend/lowering/function-context.d.ts +10 -0
- package/dist/frontend/lowering/function-context.js +11 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +52 -28
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.d.ts +25 -0
- package/dist/frontend/lowering/general-streams.js +108 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +191 -1
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +7 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +172 -69
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +43 -0
- package/dist/frontend/lowering/generic-functions.js +593 -118
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +24 -0
- package/dist/frontend/lowering/handle-properties.js +281 -0
- package/dist/frontend/lowering/handle-properties.js.map +1 -0
- package/dist/frontend/lowering/import-meta.js +2 -2
- package/dist/frontend/lowering/import-meta.js.map +1 -1
- package/dist/frontend/lowering/intern-tables.js +10 -9
- package/dist/frontend/lowering/intern-tables.js.map +1 -1
- package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
- package/dist/frontend/lowering/iterable-spelling.js +38 -0
- package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.d.ts +19 -0
- package/dist/frontend/lowering/iterator-adapters.js +331 -3
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/js-class-fields.d.ts +28 -0
- package/dist/frontend/lowering/js-class-fields.js +170 -0
- package/dist/frontend/lowering/js-class-fields.js.map +1 -0
- package/dist/frontend/lowering/js-dynamic-objects.d.ts +15 -0
- package/dist/frontend/lowering/js-dynamic-objects.js +299 -0
- package/dist/frontend/lowering/js-dynamic-objects.js.map +1 -0
- package/dist/frontend/lowering/js-dynamic-objects.test.d.ts +1 -0
- package/dist/frontend/lowering/js-dynamic-objects.test.js +35 -0
- package/dist/frontend/lowering/js-dynamic-objects.test.js.map +1 -0
- package/dist/frontend/lowering/json-require.d.ts +22 -0
- package/dist/frontend/lowering/json-require.js +131 -0
- package/dist/frontend/lowering/json-require.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.d.ts +44 -0
- package/dist/frontend/lowering/key-order-witness.js +641 -0
- package/dist/frontend/lowering/key-order-witness.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.test.d.ts +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js +239 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -0
- package/dist/frontend/lowering/lifetime-regions.js +7 -7
- package/dist/frontend/lowering/lifetime-regions.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +33 -15
- package/dist/frontend/lowering/lower-array-sort.js +117 -21
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +61 -60
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +10 -1
- package/dist/frontend/lowering/lower-async-iteration.js +34 -6
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +5 -0
- package/dist/frontend/lowering/lower-builtin-values.js +33 -3
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +1404 -448
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +54 -3
- package/dist/frontend/lowering/lower-classes.js +1529 -472
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +4 -2
- package/dist/frontend/lowering/lower-comptime.js +111 -13
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-console.js +13 -11
- package/dist/frontend/lowering/lower-console.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +10 -0
- package/dist/frontend/lowering/lower-dgram.js +241 -21
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +113 -14
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +16 -7
- package/dist/frontend/lowering/lower-event-emitter.js +258 -70
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-event-target.js +2 -2
- package/dist/frontend/lowering/lower-event-target.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +17 -13
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +188 -186
- package/dist/frontend/lowering/lower-exprs.js +1509 -12486
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +72 -22
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +6 -0
- package/dist/frontend/lowering/lower-generators.js +39 -20
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.js +5 -1
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +900 -107
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +23 -20
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-mock.d.ts +8 -1
- package/dist/frontend/lowering/lower-mock.js +185 -18
- package/dist/frontend/lowering/lower-mock.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +11 -3
- package/dist/frontend/lowering/lower-modules.js +445 -94
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +6 -0
- package/dist/frontend/lowering/lower-namespaces.js +65 -33
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +16 -0
- package/dist/frontend/lowering/lower-node-module.js +147 -14
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +6 -6
- package/dist/frontend/lowering/lower-server.js +514 -101
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +4 -0
- package/dist/frontend/lowering/lower-stdlib.js +179 -118
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +30 -7
- package/dist/frontend/lowering/lower-stmts.js +1950 -433
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +3 -0
- package/dist/frontend/lowering/lower-stream.js +398 -56
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +3 -0
- package/dist/frontend/lowering/lower-test.js +437 -62
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +96 -32
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +1 -1
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +424 -27
- package/dist/frontend/lowering/lowerer.js +2062 -310
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +10 -4
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/maybe-promise.d.ts +46 -0
- package/dist/frontend/lowering/maybe-promise.js +249 -0
- package/dist/frontend/lowering/maybe-promise.js.map +1 -0
- package/dist/frontend/lowering/module-member-this.d.ts +3 -0
- package/dist/frontend/lowering/module-member-this.js +262 -0
- package/dist/frontend/lowering/module-member-this.js.map +1 -0
- package/dist/frontend/lowering/module-namespace-elements.js +1 -1
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +3 -0
- package/dist/frontend/lowering/nan-coded-reads.js +45 -32
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +18 -3
- package/dist/frontend/lowering/narrowing-stability.js +104 -32
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.js +11 -11
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/object-factory-new.js +6 -8
- package/dist/frontend/lowering/object-factory-new.js.map +1 -1
- package/dist/frontend/lowering/private-brands.d.ts +46 -0
- package/dist/frontend/lowering/private-brands.js +265 -0
- package/dist/frontend/lowering/private-brands.js.map +1 -0
- package/dist/frontend/lowering/promise-executor-adapter.d.ts +11 -0
- package/dist/frontend/lowering/promise-executor-adapter.js +87 -0
- package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -0
- package/dist/frontend/lowering/rebindable-functions.d.ts +8 -0
- package/dist/frontend/lowering/rebindable-functions.js +54 -0
- package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
- package/dist/frontend/lowering/require-initialization.d.ts +32 -0
- package/dist/frontend/lowering/require-initialization.js +246 -0
- package/dist/frontend/lowering/require-initialization.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js +7 -7
- package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-elements.js +12 -12
- package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-guards.js +10 -10
- package/dist/frontend/lowering/runtime-optional-guards.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-guards.test.js +1 -1
- package/dist/frontend/lowering/runtime-optional-guards.test.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-ownership.js +10 -9
- package/dist/frontend/lowering/runtime-optional-ownership.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.js +2 -2
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-records.d.ts +35 -0
- package/dist/frontend/lowering/runtime-optional-records.js +205 -32
- package/dist/frontend/lowering/runtime-optional-records.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-records.test.js +19 -1
- package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/split-consumers.js +4 -4
- package/dist/frontend/lowering/split-consumers.js.map +1 -1
- package/dist/frontend/lowering/static-function-names.d.ts +28 -0
- package/dist/frontend/lowering/static-function-names.js +212 -0
- package/dist/frontend/lowering/static-function-names.js.map +1 -0
- package/dist/frontend/lowering/static-this.js +6 -6
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/static-typeof.d.ts +26 -0
- package/dist/frontend/lowering/static-typeof.js +133 -0
- package/dist/frontend/lowering/static-typeof.js.map +1 -0
- package/dist/frontend/lowering/strict-mode.d.ts +5 -0
- package/dist/frontend/lowering/strict-mode.js +31 -0
- package/dist/frontend/lowering/strict-mode.js.map +1 -0
- package/dist/frontend/lowering/string-index-bounds.js +13 -12
- package/dist/frontend/lowering/string-index-bounds.js.map +1 -1
- package/dist/frontend/lowering/string-index.d.ts +12 -0
- package/dist/frontend/lowering/string-index.js +72 -1
- package/dist/frontend/lowering/string-index.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +12 -3
- package/dist/frontend/lowering/surfaces.js +282 -45
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.d.ts +7 -0
- package/dist/frontend/lowering/symbol-fields.js +204 -36
- package/dist/frontend/lowering/symbol-fields.js.map +1 -1
- package/dist/frontend/lowering/symbol-methods.d.ts +2 -1
- package/dist/frontend/lowering/symbol-methods.js +24 -6
- package/dist/frontend/lowering/symbol-methods.js.map +1 -1
- package/dist/frontend/lowering/thenables.d.ts +16 -0
- package/dist/frontend/lowering/thenables.js +124 -0
- package/dist/frontend/lowering/thenables.js.map +1 -0
- package/dist/frontend/lowering/thread-slots.d.ts +13 -0
- package/dist/frontend/lowering/thread-slots.js +208 -0
- package/dist/frontend/lowering/thread-slots.js.map +1 -0
- package/dist/frontend/lowering/typed-arguments.d.ts +74 -0
- package/dist/frontend/lowering/typed-arguments.js +472 -0
- package/dist/frontend/lowering/typed-arguments.js.map +1 -0
- package/dist/frontend/lowering/union-retag.d.ts +8 -0
- package/dist/frontend/lowering/union-retag.js +27 -0
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +24 -1
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/var-hoisting.js +6 -6
- package/dist/frontend/lowering/var-hoisting.js.map +1 -1
- package/dist/frontend/lowering/width-lift.d.ts +4 -0
- package/dist/frontend/mock-shapes.js +13 -6
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/module-source-candidates.js +1 -1
- package/dist/frontend/module-source-candidates.js.map +1 -1
- package/dist/frontend/module-source-candidates.test.js +2 -1
- package/dist/frontend/module-source-candidates.test.js.map +1 -1
- package/dist/frontend/module-syntax.js +8 -8
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
- package/dist/frontend/npm-static-builtin-aliases.js +65 -0
- package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.d.ts +58 -0
- package/dist/frontend/npm-static-bundled-chunks.js +981 -0
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js +399 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.js +24 -23
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.d.ts +9 -0
- package/dist/frontend/npm-static-bundled-esm.js +988 -0
- package/dist/frontend/npm-static-bundled-esm.js.map +1 -0
- package/dist/frontend/npm-static-bundled-esm.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-esm.test.js +336 -0
- package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -0
- package/dist/frontend/npm-static-cjs-exports-alias.d.ts +2 -0
- package/dist/frontend/npm-static-cjs-exports-alias.js +186 -0
- package/dist/frontend/npm-static-cjs-exports-alias.js.map +1 -0
- package/dist/frontend/npm-static-cjs-exports-alias.test.d.ts +1 -0
- package/dist/frontend/npm-static-cjs-exports-alias.test.js +73 -0
- package/dist/frontend/npm-static-cjs-exports-alias.test.js.map +1 -0
- package/dist/frontend/npm-static-cjs-exports-var.d.ts +2 -0
- package/dist/frontend/npm-static-cjs-exports-var.js +236 -0
- package/dist/frontend/npm-static-cjs-exports-var.js.map +1 -0
- package/dist/frontend/npm-static-declaration-syntax.js +102 -101
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -1
- package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
- package/dist/frontend/npm-static-enum-iife.js +280 -0
- package/dist/frontend/npm-static-enum-iife.js.map +1 -0
- package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
- package/dist/frontend/npm-static-enum-iife.test.js +116 -0
- package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
- package/dist/frontend/npm-static-prune.js +36 -24
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.d.ts +4 -1
- package/dist/frontend/npm-static-rewrite-host.js +14 -3
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +19 -0
- package/dist/frontend/npm-static-rewrite-syntax.js +274 -101
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.js +7 -9
- package/dist/frontend/npm-static-subtyping.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +25 -1
- package/dist/frontend/npm-static.js +212 -16
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +22 -1
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/npm.js +13 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +47 -0
- package/dist/frontend/package-shims.js +300 -0
- package/dist/frontend/package-shims.js.map +1 -0
- package/dist/frontend/pipeline.js +230 -26
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +22 -1
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +6 -1
- package/dist/frontend/program-analysis.js +7 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +100 -2
- package/dist/frontend/program.js +1627 -262
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +76 -6
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.js +49 -2
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +49 -0
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/services.d.ts +26 -1
- package/dist/frontend/services.js +59 -3
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +2 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/threads-import.js +1 -1
- package/dist/frontend/threads-import.js.map +1 -1
- package/dist/frontend/tier-analysis.d.ts +71 -0
- package/dist/frontend/tier-analysis.js +522 -0
- package/dist/frontend/tier-analysis.js.map +1 -0
- package/dist/frontend/ts7/api-conformance.d.ts +234 -0
- package/dist/frontend/ts7/api-conformance.js +7 -0
- package/dist/frontend/ts7/api-conformance.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.js +2 -1
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +47 -25
- package/dist/frontend/ts7/ast-node.js +64 -18
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +36 -12
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-types.d.ts +10 -3
- package/dist/frontend/ts7/ast-types.generated.d.ts +39 -39
- package/dist/frontend/ts7/ast.d.ts +1 -0
- package/dist/frontend/ts7/ast.js +3 -2
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +23 -0
- package/dist/frontend/ts7/checker-backend.js +88 -0
- package/dist/frontend/ts7/checker-backend.js.map +1 -0
- package/dist/frontend/ts7/checker-backend.test.d.ts +1 -0
- package/dist/frontend/ts7/checker-backend.test.js +63 -0
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -0
- package/dist/frontend/ts7/checker-cache.d.ts +0 -3
- package/dist/frontend/ts7/checker-cache.js +0 -6
- package/dist/frontend/ts7/checker-cache.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +18 -11
- package/dist/frontend/ts7/checker.js +42 -55
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +10 -7
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/diagnostic.d.ts +19 -0
- package/dist/frontend/ts7/diagnostic.js +22 -0
- package/dist/frontend/ts7/diagnostic.js.map +1 -0
- package/dist/frontend/ts7/node-functions.d.ts +8 -0
- package/dist/frontend/ts7/node-functions.js +18 -0
- package/dist/frontend/ts7/node-functions.js.map +1 -0
- package/dist/frontend/ts7/program-host.d.ts +10 -5
- package/dist/frontend/ts7/program-host.js +19 -0
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/rpc-api.d.ts +5 -1
- package/dist/frontend/ts7/rpc-api.js +8 -1
- package/dist/frontend/ts7/rpc-api.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.d.ts +13 -6
- package/dist/frontend/ts7/semantic-checker.js +26 -8
- package/dist/frontend/ts7/semantic-checker.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.test.js +12 -9
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +57 -24
- package/dist/frontend/ts7/semantic-model.js +114 -16
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +4 -4
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-types.d.ts +7 -3
- package/dist/frontend/ts7/semantic-types.js +1 -1
- package/dist/frontend/ts7/semantic-types.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +30 -15
- package/dist/frontend/ts7/session.js +8 -5
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/session.test.js +9 -5
- package/dist/frontend/ts7/session.test.js.map +1 -1
- package/dist/frontend/ts7/source-parser.d.ts +6 -2
- package/dist/frontend/ts7/source-parser.js +24 -3
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +38 -17
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +122 -2
- package/dist/frontend/type-mapper.js +2735 -723
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-only-imports.d.ts +28 -0
- package/dist/frontend/type-only-imports.js +122 -0
- package/dist/frontend/type-only-imports.js.map +1 -0
- package/dist/frontend/worker-target.js +8 -8
- package/dist/frontend/worker-target.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +87 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +4 -2
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +31 -0
- package/dist/ir/array-length-stability.js +249 -0
- package/dist/ir/array-length-stability.js.map +1 -0
- package/dist/ir/array-length-stability.test.d.ts +1 -0
- package/dist/ir/array-length-stability.test.js +134 -0
- package/dist/ir/array-length-stability.test.js.map +1 -0
- package/dist/ir/build.d.ts +2 -2
- package/dist/ir/build.js +1 -1
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +116 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +540 -29
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/byte-numbers.js +3 -0
- package/dist/ir/byte-numbers.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +37 -0
- package/dist/ir/callback-specialization.js +459 -0
- package/dist/ir/callback-specialization.js.map +1 -0
- package/dist/ir/callback-specialization.test.d.ts +1 -0
- package/dist/ir/callback-specialization.test.js +208 -0
- package/dist/ir/callback-specialization.test.js.map +1 -0
- package/dist/ir/capture-values.d.ts +0 -1
- package/dist/ir/capture-values.js +51 -40
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/field-values.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/function-references.test.js +9 -1
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +14 -0
- package/dist/ir/int32-slots.js +97 -14
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/integer-loop-facts.d.ts +7 -0
- package/dist/ir/integer-loop-facts.js +103 -17
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +1 -1
- package/dist/ir/integer-loops.js +39 -9
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +104 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +13 -1
- package/dist/ir/integer-ranges.js +125 -26
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +273 -2
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +6 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +221 -58
- package/dist/ir/ir.js +127 -12
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +10 -0
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-ic.d.ts +52 -0
- package/dist/ir/js-ic.js +199 -0
- package/dist/ir/js-ic.js.map +1 -0
- package/dist/ir/js-ic.test.d.ts +1 -0
- package/dist/ir/js-ic.test.js +148 -0
- package/dist/ir/js-ic.test.js.map +1 -0
- package/dist/ir/jsval.d.ts +8 -0
- package/dist/ir/jsval.js +399 -0
- package/dist/ir/jsval.js.map +1 -0
- package/dist/ir/jsval.test.d.ts +1 -0
- package/dist/ir/jsval.test.js +239 -0
- package/dist/ir/jsval.test.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +183 -33
- package/dist/ir/runtime-features.js +795 -422
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/self-captures.d.ts +33 -0
- package/dist/ir/self-captures.js +245 -0
- package/dist/ir/self-captures.js.map +1 -0
- package/dist/ir/self-captures.test.d.ts +1 -0
- package/dist/ir/self-captures.test.js +135 -0
- package/dist/ir/self-captures.test.js.map +1 -0
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +7 -4
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/tiers.d.ts +26 -0
- package/dist/ir/tiers.js +101 -0
- package/dist/ir/tiers.js.map +1 -0
- package/dist/ir/tiers.test.d.ts +1 -0
- package/dist/ir/tiers.test.js +140 -0
- package/dist/ir/tiers.test.js.map +1 -0
- package/dist/ir/traverse.js +201 -150
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/traverse.test.js +33 -30
- package/dist/ir/traverse.test.js.map +1 -1
- package/dist/ir/unshare.js +65 -3
- package/dist/ir/unshare.js.map +1 -1
- package/dist/ir/unshare.test.js +1 -1
- package/dist/ir/validate.js +196 -76
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +41 -11
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/ir-policy.js +14 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +1 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/library-profile.d.ts +4 -4
- package/dist/library/library-profile.js +35 -7
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.js +13 -1
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +22 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +35 -6
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +2 -2
- package/dist/native/executable-cache.js +3 -0
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.js +10 -0
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +19 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.d.ts +2 -0
- package/dist/native/toolchain.js +10 -1
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +39 -1
- package/dist/native/toolchain.test.js.map +1 -1
- package/dist/startup-cache.d.ts +1 -0
- package/dist/startup-cache.js +1 -0
- package/dist/startup-cache.js.map +1 -1
- package/dist/wasm/base64.d.ts +5 -0
- package/dist/wasm/base64.js +62 -0
- package/dist/wasm/base64.js.map +1 -0
- package/dist/wasm/binary.d.ts +36 -0
- package/dist/wasm/binary.js +1976 -0
- package/dist/wasm/binary.js.map +1 -0
- package/dist/wasm/binary.test.d.ts +1 -0
- package/dist/wasm/binary.test.js +190 -0
- package/dist/wasm/binary.test.js.map +1 -0
- package/dist/wasm/discover.d.ts +38 -0
- package/dist/wasm/discover.js +377 -0
- package/dist/wasm/discover.js.map +1 -0
- package/dist/wasm/discover.test.d.ts +1 -0
- package/dist/wasm/discover.test.js +24 -0
- package/dist/wasm/discover.test.js.map +1 -0
- package/dist/wasm/module.d.ts +151 -0
- package/dist/wasm/module.js +575 -0
- package/dist/wasm/module.js.map +1 -0
- package/dist/wasm/translate.d.ts +48 -0
- package/dist/wasm/translate.js +2129 -0
- package/dist/wasm/translate.js.map +1 -0
- package/dist/wasm/translate.test.d.ts +1 -0
- package/dist/wasm/translate.test.js +207 -0
- package/dist/wasm/translate.test.js.map +1 -0
- package/package.json +22 -20
- package/shims/fs-extra/core/api.ts +1192 -0
- package/shims/fs-extra/index.ts +9 -0
- package/shims/undici/core/agent.ts +163 -0
- package/shims/undici/core/api.ts +93 -0
- package/shims/undici/core/client.ts +1304 -0
- package/shims/undici/core/connector.ts +157 -0
- package/shims/undici/core/diagnostics-types.ts +68 -0
- package/shims/undici/core/diagnostics.ts +16 -0
- package/shims/undici/core/dispatcher.ts +574 -0
- package/shims/undici/core/errors-v5.ts +22 -0
- package/shims/undici/core/errors-v7.ts +25 -0
- package/shims/undici/core/errors.ts +255 -0
- package/shims/undici/core/fetch.ts +635 -0
- package/shims/undici/core/pool.ts +280 -0
- package/shims/undici/core/readable.ts +268 -0
- package/shims/undici/core/request.ts +313 -0
- package/shims/undici/core/timers.ts +80 -0
- package/shims/undici/core/types.ts +167 -0
- package/shims/undici/core/util.ts +67 -0
- package/shims/undici/v5.ts +119 -0
- package/shims/undici/v7.ts +119 -0
- package/surface-manifest.json +304 -22
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { isForwardedTupleSpread, lowerForwardingApply } from "./typed-arguments.js";
|
|
1
2
|
import { guardNullProto, nullProtoRecordShape } from "./null-prototype.js";
|
|
3
|
+
import { lowerDynStreamMemberCall } from "./dyn-streams.js";
|
|
4
|
+
import { lowerBuiltinClassCall } from "./builtins/builtin-class-dyn.js";
|
|
5
|
+
import { refuseModuleMemberThis } from "./module-member-this.js";
|
|
2
6
|
import { lowerUnionEquality, tagEqualityMayMissAlias } from "./strict-equality.js";
|
|
3
7
|
import { lowerHashStreamCall } from "./builtins/hash-stream.js";
|
|
8
|
+
import { lowerWebAssemblyValueOf } from "./builtins/webassembly.js";
|
|
9
|
+
import { lowerResponseStaticJson } from "./lower-stdlib.js";
|
|
4
10
|
import { lowerArrayCallbackCall } from "./containers/array-callback-call.js";
|
|
5
11
|
/** Dispatch source calls, builtin members and receiver-specific operations.
|
|
6
12
|
* Signature collection, argument completion and function bodies have their
|
|
@@ -9,20 +15,25 @@ import { dynUndefinedExpr, nodeThrowExpr, countedFor, numLit, varRef } from "../
|
|
|
9
15
|
import { lowerBuiltinCall } from "./builtin-calls.js";
|
|
10
16
|
import { threadsImportOf } from "../threads-import.js";
|
|
11
17
|
import { adaptZeroArgTimerCallback, lowerTimersMemberCall, TIMER_MODULE_MEMBERS, } from "./lower-timers.js";
|
|
18
|
+
import { lowerMockTimersElementCall } from "./lower-test.js";
|
|
12
19
|
import { objectEnumerationReceiver } from "./object-enumeration-receiver.js";
|
|
13
20
|
import { InternalCompilerError } from "../../errors.js";
|
|
14
21
|
import { isFsStreamMember, lowerFsStreamMethodCall } from "./builtins/fs-streams.js";
|
|
15
22
|
import * as ts from "../ts7/adapter.js";
|
|
16
23
|
import { isZlibStreamMember, lowerPromisifiedZlibCall, lowerZlibStreamMethodCall, } from "./builtins/compression.js";
|
|
24
|
+
import { inlineNamespaceRequireOf, lowerInlineRequireValue, lowerUncompiledRequireCall, lowerWithInlineRequireInit, } from "./cjs-inline-require.js";
|
|
25
|
+
import { cjsExportCallIgnoresThis, cjsInFileExportGlobalOf } from "./cjs-exports-object.js";
|
|
17
26
|
import { lowerGenMethodCall } from "./lower-generators.js";
|
|
18
27
|
import { lowerClassSymbolMethodCall } from "./symbol-methods.js";
|
|
28
|
+
import { lowerReadlineDisposeCall } from "./builtins/readline.js";
|
|
19
29
|
import { errorToStringCall } from "./error-methods.js";
|
|
20
30
|
import { lowerClassPrototypeAssign, lowerClassPrototypeDescriptors } from "./class-prototypes.js";
|
|
21
|
-
import { BYTES_ELEMENT_NAME, BIGINT_T, BOOL, CAUGHT, DYN, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
|
|
31
|
+
import { BYTES_ELEMENT_NAME, BIGINT_T, BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, RUNTIME_EMITTER_CLASS, } from "../../ir/ir.js";
|
|
22
32
|
import { lowerProtocolMethodCall } from "./class-protocol-dispatch.js";
|
|
23
33
|
import { isJsSourceFile, locOf, requireSpecOf } from "../program.js";
|
|
34
|
+
import { lowerJsonRequireCall } from "./json-require.js";
|
|
24
35
|
import { lowerAssertInstanceCall } from "./assert-instances.js";
|
|
25
|
-
import { isGenericCallableMemberType, typeKey } from "../type-mapper.js";
|
|
36
|
+
import { isGenericCallableMemberType, isOverloadedCallableMemberType, typeKey, } from "../type-mapper.js";
|
|
26
37
|
import { dynFallbackType, jsFuncNameOf, newFnCtx, staticImportNamespaceType } from "./lowerer.js";
|
|
27
38
|
import { NARROW_FIRST, STRING_INDEX_METHODS, STR_METHODS, UTIL_TYPES_KEYS, stdlibGlobalNameOf, } from "./surfaces.js";
|
|
28
39
|
import { dynStringReceiver } from "./containers/dynamic-receivers.js";
|
|
@@ -30,25 +41,31 @@ import { lowerArrayConstructor, lowerArrayFromCall, lowerArrayOfCall, } from "./
|
|
|
30
41
|
import { lowerArrayFromAsyncCall } from "./containers/array-from-async.js";
|
|
31
42
|
import { lowerDynArrayFilterCall, lowerDynArrayFlatMapCall } from "./containers/array-callbacks.js";
|
|
32
43
|
import { lowerGroupByStaticCall } from "./containers/collection-grouping.js";
|
|
33
|
-
import { lowerIteratorHelperCall } from "./containers/iterator-helpers.js";
|
|
44
|
+
import { lowerGeneratorHelperCall, lowerHelperReturnCall, lowerIteratorFromCall, lowerIteratorHelperCall, } from "./containers/iterator-helpers.js";
|
|
34
45
|
import { lowerObjectAssignIndexShape, lowerObjectConstructor, lowerObjectFromEntriesCall, lowerObjectIterOverIndexShape, } from "./containers/indexed-objects.js";
|
|
35
46
|
import { lowerTupleReadMethodCall } from "./containers/array-methods.js";
|
|
36
47
|
import { tryFuseIndexRead } from "./array-values.js";
|
|
37
48
|
import { lowerBytesStaticCall } from "./containers/bytes.js";
|
|
38
|
-
import { lowerRegexMethodCall, lowerStringIndexCall, lowerStringMethodCall, lowerStringPaddingCall, lowerStringSplitCall, } from "./containers/string-and-regexp.js";
|
|
49
|
+
import { lowerRegexMethodCall, lowerStringIndexCall, lowerStringMethodCall, lowerStringPaddingCall, lowerStringSplitCall, isDynPrimitiveKindMethod, lowerDynPrimitiveMethodCall, lowerExtraNumberMethodCall, } from "./containers/string-and-regexp.js";
|
|
39
50
|
import { createRequireSpecOf } from "./builtins/module-bindings.js";
|
|
40
51
|
import { lowerChildStreamMethodCall, lowerChildWriterMethodCall, } from "./builtins/child-process-methods.js";
|
|
41
52
|
import { lowerCreateRequireCall, lowerImportMetaResolveCall, lowerRequireResolveCall, } from "./builtins/module-resolution.js";
|
|
42
|
-
import { lowerCipherMethodCall, lowerCryptoHashMethodCall } from "./builtins/crypto.js";
|
|
53
|
+
import { isWebCryptoReceiver, lowerCipherMethodCall, lowerCryptoGetRandomValues, lowerCryptoHashMethodCall, lowerPromisifiedCryptoCall, } from "./builtins/crypto.js";
|
|
54
|
+
import { lowerErrorIsErrorCall } from "./builtins/errors.js";
|
|
55
|
+
import { lowerPromisifiedDnsCall } from "./lower-dgram.js";
|
|
56
|
+
import { lowerDisposableStackUseCall } from "./builtins/disposable-stack.js";
|
|
43
57
|
import { lowerDirentMethodCall, lowerFileHandleMethodCall, lowerDirMethodCall, lowerWatcherMethodCall, } from "./builtins/filesystem.js";
|
|
44
|
-
import { fencePerfEntryKeyWalk, isPerfEntryType, lowerPerfHooksCall, perfEntryTag, } from "./builtins/performance.js";
|
|
45
|
-
import { lowerProcStreamMethodCall } from "./builtins/process.js";
|
|
58
|
+
import { fencePerfEntryKeyWalk, isPerfEntryType, lowerHistogramMethodCall, lowerPerfHooksCall, perfEntryTag, } from "./builtins/performance.js";
|
|
59
|
+
import { lowerProcStreamMethodCall, lowerProcessBuiltinModuleNamespace, } from "./builtins/process.js";
|
|
46
60
|
import { recordMayKeepSource, throughRecordSource } from "./record-sources.js";
|
|
47
61
|
import { lowerReflectCall } from "./builtins/reflection.js";
|
|
48
|
-
import { lowerAbsenceProbe, lowerOptionalNumber, lowerPromiseAllTupleCall, lowerPromiseRejectCall, lowerToNumberArgument, stringWrapperToString, symbolFieldInfo, templateRawTextOf, } from "./lower-exprs.js";
|
|
62
|
+
import { lowerAbsenceProbe, v8CalleeText, lowerOptionalNumber, lowerPromiseAllTupleCall, lowerPromiseRejectCall, lowerToNumberArgument, stringWrapperToString, symbolFieldInfo, templateRawTextOf, } from "./lower-exprs.js";
|
|
49
63
|
import { isSafeToDiscard } from "./expressions/evaluation-safety.js";
|
|
50
64
|
import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
65
|
+
import { lowerChildMethodValue, lowerChildPropertyCall } from "./handle-properties.js";
|
|
66
|
+
import { classToNumberConversion } from "./class-to-primitive.js";
|
|
51
67
|
import { hasRuntimeStatics } from "./class-runtime-statics.js";
|
|
68
|
+
import { structuralReadType } from "./class-unions.js";
|
|
52
69
|
import { httpClientFnBindingOf, lowerCompatReqStreamOptionalCall, lowerHttpClientFnCall, } from "./lower-server.js";
|
|
53
70
|
import { EMITTER_API_MEMBERS, exactClassOfReceiver, exactInstanceClassOf, findGenericMethodOn, lowerClassGenericMethodCall, lowerStaticMethodCall, lowerStaticFieldRead, returnsOnlyThis, storedClassValueType, } from "./lower-classes.js";
|
|
54
71
|
import { classCallbackCall, isClassCallback } from "./class-callbacks.js";
|
|
@@ -62,13 +79,17 @@ import { fenceNodeModuleMutationCall, lowerRequireCacheKeys } from "./lower-node
|
|
|
62
79
|
import { defaultAfterUndefined, lowerOptionalArgument, lowerStaticallyUndefinedArgument, positionNumber, } from "./optional-arguments.js";
|
|
63
80
|
import { fenceSymbolFieldCopy } from "./symbol-fields.js";
|
|
64
81
|
import { lowerClassDataDescriptor, lowerClassDescriptorRead } from "./class-descriptors.js";
|
|
82
|
+
import { lowerClassFieldDefine, lowerClassIntegrity } from "./class-attributes.js";
|
|
65
83
|
import { classStaticDataFor } from "./class-static-data.js";
|
|
66
84
|
import { lowerUrlFactory } from "./lower-url.js";
|
|
67
85
|
import { nullishValueUnitOf } from "./binding-analysis.js";
|
|
68
86
|
import { spreadNeedsRuntimeArity, completeFuncValueArgs, lowerSpreadArgsCall, completeArgs, } from "./call-arguments.js";
|
|
69
87
|
import { isThisParameter } from "./call-signatures.js";
|
|
88
|
+
import { lowerStringIteratorValue } from "./iterator-adapters.js";
|
|
70
89
|
import { checkedArmExtraction } from "./coercions/unions.js";
|
|
90
|
+
import { maybePromiseReturnStmt, promiseArmedUnionOf } from "./maybe-promise.js";
|
|
71
91
|
import { requireObjLitGenericReceiver, objLitGenericFnNodeOf, objLitGenericFnInfoOf, genericCallInstance, } from "./generic-functions.js";
|
|
92
|
+
import { codeGenerationCalleeOf, lowerCodeGenerationCall } from "./code-generation.js";
|
|
72
93
|
const ZLIB_STREAM_METHODS = new Set(["flush", "params", "close", "reset"]);
|
|
73
94
|
export function lowerCall(lowerer, expr) {
|
|
74
95
|
const loc = locOf(expr);
|
|
@@ -77,10 +98,46 @@ export function lowerCall(lowerer, expr) {
|
|
|
77
98
|
if (ts.isIdentifier(expr.expression) &&
|
|
78
99
|
expr.expression.text === "Object" &&
|
|
79
100
|
lowerer.isStdlibGlobal(expr.expression, "Object")) {
|
|
80
|
-
const object = lowerObjectConstructor(lowerer, expr.arguments, loc);
|
|
101
|
+
const object = lowerObjectConstructor(lowerer, expr.arguments.nodes, loc);
|
|
81
102
|
if (object)
|
|
82
103
|
return object;
|
|
83
104
|
}
|
|
105
|
+
// `EventEmitter.call(this)` in a constructor function: the untyped
|
|
106
|
+
// EventEmitter constructor initializes the receiver.
|
|
107
|
+
const builtinClassCall = lowerBuiltinClassCall(lowerer, expr);
|
|
108
|
+
if (builtinClassCall)
|
|
109
|
+
return builtinClassCall;
|
|
110
|
+
// require() of a JSON document: the shared parsed object.
|
|
111
|
+
const json = lowerJsonRequireCall(lowerer, expr);
|
|
112
|
+
if (json)
|
|
113
|
+
return json;
|
|
114
|
+
// eval(...) and Function(...): Node's EvalError under
|
|
115
|
+
// --disallow-code-generation-from-strings (code-generation.ts).
|
|
116
|
+
{
|
|
117
|
+
const codeGeneration = codeGenerationCalleeOf(lowerer, expr.expression);
|
|
118
|
+
if (codeGeneration !== null)
|
|
119
|
+
return lowerCodeGenerationCall(lowerer, expr, codeGeneration);
|
|
120
|
+
}
|
|
121
|
+
// Inline require() of a program module (cjs-inline-require.ts): a
|
|
122
|
+
// member call over its export table resolves like a binding's member
|
|
123
|
+
// call after the module's %init at this position; the require itself
|
|
124
|
+
// as a value answers the module's whole-export value.
|
|
125
|
+
if (ts.isPropertyAccessExpression(expr.expression) && !expr.expression.questionDotToken) {
|
|
126
|
+
const req = inlineNamespaceRequireOf(lowerer, expr.expression.expression);
|
|
127
|
+
if (req !== null && !lowerer.inlineRequireInitDone.has(req.call)) {
|
|
128
|
+
// Node calls the member with `this` bound to the module's exports.
|
|
129
|
+
if (ts.isIdentifier(expr.expression.name) &&
|
|
130
|
+
!cjsExportCallIgnoresThis(lowerer, req.dep, expr.expression.name.text)) {
|
|
131
|
+
lowerer.unsupported("SC1090", expr, `calling '${expr.expression.name.text}' through require(${JSON.stringify(req.spec)}) when the function may read 'this' (Node binds it to the module's exports object, which compiles to a static table — bind the module and call a local function instead)`);
|
|
132
|
+
}
|
|
133
|
+
return lowerWithInlineRequireInit(lowerer, req, () => lowerCall(lowerer, expr));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
{
|
|
137
|
+
const inlineValue = lowerInlineRequireValue(lowerer, expr);
|
|
138
|
+
if (inlineValue)
|
|
139
|
+
return inlineValue;
|
|
140
|
+
}
|
|
84
141
|
// A call whose chain ROOTS at an ambient-undefined name (`declare
|
|
85
142
|
// const value: Y | undefined; value?.foo("a")`, `declare function
|
|
86
143
|
// chain...; chain(o).mapValues(f).value()`, a trap binding's read):
|
|
@@ -141,10 +198,21 @@ export function lowerCall(lowerer, expr) {
|
|
|
141
198
|
if (resolved)
|
|
142
199
|
return resolved;
|
|
143
200
|
}
|
|
201
|
+
// Any other require() call of the CommonJS global: MODULE_NOT_FOUND for
|
|
202
|
+
// packages nothing installed resolves, a named refusal otherwise.
|
|
203
|
+
{
|
|
204
|
+
const uncompiled = lowerUncompiledRequireCall(lowerer, expr);
|
|
205
|
+
if (uncompiled)
|
|
206
|
+
return uncompiled;
|
|
207
|
+
}
|
|
144
208
|
// `process.getuid?.()` — intercepted BEFORE the optional-chain
|
|
145
209
|
// machinery (the member always exists on a POSIX target, so the
|
|
146
210
|
// optional call IS the call; `process.getuid` itself has no value
|
|
147
211
|
// lowering for the chain to guard).
|
|
212
|
+
// `h.return!()` / `h.return?.()` on a helper object: the method exists.
|
|
213
|
+
const helperReturn = lowerHelperReturnCall(lowerer, expr);
|
|
214
|
+
if (helperReturn)
|
|
215
|
+
return helperReturn;
|
|
148
216
|
const processOptional = lowerer.lowerProcessOptionalMethodCall(expr);
|
|
149
217
|
if (processOptional)
|
|
150
218
|
return processOptional;
|
|
@@ -189,6 +257,15 @@ export function lowerCall(lowerer, expr) {
|
|
|
189
257
|
}
|
|
190
258
|
return { kind: "libCall", fn: "http2.streamNoop", args: [], type: VOID, loc };
|
|
191
259
|
}
|
|
260
|
+
// `process.getBuiltinModule("node:os")` typed as the module namespace,
|
|
261
|
+
// including pi's cast-and-probe spelling
|
|
262
|
+
// `(process as P).getBuiltinModule?.("node:os")` (the member always
|
|
263
|
+
// exists on Node 24's process object).
|
|
264
|
+
{
|
|
265
|
+
const namespace = lowerProcessBuiltinModuleNamespace(lowerer, expr);
|
|
266
|
+
if (namespace)
|
|
267
|
+
return namespace;
|
|
268
|
+
}
|
|
192
269
|
// Optional-chain call forms: `f?.()` (the token on the call) and
|
|
193
270
|
// `a?.m()` (the token on the member access). The handled markers keep
|
|
194
271
|
// the chain lowering's re-entrant dispatch from looping.
|
|
@@ -281,7 +358,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
281
358
|
if (ts.isIdentifier(expr.expression) &&
|
|
282
359
|
expr.expression.text === "queueMicrotask" &&
|
|
283
360
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
284
|
-
if (expr.arguments.length === 0) {
|
|
361
|
+
if (expr.arguments.nodes.length === 0) {
|
|
285
362
|
// Node: queueMicrotask() throws ERR_INVALID_ARG_TYPE at runtime
|
|
286
363
|
// (the undefined callback) — the Dyn form delivers exactly that.
|
|
287
364
|
return {
|
|
@@ -292,7 +369,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
292
369
|
loc,
|
|
293
370
|
};
|
|
294
371
|
}
|
|
295
|
-
const raw = expr.arguments[0];
|
|
372
|
+
const raw = expr.arguments.nodes[0];
|
|
296
373
|
const cb = lowerer.lowerExpr(raw);
|
|
297
374
|
if (cb.type.kind === "dyn") {
|
|
298
375
|
return { kind: "libCall", fn: "timers.queueMicrotaskDyn", args: [cb], type: VOID, loc };
|
|
@@ -325,11 +402,11 @@ export function lowerCall(lowerer, expr) {
|
|
|
325
402
|
if (ts.isIdentifier(expr.expression) &&
|
|
326
403
|
expr.expression.text === "structuredClone" &&
|
|
327
404
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
328
|
-
if (expr.arguments.length === 0) {
|
|
405
|
+
if (expr.arguments.nodes.length === 0) {
|
|
329
406
|
return { kind: "libCall", fn: "dyn.cloneMissing", args: [], type: DYN, loc };
|
|
330
407
|
}
|
|
331
|
-
if (expr.arguments.length > 2) {
|
|
332
|
-
lowerer.noLowering(`structuredClone with ${expr.arguments.length} arguments`, expr);
|
|
408
|
+
if (expr.arguments.nodes.length > 2) {
|
|
409
|
+
lowerer.noLowering(`structuredClone with ${expr.arguments.nodes.length} arguments`, expr);
|
|
333
410
|
}
|
|
334
411
|
const toDynArg = (a) => {
|
|
335
412
|
if (!a)
|
|
@@ -341,26 +418,26 @@ export function lowerCall(lowerer, expr) {
|
|
|
341
418
|
}
|
|
342
419
|
return conv;
|
|
343
420
|
};
|
|
344
|
-
const valueNode = expr.arguments[0];
|
|
421
|
+
const valueNode = expr.arguments.nodes[0];
|
|
345
422
|
// A NON-EMPTY transfer array of static values: nothing static is
|
|
346
423
|
// transferable, so the call is Node's DataCloneError — decided here
|
|
347
424
|
// (the list's values need no dyn representation to fail). An EMPTY
|
|
348
425
|
// literal transfer list is a no-op member and drops.
|
|
349
426
|
{
|
|
350
|
-
let optNode = expr.arguments[1];
|
|
427
|
+
let optNode = expr.arguments.nodes[1];
|
|
351
428
|
while (optNode && ts.isParenthesizedExpression(optNode))
|
|
352
429
|
optNode = optNode.expression;
|
|
353
430
|
if (optNode && ts.isObjectLiteralExpression(optNode)) {
|
|
354
|
-
const tr = optNode.properties.find((p) => ts.isPropertyAssignment(p) &&
|
|
431
|
+
const tr = optNode.properties.nodes.find((p) => ts.isPropertyAssignment(p) &&
|
|
355
432
|
p.name !== undefined &&
|
|
356
433
|
(ts.isIdentifier(p.name) || ts.isStringLiteral(p.name)) &&
|
|
357
434
|
p.name.text === "transfer");
|
|
358
435
|
if (tr &&
|
|
359
436
|
ts.isArrayLiteralExpression(tr.initializer) &&
|
|
360
|
-
tr.initializer.elements.length > 0) {
|
|
437
|
+
tr.initializer.elements.nodes.length > 0) {
|
|
361
438
|
// An ArrayBuffer first member may be a Buffer pool slab, which
|
|
362
439
|
// Node reports as untransferable.
|
|
363
|
-
const first = tr.initializer.elements[0];
|
|
440
|
+
const first = tr.initializer.elements.nodes[0];
|
|
364
441
|
const firstType = ts.isSpreadElement(first) ? undefined : lowerer.typeOf(first);
|
|
365
442
|
const parts = !firstType
|
|
366
443
|
? []
|
|
@@ -369,7 +446,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
369
446
|
: [firstType];
|
|
370
447
|
const isStorage = parts.length > 0 &&
|
|
371
448
|
parts.every((part) => {
|
|
372
|
-
const name = part.getSymbol()
|
|
449
|
+
const name = ts.symbolNameOf(part.getSymbol());
|
|
373
450
|
return name === "ArrayBuffer" || name === "SharedArrayBuffer";
|
|
374
451
|
});
|
|
375
452
|
if (isStorage) {
|
|
@@ -385,7 +462,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
385
462
|
}
|
|
386
463
|
}
|
|
387
464
|
}
|
|
388
|
-
const optsArg = toDynArg(expr.arguments[1]);
|
|
465
|
+
const optsArg = toDynArg(expr.arguments.nodes[1]);
|
|
389
466
|
// A DOMException value clones through its own runtime arm — the
|
|
390
467
|
// typed result keeps the class (instanceof, .code, throwability).
|
|
391
468
|
const valueT = lowerer.mapTypeOf(lowerer.typeOf(valueNode));
|
|
@@ -409,11 +486,20 @@ export function lowerCall(lowerer, expr) {
|
|
|
409
486
|
};
|
|
410
487
|
// The declared result is the value's own type (the generic's T):
|
|
411
488
|
// validate the dyn copy back into it when the type can be checked;
|
|
412
|
-
// dyn-typed and unmappable results stay dyn values (JS files).
|
|
489
|
+
// dyn-typed and unmappable results stay dyn values (JS files). An
|
|
490
|
+
// empty record (`{}` inferred from a JavaScript `payload = {}`
|
|
491
|
+
// default) is the checker's supertype of whatever arrives, not a
|
|
492
|
+
// layout: checking into it would drop every member of the copy.
|
|
413
493
|
const resultT = lowerer.mapTypeOf(lowerer.typeOf(expr));
|
|
494
|
+
const resultShape = resultT?.kind === "record" ? lowerer.shapes.get(resultT.shapeId) : undefined;
|
|
495
|
+
const emptyRecord = resultShape !== undefined &&
|
|
496
|
+
!resultShape.tuple &&
|
|
497
|
+
resultShape.indexValue === undefined &&
|
|
498
|
+
resultShape.fields.length === 0;
|
|
414
499
|
if (resultT !== null &&
|
|
415
500
|
resultT.kind !== "dyn" &&
|
|
416
501
|
resultT.kind !== "void" &&
|
|
502
|
+
!emptyRecord &&
|
|
417
503
|
canDynCheckTo(resultT, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
418
504
|
return { kind: "dynCheck", value: cloned, type: resultT, loc };
|
|
419
505
|
}
|
|
@@ -438,10 +524,10 @@ export function lowerCall(lowerer, expr) {
|
|
|
438
524
|
// constants ("", false, 0). Wrapper objects stay fenced except where
|
|
439
525
|
// the receiver is immediately converted by a direct String method call.
|
|
440
526
|
if (lowerer.isStdlibGlobal(expr.expression, "BigInt")) {
|
|
441
|
-
if (expr.arguments.length !== 1) {
|
|
442
|
-
lowerer.noLowering(`BigInt with ${expr.arguments.length} arguments`, expr);
|
|
527
|
+
if (expr.arguments.nodes.length !== 1) {
|
|
528
|
+
lowerer.noLowering(`BigInt with ${expr.arguments.nodes.length} arguments`, expr);
|
|
443
529
|
}
|
|
444
|
-
const argNode = expr.arguments[0];
|
|
530
|
+
const argNode = expr.arguments.nodes[0];
|
|
445
531
|
// Captured optional storage can change after TypeScript's guard.
|
|
446
532
|
// BigInt consumes the stored value, including its nullish tag.
|
|
447
533
|
const arg = optionalCallValue(lowerer, argNode) ?? lowerer.lowerExpr(argNode);
|
|
@@ -458,10 +544,10 @@ export function lowerCall(lowerer, expr) {
|
|
|
458
544
|
: lowerer.isStdlibGlobal(expr.expression, "Boolean")
|
|
459
545
|
? "Boolean"
|
|
460
546
|
: "Number";
|
|
461
|
-
if (expr.arguments.length > 1) {
|
|
462
|
-
lowerer.noLowering(`${name} with ${expr.arguments.length} arguments`, expr);
|
|
547
|
+
if (expr.arguments.nodes.length > 1) {
|
|
548
|
+
lowerer.noLowering(`${name} with ${expr.arguments.nodes.length} arguments`, expr);
|
|
463
549
|
}
|
|
464
|
-
const argNode = expr.arguments[0];
|
|
550
|
+
const argNode = expr.arguments.nodes[0];
|
|
465
551
|
if (!argNode) {
|
|
466
552
|
if (name === "String")
|
|
467
553
|
return { kind: "strLit", value: "", type: STRING, loc };
|
|
@@ -516,7 +602,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
516
602
|
(source.type.kind === "dyn" ||
|
|
517
603
|
source.type.kind === "func" ||
|
|
518
604
|
(source.type.kind === "union" &&
|
|
519
|
-
isJsSourceFile(
|
|
605
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr)) &&
|
|
520
606
|
lowerer.dynConvertible(source.type)) ||
|
|
521
607
|
((source.type.kind === "map" || source.type.kind === "set") &&
|
|
522
608
|
lowerer.dynConvertible(source.type)) ||
|
|
@@ -527,8 +613,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
527
613
|
const receiver = varRef(local.id, DYN, loc);
|
|
528
614
|
const key = lowerer.lowerExprExpecting(access.argumentExpression, DYN);
|
|
529
615
|
const callee = { kind: "dynKeyGet", value: receiver, key, type: DYN, loc };
|
|
530
|
-
const args = expr.arguments.map((arg) => lowerer.lowerExprExpecting(ts.isSpreadElement(arg) ? arg.expression : arg, DYN));
|
|
531
|
-
const spreads = expr.arguments.flatMap((arg, index) => ts.isSpreadElement(arg) ? [{ arg: index, what: arg.expression
|
|
616
|
+
const args = expr.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(ts.isSpreadElement(arg) ? arg.expression : arg, DYN));
|
|
617
|
+
const spreads = expr.arguments.nodes.flatMap((arg, index) => ts.isSpreadElement(arg) ? [{ arg: index, what: ts.getTextOfNode(arg.expression) }] : []);
|
|
532
618
|
return {
|
|
533
619
|
kind: "seqExpr",
|
|
534
620
|
stmts: [
|
|
@@ -538,7 +624,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
538
624
|
kind: "dynCall",
|
|
539
625
|
callee,
|
|
540
626
|
receiver,
|
|
541
|
-
calleeName:
|
|
627
|
+
calleeName: ts.getTextOfNode(access),
|
|
542
628
|
args,
|
|
543
629
|
...(spreads.length > 0 ? { spreads } : {}),
|
|
544
630
|
type: DYN,
|
|
@@ -559,7 +645,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
559
645
|
// all (fs.watch, os.cpus, ...) fence with the module-qualified name.
|
|
560
646
|
if (ts.isIdentifier(expr.expression)) {
|
|
561
647
|
if (expr.expression.text === "Array" && lowerer.isStdlibGlobal(expr.expression, "Array")) {
|
|
562
|
-
return lowerArrayConstructor(lowerer, expr, expr.arguments);
|
|
648
|
+
return lowerArrayConstructor(lowerer, expr, expr.arguments.nodes);
|
|
563
649
|
}
|
|
564
650
|
// A call through a compile-time util.promisify projection. execFile
|
|
565
651
|
// keeps its custom result helper; ordinary builtins route through
|
|
@@ -576,6 +662,12 @@ export function lowerCall(lowerer, expr) {
|
|
|
576
662
|
if (projection?.kind === "promisified-zlib") {
|
|
577
663
|
return lowerPromisifiedZlibCall(lowerer, expr, projection.member, loc);
|
|
578
664
|
}
|
|
665
|
+
if (projection?.kind === "promisified-crypto") {
|
|
666
|
+
return lowerPromisifiedCryptoCall(lowerer, expr, projection.member, loc);
|
|
667
|
+
}
|
|
668
|
+
if (projection?.kind === "promisified-dns") {
|
|
669
|
+
return lowerPromisifiedDnsCall(lowerer, expr, projection.member, loc);
|
|
670
|
+
}
|
|
579
671
|
if (projection?.kind === "promisified-builtin") {
|
|
580
672
|
return lowerBuiltinCall(lowerer, expr, { module: projection.module, member: projection.member }, loc);
|
|
581
673
|
}
|
|
@@ -592,9 +684,9 @@ export function lowerCall(lowerer, expr) {
|
|
|
592
684
|
if (threadsImportOf(lowerer.program, expr.expression) === "publish") {
|
|
593
685
|
// @scriptc/threads publish(value): the same value, its graph made
|
|
594
686
|
// immortal and immutable (backend/llvm/publish.ts).
|
|
595
|
-
if (expr.arguments.length !== 1 || ts.isSpreadElement(expr.arguments[0]))
|
|
596
|
-
lowerer.noLowering(`publish with ${expr.arguments.length} arguments`, expr);
|
|
597
|
-
const value = lowerer.lowerExpr(expr.arguments[0]);
|
|
687
|
+
if (expr.arguments.nodes.length !== 1 || ts.isSpreadElement(expr.arguments.nodes[0]))
|
|
688
|
+
lowerer.noLowering(`publish with ${expr.arguments.nodes.length} arguments`, expr);
|
|
689
|
+
const value = lowerer.lowerExpr(expr.arguments.nodes[0]);
|
|
598
690
|
return { kind: "intrinsic", name: "threads.publish", args: [value], type: value.type, loc };
|
|
599
691
|
}
|
|
600
692
|
const bi = lowerer.builtinImportOf(expr.expression);
|
|
@@ -626,10 +718,10 @@ export function lowerCall(lowerer, expr) {
|
|
|
626
718
|
// generic new fence keeps it.
|
|
627
719
|
if (expr.expression.text === "Symbol" &&
|
|
628
720
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
629
|
-
if (expr.arguments.length > 1) {
|
|
630
|
-
lowerer.noLowering(`Symbol with ${expr.arguments.length} arguments`, expr);
|
|
721
|
+
if (expr.arguments.nodes.length > 1) {
|
|
722
|
+
lowerer.noLowering(`Symbol with ${expr.arguments.nodes.length} arguments`, expr);
|
|
631
723
|
}
|
|
632
|
-
const argNode = expr.arguments[0];
|
|
724
|
+
const argNode = expr.arguments.nodes[0];
|
|
633
725
|
// A literal `undefined` argument IS the no-description form
|
|
634
726
|
// (Symbol(undefined).description is undefined, like Symbol()).
|
|
635
727
|
if (!argNode || (ts.isIdentifier(argNode) && argNode.text === "undefined")) {
|
|
@@ -656,7 +748,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
656
748
|
expr.expression.text === "parseFloat" ||
|
|
657
749
|
expr.expression.text === "isFinite") &&
|
|
658
750
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
659
|
-
const parsed = lowerStaticNumberGlobal(lowerer, expr.expression.text, expr, expr.arguments, loc);
|
|
751
|
+
const parsed = lowerStaticNumberGlobal(lowerer, expr.expression.text, expr, expr.arguments.nodes, loc);
|
|
660
752
|
if (parsed !== null)
|
|
661
753
|
return parsed;
|
|
662
754
|
}
|
|
@@ -676,11 +768,11 @@ export function lowerCall(lowerer, expr) {
|
|
|
676
768
|
expr.expression.text === "decodeURIComponent") &&
|
|
677
769
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
678
770
|
const name = expr.expression.text;
|
|
679
|
-
if (expr.arguments.length !== 1) {
|
|
680
|
-
lowerer.noLowering(`${name} with ${expr.arguments.length} argument${expr.arguments.length === 1 ? "" : "s"}`, expr);
|
|
771
|
+
if (expr.arguments.nodes.length !== 1) {
|
|
772
|
+
lowerer.noLowering(`${name} with ${expr.arguments.nodes.length} argument${expr.arguments.nodes.length === 1 ? "" : "s"}`, expr);
|
|
681
773
|
}
|
|
682
774
|
const loc = locOf(expr);
|
|
683
|
-
const argNode = expr.arguments[0];
|
|
775
|
+
const argNode = expr.arguments.nodes[0];
|
|
684
776
|
if (name === "decodeURIComponent" || name === "decodeURI") {
|
|
685
777
|
const d = optionalCallValue(lowerer, argNode) ?? lowerer.lowerExpr(argNode);
|
|
686
778
|
const s = lowerer.ensureString(d, argNode);
|
|
@@ -713,13 +805,13 @@ export function lowerCall(lowerer, expr) {
|
|
|
713
805
|
if ((expr.expression.text === "atob" || expr.expression.text === "btoa") &&
|
|
714
806
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
715
807
|
const name = expr.expression.text;
|
|
716
|
-
if (expr.arguments.length === 0) {
|
|
808
|
+
if (expr.arguments.nodes.length === 0) {
|
|
717
809
|
return { kind: "libCall", fn: "str.b64Missing", args: [], type: STRING, loc };
|
|
718
810
|
}
|
|
719
|
-
if (expr.arguments.length > 1) {
|
|
720
|
-
lowerer.noLowering(`${name} with ${expr.arguments.length} arguments`, expr);
|
|
811
|
+
if (expr.arguments.nodes.length > 1) {
|
|
812
|
+
lowerer.noLowering(`${name} with ${expr.arguments.nodes.length} arguments`, expr);
|
|
721
813
|
}
|
|
722
|
-
const argNode = expr.arguments[0];
|
|
814
|
+
const argNode = expr.arguments.nodes[0];
|
|
723
815
|
const v = lowerer.lowerExpr(argNode);
|
|
724
816
|
let data;
|
|
725
817
|
if (v.type.kind === "dyn") {
|
|
@@ -743,17 +835,17 @@ export function lowerCall(lowerer, expr) {
|
|
|
743
835
|
// result exits to the declared static type. A user function
|
|
744
836
|
// shadowing the name has a different, non-stdlib symbol.
|
|
745
837
|
const islFn = lowerer.stdlibGlobalFnOf(expr.expression);
|
|
746
|
-
if (islFn && expr.arguments.length !== islFn.args.length) {
|
|
838
|
+
if (islFn && expr.arguments.nodes.length !== islFn.args.length) {
|
|
747
839
|
const name = expr.expression.text;
|
|
748
|
-
lowerer.noLowering(`${name} with ${expr.arguments.length} argument${expr.arguments.length === 1 ? "" : "s"}`, expr);
|
|
840
|
+
lowerer.noLowering(`${name} with ${expr.arguments.nodes.length} argument${expr.arguments.nodes.length === 1 ? "" : "s"}`, expr);
|
|
749
841
|
}
|
|
750
|
-
if (islFn && expr.arguments.length === islFn.args.length) {
|
|
842
|
+
if (islFn && expr.arguments.nodes.length === islFn.args.length) {
|
|
751
843
|
// The static forms above already took the exactly-typed argument
|
|
752
844
|
// (a string for parseFloat, a number for isFinite): name the
|
|
753
845
|
// argument type that refused the call, so the message states the
|
|
754
846
|
// condition rather than reading as if the global itself were
|
|
755
847
|
// unsupported.
|
|
756
|
-
const argText = loweredArgumentText(lowerer, expr.arguments[0]);
|
|
848
|
+
const argText = loweredArgumentText(lowerer, expr.arguments.nodes[0]);
|
|
757
849
|
const exact = expr.expression.text === "isFinite" ? "number" : "string";
|
|
758
850
|
lowerer.refuseUnsupportedApi(`'${expr.expression.text}' with a '${argText}' argument`, expr, exact === "string"
|
|
759
851
|
? "only a string argument compiles statically: convert the argument explicitly first (for example String(x), or narrow the union)"
|
|
@@ -768,8 +860,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
768
860
|
// typeof tests) applies inside it, tsc's call-site narrowing types
|
|
769
861
|
// the guarded branch, and a body construct with no caught lowering
|
|
770
862
|
// fences per site at its own location.
|
|
771
|
-
if (ts.isIdentifier(expr.expression) && expr.arguments.length === 1) {
|
|
772
|
-
const caughtArg = lowerer.caughtLocalOf(expr.arguments[0]);
|
|
863
|
+
if (ts.isIdentifier(expr.expression) && expr.arguments.nodes.length === 1) {
|
|
864
|
+
const caughtArg = lowerer.caughtLocalOf(expr.arguments.nodes[0]);
|
|
773
865
|
if (caughtArg) {
|
|
774
866
|
const inlined = lowerCaughtPredicateCall(lowerer, expr, caughtArg);
|
|
775
867
|
if (inlined)
|
|
@@ -797,7 +889,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
797
889
|
// VALUE path — the runtime-arity lane (lowerSpreadArgsCall) boxes
|
|
798
890
|
// the declaration's value and applies through a runtime-built
|
|
799
891
|
// argument list. Typed .ts spreads keep completeArgs' rest packing.
|
|
800
|
-
const jsSpreadArgs = expr.arguments.some((a) => ts.isSpreadElement(a)) &&
|
|
892
|
+
const jsSpreadArgs = expr.arguments.nodes.some((a) => ts.isSpreadElement(a)) &&
|
|
893
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr));
|
|
801
894
|
if (lowerer.isTopLevelFnSymbol(expr.expression) && !lowerer.peekLocal(expr.expression)) {
|
|
802
895
|
// `import g = N.f; g()` — the alias's own source-order guards
|
|
803
896
|
// (a no-op for every non-import= binding).
|
|
@@ -809,17 +902,18 @@ export function lowerCall(lowerer, expr) {
|
|
|
809
902
|
if (generic && !(jsSpreadArgs && generic.implicitParams))
|
|
810
903
|
return lowerer.lowerGenericCall(expr, generic);
|
|
811
904
|
const sig = generic ? null : lowerer.fnSigOf(expr.expression);
|
|
812
|
-
if (sig &&
|
|
905
|
+
if (sig &&
|
|
906
|
+
!(jsSpreadArgs && spreadNeedsRuntimeArity(lowerer, sig.params, expr.arguments.nodes))) {
|
|
813
907
|
lowerer.noteEdge(sig.name);
|
|
814
|
-
const args = lowerer.completeArgs(expr.arguments, sig.params, loc, expr);
|
|
908
|
+
const args = lowerer.completeArgs(expr.arguments.nodes, sig.params, loc, expr);
|
|
815
909
|
const symbol = lowerer.resolveValueSymbol(expr.expression);
|
|
816
|
-
const declaration = symbol ?
|
|
910
|
+
const declaration = symbol ? symbol.valueDeclaration : undefined;
|
|
817
911
|
// A bare call supplies undefined as this, even inside a callback
|
|
818
912
|
// currently carrying a receiver. The value-call ABI saves and
|
|
819
913
|
// restores that ambient receiver around the function invocation.
|
|
820
914
|
if (declaration &&
|
|
821
915
|
ts.isFunctionDeclaration(declaration) &&
|
|
822
|
-
declaration.parameters.some(isThisParameter)) {
|
|
916
|
+
declaration.parameters.nodes.some(isThisParameter)) {
|
|
823
917
|
const callee = lowerer.lowerExpr(expr.expression);
|
|
824
918
|
return reconcileOverloadReturn(lowerer, expr, {
|
|
825
919
|
kind: "callValue",
|
|
@@ -903,13 +997,14 @@ export function lowerCall(lowerer, expr) {
|
|
|
903
997
|
const memberSym = lowerer.checker.getSymbolAtLocation(nsMember);
|
|
904
998
|
if (memberSym)
|
|
905
999
|
fenceEarlyNsMemberRef(lowerer, expr.expression, memberSym);
|
|
1000
|
+
refuseModuleMemberThis(lowerer, expr, nsMember);
|
|
906
1001
|
const generic = lowerer.genericFnOf(nsMember);
|
|
907
1002
|
if (generic)
|
|
908
1003
|
return lowerer.lowerGenericCall(expr, generic);
|
|
909
1004
|
const sig = lowerer.fnSigOf(nsMember);
|
|
910
1005
|
if (sig) {
|
|
911
1006
|
lowerer.noteEdge(sig.name);
|
|
912
|
-
const args = lowerer.completeArgs(expr.arguments, sig.params, loc, expr);
|
|
1007
|
+
const args = lowerer.completeArgs(expr.arguments.nodes, sig.params, loc, expr);
|
|
913
1008
|
return reconcileOverloadReturn(lowerer, expr, {
|
|
914
1009
|
kind: "call",
|
|
915
1010
|
callee: sig.name,
|
|
@@ -967,13 +1062,14 @@ export function lowerCall(lowerer, expr) {
|
|
|
967
1062
|
if (!ts.isIdentifier(nameId)) {
|
|
968
1063
|
lowerer.unsupported("SC1090", nameId, "private-named module members");
|
|
969
1064
|
}
|
|
1065
|
+
refuseModuleMemberThis(lowerer, expr, nameId);
|
|
970
1066
|
const generic = lowerer.genericFnOf(nameId);
|
|
971
1067
|
if (generic)
|
|
972
1068
|
return lowerer.lowerGenericCall(expr, generic);
|
|
973
1069
|
const sig = lowerer.fnSigOf(nameId);
|
|
974
1070
|
if (sig) {
|
|
975
1071
|
lowerer.noteEdge(sig.name);
|
|
976
|
-
const args = lowerer.completeArgs(expr.arguments, sig.params, loc, expr);
|
|
1072
|
+
const args = lowerer.completeArgs(expr.arguments.nodes, sig.params, loc, expr);
|
|
977
1073
|
return reconcileOverloadReturn(lowerer, expr, {
|
|
978
1074
|
kind: "call",
|
|
979
1075
|
callee: sig.name,
|
|
@@ -993,8 +1089,35 @@ export function lowerCall(lowerer, expr) {
|
|
|
993
1089
|
const args = completeFuncValueArgs(lowerer, expr, callee.type, loc);
|
|
994
1090
|
return { kind: "callValue", callee, args, type: callee.type.ret, loc };
|
|
995
1091
|
}
|
|
1092
|
+
// `exports.f(x)` / `module.exports.f(x)` inside the module: a call of
|
|
1093
|
+
// the member's export global (cjs-exports-object.ts), the value every
|
|
1094
|
+
// `exports.f =` statement assigns.
|
|
1095
|
+
if (ts.isPropertyAccessExpression(expr.expression) && !expr.questionDotToken) {
|
|
1096
|
+
const g = cjsInFileExportGlobalOf(lowerer, expr.expression);
|
|
1097
|
+
if (g &&
|
|
1098
|
+
(g.type.kind === "func" || g.type.kind === "dyn") &&
|
|
1099
|
+
!cjsExportCallIgnoresThis(lowerer, ts.getSourceFileOfNode(expr), expr.expression.name.text)) {
|
|
1100
|
+
lowerer.unsupported("SC1090", expr, `calling '${ts.getTextOfNode(expr.expression)}' through the module's exports object when the function may read 'this' (Node binds it to the exports object, which compiles to a static table — call a local function instead)`);
|
|
1101
|
+
}
|
|
1102
|
+
if (g && (g.type.kind === "func" || g.type.kind === "dyn")) {
|
|
1103
|
+
const callee = { kind: "varRef", localId: g.id, type: g.type, loc };
|
|
1104
|
+
const checked = lowerCheckedCallableValue(lowerer, expr, callee, loc);
|
|
1105
|
+
if (checked)
|
|
1106
|
+
return checked;
|
|
1107
|
+
if (callee.type.kind === "func") {
|
|
1108
|
+
const args = completeFuncValueArgs(lowerer, expr, callee.type, loc);
|
|
1109
|
+
return { kind: "callValue", callee, args, type: callee.type.ret, loc };
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
996
1113
|
if (ts.isPropertyAccessExpression(expr.expression)) {
|
|
997
|
-
const intrinsic =
|
|
1114
|
+
const intrinsic =
|
|
1115
|
+
// Checked-dynamic stream slots dispatch per value (dyn-streams.ts).
|
|
1116
|
+
lowerDynStreamMemberCall(lowerer, expr, expr.expression) ??
|
|
1117
|
+
fenceNodeModuleMutationCall(lowerer, expr, expr.expression) ??
|
|
1118
|
+
// `f.apply(thisArg, args)` forwarding a fixed argument tuple (typed
|
|
1119
|
+
// `arguments`, a tuple rest parameter): a direct call.
|
|
1120
|
+
lowerForwardingApply(lowerer, expr, expr.expression) ??
|
|
998
1121
|
// Builtin namespace imports first (`fs.readFileSync(...)` where fs
|
|
999
1122
|
// is `import * as fs from "node:fs"`): the same tables and fences
|
|
1000
1123
|
// as named builtin imports — before anything below tries to lower
|
|
@@ -1006,6 +1129,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1006
1129
|
// .bind(performance) function value over the runtime's
|
|
1007
1130
|
// process-start-anchored monotonic clock.
|
|
1008
1131
|
lowerPerfHooksCall(lowerer, expr, expr.expression) ??
|
|
1132
|
+
lowerHistogramMethodCall(lowerer, expr, expr.expression) ??
|
|
1009
1133
|
// The composed crypto pattern (randomBytes(n).toString(enc))
|
|
1010
1134
|
// — its receiver is a Buffer-typed CALL no other lowering claims.
|
|
1011
1135
|
lowerer.lowerCryptoComposedCall(expr, expr.expression) ??
|
|
@@ -1037,6 +1161,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1037
1161
|
lowerCipherMethodCall(lowerer, expr, expr.expression) ??
|
|
1038
1162
|
lowerFileHandleMethodCall(lowerer, expr, expr.expression) ??
|
|
1039
1163
|
lowerDirMethodCall(lowerer, expr, expr.expression) ??
|
|
1164
|
+
lowerChildPropertyCall(lowerer, expr, expr.expression) ??
|
|
1040
1165
|
lowerer.lowerChildMethodCall(expr, expr.expression) ??
|
|
1041
1166
|
// Piped child-output stream receivers — on/once("data" | "end").
|
|
1042
1167
|
lowerChildStreamMethodCall(lowerer, expr, expr.expression) ??
|
|
@@ -1099,6 +1224,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
1099
1224
|
// compile-time-known, so a literal key folds to a constant.
|
|
1100
1225
|
lowerClassHasOwnPropertyCall(lowerer, expr, expr.expression) ??
|
|
1101
1226
|
lowerObjectOwnMethodCall(lowerer, expr, expr.expression) ??
|
|
1227
|
+
// Static Response.json(data, init?) builds a native Response.
|
|
1228
|
+
lowerResponseStaticJson(lowerer, expr) ??
|
|
1102
1229
|
// Refuse Response constructor operations before generic-call
|
|
1103
1230
|
// fallbacks can report an unrelated SC1090 diagnostic.
|
|
1104
1231
|
lowerer.fenceUnsupportedFetchConstructorMember(expr.expression) ??
|
|
@@ -1108,7 +1235,11 @@ export function lowerCall(lowerer, expr) {
|
|
|
1108
1235
|
lowerer.fenceStaticResponseMember(expr.expression, "call") ??
|
|
1109
1236
|
lowerer.fenceStaticHeadersMember(expr.expression, "call") ??
|
|
1110
1237
|
lowerer.fenceStaticReadableStreamMember(expr.expression, "call") ??
|
|
1238
|
+
lowerDisposableStackUseCall(lowerer, expr, expr.expression) ??
|
|
1111
1239
|
lowerer.lowerStdlibMethodCall(expr, expr.expression) ??
|
|
1240
|
+
// crypto.getRandomValues on the WebCrypto global (untyped in
|
|
1241
|
+
// fallback builds, so before the dyn receiver path) or webcrypto.
|
|
1242
|
+
lowerWebCryptoGetRandomValues(lowerer, expr, expr.expression) ??
|
|
1112
1243
|
// Dyn receivers (JSON.parse-derived `unknown`/`any` values) —
|
|
1113
1244
|
lowerDynReceiverMethodCall(lowerer, expr, expr.expression) ??
|
|
1114
1245
|
// Narrowing filters (inferred predicates, filter(Boolean)) claim
|
|
@@ -1116,6 +1247,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1116
1247
|
// by the receiver's own element.
|
|
1117
1248
|
lowerer.lowerFilterNarrowCall(expr, expr.expression) ??
|
|
1118
1249
|
lowerArrayIsArrayCall(lowerer, expr, expr.expression) ??
|
|
1250
|
+
lowerErrorIsErrorCall(lowerer, expr, expr.expression) ??
|
|
1119
1251
|
lowerBigIntMethodCall(lowerer, expr, expr.expression) ??
|
|
1120
1252
|
lowerSymbolStaticCall(lowerer, expr, expr.expression) ??
|
|
1121
1253
|
lowerSymbolMethodCall(lowerer, expr, expr.expression) ??
|
|
@@ -1128,6 +1260,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
1128
1260
|
// array method paths (the terminal names collide with array
|
|
1129
1261
|
// methods, but only iterator-typed receivers reach this).
|
|
1130
1262
|
lowerIteratorHelperCall(lowerer, expr, expr.expression) ??
|
|
1263
|
+
// Helper calls on generators and other iterator objects.
|
|
1264
|
+
lowerGeneratorHelperCall(lowerer, expr, expr.expression) ??
|
|
1131
1265
|
lowerIteratorStaticFence(lowerer, expr, expr.expression) ??
|
|
1132
1266
|
lowerObjectStaticCall(lowerer, expr, expr.expression) ??
|
|
1133
1267
|
lowerObjectFromEntriesCall(lowerer, expr, expr.expression) ??
|
|
@@ -1151,15 +1285,20 @@ export function lowerCall(lowerer, expr) {
|
|
|
1151
1285
|
lowerObjLitGenericMethodCall(lowerer, expr, expr.expression);
|
|
1152
1286
|
if (intrinsic)
|
|
1153
1287
|
return intrinsic;
|
|
1154
|
-
|
|
1288
|
+
{
|
|
1289
|
+
const boxed = lowerDynReceiverMethodCall(lowerer, expr, expr.expression, true);
|
|
1290
|
+
if (boxed)
|
|
1291
|
+
return boxed;
|
|
1292
|
+
}
|
|
1293
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr))) {
|
|
1155
1294
|
const staticField = lowerStaticFieldRead(lowerer, expr.expression);
|
|
1156
|
-
if (staticField?.type.kind === "dyn" && !expr.arguments.some(ts.isSpreadElement)) {
|
|
1295
|
+
if (staticField?.type.kind === "dyn" && !expr.arguments.nodes.some(ts.isSpreadElement)) {
|
|
1157
1296
|
return {
|
|
1158
1297
|
kind: "dynCall",
|
|
1159
1298
|
callee: staticField,
|
|
1160
1299
|
receiver: lowerer.lowerExprExpecting(expr.expression.expression, DYN),
|
|
1161
|
-
calleeName: expr.expression
|
|
1162
|
-
args: expr.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1300
|
+
calleeName: v8CalleeText(expr.expression),
|
|
1301
|
+
args: expr.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1163
1302
|
type: DYN,
|
|
1164
1303
|
loc: locOf(expr),
|
|
1165
1304
|
};
|
|
@@ -1172,12 +1311,13 @@ export function lowerCall(lowerer, expr) {
|
|
|
1172
1311
|
const args = completeFuncValueArgs(lowerer, expr, callee.type, locOf(expr));
|
|
1173
1312
|
return { kind: "callValue", callee, args, type: callee.type.ret, loc: locOf(expr) };
|
|
1174
1313
|
}
|
|
1175
|
-
if (callee.type.kind === "dyn" &&
|
|
1176
|
-
|
|
1314
|
+
if (callee.type.kind === "dyn" &&
|
|
1315
|
+
!expr.arguments.nodes.some((arg) => ts.isSpreadElement(arg))) {
|
|
1316
|
+
const args = expr.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
1177
1317
|
return {
|
|
1178
1318
|
kind: "dynCall",
|
|
1179
1319
|
callee,
|
|
1180
|
-
calleeName: expr.expression
|
|
1320
|
+
calleeName: v8CalleeText(expr.expression),
|
|
1181
1321
|
args,
|
|
1182
1322
|
type: DYN,
|
|
1183
1323
|
loc: locOf(expr),
|
|
@@ -1197,6 +1337,11 @@ export function lowerCall(lowerer, expr) {
|
|
|
1197
1337
|
return nsUndefRead(lowerer, ambientRoot.text, expr, t);
|
|
1198
1338
|
}
|
|
1199
1339
|
}
|
|
1340
|
+
{
|
|
1341
|
+
const childCall = lowerChildPropertyCall(lowerer, expr, expr.expression, true);
|
|
1342
|
+
if (childCall)
|
|
1343
|
+
return childCall;
|
|
1344
|
+
}
|
|
1200
1345
|
// The lib fence's METHOD-CALL chokepoint: a stdlib-declared member
|
|
1201
1346
|
// that every lowering above declined — an unlowered member
|
|
1202
1347
|
// (m.keys(), p.then(f), Object.keys(o)) or an unlowered call FORM of
|
|
@@ -1214,7 +1359,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1214
1359
|
{
|
|
1215
1360
|
const recvT = lowerer.typeOf(expr.expression.expression);
|
|
1216
1361
|
if (recvT.isIntersectionType() && lowerer.checker.getCallSignatures(recvT).length > 0) {
|
|
1217
|
-
lowerer.unsupported("SC1090", expr, `calls through function-with-properties values ('${expr.expression.expression
|
|
1362
|
+
lowerer.unsupported("SC1090", expr, `calls through function-with-properties values ('${ts.getTextOfNode(expr.expression.expression)}' is callable AND carries members — the chalk shape; no hybrid representation exists yet: export the base and the property as separate functions)`);
|
|
1218
1363
|
}
|
|
1219
1364
|
}
|
|
1220
1365
|
// A GENERIC method no lowering above claimed — an ambient `declare
|
|
@@ -1229,14 +1374,29 @@ export function lowerCall(lowerer, expr) {
|
|
|
1229
1374
|
lowerer.unsupported("SC1090", expr, `calls of the generic method '${expr.expression.name.text}' through this receiver (no compiled declaration with a body resolves statically here — ambient 'declare class' and interface-only methods are signature-only, and only class, static, and object-literal generic methods with bodies monomorphize)`);
|
|
1230
1375
|
}
|
|
1231
1376
|
}
|
|
1232
|
-
lowerer.unsupported("SC1090", expr, `method calls like '${expr.expression
|
|
1377
|
+
lowerer.unsupported("SC1090", expr, `method calls like '${ts.getTextOfNode(expr.expression)}'`);
|
|
1378
|
+
}
|
|
1379
|
+
// `s[Symbol.iterator]()` on a string: the string iterator as a value.
|
|
1380
|
+
if (ts.isElementAccessExpression(expr.expression) &&
|
|
1381
|
+
!expr.expression.questionDotToken &&
|
|
1382
|
+
!expr.questionDotToken &&
|
|
1383
|
+
expr.arguments.nodes.length === 0) {
|
|
1384
|
+
const iterator = lowerStringIteratorCall(lowerer, expr, expr.expression);
|
|
1385
|
+
if (iterator)
|
|
1386
|
+
return iterator;
|
|
1233
1387
|
}
|
|
1234
1388
|
// The element spelling of an unsupported native Web method must fence
|
|
1235
1389
|
// before lowering the callee into a checked-dynamic keyed read.
|
|
1236
1390
|
if (ts.isElementAccessExpression(expr.expression)) {
|
|
1391
|
+
const timersDispose = lowerMockTimersElementCall(lowerer, expr, expr.expression);
|
|
1392
|
+
if (timersDispose)
|
|
1393
|
+
return timersDispose;
|
|
1237
1394
|
const symbolMethod = lowerClassSymbolMethodCall(lowerer, expr);
|
|
1238
1395
|
if (symbolMethod)
|
|
1239
1396
|
return symbolMethod;
|
|
1397
|
+
const readlineDispose = lowerReadlineDisposeCall(lowerer, expr);
|
|
1398
|
+
if (readlineDispose)
|
|
1399
|
+
return readlineDispose;
|
|
1240
1400
|
lowerer.fenceUnsupportedFetchConstructorMember(expr.expression);
|
|
1241
1401
|
lowerer.fenceStaticResponseMember(expr.expression, "call");
|
|
1242
1402
|
lowerer.fenceStaticHeadersMember(expr.expression, "call");
|
|
@@ -1250,7 +1410,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1250
1410
|
!symbolFieldInfo(lowerer, expr.expression)) {
|
|
1251
1411
|
const access = expr.expression;
|
|
1252
1412
|
const value = tryLowerExpression(lowerer, access.expression);
|
|
1253
|
-
if (value?.type.kind === "array" && !isJsSourceFile(
|
|
1413
|
+
if (value?.type.kind === "array" && !isJsSourceFile(ts.getSourceFileOfNode(expr))) {
|
|
1254
1414
|
const callback = lowerArrayCallbackCall(lowerer, expr, access, value);
|
|
1255
1415
|
if (callback)
|
|
1256
1416
|
return callback;
|
|
@@ -1270,7 +1430,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1270
1430
|
const raw = lowerer.lowerExpr(access.argumentExpression);
|
|
1271
1431
|
const key = raw.type.kind === "string" ? raw : lowerer.coerceInto(access.argumentExpression, raw, DYN);
|
|
1272
1432
|
const callee = { kind: "dynKeyGet", value: receiver, key, type: DYN, loc };
|
|
1273
|
-
const spread = expr.arguments.some(ts.isSpreadElement)
|
|
1433
|
+
const spread = expr.arguments.nodes.some(ts.isSpreadElement)
|
|
1274
1434
|
? lowerSpreadArgsCall(lowerer, expr, callee, loc)
|
|
1275
1435
|
: null;
|
|
1276
1436
|
if (spread && spread.kind !== "dynCall")
|
|
@@ -1281,8 +1441,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
1281
1441
|
kind: "dynCall",
|
|
1282
1442
|
callee,
|
|
1283
1443
|
receiver,
|
|
1284
|
-
calleeName:
|
|
1285
|
-
args: expr.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1444
|
+
calleeName: ts.getTextOfNode(access),
|
|
1445
|
+
args: expr.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1286
1446
|
type: DYN,
|
|
1287
1447
|
loc,
|
|
1288
1448
|
};
|
|
@@ -1323,7 +1483,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1323
1483
|
else
|
|
1324
1484
|
lowerer.noteEdge(`%${found.declarer.def.name}.${memberName}`);
|
|
1325
1485
|
const receiver = lowerer.lowerExpr(expr.expression.expression);
|
|
1326
|
-
const args = lowerer.completeArgs(expr.arguments, found.sig.params, locOf(expr), expr);
|
|
1486
|
+
const args = lowerer.completeArgs(expr.arguments.nodes, found.sig.params, locOf(expr), expr);
|
|
1327
1487
|
const callArgs = [
|
|
1328
1488
|
lowerer.upcastTo(receiver, virtual ? info.def.name : found.declarer.def.name),
|
|
1329
1489
|
...args,
|
|
@@ -1374,7 +1534,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
1374
1534
|
// function" TypeError. The result is dyn (checked per use like every
|
|
1375
1535
|
// any-origin value). Spread arguments keep their fence.
|
|
1376
1536
|
if (callee.type.kind === "dyn") {
|
|
1377
|
-
if (expr.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
1537
|
+
if (expr.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
1378
1538
|
// The runtime-arity lane: a dyn callee is already boxed — the
|
|
1379
1539
|
// spread-marked dynCall applies through a fresh dyn argument
|
|
1380
1540
|
// array (lowerSpreadArgsCall). Sources outside it keep the fence.
|
|
@@ -1383,10 +1543,10 @@ export function lowerCall(lowerer, expr) {
|
|
|
1383
1543
|
return spreadServed;
|
|
1384
1544
|
lowerer.unsupported("SC1090", expr, "spread arguments in calls through 'unknown' values");
|
|
1385
1545
|
}
|
|
1386
|
-
const args = expr.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
1546
|
+
const args = expr.arguments.nodes.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
1387
1547
|
const calleeName = ts.isPropertyAccessExpression(expr.expression) ||
|
|
1388
1548
|
ts.isElementAccessExpression(expr.expression)
|
|
1389
|
-
? expr.expression
|
|
1549
|
+
? ts.getTextOfNode(expr.expression)
|
|
1390
1550
|
: ts.isIdentifier(expr.expression)
|
|
1391
1551
|
? expr.expression.text
|
|
1392
1552
|
: "value";
|
|
@@ -1398,8 +1558,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
1398
1558
|
return {
|
|
1399
1559
|
kind: "dynCall",
|
|
1400
1560
|
callee: lowerer.coerceToExpected(callee, DYN),
|
|
1401
|
-
calleeName: expr.expression
|
|
1402
|
-
args: expr.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1561
|
+
calleeName: v8CalleeText(expr.expression),
|
|
1562
|
+
args: expr.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1403
1563
|
type: DYN,
|
|
1404
1564
|
loc,
|
|
1405
1565
|
};
|
|
@@ -1420,7 +1580,16 @@ export function lowerCall(lowerer, expr) {
|
|
|
1420
1580
|
// or marshals the callee and applies through a runtime-built argument
|
|
1421
1581
|
// list (lowerSpreadArgsCall). Shapes outside its lanes fall through
|
|
1422
1582
|
// to the historical fences.
|
|
1423
|
-
|
|
1583
|
+
// Forwarded fixed tuples (`fn(...args)` over a tuple rest parameter or a
|
|
1584
|
+
// typed `arguments`) have a compile-time arity: complete them into the
|
|
1585
|
+
// callee's positional slots directly, without the runtime-arity lane.
|
|
1586
|
+
if (callee.type.rest !== true &&
|
|
1587
|
+
expr.arguments.nodes.some(ts.isSpreadElement) &&
|
|
1588
|
+
expr.arguments.nodes.every((a) => !ts.isSpreadElement(a) || isForwardedTupleSpread(lowerer, a.expression))) {
|
|
1589
|
+
const args = completeFuncValueArgs(lowerer, expr, callee.type, loc);
|
|
1590
|
+
return { kind: "callValue", callee, args, type: callee.type.ret, loc };
|
|
1591
|
+
}
|
|
1592
|
+
if (expr.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
1424
1593
|
const spreadServed = lowerSpreadArgsCall(lowerer, expr, callee, loc);
|
|
1425
1594
|
if (spreadServed)
|
|
1426
1595
|
return spreadServed;
|
|
@@ -1431,12 +1600,12 @@ export function lowerCall(lowerer, expr) {
|
|
|
1431
1600
|
// checked-dynamic boundary — box the callee, dynCall — which delivers
|
|
1432
1601
|
// JS arity exactly (the thunk ignores extras). Result dyn, checked
|
|
1433
1602
|
// per use like every any-origin value.
|
|
1434
|
-
if ((expr.arguments.length > callee.type.params.length || callee.type.rest === true) &&
|
|
1435
|
-
(isJsSourceFile(
|
|
1603
|
+
if ((expr.arguments.nodes.length > callee.type.params.length || callee.type.rest === true) &&
|
|
1604
|
+
(isJsSourceFile(ts.getSourceFileOfNode(expr)) ||
|
|
1436
1605
|
(callee.type.rest === true && callee.type.restAbi === undefined)) &&
|
|
1437
|
-
!expr.arguments.some((a) => ts.isSpreadElement(a)) &&
|
|
1606
|
+
!expr.arguments.nodes.some((a) => ts.isSpreadElement(a)) &&
|
|
1438
1607
|
canBoxFuncIntoDyn(callee.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
1439
|
-
const args = expr.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
1608
|
+
const args = expr.arguments.nodes.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
1440
1609
|
const calleeName = ts.isIdentifier(expr.expression) ? expr.expression.text : "value";
|
|
1441
1610
|
const boxed = { kind: "dynFrom", value: callee, type: DYN, loc };
|
|
1442
1611
|
return { kind: "dynCall", callee: boxed, calleeName, args, type: DYN, loc };
|
|
@@ -1451,12 +1620,13 @@ function lowerCheckedCallableValue(lowerer, call, value, loc) {
|
|
|
1451
1620
|
if (callee.type.kind !== "dyn") {
|
|
1452
1621
|
if (callee.type.kind !== "func" ||
|
|
1453
1622
|
!((callee.type.rest === true && callee.type.restAbi === undefined) ||
|
|
1454
|
-
(isJsSourceFile(
|
|
1623
|
+
(isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
1624
|
+
call.arguments.nodes.length > callee.type.params.length)) ||
|
|
1455
1625
|
!lowerer.dynConvertible(callee.type))
|
|
1456
1626
|
return null;
|
|
1457
1627
|
callee = { kind: "dynFrom", value: callee, type: DYN, loc };
|
|
1458
1628
|
}
|
|
1459
|
-
if (call.arguments.some(ts.isSpreadElement)) {
|
|
1629
|
+
if (call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
1460
1630
|
const spread = lowerSpreadArgsCall(lowerer, call, callee, loc);
|
|
1461
1631
|
if (spread)
|
|
1462
1632
|
return spread;
|
|
@@ -1465,8 +1635,8 @@ function lowerCheckedCallableValue(lowerer, call, value, loc) {
|
|
|
1465
1635
|
return {
|
|
1466
1636
|
kind: "dynCall",
|
|
1467
1637
|
callee,
|
|
1468
|
-
calleeName: call.expression
|
|
1469
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1638
|
+
calleeName: v8CalleeText(call.expression),
|
|
1639
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
1470
1640
|
type: DYN,
|
|
1471
1641
|
loc,
|
|
1472
1642
|
};
|
|
@@ -1475,19 +1645,19 @@ function lowerRegexMethodCallWithOptionalArg(lowerer, call, access) {
|
|
|
1475
1645
|
const lowered = lowerer.lowerRegexMethodCall(call, access);
|
|
1476
1646
|
if (lowered?.kind !== "regexIntrinsic" ||
|
|
1477
1647
|
lowered.method !== "test" ||
|
|
1478
|
-
call.arguments.length !== 1)
|
|
1648
|
+
call.arguments.nodes.length !== 1)
|
|
1479
1649
|
return lowered;
|
|
1480
1650
|
const subject = lowered.args[0];
|
|
1481
1651
|
if (subject?.type.kind !== "union" || lowerer.armTag(subject.type.unionId, UNDEFINED_T) < 0)
|
|
1482
1652
|
return lowered;
|
|
1483
|
-
if (lowerer.mapTypeOf(lowerer.typeOf(call.arguments[0]))?.kind !== "string")
|
|
1653
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(call.arguments.nodes[0]))?.kind !== "string")
|
|
1484
1654
|
return lowered;
|
|
1485
1655
|
const present = lowerer.stripUndefinedArm(subject.type);
|
|
1486
1656
|
if (present.kind !== "string")
|
|
1487
1657
|
return lowered;
|
|
1488
1658
|
return {
|
|
1489
1659
|
...lowered,
|
|
1490
|
-
args: [lowerer.ensureString(subject, call.arguments[0])],
|
|
1660
|
+
args: [lowerer.ensureString(subject, call.arguments.nodes[0])],
|
|
1491
1661
|
};
|
|
1492
1662
|
}
|
|
1493
1663
|
function optionalCallValue(lowerer, node) {
|
|
@@ -1504,17 +1674,17 @@ function lowerBufferStaticCallWithNarrowedArg(lowerer, call, access) {
|
|
|
1504
1674
|
// A callback can store a wider union than the checker sees at this use
|
|
1505
1675
|
// (including an added undefined arm). Extract the exact arm proven by
|
|
1506
1676
|
// control-flow narrowing, not merely the union with undefined removed.
|
|
1507
|
-
const narrowed = lowerer.mapTypeOf(lowerer.typeOf(call.arguments[0]));
|
|
1677
|
+
const narrowed = lowerer.mapTypeOf(lowerer.typeOf(call.arguments.nodes[0]));
|
|
1508
1678
|
if (!narrowed ||
|
|
1509
1679
|
!(narrowed.kind === "f64" ||
|
|
1510
1680
|
(narrowed.kind === "array" && narrowed.elem.kind === "f64") ||
|
|
1511
1681
|
(narrowed.kind === "bytes" && narrowed.elem === "u8")) ||
|
|
1512
1682
|
lowerer.armTag(lowered.source.type.unionId, narrowed) < 0) {
|
|
1513
|
-
lowerer.unsupported("SC1090", call.arguments[0], "a Buffer constructor argument whose narrowed type is not a stored source arm");
|
|
1683
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "a Buffer constructor argument whose narrowed type is not a stored source arm");
|
|
1514
1684
|
}
|
|
1515
1685
|
const helper = lowerer.narrowedArmHelper(lowered.source.type.unionId, narrowed, lowered.source.loc);
|
|
1516
1686
|
if (!helper) {
|
|
1517
|
-
lowerer.unsupported("SC1090", call.arguments[0], "a Buffer constructor argument whose narrowed type is not a stored source arm");
|
|
1687
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "a Buffer constructor argument whose narrowed type is not a stored source arm");
|
|
1518
1688
|
}
|
|
1519
1689
|
const narrowedValue = {
|
|
1520
1690
|
...lowered,
|
|
@@ -1575,7 +1745,7 @@ function lowerOptionalNumberDefault(lowerer, value, dflt, loc) {
|
|
|
1575
1745
|
}
|
|
1576
1746
|
return { kind: "call", callee: helper, args: [value], type: F64, loc };
|
|
1577
1747
|
}
|
|
1578
|
-
function lowerStringMethodCallWithOptionalArgs(lowerer, call, access, receiver, argumentNodes = call.arguments) {
|
|
1748
|
+
function lowerStringMethodCallWithOptionalArgs(lowerer, call, access, receiver, argumentNodes = call.arguments.nodes) {
|
|
1579
1749
|
const lowered = lowerStringMethodCall(lowerer, call, access, receiver, argumentNodes);
|
|
1580
1750
|
if (lowered?.kind !== "strIntrinsic")
|
|
1581
1751
|
return lowered;
|
|
@@ -1611,6 +1781,59 @@ function lowerStringMethodCallWithOptionalArgs(lowerer, call, access, receiver,
|
|
|
1611
1781
|
}
|
|
1612
1782
|
return changed ? { ...lowered, args } : lowered;
|
|
1613
1783
|
}
|
|
1784
|
+
/** `.then(String)` / `.then(Number)` / `.then(Boolean)` over a promise of
|
|
1785
|
+
* a number, string or boolean: the ambient constructor converts its first
|
|
1786
|
+
* argument (the settled value), so the handler is an interned closure over
|
|
1787
|
+
* the settled type applying that conversion. The constructors' own value
|
|
1788
|
+
* form takes a string, which a number or boolean settled value is not.
|
|
1789
|
+
* Null for every other handler. */
|
|
1790
|
+
function primitiveConversionHandler(lowerer, node, inner) {
|
|
1791
|
+
if (!ts.isIdentifier(node))
|
|
1792
|
+
return null;
|
|
1793
|
+
const name = node.text;
|
|
1794
|
+
if (name !== "String" && name !== "Number" && name !== "Boolean")
|
|
1795
|
+
return null;
|
|
1796
|
+
// A string settled value already fits the constructors' value form.
|
|
1797
|
+
if (inner.kind !== "f64" && inner.kind !== "bool")
|
|
1798
|
+
return null;
|
|
1799
|
+
if (!lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(node) ?? undefined))
|
|
1800
|
+
return null;
|
|
1801
|
+
const loc = locOf(node);
|
|
1802
|
+
const ret = name === "String" ? STRING : name === "Number" ? F64 : BOOL;
|
|
1803
|
+
const fnT = funcOf([inner], ret);
|
|
1804
|
+
const key = `then.${name}:${typeKey(inner)}`;
|
|
1805
|
+
let fnName = lowerer.arrHofHelpers.get(key);
|
|
1806
|
+
if (fnName === undefined) {
|
|
1807
|
+
fnName = `%then.${name}.${lowerer.arrHofHelpers.size}`;
|
|
1808
|
+
lowerer.arrHofHelpers.set(key, fnName);
|
|
1809
|
+
const value = varRef("v.0", inner, loc);
|
|
1810
|
+
let body;
|
|
1811
|
+
if (name === "Boolean")
|
|
1812
|
+
body = { kind: "toBool", operand: value, type: BOOL, loc };
|
|
1813
|
+
else if (name === "String")
|
|
1814
|
+
body = { kind: "toString", operand: value, type: STRING, loc };
|
|
1815
|
+
else if (inner.kind === "f64")
|
|
1816
|
+
body = value;
|
|
1817
|
+
else
|
|
1818
|
+
body = {
|
|
1819
|
+
kind: "ternary",
|
|
1820
|
+
cond: value,
|
|
1821
|
+
then: { kind: "numLit", value: 1, type: F64, loc },
|
|
1822
|
+
else_: { kind: "numLit", value: 0, type: F64, loc },
|
|
1823
|
+
type: F64,
|
|
1824
|
+
loc,
|
|
1825
|
+
};
|
|
1826
|
+
lowerer.liftedFns.push({
|
|
1827
|
+
name: fnName,
|
|
1828
|
+
params: [{ localId: "v.0", name: "v", type: inner }],
|
|
1829
|
+
returnType: ret,
|
|
1830
|
+
locals: [{ id: "v.0", name: "v", type: inner, mutable: false }],
|
|
1831
|
+
body: [{ kind: "return", value: body, loc }],
|
|
1832
|
+
loc,
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
return { kind: "closure", fnName, captures: [], type: fnT, loc };
|
|
1836
|
+
}
|
|
1614
1837
|
function lowerNumberConstructorValue(lowerer, argNode, loc) {
|
|
1615
1838
|
const undefinedArg = lowerStaticallyUndefinedArgument(lowerer, argNode);
|
|
1616
1839
|
if (undefinedArg) {
|
|
@@ -1672,6 +1895,10 @@ function lowerNumberConstructorValue(lowerer, argNode, loc) {
|
|
|
1672
1895
|
const optionalNumber = lowerOptionalStringNumber(lowerer, arg, loc);
|
|
1673
1896
|
if (optionalNumber)
|
|
1674
1897
|
return optionalNumber;
|
|
1898
|
+
// A program class instance converts through its own methods.
|
|
1899
|
+
const classNumber = classToNumberConversion(lowerer, arg, argNode);
|
|
1900
|
+
if (classNumber)
|
|
1901
|
+
return classNumber;
|
|
1675
1902
|
const scalarUnionNumber = lowerScalarUnionNumber(lowerer, arg, argNode, loc);
|
|
1676
1903
|
if (scalarUnionNumber)
|
|
1677
1904
|
return scalarUnionNumber;
|
|
@@ -1777,7 +2004,7 @@ function immediatePrimitiveWrapperToString(lowerer, node) {
|
|
|
1777
2004
|
if ((name !== "Boolean" && name !== "Number") ||
|
|
1778
2005
|
!lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(wrapped.expression) ?? undefined))
|
|
1779
2006
|
return null;
|
|
1780
|
-
const args = wrapped.arguments ?? [];
|
|
2007
|
+
const args = wrapped.arguments?.nodes ?? [];
|
|
1781
2008
|
if (args.length > 1 || args.some(ts.isSpreadElement))
|
|
1782
2009
|
return null;
|
|
1783
2010
|
const loc = locOf(wrapped);
|
|
@@ -1844,7 +2071,7 @@ function immediateObjectTagReceiver(lowerer, node) {
|
|
|
1844
2071
|
if ((ts.isCallExpression(value) || ts.isNewExpression(value)) &&
|
|
1845
2072
|
ts.isIdentifier(value.expression) &&
|
|
1846
2073
|
(value.expression.text === "Array" || value.expression.text === "Error") &&
|
|
1847
|
-
(value.arguments?.length ?? 0) === 0 &&
|
|
2074
|
+
(value.arguments?.nodes.length ?? 0) === 0 &&
|
|
1848
2075
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(value.expression) ?? undefined)) {
|
|
1849
2076
|
return { tag: value.expression.text, effect: { kind: "numLit", value: 0, type: F64, loc } };
|
|
1850
2077
|
}
|
|
@@ -1852,7 +2079,7 @@ function immediateObjectTagReceiver(lowerer, node) {
|
|
|
1852
2079
|
ts.isIdentifier(value.expression) &&
|
|
1853
2080
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(value.expression) ?? undefined)) {
|
|
1854
2081
|
const name = value.expression.text;
|
|
1855
|
-
const args = value.arguments ?? [];
|
|
2082
|
+
const args = value.arguments?.nodes ?? [];
|
|
1856
2083
|
// JavaScript dates use checked native handles, so their IR type alone
|
|
1857
2084
|
// cannot recover the tag through an immediate Object(...) wrapper.
|
|
1858
2085
|
if (name === "Date")
|
|
@@ -1883,7 +2110,7 @@ function immediateObjectTagReceiver(lowerer, node) {
|
|
|
1883
2110
|
ts.isIdentifier(value.expression) &&
|
|
1884
2111
|
value.expression.text === "Object" &&
|
|
1885
2112
|
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(value.expression) ?? undefined)) {
|
|
1886
|
-
const args = value.arguments ?? [];
|
|
2113
|
+
const args = value.arguments?.nodes ?? [];
|
|
1887
2114
|
if (args.some(ts.isSpreadElement))
|
|
1888
2115
|
return null;
|
|
1889
2116
|
const first = args[0];
|
|
@@ -1938,12 +2165,12 @@ const ARRAY_BORROW_METHODS = new Set([
|
|
|
1938
2165
|
"some",
|
|
1939
2166
|
]);
|
|
1940
2167
|
function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
|
|
1941
|
-
if (!isJsSourceFile(
|
|
2168
|
+
if (!isJsSourceFile(ts.getSourceFileOfNode(call)) ||
|
|
1942
2169
|
call.questionDotToken ||
|
|
1943
2170
|
access.questionDotToken ||
|
|
1944
2171
|
access.name.text !== "call" ||
|
|
1945
2172
|
!ts.isPropertyAccessExpression(access.expression) ||
|
|
1946
|
-
call.arguments.some(ts.isSpreadElement))
|
|
2173
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
1947
2174
|
return null;
|
|
1948
2175
|
const method = access.expression;
|
|
1949
2176
|
if (method.questionDotToken ||
|
|
@@ -1955,10 +2182,10 @@ function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
|
|
|
1955
2182
|
!lowerer.isStdlibMember(method))
|
|
1956
2183
|
return null;
|
|
1957
2184
|
const loc = locOf(call);
|
|
1958
|
-
const receiver = call.arguments[0]
|
|
1959
|
-
? lowerer.lowerExprExpecting(call.arguments[0], DYN)
|
|
2185
|
+
const receiver = call.arguments.nodes[0]
|
|
2186
|
+
? lowerer.lowerExprExpecting(call.arguments.nodes[0], DYN)
|
|
1960
2187
|
: dynUndefinedExpr(loc);
|
|
1961
|
-
const args = call.arguments.slice(1).map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
2188
|
+
const args = call.arguments.nodes.slice(1).map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
1962
2189
|
return {
|
|
1963
2190
|
kind: "libCall",
|
|
1964
2191
|
fn: "dyn.arrayProtoCall",
|
|
@@ -1983,23 +2210,23 @@ function lowerObjectOwnPrototypeCall(lowerer, call, access) {
|
|
|
1983
2210
|
prototype.name.text !== "prototype" ||
|
|
1984
2211
|
!lowerer.isStdlibGlobal(prototype.expression, "Object") ||
|
|
1985
2212
|
!lowerer.isStdlibMember(method) ||
|
|
1986
|
-
call.arguments.some(ts.isSpreadElement))
|
|
2213
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
1987
2214
|
return null;
|
|
1988
|
-
return lowerObjectOwnCall(lowerer, call, call.arguments[0], call.arguments[1], call.arguments.slice(2), method.name.text);
|
|
2215
|
+
return lowerObjectOwnCall(lowerer, call, call.arguments.nodes[0], call.arguments.nodes[1], call.arguments.nodes.slice(2), method.name.text);
|
|
1989
2216
|
}
|
|
1990
2217
|
function lowerObjectOwnMethodCall(lowerer, call, access) {
|
|
1991
2218
|
const method = access.name.text;
|
|
1992
2219
|
if (call.questionDotToken ||
|
|
1993
2220
|
access.questionDotToken ||
|
|
1994
2221
|
(method !== "hasOwnProperty" && method !== "propertyIsEnumerable") ||
|
|
1995
|
-
call.arguments.some(ts.isSpreadElement))
|
|
2222
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
1996
2223
|
return null;
|
|
1997
2224
|
if (!lowerer.isStdlibMember(access)) {
|
|
1998
2225
|
const receiver = tryLowerExpression(lowerer, access.expression);
|
|
1999
2226
|
if (receiver?.type.kind !== "dyn")
|
|
2000
2227
|
return null;
|
|
2001
2228
|
}
|
|
2002
|
-
return lowerObjectOwnCall(lowerer, call, access.expression, call.arguments[0], call.arguments.slice(1), method, access);
|
|
2229
|
+
return lowerObjectOwnCall(lowerer, call, access.expression, call.arguments.nodes[0], call.arguments.nodes.slice(1), method, access);
|
|
2003
2230
|
}
|
|
2004
2231
|
/** ToPropertyKey for the scalar keys represented by native own-key
|
|
2005
2232
|
* probes. A lowered array-loop key may carry an undefined arm even when
|
|
@@ -2110,7 +2337,7 @@ methodAccess = null) {
|
|
|
2110
2337
|
loc,
|
|
2111
2338
|
};
|
|
2112
2339
|
if (methodAccess && nullProtoRecordShape(lowerer, type)) {
|
|
2113
|
-
result = guardNullProto(receiverRef, type.shapeId, `${
|
|
2340
|
+
result = guardNullProto(receiverRef, type.shapeId, `${ts.getTextOfNode(methodAccess)} is not a function`, result, loc);
|
|
2114
2341
|
}
|
|
2115
2342
|
}
|
|
2116
2343
|
else if (type.kind === "dyn") {
|
|
@@ -2225,16 +2452,17 @@ function lowerObjectPrototypeCall(lowerer, call, access) {
|
|
|
2225
2452
|
prototype.name.text !== "prototype" ||
|
|
2226
2453
|
!lowerer.isStdlibGlobal(prototype.expression, "Object") ||
|
|
2227
2454
|
!lowerer.isStdlibMember(method) ||
|
|
2228
|
-
call.arguments.some(ts.isSpreadElement))
|
|
2455
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
2229
2456
|
return null;
|
|
2230
2457
|
const loc = locOf(call);
|
|
2231
|
-
if (call.arguments.length === 0)
|
|
2458
|
+
if (call.arguments.nodes.length === 0)
|
|
2232
2459
|
return { kind: "strLit", value: "[object Undefined]", type: STRING, loc };
|
|
2233
|
-
const receiverNode = call.arguments[0];
|
|
2460
|
+
const receiverNode = call.arguments.nodes[0];
|
|
2234
2461
|
const immediate = immediateObjectTagReceiver(lowerer, receiverNode);
|
|
2235
2462
|
const receiver = immediate?.effect ?? lowerer.lowerExpr(receiverNode);
|
|
2236
2463
|
const tag = immediate?.tag ?? objectToStringTag(lowerer, receiver.type);
|
|
2237
|
-
|
|
2464
|
+
// A generator object answers its tag through its checked capsule.
|
|
2465
|
+
if (tag === null && receiver.type.kind !== "dyn" && receiver.type.kind !== "generator") {
|
|
2238
2466
|
lowerer.noLowering("Object.prototype.toString.call over a " + lowerer.fmt(receiver.type) + " receiver", receiverNode);
|
|
2239
2467
|
}
|
|
2240
2468
|
const stmts = [];
|
|
@@ -2248,11 +2476,17 @@ function lowerObjectPrototypeCall(lowerer, call, access) {
|
|
|
2248
2476
|
stmts.push({ kind: "varDecl", localId: local.id, init: receiver, loc });
|
|
2249
2477
|
ref = varRef(local.id, receiver.type, loc);
|
|
2250
2478
|
}
|
|
2251
|
-
for (const extra of call.arguments.slice(1)) {
|
|
2479
|
+
for (const extra of call.arguments.nodes.slice(1)) {
|
|
2252
2480
|
stmts.push({ kind: "exprStmt", expr: lowerer.lowerExpr(extra), loc: locOf(extra) });
|
|
2253
2481
|
}
|
|
2254
2482
|
const result = tag === null
|
|
2255
|
-
? {
|
|
2483
|
+
? {
|
|
2484
|
+
kind: "libCall",
|
|
2485
|
+
fn: "dyn.objectTag",
|
|
2486
|
+
args: [ref.type.kind === "generator" ? lowerer.coerceToExpected(ref, DYN) : ref],
|
|
2487
|
+
type: STRING,
|
|
2488
|
+
loc,
|
|
2489
|
+
}
|
|
2256
2490
|
: { kind: "strLit", value: "[object " + tag + "]", type: STRING, loc };
|
|
2257
2491
|
return { kind: "seqExpr", stmts, result, type: STRING, loc };
|
|
2258
2492
|
}
|
|
@@ -2274,7 +2508,7 @@ function lowerDynamicStringPrototypeCall(lowerer, call, methodAccess, receiver,
|
|
|
2274
2508
|
};
|
|
2275
2509
|
const overrides = [];
|
|
2276
2510
|
try {
|
|
2277
|
-
for (const node of call.arguments.slice(1)) {
|
|
2511
|
+
for (const node of call.arguments.nodes.slice(1)) {
|
|
2278
2512
|
const undefinedValue = lowerStaticallyUndefinedArgument(lowerer, node);
|
|
2279
2513
|
const value = undefinedValue ?? lowerer.lowerExpr(node);
|
|
2280
2514
|
let ref;
|
|
@@ -2296,7 +2530,7 @@ function lowerDynamicStringPrototypeCall(lowerer, call, methodAccess, receiver,
|
|
|
2296
2530
|
overrides.push({ node, previous: lowerer.chainRecvByNode.get(node) });
|
|
2297
2531
|
lowerer.chainRecvByNode.set(node, ref);
|
|
2298
2532
|
}
|
|
2299
|
-
const result = lowerStringMethodCallWithOptionalArgs(lowerer, call, methodAccess, () => converted, call.arguments.slice(1));
|
|
2533
|
+
const result = lowerStringMethodCallWithOptionalArgs(lowerer, call, methodAccess, () => converted, call.arguments.nodes.slice(1));
|
|
2300
2534
|
return result ? { kind: "seqExpr", stmts, result, type: result.type, loc } : null;
|
|
2301
2535
|
}
|
|
2302
2536
|
finally {
|
|
@@ -2321,7 +2555,7 @@ function lowerStringPrototypeCall(lowerer, call, access) {
|
|
|
2321
2555
|
!STRING_INDEX_METHODS.has(methodAccess.name.text)) ||
|
|
2322
2556
|
!lowerer.isStdlibMember(methodAccess))
|
|
2323
2557
|
return null;
|
|
2324
|
-
if (call.arguments.some(ts.isSpreadElement))
|
|
2558
|
+
if (call.arguments.nodes.some(ts.isSpreadElement))
|
|
2325
2559
|
return null;
|
|
2326
2560
|
const entry = STR_METHODS[methodAccess.name.text];
|
|
2327
2561
|
const indexMethod = STRING_INDEX_METHODS.has(methodAccess.name.text)
|
|
@@ -2339,12 +2573,12 @@ function lowerStringPrototypeCall(lowerer, call, access) {
|
|
|
2339
2573
|
: methodAccess.name.text;
|
|
2340
2574
|
const loc = locOf(call);
|
|
2341
2575
|
const nullishError = nodeThrowExpr(1, "", `String.prototype.${method} called on null or undefined`, resultType, loc);
|
|
2342
|
-
const receiverNode = call.arguments[0];
|
|
2576
|
+
const receiverNode = call.arguments.nodes[0];
|
|
2343
2577
|
if (!receiverNode)
|
|
2344
2578
|
return nullishError;
|
|
2345
2579
|
// Receiver coercion runs after .call has evaluated its arguments; keep
|
|
2346
2580
|
// contextual wrapper lowering on forms without later method arguments.
|
|
2347
|
-
const immediateWrapper = entry?.maxArgs === 0 && call.arguments.length === 1
|
|
2581
|
+
const immediateWrapper = entry?.maxArgs === 0 && call.arguments.nodes.length === 1
|
|
2348
2582
|
? immediatePrimitiveWrapperToString(lowerer, receiverNode)
|
|
2349
2583
|
: null;
|
|
2350
2584
|
const receiverValue = immediateWrapper ?? lowerer.lowerExpr(receiverNode);
|
|
@@ -2357,7 +2591,10 @@ function lowerStringPrototypeCall(lowerer, call, access) {
|
|
|
2357
2591
|
?.arms.every((arm) => isUnitType(arm) || arm.kind === "void") ??
|
|
2358
2592
|
false));
|
|
2359
2593
|
if (nullish) {
|
|
2360
|
-
const values = [
|
|
2594
|
+
const values = [
|
|
2595
|
+
receiverValue,
|
|
2596
|
+
...call.arguments.nodes.slice(1).map((arg) => lowerer.lowerExpr(arg)),
|
|
2597
|
+
];
|
|
2361
2598
|
return {
|
|
2362
2599
|
kind: "seqExpr",
|
|
2363
2600
|
stmts: values
|
|
@@ -2387,28 +2624,28 @@ function lowerStringPrototypeCall(lowerer, call, access) {
|
|
|
2387
2624
|
// Other methods convert object receivers before lowering their arguments;
|
|
2388
2625
|
// padding uses a helper that delays conversion until every argument is ready.
|
|
2389
2626
|
const objectWithoutMethodArgs = entry?.maxArgs === 0 &&
|
|
2390
|
-
call.arguments.length === 1 &&
|
|
2627
|
+
call.arguments.nodes.length === 1 &&
|
|
2391
2628
|
(receiverType.kind === "record" ||
|
|
2392
2629
|
receiverType.kind === "array" ||
|
|
2393
2630
|
receiverType.kind === "object");
|
|
2394
2631
|
if (padding && !scalar && lowerer.dynConvertible(receiverType)) {
|
|
2395
|
-
return lowerStringPaddingCall(lowerer, call, entry.method, lowerer.coerceToExpected(receiverValue, DYN), receiverNode, call.arguments.slice(1));
|
|
2632
|
+
return lowerStringPaddingCall(lowerer, call, entry.method, lowerer.coerceToExpected(receiverValue, DYN), receiverNode, call.arguments.nodes.slice(1));
|
|
2396
2633
|
}
|
|
2397
2634
|
if (!scalar && !objectWithoutMethodArgs) {
|
|
2398
2635
|
lowerer.noLowering(`String.prototype.${methodAccess.name.text}.call with ${lowerer.fmt(receiverType)} receivers`, call);
|
|
2399
2636
|
}
|
|
2400
2637
|
if (indexMethod)
|
|
2401
|
-
return lowerStringIndexCall(lowerer, call, indexMethod, receiverValue, receiverNode, call.arguments.slice(1));
|
|
2638
|
+
return lowerStringIndexCall(lowerer, call, indexMethod, receiverValue, receiverNode, call.arguments.nodes.slice(1));
|
|
2402
2639
|
if (!entry)
|
|
2403
2640
|
return null;
|
|
2404
2641
|
if (padding) {
|
|
2405
|
-
return lowerStringPaddingCall(lowerer, call, entry.method, receiverValue, receiverNode, call.arguments.slice(1));
|
|
2642
|
+
return lowerStringPaddingCall(lowerer, call, entry.method, receiverValue, receiverNode, call.arguments.nodes.slice(1));
|
|
2406
2643
|
}
|
|
2407
2644
|
if (entry.method === "split") {
|
|
2408
|
-
return lowerStringSplitCall(lowerer, call, receiverValue, receiverNode, call.arguments.slice(1));
|
|
2645
|
+
return lowerStringSplitCall(lowerer, call, receiverValue, receiverNode, call.arguments.nodes.slice(1));
|
|
2409
2646
|
}
|
|
2410
2647
|
const receiver = lowerer.ensureString(receiverValue, receiverNode);
|
|
2411
|
-
return lowerStringMethodCallWithOptionalArgs(lowerer, call, methodAccess, () => receiver, call.arguments.slice(1));
|
|
2648
|
+
return lowerStringMethodCallWithOptionalArgs(lowerer, call, methodAccess, () => receiver, call.arguments.nodes.slice(1));
|
|
2412
2649
|
}
|
|
2413
2650
|
function lowerScalarUnionNumber(lowerer, arg, node, loc) {
|
|
2414
2651
|
if (arg.type.kind !== "union" ||
|
|
@@ -2523,9 +2760,29 @@ function lowerOptionalStringNumber(lowerer, arg, loc, fn = "num.fromString", lab
|
|
|
2523
2760
|
}
|
|
2524
2761
|
return { kind: "call", callee: helper, args: [arg], type: F64, loc };
|
|
2525
2762
|
}
|
|
2526
|
-
/**
|
|
2527
|
-
*
|
|
2528
|
-
|
|
2763
|
+
/** `s[Symbol.iterator]()` on a string-typed receiver: the generator over
|
|
2764
|
+
* its code points. Null for other element calls. */
|
|
2765
|
+
function lowerStringIteratorCall(lowerer, call, access) {
|
|
2766
|
+
let key = access.argumentExpression;
|
|
2767
|
+
while (ts.isParenthesizedExpression(key))
|
|
2768
|
+
key = key.expression;
|
|
2769
|
+
if (!ts.isPropertyAccessExpression(key) ||
|
|
2770
|
+
lowerer.stdlibGlobalMember(key, "Symbol") !== "iterator")
|
|
2771
|
+
return null;
|
|
2772
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(access.expression))?.kind !== "string")
|
|
2773
|
+
return null;
|
|
2774
|
+
const type = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
2775
|
+
if (type?.kind !== "generator")
|
|
2776
|
+
return null;
|
|
2777
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
2778
|
+
const value = lowerStringIteratorValue(lowerer, receiver, type, locOf(call));
|
|
2779
|
+
if (!value)
|
|
2780
|
+
lowerer.unsupported("SC1090", call, "this string iterator type");
|
|
2781
|
+
return value;
|
|
2782
|
+
}
|
|
2783
|
+
/** Iterator types with checked runtime receivers, whose helper calls lower
|
|
2784
|
+
* in lowerGeneratorHelperCall. */
|
|
2785
|
+
const CHECKED_ITERATOR_TYPES = new Set(["MapIterator", "SetIterator"]);
|
|
2529
2786
|
const ITERATOR_HELPER_METHODS = new Set([
|
|
2530
2787
|
"map",
|
|
2531
2788
|
"filter",
|
|
@@ -2539,6 +2796,13 @@ const ITERATOR_HELPER_METHODS = new Set([
|
|
|
2539
2796
|
"every",
|
|
2540
2797
|
"find",
|
|
2541
2798
|
]);
|
|
2799
|
+
/** A call expression, through parentheses: its value has no other holder. */
|
|
2800
|
+
function isFreshCallResult(node) {
|
|
2801
|
+
let e = node;
|
|
2802
|
+
while (ts.isParenthesizedExpression(e))
|
|
2803
|
+
e = e.expression;
|
|
2804
|
+
return ts.isCallExpression(e);
|
|
2805
|
+
}
|
|
2542
2806
|
/** METHOD calls on dyn receivers (`pkg.name.replace(...)`, `rawName.split`,
|
|
2543
2807
|
* `ws.packages.filter(...)` — JSON.parse-derived values): validate the
|
|
2544
2808
|
* receiver's dyn kind, extract, and ride the STATIC method machinery — the
|
|
@@ -2552,7 +2816,7 @@ const ITERATOR_HELPER_METHODS = new Set([
|
|
|
2552
2816
|
* the dyn array and validated-extracts the survivors into the element type
|
|
2553
2817
|
* the checker committed the result to. Null when the receiver isn't a dyn
|
|
2554
2818
|
* value or the method isn't claimable (the method-call fence stays). */
|
|
2555
|
-
function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
2819
|
+
function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = false) {
|
|
2556
2820
|
if (lowerer.chainBlocked(call, access))
|
|
2557
2821
|
return null;
|
|
2558
2822
|
if (stdlibGlobalNameOf(lowerer, access.expression) !== null) {
|
|
@@ -2570,8 +2834,16 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2570
2834
|
// array — scalar narrowings bridge through maybeNarrow's dynCheck and
|
|
2571
2835
|
// take the ordinary typed paths, but there is no static home for an
|
|
2572
2836
|
// any-elemented array). Typed receivers keep their own lowerings.
|
|
2573
|
-
|
|
2837
|
+
// An optional step the chain already guarded (`s?.m(x)`) has a receiver
|
|
2838
|
+
// proven non-nullish.
|
|
2839
|
+
const rawRecvTs = lowerer.typeOf(access.expression);
|
|
2840
|
+
const recvTs = access.questionDotToken !== undefined && lowerer.chainHandled.has(access)
|
|
2841
|
+
? lowerer.checker.getNonNullableType(rawRecvTs)
|
|
2842
|
+
: rawRecvTs;
|
|
2574
2843
|
if (lowerer.classImplementedProtocol(recvTs)) {
|
|
2844
|
+
const viewed = pickViewGenericMethodCall(lowerer, call, access, recvTs);
|
|
2845
|
+
if (viewed)
|
|
2846
|
+
return viewed;
|
|
2575
2847
|
const property = lowerer.checker.getPropertyOfType(recvTs, access.name.text);
|
|
2576
2848
|
if (property &&
|
|
2577
2849
|
isGenericCallableMemberType(lowerer.checker.getTypeOfSymbol(property), lowerer.checker))
|
|
@@ -2579,15 +2851,14 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2579
2851
|
}
|
|
2580
2852
|
const recvSymbol = recvTs.getSymbol();
|
|
2581
2853
|
if (recvSymbol &&
|
|
2582
|
-
|
|
2854
|
+
CHECKED_ITERATOR_TYPES.has(ts.symbolName(recvSymbol)) &&
|
|
2583
2855
|
lowerer.isStdlibSymbol(recvSymbol) &&
|
|
2584
2856
|
ITERATOR_HELPER_METHODS.has(access.name.text) &&
|
|
2585
2857
|
lowerer.isStdlibMember(access)) {
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
lowerer.noLowering(`${recvSymbol.name}.${access.name.text}`, call, "iterator helpers lower on chains from arr.values() or arr.entries() that end in a terminal (toArray, forEach, reduce, some, every, find) — spread the string first: [...s].values()");
|
|
2858
|
+
const helper = lowerGeneratorHelperCall(lowerer, call, access);
|
|
2859
|
+
if (helper)
|
|
2860
|
+
return helper;
|
|
2861
|
+
lowerer.noLowering(`collection iterator .${access.name.text}()`, call, "iterator helpers on Map/Set iterators are called directly on the iterator, without optional chaining");
|
|
2591
2862
|
}
|
|
2592
2863
|
const arrayReceiver = lowerer.checker.isArrayType(recvTs);
|
|
2593
2864
|
const anyArray = arrayReceiver &&
|
|
@@ -2627,7 +2898,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2627
2898
|
type: DYN,
|
|
2628
2899
|
loc,
|
|
2629
2900
|
};
|
|
2630
|
-
if (call.arguments.some(ts.isSpreadElement)) {
|
|
2901
|
+
if (call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
2631
2902
|
lowerer.unsupported("SC1090", call, "spread arguments in callable property calls");
|
|
2632
2903
|
}
|
|
2633
2904
|
return {
|
|
@@ -2637,8 +2908,8 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2637
2908
|
kind: "dynCall",
|
|
2638
2909
|
callee: member,
|
|
2639
2910
|
receiver,
|
|
2640
|
-
calleeName:
|
|
2641
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
2911
|
+
calleeName: ts.getTextOfNode(access),
|
|
2912
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
2642
2913
|
type: DYN,
|
|
2643
2914
|
loc,
|
|
2644
2915
|
},
|
|
@@ -2651,8 +2922,14 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2651
2922
|
if (info)
|
|
2652
2923
|
return lowerStaticMethodCall(lowerer, call, access);
|
|
2653
2924
|
}
|
|
2925
|
+
// A possibly missing element of a class-typed array (`items[i]`) is
|
|
2926
|
+
// the receiver's class or undefined. The class method call checks for
|
|
2927
|
+
// undefined itself, as it does in TypeScript.
|
|
2928
|
+
const presentArm = probed?.type.kind === "union" ? lowerer.stripUndefinedArm(probed.type) : null;
|
|
2929
|
+
if (presentArm?.kind === "object" && typeEquals(presentArm, lowerer.mapTypeOf(recvTs) ?? DYN))
|
|
2930
|
+
return null;
|
|
2654
2931
|
if (probed?.type.kind === "union" &&
|
|
2655
|
-
isJsSourceFile(
|
|
2932
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
2656
2933
|
lowerer.unions
|
|
2657
2934
|
.get(probed.type.unionId)
|
|
2658
2935
|
?.arms.every((arm) => isUnitType(arm) ||
|
|
@@ -2687,13 +2964,47 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2687
2964
|
return (lowerRegexMethodCall(lowerer, call, access, () => recv) ??
|
|
2688
2965
|
lowerStringMethodCall(lowerer, call, access, () => recv));
|
|
2689
2966
|
}
|
|
2967
|
+
// A checker-untyped JS binding holding `string | undefined` (string-
|
|
2968
|
+
// width's `const visibleSegment = baseVisible(segment)` after an
|
|
2969
|
+
// `=== undefined` guard the checker cannot see through): no typed
|
|
2970
|
+
// lowering claims the union, so a String method boxes it and takes the
|
|
2971
|
+
// dyn receiver path, whose undefined/null arms throw Node's read errors.
|
|
2972
|
+
if (checkerUntyped &&
|
|
2973
|
+
recv.type.kind === "union" &&
|
|
2974
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
2975
|
+
isStringMethodName(access.name.text) &&
|
|
2976
|
+
lowerer.unions
|
|
2977
|
+
.get(recv.type.unionId)
|
|
2978
|
+
?.arms.every((arm) => arm.kind === "string" || isUnitType(arm)) === true &&
|
|
2979
|
+
lowerer.dynConvertible(recv.type)) {
|
|
2980
|
+
recv = lowerer.coerceToExpected(recv, DYN);
|
|
2981
|
+
}
|
|
2982
|
+
// A native handle read through `as any` (`(hash as any).update(x)`)
|
|
2983
|
+
// dispatches through the handle, as the same value held in an
|
|
2984
|
+
// 'unknown' slot does.
|
|
2985
|
+
if (checkerUntyped && DYN_HANDLE_KINDS.has(recv.type.kind))
|
|
2986
|
+
recv = lowerer.coerceToExpected(recv, DYN);
|
|
2987
|
+
// The last-resort retry (boxTypedTemporary — every other lowering
|
|
2988
|
+
// already declined): a checker-`any` receiver whose value is a FRESH
|
|
2989
|
+
// typed result of an earlier step in the chain (`out.split("\n")`
|
|
2990
|
+
// extracted the string and answered a native string[]) has no typed
|
|
2991
|
+
// home under its `any` spelling, so it boxes into the checked-dynamic
|
|
2992
|
+
// tree and the call dispatches on the runtime kind — `.map`, `.pop`,
|
|
2993
|
+
// `.filter` on that array run JS-exact. Only call results qualify:
|
|
2994
|
+
// the box copies, and a temporary has no other holder to observe it.
|
|
2995
|
+
if (boxTypedTemporary &&
|
|
2996
|
+
checkerUntyped &&
|
|
2997
|
+
recv.type.kind !== "dyn" &&
|
|
2998
|
+
isFreshCallResult(access.expression) &&
|
|
2999
|
+
lowerer.dynConvertible(recv.type))
|
|
3000
|
+
recv = lowerer.coerceToExpected(recv, DYN);
|
|
2690
3001
|
if (recv.type.kind !== "dyn")
|
|
2691
3002
|
return null;
|
|
2692
3003
|
if (access.name.text === "normalize" &&
|
|
2693
|
-
call.arguments.length <= 1 &&
|
|
2694
|
-
!call.arguments.some(ts.isSpreadElement)) {
|
|
3004
|
+
call.arguments.nodes.length <= 1 &&
|
|
3005
|
+
!call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
2695
3006
|
const loc = locOf(call);
|
|
2696
|
-
const hasArgument = call.arguments.length === 1;
|
|
3007
|
+
const hasArgument = call.arguments.nodes.length === 1;
|
|
2697
3008
|
const name = `%dyn.string.normalize:${hasArgument ? 1 : 0}`;
|
|
2698
3009
|
if (!lowerer.liftedFns.some((fn) => fn.name === name)) {
|
|
2699
3010
|
const value = varRef("receiver", DYN, loc);
|
|
@@ -2742,7 +3053,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2742
3053
|
kind: "dynInvoke",
|
|
2743
3054
|
recv: value,
|
|
2744
3055
|
method: "normalize",
|
|
2745
|
-
calleeName:
|
|
3056
|
+
calleeName: ts.getTextOfNode(access),
|
|
2746
3057
|
args: hasArgument ? [argument] : [],
|
|
2747
3058
|
type: DYN,
|
|
2748
3059
|
loc,
|
|
@@ -2757,8 +3068,8 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2757
3068
|
callee: name,
|
|
2758
3069
|
args: [
|
|
2759
3070
|
recv,
|
|
2760
|
-
call.arguments[0]
|
|
2761
|
-
? lowerer.lowerExprExpecting(call.arguments[0], DYN)
|
|
3071
|
+
call.arguments.nodes[0]
|
|
3072
|
+
? lowerer.lowerExprExpecting(call.arguments.nodes[0], DYN)
|
|
2762
3073
|
: dynUndefinedExpr(loc),
|
|
2763
3074
|
],
|
|
2764
3075
|
type: DYN,
|
|
@@ -2777,9 +3088,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2777
3088
|
// Those are not stored members of a checked-dynamic object, so
|
|
2778
3089
|
// dynKeyGet cannot stand in for JavaScript's prototype lookup. Only
|
|
2779
3090
|
// an authored declaration can justify the own-member path.
|
|
2780
|
-
const authored = lowerer.
|
|
2781
|
-
.declarationsOf(prop)
|
|
2782
|
-
.some((decl) => !lowerer.isStdlibFile(decl.getSourceFile()));
|
|
3091
|
+
const authored = prop.declarations.some((decl) => !lowerer.isStdlibFile(ts.getSourceFileOfNode(decl)));
|
|
2783
3092
|
return (authored &&
|
|
2784
3093
|
lowerer.checker.getCallSignatures(lowerer.checker.getTypeOfSymbol(prop)).length > 0);
|
|
2785
3094
|
})();
|
|
@@ -2803,22 +3112,53 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2803
3112
|
return (lowerRegexMethodCall(lowerer, call, access, checked) ??
|
|
2804
3113
|
lowerStringMethodCall(lowerer, call, access, checked));
|
|
2805
3114
|
}
|
|
3115
|
+
// String/Number methods the runtime dispatch has no answer for
|
|
3116
|
+
// (codePointAt, substr, toLocaleLowerCase, toPrecision, ...): a string
|
|
3117
|
+
// or number receiver runs the typed lowering, every other kind keeps the
|
|
3118
|
+
// runtime dispatch.
|
|
3119
|
+
if (!ownCallable &&
|
|
3120
|
+
!call.questionDotToken &&
|
|
3121
|
+
!access.questionDotToken &&
|
|
3122
|
+
isDynPrimitiveKindMethod(access.name.text) &&
|
|
3123
|
+
!lowerer.chainBlocked(access, call)) {
|
|
3124
|
+
const primitive = lowerDynPrimitiveMethodCall(lowerer, call, access.name.text, ts.getTextOfNode(access), recv);
|
|
3125
|
+
if (primitive)
|
|
3126
|
+
return primitive;
|
|
3127
|
+
}
|
|
2806
3128
|
// The argument is a radix for bigint and an encoding for Buffer.
|
|
2807
3129
|
// Preserve its runtime value so receiver dispatch can choose correctly.
|
|
2808
|
-
if (access.name.text === "toString" && call.arguments.length <= 1) {
|
|
2809
|
-
const argument = call.arguments[0];
|
|
3130
|
+
if (access.name.text === "toString" && call.arguments.nodes.length <= 1) {
|
|
3131
|
+
const argument = call.arguments.nodes[0];
|
|
2810
3132
|
return {
|
|
2811
3133
|
kind: "libCall",
|
|
2812
3134
|
fn: "dyn.toString",
|
|
2813
3135
|
args: [
|
|
2814
3136
|
recv,
|
|
2815
3137
|
argument ? lowerer.lowerExprExpecting(argument, DYN) : dynUndefinedExpr(locOf(call)),
|
|
2816
|
-
{ kind: "strLit", value:
|
|
3138
|
+
{ kind: "strLit", value: ts.getTextOfNode(access), type: STRING, loc: locOf(call) },
|
|
2817
3139
|
],
|
|
2818
3140
|
type: STRING,
|
|
2819
3141
|
loc: locOf(call),
|
|
2820
3142
|
};
|
|
2821
3143
|
}
|
|
3144
|
+
// Every dyn kind's prototype chain declares valueOf, and the runtime
|
|
3145
|
+
// answers each kind's own: primitives and plain objects themselves, a
|
|
3146
|
+
// Date its time value, an own or inherited valueOf member its result.
|
|
3147
|
+
if (access.name.text === "valueOf" && call.arguments.nodes.length === 0) {
|
|
3148
|
+
const webAssembly = lowerWebAssemblyValueOf(lowerer, access.expression, recv, locOf(call));
|
|
3149
|
+
if (webAssembly !== null)
|
|
3150
|
+
return webAssembly;
|
|
3151
|
+
return {
|
|
3152
|
+
kind: "libCall",
|
|
3153
|
+
fn: "dyn.valueOf",
|
|
3154
|
+
args: [
|
|
3155
|
+
recv,
|
|
3156
|
+
{ kind: "strLit", value: ts.getTextOfNode(access), type: STRING, loc: locOf(call) },
|
|
3157
|
+
],
|
|
3158
|
+
type: DYN,
|
|
3159
|
+
loc: locOf(call),
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
2822
3162
|
// SHARED prototype names with a runtime dispatch (scr_dyn_invoke):
|
|
2823
3163
|
// push/slice/join/forEach/map/apply/... dispatch on the receiver's
|
|
2824
3164
|
// RUNTIME kind — the honest answer for names more than one dyn-
|
|
@@ -2839,10 +3179,19 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2839
3179
|
?.arms.every((arm) => arm.kind === "object" &&
|
|
2840
3180
|
lowerer.classes.get(arm.className)?.fields.has(access.name.text)))
|
|
2841
3181
|
return true;
|
|
3182
|
+
// A standard-library member spelled as a function-typed property
|
|
3183
|
+
// (undici-types declares Headers.append/forEach/... and the body mixin
|
|
3184
|
+
// as `readonly append: (...) => void`; scriptc's own declarations use
|
|
3185
|
+
// methods) is still the handle's native method: it takes the shared
|
|
3186
|
+
// receiver dispatch below either way (which also calls a plain object's
|
|
3187
|
+
// own member), so the lowering does not depend on which declaration
|
|
3188
|
+
// file supplies the type.
|
|
3189
|
+
const libMethod = prop !== undefined &&
|
|
3190
|
+
prop.declarations.length > 0 &&
|
|
3191
|
+
prop.declarations.every((decl) => lowerer.isStdlibFile(decl.getSourceFile()));
|
|
2842
3192
|
return (prop !== undefined &&
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
.some((decl) => ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl)));
|
|
3193
|
+
!libMethod &&
|
|
3194
|
+
prop.declarations.some((decl) => ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl)));
|
|
2846
3195
|
})();
|
|
2847
3196
|
// Protocol methods keep their static signature: instances of the
|
|
2848
3197
|
// implementing classes call the native method.
|
|
@@ -2872,7 +3221,19 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2872
3221
|
// its name overlaps a primitive prototype (`colors.bold(...)`): the
|
|
2873
3222
|
// source value was compiled from that object shape, while genuinely
|
|
2874
3223
|
// untyped/any receivers retain the runtime-kind ambiguity and fence.
|
|
2875
|
-
|
|
3224
|
+
// A name only String.prototype declares (`bold`, `italics`, `link`,
|
|
3225
|
+
// ...) on a checker-untyped receiver: every other dyn kind answers its
|
|
3226
|
+
// own or inherited member exactly like a non-prototype name (chalk's
|
|
3227
|
+
// `chalk.red.bold(...)` reads a prototype getter of a function), so
|
|
3228
|
+
// only a string receiver keeps the refusal, deferred to run time.
|
|
3229
|
+
// The same holds when only the MEMBER is checker-untyped: TypeScript
|
|
3230
|
+
// importing chalk's JavaScript source types the default export as a
|
|
3231
|
+
// plain function, so `chalk.bold` reads as `any` on a typed receiver.
|
|
3232
|
+
const stringOnlyName = (checkerUntyped ||
|
|
3233
|
+
(lowerer.typeOf(access).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0) &&
|
|
3234
|
+
!ownCallable &&
|
|
3235
|
+
DYN_STRING_PROTO_ONLY_NAMES.has(access.name.text);
|
|
3236
|
+
if (DYN_PROTO_METHOD_NAMES.has(access.name.text) && !ownCallable && !stringOnlyName)
|
|
2876
3237
|
return null;
|
|
2877
3238
|
// Optional forms (`obj.cb?.()`, `obj?.cb()`) belong to the chain
|
|
2878
3239
|
// machinery's short-circuit semantics — not modeled here yet.
|
|
@@ -2881,6 +3242,22 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2881
3242
|
const loc = locOf(call);
|
|
2882
3243
|
const receiverLocal = lowerer.declareHiddenLocal("%dynCallReceiver", DYN);
|
|
2883
3244
|
const receiver = { kind: "varRef", localId: receiverLocal.id, type: DYN, loc };
|
|
3245
|
+
// The string refusal throws in place of the member read (a seqExpr
|
|
3246
|
+
// statement cannot leave the expression).
|
|
3247
|
+
const stringRefusal = (read) => {
|
|
3248
|
+
if (!stringOnlyName)
|
|
3249
|
+
return read;
|
|
3250
|
+
const sf = ts.getSourceFileOfNode(call);
|
|
3251
|
+
const line = ts.getLineAndCharacterOfPosition(sf, ts.tokenStartOfNode(call)).line + 1;
|
|
3252
|
+
return {
|
|
3253
|
+
kind: "ternary",
|
|
3254
|
+
cond: { kind: "dynTest", test: "string", value: receiver, type: BOOL, loc },
|
|
3255
|
+
then: nodeThrowExpr(0, "SC1090", `method calls like '${ts.getTextOfNode(access)}' on a string are not supported yet [SC1090 at ${sf.fileName}:${line}]`, DYN, loc),
|
|
3256
|
+
else_: read,
|
|
3257
|
+
type: DYN,
|
|
3258
|
+
loc,
|
|
3259
|
+
};
|
|
3260
|
+
};
|
|
2884
3261
|
const member = {
|
|
2885
3262
|
kind: "dynKeyGet",
|
|
2886
3263
|
key: { kind: "strLit", value: access.name.text, type: STRING, loc: locOf(access) },
|
|
@@ -2892,15 +3269,15 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2892
3269
|
const callee = varRef(calleeLocal.id, DYN, loc);
|
|
2893
3270
|
const stmts = [
|
|
2894
3271
|
{ kind: "varDecl", localId: receiverLocal.id, init: recv, loc },
|
|
2895
|
-
{ kind: "varDecl", localId: calleeLocal.id, init: member, loc },
|
|
3272
|
+
{ kind: "varDecl", localId: calleeLocal.id, init: stringRefusal(member), loc },
|
|
2896
3273
|
];
|
|
2897
|
-
if (call.arguments.some(ts.isSpreadElement)) {
|
|
3274
|
+
if (call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
2898
3275
|
const spread = lowerSpreadArgsCall(lowerer, call, callee, loc);
|
|
2899
3276
|
if (spread?.kind === "dynCall")
|
|
2900
3277
|
return { kind: "seqExpr", stmts, result: { ...spread, receiver }, type: DYN, loc };
|
|
2901
3278
|
lowerer.unsupported("SC1090", call, "spread arguments in calls through 'unknown' values");
|
|
2902
3279
|
}
|
|
2903
|
-
const args = call.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
3280
|
+
const args = call.arguments.nodes.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
2904
3281
|
return {
|
|
2905
3282
|
kind: "seqExpr",
|
|
2906
3283
|
stmts,
|
|
@@ -2908,7 +3285,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access) {
|
|
|
2908
3285
|
kind: "dynCall",
|
|
2909
3286
|
callee,
|
|
2910
3287
|
receiver,
|
|
2911
|
-
calleeName:
|
|
3288
|
+
calleeName: ts.getTextOfNode(access),
|
|
2912
3289
|
args,
|
|
2913
3290
|
type: DYN,
|
|
2914
3291
|
loc,
|
|
@@ -2999,6 +3376,30 @@ const DYN_PROTO_METHOD_NAMES = new Set([
|
|
|
2999
3376
|
"toFixed",
|
|
3000
3377
|
"toPrecision",
|
|
3001
3378
|
]);
|
|
3379
|
+
/** The DYN_PROTO_METHOD_NAMES that only String.prototype declares among
|
|
3380
|
+
* the dyn-representable kinds' prototypes. */
|
|
3381
|
+
const DYN_STRING_PROTO_ONLY_NAMES = new Set([
|
|
3382
|
+
"anchor",
|
|
3383
|
+
"big",
|
|
3384
|
+
"blink",
|
|
3385
|
+
"bold",
|
|
3386
|
+
"codePointAt",
|
|
3387
|
+
"fixed",
|
|
3388
|
+
"fontcolor",
|
|
3389
|
+
"fontsize",
|
|
3390
|
+
"isWellFormed",
|
|
3391
|
+
"italics",
|
|
3392
|
+
"link",
|
|
3393
|
+
"localeCompare",
|
|
3394
|
+
"normalize",
|
|
3395
|
+
"small",
|
|
3396
|
+
"strike",
|
|
3397
|
+
"sub",
|
|
3398
|
+
"sup",
|
|
3399
|
+
"toLocaleLowerCase",
|
|
3400
|
+
"toLocaleUpperCase",
|
|
3401
|
+
"toWellFormed",
|
|
3402
|
+
]);
|
|
3002
3403
|
/** The SHARED prototype names scr_dyn_invoke dispatches at runtime (the
|
|
3003
3404
|
* subset of DYN_PROTO_METHOD_NAMES with a receiver-kind dispatch): the
|
|
3004
3405
|
* runtime runs the real method for the receiver's kind, throws Node's
|
|
@@ -3163,10 +3564,10 @@ const DYN_DISPATCH_METHODS = new Set([
|
|
|
3163
3564
|
]);
|
|
3164
3565
|
export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayReceiver) {
|
|
3165
3566
|
const method = access.name.text;
|
|
3166
|
-
if ((!DYN_DISPATCH_METHODS.has(method) && !isJsSourceFile(
|
|
3567
|
+
if ((!DYN_DISPATCH_METHODS.has(method) && !isJsSourceFile(ts.getSourceFileOfNode(call))) ||
|
|
3167
3568
|
lowerer.chainBlocked(call, access))
|
|
3168
3569
|
return null;
|
|
3169
|
-
if (call.arguments.some((arg) => ts.isSpreadElement(arg))) {
|
|
3570
|
+
if (call.arguments.nodes.some((arg) => ts.isSpreadElement(arg))) {
|
|
3170
3571
|
const loc = locOf(call);
|
|
3171
3572
|
const local = lowerer.declareHiddenLocal("%spreadReceiver", DYN);
|
|
3172
3573
|
const receiver = varRef(local.id, DYN, loc);
|
|
@@ -3195,9 +3596,11 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3195
3596
|
};
|
|
3196
3597
|
lowerer.unsupported("SC1090", call, "spread arguments in calls through 'unknown' values");
|
|
3197
3598
|
}
|
|
3198
|
-
const predicate = method === "filter" && call.arguments
|
|
3599
|
+
const predicate = method === "filter" && call.arguments.nodes[0]
|
|
3600
|
+
? lowerer.lowerExpr(call.arguments.nodes[0])
|
|
3601
|
+
: null;
|
|
3199
3602
|
if (arrayReceiver && predicate?.type.kind === "func" && predicate.type.ret.kind === "void") {
|
|
3200
|
-
lowerer.unsupported("SC1090", call.arguments[0], "'.filter()' with a void-returning predicate (the callback return value is erased before its truthiness can be tested)");
|
|
3603
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "'.filter()' with a void-returning predicate (the callback return value is erased before its truthiness can be tested)");
|
|
3201
3604
|
}
|
|
3202
3605
|
// A dynamic argument array consumed immediately by the fixed-arity arrow
|
|
3203
3606
|
// apply lowering below never exposes its surplus tail. Keep a pushed
|
|
@@ -3206,14 +3609,14 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3206
3609
|
// invented. If the slot falls inside the typed prefix, its dynCheck fails
|
|
3207
3610
|
// at the callback boundary; valid callers preserve the original prefix.
|
|
3208
3611
|
if (method === "push" &&
|
|
3209
|
-
call.arguments.length === 1 &&
|
|
3612
|
+
call.arguments.nodes.length === 1 &&
|
|
3210
3613
|
ts.isIdentifier(access.expression) &&
|
|
3211
3614
|
ts.isExpressionStatement(call.parent) &&
|
|
3212
3615
|
ts.isBlock(call.parent.parent)) {
|
|
3213
3616
|
const receiverSymbol = lowerer.checker.getSymbolAtLocation(access.expression);
|
|
3214
3617
|
const block = call.parent.parent;
|
|
3215
|
-
const statementIndex = block.statements.indexOf(call.parent);
|
|
3216
|
-
const next = statementIndex >= 0 ? block.statements[statementIndex + 1] : undefined;
|
|
3618
|
+
const statementIndex = block.statements.nodes.indexOf(call.parent);
|
|
3619
|
+
const next = statementIndex >= 0 ? block.statements.nodes[statementIndex + 1] : undefined;
|
|
3217
3620
|
let returned = next && ts.isReturnStatement(next) ? next.expression : undefined;
|
|
3218
3621
|
while (returned && ts.isParenthesizedExpression(returned))
|
|
3219
3622
|
returned = returned.expression;
|
|
@@ -3223,7 +3626,7 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3223
3626
|
returned.expression.name.text === "apply"
|
|
3224
3627
|
? returned
|
|
3225
3628
|
: null;
|
|
3226
|
-
const argsNode = apply?.arguments[1];
|
|
3629
|
+
const argsNode = apply?.arguments?.nodes[1];
|
|
3227
3630
|
const sameArgs = receiverSymbol !== undefined &&
|
|
3228
3631
|
argsNode !== undefined &&
|
|
3229
3632
|
ts.isIdentifier(argsNode) &&
|
|
@@ -3237,7 +3640,7 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3237
3640
|
arrow !== null &&
|
|
3238
3641
|
targetParams !== null &&
|
|
3239
3642
|
targetParams.every((param) => canDynCheckTo(param, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))) {
|
|
3240
|
-
const value = lowerer.lowerExpr(call.arguments[0]);
|
|
3643
|
+
const value = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
3241
3644
|
if (value.type.kind !== "dyn" && !lowerer.dynConvertible(value.type)) {
|
|
3242
3645
|
const saved = lowerer.declareHiddenLocal("%applyTail", DYN);
|
|
3243
3646
|
return {
|
|
@@ -3250,8 +3653,8 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3250
3653
|
kind: "dynInvoke",
|
|
3251
3654
|
recv: { kind: "varRef", localId: saved.id, type: DYN, loc: locOf(access.expression) },
|
|
3252
3655
|
method,
|
|
3253
|
-
calleeName:
|
|
3254
|
-
args: [dynUndefinedExpr(locOf(call.arguments[0]))],
|
|
3656
|
+
calleeName: ts.getTextOfNode(access),
|
|
3657
|
+
args: [dynUndefinedExpr(locOf(call.arguments.nodes[0]))],
|
|
3255
3658
|
type: DYN,
|
|
3256
3659
|
loc: locOf(call),
|
|
3257
3660
|
},
|
|
@@ -3261,7 +3664,7 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3261
3664
|
}
|
|
3262
3665
|
}
|
|
3263
3666
|
}
|
|
3264
|
-
const args = call.arguments.map((arg, i) => {
|
|
3667
|
+
const args = call.arguments.nodes.map((arg, i) => {
|
|
3265
3668
|
if (i === 0 && predicate)
|
|
3266
3669
|
return lowerer.coerceInto(arg, predicate, DYN);
|
|
3267
3670
|
const undefinedArg = lowerStaticallyUndefinedArgument(lowerer, arg);
|
|
@@ -3273,12 +3676,22 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3273
3676
|
kind: "dynInvoke",
|
|
3274
3677
|
recv,
|
|
3275
3678
|
method,
|
|
3276
|
-
calleeName:
|
|
3679
|
+
calleeName: ts.getTextOfNode(access),
|
|
3277
3680
|
args,
|
|
3278
3681
|
type: DYN,
|
|
3279
3682
|
loc: locOf(call),
|
|
3280
3683
|
};
|
|
3281
3684
|
}
|
|
3685
|
+
/** Every String.prototype method name a typed or dyn string lowering
|
|
3686
|
+
* answers. */
|
|
3687
|
+
function isStringMethodName(name) {
|
|
3688
|
+
return (Object.hasOwn(STR_METHODS, name) ||
|
|
3689
|
+
STRING_INDEX_METHODS.has(name) ||
|
|
3690
|
+
DYN_STRING_ONLY_METHODS.has(name) ||
|
|
3691
|
+
isDynPrimitiveKindMethod(name) ||
|
|
3692
|
+
name === "normalize" ||
|
|
3693
|
+
name === "lastIndexOf");
|
|
3694
|
+
}
|
|
3282
3695
|
/** STR_METHODS ∪ the regex-form names, MINUS everything Array (or any
|
|
3283
3696
|
* other dyn kind's prototype) also declares. */
|
|
3284
3697
|
const DYN_STRING_ONLY_METHODS = new Set([
|
|
@@ -3314,11 +3727,17 @@ function lowerArrayIsArrayCall(lowerer, call, access) {
|
|
|
3314
3727
|
return null;
|
|
3315
3728
|
if (lowerer.stdlibGlobalMember(access, "Array") !== "isArray")
|
|
3316
3729
|
return null;
|
|
3317
|
-
if (call.arguments.length !== 1)
|
|
3730
|
+
if (call.arguments.nodes.length !== 1)
|
|
3318
3731
|
return null; // the stdlib chokepoint fences
|
|
3319
|
-
const argNode = call.arguments[0];
|
|
3320
|
-
|
|
3732
|
+
const argNode = call.arguments.nodes[0];
|
|
3733
|
+
let arg = lowerer.lowerExpr(argNode);
|
|
3321
3734
|
const loc = locOf(call);
|
|
3735
|
+
// A checker-narrowed dyn read arrives as a validated extraction (the
|
|
3736
|
+
// dynCheck bridge). The runtime value may be wider than the flow type
|
|
3737
|
+
// claims (an overload narrower than what arrives), so test the dyn value
|
|
3738
|
+
// itself instead of folding on the extracted type (typeof's rule).
|
|
3739
|
+
if (arg.kind === "dynCheck" && arg.value.type.kind === "dyn")
|
|
3740
|
+
arg = arg.value;
|
|
3322
3741
|
if (arg.type.kind === "dyn") {
|
|
3323
3742
|
return { kind: "dynTest", test: "array", value: arg, type: BOOL, loc };
|
|
3324
3743
|
}
|
|
@@ -3388,22 +3807,26 @@ function lowerCaughtPredicateCall(lowerer, call, caughtLocal) {
|
|
|
3388
3807
|
if (!ts.isIdentifier(callee))
|
|
3389
3808
|
return null;
|
|
3390
3809
|
const symbol = lowerer.resolveValueSymbol(callee);
|
|
3391
|
-
const decl = symbol
|
|
3392
|
-
? lowerer.checker.declarationsOf(symbol).find(ts.isFunctionDeclaration)
|
|
3393
|
-
: undefined;
|
|
3810
|
+
const decl = symbol ? symbol.declarations.find(ts.isFunctionDeclaration) : undefined;
|
|
3394
3811
|
if (!symbol || !decl || !decl.body)
|
|
3395
3812
|
return null;
|
|
3396
3813
|
if (!decl.type || !ts.isTypePredicateNode(decl.type))
|
|
3397
3814
|
return null;
|
|
3398
|
-
if (decl.parameters.length !== 1)
|
|
3815
|
+
if (decl.parameters.nodes.length !== 1)
|
|
3399
3816
|
return null;
|
|
3400
|
-
const param = decl.parameters[0];
|
|
3817
|
+
const param = decl.parameters.nodes[0];
|
|
3401
3818
|
if (!ts.isIdentifier(param.name) || param.initializer || param.dotDotDotToken)
|
|
3402
3819
|
return null;
|
|
3403
3820
|
const paramSymbol = lowerer.checker.getSymbolAtLocation(param.name);
|
|
3404
3821
|
if (!paramSymbol)
|
|
3405
3822
|
return null;
|
|
3406
|
-
const ret = decl.body.statements.length === 1 ? decl.body.statements[0] : undefined;
|
|
3823
|
+
const ret = decl.body.statements.nodes.length === 1 ? decl.body.statements.nodes[0] : undefined;
|
|
3824
|
+
// A longer guard whose parameter is `unknown` (or `any`) takes the caught
|
|
3825
|
+
// value as an ordinary checked-dynamic argument: the call path converts
|
|
3826
|
+
// the binding, and the narrowed binding reads through the same value.
|
|
3827
|
+
if ((!ret || !ts.isReturnStatement(ret) || !ret.expression) &&
|
|
3828
|
+
lowerer.mapTypeOf(lowerer.checker.getTypeOfSymbol(paramSymbol))?.kind === "dyn")
|
|
3829
|
+
return null;
|
|
3407
3830
|
if (!ret || !ts.isReturnStatement(ret) || !ret.expression) {
|
|
3408
3831
|
lowerer.unsupported("SC1090", call, `the type-guard '${callee.text}' on a catch binding (only single-'return' guard bodies inline over the caught value)`);
|
|
3409
3832
|
}
|
|
@@ -3433,8 +3856,8 @@ function lowerNumberToStringCall(lowerer, call, access) {
|
|
|
3433
3856
|
if (lowerer.chainBlocked(call, access))
|
|
3434
3857
|
return null;
|
|
3435
3858
|
if (access.name.text !== "toString" ||
|
|
3436
|
-
call.arguments.length > 1 ||
|
|
3437
|
-
call.arguments.some(ts.isSpreadElement))
|
|
3859
|
+
call.arguments.nodes.length > 1 ||
|
|
3860
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
3438
3861
|
return null;
|
|
3439
3862
|
const recvKind = lowerer.mapTypeOf(lowerer.typeOf(access.expression))?.kind;
|
|
3440
3863
|
if (recvKind !== "f64" && recvKind !== "bool" && recvKind !== "string")
|
|
@@ -3451,22 +3874,44 @@ function lowerNumberToStringCall(lowerer, call, access) {
|
|
|
3451
3874
|
fn: "dyn.toString",
|
|
3452
3875
|
args: [
|
|
3453
3876
|
operand,
|
|
3454
|
-
call.arguments[0]
|
|
3455
|
-
? lowerer.lowerExprExpecting(call.arguments[0], DYN)
|
|
3877
|
+
call.arguments.nodes[0]
|
|
3878
|
+
? lowerer.lowerExprExpecting(call.arguments.nodes[0], DYN)
|
|
3456
3879
|
: dynUndefinedExpr(locOf(call)),
|
|
3457
|
-
{ kind: "strLit", value:
|
|
3880
|
+
{ kind: "strLit", value: ts.getTextOfNode(access), type: STRING, loc: locOf(call) },
|
|
3458
3881
|
],
|
|
3459
3882
|
type: STRING,
|
|
3460
3883
|
loc: locOf(call),
|
|
3461
3884
|
};
|
|
3462
3885
|
}
|
|
3463
|
-
if (call.arguments.length === 1) {
|
|
3886
|
+
if (call.arguments.nodes.length === 1) {
|
|
3464
3887
|
if (operand.type.kind !== "f64")
|
|
3465
3888
|
return null;
|
|
3889
|
+
const arg = call.arguments.nodes[0];
|
|
3890
|
+
// A number radix needs no box: ToIntegerOrInfinity of a number is a
|
|
3891
|
+
// truncation, which the typed entry point applies itself.
|
|
3892
|
+
if (!ts.isSpreadElement(arg) && lowerer.mapTypeOf(lowerer.typeOf(arg))?.kind === "f64") {
|
|
3893
|
+
const radix = lowerer.lowerExpr(arg);
|
|
3894
|
+
if (radix.type.kind === "f64") {
|
|
3895
|
+
return {
|
|
3896
|
+
kind: "libCall",
|
|
3897
|
+
fn: "num.toStringRadixF64",
|
|
3898
|
+
args: [operand, radix],
|
|
3899
|
+
type: STRING,
|
|
3900
|
+
loc: locOf(call),
|
|
3901
|
+
};
|
|
3902
|
+
}
|
|
3903
|
+
return {
|
|
3904
|
+
kind: "libCall",
|
|
3905
|
+
fn: "num.toStringRadix",
|
|
3906
|
+
args: [operand, lowerer.coerceToExpected(radix, DYN)],
|
|
3907
|
+
type: STRING,
|
|
3908
|
+
loc: locOf(call),
|
|
3909
|
+
};
|
|
3910
|
+
}
|
|
3466
3911
|
return {
|
|
3467
3912
|
kind: "libCall",
|
|
3468
3913
|
fn: "num.toStringRadix",
|
|
3469
|
-
args: [operand, lowerer.lowerExprExpecting(
|
|
3914
|
+
args: [operand, lowerer.lowerExprExpecting(arg, DYN)],
|
|
3470
3915
|
type: STRING,
|
|
3471
3916
|
loc: locOf(call),
|
|
3472
3917
|
};
|
|
@@ -3488,7 +3933,7 @@ function lowerNumberToStringCall(lowerer, call, access) {
|
|
|
3488
3933
|
function lowerUnionToStringCall(lowerer, call, access) {
|
|
3489
3934
|
if (call.questionDotToken || access.questionDotToken)
|
|
3490
3935
|
return null;
|
|
3491
|
-
if (access.name.text !== "toString" || call.arguments.length !== 0)
|
|
3936
|
+
if (access.name.text !== "toString" || call.arguments.nodes.length !== 0)
|
|
3492
3937
|
return null;
|
|
3493
3938
|
const recvT = lowerer.mapTypeOf(lowerer.typeOf(access.expression));
|
|
3494
3939
|
if (recvT?.kind !== "union")
|
|
@@ -3502,9 +3947,17 @@ function lowerUnionToStringCall(lowerer, call, access) {
|
|
|
3502
3947
|
(a.kind === "bytes" && a.elem === "u8"));
|
|
3503
3948
|
if (!stringable)
|
|
3504
3949
|
return null;
|
|
3505
|
-
|
|
3950
|
+
let operand = lowerer.lowerExpr(access.expression);
|
|
3506
3951
|
if (operand.type.kind !== "union")
|
|
3507
3952
|
return null;
|
|
3953
|
+
// A flow-narrowed read keeps its wider storage union (`string | number`
|
|
3954
|
+
// after `!Array.isArray(h.host)` over a `string | number | string[]`
|
|
3955
|
+
// slot): retag it to the proven union before the per-union helper.
|
|
3956
|
+
if (operand.type.unionId !== recvT.unionId) {
|
|
3957
|
+
operand = lowerer.coerceInto(access.expression, operand, recvT);
|
|
3958
|
+
if (operand.type.kind !== "union" || operand.type.unionId !== recvT.unionId)
|
|
3959
|
+
return null;
|
|
3960
|
+
}
|
|
3508
3961
|
return { kind: "toString", operand, type: STRING, loc: locOf(call) };
|
|
3509
3962
|
}
|
|
3510
3963
|
/** `x.toString()` resolving to Object.prototype.toString (stdlib
|
|
@@ -3519,7 +3972,7 @@ function lowerUnionToStringCall(lowerer, call, access) {
|
|
|
3519
3972
|
function lowerDefaultToStringCall(lowerer, call, access) {
|
|
3520
3973
|
if (call.questionDotToken || access.questionDotToken)
|
|
3521
3974
|
return null;
|
|
3522
|
-
if (access.name.text !== "toString" || call.arguments.length !== 0)
|
|
3975
|
+
if (access.name.text !== "toString" || call.arguments.nodes.length !== 0)
|
|
3523
3976
|
return null;
|
|
3524
3977
|
if (!lowerer.isStdlibMember(access))
|
|
3525
3978
|
return null;
|
|
@@ -3553,7 +4006,7 @@ function lowerDefaultToStringCall(lowerer, call, access) {
|
|
|
3553
4006
|
// A null-prototype record (Object.groupBy) has no toString: Node
|
|
3554
4007
|
// throws "<callee> is not a function".
|
|
3555
4008
|
const nullProtoT = nullProtoRecordShape(lowerer, recvT);
|
|
3556
|
-
const missing = nullProtoT ? `${
|
|
4009
|
+
const missing = nullProtoT ? `${ts.getTextOfNode(access)} is not a function` : null;
|
|
3557
4010
|
if (!missing && pureObjectToStringReceiver(access.expression))
|
|
3558
4011
|
return constant;
|
|
3559
4012
|
const recv = lowerer.lowerExpr(access.expression);
|
|
@@ -3593,7 +4046,7 @@ function pureObjectToStringReceiver(node) {
|
|
|
3593
4046
|
ts.isTypeAssertion(e)) {
|
|
3594
4047
|
e = e.expression;
|
|
3595
4048
|
}
|
|
3596
|
-
if (ts.isObjectLiteralExpression(e) && e.properties.length === 0)
|
|
4049
|
+
if (ts.isObjectLiteralExpression(e) && e.properties.nodes.length === 0)
|
|
3597
4050
|
return true;
|
|
3598
4051
|
return pureReceiverNode(e);
|
|
3599
4052
|
}
|
|
@@ -3606,11 +4059,11 @@ function pureObjectToStringReceiver(node) {
|
|
|
3606
4059
|
function lowerClassHasOwnPropertyCall(lowerer, call, access) {
|
|
3607
4060
|
if (call.questionDotToken || access.questionDotToken)
|
|
3608
4061
|
return null;
|
|
3609
|
-
if (access.name.text !== "hasOwnProperty" || call.arguments.length !== 1)
|
|
4062
|
+
if (access.name.text !== "hasOwnProperty" || call.arguments.nodes.length !== 1)
|
|
3610
4063
|
return null;
|
|
3611
4064
|
if (!ts.isIdentifier(access.expression))
|
|
3612
4065
|
return null;
|
|
3613
|
-
const argNode = call.arguments[0];
|
|
4066
|
+
const argNode = call.arguments.nodes[0];
|
|
3614
4067
|
if (!ts.isStringLiteralLike(argNode))
|
|
3615
4068
|
return null;
|
|
3616
4069
|
if (!lowerer.isStdlibMember(access))
|
|
@@ -3621,7 +4074,7 @@ function lowerClassHasOwnPropertyCall(lowerer, call, access) {
|
|
|
3621
4074
|
return null; // builtin/runtime classes keep the fence
|
|
3622
4075
|
const key = argNode.text;
|
|
3623
4076
|
const own = new Set(["prototype", "name", "length"]);
|
|
3624
|
-
for (const m of info.decl.members) {
|
|
4077
|
+
for (const m of info.decl.members.nodes) {
|
|
3625
4078
|
const isStatic = ts.canHaveModifiers(m) &&
|
|
3626
4079
|
(ts.getModifiers(m) ?? []).some((mod) => mod.kind === ts.SyntaxKind.StaticKeyword);
|
|
3627
4080
|
if (!isStatic)
|
|
@@ -3692,26 +4145,52 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
|
|
|
3692
4145
|
return null;
|
|
3693
4146
|
const recvKind = lowerer.mapTypeOf(lowerer.typeOf(recv))?.kind;
|
|
3694
4147
|
if ((name === "toFixed" || name === "toExponential") &&
|
|
3695
|
-
call.arguments.length <= 1 &&
|
|
3696
|
-
!call.arguments.some(ts.isSpreadElement) &&
|
|
3697
|
-
isJsSourceFile(
|
|
4148
|
+
call.arguments.nodes.length <= 1 &&
|
|
4149
|
+
!call.arguments.nodes.some(ts.isSpreadElement) &&
|
|
4150
|
+
isJsSourceFile(ts.getSourceFileOfNode(call))) {
|
|
3698
4151
|
const operand = lowerer.lowerExpr(recv);
|
|
4152
|
+
if (name === "toExponential" &&
|
|
4153
|
+
call.arguments.nodes.length === 1 &&
|
|
4154
|
+
(operand.type.kind === "dyn" ||
|
|
4155
|
+
(operand.type.kind === "union" && lowerer.dynConvertible(operand.type)))) {
|
|
4156
|
+
const dispatched = lowerDynPrimitiveMethodCall(lowerer, call, name, `${ts.getTextOfNode(recv)}.${name}`, lowerer.coerceToExpected(operand, DYN));
|
|
4157
|
+
if (dispatched)
|
|
4158
|
+
return dispatched;
|
|
4159
|
+
}
|
|
3699
4160
|
if (operand.type.kind === "dyn" ||
|
|
3700
4161
|
(operand.type.kind === "union" && lowerer.dynConvertible(operand.type)))
|
|
3701
4162
|
return {
|
|
3702
4163
|
kind: "dynInvoke",
|
|
3703
4164
|
recv: lowerer.coerceToExpected(operand, DYN),
|
|
3704
4165
|
method: name,
|
|
3705
|
-
calleeName: `${
|
|
3706
|
-
args: call.arguments.map((argument) => lowerer.lowerExprExpecting(argument, DYN)),
|
|
4166
|
+
calleeName: `${ts.getTextOfNode(recv)}.${name}`,
|
|
4167
|
+
args: call.arguments.nodes.map((argument) => lowerer.lowerExprExpecting(argument, DYN)),
|
|
3707
4168
|
type: DYN,
|
|
3708
4169
|
loc: locOf(call),
|
|
3709
4170
|
};
|
|
3710
4171
|
}
|
|
4172
|
+
if (name === "toPrecision" &&
|
|
4173
|
+
call.arguments.nodes.length <= 1 &&
|
|
4174
|
+
!call.arguments.nodes.some(ts.isSpreadElement) &&
|
|
4175
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
4176
|
+
recvKind === "union") {
|
|
4177
|
+
const operand = lowerer.lowerExpr(recv);
|
|
4178
|
+
if (operand.type.kind === "union" && lowerer.dynConvertible(operand.type)) {
|
|
4179
|
+
const dispatched = lowerDynPrimitiveMethodCall(lowerer, call, name, `${ts.getTextOfNode(recv)}.${name}`, lowerer.coerceToExpected(operand, DYN));
|
|
4180
|
+
if (dispatched)
|
|
4181
|
+
return dispatched;
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
if (recvKind === "f64" &&
|
|
4185
|
+
(name === "toPrecision" || (name === "toExponential" && call.arguments.nodes.length === 1))) {
|
|
4186
|
+
const typed = lowerExtraNumberMethodCall(lowerer, call, name, lowerer.lowerExpr(recv));
|
|
4187
|
+
if (typed)
|
|
4188
|
+
return typed;
|
|
4189
|
+
}
|
|
3711
4190
|
if (recvKind !== "f64" && recvKind !== "bool" && recvKind !== "string")
|
|
3712
4191
|
return null;
|
|
3713
4192
|
const loc = locOf(call);
|
|
3714
|
-
if (name === "toString" && call.arguments.length === 0) {
|
|
4193
|
+
if (name === "toString" && call.arguments.nodes.length === 0) {
|
|
3715
4194
|
const operand = lowerer.lowerExpr(recv);
|
|
3716
4195
|
if (operand.type.kind === "string")
|
|
3717
4196
|
return operand; // identity
|
|
@@ -3721,16 +4200,16 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
|
|
|
3721
4200
|
}
|
|
3722
4201
|
if ((name === "toExponential" || name === "toFixed") &&
|
|
3723
4202
|
recvKind === "f64" &&
|
|
3724
|
-
call.arguments.length === 0) {
|
|
4203
|
+
call.arguments.nodes.length === 0) {
|
|
3725
4204
|
const operand = lowerer.lowerExpr(recv);
|
|
3726
4205
|
if (operand.type.kind !== "f64")
|
|
3727
4206
|
return null;
|
|
3728
4207
|
const fn = name === "toExponential" ? "num.toExponential" : "num.toFixed0";
|
|
3729
4208
|
return { kind: "libCall", fn, args: [operand], type: STRING, loc };
|
|
3730
4209
|
}
|
|
3731
|
-
if (name === "toFixed" && recvKind === "f64" && call.arguments.length === 1) {
|
|
4210
|
+
if (name === "toFixed" && recvKind === "f64" && call.arguments.nodes.length === 1) {
|
|
3732
4211
|
const operand = lowerer.lowerExpr(recv);
|
|
3733
|
-
let digits = lowerer.lowerExpr(call.arguments[0]);
|
|
4212
|
+
let digits = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
3734
4213
|
// The optional parameter also admits undefined. Exact unit values
|
|
3735
4214
|
// become the default 0 after preserving any evaluation effects; an
|
|
3736
4215
|
// optional number selects 0 at runtime through the same narrowed
|
|
@@ -3769,15 +4248,15 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
|
|
|
3769
4248
|
// host environment's default, which a compiled binary cannot carry),
|
|
3770
4249
|
// other locales (ICU data the binary does not embed), options bags.
|
|
3771
4250
|
if (name === "toLocaleString" && recvKind === "f64") {
|
|
3772
|
-
if (call.arguments.length === 0) {
|
|
4251
|
+
if (call.arguments.nodes.length === 0) {
|
|
3773
4252
|
lowerer.noLowering("Number.prototype.toLocaleString without a locale", call, "the default locale is the host environment's, which a compiled binary cannot carry — " +
|
|
3774
4253
|
'pass it explicitly: x.toLocaleString("en-US")');
|
|
3775
4254
|
}
|
|
3776
|
-
if (call.arguments.length > 1) {
|
|
4255
|
+
if (call.arguments.nodes.length > 1) {
|
|
3777
4256
|
lowerer.noLowering("Number.prototype.toLocaleString with an options bag", call, "the embedded data covers DEFAULT options only (decimal notation, up to 3 fraction " +
|
|
3778
4257
|
'digits, grouping) — x.toLocaleString("en-US")');
|
|
3779
4258
|
}
|
|
3780
|
-
const locNode = call.arguments[0];
|
|
4259
|
+
const locNode = call.arguments.nodes[0];
|
|
3781
4260
|
if (ts.isSpreadElement(locNode) ||
|
|
3782
4261
|
!ts.isStringLiteralLike(locNode) ||
|
|
3783
4262
|
locNode.text !== "en-US") {
|
|
@@ -3793,17 +4272,17 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
|
|
|
3793
4272
|
}
|
|
3794
4273
|
if (name === "charAt" &&
|
|
3795
4274
|
recvKind === "string" &&
|
|
3796
|
-
call.arguments.length === 1 &&
|
|
3797
|
-
!ts.isSpreadElement(call.arguments[0])) {
|
|
4275
|
+
call.arguments.nodes.length === 1 &&
|
|
4276
|
+
!ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
3798
4277
|
const receiver = lowerer.lowerExpr(recv);
|
|
3799
4278
|
if (receiver.type.kind !== "string")
|
|
3800
4279
|
return null;
|
|
3801
|
-
const idx = lowerer.lowerExprExpecting(call.arguments[0], F64);
|
|
4280
|
+
const idx = lowerer.lowerExprExpecting(call.arguments.nodes[0], F64);
|
|
3802
4281
|
return { kind: "strIntrinsic", method: "charAt", receiver, args: [idx], type: STRING, loc };
|
|
3803
4282
|
}
|
|
3804
|
-
if (name !== "hasOwnProperty" || call.arguments.length !== 1)
|
|
4283
|
+
if (name !== "hasOwnProperty" || call.arguments.nodes.length !== 1)
|
|
3805
4284
|
return null;
|
|
3806
|
-
const argNode = call.arguments[0];
|
|
4285
|
+
const argNode = call.arguments.nodes[0];
|
|
3807
4286
|
if (!ts.isStringLiteralLike(argNode))
|
|
3808
4287
|
return null;
|
|
3809
4288
|
const key = argNode.text;
|
|
@@ -3850,7 +4329,7 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
|
|
|
3850
4329
|
function implicitReceiverOverloadReturn(lowerer, expr) {
|
|
3851
4330
|
if (!ts.isCallExpression(expr) ||
|
|
3852
4331
|
!ts.isPropertyAccessExpression(expr.expression) ||
|
|
3853
|
-
expr.arguments.some(ts.isSpreadElement)) {
|
|
4332
|
+
expr.arguments.nodes.some(ts.isSpreadElement)) {
|
|
3854
4333
|
return null;
|
|
3855
4334
|
}
|
|
3856
4335
|
const access = expr.expression;
|
|
@@ -3865,14 +4344,14 @@ function implicitReceiverOverloadReturn(lowerer, expr) {
|
|
|
3865
4344
|
return null;
|
|
3866
4345
|
const signatures = lowerer.checker.getCallSignatures(lowerer.checker.getTypeOfSymbol(member));
|
|
3867
4346
|
const matches = signatures.filter((signature) => {
|
|
3868
|
-
const decl =
|
|
4347
|
+
const decl = signature.declaration;
|
|
3869
4348
|
if (!decl || !(ts.isFunctionDeclaration(decl) || ts.isMethodDeclaration(decl)) || decl.body) {
|
|
3870
4349
|
return false;
|
|
3871
4350
|
}
|
|
3872
|
-
const params = decl.parameters.filter((param) => !isThisParameter(param));
|
|
4351
|
+
const params = decl.parameters.nodes.filter((param) => !isThisParameter(param));
|
|
3873
4352
|
const required = params.filter((param) => !param.questionToken && !param.initializer && !param.dotDotDotToken).length;
|
|
3874
4353
|
const maximum = params.some((param) => param.dotDotDotToken) ? Infinity : params.length;
|
|
3875
|
-
return expr.arguments.length >= required && expr.arguments.length <= maximum;
|
|
4354
|
+
return expr.arguments.nodes.length >= required && expr.arguments.nodes.length <= maximum;
|
|
3876
4355
|
});
|
|
3877
4356
|
if (matches.length !== 1)
|
|
3878
4357
|
return null;
|
|
@@ -3906,21 +4385,38 @@ function isSoleAbstractMethod(decl) {
|
|
|
3906
4385
|
const owner = decl.parent;
|
|
3907
4386
|
if (!ts.isClassDeclaration(owner) && !ts.isClassExpression(owner))
|
|
3908
4387
|
return false;
|
|
3909
|
-
const name = decl.name
|
|
3910
|
-
return !owner.members.some((member) => member !== decl && ts.isMethodDeclaration(member) && member.name
|
|
4388
|
+
const name = ts.getTextOfNode(decl.name);
|
|
4389
|
+
return !owner.members.nodes.some((member) => member !== decl && ts.isMethodDeclaration(member) && ts.getTextOfNode(member.name) === name);
|
|
3911
4390
|
}
|
|
3912
4391
|
function reconcileOverloadReturn(lowerer, expr, call) {
|
|
3913
4392
|
const rsig = lowerer.checker.getResolvedSignature(expr);
|
|
3914
|
-
const rdecl = rsig ?
|
|
4393
|
+
const rdecl = rsig ? rsig.declaration : undefined;
|
|
3915
4394
|
// Nominal covariant overrides share the base's return ABI, but retain
|
|
3916
4395
|
// their declared subclass result at the call site. Unannotated fluent
|
|
3917
4396
|
// JS overrides use the same bridge for their proven receiver result.
|
|
3918
4397
|
if (call.type.kind === "object" &&
|
|
3919
4398
|
rdecl &&
|
|
3920
4399
|
ts.isMethodDeclaration(rdecl) &&
|
|
3921
|
-
(!isJsSourceFile(
|
|
4400
|
+
(!isJsSourceFile(ts.getSourceFileOfNode(rdecl)) || returnsOnlyThis(rdecl))) {
|
|
3922
4401
|
call = lowerer.maybeNarrow(call, expr);
|
|
3923
4402
|
}
|
|
4403
|
+
// An override narrowed to part of its base's union return shares the
|
|
4404
|
+
// union ABI; a call resolved to that override narrows the result back.
|
|
4405
|
+
if (call.type.kind === "union" &&
|
|
4406
|
+
rsig &&
|
|
4407
|
+
rdecl &&
|
|
4408
|
+
ts.isMethodDeclaration(rdecl) &&
|
|
4409
|
+
lowerer.unionReturnOverrides.has(rdecl)) {
|
|
4410
|
+
const declared = lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(rsig));
|
|
4411
|
+
if (declared && !typeEquals(declared, call.type)) {
|
|
4412
|
+
if (declared.kind !== "union") {
|
|
4413
|
+
const helper = lowerer.narrowedArmHelper(call.type.unionId, declared, call.loc);
|
|
4414
|
+
if (helper)
|
|
4415
|
+
return lowerer.checkedNarrowCall(helper, call, declared, call.loc);
|
|
4416
|
+
}
|
|
4417
|
+
return lowerer.coerceInto(expr, call, declared);
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
3924
4420
|
const resolvedOverload = rsig &&
|
|
3925
4421
|
rdecl &&
|
|
3926
4422
|
(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) &&
|
|
@@ -4000,7 +4496,7 @@ export function lowerTaggedTemplate(lowerer, expr) {
|
|
|
4000
4496
|
const loc = locOf(expr);
|
|
4001
4497
|
const pieces = ts.isNoSubstitutionTemplateLiteral(expr.template)
|
|
4002
4498
|
? [expr.template]
|
|
4003
|
-
: [expr.template.head, ...expr.template.templateSpans.map((s) => s.literal)];
|
|
4499
|
+
: [expr.template.head, ...expr.template.templateSpans.nodes.map((s) => s.literal)];
|
|
4004
4500
|
for (const p of pieces) {
|
|
4005
4501
|
if (!templateEscapesValid(templateRawTextOf(p))) {
|
|
4006
4502
|
lowerer.unsupported("SC1090", p, "tagged templates with invalid escape sequences (the span cooks to undefined, which the strings array cannot carry)");
|
|
@@ -4009,7 +4505,7 @@ export function lowerTaggedTemplate(lowerer, expr) {
|
|
|
4009
4505
|
const strings = () => loweredTemplateStrings(lowerer, expr, pieces.map((piece) => piece.text), loc);
|
|
4010
4506
|
const values = ts.isNoSubstitutionTemplateLiteral(expr.template)
|
|
4011
4507
|
? []
|
|
4012
|
-
: expr.template.templateSpans.map((s) => s.expression);
|
|
4508
|
+
: expr.template.templateSpans.nodes.map((s) => s.expression);
|
|
4013
4509
|
// Direct call of a top-level declared function — the plain-call fast
|
|
4014
4510
|
// path with the strings array as the leading completed argument.
|
|
4015
4511
|
if (ts.isIdentifier(expr.tag) && !lowerer.isSelfReference(expr.tag)) {
|
|
@@ -4054,7 +4550,7 @@ export function lowerTaggedTemplate(lowerer, expr) {
|
|
|
4054
4550
|
// tag throws Node's catchable "<name> is not a function" TypeError.
|
|
4055
4551
|
let callee = lowerer.lowerExpr(expr.tag);
|
|
4056
4552
|
if (callee.type.kind === "func" &&
|
|
4057
|
-
isJsSourceFile(
|
|
4553
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr)) &&
|
|
4058
4554
|
lowerer.dynConvertible(callee.type)) {
|
|
4059
4555
|
callee = { kind: "dynFrom", value: callee, type: DYN, loc };
|
|
4060
4556
|
}
|
|
@@ -4064,7 +4560,7 @@ export function lowerTaggedTemplate(lowerer, expr) {
|
|
|
4064
4560
|
...values.map((a) => lowerer.lowerExprExpecting(a, DYN)),
|
|
4065
4561
|
];
|
|
4066
4562
|
const calleeName = ts.isPropertyAccessExpression(expr.tag) || ts.isElementAccessExpression(expr.tag)
|
|
4067
|
-
? expr.tag
|
|
4563
|
+
? ts.getTextOfNode(expr.tag)
|
|
4068
4564
|
: ts.isIdentifier(expr.tag)
|
|
4069
4565
|
? expr.tag.text
|
|
4070
4566
|
: "value";
|
|
@@ -4123,7 +4619,7 @@ function loweredTemplateStrings(lowerer, expr, cooked, loc, raw) {
|
|
|
4123
4619
|
loc,
|
|
4124
4620
|
})
|
|
4125
4621
|
: null;
|
|
4126
|
-
const key = `templateStringsGlobal:${loc.file}:${expr.template
|
|
4622
|
+
const key = `templateStringsGlobal:${loc.file}:${ts.tokenStartOfNode(expr.template)}:${raw ? "checked" : "typed"}`;
|
|
4127
4623
|
let getter = lowerer.valueHelpers.get(key);
|
|
4128
4624
|
if (!getter) {
|
|
4129
4625
|
const site = lowerer.globalsList.length;
|
|
@@ -4228,7 +4724,7 @@ function markModuleNsHandlerParams(lowerer, handler, type) {
|
|
|
4228
4724
|
e = e.expression;
|
|
4229
4725
|
if (!ts.isArrowFunction(e) && !ts.isFunctionExpression(e))
|
|
4230
4726
|
return;
|
|
4231
|
-
for (const p of e.parameters) {
|
|
4727
|
+
for (const p of e.parameters.nodes) {
|
|
4232
4728
|
if (ts.isIdentifier(p.name) && !p.dotDotDotToken && !p.initializer) {
|
|
4233
4729
|
lowerer.moduleNsParamOverrides.set(p, type);
|
|
4234
4730
|
}
|
|
@@ -4269,12 +4765,12 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4269
4765
|
e.text === "undefined" &&
|
|
4270
4766
|
(lowerer.typeOf(e).flags & ts.TypeFlags.Undefined) !== 0));
|
|
4271
4767
|
};
|
|
4272
|
-
const passthrough = call.arguments.length === 0 ||
|
|
4273
|
-
(call.arguments.length === 1 && isAbsentHandler(call.arguments[0]));
|
|
4274
|
-
if (call.arguments.length !== 1 &&
|
|
4768
|
+
const passthrough = call.arguments.nodes.length === 0 ||
|
|
4769
|
+
(call.arguments.nodes.length === 1 && isAbsentHandler(call.arguments.nodes[0]));
|
|
4770
|
+
if (call.arguments.nodes.length !== 1 &&
|
|
4275
4771
|
!passthrough &&
|
|
4276
|
-
!(member === "then" && call.arguments.length === 2)) {
|
|
4277
|
-
lowerer.noLowering(`${member} with ${call.arguments.length} arguments`, call, member === "then"
|
|
4772
|
+
!(member === "then" && call.arguments.nodes.length === 2)) {
|
|
4773
|
+
lowerer.noLowering(`${member} with ${call.arguments.nodes.length} arguments`, call, member === "then"
|
|
4278
4774
|
? "the supported form takes a fulfillment handler and an optional rejection handler"
|
|
4279
4775
|
: `the supported form takes exactly one ${member === "catch" ? "inline handler" : "callback"}`);
|
|
4280
4776
|
}
|
|
@@ -4343,9 +4839,9 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4343
4839
|
}
|
|
4344
4840
|
}
|
|
4345
4841
|
if (member === "then") {
|
|
4346
|
-
if (call.arguments.length === 2) {
|
|
4347
|
-
const fulfilledNode = call.arguments[0];
|
|
4348
|
-
const rejectedNode = call.arguments[1];
|
|
4842
|
+
if (call.arguments.nodes.length === 2) {
|
|
4843
|
+
const fulfilledNode = call.arguments.nodes[0];
|
|
4844
|
+
const rejectedNode = call.arguments.nodes[1];
|
|
4349
4845
|
const fulfilledAbsent = isAbsentHandler(fulfilledNode);
|
|
4350
4846
|
const rejectedAbsent = isAbsentHandler(rejectedNode);
|
|
4351
4847
|
const resultT = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
@@ -4412,6 +4908,9 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4412
4908
|
const resultOf = (value, returnsPromise = false) => {
|
|
4413
4909
|
if (value.type.kind === "promise")
|
|
4414
4910
|
return [lowerer.adoptingReturn(value, R, (e) => lowerer.coerceInto(call, e, R))];
|
|
4911
|
+
const flattened = maybePromiseHandlerResult(lowerer, call, value, R);
|
|
4912
|
+
if (flattened)
|
|
4913
|
+
return [flattened];
|
|
4415
4914
|
if (returnsPromise) {
|
|
4416
4915
|
// A boxed handler's promise result adopts too: the then job's
|
|
4417
4916
|
// turn after the call, then the await of the returned value.
|
|
@@ -4562,8 +5061,9 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4562
5061
|
// contextual type spelled (a module-namespace type has no mapping —
|
|
4563
5062
|
// the handle is the value's only story, isIslandExpr's local rule).
|
|
4564
5063
|
if (inner.kind === "moduleNs")
|
|
4565
|
-
markModuleNsHandlerParams(lowerer, call.arguments[0], inner);
|
|
4566
|
-
let cb = lowerer
|
|
5064
|
+
markModuleNsHandlerParams(lowerer, call.arguments.nodes[0], inner);
|
|
5065
|
+
let cb = primitiveConversionHandler(lowerer, call.arguments.nodes[0], inner) ??
|
|
5066
|
+
lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
4567
5067
|
// A TYPED handler on a DYN-settling promise (the tracePromise
|
|
4568
5068
|
// result's `.then((value) => ...)` — the checker's generic
|
|
4569
5069
|
// instantiation typed the parameter, but the settled value is a
|
|
@@ -4592,7 +5092,7 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4592
5092
|
if (canConvertToDyn(v.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4593
5093
|
return { kind: "dynFrom", value: v, type: DYN, loc };
|
|
4594
5094
|
}
|
|
4595
|
-
lowerer.unsupported("SC1090", call.arguments[0], `then handlers receiving '${lowerer.fmt(v.type)}' values through an untyped handler (the settled value cannot cross the checked-dynamic tree boundary)`);
|
|
5095
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], `then handlers receiving '${lowerer.fmt(v.type)}' values through an untyped handler (the settled value cannot cross the checked-dynamic tree boundary)`);
|
|
4596
5096
|
};
|
|
4597
5097
|
const resultT = { kind: "promise", inner: DYN };
|
|
4598
5098
|
const fnName = `%fn${lowerer.lambdaCounter++}_then`;
|
|
@@ -4629,7 +5129,7 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4629
5129
|
value: {
|
|
4630
5130
|
kind: "dynCall",
|
|
4631
5131
|
callee: { kind: "varRef", localId: cbLocal.id, type: DYN, loc },
|
|
4632
|
-
calleeName: jsFuncNameOf(call.arguments[0], lowerer) ?? "onFulfilled",
|
|
5132
|
+
calleeName: jsFuncNameOf(call.arguments.nodes[0], lowerer) ?? "onFulfilled",
|
|
4633
5133
|
args: handlerArgs,
|
|
4634
5134
|
type: DYN,
|
|
4635
5135
|
loc,
|
|
@@ -4665,13 +5165,13 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4665
5165
|
}
|
|
4666
5166
|
}
|
|
4667
5167
|
if (cb.type.kind !== "func" || cb.type.params.length > 1) {
|
|
4668
|
-
lowerer.unsupported("SC1090", call.arguments[0], "then handlers with more than one parameter (the two-argument onRejected form has no lowering — chain .catch(...) instead)");
|
|
5168
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "then handlers with more than one parameter (the two-argument onRejected form has no lowering — chain .catch(...) instead)");
|
|
4669
5169
|
}
|
|
4670
5170
|
const param = cb.type.params[0];
|
|
4671
5171
|
if (param !== undefined &&
|
|
4672
5172
|
!typeEquals(param, inner) &&
|
|
4673
5173
|
!(param.kind === "dyn" && (inner.kind === "void" || lowerer.dynConvertible(inner)))) {
|
|
4674
|
-
lowerer.unsupported("SC1090", call.arguments[0], `then handlers whose parameter is not the settled value's type (expected '${lowerer.fmt(inner)}', got '${lowerer.fmt(param)}')`);
|
|
5174
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], `then handlers whose parameter is not the settled value's type (expected '${lowerer.fmt(inner)}', got '${lowerer.fmt(param)}')`);
|
|
4675
5175
|
}
|
|
4676
5176
|
const resultT = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
4677
5177
|
if (resultT?.kind !== "promise") {
|
|
@@ -4723,7 +5223,11 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4723
5223
|
// The handler's result: promise returns flatten exactly like
|
|
4724
5224
|
// `return p` in any async body (the spec's thenable adoption);
|
|
4725
5225
|
// everything else coerces into R.
|
|
4726
|
-
|
|
5226
|
+
const flattened = maybePromiseHandlerResult(lowerer, call, handlerCall, R);
|
|
5227
|
+
if (flattened) {
|
|
5228
|
+
body.push(flattened);
|
|
5229
|
+
}
|
|
5230
|
+
else if (handlerCall.type.kind === "promise" && R.kind !== "promise") {
|
|
4727
5231
|
body.push(lowerer.adoptingReturn(handlerCall, R, (e) => lowerer.coerceInto(call, e, R)));
|
|
4728
5232
|
}
|
|
4729
5233
|
else if (R.kind === "void") {
|
|
@@ -4762,13 +5266,13 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4762
5266
|
}
|
|
4763
5267
|
}
|
|
4764
5268
|
if (member === "finally") {
|
|
4765
|
-
const cb = lowerer.lowerExpr(call.arguments[0]);
|
|
5269
|
+
const cb = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
4766
5270
|
if (lowerer.dynConvertible(promT) && lowerer.dynConvertible(cb.type)) {
|
|
4767
5271
|
const result = {
|
|
4768
5272
|
kind: "dynInvoke",
|
|
4769
5273
|
recv: lowerer.coerceToExpected(receiver, DYN),
|
|
4770
5274
|
method: "finally",
|
|
4771
|
-
calleeName:
|
|
5275
|
+
calleeName: ts.getTextOfNode(access),
|
|
4772
5276
|
args: [lowerer.coerceToExpected(cb, DYN)],
|
|
4773
5277
|
type: DYN,
|
|
4774
5278
|
loc,
|
|
@@ -4776,7 +5280,7 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4776
5280
|
return lowerer.coerceToExpected(result, promT);
|
|
4777
5281
|
}
|
|
4778
5282
|
if (cb.type.kind !== "func" || cb.type.params.length !== 0 || cb.type.ret.kind !== "void") {
|
|
4779
|
-
lowerer.unsupported("SC1090", call.arguments[0], "finally callbacks with parameters or a return value (use () => { ... })");
|
|
5283
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "finally callbacks with parameters or a return value (use () => { ... })");
|
|
4780
5284
|
}
|
|
4781
5285
|
const fnName = `%fn${lowerer.lambdaCounter++}_finally`;
|
|
4782
5286
|
const funcType = {
|
|
@@ -4865,9 +5369,9 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4865
5369
|
// snapshot (the dyn-then desugar's catch twin).
|
|
4866
5370
|
if (member === "catch" &&
|
|
4867
5371
|
(inner.kind === "dyn" ||
|
|
4868
|
-
(isJsSourceFile(
|
|
5372
|
+
(isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
4869
5373
|
(inner.kind === "void" || lowerer.dynConvertible(inner))))) {
|
|
4870
|
-
let cb = lowerer.lowerExpr(call.arguments[0]);
|
|
5374
|
+
let cb = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
4871
5375
|
if (cb.type.kind === "func" &&
|
|
4872
5376
|
canBoxFuncIntoDyn(cb.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
4873
5377
|
cb = { kind: "dynFrom", value: cb, type: DYN, loc };
|
|
@@ -4912,7 +5416,7 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4912
5416
|
value: {
|
|
4913
5417
|
kind: "dynCall",
|
|
4914
5418
|
callee: { kind: "varRef", localId: cbLocal.id, type: DYN, loc },
|
|
4915
|
-
calleeName: jsFuncNameOf(call.arguments[0], lowerer) ?? "onRejected",
|
|
5419
|
+
calleeName: jsFuncNameOf(call.arguments.nodes[0], lowerer) ?? "onRejected",
|
|
4916
5420
|
args: [
|
|
4917
5421
|
{
|
|
4918
5422
|
kind: "caughtToDyn",
|
|
@@ -4961,20 +5465,20 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4961
5465
|
}
|
|
4962
5466
|
// .catch: the handler must be INLINE — its parameter becomes the
|
|
4963
5467
|
// catch binding.
|
|
4964
|
-
let handlerNode = call.arguments[0];
|
|
5468
|
+
let handlerNode = call.arguments.nodes[0];
|
|
4965
5469
|
while (ts.isParenthesizedExpression(handlerNode))
|
|
4966
5470
|
handlerNode = handlerNode.expression;
|
|
4967
5471
|
if (!ts.isArrowFunction(handlerNode) && !ts.isFunctionExpression(handlerNode)) {
|
|
4968
|
-
lowerer.unsupported("SC1090", call.arguments[0], "catch handlers that are not inline function literals (the handler's parameter " +
|
|
5472
|
+
lowerer.unsupported("SC1090", call.arguments.nodes[0], "catch handlers that are not inline function literals (the handler's parameter " +
|
|
4969
5473
|
"becomes a typed-catch binding, which only an inline `(e) => ...` can receive)");
|
|
4970
5474
|
}
|
|
4971
|
-
if (handlerNode.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
5475
|
+
if (handlerNode.modifiers?.nodes.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
4972
5476
|
lowerer.unsupported("SC1090", handlerNode, "async catch handlers");
|
|
4973
5477
|
}
|
|
4974
|
-
if (handlerNode.parameters.length > 1) {
|
|
5478
|
+
if (handlerNode.parameters.nodes.length > 1) {
|
|
4975
5479
|
lowerer.unsupported("SC1090", handlerNode, "catch handlers with more than one parameter");
|
|
4976
5480
|
}
|
|
4977
|
-
const param = handlerNode.parameters[0];
|
|
5481
|
+
const param = handlerNode.parameters.nodes[0];
|
|
4978
5482
|
if (param && (!ts.isIdentifier(param.name) || param.dotDotDotToken || param.initializer)) {
|
|
4979
5483
|
lowerer.unsupported("SC1062", param);
|
|
4980
5484
|
}
|
|
@@ -5021,7 +5525,7 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
5021
5525
|
}
|
|
5022
5526
|
const hb = handlerNode.body;
|
|
5023
5527
|
if (ts.isBlock(hb)) {
|
|
5024
|
-
catchBody = lowerer.lowerStmts(hb.statements);
|
|
5528
|
+
catchBody = lowerer.lowerStmts(hb.statements.nodes);
|
|
5025
5529
|
}
|
|
5026
5530
|
else if (R.kind === "void") {
|
|
5027
5531
|
catchBody = [{ kind: "exprStmt", expr: lowerer.lowerExpr(hb), loc: locOf(hb) }];
|
|
@@ -5119,10 +5623,10 @@ export function lowerFilterNarrowCall(lowerer, call, access) {
|
|
|
5119
5623
|
return null;
|
|
5120
5624
|
if (!lowerer.isStdlibMember(access))
|
|
5121
5625
|
return null;
|
|
5122
|
-
if (call.arguments.length !== 1)
|
|
5626
|
+
if (call.arguments.nodes.length !== 1)
|
|
5123
5627
|
return null; // the generic path's arity fence
|
|
5124
5628
|
const elem = receiverIr.elem;
|
|
5125
|
-
const argNode = call.arguments[0];
|
|
5629
|
+
const argNode = call.arguments.nodes[0];
|
|
5126
5630
|
const loc = locOf(call);
|
|
5127
5631
|
const isBooleanArg = ts.isIdentifier(argNode) &&
|
|
5128
5632
|
argNode.text === "Boolean" &&
|
|
@@ -5324,19 +5828,19 @@ function lowerSymbolStaticCall(lowerer, call, access) {
|
|
|
5324
5828
|
const member = access.name.text;
|
|
5325
5829
|
const loc = locOf(call);
|
|
5326
5830
|
if (member === "for") {
|
|
5327
|
-
if (call.arguments.length !== 1) {
|
|
5328
|
-
lowerer.noLowering(`Symbol.for with ${call.arguments.length} arguments`, call);
|
|
5831
|
+
if (call.arguments.nodes.length !== 1) {
|
|
5832
|
+
lowerer.noLowering(`Symbol.for with ${call.arguments.nodes.length} arguments`, call);
|
|
5329
5833
|
}
|
|
5330
|
-
const key = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
5834
|
+
const key = lowerer.lowerExprExpecting(call.arguments.nodes[0], STRING);
|
|
5331
5835
|
return { kind: "libCall", fn: "sym.for", args: [key], type: SYMBOL_T, loc };
|
|
5332
5836
|
}
|
|
5333
5837
|
if (member === "keyFor") {
|
|
5334
|
-
if (call.arguments.length !== 1) {
|
|
5335
|
-
lowerer.noLowering(`Symbol.keyFor with ${call.arguments.length} arguments`, call);
|
|
5838
|
+
if (call.arguments.nodes.length !== 1) {
|
|
5839
|
+
lowerer.noLowering(`Symbol.keyFor with ${call.arguments.nodes.length} arguments`, call);
|
|
5336
5840
|
}
|
|
5337
|
-
const sym = lowerer.lowerExpr(call.arguments[0]);
|
|
5841
|
+
const sym = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
5338
5842
|
if (sym.type.kind !== "symbol") {
|
|
5339
|
-
lowerer.noLowering(`Symbol.keyFor of a '${lowerer.fmt(sym.type)}' value`, call.arguments[0], "the argument must be symbol-typed");
|
|
5843
|
+
lowerer.noLowering(`Symbol.keyFor of a '${lowerer.fmt(sym.type)}' value`, call.arguments.nodes[0], "the argument must be symbol-typed");
|
|
5340
5844
|
}
|
|
5341
5845
|
// The checker types the call `string | undefined`, which interns
|
|
5342
5846
|
// the result union (the map.get pattern); the backend builds the
|
|
@@ -5357,12 +5861,12 @@ function lowerBigIntStaticCall(lowerer, call, access) {
|
|
|
5357
5861
|
const name = access.name.text;
|
|
5358
5862
|
if (name !== "asUintN" && name !== "asIntN")
|
|
5359
5863
|
return null;
|
|
5360
|
-
if (call.arguments.length !== 2) {
|
|
5361
|
-
lowerer.noLowering(`BigInt.${name} with ${call.arguments.length} arguments`, call);
|
|
5864
|
+
if (call.arguments.nodes.length !== 2) {
|
|
5865
|
+
lowerer.noLowering(`BigInt.${name} with ${call.arguments.nodes.length} arguments`, call);
|
|
5362
5866
|
}
|
|
5363
5867
|
const loc = locOf(call);
|
|
5364
|
-
const bits = lowerer.lowerExprExpecting(call.arguments[0], F64);
|
|
5365
|
-
const value = lowerer.lowerExprExpecting(call.arguments[1], BIGINT_T);
|
|
5868
|
+
const bits = lowerer.lowerExprExpecting(call.arguments.nodes[0], F64);
|
|
5869
|
+
const value = lowerer.lowerExprExpecting(call.arguments.nodes[1], BIGINT_T);
|
|
5366
5870
|
return {
|
|
5367
5871
|
kind: "libCall",
|
|
5368
5872
|
fn: name === "asUintN" ? "bigint.asUintN" : "bigint.asIntN",
|
|
@@ -5381,12 +5885,12 @@ function lowerBigIntMethodCall(lowerer, call, access) {
|
|
|
5381
5885
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5382
5886
|
if (receiver.type.kind !== "bigint")
|
|
5383
5887
|
return null;
|
|
5384
|
-
if (name === "valueOf" && call.arguments.length === 0)
|
|
5888
|
+
if (name === "valueOf" && call.arguments.nodes.length === 0)
|
|
5385
5889
|
return receiver;
|
|
5386
|
-
if (name === "toString" && call.arguments.length <= 1) {
|
|
5890
|
+
if (name === "toString" && call.arguments.nodes.length <= 1) {
|
|
5387
5891
|
const defaultRadix = { kind: "numLit", value: 10, type: F64, loc };
|
|
5388
|
-
const radix = call.arguments[0]
|
|
5389
|
-
? lowerOptionalArgument(lowerer, call.arguments[0], F64, defaultRadix)
|
|
5892
|
+
const radix = call.arguments.nodes[0]
|
|
5893
|
+
? lowerOptionalArgument(lowerer, call.arguments.nodes[0], F64, defaultRadix)
|
|
5390
5894
|
: defaultRadix;
|
|
5391
5895
|
return { kind: "libCall", fn: "bigint.toString", args: [receiver, radix], type: STRING, loc };
|
|
5392
5896
|
}
|
|
@@ -5404,13 +5908,13 @@ function lowerSymbolMethodCall(lowerer, call, access) {
|
|
|
5404
5908
|
return null;
|
|
5405
5909
|
const name = access.name.text;
|
|
5406
5910
|
const loc = locOf(call);
|
|
5407
|
-
if (name === "toString" && call.arguments.length === 0) {
|
|
5911
|
+
if (name === "toString" && call.arguments.nodes.length === 0) {
|
|
5408
5912
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5409
5913
|
if (receiver.type.kind !== "symbol")
|
|
5410
5914
|
return null;
|
|
5411
5915
|
return { kind: "libCall", fn: "sym.toString", args: [receiver], type: STRING, loc };
|
|
5412
5916
|
}
|
|
5413
|
-
if (name === "valueOf" && call.arguments.length === 0) {
|
|
5917
|
+
if (name === "valueOf" && call.arguments.nodes.length === 0) {
|
|
5414
5918
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5415
5919
|
if (receiver.type.kind !== "symbol")
|
|
5416
5920
|
return null;
|
|
@@ -5427,6 +5931,7 @@ function lowerSymbolMethodCall(lowerer, call, access) {
|
|
|
5427
5931
|
* for-in iterates exactly the keys Object.keys answers. */
|
|
5428
5932
|
export function recordKeysArrayCall(lowerer, receiver, argIr, shape, loc) {
|
|
5429
5933
|
const resultT = arrayOf(STRING);
|
|
5934
|
+
lowerer.keyOrder.observe(argIr);
|
|
5430
5935
|
const key = `obj.keys:${argIr.shapeId}:${typeKey(resultT)}`;
|
|
5431
5936
|
let helper = lowerer.arrHofHelpers.get(key);
|
|
5432
5937
|
if (!helper) {
|
|
@@ -5542,6 +6047,90 @@ function recordHasOwnHelper(lowerer, shapeId, loc) {
|
|
|
5542
6047
|
});
|
|
5543
6048
|
return helper;
|
|
5544
6049
|
}
|
|
6050
|
+
/** Whether `Object.assign(instance, record)` can copy every field of the
|
|
6051
|
+
* record shape into a field the class declares with the same type: a plain
|
|
6052
|
+
* record (no tuple, index signature or accessor slots) and a compiled
|
|
6053
|
+
* class whose chain has no builtin or runtime-provided storage and no
|
|
6054
|
+
* accessor for the written names. */
|
|
6055
|
+
function classAssignPlan(lowerer, className, srcShapeId) {
|
|
6056
|
+
const info = lowerer.classes.get(className);
|
|
6057
|
+
const shape = lowerer.shapes.get(srcShapeId);
|
|
6058
|
+
if (!info || !shape || shape.tuple || shape.indexValue || shapeHasAccessorSlots(shape))
|
|
6059
|
+
return false;
|
|
6060
|
+
for (let c = info; c; c = c.base) {
|
|
6061
|
+
if (c.builtinError || c.builtinEmitter || c.builtinStream !== undefined || c.def.runtime)
|
|
6062
|
+
return false;
|
|
6063
|
+
}
|
|
6064
|
+
return shape.fields.every((f) => {
|
|
6065
|
+
const declared = info.fields.get(f.name);
|
|
6066
|
+
return (declared !== undefined &&
|
|
6067
|
+
(typeEquals(declared, f.type) || lowerer.widthLiftPlan(f.type, declared) !== null) &&
|
|
6068
|
+
!lowerer.findMethodOn(info, f.name) &&
|
|
6069
|
+
!lowerer.findMethodOn(info, `get:${f.name}`) &&
|
|
6070
|
+
!lowerer.findMethodOn(info, `set:${f.name}`));
|
|
6071
|
+
});
|
|
6072
|
+
}
|
|
6073
|
+
/** Interned `%obj.assignClass.<n>(o, s)` — Object.assign's per-field
|
|
6074
|
+
* write of a record into a class instance (classAssignPlan's gate):
|
|
6075
|
+
* optional source fields write only when present, and the instance
|
|
6076
|
+
* returns. */
|
|
6077
|
+
function classAssignHelper(lowerer, className, srcShapeId, loc) {
|
|
6078
|
+
if (!classAssignPlan(lowerer, className, srcShapeId))
|
|
6079
|
+
return null;
|
|
6080
|
+
const key = `obj.assignClass:${className}:${srcShapeId}`;
|
|
6081
|
+
const existing = lowerer.arrHofHelpers.get(key);
|
|
6082
|
+
if (existing)
|
|
6083
|
+
return existing;
|
|
6084
|
+
const helper = `%obj.assignClass.${lowerer.arrHofHelpers.size}`;
|
|
6085
|
+
lowerer.arrHofHelpers.set(key, helper);
|
|
6086
|
+
const sShape = lowerer.shapes.get(srcShapeId);
|
|
6087
|
+
const oT = { kind: "object", className };
|
|
6088
|
+
const sT = { kind: "record", shapeId: srcShapeId };
|
|
6089
|
+
const oRef = { kind: "varRef", localId: "o.0", type: oT, loc };
|
|
6090
|
+
const sRef = { kind: "varRef", localId: "s.0", type: sT, loc };
|
|
6091
|
+
const body = [];
|
|
6092
|
+
const info = lowerer.classes.get(className);
|
|
6093
|
+
for (const f of sShape.fields) {
|
|
6094
|
+
const declared = info.fields.get(f.name);
|
|
6095
|
+
const read = {
|
|
6096
|
+
kind: "recordGet",
|
|
6097
|
+
obj: sRef,
|
|
6098
|
+
shapeId: srcShapeId,
|
|
6099
|
+
field: f.name,
|
|
6100
|
+
type: f.type,
|
|
6101
|
+
loc,
|
|
6102
|
+
};
|
|
6103
|
+
const lift = typeEquals(declared, f.type) ? null : lowerer.widthLiftPlan(f.type, declared);
|
|
6104
|
+
const set = {
|
|
6105
|
+
kind: "fieldSet",
|
|
6106
|
+
obj: oRef,
|
|
6107
|
+
className,
|
|
6108
|
+
field: f.name,
|
|
6109
|
+
value: lift === null ? read : lowerer.applyWidthLift(lift, read, declared, loc),
|
|
6110
|
+
loc,
|
|
6111
|
+
};
|
|
6112
|
+
const present = lowerer.recordFieldPresent(sRef, srcShapeId, f.name, loc);
|
|
6113
|
+
body.push(present.kind === "recordHas"
|
|
6114
|
+
? { kind: "if", cond: present, then: [set], else_: null, loc }
|
|
6115
|
+
: set);
|
|
6116
|
+
}
|
|
6117
|
+
body.push({ kind: "return", value: oRef, loc });
|
|
6118
|
+
lowerer.liftedFns.push({
|
|
6119
|
+
name: helper,
|
|
6120
|
+
params: [
|
|
6121
|
+
{ localId: "o.0", name: "o", type: oT },
|
|
6122
|
+
{ localId: "s.0", name: "s", type: sT },
|
|
6123
|
+
],
|
|
6124
|
+
returnType: oT,
|
|
6125
|
+
locals: [
|
|
6126
|
+
{ id: "o.0", name: "o", type: oT, mutable: true },
|
|
6127
|
+
{ id: "s.0", name: "s", type: sT, mutable: true },
|
|
6128
|
+
],
|
|
6129
|
+
body,
|
|
6130
|
+
loc,
|
|
6131
|
+
});
|
|
6132
|
+
return helper;
|
|
6133
|
+
}
|
|
5545
6134
|
/** Interned `%obj.assign.<n>(t, s)` — Object.assign's per-field copy
|
|
5546
6135
|
* over signature-free records (every source field lands on a same-named,
|
|
5547
6136
|
* same-typed target field — the caller's gate): optional source fields
|
|
@@ -5556,6 +6145,7 @@ function recordAssignHelper(lowerer, targetShapeId, srcShapeId, loc) {
|
|
|
5556
6145
|
const helper = `%obj.assign.${lowerer.arrHofHelpers.size}`;
|
|
5557
6146
|
lowerer.arrHofHelpers.set(key, helper);
|
|
5558
6147
|
const sShape = lowerer.shapes.get(srcShapeId);
|
|
6148
|
+
const tShape = lowerer.shapes.get(targetShapeId);
|
|
5559
6149
|
const tT = { kind: "record", shapeId: targetShapeId };
|
|
5560
6150
|
const sT = { kind: "record", shapeId: srcShapeId };
|
|
5561
6151
|
const tRef = { kind: "varRef", localId: "t.0", type: tT, loc };
|
|
@@ -5570,12 +6160,13 @@ function recordAssignHelper(lowerer, targetShapeId, srcShapeId, loc) {
|
|
|
5570
6160
|
type: f.type,
|
|
5571
6161
|
loc,
|
|
5572
6162
|
};
|
|
6163
|
+
const targetType = tShape.fields.find((x) => x.name === f.name).type;
|
|
5573
6164
|
const set = {
|
|
5574
6165
|
kind: "recordSet",
|
|
5575
6166
|
obj: tRef,
|
|
5576
6167
|
shapeId: targetShapeId,
|
|
5577
6168
|
field: f.name,
|
|
5578
|
-
value: get,
|
|
6169
|
+
value: typeEquals(targetType, f.type) ? get : lowerer.coerceToExpected(get, targetType),
|
|
5579
6170
|
loc,
|
|
5580
6171
|
};
|
|
5581
6172
|
const present = lowerer.recordFieldPresent(sRef, srcShapeId, f.name, loc);
|
|
@@ -5600,17 +6191,22 @@ function recordAssignHelper(lowerer, targetShapeId, srcShapeId, loc) {
|
|
|
5600
6191
|
});
|
|
5601
6192
|
return helper;
|
|
5602
6193
|
}
|
|
5603
|
-
/** The `Iterator` global's statics (ES2025
|
|
5604
|
-
*
|
|
5605
|
-
*
|
|
5606
|
-
*
|
|
6194
|
+
/** The `Iterator` global's statics (ES2025): `Iterator.from` over a typed
|
|
6195
|
+
* built-in iterable lowers (lowerIteratorFromCall); every other member,
|
|
6196
|
+
* and other arguments, fence with the working spelling named instead of
|
|
6197
|
+
* the generic-method fence's monomorphization wording. */
|
|
5607
6198
|
function lowerIteratorStaticFence(lowerer, call, access) {
|
|
5608
6199
|
if (!lowerer.isStdlibGlobal(access.expression, "Iterator"))
|
|
5609
6200
|
return null;
|
|
5610
6201
|
if (!lowerer.isStdlibMember(access))
|
|
5611
6202
|
return null;
|
|
5612
|
-
lowerer
|
|
5613
|
-
|
|
6203
|
+
const from = lowerIteratorFromCall(lowerer, call, access);
|
|
6204
|
+
if (from)
|
|
6205
|
+
return from;
|
|
6206
|
+
lowerer.noLowering(`Iterator.${access.name.text}`, call, access.name.text === "from"
|
|
6207
|
+
? "Iterator.from accepts arrays, strings, typed arrays, Sets, Maps and iterator objects such as generators"
|
|
6208
|
+
: "iterator helpers apply directly to generators and to array, Map and Set iterators: " +
|
|
6209
|
+
"arr.values().map(f).take(n).toArray()");
|
|
5614
6210
|
}
|
|
5615
6211
|
/** `RegExp.escape(s)` (ES2025) — the one RegExp static with a lowering:
|
|
5616
6212
|
* a total string→string libCall (scr_regexp_escape). The lib pins the
|
|
@@ -5626,12 +6222,12 @@ function lowerRegExpStaticCall(lowerer, call, access) {
|
|
|
5626
6222
|
return null;
|
|
5627
6223
|
if (!lowerer.isStdlibMember(access))
|
|
5628
6224
|
return null;
|
|
5629
|
-
if (call.arguments.length !== 1 || ts.isSpreadElement(call.arguments[0])) {
|
|
5630
|
-
lowerer.noLowering(`RegExp.escape with ${call.arguments.length} arguments`, call);
|
|
6225
|
+
if (call.arguments.nodes.length !== 1 || ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
6226
|
+
lowerer.noLowering(`RegExp.escape with ${call.arguments.nodes.length} arguments`, call);
|
|
5631
6227
|
}
|
|
5632
|
-
const arg = lowerer.lowerExprExpecting(call.arguments[0], STRING);
|
|
6228
|
+
const arg = lowerer.lowerExprExpecting(call.arguments.nodes[0], STRING);
|
|
5633
6229
|
if (arg.type.kind !== "string")
|
|
5634
|
-
lowerer.badType(call.arguments[0], lowerer.typeOf(call.arguments[0]));
|
|
6230
|
+
lowerer.badType(call.arguments.nodes[0], lowerer.typeOf(call.arguments.nodes[0]));
|
|
5635
6231
|
return { kind: "libCall", fn: "regexp.escape", args: [arg], type: STRING, loc: locOf(call) };
|
|
5636
6232
|
}
|
|
5637
6233
|
/** The composed en-US Intl.NumberFormat form: `new Intl.NumberFormat(
|
|
@@ -5663,7 +6259,7 @@ function lowerIntlNumberFormatCall(lowerer, call, access) {
|
|
|
5663
6259
|
!lowerer.isStdlibGlobal(ctor.expression, "Intl")) {
|
|
5664
6260
|
return null;
|
|
5665
6261
|
}
|
|
5666
|
-
ctorArgs = recv.arguments ?? [];
|
|
6262
|
+
ctorArgs = recv.arguments?.nodes ?? [];
|
|
5667
6263
|
}
|
|
5668
6264
|
else {
|
|
5669
6265
|
return null;
|
|
@@ -5684,10 +6280,10 @@ function lowerIntlNumberFormatCall(lowerer, call, access) {
|
|
|
5684
6280
|
: "Intl.NumberFormat with a non-literal locale", locArg, '"en-US" (Node\'s default-build locale) is the one locale whose data the runtime embeds — ' +
|
|
5685
6281
|
"everything else is ICU data the binary does not carry");
|
|
5686
6282
|
}
|
|
5687
|
-
if (call.arguments.length !== 1 || ts.isSpreadElement(call.arguments[0])) {
|
|
5688
|
-
lowerer.noLowering(`Intl.NumberFormat("en-US").format with ${call.arguments.length} arguments`, call);
|
|
6283
|
+
if (call.arguments.nodes.length !== 1 || ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
6284
|
+
lowerer.noLowering(`Intl.NumberFormat("en-US").format with ${call.arguments.nodes.length} arguments`, call);
|
|
5689
6285
|
}
|
|
5690
|
-
const argNode = call.arguments[0];
|
|
6286
|
+
const argNode = call.arguments.nodes[0];
|
|
5691
6287
|
if (lowerer.mapTypeOf(lowerer.typeOf(argNode))?.kind !== "f64") {
|
|
5692
6288
|
lowerer.noLowering(`Intl.NumberFormat("en-US").format over a '${lowerer.checker.typeToString(lowerer.typeOf(argNode))}'`, argNode, "a number argument is the lowered form (bigint and numeric-string inputs have no representation)");
|
|
5693
6289
|
}
|
|
@@ -5730,9 +6326,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5730
6326
|
if ((member === "getOwnPropertyNames" ||
|
|
5731
6327
|
member === "getOwnPropertySymbols" ||
|
|
5732
6328
|
member === "getOwnPropertyDescriptors") &&
|
|
5733
|
-
call.arguments.length === 1 &&
|
|
5734
|
-
!call.arguments.some(ts.isSpreadElement)) {
|
|
5735
|
-
let object = lowerer.lowerExpr(call.arguments[0]);
|
|
6329
|
+
call.arguments.nodes.length === 1 &&
|
|
6330
|
+
!call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
6331
|
+
let object = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
5736
6332
|
if (object.type.kind === "string" ||
|
|
5737
6333
|
object.type.kind === "f64" ||
|
|
5738
6334
|
object.type.kind === "bool" ||
|
|
@@ -5752,11 +6348,11 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5752
6348
|
};
|
|
5753
6349
|
}
|
|
5754
6350
|
if ((member === "getPrototypeOf" || member === "setPrototypeOf") &&
|
|
5755
|
-
call.arguments.length === (member === "getPrototypeOf" ? 1 : 2) &&
|
|
5756
|
-
!call.arguments.some(ts.isSpreadElement)) {
|
|
5757
|
-
let object = lowerer.lowerExpr(call.arguments[0]);
|
|
6351
|
+
call.arguments.nodes.length === (member === "getPrototypeOf" ? 1 : 2) &&
|
|
6352
|
+
!call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
6353
|
+
let object = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
5758
6354
|
if (object.type.kind === "func") {
|
|
5759
|
-
const fnName = jsFuncNameOf(call.arguments[0], lowerer);
|
|
6355
|
+
const fnName = jsFuncNameOf(call.arguments.nodes[0], lowerer);
|
|
5760
6356
|
object = {
|
|
5761
6357
|
kind: "dynFrom",
|
|
5762
6358
|
value: object,
|
|
@@ -5767,7 +6363,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5767
6363
|
}
|
|
5768
6364
|
if (object.type.kind !== "dyn" &&
|
|
5769
6365
|
canConvertToDyn(object.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
5770
|
-
object = lowerer.coerceInto(call.arguments[0], object, DYN);
|
|
6366
|
+
object = lowerer.coerceInto(call.arguments.nodes[0], object, DYN);
|
|
5771
6367
|
if (object.type.kind === "dyn") {
|
|
5772
6368
|
const loc = locOf(call);
|
|
5773
6369
|
if (member === "getPrototypeOf") {
|
|
@@ -5789,7 +6385,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5789
6385
|
...(identityOnly ? { prototypeIdentityOnly: true } : {}),
|
|
5790
6386
|
};
|
|
5791
6387
|
}
|
|
5792
|
-
const prototype = lowerer.lowerExprExpecting(call.arguments[1], DYN);
|
|
6388
|
+
const prototype = lowerer.lowerExprExpecting(call.arguments.nodes[1], DYN);
|
|
5793
6389
|
if (prototype.type.kind === "dyn")
|
|
5794
6390
|
return {
|
|
5795
6391
|
kind: "libCall",
|
|
@@ -5800,8 +6396,8 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5800
6396
|
};
|
|
5801
6397
|
}
|
|
5802
6398
|
}
|
|
5803
|
-
if (member === "getOwnPropertyDescriptor" && call.arguments.length === 2) {
|
|
5804
|
-
const [receiver, key] = call.arguments;
|
|
6399
|
+
if (member === "getOwnPropertyDescriptor" && call.arguments.nodes.length === 2) {
|
|
6400
|
+
const [receiver, key] = call.arguments.nodes;
|
|
5805
6401
|
if (receiver &&
|
|
5806
6402
|
key &&
|
|
5807
6403
|
ts.isPropertyAccessExpression(receiver) &&
|
|
@@ -5834,12 +6430,13 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5834
6430
|
// with the operands still evaluated (tsc admits any pair — Object.is
|
|
5835
6431
|
// is (any, any) — and JS evaluates the arguments either way).
|
|
5836
6432
|
if (member === "is") {
|
|
5837
|
-
if (call.arguments.length !== 2 ||
|
|
5838
|
-
|
|
6433
|
+
if (call.arguments.nodes.length !== 2 ||
|
|
6434
|
+
call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
6435
|
+
lowerer.noLowering(`Object.is with ${call.arguments.nodes.length} arguments`, call, "exactly two arguments are the lowered form (JS treats a missing one as undefined — pass it explicitly)");
|
|
5839
6436
|
}
|
|
5840
6437
|
const loc = locOf(call);
|
|
5841
|
-
const leftNode = call.arguments[0];
|
|
5842
|
-
const rightNode = call.arguments[1];
|
|
6438
|
+
const leftNode = call.arguments.nodes[0];
|
|
6439
|
+
const rightNode = call.arguments.nodes[1];
|
|
5843
6440
|
const left = lowerer.lowerExpr(leftNode);
|
|
5844
6441
|
const right = lowerer.lowerExpr(rightNode);
|
|
5845
6442
|
const lk = left.type.kind;
|
|
@@ -5945,18 +6542,18 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5945
6542
|
// Native checked objects retain a live prototype and can install an
|
|
5946
6543
|
// own-property descriptor table during creation.
|
|
5947
6544
|
if (member === "create") {
|
|
5948
|
-
if (call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
6545
|
+
if (call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
5949
6546
|
lowerer.noLowering("Object.create with spread arguments", call);
|
|
5950
6547
|
}
|
|
5951
|
-
if (call.arguments.length < 1 || call.arguments.length > 2) {
|
|
5952
|
-
lowerer.noLowering(`Object.create with ${call.arguments.length} arguments`, call);
|
|
6548
|
+
if (call.arguments.nodes.length < 1 || call.arguments.nodes.length > 2) {
|
|
6549
|
+
lowerer.noLowering(`Object.create with ${call.arguments.nodes.length} arguments`, call);
|
|
5953
6550
|
}
|
|
5954
6551
|
const loc = locOf(call);
|
|
5955
|
-
let protoNode = call.arguments[0];
|
|
6552
|
+
let protoNode = call.arguments.nodes[0];
|
|
5956
6553
|
while (ts.isParenthesizedExpression(protoNode))
|
|
5957
6554
|
protoNode = protoNode.expression;
|
|
5958
6555
|
const nullProto = protoNode.kind === ts.SyntaxKind.NullKeyword;
|
|
5959
|
-
if (nullProto && call.arguments.length === 1) {
|
|
6556
|
+
if (nullProto && call.arguments.nodes.length === 1) {
|
|
5960
6557
|
return { kind: "libCall", fn: "dyn.objCreateNullProto", args: [], type: DYN, loc };
|
|
5961
6558
|
}
|
|
5962
6559
|
let proto = nullProto
|
|
@@ -5981,9 +6578,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
5981
6578
|
canConvertToDyn(proto.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
5982
6579
|
proto = lowerer.coerceInto(protoNode, proto, DYN);
|
|
5983
6580
|
if (proto.type.kind === "dyn") {
|
|
5984
|
-
if (call.arguments.length === 1)
|
|
6581
|
+
if (call.arguments.nodes.length === 1)
|
|
5985
6582
|
return { kind: "libCall", fn: "dyn.objCreate", args: [proto], type: DYN, loc };
|
|
5986
|
-
const descriptors = lowerer.lowerExprExpecting(call.arguments[1], DYN);
|
|
6583
|
+
const descriptors = lowerer.lowerExprExpecting(call.arguments.nodes[1], DYN);
|
|
5987
6584
|
if (descriptors.type.kind === "dyn")
|
|
5988
6585
|
return {
|
|
5989
6586
|
kind: "libCall",
|
|
@@ -6001,10 +6598,10 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6001
6598
|
const prototype = lowerClassPrototypeAssign(lowerer, call);
|
|
6002
6599
|
if (prototype)
|
|
6003
6600
|
return prototype;
|
|
6004
|
-
if (isJsSourceFile(
|
|
6005
|
-
call.arguments.length > 0 &&
|
|
6006
|
-
!call.arguments.some(ts.isSpreadElement)) {
|
|
6007
|
-
const target = tryLowerExpression(lowerer, call.arguments[0]);
|
|
6601
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
6602
|
+
call.arguments.nodes.length > 0 &&
|
|
6603
|
+
!call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
6604
|
+
const target = tryLowerExpression(lowerer, call.arguments.nodes[0]);
|
|
6008
6605
|
if (target &&
|
|
6009
6606
|
((target.type.kind === "func" && lowerer.dynConvertible(target.type)) ||
|
|
6010
6607
|
(target.type.kind === "object" && lowerer.dynConvertible(target.type)))) {
|
|
@@ -6016,7 +6613,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6016
6613
|
lowerer.coerceToExpected(target, DYN),
|
|
6017
6614
|
{
|
|
6018
6615
|
kind: "dynArrLit",
|
|
6019
|
-
elems: call.arguments.
|
|
6616
|
+
elems: call.arguments.nodes
|
|
6617
|
+
.slice(1)
|
|
6618
|
+
.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
6020
6619
|
type: DYN,
|
|
6021
6620
|
loc,
|
|
6022
6621
|
},
|
|
@@ -6026,6 +6625,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6026
6625
|
};
|
|
6027
6626
|
}
|
|
6028
6627
|
}
|
|
6628
|
+
const onError = lowerObjectAssignOntoError(lowerer, call);
|
|
6629
|
+
if (onError)
|
|
6630
|
+
return onError;
|
|
6029
6631
|
const hybrid = lowerObjectAssignHybrid(lowerer, call);
|
|
6030
6632
|
if (hybrid)
|
|
6031
6633
|
return hybrid;
|
|
@@ -6034,15 +6636,16 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6034
6636
|
// exactly the source literal's properties, which IS the source
|
|
6035
6637
|
// literal evaluated (both fresh, no alias can tell them apart).
|
|
6036
6638
|
// Everything else keeps the spread hint (stdlibMemberFence).
|
|
6037
|
-
if (call.arguments.length === 2 &&
|
|
6038
|
-
|
|
6639
|
+
if (call.arguments.nodes.length === 2 &&
|
|
6640
|
+
!call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
6641
|
+
let target = call.arguments.nodes[0];
|
|
6039
6642
|
while (ts.isParenthesizedExpression(target))
|
|
6040
6643
|
target = target.expression;
|
|
6041
|
-
let source = call.arguments[1];
|
|
6644
|
+
let source = call.arguments.nodes[1];
|
|
6042
6645
|
while (ts.isParenthesizedExpression(source))
|
|
6043
6646
|
source = source.expression;
|
|
6044
6647
|
if (ts.isObjectLiteralExpression(target) &&
|
|
6045
|
-
target.properties.length === 0 &&
|
|
6648
|
+
target.properties.nodes.length === 0 &&
|
|
6046
6649
|
ts.isObjectLiteralExpression(source)) {
|
|
6047
6650
|
return lowerer.lowerExpr(source);
|
|
6048
6651
|
}
|
|
@@ -6062,22 +6665,40 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6062
6665
|
// optional field must not erase the target's value — Node copies own
|
|
6063
6666
|
// keys only — while an explicit `k: undefined` does). Everything
|
|
6064
6667
|
// else keeps the spread hint.
|
|
6065
|
-
if (call.arguments.length === 2 &&
|
|
6066
|
-
|
|
6067
|
-
const
|
|
6668
|
+
if (call.arguments.nodes.length === 2 &&
|
|
6669
|
+
!call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
6670
|
+
const tProbe = tryLowerExpression(lowerer, call.arguments.nodes[0]);
|
|
6671
|
+
const sProbe = tryLowerExpression(lowerer, call.arguments.nodes[1]);
|
|
6068
6672
|
// CHECKED-DYNAMIC target and source (the JS file-scope
|
|
6069
6673
|
// object-literal identity story): the runtime dyn copy — own
|
|
6070
6674
|
// members of the source land on the target, which returns.
|
|
6071
6675
|
if (tProbe?.type.kind === "dyn") {
|
|
6072
6676
|
const loc = locOf(call);
|
|
6073
|
-
const target = lowerer.lowerExpr(call.arguments[0]);
|
|
6074
|
-
const rawSource = lowerer.lowerExpr(call.arguments[1]);
|
|
6075
|
-
fenceSymbolFieldCopy(lowerer, call.arguments[1], rawSource.type);
|
|
6677
|
+
const target = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
6678
|
+
const rawSource = lowerer.lowerExpr(call.arguments.nodes[1]);
|
|
6679
|
+
fenceSymbolFieldCopy(lowerer, call.arguments.nodes[1], rawSource.type);
|
|
6076
6680
|
const source = lowerer.coerceToExpected(rawSource, DYN);
|
|
6077
6681
|
if (target.type.kind === "dyn" && source.type.kind === "dyn") {
|
|
6078
6682
|
return { kind: "libCall", fn: "dyn.assign", args: [target, source], type: DYN, loc };
|
|
6079
6683
|
}
|
|
6080
6684
|
}
|
|
6685
|
+
// A CLASS-INSTANCE target and a plain record source whose fields are
|
|
6686
|
+
// all fields the class declares with the same types
|
|
6687
|
+
// (`Object.assign(this, { retries: 3 })`): the per-field write into
|
|
6688
|
+
// the instance, returning it — the instance mutates in place.
|
|
6689
|
+
if (tProbe?.type.kind === "object" && sProbe?.type.kind === "record") {
|
|
6690
|
+
const helper = classAssignPlan(lowerer, tProbe.type.className, sProbe.type.shapeId);
|
|
6691
|
+
if (helper) {
|
|
6692
|
+
const loc = locOf(call);
|
|
6693
|
+
const target = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
6694
|
+
const source = lowerer.lowerExpr(call.arguments.nodes[1]);
|
|
6695
|
+
if (target.type.kind === "object" && source.type.kind === "record") {
|
|
6696
|
+
const name = classAssignHelper(lowerer, target.type.className, source.type.shapeId, loc);
|
|
6697
|
+
if (name)
|
|
6698
|
+
return { kind: "call", callee: name, args: [target, source], type: target.type, loc };
|
|
6699
|
+
}
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6081
6702
|
if (tProbe?.type.kind === "record" && sProbe?.type.kind === "record") {
|
|
6082
6703
|
const tShape = lowerer.shapes.get(tProbe.type.shapeId);
|
|
6083
6704
|
const sShape = lowerer.shapes.get(sProbe.type.shapeId);
|
|
@@ -6091,12 +6712,15 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6091
6712
|
!shapeHasAccessorSlots(sShape) &&
|
|
6092
6713
|
sShape.fields.every((sf) => {
|
|
6093
6714
|
const tf = tShape.fields.find((x) => x.name === sf.name);
|
|
6094
|
-
|
|
6715
|
+
// A source value converts into a wider target field (`{ bail:
|
|
6716
|
+
// true }` into `bail?: boolean`).
|
|
6717
|
+
return (tf !== undefined &&
|
|
6718
|
+
(typeEquals(tf.type, sf.type) || lowerer.coercibleValue(sf.type, tf.type)));
|
|
6095
6719
|
});
|
|
6096
6720
|
if (ok) {
|
|
6097
6721
|
const loc = locOf(call);
|
|
6098
|
-
const target = lowerer.lowerExpr(call.arguments[0]);
|
|
6099
|
-
const source = lowerer.lowerExpr(call.arguments[1]);
|
|
6722
|
+
const target = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
6723
|
+
const source = lowerer.lowerExpr(call.arguments.nodes[1]);
|
|
6100
6724
|
if (target.type.kind === "record" && source.type.kind === "record") {
|
|
6101
6725
|
const helper = recordAssignHelper(lowerer, target.type.shapeId, source.type.shapeId, loc);
|
|
6102
6726
|
return { kind: "call", callee: helper, args: [target, source], type: target.type, loc };
|
|
@@ -6104,6 +6728,34 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6104
6728
|
}
|
|
6105
6729
|
}
|
|
6106
6730
|
}
|
|
6731
|
+
// `throw Object.assign(record, { extra })`: an error-shaped record given
|
|
6732
|
+
// a member its type lacks, thrown at once. A fixed record cannot grow
|
|
6733
|
+
// the member, so the throw carries a checked-dynamic copy of the target
|
|
6734
|
+
// with the source's members added. The copy is unobservable: control
|
|
6735
|
+
// leaves with the throw, so nothing on that path reads the target again.
|
|
6736
|
+
{
|
|
6737
|
+
let parent = call.parent;
|
|
6738
|
+
while (parent && ts.isParenthesizedExpression(parent))
|
|
6739
|
+
parent = parent.parent;
|
|
6740
|
+
const argNodes = call.arguments.nodes;
|
|
6741
|
+
if (parent &&
|
|
6742
|
+
ts.isThrowStatement(parent) &&
|
|
6743
|
+
argNodes.length === 2 &&
|
|
6744
|
+
!argNodes.some((a) => ts.isSpreadElement(a))) {
|
|
6745
|
+
const tProbe = tryLowerExpression(lowerer, argNodes[0]);
|
|
6746
|
+
const sProbe = tryLowerExpression(lowerer, argNodes[1]);
|
|
6747
|
+
if (tProbe?.type.kind === "record" &&
|
|
6748
|
+
lowerer.dynConvertible(tProbe.type) &&
|
|
6749
|
+
sProbe &&
|
|
6750
|
+
(sProbe.type.kind === "dyn" || lowerer.dynConvertible(sProbe.type))) {
|
|
6751
|
+
const loc = locOf(call);
|
|
6752
|
+
const target = lowerer.coerceToExpected(lowerer.lowerExpr(argNodes[0]), DYN);
|
|
6753
|
+
const source = lowerer.coerceToExpected(lowerer.lowerExpr(argNodes[1]), DYN);
|
|
6754
|
+
if (target.type.kind === "dyn" && source.type.kind === "dyn")
|
|
6755
|
+
return { kind: "libCall", fn: "dyn.assign", args: [target, source], type: DYN, loc };
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6107
6759
|
// `Object.assign(target, ...sources)` over a CHECKED-DYNAMIC target
|
|
6108
6760
|
// — the n-ary/spread form (`Object.assign({}, ...plugins.map(p =>
|
|
6109
6761
|
// p.options), coreOptions)`, support.js's option-table merge). The
|
|
@@ -6123,16 +6775,18 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6123
6775
|
// unobservable), or a nullish unit (Node's ToObject TypeError
|
|
6124
6776
|
// throws at the call, catchably); aliased record targets keep the
|
|
6125
6777
|
// fence — their identity could not survive the conversion.
|
|
6126
|
-
if (call.arguments.length >= 1 && !ts.isSpreadElement(call.arguments[0])) {
|
|
6127
|
-
let targetNode = call.arguments[0];
|
|
6778
|
+
if (call.arguments.nodes.length >= 1 && !ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
6779
|
+
let targetNode = call.arguments.nodes[0];
|
|
6128
6780
|
while (ts.isParenthesizedExpression(targetNode))
|
|
6129
6781
|
targetNode = targetNode.expression;
|
|
6130
6782
|
const freshLiteralTarget = ts.isObjectLiteralExpression(targetNode);
|
|
6131
|
-
const tProbe = freshLiteralTarget
|
|
6783
|
+
const tProbe = freshLiteralTarget
|
|
6784
|
+
? null
|
|
6785
|
+
: tryLowerExpression(lowerer, call.arguments.nodes[0]);
|
|
6132
6786
|
const tKind = tProbe?.type.kind;
|
|
6133
6787
|
if (freshLiteralTarget || tKind === "dyn" || tKind === "nullT" || tKind === "undefinedT") {
|
|
6134
6788
|
const loc = locOf(call);
|
|
6135
|
-
const target = lowerer.lowerExprExpecting(call.arguments[0], DYN);
|
|
6789
|
+
const target = lowerer.lowerExprExpecting(call.arguments.nodes[0], DYN);
|
|
6136
6790
|
if (target.type.kind === "dyn") {
|
|
6137
6791
|
const t = lowerer.declareHiddenLocal("%oat", DYN);
|
|
6138
6792
|
const p = lowerer.declareHiddenLocal("%oap", DYN);
|
|
@@ -6152,7 +6806,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6152
6806
|
// SINGLE LAST argument; every other spread position drives
|
|
6153
6807
|
// the real iterator protocol, whose failure describes the
|
|
6154
6808
|
// value — the two runtime variants, picked here by position.
|
|
6155
|
-
const sources = call.arguments.slice(1);
|
|
6809
|
+
const sources = call.arguments.nodes.slice(1);
|
|
6156
6810
|
const spreadCount = sources.filter((a) => ts.isSpreadElement(a)).length;
|
|
6157
6811
|
let ok = true;
|
|
6158
6812
|
for (let i = 0; i < sources.length; i++) {
|
|
@@ -6161,6 +6815,19 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6161
6815
|
const srcNode = spread ? argNode.expression : argNode;
|
|
6162
6816
|
const rawSource = lowerer.lowerExpr(srcNode);
|
|
6163
6817
|
fenceSymbolFieldCopy(lowerer, srcNode, rawSource.type, spread);
|
|
6818
|
+
// A class instance copied into a fresh object
|
|
6819
|
+
// (`Object.assign({}, instance)`): the result is a plain
|
|
6820
|
+
// object holding the instance's own fields, never an
|
|
6821
|
+
// instance, so a result the checker types as the class has
|
|
6822
|
+
// no representation (the checked cast would throw).
|
|
6823
|
+
if (rawSource.type.kind === "object" &&
|
|
6824
|
+
freshLiteralTarget &&
|
|
6825
|
+
!ts.isExpressionStatement(call.parent)) {
|
|
6826
|
+
const resultT = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6827
|
+
if (resultT !== null && resultT.kind === "object") {
|
|
6828
|
+
lowerer.unsupported("SC1090", srcNode, `Object.assign copying a '${lowerer.fmt(rawSource.type)}' instance into a fresh object typed as the class (the copy is a plain object holding the instance's own fields, not an instance — build the object literal from the fields you need)`);
|
|
6829
|
+
}
|
|
6830
|
+
}
|
|
6164
6831
|
const src = lowerer.coerceToExpected(rawSource, DYN);
|
|
6165
6832
|
if (src.type.kind !== "dyn") {
|
|
6166
6833
|
ok = false;
|
|
@@ -6178,7 +6845,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6178
6845
|
args: [
|
|
6179
6846
|
pRef(),
|
|
6180
6847
|
src,
|
|
6181
|
-
{
|
|
6848
|
+
{
|
|
6849
|
+
kind: "strLit",
|
|
6850
|
+
value: ts.getTextOfNode(srcNode),
|
|
6851
|
+
type: STRING,
|
|
6852
|
+
loc: argLoc,
|
|
6853
|
+
},
|
|
6182
6854
|
],
|
|
6183
6855
|
type: VOID,
|
|
6184
6856
|
loc: argLoc,
|
|
@@ -6220,24 +6892,29 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6220
6892
|
}
|
|
6221
6893
|
return null;
|
|
6222
6894
|
}
|
|
6223
|
-
if ((member === "defineProperty" && call.arguments.length === 3) ||
|
|
6224
|
-
(member === "getOwnPropertyDescriptor" && call.arguments.length === 2)) {
|
|
6225
|
-
if (call.arguments.some((a) => ts.isSpreadElement(a)))
|
|
6895
|
+
if ((member === "defineProperty" && call.arguments.nodes.length === 3) ||
|
|
6896
|
+
(member === "getOwnPropertyDescriptor" && call.arguments.nodes.length === 2)) {
|
|
6897
|
+
if (call.arguments.nodes.some((a) => ts.isSpreadElement(a)))
|
|
6226
6898
|
return null;
|
|
6227
|
-
let target = tryLowerExpression(lowerer, call.arguments[0]);
|
|
6228
|
-
const targetNode = call.arguments[0];
|
|
6899
|
+
let target = tryLowerExpression(lowerer, call.arguments.nodes[0]);
|
|
6900
|
+
const targetNode = call.arguments.nodes[0];
|
|
6229
6901
|
// The checker gives C.prototype the instance type, but its lowered
|
|
6230
6902
|
// value is the shared prototype table, not an instance to unbox.
|
|
6231
6903
|
const prototypeTarget = ts.isPropertyAccessExpression(targetNode) &&
|
|
6232
6904
|
targetNode.name.text === "prototype" &&
|
|
6233
6905
|
(exactClassOfReceiver(lowerer, targetNode.expression) !== null ||
|
|
6234
6906
|
storedClassValueType(lowerer, targetNode.expression)?.kind === "classval");
|
|
6235
|
-
const declaredTarget = target?.type.kind === "dyn" &&
|
|
6907
|
+
const declaredTarget = target?.type.kind === "dyn" &&
|
|
6908
|
+
!prototypeTarget &&
|
|
6909
|
+
!isJsSourceFile(ts.getSourceFileOfNode(targetNode))
|
|
6236
6910
|
? lowerer.mapTypeOf(lowerer.typeOf(targetNode))
|
|
6237
6911
|
: null;
|
|
6238
6912
|
if (target && declaredTarget && isDynTypedRefType(declaredTarget))
|
|
6239
6913
|
target = lowerer.coerceToExpected(target, declaredTarget);
|
|
6240
6914
|
if (target && member === "defineProperty") {
|
|
6915
|
+
const field = lowerClassFieldDefine(lowerer, call, target);
|
|
6916
|
+
if (field)
|
|
6917
|
+
return field;
|
|
6241
6918
|
const native = lowerClassDataDescriptor(lowerer, call, member, target);
|
|
6242
6919
|
if (native)
|
|
6243
6920
|
return native;
|
|
@@ -6249,7 +6926,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6249
6926
|
target = lowerer.coerceToExpected(target, DYN);
|
|
6250
6927
|
}
|
|
6251
6928
|
// Error instances share a live property table with their checked view.
|
|
6252
|
-
const keyNode = call.arguments[1];
|
|
6929
|
+
const keyNode = call.arguments.nodes[1];
|
|
6253
6930
|
if (target?.type.kind === "object" &&
|
|
6254
6931
|
target.type.className !== "%DOMException" &&
|
|
6255
6932
|
lowerer.errorHierarchyClassOf(target.type.className) &&
|
|
@@ -6258,12 +6935,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6258
6935
|
target = lowerer.coerceToExpected(target, DYN);
|
|
6259
6936
|
}
|
|
6260
6937
|
if (target?.type.kind === "func" && lowerer.dynConvertible(target.type)) {
|
|
6261
|
-
const fnName = jsFuncNameOf(call.arguments[0], lowerer);
|
|
6938
|
+
const fnName = jsFuncNameOf(call.arguments.nodes[0], lowerer);
|
|
6262
6939
|
target = {
|
|
6263
6940
|
kind: "dynFrom",
|
|
6264
6941
|
value: target,
|
|
6265
6942
|
type: DYN,
|
|
6266
|
-
loc: locOf(call.arguments[0]),
|
|
6943
|
+
loc: locOf(call.arguments.nodes[0]),
|
|
6267
6944
|
...(fnName !== null ? { fnName } : {}),
|
|
6268
6945
|
};
|
|
6269
6946
|
}
|
|
@@ -6273,8 +6950,8 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6273
6950
|
if (!target || (target.type.kind !== "dyn" && !isUnitType(target.type) && !descriptorPrimitive))
|
|
6274
6951
|
return null;
|
|
6275
6952
|
if (target.type.kind !== "dyn")
|
|
6276
|
-
target = { kind: "dynFrom", value: target, type: DYN, loc: locOf(call.arguments[0]) };
|
|
6277
|
-
const key = lowerer.lowerExprExpecting(call.arguments[1], DYN);
|
|
6953
|
+
target = { kind: "dynFrom", value: target, type: DYN, loc: locOf(call.arguments.nodes[0]) };
|
|
6954
|
+
const key = lowerer.lowerExprExpecting(call.arguments.nodes[1], DYN);
|
|
6278
6955
|
if (key.type.kind !== "dyn")
|
|
6279
6956
|
return null;
|
|
6280
6957
|
if (member === "getOwnPropertyDescriptor") {
|
|
@@ -6286,7 +6963,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6286
6963
|
loc: locOf(call),
|
|
6287
6964
|
};
|
|
6288
6965
|
}
|
|
6289
|
-
const descriptor = lowerer.lowerExprExpecting(call.arguments[2], DYN);
|
|
6966
|
+
const descriptor = lowerer.lowerExprExpecting(call.arguments.nodes[2], DYN);
|
|
6290
6967
|
if (descriptor.type.kind !== "dyn")
|
|
6291
6968
|
return null;
|
|
6292
6969
|
return {
|
|
@@ -6305,12 +6982,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6305
6982
|
// The result is the target, like JS. Typed targets keep the fence:
|
|
6306
6983
|
// static shapes have no property table to extend.
|
|
6307
6984
|
if (member === "defineProperties" &&
|
|
6308
|
-
call.arguments.length === 2 &&
|
|
6309
|
-
!call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
6985
|
+
call.arguments.nodes.length === 2 &&
|
|
6986
|
+
!call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
6310
6987
|
const prototype = lowerClassPrototypeDescriptors(lowerer, call, member);
|
|
6311
6988
|
if (prototype)
|
|
6312
6989
|
return prototype;
|
|
6313
|
-
let target = tryLowerExpression(lowerer, call.arguments[0]);
|
|
6990
|
+
let target = tryLowerExpression(lowerer, call.arguments.nodes[0]);
|
|
6314
6991
|
if (target) {
|
|
6315
6992
|
const native = lowerClassDataDescriptor(lowerer, call, member, target);
|
|
6316
6993
|
if (native)
|
|
@@ -6323,20 +7000,20 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6323
7000
|
if (target &&
|
|
6324
7001
|
target.type.kind === "func" &&
|
|
6325
7002
|
canBoxFuncIntoDyn(target.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
6326
|
-
const fnName = jsFuncNameOf(call.arguments[0], lowerer);
|
|
7003
|
+
const fnName = jsFuncNameOf(call.arguments.nodes[0], lowerer);
|
|
6327
7004
|
target = {
|
|
6328
7005
|
kind: "dynFrom",
|
|
6329
7006
|
value: target,
|
|
6330
7007
|
type: DYN,
|
|
6331
|
-
loc: locOf(call.arguments[0]),
|
|
7008
|
+
loc: locOf(call.arguments.nodes[0]),
|
|
6332
7009
|
...(fnName !== null ? { fnName } : {}),
|
|
6333
7010
|
};
|
|
6334
7011
|
}
|
|
6335
7012
|
if (target && isUnitType(target.type)) {
|
|
6336
|
-
target = { kind: "dynFrom", value: target, type: DYN, loc: locOf(call.arguments[0]) };
|
|
7013
|
+
target = { kind: "dynFrom", value: target, type: DYN, loc: locOf(call.arguments.nodes[0]) };
|
|
6337
7014
|
}
|
|
6338
7015
|
if (target?.type.kind === "dyn") {
|
|
6339
|
-
const descs = lowerer.lowerExprExpecting(call.arguments[1], DYN);
|
|
7016
|
+
const descs = lowerer.lowerExprExpecting(call.arguments.nodes[1], DYN);
|
|
6340
7017
|
if (descs.type.kind === "dyn") {
|
|
6341
7018
|
return {
|
|
6342
7019
|
kind: "libCall",
|
|
@@ -6350,9 +7027,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6350
7027
|
return null;
|
|
6351
7028
|
}
|
|
6352
7029
|
if (["preventExtensions", "isExtensible", "seal", "isSealed"].includes(member) &&
|
|
6353
|
-
call.arguments.length === 1 &&
|
|
6354
|
-
!ts.isSpreadElement(call.arguments[0])) {
|
|
6355
|
-
const value = lowerer.lowerExpr(call.arguments[0]);
|
|
7030
|
+
call.arguments.nodes.length === 1 &&
|
|
7031
|
+
!ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
7032
|
+
const value = lowerer.lowerExpr(call.arguments.nodes[0]);
|
|
6356
7033
|
if (value.type.kind === "string" ||
|
|
6357
7034
|
value.type.kind === "f64" ||
|
|
6358
7035
|
value.type.kind === "bool" ||
|
|
@@ -6372,6 +7049,21 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6372
7049
|
loc,
|
|
6373
7050
|
};
|
|
6374
7051
|
}
|
|
7052
|
+
if (member === "preventExtensions" || member === "seal") {
|
|
7053
|
+
const integrity = lowerClassIntegrity(lowerer, call, member, value);
|
|
7054
|
+
if (integrity)
|
|
7055
|
+
return integrity;
|
|
7056
|
+
}
|
|
7057
|
+
else if (isDynTypedRefType(value.type)) {
|
|
7058
|
+
// The instance's checked view carries its integrity state.
|
|
7059
|
+
return {
|
|
7060
|
+
kind: "libCall",
|
|
7061
|
+
fn: member === "isSealed" ? "dyn.isSealed" : "dyn.isExtensible",
|
|
7062
|
+
args: [lowerer.coerceToExpected(value, DYN)],
|
|
7063
|
+
type: BOOL,
|
|
7064
|
+
loc: locOf(call),
|
|
7065
|
+
};
|
|
7066
|
+
}
|
|
6375
7067
|
if (value.type.kind === "dyn") {
|
|
6376
7068
|
const operation = {
|
|
6377
7069
|
preventExtensions: "dyn.preventExtensions",
|
|
@@ -6395,19 +7087,19 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6395
7087
|
// other reference can write). Primitives pass through per ES2015.
|
|
6396
7088
|
// Aliased objects keep a fence: a later write through the original
|
|
6397
7089
|
// reference would need the runtime frozen bit (strict mode throws).
|
|
6398
|
-
if (member === "isFrozen" && call.arguments.length === 1) {
|
|
6399
|
-
const value = lowerer.lowerExprExpecting(call.arguments[0], DYN);
|
|
7090
|
+
if (member === "isFrozen" && call.arguments.nodes.length === 1) {
|
|
7091
|
+
const value = lowerer.lowerExprExpecting(call.arguments.nodes[0], DYN);
|
|
6400
7092
|
return { kind: "libCall", fn: "dyn.isFrozen", args: [value], type: BOOL, loc: locOf(call) };
|
|
6401
7093
|
}
|
|
6402
7094
|
if (member === "freeze") {
|
|
6403
|
-
if (call.arguments.length !== 1 || ts.isSpreadElement(call.arguments[0])) {
|
|
6404
|
-
lowerer.noLowering(`Object.freeze with ${call.arguments.length} arguments`, call);
|
|
7095
|
+
if (call.arguments.nodes.length !== 1 || ts.isSpreadElement(call.arguments.nodes[0])) {
|
|
7096
|
+
lowerer.noLowering(`Object.freeze with ${call.arguments.nodes.length} arguments`, call);
|
|
6405
7097
|
}
|
|
6406
|
-
const argNode = call.arguments[0];
|
|
7098
|
+
const argNode = call.arguments.nodes[0];
|
|
6407
7099
|
let inner = argNode;
|
|
6408
7100
|
while (ts.isParenthesizedExpression(inner) || ts.isAsExpression(inner))
|
|
6409
7101
|
inner = inner.expression;
|
|
6410
|
-
const value = isJsSourceFile(
|
|
7102
|
+
const value = isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
6411
7103
|
(ts.isObjectLiteralExpression(inner) || ts.isArrayLiteralExpression(inner))
|
|
6412
7104
|
? lowerer.lowerExprExpecting(argNode, DYN)
|
|
6413
7105
|
: lowerer.lowerExpr(argNode);
|
|
@@ -6434,6 +7126,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6434
7126
|
arm.kind === "string" ||
|
|
6435
7127
|
arm.kind === "symbol"))
|
|
6436
7128
|
return value;
|
|
7129
|
+
const integrity = lowerClassIntegrity(lowerer, call, "freeze", value);
|
|
7130
|
+
if (integrity)
|
|
7131
|
+
return integrity;
|
|
6437
7132
|
lowerer.noLowering("Object.freeze of a possibly-aliased value", call, "freeze of a FRESH object/array literal (and of primitives) compiles — frozen-ness is unobservable there; an aliased target's later writes would need the runtime frozen bit");
|
|
6438
7133
|
}
|
|
6439
7134
|
// `Object.hasOwn(r, k)` over a RECORD receiver: a record's own-key set
|
|
@@ -6445,10 +7140,10 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6445
7140
|
// records additionally probe the overflow map; non-record receivers
|
|
6446
7141
|
// do too.
|
|
6447
7142
|
if (member === "hasOwn" &&
|
|
6448
|
-
call.arguments.length === 2 &&
|
|
6449
|
-
!call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
6450
|
-
const recvNode = call.arguments[0];
|
|
6451
|
-
const keyNode = call.arguments[1];
|
|
7143
|
+
call.arguments.nodes.length === 2 &&
|
|
7144
|
+
!call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
7145
|
+
const recvNode = call.arguments.nodes[0];
|
|
7146
|
+
const keyNode = call.arguments.nodes[1];
|
|
6452
7147
|
const probed = tryLowerExpression(lowerer, recvNode);
|
|
6453
7148
|
const arrayKey = probed?.type.kind === "array" ? lowerer.lowerExpr(keyNode) : null;
|
|
6454
7149
|
if (probed?.type.kind === "array" && arrayKey?.type.kind === "f64") {
|
|
@@ -6507,9 +7202,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6507
7202
|
}
|
|
6508
7203
|
if (member !== "keys" && member !== "values" && member !== "entries")
|
|
6509
7204
|
return null;
|
|
6510
|
-
if (call.arguments.length !== 1 || ts.isSpreadElement(call.arguments[0]))
|
|
7205
|
+
if (call.arguments.nodes.length !== 1 || ts.isSpreadElement(call.arguments.nodes[0]))
|
|
6511
7206
|
return null;
|
|
6512
|
-
const argNode = call.arguments[0];
|
|
7207
|
+
const argNode = call.arguments.nodes[0];
|
|
6513
7208
|
// util.types and node:util/types list Node's pinned key census
|
|
6514
7209
|
// (UTIL_TYPES_KEYS): the object's own keys in Node's order, or the module
|
|
6515
7210
|
// namespace's export names sorted with "default". values/entries would
|
|
@@ -6524,7 +7219,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6524
7219
|
? lowerer.checker.getSymbolAtLocation(argNode)
|
|
6525
7220
|
: undefined;
|
|
6526
7221
|
const namespace = symbol
|
|
6527
|
-
?
|
|
7222
|
+
? symbol.declarations.some((decl) => ts.isNamespaceImport(decl))
|
|
6528
7223
|
: false;
|
|
6529
7224
|
const names = namespace ? [...UTIL_TYPES_KEYS, "default"].sort() : UTIL_TYPES_KEYS;
|
|
6530
7225
|
const loc = locOf(call);
|
|
@@ -6599,7 +7294,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6599
7294
|
probed.type.kind === "f64" ||
|
|
6600
7295
|
probed.type.kind === "bool");
|
|
6601
7296
|
const isJsUnion = probed?.type.kind === "union" &&
|
|
6602
|
-
isJsSourceFile(
|
|
7297
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
6603
7298
|
lowerer.dynConvertible(probed.type);
|
|
6604
7299
|
if (isDyn ||
|
|
6605
7300
|
isPrimitive ||
|
|
@@ -6618,7 +7313,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6618
7313
|
// entries as a native [string, any][]: the checker keeps every later
|
|
6619
7314
|
// write to the arrays well typed. JavaScript may store anything into
|
|
6620
7315
|
// them, so it keeps the checked-dynamic arrays.
|
|
6621
|
-
const resultT = member !== "values" && !isJsSourceFile(
|
|
7316
|
+
const resultT = member !== "values" && !isJsSourceFile(ts.getSourceFileOfNode(call))
|
|
6622
7317
|
? lowerer.mapTypeOf(lowerer.typeOf(call))
|
|
6623
7318
|
: null;
|
|
6624
7319
|
if (member === "keys" && resultT?.kind === "array" && resultT.elem.kind === "string")
|
|
@@ -6641,7 +7336,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6641
7336
|
// program only iterates or indexes the result, or passes it to a
|
|
6642
7337
|
// read-only array method, a native vector of the checked values skips
|
|
6643
7338
|
// building that array and, for for-of, the iterator protocol.
|
|
6644
|
-
if (member === "values" &&
|
|
7339
|
+
if (member === "values" &&
|
|
7340
|
+
!isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
7341
|
+
consumesValueList(call))
|
|
6645
7342
|
return {
|
|
6646
7343
|
kind: "libCall",
|
|
6647
7344
|
fn: "dyn.objValueList",
|
|
@@ -6676,7 +7373,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6676
7373
|
const enumerationType = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6677
7374
|
if ((member === "values" || member === "entries") &&
|
|
6678
7375
|
(enumerationType?.kind === "dyn" ||
|
|
6679
|
-
(enumerationType === null && isJsSourceFile(
|
|
7376
|
+
(enumerationType === null && isJsSourceFile(ts.getSourceFileOfNode(call))))) {
|
|
6680
7377
|
let receiver = lowerer.coerceToExpected(lowerer.lowerExpr(argNode), DYN);
|
|
6681
7378
|
if (receiver.type.kind !== "dyn")
|
|
6682
7379
|
lowerer.badType(argNode, lowerer.typeOf(argNode));
|
|
@@ -6744,6 +7441,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6744
7441
|
lowerer.badType(call, lowerer.typeOf(call));
|
|
6745
7442
|
valueT = tupleShape.fields.find((f) => f.name === "1").type;
|
|
6746
7443
|
}
|
|
7444
|
+
lowerer.keyOrder.observe(argIr);
|
|
6747
7445
|
const key = `obj.${member}:${argIr.shapeId}:${typeKey(resultT)}`;
|
|
6748
7446
|
let helper = lowerer.arrHofHelpers.get(key);
|
|
6749
7447
|
if (!helper) {
|
|
@@ -7048,19 +7746,19 @@ function lowerObjectAssignHybrid(lowerer, call) {
|
|
|
7048
7746
|
const callField = shape?.fields.find((f) => f.name === "%call");
|
|
7049
7747
|
if (!shape || !callField || callField.type.kind !== "func")
|
|
7050
7748
|
return null;
|
|
7051
|
-
if (call.arguments.length < 2 || call.arguments.some((a) => ts.isSpreadElement(a)))
|
|
7749
|
+
if (call.arguments.nodes.length < 2 || call.arguments.nodes.some((a) => ts.isSpreadElement(a)))
|
|
7052
7750
|
return null;
|
|
7053
7751
|
const loc = locOf(call);
|
|
7054
7752
|
const values = new Map();
|
|
7055
|
-
values.set("%call", lowerer.lowerExprExpecting(call.arguments[0], callField.type));
|
|
7056
|
-
for (const argNode of call.arguments.slice(1)) {
|
|
7753
|
+
values.set("%call", lowerer.lowerExprExpecting(call.arguments.nodes[0], callField.type));
|
|
7754
|
+
for (const argNode of call.arguments.nodes.slice(1)) {
|
|
7057
7755
|
let src = argNode;
|
|
7058
7756
|
while (ts.isParenthesizedExpression(src) || ts.isAsExpression(src) || ts.isTypeAssertion(src))
|
|
7059
7757
|
src = src.expression;
|
|
7060
7758
|
if (!ts.isObjectLiteralExpression(src)) {
|
|
7061
7759
|
lowerer.unsupported("SC1090", argNode, "Object.assign sources other than plain object literals when building a function-with-properties value");
|
|
7062
7760
|
}
|
|
7063
|
-
for (const prop of src.properties) {
|
|
7761
|
+
for (const prop of src.properties.nodes) {
|
|
7064
7762
|
const nameOk = (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&
|
|
7065
7763
|
(ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name));
|
|
7066
7764
|
if (!nameOk) {
|
|
@@ -7092,6 +7790,25 @@ function lowerObjectAssignHybrid(lowerer, call) {
|
|
|
7092
7790
|
}
|
|
7093
7791
|
return { kind: "recordLit", fields, type: mapped, loc };
|
|
7094
7792
|
}
|
|
7793
|
+
/** The accessed member is an overload set (isOverloadedCallableMemberType),
|
|
7794
|
+
* also under an optional chain whose access still spells `| undefined`. */
|
|
7795
|
+
function isOverloadedMemberAccess(lowerer, access) {
|
|
7796
|
+
return isOverloadedCallableMemberType(lowerer.checker.getNonNullableType(lowerer.typeOf(access)), lowerer.checker);
|
|
7797
|
+
}
|
|
7798
|
+
/** The result type of the overload a call through an overloaded member
|
|
7799
|
+
* resolved to: the erased slot's result converts to it. A non-generic
|
|
7800
|
+
* overload answers through its declaration, because the resolved signature
|
|
7801
|
+
* of an optional-chain call (`api?.m(x)`) also carries the chain's
|
|
7802
|
+
* undefined; a generic one answers through its instantiation. */
|
|
7803
|
+
function resolvedOverloadResultType(lowerer, call) {
|
|
7804
|
+
const { checker } = lowerer;
|
|
7805
|
+
const signature = checker.getResolvedSignature(call);
|
|
7806
|
+
const decl = signature ? signature.declaration : undefined;
|
|
7807
|
+
const declared = decl ? checker.getSignatureFromDeclaration(decl) : undefined;
|
|
7808
|
+
const source = declared && declared.getTypeParameters().length === 0 ? declared : signature;
|
|
7809
|
+
const result = source ? lowerer.mapTypeOf(checker.getReturnTypeOfSignature(source)) : null;
|
|
7810
|
+
return result ?? lowerer.irTypeOf(call);
|
|
7811
|
+
}
|
|
7095
7812
|
export function lowerRecordFieldCall(lowerer, call, access) {
|
|
7096
7813
|
if (lowerer.chainBlocked(call))
|
|
7097
7814
|
return null;
|
|
@@ -7117,11 +7834,22 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
7117
7834
|
if (callee?.type.kind !== "func")
|
|
7118
7835
|
return null;
|
|
7119
7836
|
const args = completeFuncValueArgs(lowerer, call, callee.type, locOf(call));
|
|
7120
|
-
|
|
7837
|
+
const value = {
|
|
7838
|
+
kind: "callValue",
|
|
7839
|
+
callee,
|
|
7840
|
+
args,
|
|
7841
|
+
type: callee.type.ret,
|
|
7842
|
+
loc: locOf(call),
|
|
7843
|
+
};
|
|
7844
|
+
// An overloaded member's erased result converts to the resolved
|
|
7845
|
+
// overload's type, as on a single record receiver below.
|
|
7846
|
+
return isOverloadedMemberAccess(lowerer, access)
|
|
7847
|
+
? lowerer.coerceInto(call, value, resolvedOverloadResultType(lowerer, call))
|
|
7848
|
+
: value;
|
|
7121
7849
|
}
|
|
7122
7850
|
const target = lowerer.fieldTarget(access);
|
|
7123
7851
|
const loc = locOf(call);
|
|
7124
|
-
const receiverLocal = target && isJsSourceFile(
|
|
7852
|
+
const receiverLocal = target && isJsSourceFile(ts.getSourceFileOfNode(call))
|
|
7125
7853
|
? lowerer.declareHiddenLocal("%callReceiver", target.obj.type)
|
|
7126
7854
|
: null;
|
|
7127
7855
|
const init = target && receiverLocal
|
|
@@ -7142,10 +7870,10 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
7142
7870
|
// TypeScript reaches here for callable library types that are checked
|
|
7143
7871
|
// values (util.DebugLogger).
|
|
7144
7872
|
if (callee.type.kind === "dyn" &&
|
|
7145
|
-
(isJsSourceFile(
|
|
7873
|
+
(isJsSourceFile(ts.getSourceFileOfNode(call)) ||
|
|
7146
7874
|
lowerer.checker.getCallSignatures(lowerer.typeOf(access)).length > 0)) {
|
|
7147
7875
|
const receiver = target && receiverLocal ? lowerer.coerceToExpected(target.obj, DYN) : undefined;
|
|
7148
|
-
const spread = call.arguments.some(ts.isSpreadElement)
|
|
7876
|
+
const spread = call.arguments.nodes.some(ts.isSpreadElement)
|
|
7149
7877
|
? lowerSpreadArgsCall(lowerer, call, callee, loc)
|
|
7150
7878
|
: null;
|
|
7151
7879
|
if (spread && spread.kind !== "dynCall")
|
|
@@ -7158,13 +7886,17 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
7158
7886
|
kind: "dynCall",
|
|
7159
7887
|
callee,
|
|
7160
7888
|
...(receiver ? { receiver } : {}),
|
|
7161
|
-
calleeName:
|
|
7162
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
7889
|
+
calleeName: ts.getTextOfNode(access),
|
|
7890
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
7163
7891
|
type: DYN,
|
|
7164
7892
|
loc,
|
|
7165
7893
|
};
|
|
7166
7894
|
return init ? { kind: "seqExpr", stmts: [init], result, type: result.type, loc } : result;
|
|
7167
7895
|
}
|
|
7896
|
+
// An optional callback field the checker narrowed at this call
|
|
7897
|
+
// (`o.cb ? o.cb(x) : …`, `if (o.cb) o.cb(x)`): extract the func arm.
|
|
7898
|
+
if (callee.type.kind === "union")
|
|
7899
|
+
callee = lowerer.maybeNarrow(callee, access);
|
|
7168
7900
|
if (callee.type.kind !== "func")
|
|
7169
7901
|
lowerer.badType(access, lowerer.typeOf(access));
|
|
7170
7902
|
// JavaScript passes the record as `this`. A record with no dynamic form
|
|
@@ -7180,7 +7912,7 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
7180
7912
|
}
|
|
7181
7913
|
}
|
|
7182
7914
|
const args = completeFuncValueArgs(lowerer, call, callee.type, locOf(call));
|
|
7183
|
-
|
|
7915
|
+
let result = {
|
|
7184
7916
|
kind: "callValue",
|
|
7185
7917
|
callee,
|
|
7186
7918
|
...(receiver ? { receiver } : {}),
|
|
@@ -7188,6 +7920,14 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
7188
7920
|
type: callee.type.ret,
|
|
7189
7921
|
loc,
|
|
7190
7922
|
};
|
|
7923
|
+
// A generic member's field holds its erased instance, and an overloaded
|
|
7924
|
+
// member's field its erased function (the overloads joined): the result
|
|
7925
|
+
// converts to this call's instantiated or resolved return type.
|
|
7926
|
+
const memberType = lowerer.typeOf(access);
|
|
7927
|
+
if (isGenericCallableMemberType(memberType, lowerer.checker))
|
|
7928
|
+
result = lowerer.coerceInto(call, result, lowerer.irTypeOf(call));
|
|
7929
|
+
else if (isOverloadedMemberAccess(lowerer, access))
|
|
7930
|
+
result = lowerer.coerceInto(call, result, resolvedOverloadResultType(lowerer, call));
|
|
7191
7931
|
return init ? { kind: "seqExpr", stmts: [init], result, type: result.type, loc } : result;
|
|
7192
7932
|
}
|
|
7193
7933
|
/** `o.m(args)` where `m` is an object-literal GENERIC method (own type
|
|
@@ -7213,12 +7953,12 @@ function lowerUrlStaticCall(lowerer, call, callee) {
|
|
|
7213
7953
|
if (!ts.isIdentifier(callee.expression))
|
|
7214
7954
|
return null;
|
|
7215
7955
|
const sym = lowerer.resolveValueSymbol(callee.expression);
|
|
7216
|
-
if (!sym || !lowerer.isStdlibSymbol(sym) || sym
|
|
7956
|
+
if (!sym || !lowerer.isStdlibSymbol(sym) || ts.symbolName(sym) !== "URL")
|
|
7217
7957
|
return null;
|
|
7218
7958
|
if (callee.name.text === "canParse" || callee.name.text === "parse") {
|
|
7219
7959
|
return lowerUrlFactory(lowerer, call, callee.name.text);
|
|
7220
7960
|
}
|
|
7221
|
-
if (callee.name.text !== "revokeObjectURL" || call.arguments.length !== 0)
|
|
7961
|
+
if (callee.name.text !== "revokeObjectURL" || call.arguments.nodes.length !== 0)
|
|
7222
7962
|
return null;
|
|
7223
7963
|
return nodeThrowExpr(1, "ERR_MISSING_ARGS", 'The "url" argument must be specified', VOID, locOf(call));
|
|
7224
7964
|
}
|
|
@@ -7240,7 +7980,7 @@ function arrowSignatureOf(lowerer, node) {
|
|
|
7240
7980
|
const signatures = lowerer.checker.getCallSignatures(lowerer.typeOf(node));
|
|
7241
7981
|
if (signatures.length !== 1)
|
|
7242
7982
|
return null;
|
|
7243
|
-
const declaration =
|
|
7983
|
+
const declaration = signatures[0].declaration;
|
|
7244
7984
|
return declaration !== undefined && ts.isArrowFunction(declaration) ? signatures[0] : null;
|
|
7245
7985
|
}
|
|
7246
7986
|
/** An inline arrow has lexical `this` and no observable own properties
|
|
@@ -7249,8 +7989,8 @@ function arrowSignatureOf(lowerer, node) {
|
|
|
7249
7989
|
* other receivers and rest/preset-argument forms on the named fence. */
|
|
7250
7990
|
function lowerInlineArrowBind(lowerer, call, access) {
|
|
7251
7991
|
if (access.name.text !== "bind" ||
|
|
7252
|
-
call.arguments.length > 1 ||
|
|
7253
|
-
call.arguments.some(ts.isSpreadElement))
|
|
7992
|
+
call.arguments.nodes.length > 1 ||
|
|
7993
|
+
call.arguments.nodes.some(ts.isSpreadElement))
|
|
7254
7994
|
return null;
|
|
7255
7995
|
let arrow = access.expression;
|
|
7256
7996
|
while (ts.isParenthesizedExpression(arrow))
|
|
@@ -7264,8 +8004,8 @@ function lowerInlineArrowBind(lowerer, call, access) {
|
|
|
7264
8004
|
return null;
|
|
7265
8005
|
const type = callee.type;
|
|
7266
8006
|
const loc = locOf(call);
|
|
7267
|
-
const firstDefault = arrow.parameters.findIndex((p) => p.initializer !== undefined);
|
|
7268
|
-
const length = firstDefault < 0 ? arrow.parameters.length : firstDefault;
|
|
8007
|
+
const firstDefault = arrow.parameters.nodes.findIndex((p) => p.initializer !== undefined);
|
|
8008
|
+
const length = firstDefault < 0 ? arrow.parameters.nodes.length : firstDefault;
|
|
7269
8009
|
const key = `arrow.bind:${typeKey(type)}:${length}`;
|
|
7270
8010
|
const existing = lowerer.arrHofHelpers.get(key);
|
|
7271
8011
|
const name = existing ?? `%arrow.bind.${lowerer.arrHofHelpers.size}`;
|
|
@@ -7358,8 +8098,8 @@ function lowerInlineArrowBind(lowerer, call, access) {
|
|
|
7358
8098
|
const stmts = [{ kind: "varDecl", localId: saved.id, init: callee, loc }];
|
|
7359
8099
|
// The receiver is ignored by the arrow, but its effects and throws
|
|
7360
8100
|
// happen after creating the arrow and before returning the bound value.
|
|
7361
|
-
if (call.arguments[0])
|
|
7362
|
-
stmts.push(lowerer.lowerExprStatement(call.arguments[0]));
|
|
8101
|
+
if (call.arguments.nodes[0])
|
|
8102
|
+
stmts.push(lowerer.lowerExprStatement(call.arguments.nodes[0]));
|
|
7363
8103
|
const result = {
|
|
7364
8104
|
kind: "call",
|
|
7365
8105
|
callee: name,
|
|
@@ -7374,8 +8114,8 @@ function lowerInlineArrowBind(lowerer, call, access) {
|
|
|
7374
8114
|
* parameters validate from the dynamic array in order. */
|
|
7375
8115
|
function lowerArrowFunctionApply(lowerer, call, access) {
|
|
7376
8116
|
if (access.name.text !== "apply" ||
|
|
7377
|
-
call.arguments.length !== 2 ||
|
|
7378
|
-
call.arguments.some(ts.isSpreadElement) ||
|
|
8117
|
+
call.arguments.nodes.length !== 2 ||
|
|
8118
|
+
call.arguments.nodes.some(ts.isSpreadElement) ||
|
|
7379
8119
|
arrowSignatureOf(lowerer, access.expression) === null) {
|
|
7380
8120
|
return null;
|
|
7381
8121
|
}
|
|
@@ -7385,7 +8125,7 @@ function lowerArrowFunctionApply(lowerer, call, access) {
|
|
|
7385
8125
|
if (!callee.type.params.every((param) => canDynCheckTo(param, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))) {
|
|
7386
8126
|
return null;
|
|
7387
8127
|
}
|
|
7388
|
-
const argsList = lowerer.lowerExpr(call.arguments[1]);
|
|
8128
|
+
const argsList = lowerer.lowerExpr(call.arguments.nodes[1]);
|
|
7389
8129
|
if (argsList.type.kind !== "dyn")
|
|
7390
8130
|
return null;
|
|
7391
8131
|
const loc = locOf(call);
|
|
@@ -7393,7 +8133,7 @@ function lowerArrowFunctionApply(lowerer, call, access) {
|
|
|
7393
8133
|
const savedArgs = lowerer.declareHiddenLocal("%applyArgs", DYN);
|
|
7394
8134
|
const stmts = [
|
|
7395
8135
|
{ kind: "varDecl", localId: savedCallee.id, init: callee, loc },
|
|
7396
|
-
{ kind: "exprStmt", expr: lowerer.lowerExpr(call.arguments[0]), loc },
|
|
8136
|
+
{ kind: "exprStmt", expr: lowerer.lowerExpr(call.arguments.nodes[0]), loc },
|
|
7397
8137
|
{ kind: "varDecl", localId: savedArgs.id, init: argsList, loc },
|
|
7398
8138
|
];
|
|
7399
8139
|
const args = callee.type.params.map((param, index) => {
|
|
@@ -7404,7 +8144,7 @@ function lowerArrowFunctionApply(lowerer, call, access) {
|
|
|
7404
8144
|
type: DYN,
|
|
7405
8145
|
loc,
|
|
7406
8146
|
};
|
|
7407
|
-
return lowerer.coerceInto(call.arguments[1], read, param);
|
|
8147
|
+
return lowerer.coerceInto(call.arguments.nodes[1], read, param);
|
|
7408
8148
|
});
|
|
7409
8149
|
const invoked = {
|
|
7410
8150
|
kind: "callValue",
|
|
@@ -7440,7 +8180,7 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7440
8180
|
lowerer.mapTypeOf(lowerer.typeOf(access.expression.expression))?.kind === "searchParams" &&
|
|
7441
8181
|
SP_BRAND_METHODS.has(access.expression.name.text) &&
|
|
7442
8182
|
lowerer.isStdlibMember(access.expression)) {
|
|
7443
|
-
const thisArg = call.arguments[0];
|
|
8183
|
+
const thisArg = call.arguments.nodes[0];
|
|
7444
8184
|
const thisT = thisArg
|
|
7445
8185
|
? lowerer.mapTypeOf(lowerer.typeOf(thisArg))
|
|
7446
8186
|
: { kind: "undefinedT" };
|
|
@@ -7460,7 +8200,7 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7460
8200
|
const propSym = lowerer.checker.getPropertyOfType(recvT, name);
|
|
7461
8201
|
if (!propSym)
|
|
7462
8202
|
return null;
|
|
7463
|
-
const propertyDecl =
|
|
8203
|
+
const propertyDecl = propSym.valueDeclaration;
|
|
7464
8204
|
if (propertyDecl &&
|
|
7465
8205
|
ts.isShorthandPropertyAssignment(propertyDecl) &&
|
|
7466
8206
|
ts.isIdentifier(propertyDecl.name) &&
|
|
@@ -7480,9 +8220,7 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7480
8220
|
// CLASS members belong to the class path (lowerClassGenericMethodCall
|
|
7481
8221
|
// claimed compilable ones; a class that failed collection keeps its
|
|
7482
8222
|
// own diagnostics and the generic method-call fence downstream).
|
|
7483
|
-
if (
|
|
7484
|
-
.declarationsOf(propSym)
|
|
7485
|
-
.some((d) => d.parent !== undefined &&
|
|
8223
|
+
if (propSym.declarations.some((d) => d.parent !== undefined &&
|
|
7486
8224
|
(ts.isClassDeclaration(d.parent) || ts.isClassExpression(d.parent)))) {
|
|
7487
8225
|
return null;
|
|
7488
8226
|
}
|
|
@@ -7517,21 +8255,39 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7517
8255
|
if ((name === "apply" || name === "call" || name === "bind") &&
|
|
7518
8256
|
lowerer.checker.getCallSignatures(recvT).length > 0) {
|
|
7519
8257
|
const value = tryLowerExpression(lowerer, access.expression);
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
8258
|
+
// Builtin function values held as checked-dynamic functions
|
|
8259
|
+
// (String.fromCharCode, JSON.stringify) bind the same way, and so
|
|
8260
|
+
// does a member that lowers to a checked-dynamic value (a native
|
|
8261
|
+
// handle's method read in JavaScript).
|
|
8262
|
+
if (value &&
|
|
8263
|
+
(value.type.kind === "dyn" ||
|
|
8264
|
+
(value.type.kind === "func" && lowerer.dynConvertible(value.type))) &&
|
|
8265
|
+
!call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
8266
|
+
const loc = locOf(call);
|
|
8267
|
+
return {
|
|
8268
|
+
kind: "dynInvoke",
|
|
8269
|
+
recv: value.type.kind === "dyn" ? value : { kind: "dynFrom", value, type: DYN, loc },
|
|
8270
|
+
method: name,
|
|
8271
|
+
calleeName: ts.getTextOfNode(access),
|
|
8272
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
8273
|
+
type: DYN,
|
|
8274
|
+
loc,
|
|
8275
|
+
};
|
|
8276
|
+
}
|
|
8277
|
+
const childMethod = lowerChildMethodValue(lowerer, access.expression);
|
|
8278
|
+
if (childMethod && !call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
7523
8279
|
const loc = locOf(call);
|
|
7524
8280
|
return {
|
|
7525
8281
|
kind: "dynInvoke",
|
|
7526
|
-
recv:
|
|
8282
|
+
recv: childMethod,
|
|
7527
8283
|
method: name,
|
|
7528
|
-
calleeName:
|
|
7529
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
8284
|
+
calleeName: ts.getTextOfNode(access),
|
|
8285
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
7530
8286
|
type: DYN,
|
|
7531
8287
|
loc,
|
|
7532
8288
|
};
|
|
7533
8289
|
}
|
|
7534
|
-
lowerer.unsupported("SC1090", call, `Function.prototype.${name} on a function whose signature cannot cross the checked-value boundary (call '${access.expression
|
|
8290
|
+
lowerer.unsupported("SC1090", call, `Function.prototype.${name} on a function whose signature cannot cross the checked-value boundary (call '${ts.getTextOfNode(access.expression)}(...)' directly)`);
|
|
7535
8291
|
}
|
|
7536
8292
|
// STANDARD-LIBRARY generic members (Promise.then, Object.
|
|
7537
8293
|
// defineProperty, Array-augmentation methods) are the lib fence's
|
|
@@ -7544,9 +8300,27 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7544
8300
|
// receiver's runtime class must be provable — name that discipline
|
|
7545
8301
|
// instead of the object-literal wording when the method lives on an
|
|
7546
8302
|
// interface.
|
|
7547
|
-
const onInterface =
|
|
7548
|
-
|
|
7549
|
-
|
|
8303
|
+
const onInterface = propSym.declarations.some((d) => d.parent !== undefined && ts.isInterfaceDeclaration(d.parent));
|
|
8304
|
+
// A receiver held as a checked-dynamic value (a class-backed interface)
|
|
8305
|
+
// dispatches by name to the runtime object's member, which a generic
|
|
8306
|
+
// method answers with its erased instance; the result converts to this
|
|
8307
|
+
// call's instantiated return type.
|
|
8308
|
+
if (onInterface && !call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
8309
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
8310
|
+
if (receiver.type.kind === "dyn") {
|
|
8311
|
+
const loc = locOf(call);
|
|
8312
|
+
const invoked = {
|
|
8313
|
+
kind: "dynInvoke",
|
|
8314
|
+
recv: receiver,
|
|
8315
|
+
method: name,
|
|
8316
|
+
calleeName: ts.getTextOfNode(access),
|
|
8317
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
8318
|
+
type: DYN,
|
|
8319
|
+
loc,
|
|
8320
|
+
};
|
|
8321
|
+
return lowerer.coerceInto(call, invoked, lowerer.irTypeOf(call));
|
|
8322
|
+
}
|
|
8323
|
+
}
|
|
7550
8324
|
if (onInterface) {
|
|
7551
8325
|
lowerer.unsupported("SC1090", call, `calls of the generic method '${name}' through this receiver (the interface declaration is signature-only and generic methods dispatch statically, so the receiver's runtime class must be provable — bind the receiver to a const initialized with its 'new' expression, e.g. 'const r: ${lowerer.checker.typeToString(recvT)} = new C(...)')`);
|
|
7552
8326
|
}
|
|
@@ -7556,7 +8330,7 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7556
8330
|
const info = objLitGenericFnInfoOf(lowerer, call, name, found);
|
|
7557
8331
|
const instance = genericCallInstance(lowerer, call, info);
|
|
7558
8332
|
const loc = locOf(call);
|
|
7559
|
-
const args = lowerer.completeArgs(call.arguments, instance.params, loc, call);
|
|
8333
|
+
const args = lowerer.completeArgs(call.arguments.nodes, instance.params, loc, call);
|
|
7560
8334
|
return { kind: "call", callee: instance.name, args, type: instance.returnType, loc };
|
|
7561
8335
|
}
|
|
7562
8336
|
/** `obj.method(args)` — whole-program devirtualization decides the form:
|
|
@@ -7568,7 +8342,17 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7568
8342
|
export function lowerObjectMethodCall(lowerer, call, access) {
|
|
7569
8343
|
if (lowerer.chainBlocked(access, call))
|
|
7570
8344
|
return null;
|
|
7571
|
-
let mappedReceiver = lowerer.
|
|
8345
|
+
let mappedReceiver = lowerer.receiverTypeOverrides.get(access.expression) ??
|
|
8346
|
+
structuralReadType(lowerer, access.expression) ??
|
|
8347
|
+
lowerer.mapTypeOf(lowerer.typeOf(access.expression));
|
|
8348
|
+
// EventEmitter's static side (the class, a value of it, or the events
|
|
8349
|
+
// module, which is the class) keeps its static surface on the emitter
|
|
8350
|
+
// dispatch (`EventEmitter.setMaxListeners(n)`), which tells the statics
|
|
8351
|
+
// apart by the receiver's construct signatures. The stream classes
|
|
8352
|
+
// inherit the same statics.
|
|
8353
|
+
if (mappedReceiver?.kind === "classval" && mappedReceiver.className === RUNTIME_EMITTER_CLASS) {
|
|
8354
|
+
mappedReceiver = { kind: "object", className: RUNTIME_EMITTER_CLASS };
|
|
8355
|
+
}
|
|
7572
8356
|
// A specialized JS parameter can expose a native field whose checker
|
|
7573
8357
|
// type still belongs to the unspecialized body (plane.normal.dot()).
|
|
7574
8358
|
// Use the lowered receiver's representation and retain its evaluation.
|
|
@@ -7576,7 +8360,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7576
8360
|
(lowerer.implicitParamTypes !== null ||
|
|
7577
8361
|
lowerer.classImplementedProtocol(lowerer.typeOf(access.expression)) ||
|
|
7578
8362
|
ts.isNewExpression(access.expression) ||
|
|
7579
|
-
isJsSourceFile(
|
|
8363
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)))
|
|
7580
8364
|
? ts.isNewExpression(access.expression)
|
|
7581
8365
|
? lowerer.lowerExpr(access.expression)
|
|
7582
8366
|
: tryLowerExpression(lowerer, access.expression)
|
|
@@ -7594,7 +8378,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7594
8378
|
if (dispatched)
|
|
7595
8379
|
return dispatched;
|
|
7596
8380
|
const arms = lowerer.unions.get(mappedReceiver.unionId)?.arms;
|
|
7597
|
-
if (isJsSourceFile(
|
|
8381
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
7598
8382
|
arms?.every((arm) => arm.kind === "object" && !lowerer.classes.get(arm.className)?.def.runtime) &&
|
|
7599
8383
|
lowerer.dynConvertible(mappedReceiver)) {
|
|
7600
8384
|
return lowerDynReceiverMethodCall(lowerer, call, access);
|
|
@@ -7664,7 +8448,13 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7664
8448
|
// The EventEmitter surface: API-named calls on emitter-rooted
|
|
7665
8449
|
// receivers lower through the emitter spoke (subclass members with
|
|
7666
8450
|
// these names are fenced at collection, so `found` never shadows).
|
|
7667
|
-
if (info &&
|
|
8451
|
+
if (info &&
|
|
8452
|
+
!found &&
|
|
8453
|
+
(EMITTER_API_MEMBERS.has(access.name.text) ||
|
|
8454
|
+
// A static with no instance twin (events.getEventListeners).
|
|
8455
|
+
(access.name.text === "getEventListeners" &&
|
|
8456
|
+
lowerer.checker.getConstructSignatures(lowerer.typeOf(access.expression)).length > 0)) &&
|
|
8457
|
+
emitterRooted(lowerer, info)) {
|
|
7668
8458
|
return lowerEmitterMethodCall(lowerer, call, access, info);
|
|
7669
8459
|
}
|
|
7670
8460
|
// The inherited EventTarget/Event methods of a class rooted at those
|
|
@@ -7723,7 +8513,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7723
8513
|
let callee = target ? lowerer.fieldGetExpr(target, locOf(access), access) : null;
|
|
7724
8514
|
if (callee?.type.kind === "union" && callableType !== null) {
|
|
7725
8515
|
// Calling a cleared callback field throws Node's call TypeError.
|
|
7726
|
-
const inPlace = checkedArmExtraction(lowerer, callee, lowerer.armTag(callee.type.unionId, callableType), callableType, () => `${
|
|
8516
|
+
const inPlace = checkedArmExtraction(lowerer, callee, lowerer.armTag(callee.type.unionId, callableType), callableType, () => `${ts.getTextOfNode(access)} is not a function`);
|
|
7727
8517
|
const helper = inPlace
|
|
7728
8518
|
? null
|
|
7729
8519
|
: lowerer.narrowedArmHelper(callee.type.unionId, callableType, locOf(access));
|
|
@@ -7735,19 +8525,19 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7735
8525
|
}
|
|
7736
8526
|
if (callee?.type.kind === "func") {
|
|
7737
8527
|
if (((callee.type.rest === true && callee.type.restAbi === undefined) ||
|
|
7738
|
-
call.arguments.length > callee.type.params.length) &&
|
|
7739
|
-
isJsSourceFile(
|
|
8528
|
+
call.arguments.nodes.length > callee.type.params.length) &&
|
|
8529
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
7740
8530
|
lowerer.dynConvertible(callee.type)) {
|
|
7741
8531
|
const boxed = { kind: "dynFrom", value: callee, type: DYN, loc };
|
|
7742
8532
|
const spread = lowerSpreadArgsCall(lowerer, call, boxed, loc);
|
|
7743
8533
|
if (spread?.kind === "dynCall")
|
|
7744
8534
|
return finish({ ...spread, ...receiver });
|
|
7745
|
-
const args = call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
8535
|
+
const args = call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
7746
8536
|
return finish({
|
|
7747
8537
|
kind: "dynCall",
|
|
7748
8538
|
callee: boxed,
|
|
7749
8539
|
...receiver,
|
|
7750
|
-
calleeName:
|
|
8540
|
+
calleeName: ts.getTextOfNode(access),
|
|
7751
8541
|
args,
|
|
7752
8542
|
type: DYN,
|
|
7753
8543
|
loc,
|
|
@@ -7757,15 +8547,15 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7757
8547
|
return finish({ kind: "callValue", callee, ...receiver, args, type: callee.type.ret, loc });
|
|
7758
8548
|
}
|
|
7759
8549
|
if (callee?.type.kind === "dyn") {
|
|
7760
|
-
if (call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
8550
|
+
if (call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
|
|
7761
8551
|
lowerer.unsupported("SC1090", call, "spread arguments in calls through 'unknown' values");
|
|
7762
8552
|
}
|
|
7763
|
-
const args = call.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
8553
|
+
const args = call.arguments.nodes.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
7764
8554
|
return finish({
|
|
7765
8555
|
kind: "dynCall",
|
|
7766
8556
|
callee,
|
|
7767
8557
|
...receiver,
|
|
7768
|
-
calleeName:
|
|
8558
|
+
calleeName: ts.getTextOfNode(access),
|
|
7769
8559
|
args,
|
|
7770
8560
|
type: DYN,
|
|
7771
8561
|
loc,
|
|
@@ -7773,7 +8563,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7773
8563
|
}
|
|
7774
8564
|
}
|
|
7775
8565
|
if (!fieldType &&
|
|
7776
|
-
isJsSourceFile(
|
|
8566
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
7777
8567
|
!info.def.runtime &&
|
|
7778
8568
|
!info.builtinError &&
|
|
7779
8569
|
!info.builtinEmitter &&
|
|
@@ -7790,7 +8580,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7790
8580
|
type: DYN,
|
|
7791
8581
|
loc,
|
|
7792
8582
|
};
|
|
7793
|
-
const spread = call.arguments.some(ts.isSpreadElement)
|
|
8583
|
+
const spread = call.arguments.nodes.some(ts.isSpreadElement)
|
|
7794
8584
|
? lowerSpreadArgsCall(lowerer, call, callee, loc)
|
|
7795
8585
|
: null;
|
|
7796
8586
|
if (spread && spread.kind !== "dynCall")
|
|
@@ -7801,8 +8591,8 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7801
8591
|
kind: "dynCall",
|
|
7802
8592
|
callee,
|
|
7803
8593
|
receiver,
|
|
7804
|
-
calleeName:
|
|
7805
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
8594
|
+
calleeName: ts.getTextOfNode(access),
|
|
8595
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
7806
8596
|
type: DYN,
|
|
7807
8597
|
loc,
|
|
7808
8598
|
};
|
|
@@ -7824,7 +8614,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7824
8614
|
const receiver = lowerReceiver();
|
|
7825
8615
|
const local = lowerer.declareHiddenLocal("%callbackReceiver", receiver.type);
|
|
7826
8616
|
const value = { kind: "varRef", localId: local.id, type: receiver.type, loc };
|
|
7827
|
-
const args = lowerer.completeArgs(call.arguments, found.sig.params, loc, call);
|
|
8617
|
+
const args = lowerer.completeArgs(call.arguments.nodes, found.sig.params, loc, call);
|
|
7828
8618
|
const virtual = lowerer.overrideBelow(info, method);
|
|
7829
8619
|
if (virtual)
|
|
7830
8620
|
lowerer.noteVirtualEdge(info, method);
|
|
@@ -7846,7 +8636,7 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7846
8636
|
type: found.sig.ret,
|
|
7847
8637
|
loc,
|
|
7848
8638
|
};
|
|
7849
|
-
const result = classCallbackCall(lowerer, value, method, call.arguments, fallback, loc,
|
|
8639
|
+
const result = classCallbackCall(lowerer, value, method, call.arguments.nodes, fallback, loc, ts.getTextOfNode(access));
|
|
7850
8640
|
return {
|
|
7851
8641
|
kind: "seqExpr",
|
|
7852
8642
|
stmts: [{ kind: "varDecl", localId: local.id, init: receiver, loc }],
|
|
@@ -7867,12 +8657,34 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7867
8657
|
if (found.sig.abstract === true && !lowerer.overrideBelow(info, method)) {
|
|
7868
8658
|
lowerer.unsupported("SC1090", call, `calls of the abstract method '${method}' with no concrete implementation below the receiver's static class`);
|
|
7869
8659
|
}
|
|
8660
|
+
// The static receiver's nearest declaration is an override adapted to
|
|
8661
|
+
// the inherited ABI, and nothing below overrides it: call its body
|
|
8662
|
+
// directly under its declared signature (exact parameters and result).
|
|
8663
|
+
// The slot function stays reachable; it lifts the body.
|
|
8664
|
+
const adapted = found.declarer.returnAdapters?.get(method);
|
|
8665
|
+
// A TypeScript override's own entry answers its declared result. A
|
|
8666
|
+
// JavaScript body's result is inferred, so its callers keep the slot.
|
|
8667
|
+
const declarerDecl = found.declarer.decl;
|
|
8668
|
+
if (adapted &&
|
|
8669
|
+
!(declarerDecl && isJsSourceFile(ts.getSourceFileOfNode(declarerDecl))) &&
|
|
8670
|
+
!lowerer.overrideBelow(info, method)) {
|
|
8671
|
+
lowerer.noteEdge(`%${found.declarer.def.name}.${method}`);
|
|
8672
|
+
const receiver = lowerReceiver();
|
|
8673
|
+
const args = lowerer.completeArgs(call.arguments.nodes, adapted.params, locOf(call), call);
|
|
8674
|
+
return {
|
|
8675
|
+
kind: "call",
|
|
8676
|
+
callee: `%${found.declarer.def.name}.${method}$own`,
|
|
8677
|
+
args: [lowerer.upcastTo(receiver, found.declarer.def.name), ...args],
|
|
8678
|
+
type: adapted.ret,
|
|
8679
|
+
loc: locOf(call),
|
|
8680
|
+
};
|
|
8681
|
+
}
|
|
7870
8682
|
if (lowerer.overrideBelow(info, method))
|
|
7871
8683
|
lowerer.noteVirtualEdge(info, method);
|
|
7872
8684
|
else
|
|
7873
8685
|
lowerer.noteEdge(`%${found.declarer.def.name}.${method}`);
|
|
7874
8686
|
const receiver = lowerReceiver();
|
|
7875
|
-
const args = lowerer.completeArgs(call.arguments, found.sig.params, locOf(call), call);
|
|
8687
|
+
const args = lowerer.completeArgs(call.arguments.nodes, found.sig.params, locOf(call), call);
|
|
7876
8688
|
if (lowerer.overrideBelow(info, method)) {
|
|
7877
8689
|
return reconcileOverloadReturn(lowerer, call, {
|
|
7878
8690
|
kind: "virtualCall",
|
|
@@ -7926,7 +8738,7 @@ function lowerUnionObjectMethodCall(lowerer, call, access, receiverT) {
|
|
|
7926
8738
|
type: DYN,
|
|
7927
8739
|
loc,
|
|
7928
8740
|
};
|
|
7929
|
-
const spread = call.arguments.some(ts.isSpreadElement)
|
|
8741
|
+
const spread = call.arguments.nodes.some(ts.isSpreadElement)
|
|
7930
8742
|
? lowerSpreadArgsCall(lowerer, call, callee, loc)
|
|
7931
8743
|
: null;
|
|
7932
8744
|
if (spread && spread.kind !== "dynCall")
|
|
@@ -7937,8 +8749,8 @@ function lowerUnionObjectMethodCall(lowerer, call, access, receiverT) {
|
|
|
7937
8749
|
kind: "dynCall",
|
|
7938
8750
|
callee,
|
|
7939
8751
|
receiver,
|
|
7940
|
-
calleeName:
|
|
7941
|
-
args: call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
8752
|
+
calleeName: ts.getTextOfNode(access),
|
|
8753
|
+
args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
|
|
7942
8754
|
type: DYN,
|
|
7943
8755
|
loc,
|
|
7944
8756
|
};
|
|
@@ -7966,7 +8778,7 @@ function lowerUnionObjectMethodCall(lowerer, call, access, receiverT) {
|
|
|
7966
8778
|
return null;
|
|
7967
8779
|
const loc = locOf(call);
|
|
7968
8780
|
const receiver = lowerer.coerceInto(access.expression, lowerer.lowerExpr(access.expression), receiverT);
|
|
7969
|
-
const args = lowerer.completeArgs(call.arguments, shapes, loc, call);
|
|
8781
|
+
const args = lowerer.completeArgs(call.arguments.nodes, shapes, loc, call);
|
|
7970
8782
|
const helper = unionObjectMethodHelper(lowerer, call, receiverT, method, plans, shapes, resultT, loc);
|
|
7971
8783
|
return { kind: "call", callee: helper, args: [receiver, ...args], type: resultT, loc };
|
|
7972
8784
|
}
|
|
@@ -7998,7 +8810,7 @@ function lowerUnionObjectDynFieldCall(lowerer, call, access, receiverT) {
|
|
|
7998
8810
|
return null;
|
|
7999
8811
|
plans.push({ arm, info });
|
|
8000
8812
|
}
|
|
8001
|
-
if (call.arguments.some(ts.isSpreadElement)) {
|
|
8813
|
+
if (call.arguments.nodes.some(ts.isSpreadElement)) {
|
|
8002
8814
|
lowerer.unsupported("SC1090", call, "spread arguments in calls through 'unknown' values");
|
|
8003
8815
|
}
|
|
8004
8816
|
const loc = locOf(call);
|
|
@@ -8066,7 +8878,7 @@ function lowerUnionObjectDynFieldCall(lowerer, call, access, receiverT) {
|
|
|
8066
8878
|
lowerer.liftedFns.push({ name: helper, params, returnType: DYN, locals, body, loc });
|
|
8067
8879
|
}
|
|
8068
8880
|
const callee = { kind: "call", callee: helper, args: [receiverRef], type: DYN, loc };
|
|
8069
|
-
const args = call.arguments.map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
8881
|
+
const args = call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN));
|
|
8070
8882
|
return {
|
|
8071
8883
|
kind: "seqExpr",
|
|
8072
8884
|
stmts: [{ kind: "varDecl", localId: receiverLocal.id, init: receiver, loc }],
|
|
@@ -8074,7 +8886,7 @@ function lowerUnionObjectDynFieldCall(lowerer, call, access, receiverT) {
|
|
|
8074
8886
|
kind: "dynCall",
|
|
8075
8887
|
callee,
|
|
8076
8888
|
receiver: lowerer.coerceToExpected(receiverRef, DYN),
|
|
8077
|
-
calleeName:
|
|
8889
|
+
calleeName: ts.getTextOfNode(access),
|
|
8078
8890
|
args,
|
|
8079
8891
|
type: DYN,
|
|
8080
8892
|
loc,
|
|
@@ -8090,6 +8902,18 @@ function unionObjectMethodHelper(lowerer, sourceCall, receiverT, method, plans,
|
|
|
8090
8902
|
return existing;
|
|
8091
8903
|
const name = `%union.call.${lowerer.unionCallHelpers.size}`;
|
|
8092
8904
|
lowerer.unionCallHelpers.set(key, name);
|
|
8905
|
+
// A probe that catches a refusal while the body lowers must not leave
|
|
8906
|
+
// the name registered for a helper that was never emitted.
|
|
8907
|
+
try {
|
|
8908
|
+
lowerer.liftedFns.push(unionObjectMethodFunction(lowerer, name, sourceCall, receiverT, method, plans, shapes, resultT, loc));
|
|
8909
|
+
}
|
|
8910
|
+
catch (e) {
|
|
8911
|
+
lowerer.unionCallHelpers.delete(key);
|
|
8912
|
+
throw e;
|
|
8913
|
+
}
|
|
8914
|
+
return name;
|
|
8915
|
+
}
|
|
8916
|
+
function unionObjectMethodFunction(lowerer, name, sourceCall, receiverT, method, plans, shapes, resultT, loc) {
|
|
8093
8917
|
const receiver = varRef("this.0", receiverT, loc);
|
|
8094
8918
|
const argRefs = shapes.map((shape, i) => varRef(`a.${i}`, shape.type, loc));
|
|
8095
8919
|
const branch = (plan) => {
|
|
@@ -8166,8 +8990,7 @@ function unionObjectMethodHelper(lowerer, sourceCall, receiverT, method, plans,
|
|
|
8166
8990
|
type: param.type,
|
|
8167
8991
|
mutable: false,
|
|
8168
8992
|
}));
|
|
8169
|
-
|
|
8170
|
-
return name;
|
|
8993
|
+
return { name, params, returnType: resultT, locals, body, loc };
|
|
8171
8994
|
}
|
|
8172
8995
|
/** The argument's lowered type for a message (what the static form saw),
|
|
8173
8996
|
* or the checker's text when the argument itself does not lower. */
|
|
@@ -8195,7 +9018,28 @@ export function lowerStaticNumberGlobal(lowerer, name, call, args, loc) {
|
|
|
8195
9018
|
const radix = args[1]
|
|
8196
9019
|
? lowerer.lowerExprExpecting(args[1], F64)
|
|
8197
9020
|
: { kind: "numLit", value: 0, type: F64, loc };
|
|
8198
|
-
|
|
9021
|
+
let optional = optionalCallValue(lowerer, args[0]);
|
|
9022
|
+
let lowered = null;
|
|
9023
|
+
// A possibly-missing or untyped text in JavaScript (`parseInt(process.
|
|
9024
|
+
// env.PORT, 10)`): TypeScript rejects the call, Node parses the text
|
|
9025
|
+
// of whatever arrives ("undefined").
|
|
9026
|
+
if (optional === null && isJsSourceFile(ts.getSourceFileOfNode(call))) {
|
|
9027
|
+
const argT = lowerer.typeOf(args[0]);
|
|
9028
|
+
const parts = argT.isUnionType() ? ts.constituentTypes(argT) : [argT];
|
|
9029
|
+
if (parts.some((part) => (part.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Any)) !== 0)) {
|
|
9030
|
+
const raw = lowerer.lowerExpr(args[0]);
|
|
9031
|
+
if (raw.type.kind === "union") {
|
|
9032
|
+
optional = raw;
|
|
9033
|
+
lowered = raw;
|
|
9034
|
+
}
|
|
9035
|
+
else {
|
|
9036
|
+
const text = raw.type.kind === "dyn"
|
|
9037
|
+
? { kind: "libCall", fn: "dyn.toStringCoerce", args: [raw], type: STRING, loc }
|
|
9038
|
+
: lowerer.coerceInto(args[0], raw, STRING);
|
|
9039
|
+
return { kind: "libCall", fn: "num.parseInt", args: [text, radix], type: F64, loc };
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
}
|
|
8199
9043
|
if (optional?.type.kind === "union") {
|
|
8200
9044
|
const def = lowerer.unions.get(optional.type.unionId);
|
|
8201
9045
|
const stringTag = def?.arms.findIndex((arm) => arm.kind === "string") ?? -1;
|
|
@@ -8290,7 +9134,9 @@ export function lowerStaticNumberGlobal(lowerer, name, call, args, loc) {
|
|
|
8290
9134
|
return { kind: "call", callee: helper, args: [optional, radix], type: F64, loc };
|
|
8291
9135
|
}
|
|
8292
9136
|
}
|
|
8293
|
-
const s =
|
|
9137
|
+
const s = lowered !== null
|
|
9138
|
+
? lowerer.coerceInto(args[0], lowered, STRING)
|
|
9139
|
+
: lowerer.lowerExprExpecting(args[0], STRING);
|
|
8294
9140
|
return { kind: "libCall", fn: "num.parseInt", args: [s, radix], type: F64, loc };
|
|
8295
9141
|
}
|
|
8296
9142
|
// STATIC parseFloat/isFinite over exactly-typed arguments —
|
|
@@ -8337,4 +9183,114 @@ export function lowerStaticNumberGlobal(lowerer, name, call, args, loc) {
|
|
|
8337
9183
|
}
|
|
8338
9184
|
return null;
|
|
8339
9185
|
}
|
|
9186
|
+
/** `crypto.getRandomValues(view)` on the WebCrypto global or webcrypto. */
|
|
9187
|
+
function lowerWebCryptoGetRandomValues(lowerer, call, access) {
|
|
9188
|
+
if (access.name.text !== "getRandomValues" ||
|
|
9189
|
+
call.questionDotToken ||
|
|
9190
|
+
access.questionDotToken ||
|
|
9191
|
+
!isWebCryptoReceiver(lowerer, access.expression))
|
|
9192
|
+
return null;
|
|
9193
|
+
return lowerCryptoGetRandomValues(lowerer, call);
|
|
9194
|
+
}
|
|
9195
|
+
/** A then handler's promise-armed result (`.then(() => cached ?? load())`
|
|
9196
|
+
* typed `T | Promise<T>`, or a `Promise<void> | void` callback's result):
|
|
9197
|
+
* the lifted async body adopts the promise arm and fulfills with the
|
|
9198
|
+
* others, like `return u` in an async function. Null for other results. */
|
|
9199
|
+
function maybePromiseHandlerResult(lowerer, call, value, R) {
|
|
9200
|
+
const mp = promiseArmedUnionOf(lowerer, value.type);
|
|
9201
|
+
if (!mp || promiseArmedUnionOf(lowerer, R))
|
|
9202
|
+
return null;
|
|
9203
|
+
const stmt = maybePromiseReturnStmt(lowerer, value, mp, R, (e) => lowerer.coerceInto(call, e, R));
|
|
9204
|
+
if (stmt === null) {
|
|
9205
|
+
lowerer.unsupported("SC1090", call, `then handlers returning '${lowerer.fmt(value.type)}' into '${lowerer.fmt(R)}' (an arm does not convert to the result)`);
|
|
9206
|
+
}
|
|
9207
|
+
return stmt;
|
|
9208
|
+
}
|
|
9209
|
+
/** `view.m(args)` where `view` is a `Pick<C, K>` / `Omit<C, K>` view of a
|
|
9210
|
+
* program class C and `m` is one of C's GENERIC methods (its overloads
|
|
9211
|
+
* included): generic methods have no dispatchable method value, so the
|
|
9212
|
+
* view's live receiver is extracted as the C instance it holds (a checked
|
|
9213
|
+
* extraction — a value of another class throws Node-style TypeError
|
|
9214
|
+
* text naming C) and the call monomorphizes statically against C, the
|
|
9215
|
+
* same lowering a C-typed receiver gets. Null for other receivers. */
|
|
9216
|
+
function pickViewGenericMethodCall(lowerer, call, access, recvTs) {
|
|
9217
|
+
const alias = recvTs.getAliasSymbol();
|
|
9218
|
+
if (alias === undefined || (ts.symbolName(alias) !== "Pick" && ts.symbolName(alias) !== "Omit"))
|
|
9219
|
+
return null;
|
|
9220
|
+
if (!alias.declarations.every((d) => ts.getSourceFileOfNode(d).isDeclarationFile))
|
|
9221
|
+
return null;
|
|
9222
|
+
const source = recvTs.getAliasTypeArguments()[0];
|
|
9223
|
+
const symbol = source?.getSymbol();
|
|
9224
|
+
const info = symbol ? lowerer.classBySymbol.get(symbol) : undefined;
|
|
9225
|
+
if (!info || call.questionDotToken || access.questionDotToken)
|
|
9226
|
+
return null;
|
|
9227
|
+
const found = findGenericMethodOn(lowerer, info, access.name.text);
|
|
9228
|
+
if (!found)
|
|
9229
|
+
return null;
|
|
9230
|
+
const loc = locOf(access.expression);
|
|
9231
|
+
const lowered = lowerer.lowerExpr(access.expression);
|
|
9232
|
+
const instance = { kind: "object", className: info.def.name };
|
|
9233
|
+
// A view that statically holds an instance of another class (a
|
|
9234
|
+
// structurally compatible one) calls that class's method in Node, not
|
|
9235
|
+
// C's: the call is refused rather than extracted as a C instance.
|
|
9236
|
+
if (lowered.type.kind === "object" &&
|
|
9237
|
+
lowered.type.className !== info.def.name &&
|
|
9238
|
+
!lowerer.isSubclassOf(lowered.type.className, info.def.name)) {
|
|
9239
|
+
lowerer.unsupported("SC1090", access, `calling the generic method '${access.name.text}' through a '${ts.symbolName(alias)}' view of '${info.def.name}' that holds a '${lowerer.fmt(lowered.type)}'`);
|
|
9240
|
+
}
|
|
9241
|
+
const receiver = lowered.type.kind === "object"
|
|
9242
|
+
? lowered
|
|
9243
|
+
: { kind: "dynCheck", value: lowerer.coerceToExpected(lowered, DYN), type: instance, loc };
|
|
9244
|
+
return lowerClassGenericMethodCall(lowerer, call, access, info, found, receiver);
|
|
9245
|
+
}
|
|
9246
|
+
/** `Object.assign(err, ...sources)` in TypeScript onto an error-hierarchy
|
|
9247
|
+
* target (`Object.assign(new Error(message), details)`): the sources'
|
|
9248
|
+
* own members land on the error — the runtime copy over its
|
|
9249
|
+
* checked-dynamic node, whose name, message, stack, cause and code feed
|
|
9250
|
+
* back into the typed slots — and the call answers the error itself.
|
|
9251
|
+
* Null for every other target. */
|
|
9252
|
+
function lowerObjectAssignOntoError(lowerer, call) {
|
|
9253
|
+
const argNodes = call.arguments.nodes;
|
|
9254
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(call)) ||
|
|
9255
|
+
argNodes.length < 2 ||
|
|
9256
|
+
argNodes.some((a) => ts.isSpreadElement(a)))
|
|
9257
|
+
return null;
|
|
9258
|
+
const probe = tryLowerExpression(lowerer, argNodes[0]);
|
|
9259
|
+
if (probe?.type.kind !== "object" || !lowerer.isErrorRootedClass(probe.type.className))
|
|
9260
|
+
return null;
|
|
9261
|
+
const loc = locOf(call);
|
|
9262
|
+
const target = lowerer.lowerExpr(argNodes[0]);
|
|
9263
|
+
const slot = lowerer.declareHiddenLocal("%assignErr", target.type);
|
|
9264
|
+
const sources = [];
|
|
9265
|
+
for (const node of argNodes.slice(1)) {
|
|
9266
|
+
const raw = lowerer.lowerExpr(node);
|
|
9267
|
+
fenceSymbolFieldCopy(lowerer, node, raw.type);
|
|
9268
|
+
const source = lowerer.coerceToExpected(raw, DYN);
|
|
9269
|
+
if (source.type.kind !== "dyn") {
|
|
9270
|
+
lowerer.unsupported("SC1090", node, `Object.assign onto an Error from a '${lowerer.fmt(raw.type)}' source (sources enter the error's dynamic properties)`);
|
|
9271
|
+
}
|
|
9272
|
+
sources.push(source);
|
|
9273
|
+
}
|
|
9274
|
+
const ref = () => ({ kind: "varRef", localId: slot.id, type: target.type, loc });
|
|
9275
|
+
return {
|
|
9276
|
+
kind: "seqExpr",
|
|
9277
|
+
stmts: [
|
|
9278
|
+
{ kind: "varDecl", localId: slot.id, init: target, loc },
|
|
9279
|
+
{
|
|
9280
|
+
kind: "exprStmt",
|
|
9281
|
+
expr: {
|
|
9282
|
+
kind: "libCall",
|
|
9283
|
+
fn: "error.assign",
|
|
9284
|
+
args: [ref(), { kind: "dynArrLit", elems: sources, type: DYN, loc }],
|
|
9285
|
+
type: VOID,
|
|
9286
|
+
loc,
|
|
9287
|
+
},
|
|
9288
|
+
loc,
|
|
9289
|
+
},
|
|
9290
|
+
],
|
|
9291
|
+
result: ref(),
|
|
9292
|
+
type: target.type,
|
|
9293
|
+
loc,
|
|
9294
|
+
};
|
|
9295
|
+
}
|
|
8340
9296
|
//# sourceMappingURL=lower-calls.js.map
|