@scriptc/compiler 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/node-fallback/assert-strict.d.ts +47 -0
- package/ambient/node-fallback/assert.d.ts +86 -0
- package/ambient/node-fallback/async_hooks.d.ts +41 -0
- package/ambient/node-fallback/buffer.d.ts +23 -0
- package/ambient/node-fallback/child_process.d.ts +242 -0
- package/ambient/node-fallback/cluster.d.ts +17 -0
- package/ambient/node-fallback/constants.d.ts +15 -0
- package/ambient/node-fallback/crypto.d.ts +837 -0
- package/ambient/node-fallback/dgram.d.ts +58 -0
- package/ambient/node-fallback/diagnostics_channel.d.ts +87 -0
- package/ambient/node-fallback/dns-promises.d.ts +27 -0
- package/ambient/node-fallback/dns.d.ts +65 -0
- package/ambient/node-fallback/events.d.ts +60 -0
- package/ambient/node-fallback/fs-promises.d.ts +225 -0
- package/ambient/node-fallback/fs.d.ts +641 -0
- package/ambient/node-fallback/graceful-fs.d.ts +9 -0
- package/ambient/node-fallback/http.d.ts +326 -0
- package/ambient/node-fallback/http2.d.ts +816 -0
- package/ambient/node-fallback/https.d.ts +59 -0
- package/ambient/node-fallback/module.d.ts +10 -0
- package/ambient/node-fallback/net.d.ts +374 -0
- package/ambient/node-fallback/os.d.ts +288 -0
- package/ambient/node-fallback/path-posix.d.ts +22 -0
- package/ambient/node-fallback/path-win32.d.ts +22 -0
- package/ambient/node-fallback/path.d.ts +55 -0
- package/ambient/node-fallback/process.d.ts +11 -0
- package/ambient/node-fallback/punycode.d.ts +18 -0
- package/ambient/node-fallback/querystring.d.ts +55 -0
- package/ambient/node-fallback/stream-consumers.d.ts +21 -0
- package/ambient/node-fallback/stream-promises.d.ts +28 -0
- package/ambient/node-fallback/stream-web.d.ts +36 -0
- package/ambient/node-fallback/stream.d.ts +644 -0
- package/ambient/node-fallback/string_decoder.d.ts +20 -0
- package/ambient/node-fallback/test.d.ts +236 -0
- package/ambient/node-fallback/timers-promises.d.ts +31 -0
- package/ambient/node-fallback/timers.d.ts +28 -0
- package/ambient/node-fallback/tls.d.ts +169 -0
- package/ambient/node-fallback/url.d.ts +95 -0
- package/ambient/node-fallback/util-types.d.ts +50 -0
- package/ambient/node-fallback/util.d.ts +416 -0
- package/ambient/node-fallback/v8.d.ts +43 -0
- package/ambient/node-fallback/worker_threads.d.ts +113 -0
- package/ambient/node-fallback/zlib.d.ts +422 -0
- package/ambient/scriptc-node-fallback.d.ts +224 -6688
- package/dist/backend/cycle-analysis.js +4 -0
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +15 -2
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/huge-text.d.ts +16 -0
- package/dist/backend/huge-text.js +103 -0
- package/dist/backend/huge-text.js.map +1 -0
- package/dist/backend/huge-text.test.d.ts +1 -0
- package/dist/backend/huge-text.test.js +73 -0
- package/dist/backend/huge-text.test.js.map +1 -0
- package/dist/backend/library-pack.js +1 -1
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +10 -0
- package/dist/backend/link-plan-core.js +14 -2
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan-core.test.d.ts +1 -0
- package/dist/backend/link-plan-core.test.js +20 -0
- package/dist/backend/link-plan-core.test.js.map +1 -0
- package/dist/backend/link-plan.d.ts +8 -0
- package/dist/backend/link-plan.js +7 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/linker.js +37 -14
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +13 -0
- package/dist/backend/lld.js +18 -1
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +7 -1
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +2 -0
- package/dist/backend/llvm/alloc.js +1 -1
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +78 -0
- package/dist/backend/llvm/arenas.js +313 -0
- package/dist/backend/llvm/arenas.js.map +1 -0
- package/dist/backend/llvm/arenas.test.d.ts +1 -0
- package/dist/backend/llvm/arenas.test.js +140 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +11 -1
- package/dist/backend/llvm/blocks.js +23 -5
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.d.ts +19 -0
- package/dist/backend/llvm/bytes-headers.js +55 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -0
- package/dist/backend/llvm/bytes-loop-versions.d.ts +4 -3
- package/dist/backend/llvm/bytes-loop-versions.js +42 -7
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +39 -4
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/call-lifetimes.js +43 -8
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +26 -0
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.d.ts +3 -0
- package/dist/backend/llvm/checked-narrows.js +8 -1
- package/dist/backend/llvm/checked-narrows.js.map +1 -1
- package/dist/backend/llvm/class-unions.d.ts +21 -0
- package/dist/backend/llvm/class-unions.js +141 -0
- package/dist/backend/llvm/class-unions.js.map +1 -0
- package/dist/backend/llvm/class-unions.test.d.ts +1 -0
- package/dist/backend/llvm/class-unions.test.js +137 -0
- package/dist/backend/llvm/class-unions.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +46 -8
- package/dist/backend/llvm/classes.js +259 -32
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +4 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +23 -0
- package/dist/backend/llvm/common.js +34 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +39 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/constant-choices.d.ts +32 -0
- package/dist/backend/llvm/constant-choices.js +209 -0
- package/dist/backend/llvm/constant-choices.js.map +1 -0
- package/dist/backend/llvm/constant-choices.test.d.ts +1 -0
- package/dist/backend/llvm/constant-choices.test.js +94 -0
- package/dist/backend/llvm/constant-choices.test.js.map +1 -0
- package/dist/backend/llvm/counted-loops.d.ts +14 -2
- package/dist/backend/llvm/counted-loops.js +60 -7
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/counted-loops.test.d.ts +1 -0
- package/dist/backend/llvm/counted-loops.test.js +34 -0
- package/dist/backend/llvm/counted-loops.test.js.map +1 -0
- package/dist/backend/llvm/cpu-dispatch.d.ts +26 -0
- package/dist/backend/llvm/cpu-dispatch.js +279 -0
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -0
- package/dist/backend/llvm/dense-array-access.d.ts +13 -2
- package/dist/backend/llvm/dense-array-access.js +60 -6
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dyn-handle-tags.test.js +40 -14
- package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +28 -2
- package/dist/backend/llvm/dyn.js +176 -27
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +25 -3
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +1 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -1
- package/dist/backend/llvm/emit-module.d.ts +5 -3
- package/dist/backend/llvm/emit-module.js +362 -74
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +327 -59
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +223 -33
- package/dist/backend/llvm/emitter.js +713 -100
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +20 -1
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +32 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +9 -1
- package/dist/backend/llvm/expr-bytes.js +105 -9
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-callbacks.js +29 -22
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +0 -4
- package/dist/backend/llvm/expr-calls.js +116 -14
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +77 -12
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +22 -0
- package/dist/backend/llvm/expr-control.d.ts +4 -0
- package/dist/backend/llvm/expr-control.js +485 -426
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +4 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +3 -3
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +6 -0
- package/dist/backend/llvm/expr-primitives.js +119 -58
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +11 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +36 -4
- package/dist/backend/llvm/expr-records.js +249 -37
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +124 -7
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +13 -14
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/frame-escapes.d.ts +11 -0
- package/dist/backend/llvm/frame-escapes.js +219 -0
- package/dist/backend/llvm/frame-escapes.js.map +1 -0
- package/dist/backend/llvm/function-layout.d.ts +15 -0
- package/dist/backend/llvm/function-layout.js +40 -0
- package/dist/backend/llvm/function-layout.js.map +1 -0
- package/dist/backend/llvm/heap-census.d.ts +34 -0
- package/dist/backend/llvm/heap-census.js +163 -0
- package/dist/backend/llvm/heap-census.js.map +1 -0
- package/dist/backend/llvm/inline-arrays.d.ts +41 -0
- package/dist/backend/llvm/inline-arrays.js +195 -0
- package/dist/backend/llvm/inline-arrays.js.map +1 -0
- package/dist/backend/llvm/int32-kind-loops.js +2 -0
- package/dist/backend/llvm/int32-kind-loops.js.map +1 -1
- package/dist/backend/llvm/integer-clones.d.ts +32 -5
- package/dist/backend/llvm/integer-clones.js +237 -44
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/integer-clones.test.js +120 -0
- package/dist/backend/llvm/integer-clones.test.js.map +1 -1
- package/dist/backend/llvm/iterative-teardown.test.d.ts +1 -0
- package/dist/backend/llvm/iterative-teardown.test.js +62 -0
- package/dist/backend/llvm/iterative-teardown.test.js.map +1 -0
- package/dist/backend/llvm/js-ic.js +246 -62
- package/dist/backend/llvm/js-ic.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 +2 -2
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +153 -16
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.d.ts +8 -0
- package/dist/backend/llvm/lib-filesystem.js +48 -4
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +4 -3
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +1 -1
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +15 -1
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +32 -8
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.d.ts +3 -0
- package/dist/backend/llvm/lib-shared.js +191 -28
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +1 -1
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +15 -1
- 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-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-extents.d.ts +22 -0
- package/dist/backend/llvm/local-extents.js +102 -0
- package/dist/backend/llvm/local-extents.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.js +15 -2
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-callees.d.ts +21 -0
- package/dist/backend/llvm/loop-callees.js +119 -0
- package/dist/backend/llvm/loop-callees.js.map +1 -0
- package/dist/backend/llvm/loop-callees.test.d.ts +1 -0
- package/dist/backend/llvm/loop-callees.test.js +65 -0
- package/dist/backend/llvm/loop-callees.test.js.map +1 -0
- package/dist/backend/llvm/loop-entry-versions.d.ts +17 -0
- package/dist/backend/llvm/loop-entry-versions.js +185 -0
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -0
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +13 -4
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +11 -0
- package/dist/backend/llvm/map-read-lifetimes.js +51 -1
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +6 -3
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.d.ts +67 -10
- package/dist/backend/llvm/nullable-unions.js +218 -22
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +124 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/periodic-guards.d.ts +16 -0
- package/dist/backend/llvm/periodic-guards.js +91 -0
- package/dist/backend/llvm/periodic-guards.js.map +1 -0
- package/dist/backend/llvm/periodic-guards.test.d.ts +1 -0
- package/dist/backend/llvm/periodic-guards.test.js +64 -0
- package/dist/backend/llvm/periodic-guards.test.js.map +1 -0
- package/dist/backend/llvm/publish.d.ts +12 -2
- package/dist/backend/llvm/publish.js +15 -8
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/rebound-parameters.d.ts +4 -1
- package/dist/backend/llvm/rebound-parameters.js +17 -1
- package/dist/backend/llvm/rebound-parameters.js.map +1 -1
- package/dist/backend/llvm/receivers.d.ts +7 -0
- package/dist/backend/llvm/receivers.js +77 -10
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-union-keys.test.js +29 -0
- package/dist/backend/llvm/record-union-keys.test.js.map +1 -1
- package/dist/backend/llvm/record-views.d.ts +29 -0
- package/dist/backend/llvm/record-views.js +249 -0
- package/dist/backend/llvm/record-views.js.map +1 -0
- package/dist/backend/llvm/record-views.test.d.ts +1 -0
- package/dist/backend/llvm/record-views.test.js +118 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -0
- package/dist/backend/llvm/reference-writes.js +21 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/reference-writes.test.js +42 -0
- package/dist/backend/llvm/reference-writes.test.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.d.ts +5 -1
- package/dist/backend/llvm/regex-matchers.js +173 -21
- package/dist/backend/llvm/regex-matchers.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.test.js +39 -1
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -1
- package/dist/backend/llvm/region-groups.d.ts +67 -0
- package/dist/backend/llvm/region-groups.js +1719 -0
- package/dist/backend/llvm/region-groups.js.map +1 -0
- package/dist/backend/llvm/region-groups.test.d.ts +1 -0
- package/dist/backend/llvm/region-groups.test.js +197 -0
- package/dist/backend/llvm/region-groups.test.js.map +1 -0
- package/dist/backend/llvm/region-ir.d.ts +31 -0
- package/dist/backend/llvm/region-ir.js +256 -0
- package/dist/backend/llvm/region-ir.js.map +1 -0
- package/dist/backend/llvm/region-sites.d.ts +20 -0
- package/dist/backend/llvm/region-sites.js +327 -0
- package/dist/backend/llvm/region-sites.js.map +1 -0
- package/dist/backend/llvm/region-sites.test.d.ts +1 -0
- package/dist/backend/llvm/region-sites.test.js +216 -0
- package/dist/backend/llvm/region-sites.test.js.map +1 -0
- package/dist/backend/llvm/repr-report.d.ts +9 -0
- package/dist/backend/llvm/repr-report.js +143 -0
- package/dist/backend/llvm/repr-report.js.map +1 -0
- package/dist/backend/llvm/repr-report.test.d.ts +1 -0
- package/dist/backend/llvm/repr-report.test.js +62 -0
- package/dist/backend/llvm/repr-report.test.js.map +1 -0
- package/dist/backend/llvm/runtime-registries.test.d.ts +1 -0
- package/dist/backend/llvm/runtime-registries.test.js +88 -0
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js +1 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shape-union-tags.test.d.ts +1 -0
- package/dist/backend/llvm/shape-union-tags.test.js +75 -0
- package/dist/backend/llvm/shape-union-tags.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +60 -10
- package/dist/backend/llvm/shapes.js +233 -51
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +37 -18
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +3 -0
- package/dist/backend/llvm/speculative-integers.js +20 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/split.js +6 -1
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +23 -0
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-callbacks.js +4 -2
- package/dist/backend/llvm/stack-callbacks.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +12 -3
- package/dist/backend/llvm/stack-objects.js +110 -22
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/stack-objects.test.js +144 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -1
- package/dist/backend/llvm/stack-unions.test.js +24 -1
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.js +2 -1
- package/dist/backend/llvm/string-lifetimes.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +4 -0
- package/dist/backend/llvm/string-reads.js +27 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/test-boxed-unions.d.ts +10 -8
- package/dist/backend/llvm/test-boxed-unions.js +20 -25
- package/dist/backend/llvm/test-boxed-unions.js.map +1 -1
- package/dist/backend/llvm/union-repr.js +9 -8
- package/dist/backend/llvm/union-repr.js.map +1 -1
- package/dist/backend/llvm/union-retype.test.js +45 -2
- package/dist/backend/llvm/union-retype.test.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +20 -8
- package/dist/backend/llvm/unwind-abi.js +177 -70
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.test.js +90 -3
- package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +3 -2
- package/dist/backend/llvm/walk-borrows.js +2 -2
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.test.js +18 -0
- package/dist/backend/llvm/walk-borrows.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +14 -1
- package/dist/backend/llvm/walkers.js +103 -11
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wrapping-sums.d.ts +26 -6
- package/dist/backend/llvm/wrapping-sums.js +64 -12
- package/dist/backend/llvm/wrapping-sums.js.map +1 -1
- package/dist/backend/loop-polls.d.ts +4 -2
- package/dist/backend/loop-polls.js +11 -2
- package/dist/backend/loop-polls.js.map +1 -1
- package/dist/backend/mangle.d.ts +0 -5
- package/dist/backend/mangle.js +0 -9
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.d.ts +10 -9
- package/dist/backend/may-throw.js +189 -27
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +44 -7
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +5 -0
- package/dist/backend/native/compiler-fingerprint.js +62 -16
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +31 -8
- package/dist/backend/native/executable.js +56 -32
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +3 -4
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/object-merge.d.ts +3 -1
- package/dist/backend/native/object-merge.js +24 -11
- package/dist/backend/native/object-merge.js.map +1 -1
- package/dist/backend/native/program-shards.js +6 -3
- package/dist/backend/native/program-shards.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +3 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native-codegen-core.d.ts +15 -6
- package/dist/backend/native-codegen-core.js +20 -9
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +51 -5
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +82 -8
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +30 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +68 -4
- package/dist/backend/native-profile.js +86 -14
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +127 -4
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +1 -1
- package/dist/backend/native-toolchain.js +1 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +58 -4
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +17 -3
- package/dist/backend/native-tools.js +12 -4
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/native-tools.test.d.ts +1 -0
- package/dist/backend/native-tools.test.js +76 -0
- package/dist/backend/native-tools.test.js.map +1 -0
- package/dist/backend/object-localize.js +69 -9
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +99 -10
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/publication.d.ts +2 -0
- package/dist/backend/publication.js +4 -0
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +19 -0
- package/dist/backend/runtime-pack-core.js +23 -3
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.test.js +48 -2
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-cpu.d.ts +2 -0
- package/dist/backend/target-cpu.js +4 -0
- package/dist/backend/target-cpu.js.map +1 -1
- package/dist/backend/target-diagnostics.js +1 -19
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/backend/targets.d.ts +28 -0
- package/dist/backend/targets.js +70 -0
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +75 -1
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -1
- package/dist/backend/vendor-archives.js +25 -12
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +15 -2
- package/dist/backend/vendor-inputs.js +59 -3
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.d.ts +1 -0
- package/dist/backend/vendor-inputs.test.js +74 -0
- package/dist/backend/vendor-inputs.test.js.map +1 -0
- package/dist/cli/command.js +95 -5
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +3 -0
- package/dist/cli/output-options.js +8 -2
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +28 -1
- package/dist/cli/usage.js +56 -6
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +3 -0
- package/dist/compat/fetch-profile.js +23 -3
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +45 -0
- package/dist/contracts/check.js +70 -2
- package/dist/contracts/check.js.map +1 -1
- package/dist/contracts/int32-elements.d.ts +2 -1
- package/dist/contracts/int32-elements.js.map +1 -1
- package/dist/coverage/report.d.ts +5 -1
- package/dist/coverage/report.js +83 -2
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +2 -0
- package/dist/coverage/verdict-cache.js +5 -10
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +145 -0
- package/dist/diagnostics/codes.js +159 -0
- package/dist/diagnostics/codes.js.map +1 -0
- package/dist/diagnostics/codes.test.d.ts +1 -0
- package/dist/diagnostics/codes.test.js +78 -0
- package/dist/diagnostics/codes.test.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +101 -2
- package/dist/diagnostics/diagnostic.js +155 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-slots.d.ts +23 -0
- package/dist/diagnostics/dynamic-slots.js +29 -0
- package/dist/diagnostics/dynamic-slots.js.map +1 -0
- package/dist/diagnostics/dynamic-tier.d.ts +6 -0
- package/dist/diagnostics/dynamic-tier.js +8 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +43 -1
- package/dist/diagnostics/envelope.js +19 -1
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/diagnostics/render.d.ts +3 -1
- package/dist/diagnostics/render.js +27 -6
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +41 -0
- package/dist/executable/executable-cache.js +39 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +4 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +2 -1
- package/dist/executable/prepare.js +421 -10
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +1 -0
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/canon-map.d.ts +17 -0
- package/dist/frontend/canon-map.js +177 -0
- package/dist/frontend/canon-map.js.map +1 -0
- package/dist/frontend/canon.d.ts +122 -0
- package/dist/frontend/canon.js +462 -0
- package/dist/frontend/canon.js.map +1 -0
- package/dist/frontend/contract-types.d.ts +9 -1
- package/dist/frontend/contract-types.js +46 -4
- package/dist/frontend/contract-types.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +3 -0
- package/dist/frontend/decl-projection.js +121 -3
- package/dist/frontend/decl-projection.js.map +1 -1
- package/dist/frontend/dts-paths.d.ts +17 -4
- package/dist/frontend/dts-paths.js +149 -5
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +4 -4
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.js +3 -3
- package/dist/frontend/fork-target.test.js.map +1 -1
- package/dist/frontend/heritage-elements.d.ts +15 -0
- package/dist/frontend/heritage-elements.js +18 -0
- package/dist/frontend/heritage-elements.js.map +1 -0
- package/dist/frontend/heritage-elements.test.d.ts +1 -0
- package/dist/frontend/heritage-elements.test.js +68 -0
- package/dist/frontend/heritage-elements.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +20 -0
- package/dist/frontend/input-tracker.js +74 -4
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +66 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lowering/any-collection-residue.d.ts +9 -0
- package/dist/frontend/lowering/any-collection-residue.js +42 -0
- package/dist/frontend/lowering/any-collection-residue.js.map +1 -0
- package/dist/frontend/lowering/array-values.d.ts +44 -2
- package/dist/frontend/lowering/array-values.js +193 -3
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +6 -2
- package/dist/frontend/lowering/builtin-namespaces.js +28 -6
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtins/array-classes.d.ts +69 -0
- package/dist/frontend/lowering/builtins/array-classes.js +729 -0
- package/dist/frontend/lowering/builtins/array-classes.js.map +1 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js +4 -0
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js +34 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/disposable-stack.js +1 -3
- package/dist/frontend/lowering/builtins/disposable-stack.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.d.ts +13 -9
- package/dist/frontend/lowering/builtins/errors.js +136 -56
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +85 -4
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +11 -6
- package/dist/frontend/lowering/builtins/filesystem.js +270 -24
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +7 -1
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/mime.d.ts +25 -0
- package/dist/frontend/lowering/builtins/mime.js +167 -0
- package/dist/frontend/lowering/builtins/mime.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +3 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +6 -0
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +79 -12
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +7 -4
- package/dist/frontend/lowering/builtins/module-resolution.js +115 -13
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/navigator.d.ts +3 -1
- package/dist/frontend/lowering/builtins/navigator.js +22 -8
- package/dist/frontend/lowering/builtins/navigator.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +49 -9
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +18 -3
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.d.ts +6 -2
- package/dist/frontend/lowering/builtins/promisify-callback.js +19 -6
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +23 -5
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +42 -0
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +321 -0
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -0
- package/dist/frontend/lowering/builtins/x509.js +35 -5
- package/dist/frontend/lowering/builtins/x509.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +14 -1
- package/dist/frontend/lowering/call-arguments.js +84 -70
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +108 -24
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-attributes.js +6 -5
- package/dist/frontend/lowering/class-attributes.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +40 -19
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocol-dispatch.js +4 -0
- package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +61 -1
- package/dist/frontend/lowering/class-protocols.js +297 -21
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +3 -2
- package/dist/frontend/lowering/class-to-primitive.js +15 -5
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
- package/dist/frontend/lowering/coercions/asserted.d.ts +16 -0
- package/dist/frontend/lowering/coercions/asserted.js +79 -0
- package/dist/frontend/lowering/coercions/asserted.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +13 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +70 -3
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +23 -0
- package/dist/frontend/lowering/coercions/state.js +9 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +67 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.d.ts +10 -0
- package/dist/frontend/lowering/coercions/structural.js +134 -4
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +11 -0
- package/dist/frontend/lowering/coercions/unions.js +83 -4
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/completion-callbacks.js +3 -2
- package/dist/frontend/lowering/completion-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +10 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +224 -81
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.d.ts +5 -2
- package/dist/frontend/lowering/containers/array-concat.js +76 -7
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.d.ts +9 -4
- package/dist/frontend/lowering/containers/array-construction.js +112 -100
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +193 -45
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.d.ts +3 -0
- package/dist/frontend/lowering/containers/array-pipelines.js +81 -13
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +1 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +28 -2
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +13 -3
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.js +34 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +34 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +131 -72
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.js +43 -6
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/decl-origin.d.ts +49 -0
- package/dist/frontend/lowering/decl-origin.js +402 -0
- package/dist/frontend/lowering/decl-origin.js.map +1 -0
- package/dist/frontend/lowering/deferred-module-initializers.d.ts +2 -0
- package/dist/frontend/lowering/deferred-module-initializers.js +7 -0
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/divergences.js +5 -0
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/dynamic-tier.d.ts +8 -2
- package/dist/frontend/lowering/dynamic-tier.js +111 -3
- package/dist/frontend/lowering/dynamic-tier.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.d.ts +14 -1
- package/dist/frontend/lowering/expressions/array-literals.js +43 -5
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +48 -0
- package/dist/frontend/lowering/expressions/asserted-receiver.js +233 -0
- package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -0
- package/dist/frontend/lowering/expressions/binary.js +136 -1
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.d.ts +7 -0
- package/dist/frontend/lowering/expressions/element-access.js +363 -12
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.d.ts +3 -0
- package/dist/frontend/lowering/expressions/identifiers.js +78 -62
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/message-listeners.d.ts +3 -0
- package/dist/frontend/lowering/expressions/message-listeners.js +19 -0
- package/dist/frontend/lowering/expressions/message-listeners.js.map +1 -0
- package/dist/frontend/lowering/expressions/narrowing.js +224 -6
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +5 -2
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +282 -24
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +15 -3
- package/dist/frontend/lowering/expressions/property-access.js +397 -74
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +202 -70
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +9 -1
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +28 -8
- package/dist/frontend/lowering/expressions/union-fields.js +168 -14
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +8 -0
- package/dist/frontend/lowering/frozen-records.js +56 -9
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/function-context.d.ts +3 -0
- package/dist/frontend/lowering/function-context.js +4 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.d.ts +4 -0
- package/dist/frontend/lowering/function-returns.js +231 -2
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.js +3 -2
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +26 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +294 -2
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +10 -0
- package/dist/frontend/lowering/generic-functions.js +67 -7
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-values.d.ts +37 -0
- package/dist/frontend/lowering/global-values.js +395 -0
- package/dist/frontend/lowering/global-values.js.map +1 -0
- package/dist/frontend/lowering/handle-properties.js +3 -2
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.test.d.ts +1 -0
- package/dist/frontend/lowering/handle-properties.test.js +25 -0
- package/dist/frontend/lowering/handle-properties.test.js.map +1 -0
- package/dist/frontend/lowering/import-meta.d.ts +3 -0
- package/dist/frontend/lowering/import-meta.js +8 -3
- package/dist/frontend/lowering/import-meta.js.map +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +3 -3
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.d.ts +2 -0
- package/dist/frontend/lowering/key-order-witness.js +10 -0
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +5 -1
- package/dist/frontend/lowering/lower-array-sort.js +16 -2
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +7 -0
- package/dist/frontend/lowering/lower-builtin-values.js +65 -16
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +222 -24
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +6 -0
- package/dist/frontend/lowering/lower-classes.js +154 -20
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-console.js +25 -2
- package/dist/frontend/lowering/lower-console.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +29 -0
- package/dist/frontend/lowering/lower-exprs.js +544 -24
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +93 -18
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +4 -1
- package/dist/frontend/lowering/lower-global-value.js +10 -3
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +44 -4
- package/dist/frontend/lowering/lower-inspect.js +723 -26
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +3 -1
- package/dist/frontend/lowering/lower-modules.js +189 -24
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +7 -0
- package/dist/frontend/lowering/lower-namespaces.js +23 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +74 -0
- package/dist/frontend/lowering/lower-node-island.js +1931 -0
- package/dist/frontend/lowering/lower-node-island.js.map +1 -0
- package/dist/frontend/lowering/lower-server.js +44 -0
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.d.ts +27 -0
- package/dist/frontend/lowering/lower-shared-modules.js +611 -0
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -0
- package/dist/frontend/lowering/lower-stdlib.js +85 -9
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +2 -6
- package/dist/frontend/lowering/lower-stmts.js +781 -143
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +548 -36
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +9 -0
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +514 -10
- package/dist/frontend/lowering/lowerer.js +2667 -163
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +44 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/maybe-promise.d.ts +6 -0
- package/dist/frontend/lowering/maybe-promise.js +13 -0
- package/dist/frontend/lowering/maybe-promise.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.d.ts +12 -0
- package/dist/frontend/lowering/module-namespace-elements.js +114 -18
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +11 -0
- package/dist/frontend/lowering/nan-coded-reads.js +45 -2
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +4 -0
- package/dist/frontend/lowering/narrowing-stability.js +14 -6
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
- package/dist/frontend/lowering/receiver-returns.d.ts +3 -0
- package/dist/frontend/lowering/receiver-returns.js +134 -0
- package/dist/frontend/lowering/receiver-returns.js.map +1 -0
- package/dist/frontend/lowering/record-inherited.d.ts +26 -0
- package/dist/frontend/lowering/record-inherited.js +807 -0
- package/dist/frontend/lowering/record-inherited.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-elements.d.ts +31 -1
- package/dist/frontend/lowering/runtime-optional-elements.js +105 -13
- package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-guards.d.ts +3 -0
- package/dist/frontend/lowering/runtime-optional-guards.js +35 -7
- package/dist/frontend/lowering/runtime-optional-guards.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-guards.test.js +59 -1
- package/dist/frontend/lowering/runtime-optional-guards.test.js.map +1 -1
- package/dist/frontend/lowering/stable-names.d.ts +8 -0
- package/dist/frontend/lowering/stable-names.js +22 -0
- package/dist/frontend/lowering/stable-names.js.map +1 -1
- package/dist/frontend/lowering/stable-names.test.d.ts +1 -0
- package/dist/frontend/lowering/stable-names.test.js +16 -0
- package/dist/frontend/lowering/stable-names.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +5 -4
- package/dist/frontend/lowering/static-typeof.js +10 -4
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +22 -0
- package/dist/frontend/lowering/structural-instances.js +282 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -0
- package/dist/frontend/lowering/surfaces.js +108 -12
- 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 +32 -0
- package/dist/frontend/lowering/symbol-fields.js.map +1 -1
- package/dist/frontend/lowering/type-failure.d.ts +17 -0
- package/dist/frontend/lowering/type-failure.js +163 -0
- package/dist/frontend/lowering/type-failure.js.map +1 -0
- package/dist/frontend/lowering/typed-arguments.d.ts +5 -6
- package/dist/frontend/lowering/typed-arguments.js +10 -2
- package/dist/frontend/lowering/typed-arguments.js.map +1 -1
- package/dist/frontend/lowering/union-narrow.d.ts +9 -1
- package/dist/frontend/lowering/union-narrow.js +31 -2
- package/dist/frontend/lowering/union-narrow.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +42 -2
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +194 -0
- package/dist/frontend/lowering/unit-journal.js +556 -0
- package/dist/frontend/lowering/unit-journal.js.map +1 -0
- package/dist/frontend/lowering/unit-journal.test.d.ts +1 -0
- package/dist/frontend/lowering/unit-journal.test.js +335 -0
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +19 -0
- package/dist/frontend/node-api-import.d.ts +21 -0
- package/dist/frontend/node-api-import.js +88 -0
- package/dist/frontend/node-api-import.js.map +1 -0
- package/dist/frontend/npm-static-type-exports-host.js +4 -3
- package/dist/frontend/npm-static-type-exports-host.js.map +1 -1
- package/dist/frontend/npm-static.js +9 -2
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +6 -2
- package/dist/frontend/package-shims.js +13 -2
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +11 -4
- package/dist/frontend/pipeline.js +249 -26
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/process-fork.d.ts +3 -0
- package/dist/frontend/process-fork.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +6 -0
- package/dist/frontend/program-analysis.js +4 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +12 -1
- package/dist/frontend/program.js +256 -36
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.js +8 -2
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +23 -1
- package/dist/frontend/shape-inference/analyze.js +982 -97
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/constant-graphs.d.ts +2 -0
- package/dist/frontend/shape-inference/constant-graphs.js +39 -4
- package/dist/frontend/shape-inference/constant-graphs.js.map +1 -1
- package/dist/frontend/shape-inference/domain.d.ts +2 -0
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/fallback.d.ts +17 -0
- package/dist/frontend/shape-inference/fallback.js +303 -0
- package/dist/frontend/shape-inference/fallback.js.map +1 -0
- package/dist/frontend/shape-inference/index.d.ts +75 -1
- package/dist/frontend/shape-inference/index.js +531 -2
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/inferred-checks.d.ts +2 -0
- package/dist/frontend/shape-inference/inferred-checks.js +90 -0
- package/dist/frontend/shape-inference/inferred-checks.js.map +1 -0
- package/dist/frontend/shape-inference/memo.d.ts +30 -0
- package/dist/frontend/shape-inference/memo.js +99 -0
- package/dist/frontend/shape-inference/memo.js.map +1 -0
- package/dist/frontend/shape-inference/overlay.d.ts +81 -0
- package/dist/frontend/shape-inference/overlay.js +1160 -0
- package/dist/frontend/shape-inference/overlay.js.map +1 -0
- package/dist/frontend/shape-inference/registry.test.d.ts +1 -0
- package/dist/frontend/shape-inference/registry.test.js +34 -0
- package/dist/frontend/shape-inference/registry.test.js.map +1 -0
- package/dist/frontend/shape-inference/report.js +42 -8
- package/dist/frontend/shape-inference/report.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.d.ts +29 -0
- package/dist/frontend/shape-inference/static-objects.js +1951 -0
- package/dist/frontend/shape-inference/static-objects.js.map +1 -0
- package/dist/frontend/tier-analysis.d.ts +53 -1
- package/dist/frontend/tier-analysis.js +133 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/ts7/api.js +4 -2
- package/dist/frontend/ts7/api.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +9 -0
- package/dist/frontend/ts7/ast-node.js +42 -10
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +23 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire-protocols.test.js +93 -0
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +18 -0
- package/dist/frontend/ts7/ast-wire.js +66 -4
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-server.d.ts +12 -11
- package/dist/frontend/ts7/checker-server.js +28 -12
- package/dist/frontend/ts7/checker-server.js.map +1 -1
- package/dist/frontend/ts7/checker-server.test.js +8 -3
- package/dist/frontend/ts7/checker-server.test.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +4 -0
- package/dist/frontend/ts7/checker.js +9 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +216 -205
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/lib-diagnostics.d.ts +71 -4
- package/dist/frontend/ts7/lib-diagnostics.js +337 -20
- package/dist/frontend/ts7/lib-diagnostics.js.map +1 -1
- package/dist/frontend/ts7/lib-diagnostics.test.js +268 -5
- package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -1
- package/dist/frontend/ts7/native-api.d.ts +4 -0
- package/dist/frontend/ts7/native-api.js +36 -1
- package/dist/frontend/ts7/native-api.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +19 -2
- package/dist/frontend/ts7/program-host.js +69 -9
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +42 -1
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.d.ts +4 -2
- package/dist/frontend/ts7/rpc-filesystem.js +23 -2
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -1
- package/dist/frontend/ts7/rpc-filesystem.test.js +28 -2
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.js +73 -5
- package/dist/frontend/ts7/semantic-checker.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.test.js +106 -74
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.d.ts +2 -6
- package/dist/frontend/ts7/semantic-model-71.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-model-71.test.js +131 -0
- package/dist/frontend/ts7/semantic-model-71.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.d.ts +121 -3
- package/dist/frontend/ts7/semantic-model.js +245 -8
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +19 -1
- package/dist/frontend/ts7/session.js +111 -11
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/session.test.js +259 -239
- package/dist/frontend/ts7/session.test.js.map +1 -1
- package/dist/frontend/ts7/test-servers.d.ts +12 -0
- package/dist/frontend/ts7/test-servers.js +16 -0
- package/dist/frontend/ts7/test-servers.js.map +1 -0
- package/dist/frontend/tsc-codes.js +6 -3
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +61 -1
- package/dist/frontend/type-mapper.js +577 -28
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-patches/command.d.ts +19 -0
- package/dist/frontend/type-patches/command.js +352 -0
- package/dist/frontend/type-patches/command.js.map +1 -0
- package/dist/frontend/type-patches/layer.d.ts +45 -0
- package/dist/frontend/type-patches/layer.js +409 -0
- package/dist/frontend/type-patches/layer.js.map +1 -0
- package/dist/frontend/type-patches/locate.d.ts +41 -0
- package/dist/frontend/type-patches/locate.js +914 -0
- package/dist/frontend/type-patches/locate.js.map +1 -0
- package/dist/frontend/type-patches/locate.test.d.ts +1 -0
- package/dist/frontend/type-patches/locate.test.js +179 -0
- package/dist/frontend/type-patches/locate.test.js.map +1 -0
- package/dist/frontend/type-patches/selector.d.ts +43 -0
- package/dist/frontend/type-patches/selector.js +126 -0
- package/dist/frontend/type-patches/selector.js.map +1 -0
- package/dist/frontend/type-patches/selector.test.d.ts +1 -0
- package/dist/frontend/type-patches/selector.test.js +56 -0
- package/dist/frontend/type-patches/selector.test.js.map +1 -0
- package/dist/frontend/type-patches/semver.d.ts +19 -0
- package/dist/frontend/type-patches/semver.js +221 -0
- package/dist/frontend/type-patches/semver.js.map +1 -0
- package/dist/frontend/type-patches/semver.test.d.ts +1 -0
- package/dist/frontend/type-patches/semver.test.js +47 -0
- package/dist/frontend/type-patches/semver.test.js.map +1 -0
- package/dist/frontend/worker-target.test.js +2 -2
- package/dist/frontend/worker-target.test.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +292 -27
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +51 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +4 -3
- package/dist/ir/builtin-signatures.js +277 -12
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.js +108 -67
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +7 -1
- package/dist/ir/capture-values.js +28 -5
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.js +38 -42
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/expression-inlining.js +12 -6
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +751 -0
- package/dist/ir/fields.generated.js +2071 -0
- package/dist/ir/fields.generated.js.map +1 -0
- package/dist/ir/fields.test.d.ts +1 -0
- package/dist/ir/fields.test.js +113 -0
- package/dist/ir/fields.test.js.map +1 -0
- package/dist/ir/function-references.js +4 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +25 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/inline-array-sources.d.ts +15 -0
- package/dist/ir/inline-array-sources.js +1825 -0
- package/dist/ir/inline-array-sources.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +41 -0
- package/dist/ir/inline-arrays.js +533 -0
- package/dist/ir/inline-arrays.js.map +1 -0
- package/dist/ir/inline-arrays.test.d.ts +1 -0
- package/dist/ir/inline-arrays.test.js +225 -0
- package/dist/ir/inline-arrays.test.js.map +1 -0
- package/dist/ir/int32-slots.d.ts +6 -0
- package/dist/ir/int32-slots.js +154 -16
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +48 -0
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +12 -0
- package/dist/ir/integer-loops.js +23 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +7 -1
- package/dist/ir/integer-ranges.js +29 -2
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +2 -1
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +103 -5
- package/dist/ir/ir.js +38 -4
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +134 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/jsval.js +211 -29
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +120 -0
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.d.ts +38 -0
- package/dist/ir/loop-entry-ranges.js +259 -0
- package/dist/ir/loop-entry-ranges.js.map +1 -0
- package/dist/ir/loop-entry-ranges.test.d.ts +1 -0
- package/dist/ir/loop-entry-ranges.test.js +191 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -0
- package/dist/ir/node-index.d.ts +3 -0
- package/dist/ir/node-index.js +6 -0
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +9 -6
- package/dist/ir/numeric-call-specialization.js +164 -34
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.js +23 -19
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.js +6 -3
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/receiver-readers.d.ts +10 -0
- package/dist/ir/receiver-readers.js +65 -28
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +9 -1
- package/dist/ir/row-pairs.js +136 -43
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/row-pairs.test.js +25 -5
- package/dist/ir/row-pairs.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +33 -1
- package/dist/ir/runtime-features.js +104 -6
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +13 -0
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/saturating-loop-jams.d.ts +24 -0
- package/dist/ir/saturating-loop-jams.js +420 -0
- package/dist/ir/saturating-loop-jams.js.map +1 -0
- package/dist/ir/saturating-loop-jams.test.d.ts +1 -0
- package/dist/ir/saturating-loop-jams.test.js +196 -0
- package/dist/ir/saturating-loop-jams.test.js.map +1 -0
- package/dist/ir/scalar-records.js +9 -3
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.js +2 -1
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/serialize.d.ts +5 -1
- package/dist/ir/serialize.js +7 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +3 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +91 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cache.js +2 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cli.js +54 -7
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.d.ts +3 -0
- package/dist/native/compiler.js +173 -36
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +86 -3
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +20 -2
- package/dist/native/executable-cache.js +17 -10
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/executable-cache.test.js +38 -1
- package/dist/native/executable-cache.test.js.map +1 -1
- package/dist/native/linker-job.d.ts +71 -0
- package/dist/native/linker-job.js +242 -0
- package/dist/native/linker-job.js.map +1 -0
- package/dist/native/linker-job.test.d.ts +1 -0
- package/dist/native/linker-job.test.js +349 -0
- package/dist/native/linker-job.test.js.map +1 -0
- package/dist/native/prepare.js +15 -2
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +10 -15
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +152 -66
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.d.ts +11 -2
- package/dist/native/toolchain.js +43 -17
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +75 -0
- package/dist/native/toolchain.test.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +37 -0
- package/dist/node-islands/boundary.js +135 -0
- package/dist/node-islands/boundary.js.map +1 -0
- package/dist/node-islands/classify.js +1 -1
- package/dist/node-islands/classify.js.map +1 -1
- package/dist/node-islands/effect-gate.d.ts +11 -0
- package/dist/node-islands/effect-gate.js +746 -0
- package/dist/node-islands/effect-gate.js.map +1 -0
- package/dist/node-islands/effect-gate.test.d.ts +1 -0
- package/dist/node-islands/effect-gate.test.js +152 -0
- package/dist/node-islands/effect-gate.test.js.map +1 -0
- package/dist/node-islands/libnode-pack.d.ts +68 -0
- package/dist/node-islands/libnode-pack.js +199 -0
- package/dist/node-islands/libnode-pack.js.map +1 -0
- package/dist/node-islands/libnode-pack.test.d.ts +1 -0
- package/dist/node-islands/libnode-pack.test.js +258 -0
- package/dist/node-islands/libnode-pack.test.js.map +1 -0
- package/dist/node-islands/libnode.d.ts +32 -0
- package/dist/node-islands/libnode.js +212 -0
- package/dist/node-islands/libnode.js.map +1 -0
- package/dist/node-islands/libnode.test.d.ts +1 -0
- package/dist/node-islands/libnode.test.js +170 -0
- package/dist/node-islands/libnode.test.js.map +1 -0
- package/dist/node-islands/modules.d.ts +96 -0
- package/dist/node-islands/modules.js +803 -0
- package/dist/node-islands/modules.js.map +1 -0
- package/dist/node-islands/modules.test.d.ts +1 -0
- package/dist/node-islands/modules.test.js +276 -0
- package/dist/node-islands/modules.test.js.map +1 -0
- package/dist/node-islands/resolve.d.ts +8 -0
- package/dist/node-islands/resolve.js +10 -0
- package/dist/node-islands/resolve.js.map +1 -0
- package/dist/node-islands/snapshot.d.ts +16 -0
- package/dist/node-islands/snapshot.js +486 -0
- package/dist/node-islands/snapshot.js.map +1 -0
- package/dist/node-islands/snapshot.test.d.ts +1 -0
- package/dist/node-islands/snapshot.test.js +56 -0
- package/dist/node-islands/snapshot.test.js.map +1 -0
- package/dist/project-config.d.ts +37 -1
- package/dist/project-config.js +159 -7
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +153 -0
- package/dist/project-config.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/package.json +24 -21
- package/surface-manifest.json +47 -7
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { markInferredFactChecks, shapeOverlayFileNames } from "../shape-inference/index.js";
|
|
2
|
+
import { npmStaticPackageOfPath } from "../npm-static.js";
|
|
3
|
+
import { globalMemberValue } from "./global-values.js";
|
|
4
|
+
import { unionNarrowFailureMessage } from "./union-narrow.js";
|
|
5
|
+
import { arrayClassFieldsFn, arrayClassSpeciesFn, arrayOfClassInstance, arrayRootOf, lowerWithArraySpecies, } from "./builtins/array-classes.js";
|
|
6
|
+
import { canonShadowHook, mapCanonical } from "../canon-map.js";
|
|
7
|
+
import { Normalizer } from "../canon.js";
|
|
8
|
+
import { compactDeclOrigins, inPackageFile, recordOrigin, slotOrigin, } from "./decl-origin.js";
|
|
1
9
|
import { isDeclBoundaryFile } from "../decl-projection.js";
|
|
2
10
|
import { relieveHeapPressure } from "../../heap-pressure.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
11
|
+
import { checkedTable, countTable, fixedScalar, flagScalar, functionTable, irDataTable, journalDump, journalMode, lowerWaveRecorded, mapTable, setTable, waveStats, writeRecords, } from "./unit-journal.js";
|
|
12
|
+
import { moduleNamespaceDynValue, moduleNamespaceObject, moduleNamespaceValue, } from "./module-namespace-elements.js";
|
|
13
|
+
import { keyedHelperName, moduleTagNumber, portableRelativePath } from "./stable-names.js";
|
|
5
14
|
import { positionTag, StructuralPositions } from "./structural-positions.js";
|
|
6
|
-
import {
|
|
15
|
+
import { activeNodeIslands, isForeignType, setActiveNodeIslands, } from "../../node-islands/boundary.js";
|
|
16
|
+
import { bindingSymbolOfRead, onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
|
|
7
17
|
import { needsGeneralNodeStreams, noteUntypedStreamFlow, stdioIntoGeneralStream, } from "./general-streams.js";
|
|
8
18
|
import { extendAssertedRecordMembers } from "./assertion-members.js";
|
|
9
19
|
import { jsDynamicDeclarations } from "./js-dynamic-objects.js";
|
|
@@ -41,21 +51,24 @@ import { isDiffieHellmanType, lowerDiffieHellmanCall } from "./builtins/dh.js";
|
|
|
41
51
|
import { fenceWebCryptoMember, lowerWebCryptoCall } from "./builtins/webcrypto.js";
|
|
42
52
|
import { valueStreamOf } from "./builtins/hash-stream.js";
|
|
43
53
|
import { lowerNetAddressCall, lowerNetAddressNew } from "./builtins/net-address.js";
|
|
54
|
+
import { lowerMimeCall, lowerMimeNew } from "./builtins/mime.js";
|
|
55
|
+
import { installFetchBodyWebStreams, lowerWebStreamNew, lowerWebStreamStaticCall, } from "./builtins/web-streams-dyn.js";
|
|
44
56
|
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
45
57
|
import { iteratorSlotAdapter } from "./iterator-adapters.js";
|
|
46
58
|
import { iterableSlotValue } from "./iterable-values.js";
|
|
47
59
|
import { lowerBuiltinCall } from "./builtin-calls.js";
|
|
48
60
|
import { CoercionState } from "./coercions/state.js";
|
|
49
61
|
import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocker, objToRecordPlan, recordToClassPlan, } from "./coercions/structural-plans.js";
|
|
50
|
-
import { widthCoerce, applyWidthLift, unionRecordWidthHelper, recordWidthHelper, tupleArrayWidthHelper, emptyArrayLiftHelper, arrayWidthHelper, objRecordWidthHelper, recordClassWidthHelper, classStaticsProjection, } from "./coercions/structural.js";
|
|
62
|
+
import { widthCoerce, applyWidthLift, unionRecordWidthHelper, unionArrayWidthHelper, recordWidthHelper, tupleArrayWidthHelper, emptyArrayLiftHelper, arrayWidthHelper, objRecordWidthHelper, recordClassWidthHelper, classStaticsProjection, } from "./coercions/structural.js";
|
|
51
63
|
import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
|
|
52
|
-
import { unionRetagMappable, narrowedRetagHelper, uninhabitedArmRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionRouteHelper, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
|
|
64
|
+
import { unionRetagMappable, narrowedRetagHelper, uninhabitedArmRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionRouteHelper, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, widthNarrowHelper, } from "./coercions/unions.js";
|
|
65
|
+
import { assertedConversion } from "./coercions/asserted.js";
|
|
53
66
|
import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
|
|
54
67
|
import { devirtualizeVirtualCalls } from "./devirtualize.js";
|
|
55
68
|
import { foldRegexSpanReads } from "./regex-span-reads.js";
|
|
56
69
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
57
70
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
58
|
-
import { NarrowingStability } from "./narrowing-stability.js";
|
|
71
|
+
import { NarrowingStability, widenedReceiver } from "./narrowing-stability.js";
|
|
59
72
|
import { ArrayElementStates } from "./runtime-optional-elements.js";
|
|
60
73
|
import { indexReadInBounds } from "./runtime-optional-bounds.js";
|
|
61
74
|
import { ArrayOwnership } from "./runtime-optional-ownership.js";
|
|
@@ -67,13 +80,14 @@ import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
|
|
|
67
80
|
import { collectContractAnnotations } from "../contract-types.js";
|
|
68
81
|
import { sanitizeUnregisteredClassTypes } from "./sanitize-class-types.js";
|
|
69
82
|
import { UnregisteredClassTypes } from "./unregistered-class-types.js";
|
|
70
|
-
import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, } from "./function-context.js";
|
|
83
|
+
import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, newFnCtx, } from "./function-context.js";
|
|
71
84
|
import { InternalCompilerError } from "../../errors.js";
|
|
72
85
|
import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
|
|
73
86
|
import {} from "./class-protocol-dispatch.js";
|
|
74
87
|
import { ClassDynamicDispatch, boxClassInstancesExactly, trackClassFieldCreation, } from "./class-dynamic-dispatch.js";
|
|
75
88
|
import { addUntypedIntegrityWords, guardClassAttributeWrites } from "./class-attributes.js";
|
|
76
89
|
import { inferredCollectionType } from "./js-collection-types.js";
|
|
90
|
+
import { sloppyDynamicWrites } from "./frozen-records.js";
|
|
77
91
|
import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
|
|
78
92
|
import { applyHandleProperties } from "./handle-properties.js";
|
|
79
93
|
import { installBufferValue } from "./containers/bytes.js";
|
|
@@ -81,13 +95,14 @@ import { ClassProtocols } from "./class-protocols.js";
|
|
|
81
95
|
import { earlyReadVarSymbols } from "./var-hoisting.js";
|
|
82
96
|
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
83
97
|
import { assignLegacyTiers } from "../../ir/tiers.js";
|
|
84
|
-
import { dynamicTierWarning } from "./dynamic-tier.js";
|
|
98
|
+
import { dynamicSlotOperationCounts, dynamicTierWarning } from "./dynamic-tier.js";
|
|
85
99
|
import { promoteJsvals } from "../../ir/jsval.js";
|
|
100
|
+
import { returnDispatchReceivers } from "./receiver-returns.js";
|
|
86
101
|
import { analyzeTiers, dynamicStatementCount, } from "../tier-analysis.js";
|
|
87
102
|
import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
|
|
88
103
|
import { finalizeClassMethodValues } from "./class-method-values.js";
|
|
89
104
|
import { finalizePrivateBrands } from "./private-brands.js";
|
|
90
|
-
import { tableKeyFieldType } from "./symbol-fields.js";
|
|
105
|
+
import { INSPECT_CUSTOM_MEMBER, tableKeyFieldType } from "./symbol-fields.js";
|
|
91
106
|
export { newFnCtx } from "./function-context.js";
|
|
92
107
|
/* AST + checker → IR.
|
|
93
108
|
*
|
|
@@ -103,7 +118,7 @@ export { newFnCtx } from "./function-context.js";
|
|
|
103
118
|
* - Lexical scoping is resolved here: locals get function-unique ids
|
|
104
119
|
* ("x.0", "x.1" for shadowing); the IR is scope-flat.
|
|
105
120
|
*/
|
|
106
|
-
import { dirname,
|
|
121
|
+
import { dirname, resolve } from "node:path";
|
|
107
122
|
import { bindingSource } from "../binding-source.js";
|
|
108
123
|
import { compilerOwnedFileName, tsgoPath } from "../dts-paths.js";
|
|
109
124
|
import * as ts from "../ts7/adapter.js";
|
|
@@ -111,10 +126,12 @@ import { isBundledShimForwarder } from "../package-shims.js";
|
|
|
111
126
|
import { erasedTypeOnlyImport } from "../type-only-imports.js";
|
|
112
127
|
import { literalValues } from "../literal-values.js";
|
|
113
128
|
import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
|
|
114
|
-
import {
|
|
129
|
+
import { declarationGroupKey, typeFailureOf } from "./type-failure.js";
|
|
130
|
+
import { dynamicSlotDiag } from "../../diagnostics/dynamic-slots.js";
|
|
131
|
+
import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, stdlibSnapshotValueUseDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
|
|
115
132
|
import { arrayOf, BOOL, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
116
133
|
import { provenanceActive } from "../provenance-registry.js";
|
|
117
|
-
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportsAssignedInFunctions, cjsReexportedModules, cjsNamespaceExportNames,
|
|
134
|
+
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportsAssignedInFunctions, cjsReexportedModules, cjsNamespaceExportNames, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isFallbackDtsPath, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
118
135
|
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, erasedOverloadMemberType, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isOverloadedCallableMemberType, isUnitOnlyTsType, isWorkerHandleType, isFetchHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
119
136
|
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
120
137
|
import { builtinClassAliasOf, runtimeClassValueOfType, } from "./builtins/class-values.js";
|
|
@@ -131,16 +148,17 @@ import { funcTypeFromParamShapes, isThisParameter, paramShape, paramShapes, chec
|
|
|
131
148
|
import { dynamicOverloadChoice, guessedOverloadIdentifier } from "./overload-choice.js";
|
|
132
149
|
import { implicitAnyParamSymbolsOf, implicitLocalFnNodeOf, implicitMonoFile, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, genericLocalClassBinding, } from "./generic-functions.js";
|
|
133
150
|
import { bindingNeverReassigned } from "./binding-analysis.js";
|
|
151
|
+
import { isMessageListenerCall } from "./expressions/message-listeners.js";
|
|
134
152
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
135
153
|
import { completeArgs, wrappedUndefined, undefinedArgFor } from "./call-arguments.js";
|
|
136
|
-
import { bodyReturnType, declaredReturnType } from "./function-returns.js";
|
|
154
|
+
import { bodyReturnType, declaredReturnType, widensReducedRecords } from "./function-returns.js";
|
|
137
155
|
import { lowerCall, lowerPromiseMethodCall, lowerFilterNarrowCall } from "./lower-calls.js";
|
|
138
156
|
import { lowerFfiCall, validateFfiImports } from "./native-ffi.js";
|
|
139
157
|
import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, blockedBodyDiagnostics, } from "./lower-functions.js";
|
|
140
158
|
import { lowerArrayMethodCall } from "./containers/array-methods.js";
|
|
141
159
|
import { fuseArrayPipelines } from "./containers/array-pipelines.js";
|
|
142
160
|
import { lowerMapMethodCall, lowerMapForEachCall, lowerSetMethodCall, lowerSetForEachCall, } from "./containers/collection-methods.js";
|
|
143
|
-
import { lowerEnvToPairsHelper } from "./containers/indexed-objects.js";
|
|
161
|
+
import { lowerEnvToPairsHelper, recordOvfCapturePlan, } from "./containers/indexed-objects.js";
|
|
144
162
|
import { lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew } from "./containers/bytes.js";
|
|
145
163
|
import { lowerRegexMethodCall, lowerStringMethodCall } from "./containers/string-and-regexp.js";
|
|
146
164
|
import { lowerEmitOverrideSpec, } from "./lower-event-emitter.js";
|
|
@@ -191,10 +209,33 @@ import { fenceCrossBlockNsRef, nsPathPrefix } from "./lower-namespaces.js";
|
|
|
191
209
|
import { isSafeToRepeat } from "./expressions/evaluation-safety.js";
|
|
192
210
|
import { lowerTernary } from "./lower-exprs.js";
|
|
193
211
|
import { maybePromiseReturnStmt, maybePromiseUnionOf, promiseArmedUnionOf, } from "./maybe-promise.js";
|
|
212
|
+
import { NodeIslandModuleCollector } from "../../node-islands/modules.js";
|
|
194
213
|
/** Entry function name. '%' cannot appear in a TS identifier, so a user
|
|
195
214
|
* function can never collide with it (mangling is injective per prefix). */
|
|
196
215
|
export const ENTRY_NAME = "%main";
|
|
216
|
+
/** Localized failure: rounds of the declaration flush retry. */
|
|
217
|
+
const MAX_DECLARATION_RETRIES = 16;
|
|
218
|
+
/** The slot kinds the declaration flush retry degrades (stage L2). */
|
|
219
|
+
const DECLARATION_SLOTS = new Set([
|
|
220
|
+
"field",
|
|
221
|
+
"param",
|
|
222
|
+
"return",
|
|
223
|
+
"local",
|
|
224
|
+
"global",
|
|
225
|
+
"loop",
|
|
226
|
+
]);
|
|
197
227
|
export class PoisonError extends Error {
|
|
228
|
+
/** Set when a type with no static lowering poisoned a slot (badType and
|
|
229
|
+
* the dyn class field policy): what failed, for the localized-failure
|
|
230
|
+
* commit points. Report-only in stage L0. */
|
|
231
|
+
failure;
|
|
232
|
+
/** The checker type that failed (with `failure`). */
|
|
233
|
+
failedType;
|
|
234
|
+
constructor(failure, failedType) {
|
|
235
|
+
super();
|
|
236
|
+
this.failure = failure;
|
|
237
|
+
this.failedType = failedType;
|
|
238
|
+
}
|
|
198
239
|
}
|
|
199
240
|
/** Own-property lookup for the surface tables. They are plain object
|
|
200
241
|
* literals, so a bare `table[name]` would also find Object.prototype
|
|
@@ -314,6 +355,55 @@ function emitSpecRoot(spec) {
|
|
|
314
355
|
return `%emit.${spec.info.def.name}.${spec.event}.${spec.ordinal}`;
|
|
315
356
|
}
|
|
316
357
|
export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
358
|
+
setActiveNodeIslands(options.nodeIslands ?? null);
|
|
359
|
+
try {
|
|
360
|
+
const result = lowerToIrWithIslands(program, entry, moduleOrder, options);
|
|
361
|
+
markModuleInitFences(program, result.runtimeFences);
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
setActiveNodeIslands(null);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/** Marks the runtime fences in npm package code whose site is top-level
|
|
369
|
+
* module code (outside every function body): they throw when the module
|
|
370
|
+
* evaluates (ScrDiagnostic.moduleInit). */
|
|
371
|
+
function markModuleInitFences(program, fences) {
|
|
372
|
+
for (const d of fences) {
|
|
373
|
+
if (!d.loc.file.includes("/node_modules/"))
|
|
374
|
+
continue;
|
|
375
|
+
// A fence without a source position belongs to synthesized code, such
|
|
376
|
+
// as the global object's lookup (global-values.ts), which runs when the
|
|
377
|
+
// program calls it, not when the module evaluates.
|
|
378
|
+
if (d.loc.start < 0)
|
|
379
|
+
continue;
|
|
380
|
+
const sf = program.getSourceFile(d.loc.file);
|
|
381
|
+
if (sf === undefined)
|
|
382
|
+
continue;
|
|
383
|
+
let inFunction = false;
|
|
384
|
+
let node = sf;
|
|
385
|
+
while (node !== undefined && !inFunction) {
|
|
386
|
+
let next;
|
|
387
|
+
ts.forEachChild(node, (child) => {
|
|
388
|
+
if (next === undefined &&
|
|
389
|
+
ts.tokenStartOfNode(child) <= d.loc.start &&
|
|
390
|
+
d.loc.start < child.end)
|
|
391
|
+
next = child;
|
|
392
|
+
return undefined;
|
|
393
|
+
});
|
|
394
|
+
if (next === undefined)
|
|
395
|
+
break;
|
|
396
|
+
if (ts.isFunctionLike(next) ||
|
|
397
|
+
(ts.isPropertyDeclaration(next) &&
|
|
398
|
+
!next.modifiers?.nodes.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)))
|
|
399
|
+
inFunction = true;
|
|
400
|
+
node = next;
|
|
401
|
+
}
|
|
402
|
+
if (!inFunction)
|
|
403
|
+
d.moduleInit = true;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function lowerToIrWithIslands(program, entry, moduleOrder, options) {
|
|
317
407
|
const phaseTiming = process.env["SCRIPTC_TIMING"] === "1";
|
|
318
408
|
const phaseStarted = performance.now();
|
|
319
409
|
let phaseLast = phaseStarted;
|
|
@@ -354,7 +444,11 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
354
444
|
// Inline require() calls closing a cycle inside the appended subgraphs
|
|
355
445
|
// join preflight's set (the same run-time refusal by name).
|
|
356
446
|
const inlineRequireCycleCalls = new Set(options.inlineRequireCycleCalls ?? []);
|
|
357
|
-
const graph = {
|
|
447
|
+
const graph = {
|
|
448
|
+
edges: options.moduleEdges,
|
|
449
|
+
inlineCycleCalls: inlineRequireCycleCalls,
|
|
450
|
+
rejected: options.dynamicImportRejections,
|
|
451
|
+
};
|
|
358
452
|
for (let pass = 0; pass < 32; pass++) {
|
|
359
453
|
const before = moduleOrder.length;
|
|
360
454
|
appendDynamicImportModules(program, moduleOrder, onExtraCycle, graph);
|
|
@@ -376,6 +470,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
376
470
|
targetPlatform,
|
|
377
471
|
startupCrash,
|
|
378
472
|
inlineRequireCycleCalls,
|
|
473
|
+
dynamicImportRejections: options.dynamicImportRejections,
|
|
379
474
|
ffiImports,
|
|
380
475
|
libraryCallbacks,
|
|
381
476
|
forkTargets,
|
|
@@ -399,6 +494,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
399
494
|
targetPlatform,
|
|
400
495
|
startupCrash,
|
|
401
496
|
inlineRequireCycleCalls,
|
|
497
|
+
dynamicImportRejections: options.dynamicImportRejections,
|
|
402
498
|
ffiImports,
|
|
403
499
|
libraryCallbacks,
|
|
404
500
|
forkTargets,
|
|
@@ -417,6 +513,41 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
417
513
|
let result = emitted.result;
|
|
418
514
|
let resultLowerer = reachableEmit;
|
|
419
515
|
timing("reachable-emit", { reachable: reachable.size });
|
|
516
|
+
// Localized failure (stage L3): push-down must never cost a failing
|
|
517
|
+
// program more errors than the whole-slot checked dynamic. A pushed-down
|
|
518
|
+
// type is baked into the globals, fields and signatures that hold it, so
|
|
519
|
+
// when the program still fails, the emit runs once more with every
|
|
520
|
+
// degraded type held whole, and the pass with fewer errors wins (ties
|
|
521
|
+
// keep push-down). A program that compiles never takes this path.
|
|
522
|
+
if (result.diagnostics.length > 0 && reachableEmit.hasPartialDegradedTypes()) {
|
|
523
|
+
const whole = new Lowerer(program, entry, moduleOrder, {
|
|
524
|
+
frontendServices: options.frontendServices,
|
|
525
|
+
projectCheckJs: options.projectCheckJs ?? false,
|
|
526
|
+
targetPlatform,
|
|
527
|
+
startupCrash,
|
|
528
|
+
inlineRequireCycleCalls,
|
|
529
|
+
ffiImports,
|
|
530
|
+
libraryCallbacks,
|
|
531
|
+
forkTargets,
|
|
532
|
+
workerTargets,
|
|
533
|
+
externalTypes,
|
|
534
|
+
externalTypeSpecifiersByFile,
|
|
535
|
+
tierMode,
|
|
536
|
+
ffiBindingSymbols: ffiValidation.symbolsByName,
|
|
537
|
+
wholeSlotDegradation: true,
|
|
538
|
+
});
|
|
539
|
+
for (const d of extraModuleCycleDiags)
|
|
540
|
+
whole.pushDiag(d);
|
|
541
|
+
for (const d of ffiValidation.diagnostics)
|
|
542
|
+
whole.pushDiag(d);
|
|
543
|
+
const wholeEmitted = whole.emitReachable(options.libRoots);
|
|
544
|
+
if (wholeEmitted.result.diagnostics.length < result.diagnostics.length) {
|
|
545
|
+
reachable = wholeEmitted.reachable;
|
|
546
|
+
result = wholeEmitted.result;
|
|
547
|
+
resultLowerer = whole;
|
|
548
|
+
}
|
|
549
|
+
timing("whole-slot-relower", { reachable: wholeEmitted.reachable.size });
|
|
550
|
+
}
|
|
420
551
|
// The general stream representation (TypeMapperCtx.generalNodeStreams)
|
|
421
552
|
// is a per-program decision: only a program whose reachable code moved
|
|
422
553
|
// a general stream into a stdio-represented stream slot lowers again
|
|
@@ -433,6 +564,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
433
564
|
targetPlatform,
|
|
434
565
|
startupCrash,
|
|
435
566
|
inlineRequireCycleCalls,
|
|
567
|
+
dynamicImportRejections: options.dynamicImportRejections,
|
|
436
568
|
ffiImports,
|
|
437
569
|
libraryCallbacks,
|
|
438
570
|
forkTargets,
|
|
@@ -443,6 +575,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
443
575
|
ffiBindingSymbols: ffiValidation.symbolsByName,
|
|
444
576
|
generalNodeStreams: true,
|
|
445
577
|
...(dyn ? { dynNodeStreams: true } : {}),
|
|
578
|
+
...(resultLowerer.wholeSlotDegradation ? { wholeSlotDegradation: true } : {}),
|
|
446
579
|
});
|
|
447
580
|
for (const d of extraModuleCycleDiags)
|
|
448
581
|
general.pushDiag(d);
|
|
@@ -479,6 +612,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
479
612
|
targetPlatform,
|
|
480
613
|
startupCrash,
|
|
481
614
|
inlineRequireCycleCalls,
|
|
615
|
+
dynamicImportRejections: options.dynamicImportRejections,
|
|
482
616
|
ffiImports,
|
|
483
617
|
libraryCallbacks,
|
|
484
618
|
forkTargets,
|
|
@@ -487,6 +621,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
487
621
|
externalTypes,
|
|
488
622
|
externalTypeSpecifiersByFile,
|
|
489
623
|
tierMode,
|
|
624
|
+
...(resultLowerer.wholeSlotDegradation ? { wholeSlotDegradation: true } : {}),
|
|
490
625
|
});
|
|
491
626
|
for (const d of extraModuleCycleDiags)
|
|
492
627
|
emit.pushDiag(d);
|
|
@@ -498,7 +633,10 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
498
633
|
}
|
|
499
634
|
// Divergence warnings over the program's own modules: computed once,
|
|
500
635
|
// after lowering, from the same checker (never part of a failure).
|
|
501
|
-
const divergences =
|
|
636
|
+
const divergences = [
|
|
637
|
+
...scanDivergences(resultLowerer, moduleOrder),
|
|
638
|
+
...resultLowerer.sharedModuleWarnings,
|
|
639
|
+
];
|
|
502
640
|
timing("divergence-scan", { found: divergences.length });
|
|
503
641
|
if (divergences.length > 0)
|
|
504
642
|
result = { ...result, divergences };
|
|
@@ -510,6 +648,25 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
510
648
|
if (hotDynamic !== null)
|
|
511
649
|
result = { ...result, performance: [hotDynamic] };
|
|
512
650
|
}
|
|
651
|
+
// Localized failure (SC6104): one performance warning per dynamic slot.
|
|
652
|
+
if (resultLowerer.dynamicSlots.length > 0) {
|
|
653
|
+
const operations = dynamicSlotOperationCounts(resultLowerer, resultLowerer.dynamicBodies, resultLowerer.dynamicSlots);
|
|
654
|
+
const dynamicSlots = resultLowerer.dynamicSlots.map((slot, i) => ({
|
|
655
|
+
operations: operations[i],
|
|
656
|
+
loc: slot.loc,
|
|
657
|
+
name: slot.failure.name,
|
|
658
|
+
slot: slot.failure.slot,
|
|
659
|
+
declaredType: slot.failure.declaredType,
|
|
660
|
+
code: slot.code,
|
|
661
|
+
reason: slot.reason,
|
|
662
|
+
...(slot.partial ? { partial: true } : {}),
|
|
663
|
+
}));
|
|
664
|
+
result = {
|
|
665
|
+
...result,
|
|
666
|
+
performance: [...(result.performance ?? []), ...dynamicSlots.map(dynamicSlotDiag)],
|
|
667
|
+
dynamicSlots,
|
|
668
|
+
};
|
|
669
|
+
}
|
|
513
670
|
// Contract types (@scriptc/types): written annotations, checked against
|
|
514
671
|
// the IR by the compile pipeline (contracts/check.ts).
|
|
515
672
|
// Acyclic object types name the IR unit the program lowered them to; a
|
|
@@ -591,7 +748,10 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
591
748
|
reachable,
|
|
592
749
|
remainder: true,
|
|
593
750
|
alreadyFlushed: resultLowerer.flushedSymbols,
|
|
751
|
+
degradedTypes: resultLowerer.degradedTypes,
|
|
752
|
+
retriedSymbols: resultLowerer.retriedSymbols,
|
|
594
753
|
inlineRequireCycleCalls,
|
|
754
|
+
dynamicImportRejections: options.dynamicImportRejections,
|
|
595
755
|
targetPlatform,
|
|
596
756
|
ffiImports,
|
|
597
757
|
libraryCallbacks,
|
|
@@ -1047,6 +1207,62 @@ function anyPiecedFuncType(lowerer, node, t) {
|
|
|
1047
1207
|
* their own name, anonymous function/arrow expressions their
|
|
1048
1208
|
* NamedEvaluation home (a variable initializer or property assignment).
|
|
1049
1209
|
* Null when nothing names the value (the box stays anonymous). */
|
|
1210
|
+
/** The name Node gives the builtin module function `node` reads, through
|
|
1211
|
+
* const aliases (`const get = process.cwd`), when the module table names its
|
|
1212
|
+
* value differently from its member (BuiltinModuleFn.valueName); else null. */
|
|
1213
|
+
export function builtinValueNameOf(node, lowerer) {
|
|
1214
|
+
let n = node;
|
|
1215
|
+
const seen = new Set();
|
|
1216
|
+
for (;;) {
|
|
1217
|
+
while (ts.isParenthesizedExpression(n))
|
|
1218
|
+
n = n.expression;
|
|
1219
|
+
if (!ts.isIdentifier(n))
|
|
1220
|
+
break;
|
|
1221
|
+
const imported = lowerer.builtinImportOf(n);
|
|
1222
|
+
if (imported)
|
|
1223
|
+
return builtinModuleFnOf(lowerer, imported.module, imported.member)?.valueName ?? null;
|
|
1224
|
+
const symbol = lowerer.resolveValueSymbol(n);
|
|
1225
|
+
const declaration = symbol?.valueDeclaration;
|
|
1226
|
+
if (!symbol || seen.has(symbol) || !declaration)
|
|
1227
|
+
return null;
|
|
1228
|
+
seen.add(symbol);
|
|
1229
|
+
// A member destructured from a module or the process global
|
|
1230
|
+
// (`const { cwd } = process`).
|
|
1231
|
+
if (ts.isBindingElement(declaration)) {
|
|
1232
|
+
const pattern = declaration.parent;
|
|
1233
|
+
const holder = pattern?.parent;
|
|
1234
|
+
const key = declaration.propertyName ?? declaration.name;
|
|
1235
|
+
if (declaration.dotDotDotToken ||
|
|
1236
|
+
!pattern ||
|
|
1237
|
+
!ts.isObjectBindingPattern(pattern) ||
|
|
1238
|
+
!holder ||
|
|
1239
|
+
!ts.isVariableDeclaration(holder) ||
|
|
1240
|
+
!holder.initializer ||
|
|
1241
|
+
(ts.getCombinedNodeFlags(holder) & ts.NodeFlags.Const) === 0 ||
|
|
1242
|
+
!ts.isIdentifier(key))
|
|
1243
|
+
return null;
|
|
1244
|
+
return builtinMemberValueName(lowerer, holder.initializer, key.text);
|
|
1245
|
+
}
|
|
1246
|
+
if (!ts.isVariableDeclaration(declaration) ||
|
|
1247
|
+
!declaration.initializer ||
|
|
1248
|
+
(ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const) === 0)
|
|
1249
|
+
return null;
|
|
1250
|
+
n = declaration.initializer;
|
|
1251
|
+
}
|
|
1252
|
+
if (!ts.isPropertyAccessExpression(n))
|
|
1253
|
+
return null;
|
|
1254
|
+
return builtinMemberValueName(lowerer, n.expression, n.name.text);
|
|
1255
|
+
}
|
|
1256
|
+
/** BuiltinModuleFn.valueName of `member` read from `receiver`, the process
|
|
1257
|
+
* global or a builtin module's namespace; null for anything else. */
|
|
1258
|
+
function builtinMemberValueName(lowerer, receiver, member) {
|
|
1259
|
+
const module = lowerer.isStdlibGlobal(receiver, "process")
|
|
1260
|
+
? "process"
|
|
1261
|
+
: lowerer.builtinNamespaceModuleOf(receiver);
|
|
1262
|
+
if (module === null)
|
|
1263
|
+
return null;
|
|
1264
|
+
return builtinModuleFnOf(lowerer, module, member)?.valueName ?? null;
|
|
1265
|
+
}
|
|
1050
1266
|
export function jsFuncNameOf(node, lowerer) {
|
|
1051
1267
|
let n = node;
|
|
1052
1268
|
while (ts.isParenthesizedExpression(n))
|
|
@@ -1078,14 +1294,19 @@ export function jsFuncNameOf(node, lowerer) {
|
|
|
1078
1294
|
if ((ts.isFunctionExpression(n) || ts.isFunctionDeclaration(n)) && n.name)
|
|
1079
1295
|
return n.name.text;
|
|
1080
1296
|
if (ts.isFunctionExpression(n) || ts.isArrowFunction(n)) {
|
|
1081
|
-
|
|
1082
|
-
|
|
1297
|
+
// An anonymous function takes the name of the binding or property it
|
|
1298
|
+
// initializes, through parentheses (`const f = (function () {})`).
|
|
1299
|
+
let outer = n;
|
|
1300
|
+
while (outer.parent && ts.isParenthesizedExpression(outer.parent))
|
|
1301
|
+
outer = outer.parent;
|
|
1302
|
+
const p = outer.parent;
|
|
1303
|
+
if (p && ts.isVariableDeclaration(p) && p.initializer === outer && ts.isIdentifier(p.name)) {
|
|
1083
1304
|
return p.name.text;
|
|
1084
1305
|
}
|
|
1085
|
-
if (p && ts.isBindingElement(p) && p.initializer ===
|
|
1306
|
+
if (p && ts.isBindingElement(p) && p.initializer === outer && ts.isIdentifier(p.name)) {
|
|
1086
1307
|
return p.name.text;
|
|
1087
1308
|
}
|
|
1088
|
-
if (p && ts.isPropertyAssignment(p) && p.initializer ===
|
|
1309
|
+
if (p && ts.isPropertyAssignment(p) && p.initializer === outer && ts.isIdentifier(p.name)) {
|
|
1089
1310
|
return p.name.text;
|
|
1090
1311
|
}
|
|
1091
1312
|
}
|
|
@@ -1147,11 +1368,22 @@ export class Lowerer {
|
|
|
1147
1368
|
/** Inline require() calls whose module edge closes a require cycle
|
|
1148
1369
|
* (LoadResult.inlineRequireCycleCalls). */
|
|
1149
1370
|
inlineRequireCycleCalls;
|
|
1371
|
+
/** LoadResult.dynamicImportRejections. */
|
|
1372
|
+
dynamicImportRejections;
|
|
1150
1373
|
/** Immutable callable aliases and compiler-generated adapters. The map
|
|
1151
1374
|
* is symbol-keyed, so shadowing and cross-module imports keep the same
|
|
1152
1375
|
* exact binding discipline as globals/functions. */
|
|
1153
1376
|
staticCallables = new Map();
|
|
1154
1377
|
genericFnsBySymbol = new Map();
|
|
1378
|
+
/** Typed declarations' instances for arguments that keep their own
|
|
1379
|
+
* record or array layout (structural-instances.ts). */
|
|
1380
|
+
structuralFnInfos = new Map();
|
|
1381
|
+
/** Consts that keep their initializer's record or array layout, with the
|
|
1382
|
+
* initializer's checker type (structural-instances.ts). */
|
|
1383
|
+
preservedLayoutTypes = new Map();
|
|
1384
|
+
/** Arguments and const initializers whose array or record layout the
|
|
1385
|
+
* lowering kept instead of copying (divergences.ts reports no copy there). */
|
|
1386
|
+
layoutKeptNodes = new Set();
|
|
1155
1387
|
/** Object-literal GENERIC methods (`{ m<T>(x: T) {...} }`), interned by
|
|
1156
1388
|
* their function-like node — instances ride the same monomorphization
|
|
1157
1389
|
* queue (objLitGenericFnInfoOf). */
|
|
@@ -1245,6 +1477,7 @@ export class Lowerer {
|
|
|
1245
1477
|
}
|
|
1246
1478
|
}
|
|
1247
1479
|
noteGenericInstanceDemand(inst) {
|
|
1480
|
+
this.unitEvents?.record("functionDemand", inst.name);
|
|
1248
1481
|
const owner = this.genericDemandOwner;
|
|
1249
1482
|
owner?.functionDemands.push(inst);
|
|
1250
1483
|
const ref = this.genericDemandPriority.get(inst) ?? { rank: [4, Number.MAX_SAFE_INTEGER] };
|
|
@@ -1257,6 +1490,7 @@ export class Lowerer {
|
|
|
1257
1490
|
this.genericDemandPriority.set(inst, ref);
|
|
1258
1491
|
}
|
|
1259
1492
|
noteGenericClassInstanceDemand(info) {
|
|
1493
|
+
this.unitEvents?.record("classDemand", info.def.name);
|
|
1260
1494
|
const owner = this.genericDemandOwner;
|
|
1261
1495
|
owner?.classDemands.push(info);
|
|
1262
1496
|
const ref = this.genericClassDemandPriority.get(info) ?? { rank: [4, Number.MAX_SAFE_INTEGER] };
|
|
@@ -1445,6 +1679,20 @@ export class Lowerer {
|
|
|
1445
1679
|
* the body needs — indexed accesses (`T[K]` needs K's literal key) and
|
|
1446
1680
|
* keyed record reads (`o[k]` where k's type is a literal-bound K). */
|
|
1447
1681
|
typeParamTsBindings = null;
|
|
1682
|
+
/** Generic alias references of call-keyed instances' declared signatures
|
|
1683
|
+
* (`Catalog<G, P>`), each with the same alias as every call's resolved
|
|
1684
|
+
* signature instantiates it (`Catalog<{ g1: … }, "acme">`), together with
|
|
1685
|
+
* that instance's ts-level bindings map (typeParamTsBindings), which every
|
|
1686
|
+
* scope that lowers the instance installs. The checker keeps the alias
|
|
1687
|
+
* symbolic inside the generic body and offers no way to instantiate it
|
|
1688
|
+
* with the bound arguments, but alias instantiations are interned: the
|
|
1689
|
+
* body's `x as Catalog<G, P>` is the very type the signature declares, so
|
|
1690
|
+
* the pair recorded during unification is that re-instantiation. */
|
|
1691
|
+
boundAliasInstances = new Map();
|
|
1692
|
+
/** Values an erased type assertion produced, with the asserted type
|
|
1693
|
+
* (`x as T` keeps x's representation): a slot that no ordinary
|
|
1694
|
+
* conversion reaches converts them as asserted (assertedConversion). */
|
|
1695
|
+
assertedValues = new Map();
|
|
1448
1696
|
/** Non-null while an IMPLICIT-ANY instance body lowers (npm-static JS;
|
|
1449
1697
|
* see generic-functions.ts): bound param symbol →
|
|
1450
1698
|
* the call site's checker type, consulted by typeOf for identifier
|
|
@@ -1611,6 +1859,11 @@ export class Lowerer {
|
|
|
1611
1859
|
/** for-of loops over arrays that can hold neither holes nor undefined:
|
|
1612
1860
|
* each pass reads the element payload directly. */
|
|
1613
1861
|
presentElementLoops = new Set();
|
|
1862
|
+
/** Element keys (typeKey of the element type) of native arrays that can
|
|
1863
|
+
* hold elements outside their element type, stored through dynamic views
|
|
1864
|
+
* (SCR_ARR_FOREIGN); "*" for every array. Empty unless the program stores
|
|
1865
|
+
* values through a dynamic value that can view a native array. */
|
|
1866
|
+
foreignElementKeys = new Set();
|
|
1614
1867
|
/** The fs/promises glob() call lowerForOf is lowering as a for await
|
|
1615
1868
|
* head; other glob() calls have no lowering. */
|
|
1616
1869
|
fspGlobHead = null;
|
|
@@ -1665,6 +1918,69 @@ export class Lowerer {
|
|
|
1665
1918
|
}
|
|
1666
1919
|
return fallback ?? null;
|
|
1667
1920
|
}
|
|
1921
|
+
/** An object or array literal in an untyped context: its contextual type
|
|
1922
|
+
* is `unknown` or `any` from a slot the program declares (a variable,
|
|
1923
|
+
* field, parameter, return type or `unknown[]` element; a library
|
|
1924
|
+
* parameter typed `any` only through a type argument), it is thrown, or
|
|
1925
|
+
* it is a member of such a literal, and it holds data only (no methods,
|
|
1926
|
+
* accessors or function members). Its value is built as a dynamic
|
|
1927
|
+
* object: no type the program wrote gives it a native layout, and a later
|
|
1928
|
+
* checked cast adopts it (dyn.adoptShared), so every holder keeps one
|
|
1929
|
+
* identity. A library parameter the declarations type `any` or `unknown`
|
|
1930
|
+
* itself (`console.log`, `JSON.stringify`) only reads the value and keeps
|
|
1931
|
+
* the native literal. */
|
|
1932
|
+
untypedLiteralContext(x) {
|
|
1933
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(x)))
|
|
1934
|
+
return false;
|
|
1935
|
+
// Data only: a literal with methods, accessors or function members is an
|
|
1936
|
+
// object with behavior, which keeps its native layout (and boxed form).
|
|
1937
|
+
if (ts.isObjectLiteralExpression(x) &&
|
|
1938
|
+
x.properties.nodes.some((p) => {
|
|
1939
|
+
if (!ts.isPropertyAssignment(p))
|
|
1940
|
+
return !ts.isShorthandPropertyAssignment(p) && !ts.isSpreadAssignment(p);
|
|
1941
|
+
let init = p.initializer;
|
|
1942
|
+
while (ts.isParenthesizedExpression(init))
|
|
1943
|
+
init = init.expression;
|
|
1944
|
+
return (ts.isFunctionExpression(init) || ts.isArrowFunction(init) || ts.isClassExpression(init));
|
|
1945
|
+
}))
|
|
1946
|
+
return false;
|
|
1947
|
+
let node = x;
|
|
1948
|
+
while (node.parent !== undefined && ts.isParenthesizedExpression(node.parent))
|
|
1949
|
+
node = node.parent;
|
|
1950
|
+
const parent = node.parent;
|
|
1951
|
+
if (parent === undefined)
|
|
1952
|
+
return false;
|
|
1953
|
+
if (ts.isThrowStatement(parent))
|
|
1954
|
+
return true;
|
|
1955
|
+
if (ts.isPropertyAssignment(parent) && parent.initializer === node) {
|
|
1956
|
+
const literal = parent.parent;
|
|
1957
|
+
if (ts.isObjectLiteralExpression(literal))
|
|
1958
|
+
return this.untypedLiteralContext(literal);
|
|
1959
|
+
}
|
|
1960
|
+
if (ts.isArrayLiteralExpression(parent) && this.untypedLiteralContext(parent))
|
|
1961
|
+
return true;
|
|
1962
|
+
const contextual = this.checker.getContextualType(x);
|
|
1963
|
+
if (!contextual || !(contextual.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)))
|
|
1964
|
+
return false;
|
|
1965
|
+
if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {
|
|
1966
|
+
const signature = this.checker.getResolvedSignature(parent);
|
|
1967
|
+
const decl = signature?.declaration;
|
|
1968
|
+
if (decl && this.isStdlibFile(ts.getSourceFileOfNode(decl))) {
|
|
1969
|
+
const index = (parent.arguments?.nodes ?? []).indexOf(node);
|
|
1970
|
+
const params = decl
|
|
1971
|
+
.parameters?.nodes;
|
|
1972
|
+
const param = params?.[Math.min(index, params.length - 1)];
|
|
1973
|
+
let annotation = param?.type;
|
|
1974
|
+
if (annotation && ts.isArrayTypeNode(annotation))
|
|
1975
|
+
annotation = annotation.elementType;
|
|
1976
|
+
if (!annotation ||
|
|
1977
|
+
annotation.kind === ts.SyntaxKind.AnyKeyword ||
|
|
1978
|
+
annotation.kind === ts.SyntaxKind.UnknownKeyword)
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1668
1984
|
/** A fresh TypeScript data literal (`{ message: "m" }`) passed to a
|
|
1669
1985
|
* checked-dynamic parameter of a callee implemented in JavaScript, whose
|
|
1670
1986
|
* contract lets it reshape the object: a call through an untyped value, an
|
|
@@ -2151,6 +2467,16 @@ export class Lowerer {
|
|
|
2151
2467
|
* checks resolve through this map (stdlibGlobalNameOf), declarations
|
|
2152
2468
|
* emit nothing. */
|
|
2153
2469
|
stdlibGlobalAliases = new Map();
|
|
2470
|
+
/** The TypeScript declarations registered in stdlibGlobalAliases: the
|
|
2471
|
+
* global each one names and its own name node. Their declarations emit
|
|
2472
|
+
* nothing, so a read that needs the VALUE reports at the declaration
|
|
2473
|
+
* (stdlibGlobalAliasDecl, rejectUnresolvedSymbol) instead of compiling
|
|
2474
|
+
* it away. An unread snapshot stays elided: reading a global has no
|
|
2475
|
+
* side effects. */
|
|
2476
|
+
stdlibGlobalAliasDecls = new Map();
|
|
2477
|
+
/** Snapshots whose declaration-side refusal already reported (one
|
|
2478
|
+
* declaration, one report). */
|
|
2479
|
+
stdlibSnapshotReported = new Set();
|
|
2154
2480
|
/** The stdlibGlobalAliases bound through a cast of the global object
|
|
2155
2481
|
* (`(globalThis as { Buffer?: B }).Buffer`). Their static type is the
|
|
2156
2482
|
* cast's, so their value reads are refused (identifiers.ts). */
|
|
@@ -2258,6 +2584,9 @@ export class Lowerer {
|
|
|
2258
2584
|
/** The property names the program assigns on the global object
|
|
2259
2585
|
* (property-access.ts), collected on first use. */
|
|
2260
2586
|
globalThisWrittenNames = null;
|
|
2587
|
+
/** Set with globalThisWrittenNames: the program writes the global object
|
|
2588
|
+
* by a computed name somewhere. */
|
|
2589
|
+
globalThisComputedWrite = false;
|
|
2261
2590
|
/** Well-known symbol methods (`sym:iterator`) the program may replace
|
|
2262
2591
|
* through a symbol-keyed write: an instance or prototype property, or a
|
|
2263
2592
|
* reflection call. */
|
|
@@ -2272,6 +2601,8 @@ export class Lowerer {
|
|
|
2272
2601
|
/** Inferred JS methods participating in an override chain keep a vtable
|
|
2273
2602
|
* ABI instead of call-site specialization. Filled before class collection. */
|
|
2274
2603
|
virtualJsMethods = new Set();
|
|
2604
|
+
/** Methods of checked-JavaScript override pairs (vtable dispatch). */
|
|
2605
|
+
checkedJsOverrideMethods = new Set();
|
|
2275
2606
|
/** Descendant writes must widen the original JS field before collecting
|
|
2276
2607
|
* any class layout; base and derived instances share its storage ABI. */
|
|
2277
2608
|
inheritedJsFieldWrites = new Map();
|
|
@@ -2358,6 +2689,31 @@ export class Lowerer {
|
|
|
2358
2689
|
usesWasmCustomSections = false;
|
|
2359
2690
|
/** The program constructs a LifetimeRegion (lifetime-regions.ts). */
|
|
2360
2691
|
usesLifetimeRegions = false;
|
|
2692
|
+
/** The program calls into Node.js (@scriptc/node): the module carries
|
|
2693
|
+
* the nodeIsland record, which the executable build fills in. */
|
|
2694
|
+
usesNodeIsland = false;
|
|
2695
|
+
/** The program's Node island packages (scope-B NI-4), or null. */
|
|
2696
|
+
nodeIslands = activeNodeIslands();
|
|
2697
|
+
/** Island module loads, by the importing file and specifier: the module
|
|
2698
|
+
* global holding what the import form sees (lower-node-island.ts). */
|
|
2699
|
+
islandModules = new Map();
|
|
2700
|
+
/** The modules Node island calls load (lower-node-island.ts). */
|
|
2701
|
+
nodeIslandModules = new NodeIslandModuleCollector();
|
|
2702
|
+
/** Each call's caller literal, set to its tree path when lowering ends. */
|
|
2703
|
+
nodeIslandCallers = [];
|
|
2704
|
+
/** Absolute specifiers, rewritten to the shipped file relative to their caller. */
|
|
2705
|
+
nodeIslandSpecifiers = [];
|
|
2706
|
+
/** Each island module load's path literal, set to its tree path when lowering ends. */
|
|
2707
|
+
nodeIslandLoads = [];
|
|
2708
|
+
/** Island handle bindings by symbol (lower-node-island.ts). */
|
|
2709
|
+
islandHandleBindings = new Map();
|
|
2710
|
+
/** `instanceof` expressions the island lowering already handles. */
|
|
2711
|
+
islandInstanceofHandled = new Set();
|
|
2712
|
+
/** NI-6: the modules shared with Node islands (lower-shared-modules.ts),
|
|
2713
|
+
* their SC8020 warnings, and the TDZ flags their declarations set. */
|
|
2714
|
+
sharedModules = null;
|
|
2715
|
+
sharedModuleWarnings = [];
|
|
2716
|
+
sharedInitFlags = new Map();
|
|
2361
2717
|
/** Per-directory answers of experimental-import.ts's declaration-file test. */
|
|
2362
2718
|
experimentalFiles = new Map();
|
|
2363
2719
|
/** Interned LifetimeRegion.run helpers, by callback type key. */
|
|
@@ -2437,7 +2793,6 @@ export class Lowerer {
|
|
|
2437
2793
|
typeMemo = new Map();
|
|
2438
2794
|
ambient = ambientDtsPath();
|
|
2439
2795
|
overridesAmbient = overridesDtsPath();
|
|
2440
|
-
fallbackAmbient = fallbackDtsPath();
|
|
2441
2796
|
/** The one mapType context: registries + hooks, assembled in the
|
|
2442
2797
|
* constructor (typeParamResolver reads the CURRENT instantiation bindings
|
|
2443
2798
|
* through `this`, so the same ctx serves generic bodies too). */
|
|
@@ -2465,6 +2820,23 @@ export class Lowerer {
|
|
|
2465
2820
|
* values other than fresh literals (noteUntypedIntegrity). */
|
|
2466
2821
|
untypedIntegrity = false;
|
|
2467
2822
|
liftedFns = [];
|
|
2823
|
+
/** `for … of` and `for await` loops over untyped iterables, by their
|
|
2824
|
+
* generator-kind local (generator-dynamic-dispatch.ts steps the program's
|
|
2825
|
+
* own generators there on the typed path). Local ids repeat across
|
|
2826
|
+
* functions; the local itself is in its function's locals. */
|
|
2827
|
+
untypedLoops = new Map();
|
|
2828
|
+
/** global-values.ts's answer per JavaScript source: the receiver of its
|
|
2829
|
+
* first read of the global object by a computed name, or null. */
|
|
2830
|
+
computedGlobalReads = new Map();
|
|
2831
|
+
/** global-values.ts's answer per JavaScript source: the builtin globals
|
|
2832
|
+
* its sloppy-mode functions read through their `this`. */
|
|
2833
|
+
sloppyThisGlobalReads = new Map();
|
|
2834
|
+
/** global-values.ts's answer: the names the program's global lookup
|
|
2835
|
+
* answers; undefined until asked. */
|
|
2836
|
+
globalLookupNames = undefined;
|
|
2837
|
+
/** web-streams-dyn.ts's answer: whether a JavaScript source names a web
|
|
2838
|
+
* stream class; undefined until asked. */
|
|
2839
|
+
namesWebStreamClass = undefined;
|
|
2468
2840
|
/** The first lifted function of each name (liftedFnNamed), for the
|
|
2469
2841
|
* liftedFns indexed so far. liftedFns only grows. */
|
|
2470
2842
|
liftedFnsByName = new Map();
|
|
@@ -2487,10 +2859,16 @@ export class Lowerer {
|
|
|
2487
2859
|
* names do not depend on where the program sits, default library files
|
|
2488
2860
|
* by their base name (two checkers install them in different
|
|
2489
2861
|
* directories), and the files scriptc ships by their name inside scriptc,
|
|
2490
|
-
* so names do not depend on where scriptc is installed either.
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2862
|
+
* so names do not depend on where scriptc is installed either. Relative
|
|
2863
|
+
* paths use `/` on every platform. */
|
|
2864
|
+
positions = new StructuralPositions((sf) => this.stableFileName(sf));
|
|
2865
|
+
/** The name of `sf` in positions and module tags. */
|
|
2866
|
+
stableFileName(sf) {
|
|
2867
|
+
return this.program.isSourceFileDefaultLibrary(sf)
|
|
2868
|
+
? `lib:${sf.fileName.slice(sf.fileName.lastIndexOf("/") + 1)}`
|
|
2869
|
+
: (compilerOwnedFileName(sf.fileName) ??
|
|
2870
|
+
portableRelativePath(dirname(this.entry.fileName), sf.fileName));
|
|
2871
|
+
}
|
|
2494
2872
|
/** The outermost node whose token span is exactly `loc`, or null. */
|
|
2495
2873
|
nodeAtLoc(loc) {
|
|
2496
2874
|
const sf = this.program.getSourceFile(loc.file);
|
|
@@ -2592,6 +2970,14 @@ export class Lowerer {
|
|
|
2592
2970
|
* promise operand (returnedPromiseAwait). */
|
|
2593
2971
|
returnAwaitedPromise = false;
|
|
2594
2972
|
virtualEdges = new Map();
|
|
2973
|
+
/** The events of the unit being recorded (unit-journal.ts); null
|
|
2974
|
+
* otherwise. */
|
|
2975
|
+
unitEvents = null;
|
|
2976
|
+
/** Fields added to collected classes (class-attributes.ts) and reachable
|
|
2977
|
+
* units registered while units lower: a unit that changes either has no
|
|
2978
|
+
* record (journalScalars). */
|
|
2979
|
+
classLayoutChanges = 0;
|
|
2980
|
+
unitRegistrations = 0;
|
|
2595
2981
|
classCanBeConstructed(info) {
|
|
2596
2982
|
return (this.constructedClasses === null ||
|
|
2597
2983
|
this.constructedClasses.has(info.def.name) ||
|
|
@@ -2641,6 +3027,7 @@ export class Lowerer {
|
|
|
2641
3027
|
this.internTableHelpers,
|
|
2642
3028
|
this.coercions.retags,
|
|
2643
3029
|
this.coercions.narrows,
|
|
3030
|
+
this.coercions.widthNarrows,
|
|
2644
3031
|
])
|
|
2645
3032
|
for (const name of table.values())
|
|
2646
3033
|
interned.add(name);
|
|
@@ -2741,6 +3128,462 @@ export class Lowerer {
|
|
|
2741
3128
|
}
|
|
2742
3129
|
return name === undefined ? undefined : this.liftedFnsByName.get(name);
|
|
2743
3130
|
}
|
|
3131
|
+
/** The tables lowering a unit can grow (unit-journal.ts): the
|
|
3132
|
+
* appendable tables whose entries a unit's record carries, then the
|
|
3133
|
+
* tables whose growth leaves the unit without a record.
|
|
3134
|
+
* Lowerer.unjournaled lists the collections that are in neither. */
|
|
3135
|
+
journalTables() {
|
|
3136
|
+
const sizes = (name, of) => checkedTable(name, () => {
|
|
3137
|
+
let hash = 0;
|
|
3138
|
+
for (const size of of())
|
|
3139
|
+
hash = (Math.imul(hash, 31) + size) | 0;
|
|
3140
|
+
return hash;
|
|
3141
|
+
});
|
|
3142
|
+
return [
|
|
3143
|
+
functionTable("implicitFns", this.implicitFns, (fn) => this.implicitFns.some((other) => other.name === fn)),
|
|
3144
|
+
mapTable("equalityHelpers", this.equalityHelpers),
|
|
3145
|
+
mapTable("arrHofHelpers", this.arrHofHelpers),
|
|
3146
|
+
irDataTable("arrHofInfo", this.arrHofInfo),
|
|
3147
|
+
mapTable("unionCallHelpers", this.unionCallHelpers),
|
|
3148
|
+
mapTable("indexedUnionNumericTwins", this.indexedUnionNumericTwins),
|
|
3149
|
+
setTable("coercions.checkedNarrows", this.coercions.checkedNarrows),
|
|
3150
|
+
irDataTable("coercions.checkedNarrowArms", this.coercions.checkedNarrowArms),
|
|
3151
|
+
mapTable("coercions.retags", this.coercions.retags),
|
|
3152
|
+
mapTable("coercions.narrows", this.coercions.narrows),
|
|
3153
|
+
mapTable("coercions.widthNarrows", this.coercions.widthNarrows),
|
|
3154
|
+
setTable("coercions.widenedReturns", this.coercions.widenedReturns),
|
|
3155
|
+
mapTable("valueHelpers", this.valueHelpers),
|
|
3156
|
+
countTable("keyedNameKeys", this.keyedNameKeys),
|
|
3157
|
+
mapTable("assertHelpers", this.assertHelpers),
|
|
3158
|
+
mapTable("inspectHelpers", this.inspectHelpers),
|
|
3159
|
+
setTable("classMethodValueHelpers", this.classMethodValueHelpers),
|
|
3160
|
+
setTable("freshClosureAdapters", this.freshClosureAdapters),
|
|
3161
|
+
mapTable("iterDrainHelpers", this.iterDrainHelpers),
|
|
3162
|
+
mapTable("mapHofHelpers", this.mapHofHelpers),
|
|
3163
|
+
mapTable("setHofHelpers", this.setHofHelpers),
|
|
3164
|
+
mapTable("spHofHelpers", this.spHofHelpers),
|
|
3165
|
+
mapTable("primitiveCtorFns", this.primitiveCtorFns),
|
|
3166
|
+
mapTable("builtinCallableValueFns", this.builtinCallableValueFns),
|
|
3167
|
+
mapTable("builtinCallableValueNames", this.builtinCallableValueNames),
|
|
3168
|
+
countTable("builtinCallableValueLengths", this.builtinCallableValueLengths),
|
|
3169
|
+
mapTable("regionRunHelpers", this.regionRunHelpers),
|
|
3170
|
+
mapTable("internTableHelpers", this.internTableHelpers),
|
|
3171
|
+
functionTable("liftedFns", this.liftedFns, (fn) => this.liftedFnNamed(fn) !== undefined, () => {
|
|
3172
|
+
this.liftedFnsByName.clear();
|
|
3173
|
+
this.liftedFnsIndexed = 0;
|
|
3174
|
+
}),
|
|
3175
|
+
countTable("closureNameCounts", this.closureNameCounts),
|
|
3176
|
+
setTable("sharedHelperNames", this.sharedHelperNames),
|
|
3177
|
+
setTable("sloppyRecordWrites", this.sloppyRecordWrites),
|
|
3178
|
+
setTable("recordFieldDeletes", this.recordFieldDeletes),
|
|
3179
|
+
setTable("freezableArrays", this.freezableArrays),
|
|
3180
|
+
checkedTable("moduleOrder", () => this.moduleOrder.length),
|
|
3181
|
+
checkedTable("diags", () => this.diags.length),
|
|
3182
|
+
// The shared-module plan runs inside the first unit that lowers a
|
|
3183
|
+
// module; a warning it adds is a diagnostic of that unit, so its count
|
|
3184
|
+
// is journaled like `diags` (the plan itself is unjournaled).
|
|
3185
|
+
checkedTable("sharedModuleWarnings", () => this.sharedModuleWarnings.length),
|
|
3186
|
+
// Node island call sites hold literals of the unit's IR that lowering's
|
|
3187
|
+
// end rewrites to module tree paths (nodeIslandRecord): a unit that adds
|
|
3188
|
+
// one lowers again rather than replaying a record.
|
|
3189
|
+
checkedTable("nodeIslandCallers", () => this.nodeIslandCallers.length),
|
|
3190
|
+
checkedTable("nodeIslandSpecifiers", () => this.nodeIslandSpecifiers.length),
|
|
3191
|
+
// Island module loads hold literals of the unit's IR too, and their
|
|
3192
|
+
// module globals (with each CommonJS named import's snapshot global)
|
|
3193
|
+
// are created by the first load: a unit that adds either lowers again.
|
|
3194
|
+
checkedTable("islandModules", () => this.islandModules.size),
|
|
3195
|
+
checkedTable("nodeIslandLoads", () => this.nodeIslandLoads.length),
|
|
3196
|
+
checkedTable("fnSigsBySymbol", () => this.fnSigsBySymbol.size),
|
|
3197
|
+
checkedTable("cjsExportsAssignments", () => this.cjsExportsAssignments.size),
|
|
3198
|
+
checkedTable("inlineRequireCycleCalls", () => this.inlineRequireCycleCalls.size),
|
|
3199
|
+
checkedTable("dynamicImportRejections", () => this.dynamicImportRejections.size),
|
|
3200
|
+
checkedTable("staticCallables", () => this.staticCallables.size),
|
|
3201
|
+
checkedTable("genericFnsBySymbol", () => this.genericFnsBySymbol.size),
|
|
3202
|
+
checkedTable("objLitGenericFns", () => this.objLitGenericFns.size),
|
|
3203
|
+
checkedTable("bindingGenericFns", () => this.bindingGenericFns.size),
|
|
3204
|
+
checkedTable("bindingIdentifiers", () => this.bindingIdentifiers.size),
|
|
3205
|
+
checkedTable("ownToStringTargets", () => this.ownToStringTargets.size),
|
|
3206
|
+
checkedTable("neverReassignedCache", () => this.neverReassignedCache.size),
|
|
3207
|
+
checkedTable("jsBindingWritesByOwner", () => this.jsBindingWritesByOwner.size),
|
|
3208
|
+
checkedTable("rebindableFunctions", () => this.rebindableFunctions.size),
|
|
3209
|
+
checkedTable("trapBindings", () => this.trapBindings.size),
|
|
3210
|
+
checkedTable("deadBindings", () => this.deadBindings.size),
|
|
3211
|
+
checkedTable("instantiationQueue", () => this.instantiationQueue.length),
|
|
3212
|
+
checkedTable("genericFunctionDemandOwner", () => this.genericFunctionDemandOwner.size),
|
|
3213
|
+
checkedTable("genericClassDemandOwner", () => this.genericClassDemandOwner.size),
|
|
3214
|
+
checkedTable("erasingLambdas", () => this.erasingLambdas.size),
|
|
3215
|
+
checkedTable("typedArgumentsLambdas", () => this.typedArgumentsLambdas.size),
|
|
3216
|
+
checkedTable("tupleAliasSymbols", () => this.tupleAliasSymbols.size),
|
|
3217
|
+
checkedTable("nullishFuncResults", () => this.nullishFuncResults.size),
|
|
3218
|
+
checkedTable("localClassInstantiations", () => this.localClassInstantiations.length),
|
|
3219
|
+
checkedTable("localClassInstanceTypes", () => this.localClassInstanceTypes.size),
|
|
3220
|
+
checkedTable("localClassValueTypes", () => this.localClassValueTypes.size),
|
|
3221
|
+
checkedTable("dynParamLambdas", () => this.dynParamLambdas.size),
|
|
3222
|
+
checkedTable("aliasNarrowTypes", () => this.aliasNarrowTypes.size),
|
|
3223
|
+
checkedTable("classSymbolKeys", () => this.classSymbolKeys.size),
|
|
3224
|
+
checkedTable("registeredClassSymbols", () => this.registeredClassSymbols.size),
|
|
3225
|
+
checkedTable("symbolFieldIdentities", () => this.symbolFieldIdentities.size),
|
|
3226
|
+
checkedTable("httpClientFnBindings", () => this.httpClientFnBindings.size),
|
|
3227
|
+
checkedTable("emitterComputedPatterns", () => this.emitterComputedPatterns.length),
|
|
3228
|
+
checkedTable("unstableSwitchBindings", () => this.unstableSwitchBindings.size),
|
|
3229
|
+
checkedTable("earlyReadVars", () => this.earlyReadVars.size),
|
|
3230
|
+
checkedTable("runtimeOptionalGlobals", () => this.runtimeOptionalGlobals.size),
|
|
3231
|
+
checkedTable("cjsExportsThis", () => this.cjsExportsThis.size),
|
|
3232
|
+
checkedTable("inlineRequireInitDone", () => this.inlineRequireInitDone.size),
|
|
3233
|
+
checkedTable("runtimeOptionalArithmeticGlobals", () => this.runtimeOptionalArithmeticGlobals.size),
|
|
3234
|
+
checkedTable("runtimeOptionalBindingTypes", () => this.runtimeOptionalBindingTypes.size),
|
|
3235
|
+
checkedTable("stageSourceTypes", () => this.stageSourceTypes.size),
|
|
3236
|
+
checkedTable("runtimeOptionalAssignedSymbols", () => this.runtimeOptionalAssignedSymbols.size),
|
|
3237
|
+
checkedTable("runtimeOptionalGenericReturns", () => this.runtimeOptionalGenericReturns.size),
|
|
3238
|
+
checkedTable("runtimeOptionalFunctionReturns", () => this.runtimeOptionalFunctionReturns.size),
|
|
3239
|
+
checkedTable("contextualFunctionReturns", () => this.contextualFunctionReturns.size),
|
|
3240
|
+
checkedTable("runtimeOptionalArithmeticTypes", () => this.runtimeOptionalArithmeticTypes.size),
|
|
3241
|
+
checkedTable("runtimeOptionalFields", () => this.runtimeOptionalFields.size),
|
|
3242
|
+
checkedTable("dateJsonBindings", () => this.dateJsonBindings.size),
|
|
3243
|
+
checkedTable("runtimeOptionalRecordsKeptDeclared", () => this.runtimeOptionalRecordsKeptDeclared.size),
|
|
3244
|
+
checkedTable("runtimeOptionalPatternTypes", () => this.runtimeOptionalPatternTypes.size),
|
|
3245
|
+
checkedTable("runtimeOptionalReduceTypes", () => this.runtimeOptionalReduceTypes.size),
|
|
3246
|
+
checkedTable("runtimeOptionalAssertions", () => this.runtimeOptionalAssertions.size),
|
|
3247
|
+
checkedTable("presentElementCalls", () => this.presentElementCalls.size),
|
|
3248
|
+
checkedTable("presentElementLoops", () => this.presentElementLoops.size),
|
|
3249
|
+
checkedTable("errorFirstLiterals", () => this.errorFirstLiterals.size),
|
|
3250
|
+
checkedTable("anySymbols", () => this.anySymbols.size),
|
|
3251
|
+
checkedTable("knownErrors", () => this.knownErrors.size),
|
|
3252
|
+
checkedTable("shapeOrderMetadataFinalizers", () => this.shapeOrderMetadataFinalizers.length),
|
|
3253
|
+
checkedTable("receiverTypeOverrides", () => this.receiverTypeOverrides.size),
|
|
3254
|
+
checkedTable("shapeOrderHelperFinalizers", () => this.shapeOrderHelperFinalizers.length),
|
|
3255
|
+
checkedTable("emitSpecDone", () => this.emitSpecDone.size),
|
|
3256
|
+
checkedTable("emitSpecQueue", () => this.emitSpecQueue.length),
|
|
3257
|
+
checkedTable("structuralClassPeers", () => this.structuralClassPeers.size),
|
|
3258
|
+
checkedTable("methodLambdasInProgress", () => this.methodLambdasInProgress.size),
|
|
3259
|
+
checkedTable("classMethodValueSelections", () => this.classMethodValueSelections.size),
|
|
3260
|
+
checkedTable("stdlibGlobalAliases", () => this.stdlibGlobalAliases.size),
|
|
3261
|
+
// The snapshots' own declarations and their one-report memory: both
|
|
3262
|
+
// grow with stdlibGlobalAliases, one entry per registered declaration.
|
|
3263
|
+
checkedTable("stdlibGlobalAliasDecls", () => this.stdlibGlobalAliasDecls.size),
|
|
3264
|
+
checkedTable("stdlibSnapshotReported", () => this.stdlibSnapshotReported.size),
|
|
3265
|
+
checkedTable("cjsAccessorFns", () => this.cjsAccessorFns.size),
|
|
3266
|
+
checkedTable("cjsAccessorSnapshots", () => this.cjsAccessorSnapshots.size),
|
|
3267
|
+
checkedTable("cjsSnapshotReady", () => this.cjsSnapshotReady.size),
|
|
3268
|
+
checkedTable("matchAllIndexBindings", () => this.matchAllIndexBindings.size),
|
|
3269
|
+
checkedTable("matchAllDrainIndexes", () => this.matchAllDrainIndexes.size),
|
|
3270
|
+
checkedTable("numericIterators", () => this.numericIterators.size),
|
|
3271
|
+
checkedTable("classes", () => this.classes.size),
|
|
3272
|
+
checkedTable("classBySymbol", () => this.classBySymbol.size),
|
|
3273
|
+
checkedTable("prototypeMethodAccesses", () => this.prototypeMethodAccesses.size),
|
|
3274
|
+
checkedTable("replacedSymbolMethods", () => this.replacedSymbolMethods.size),
|
|
3275
|
+
checkedTable("protocolDispatches", () => this.protocolDispatches.size),
|
|
3276
|
+
checkedTable("protocolOwnedBindings", () => this.protocolOwnedBindings.size),
|
|
3277
|
+
checkedTable("receiverFreeCallbackFields", () => this.receiverFreeCallbackFields.size),
|
|
3278
|
+
checkedTable("virtualJsMethods", () => this.virtualJsMethods.size),
|
|
3279
|
+
checkedTable("inheritedJsFieldWrites", () => this.inheritedJsFieldWrites.size),
|
|
3280
|
+
checkedTable("virtualJsMethodArity", () => this.virtualJsMethodArity.size),
|
|
3281
|
+
checkedTable("checkedVirtualJsMethods", () => this.checkedVirtualJsMethods.size),
|
|
3282
|
+
checkedTable("unionReturnOverrides", () => this.unionReturnOverrides.size),
|
|
3283
|
+
checkedTable("checkedVirtualJsAccessors", () => this.checkedVirtualJsAccessors.size),
|
|
3284
|
+
checkedTable("checkedVirtualJsValueReturns", () => this.checkedVirtualJsValueReturns.size),
|
|
3285
|
+
checkedTable("globalsBySymbol", () => this.globalsBySymbol.size),
|
|
3286
|
+
checkedTable("expandoMembers", () => this.expandoMembers.size),
|
|
3287
|
+
checkedTable("globalsByDeclNode", () => this.globalsByDeclNode.size),
|
|
3288
|
+
checkedTable("globalsList", () => this.globalsList.length),
|
|
3289
|
+
checkedTable("npmInitActions", () => this.npmInitActions.size),
|
|
3290
|
+
checkedTable("jsonInitActions", () => this.jsonInitActions.size),
|
|
3291
|
+
checkedTable("jsonRequireModules", () => this.jsonRequireModules.size),
|
|
3292
|
+
checkedTable("jsonRequireCalls", () => this.jsonRequireCalls.size),
|
|
3293
|
+
checkedTable("dynImports", () => this.dynImports.size),
|
|
3294
|
+
checkedTable("createRequireImports", () => this.createRequireImports.size),
|
|
3295
|
+
checkedTable("dynNsBuilders", () => this.dynNsBuilders.size),
|
|
3296
|
+
checkedTable("checkedCallbackParams", () => this.checkedCallbackParams.size),
|
|
3297
|
+
checkedTable("valueStreamReceivers", () => this.valueStreamReceivers.size),
|
|
3298
|
+
checkedTable("stagedArguments", () => this.stagedArguments.size),
|
|
3299
|
+
checkedTable("moduleNsParamOverrides", () => this.moduleNsParamOverrides.size),
|
|
3300
|
+
checkedTable("fileTag", () => this.fileTag.size),
|
|
3301
|
+
checkedTable("forkTargets", () => this.forkTargets.length),
|
|
3302
|
+
checkedTable("workerTargets", () => this.workerTargets.length),
|
|
3303
|
+
checkedTable("workerTargetIdByPath", () => this.workerTargetIdByPath.size),
|
|
3304
|
+
checkedTable("experimentalFiles", () => this.experimentalFiles.size),
|
|
3305
|
+
checkedTable("internTableNames", () => this.internTableNames.size),
|
|
3306
|
+
checkedTable("threadSlotNames", () => this.threadSlotNames.size),
|
|
3307
|
+
checkedTable("threadSlotFamilies", () => this.threadSlotFamilies.size),
|
|
3308
|
+
checkedTable("threadSlotKeys", () => this.threadSlotKeys.size),
|
|
3309
|
+
checkedTable("forkTargetIdByPath", () => this.forkTargetIdByPath.size),
|
|
3310
|
+
checkedTable("nsBlocks", () => this.nsBlocks.size),
|
|
3311
|
+
checkedTable("initNameOf", () => this.initNameOf.size),
|
|
3312
|
+
checkedTable("cjsModuleIdOf", () => this.cjsModuleIdOf.size),
|
|
3313
|
+
checkedTable("cjsModuleFiles", () => this.cjsModuleFiles.length),
|
|
3314
|
+
checkedTable("moduleGuardOf", () => this.moduleGuardOf.size),
|
|
3315
|
+
checkedTable("asyncInitFiles", () => this.asyncInitFiles.size),
|
|
3316
|
+
checkedTable("modulePromiseOf", () => this.modulePromiseOf.size),
|
|
3317
|
+
checkedTable("asyncCycleRepresentativeOf", () => this.asyncCycleRepresentativeOf.size),
|
|
3318
|
+
checkedTable("asyncCyclePromiseOf", () => this.asyncCyclePromiseOf.size),
|
|
3319
|
+
checkedTable("runtimeClassValues", () => this.runtimeClassValues.size),
|
|
3320
|
+
checkedTable("preparedClassFactories", () => this.preparedClassFactories.size),
|
|
3321
|
+
checkedTable("preparingClassFactories", () => this.preparingClassFactories.size),
|
|
3322
|
+
checkedTable("varGlobalEntryInits", () => this.varGlobalEntryInits.size),
|
|
3323
|
+
checkedTable("cycleInitFlags", () => this.cycleInitFlags.size),
|
|
3324
|
+
checkedTable("classInitFlags", () => this.classInitFlags.size),
|
|
3325
|
+
checkedTable("cycleInitDeclarations", () => this.cycleInitDeclarations.size),
|
|
3326
|
+
checkedTable("uninitializedLexicalGlobals", () => this.uninitializedLexicalGlobals.size),
|
|
3327
|
+
checkedTable("requireInitFlags", () => this.requireInitFlags.size),
|
|
3328
|
+
checkedTable("requireEarlyReferences", () => this.requireEarlyReferences.length),
|
|
3329
|
+
checkedTable("sharedHelpers", () => this.sharedHelpers.size),
|
|
3330
|
+
checkedTable("dynamicFunctions", () => this.dynamicFunctions.length),
|
|
3331
|
+
checkedTable("dynamicBodies", () => this.dynamicBodies.length),
|
|
3332
|
+
checkedTable("deferredDiags", () => this.deferredDiags.size),
|
|
3333
|
+
checkedTable("deferredClassByName", () => this.deferredClassByName.size),
|
|
3334
|
+
checkedTable("flushedSymbols", () => this.flushedSymbols.size),
|
|
3335
|
+
checkedTable("alreadyFlushed", () => this.alreadyFlushed.size),
|
|
3336
|
+
checkedTable("pendingFlushes", () => this.pendingFlushes.size),
|
|
3337
|
+
checkedTable("checkedJsFiles", () => this.checkedJsFiles.size),
|
|
3338
|
+
checkedTable("ffiImports", () => this.ffiImports.length),
|
|
3339
|
+
checkedTable("ffiImportsByName", () => this.ffiImportsByName.size),
|
|
3340
|
+
checkedTable("externalTypes", () => this.externalTypes.size),
|
|
3341
|
+
checkedTable("externalTypeSpecifiersByFile", () => this.externalTypeSpecifiersByFile.size),
|
|
3342
|
+
checkedTable("blockedBindings", () => this.blockedBindings.size),
|
|
3343
|
+
checkedTable("runtimeFences", () => this.runtimeFences.length),
|
|
3344
|
+
checkedTable("provenanceElided", () => this.provenanceElided.length),
|
|
3345
|
+
checkedTable("statsByFile", () => this.statsByFile.size),
|
|
3346
|
+
checkedTable("reachedBlockedBodyDiagnostics", () => this.reachedBlockedBodyDiagnostics.length),
|
|
3347
|
+
checkedTable("exprClasses", () => this.exprClasses.length),
|
|
3348
|
+
checkedTable("exprClassInfoByName", () => this.exprClassInfoByName.size),
|
|
3349
|
+
checkedTable("collectingExprClasses", () => this.collectingExprClasses.size),
|
|
3350
|
+
checkedTable("pendingClassExprInits", () => this.pendingClassExprInits.length),
|
|
3351
|
+
checkedTable("computedClassBases", () => this.computedClassBases.size),
|
|
3352
|
+
checkedTable("computedCallableBases", () => this.computedCallableBases.size),
|
|
3353
|
+
checkedTable("mixinInstanceByCall", () => this.mixinInstanceByCall.size),
|
|
3354
|
+
checkedTable("mixinCollectingCalls", () => this.mixinCollectingCalls.size),
|
|
3355
|
+
checkedTable("mixinOrdinals", () => this.mixinOrdinals.size),
|
|
3356
|
+
checkedTable("mixinInstancesByClassNode", () => this.mixinInstancesByClassNode.size),
|
|
3357
|
+
checkedTable("genericClassByDecl", () => this.genericClassByDecl.size),
|
|
3358
|
+
checkedTable("collectingClassDeclarations", () => this.collectingClassDeclarations.size),
|
|
3359
|
+
checkedTable("genericClassInstances", () => this.genericClassInstances.length),
|
|
3360
|
+
checkedTable("mainPrelude", () => this.mainPrelude.length),
|
|
3361
|
+
checkedTable("structuralFnInfos", () => this.structuralFnInfos.size),
|
|
3362
|
+
checkedTable("preservedLayoutTypes", () => this.preservedLayoutTypes.size),
|
|
3363
|
+
checkedTable("layoutKeptNodes", () => this.layoutKeptNodes.size),
|
|
3364
|
+
checkedTable("boundAliasInstances", () => this.boundAliasInstances.size),
|
|
3365
|
+
checkedTable("castGlobalAliases", () => this.castGlobalAliases.size),
|
|
3366
|
+
checkedTable("methodAccessSites", () => this.methodAccessSites.size),
|
|
3367
|
+
checkedTable("checkedJsOverrideMethods", () => this.checkedJsOverrideMethods.size),
|
|
3368
|
+
checkedTable("untypedLoops", () => this.untypedLoops.size),
|
|
3369
|
+
checkedTable("classBagInitializers", () => this.classBagInitializers.size),
|
|
3370
|
+
checkedTable("degradedTypes", () => this.degradedTypes.size),
|
|
3371
|
+
checkedTable("rejectedGroups", () => this.rejectedGroups.size),
|
|
3372
|
+
checkedTable("lenientPieces", () => this.lenientPieces.size),
|
|
3373
|
+
checkedTable("dynamicSlots", () => this.dynamicSlots.length),
|
|
3374
|
+
checkedTable("retriedSymbols", () => this.retriedSymbols.size),
|
|
3375
|
+
checkedTable("skippedBodies", () => this.skippedBodies.size),
|
|
3376
|
+
checkedTable("retriedDeclarations", () => this.retriedDeclarations.length),
|
|
3377
|
+
checkedTable("loweredOnceDiags", () => this.loweredOnceDiags.size),
|
|
3378
|
+
checkedTable("staticInitsPassed", () => this.staticInitsPassed.size),
|
|
3379
|
+
checkedTable("deferredCollectors", () => this.deferredCollectors.size),
|
|
3380
|
+
checkedTable("retriableDiags", () => this.retriableDiags.size),
|
|
3381
|
+
checkedTable("failedTypes", () => this.failedTypes.size),
|
|
3382
|
+
checkedTable("retryDegraded", () => this.retryDegraded.length),
|
|
3383
|
+
checkedTable("declOrigins", () => this.declOrigins.length),
|
|
3384
|
+
checkedTable("declOriginIds", () => this.declOriginIds.size),
|
|
3385
|
+
sizes("shapes", () => this.shapes.journalSizes()),
|
|
3386
|
+
this.unions.journalTable(),
|
|
3387
|
+
sizes("unions.recIds", () => this.unions.journalSizes()),
|
|
3388
|
+
sizes("keyOrder", () => this.keyOrder.journalSizes()),
|
|
3389
|
+
sizes("deferredModuleInitializers", () => this.deferredModuleInitializers === null
|
|
3390
|
+
? []
|
|
3391
|
+
: this.deferredModuleInitializers.journalSizes()),
|
|
3392
|
+
];
|
|
3393
|
+
}
|
|
3394
|
+
/** The fields a unit's record need not carry: settings, caches of
|
|
3395
|
+
* program facts that are computed again when needed, state of the unit
|
|
3396
|
+
* being lowered (keyed by its own IR, nodes or frames), scratch that
|
|
3397
|
+
* unwinds before the unit ends, and state that applying the unit's events
|
|
3398
|
+
* rebuilds. */
|
|
3399
|
+
static unjournaled = [
|
|
3400
|
+
// settings
|
|
3401
|
+
"frontendServices",
|
|
3402
|
+
"nodeIslands",
|
|
3403
|
+
"ambient",
|
|
3404
|
+
"overridesAmbient",
|
|
3405
|
+
"remainder",
|
|
3406
|
+
"tierMode",
|
|
3407
|
+
"generalNodeStreams",
|
|
3408
|
+
"dynNodeStreams",
|
|
3409
|
+
"targetPlatform",
|
|
3410
|
+
"startupCrash",
|
|
3411
|
+
"projectCheckJs",
|
|
3412
|
+
"libraryCallbacks",
|
|
3413
|
+
"ffiBindingSymbols",
|
|
3414
|
+
"priorRetriedSymbols",
|
|
3415
|
+
"wholeSlotDegradation",
|
|
3416
|
+
"inferredCollectionTypes",
|
|
3417
|
+
"foreignElementKeys",
|
|
3418
|
+
// caches made when first needed
|
|
3419
|
+
"nanCodedReads",
|
|
3420
|
+
"mentionsProcessVersions",
|
|
3421
|
+
"stringIndexBoundsCache",
|
|
3422
|
+
"functionLocalSubclasses",
|
|
3423
|
+
"socketEncodingReachable",
|
|
3424
|
+
"thenablesMayBeDefined",
|
|
3425
|
+
"unixListenReachable",
|
|
3426
|
+
"streamPropMutatedSyms",
|
|
3427
|
+
"readsExitCode",
|
|
3428
|
+
"requestInitPropMutatedSyms",
|
|
3429
|
+
"classProtocols",
|
|
3430
|
+
"cjsSplitRequireBindings",
|
|
3431
|
+
"cjsWholeExportSymbols",
|
|
3432
|
+
"cjsLiveMemberExports",
|
|
3433
|
+
"cjsNamespaces",
|
|
3434
|
+
"createRequireBindingTargets",
|
|
3435
|
+
"createRequireElementTargets",
|
|
3436
|
+
"computedGlobalReads",
|
|
3437
|
+
"sloppyThisGlobalReads",
|
|
3438
|
+
"globalLookupNames",
|
|
3439
|
+
"namesWebStreamClass",
|
|
3440
|
+
"timeValueDateDecisions",
|
|
3441
|
+
"timeValueDateWrites",
|
|
3442
|
+
"dynamicOverloadAnswers",
|
|
3443
|
+
"argumentCountSlots",
|
|
3444
|
+
"coercions.widenedReturnTypes",
|
|
3445
|
+
"packageFileMemo",
|
|
3446
|
+
// NI-5: whether a symbol names an island handle binding depends only on
|
|
3447
|
+
// its declaration, so the answer is a memo keyed by symbol.
|
|
3448
|
+
"islandHandleBindings",
|
|
3449
|
+
// The modules shared with the islands (NI-6): a pure function of the
|
|
3450
|
+
// program's modules, computed once, and the TDZ flags its plan gives a
|
|
3451
|
+
// statement.
|
|
3452
|
+
"sharedModules",
|
|
3453
|
+
"sharedInitFlags",
|
|
3454
|
+
"slotOriginMemo",
|
|
3455
|
+
"recordOriginMemo",
|
|
3456
|
+
"boundaryCastOrder",
|
|
3457
|
+
"declBoundaryMemo",
|
|
3458
|
+
"structuredCloneReadCounts",
|
|
3459
|
+
// state of the unit being lowered
|
|
3460
|
+
"assertedValues",
|
|
3461
|
+
"timeValueDateLocals",
|
|
3462
|
+
"speculatedClosures",
|
|
3463
|
+
"fsPathPlans",
|
|
3464
|
+
"fallibleFsCalls",
|
|
3465
|
+
"failureTouches",
|
|
3466
|
+
"partialHits",
|
|
3467
|
+
// sized by journalTables, indexes over journaled tables, and state that
|
|
3468
|
+
// applying a unit's events rebuilds
|
|
3469
|
+
"deferredModuleInitializers",
|
|
3470
|
+
"liftedFnsIndexed",
|
|
3471
|
+
"liftedFnsByName",
|
|
3472
|
+
"reachable",
|
|
3473
|
+
"reachableForArtifacts",
|
|
3474
|
+
"constructedClasses",
|
|
3475
|
+
"virtualEdges",
|
|
3476
|
+
"countedStatements",
|
|
3477
|
+
"failedStatements",
|
|
3478
|
+
"genericDemandRoots",
|
|
3479
|
+
"genericDemandPriority",
|
|
3480
|
+
"genericClassDemandPriority",
|
|
3481
|
+
"unitEvents",
|
|
3482
|
+
// scratch of the lowering in progress, and memos keyed by nodes
|
|
3483
|
+
"islandInstanceofHandled",
|
|
3484
|
+
"nullishBindings",
|
|
3485
|
+
"implicitLocalFns",
|
|
3486
|
+
"builtinClassAliases",
|
|
3487
|
+
"runtimeOptionalLocals.active",
|
|
3488
|
+
"runtimeOptionalLocals.scopes",
|
|
3489
|
+
"narrowing.facts",
|
|
3490
|
+
"narrowing.verdicts",
|
|
3491
|
+
"narrowing.effects",
|
|
3492
|
+
"narrowing.capturedMutable",
|
|
3493
|
+
"narrowing.staleBindings",
|
|
3494
|
+
"narrowing.identifierWrites",
|
|
3495
|
+
"narrowing.widened",
|
|
3496
|
+
"narrowing.plainContainers",
|
|
3497
|
+
"runtimeOptionalStorageLocals",
|
|
3498
|
+
"runtimeOptionalArithmeticLocals",
|
|
3499
|
+
"runtimeOptionalRoots",
|
|
3500
|
+
"coercions.planning",
|
|
3501
|
+
"coercions.copyRetags",
|
|
3502
|
+
"assertInstances",
|
|
3503
|
+
"unionLiteralOwners",
|
|
3504
|
+
"strippedUndefinedArms",
|
|
3505
|
+
"addedUndefinedArms",
|
|
3506
|
+
"stdlibSymbols",
|
|
3507
|
+
"chainRecvByNode",
|
|
3508
|
+
"neverValued",
|
|
3509
|
+
"chainNarrowedType",
|
|
3510
|
+
"chainHandled",
|
|
3511
|
+
"splitIdentifierUses",
|
|
3512
|
+
"typeMemo",
|
|
3513
|
+
"fnStack",
|
|
3514
|
+
"positions.nodesByKey",
|
|
3515
|
+
"positions.paths",
|
|
3516
|
+
"activeStmtLists",
|
|
3517
|
+
"constructorReturnPlans",
|
|
3518
|
+
"mixinFnShapes",
|
|
3519
|
+
];
|
|
3520
|
+
/** The fields a unit must leave as they were, and the flags it may set
|
|
3521
|
+
* (unit-journal.ts). */
|
|
3522
|
+
journalScalars() {
|
|
3523
|
+
const flag = flagScalar;
|
|
3524
|
+
const fixed = fixedScalar;
|
|
3525
|
+
return [
|
|
3526
|
+
flag("handleEventReader", () => this.handleEventReader, () => (this.handleEventReader = true)),
|
|
3527
|
+
flag("writesOntoChildren", () => this.writesOntoChildren, () => (this.writesOntoChildren = true)),
|
|
3528
|
+
flag("regexGroupResults", () => this.regexGroupResults, () => (this.regexGroupResults = true)),
|
|
3529
|
+
flag("requiresHistoricalOrderRelower", () => this.requiresHistoricalOrderRelower, () => (this.requiresHistoricalOrderRelower = true)),
|
|
3530
|
+
flag("requiresGeneralNodeStreams", () => this.requiresGeneralNodeStreams, () => (this.requiresGeneralNodeStreams = true)),
|
|
3531
|
+
flag("requiresDynNodeStreams", () => this.requiresDynNodeStreams, () => (this.requiresDynNodeStreams = true)),
|
|
3532
|
+
flag("errorPrototypeValues", () => this.errorPrototypeValues, () => (this.errorPrototypeValues = true)),
|
|
3533
|
+
flag("usesWorkers", () => this.usesWorkers, () => (this.usesWorkers = true)),
|
|
3534
|
+
flag("usesWebAssembly", () => this.usesWebAssembly, () => (this.usesWebAssembly = true)),
|
|
3535
|
+
flag("usesWasmCustomSections", () => this.usesWasmCustomSections, () => (this.usesWasmCustomSections = true)),
|
|
3536
|
+
flag("usesLifetimeRegions", () => this.usesLifetimeRegions, () => (this.usesLifetimeRegions = true)),
|
|
3537
|
+
flag("usesNodeIsland", () => this.usesNodeIsland, () => (this.usesNodeIsland = true)),
|
|
3538
|
+
flag("cjsModuleGraphEnabled", () => this.cjsModuleGraphEnabled, () => (this.cjsModuleGraphEnabled = true)),
|
|
3539
|
+
flag("globalThisComputedWrite", () => this.globalThisComputedWrite, () => (this.globalThisComputedWrite = true)),
|
|
3540
|
+
flag("untypedIntegrity", () => this.untypedIntegrity, () => (this.untypedIntegrity = true)),
|
|
3541
|
+
flag("partialDegradedTypesMapped", () => this.partialDegradedTypesMapped, () => (this.partialDegradedTypesMapped = true)),
|
|
3542
|
+
fixed("errorAccessorReflection", () => this.errorAccessorReflection),
|
|
3543
|
+
fixed("subclassLinks", () => this.subclassLinks),
|
|
3544
|
+
fixed("errorPathCopies", () => this.errorPathCopies),
|
|
3545
|
+
fixed("errorMethodDispatchRevision", () => this.errorMethodDispatchRevision),
|
|
3546
|
+
fixed("errorPropertyDispatchRevision", () => this.errorPropertyDispatchRevision),
|
|
3547
|
+
fixed("childAdditions", () => this.childAdditions),
|
|
3548
|
+
fixed("emitterEventTable", () => this.emitterEventTable),
|
|
3549
|
+
fixed("globalThisWrittenNames", () => this.globalThisWrittenNames),
|
|
3550
|
+
fixed("importRetryModules", () => this.importRetryModules),
|
|
3551
|
+
fixed("localSubclassIndex", () => this.localSubclassIndex),
|
|
3552
|
+
// State of the lowering in progress, which a unit restores.
|
|
3553
|
+
fixed("genericInstantiationPath", () => this.genericInstantiationPath),
|
|
3554
|
+
fixed("genericDemandOwner", () => this.genericDemandOwner),
|
|
3555
|
+
fixed("typeParamBindings", () => this.typeParamBindings),
|
|
3556
|
+
fixed("staticFnNames", () => this.staticFnNames),
|
|
3557
|
+
fixed("erasingDepth", () => this.erasingDepth),
|
|
3558
|
+
fixed("instanceResultClass", () => this.instanceResultClass),
|
|
3559
|
+
fixed("typeParamTsBindings", () => this.typeParamTsBindings),
|
|
3560
|
+
fixed("implicitParamTypes", () => this.implicitParamTypes),
|
|
3561
|
+
fixed("fspGlobHead", () => this.fspGlobHead),
|
|
3562
|
+
fixed("instantiationContext", () => this.instantiationContext),
|
|
3563
|
+
fixed("suppressStats", () => this.suppressStats),
|
|
3564
|
+
fixed("emitSpecCtx", () => this.emitSpecCtx),
|
|
3565
|
+
fixed("assertCallOptions", () => this.assertCallOptions),
|
|
3566
|
+
fixed("currentClass", () => this.currentClass),
|
|
3567
|
+
fixed("closureRoot", () => this.closureRoot),
|
|
3568
|
+
fixed("superConstructorEdge", () => this.superConstructorEdge),
|
|
3569
|
+
fixed("returnAwaitedPromise", () => this.returnAwaitedPromise),
|
|
3570
|
+
fixed("collecting", () => this.collecting),
|
|
3571
|
+
fixed("diagSink", () => this.diagSink),
|
|
3572
|
+
fixed("speculativeTypeQueryDepth", () => this.speculativeTypeQueryDepth),
|
|
3573
|
+
fixed("mixinTypeContext", () => this.mixinTypeContext),
|
|
3574
|
+
fixed("pendingLabels", () => this.pendingLabels),
|
|
3575
|
+
fixed("onEdge", () => this.onEdge),
|
|
3576
|
+
fixed("onExprClassCollected", () => this.onExprClassCollected),
|
|
3577
|
+
fixed("onLateClassCollected", () => this.onLateClassCollected),
|
|
3578
|
+
fixed("onDeclarationRegistered", () => this.onDeclarationRegistered),
|
|
3579
|
+
fixed("classLayoutChanges", () => this.classLayoutChanges),
|
|
3580
|
+
fixed("unitRegistrations", () => this.unitRegistrations),
|
|
3581
|
+
fixed("liftDynFieldPolicy", () => this.liftDynFieldPolicy),
|
|
3582
|
+
fixed("coercionOriginNode", () => this.coercionOriginNode),
|
|
3583
|
+
fixed("coercionOriginUnion", () => this.coercionOriginUnion),
|
|
3584
|
+
fixed("coercionFieldOrigin", () => this.coercionFieldOrigin),
|
|
3585
|
+
];
|
|
3586
|
+
}
|
|
2744
3587
|
/** Coverage remainder mode: the reachability gate inverts (see wantBody)
|
|
2745
3588
|
* and no module is built. */
|
|
2746
3589
|
remainder;
|
|
@@ -2796,6 +3639,61 @@ export class Lowerer {
|
|
|
2796
3639
|
* the fallthroughs report the inherited-blocker cascade (SC2004)
|
|
2797
3640
|
* instead of misattributing the reference. */
|
|
2798
3641
|
blockedBindings = new Set();
|
|
3642
|
+
/** Localized failure, report-only: the failure group (type-failure.ts)
|
|
3643
|
+
* of each declaration whose rejection reached the build — a flushed
|
|
3644
|
+
* deferred declaration, or a binding of a poisoned declaration
|
|
3645
|
+
* statement. */
|
|
3646
|
+
rejectedGroups = new Map();
|
|
3647
|
+
/** One frame per statement lowerStmts is lowering: the failure groups
|
|
3648
|
+
* its lowering touched. A statement that then poisons attributes its
|
|
3649
|
+
* diagnostics to them (ScrDiagnostic.cause). */
|
|
3650
|
+
failureTouches = [];
|
|
3651
|
+
/** Localized failure: checker types (by id) whose strict mapping failed
|
|
3652
|
+
* at a committed slot, with their lenient mapping. Filled only at the
|
|
3653
|
+
* commit points (degradeAtCommit), so a program that compiles today
|
|
3654
|
+
* never fills it. */
|
|
3655
|
+
degradedTypes = new Map();
|
|
3656
|
+
/** A pushed-down (partial) degraded type was mapped (hasPartialDegradedTypes). */
|
|
3657
|
+
partialDegradedTypesMapped = false;
|
|
3658
|
+
/** The components lenient mappings turned into the checked dynamic, by
|
|
3659
|
+
* checker type id, with the declared type they are pieces of (SC6101
|
|
3660
|
+
* causes and per-slot operation counts). */
|
|
3661
|
+
lenientPieces = new Map();
|
|
3662
|
+
/** One frame per unit a commit point may retry: the pushed-down
|
|
3663
|
+
* (partial) degraded types its lowering mapped (withPartialHits). */
|
|
3664
|
+
partialHits = [];
|
|
3665
|
+
/** The dynamic slots the commit points created: one SC6104 each. */
|
|
3666
|
+
dynamicSlots = [];
|
|
3667
|
+
/** Declarations retryDeferred registered. */
|
|
3668
|
+
retriedSymbols = new Set();
|
|
3669
|
+
/** LowererMode.retriedSymbols. */
|
|
3670
|
+
priorRetriedSymbols;
|
|
3671
|
+
/** LowererMode.wholeSlotDegradation. */
|
|
3672
|
+
wholeSlotDegradation;
|
|
3673
|
+
/** Bodies run() skipped because their declaration had not registered. */
|
|
3674
|
+
skippedBodies = new Set();
|
|
3675
|
+
/** Declarations retryDeferred registered, in order: run() lowers the
|
|
3676
|
+
* bodies it had skipped. */
|
|
3677
|
+
retriedDeclarations = [];
|
|
3678
|
+
/** Diagnostics of lowering that a statement's retry does not repeat (a
|
|
3679
|
+
* function-local class's member bodies, lowered once and kept):
|
|
3680
|
+
* dropAttemptDiags keeps them. */
|
|
3681
|
+
loweredOnceDiags = new Set();
|
|
3682
|
+
/** Deferred classes whose static field initializers' place in %init
|
|
3683
|
+
* has been lowered (retryDeferredAtDeclaration): a later flush must not
|
|
3684
|
+
* register them, since their initializers would never run. */
|
|
3685
|
+
staticInitsPassed = new Set();
|
|
3686
|
+
/** Deferred declarations' collections, for the flush retry
|
|
3687
|
+
* (retryDeferred). */
|
|
3688
|
+
deferredCollectors = new Map();
|
|
3689
|
+
/** True while a flush retry collects a declaration: the dyn class
|
|
3690
|
+
* field policy (dynFieldPolicyFence) is lifted for reached classes. */
|
|
3691
|
+
liftDynFieldPolicy = false;
|
|
3692
|
+
/** Collection diagnostics that a flush retry may simply run again (a
|
|
3693
|
+
* derived class whose base had not registered yet). */
|
|
3694
|
+
retriableDiags = new Set();
|
|
3695
|
+
/** The checker type behind each type failure badType committed. */
|
|
3696
|
+
failedTypes = new Map();
|
|
2799
3697
|
/** True while collectProgram runs: resolution helpers must not flush
|
|
2800
3698
|
* deferred diagnostics (collection itself resolves symbols — extends
|
|
2801
3699
|
* clauses — and collection order must not decide what reports). */
|
|
@@ -2832,6 +3730,7 @@ export class Lowerer {
|
|
|
2832
3730
|
if (this.countedStatements.has(node))
|
|
2833
3731
|
return;
|
|
2834
3732
|
this.countedStatements.add(node);
|
|
3733
|
+
this.unitEvents?.record("statement", ts.getSourceFileOfNode(node).fileName, file ?? null, node.index);
|
|
2835
3734
|
this.stats.statementsTotal++;
|
|
2836
3735
|
if (file !== undefined)
|
|
2837
3736
|
this.bumpFileStat(file, "total");
|
|
@@ -2842,6 +3741,7 @@ export class Lowerer {
|
|
|
2842
3741
|
if (this.failedStatements.has(node))
|
|
2843
3742
|
return;
|
|
2844
3743
|
this.failedStatements.add(node);
|
|
3744
|
+
this.unitEvents?.record("failedStatement", ts.getSourceFileOfNode(node).fileName, file ?? null, node.index);
|
|
2845
3745
|
this.stats.statementsFailed++;
|
|
2846
3746
|
if (file !== undefined)
|
|
2847
3747
|
this.bumpFileStat(file, "failed");
|
|
@@ -2849,21 +3749,89 @@ export class Lowerer {
|
|
|
2849
3749
|
/** Bumps the per-file attribution counter (no-op unless provenance is
|
|
2850
3750
|
* active and this is the emit/discovery lane — mirror the CALLER's
|
|
2851
3751
|
* suppressStats guard, this method only gates remainder). */
|
|
2852
|
-
bumpFileStat(file, kind) {
|
|
3752
|
+
bumpFileStat(file, kind, by = 1) {
|
|
2853
3753
|
if (this.remainder || !provenanceActive())
|
|
2854
3754
|
return;
|
|
2855
3755
|
let s = this.statsByFile.get(file);
|
|
2856
3756
|
if (!s)
|
|
2857
3757
|
this.statsByFile.set(file, (s = { total: 0, failed: 0 }));
|
|
2858
3758
|
if (kind === "total")
|
|
2859
|
-
s.total +=
|
|
3759
|
+
s.total += by;
|
|
2860
3760
|
else if (kind === "failed")
|
|
2861
|
-
s.failed +=
|
|
3761
|
+
s.failed += by;
|
|
2862
3762
|
}
|
|
2863
3763
|
/** The program holds the declaration-typed boundary's projection
|
|
2864
3764
|
* (decl-projection.ts): user-file record and array values crossing into
|
|
2865
3765
|
* dynamic slots (package parameters) box as live capsules, so a value
|
|
2866
3766
|
* that comes back through a boundary cast keeps its identity. */
|
|
3767
|
+
/** Origins of package-declared types checked in this program
|
|
3768
|
+
* (decl-origin.ts), by IrModule.declOrigins index. */
|
|
3769
|
+
declOrigins = [];
|
|
3770
|
+
declOriginIds = new Map();
|
|
3771
|
+
packageFileMemo = new Map();
|
|
3772
|
+
slotOriginMemo = new Map();
|
|
3773
|
+
/** The value whose slot coercion is being lowered, while that value is
|
|
3774
|
+
* in a package file: union extractions built for it carry the slot's
|
|
3775
|
+
* origin in their TypeError. */
|
|
3776
|
+
coercionOriginNode = null;
|
|
3777
|
+
/** Per user file, each declaration-boundary cast's index in source
|
|
3778
|
+
* order (narrowing.ts recordedBoundaryOrigin). */
|
|
3779
|
+
boundaryCastOrder = new Map();
|
|
3780
|
+
/** The union type of that value: only its own extraction is the slot's. */
|
|
3781
|
+
coercionOriginUnion = null;
|
|
3782
|
+
/** While a record projection into a package-declared type builds, the
|
|
3783
|
+
* origin of the field being converted. */
|
|
3784
|
+
coercionFieldOrigin = null;
|
|
3785
|
+
recordOriginMemo = new Map();
|
|
3786
|
+
/** The package-declared record type the current coercion converts to. */
|
|
3787
|
+
coercionRecordOrigin() {
|
|
3788
|
+
const node = this.coercionOriginNode;
|
|
3789
|
+
if (node === null)
|
|
3790
|
+
return null;
|
|
3791
|
+
let origin = this.recordOriginMemo.get(node);
|
|
3792
|
+
if (origin === undefined) {
|
|
3793
|
+
try {
|
|
3794
|
+
origin = recordOrigin(this.checker, node);
|
|
3795
|
+
}
|
|
3796
|
+
catch {
|
|
3797
|
+
origin = null;
|
|
3798
|
+
}
|
|
3799
|
+
this.recordOriginMemo.set(node, origin);
|
|
3800
|
+
}
|
|
3801
|
+
return origin;
|
|
3802
|
+
}
|
|
3803
|
+
declOriginIndex(origin) {
|
|
3804
|
+
let id = this.declOriginIds.get(origin);
|
|
3805
|
+
if (id === undefined) {
|
|
3806
|
+
id = this.declOrigins.length;
|
|
3807
|
+
this.declOrigins.push(origin);
|
|
3808
|
+
this.declOriginIds.set(origin, id);
|
|
3809
|
+
}
|
|
3810
|
+
return id;
|
|
3811
|
+
}
|
|
3812
|
+
/** The origin of the package-declared slot a value flows into. */
|
|
3813
|
+
slotOriginOf(node) {
|
|
3814
|
+
let origin = this.slotOriginMemo.get(node);
|
|
3815
|
+
if (origin === undefined) {
|
|
3816
|
+
try {
|
|
3817
|
+
origin = slotOrigin(this.checker, node);
|
|
3818
|
+
}
|
|
3819
|
+
catch {
|
|
3820
|
+
origin = null;
|
|
3821
|
+
}
|
|
3822
|
+
this.slotOriginMemo.set(node, origin);
|
|
3823
|
+
}
|
|
3824
|
+
return origin;
|
|
3825
|
+
}
|
|
3826
|
+
inPackageFileOf(node) {
|
|
3827
|
+
const sf = ts.getSourceFileOfNode(node);
|
|
3828
|
+
let inside = this.packageFileMemo.get(sf);
|
|
3829
|
+
if (inside === undefined) {
|
|
3830
|
+
inside = inPackageFile(node);
|
|
3831
|
+
this.packageFileMemo.set(sf, inside);
|
|
3832
|
+
}
|
|
3833
|
+
return inside;
|
|
3834
|
+
}
|
|
2867
3835
|
declBoundaryMemo = null;
|
|
2868
3836
|
get declBoundary() {
|
|
2869
3837
|
this.declBoundaryMemo ??= this.program.getSourceFileNames().some(isDeclBoundaryFile);
|
|
@@ -2878,12 +3846,23 @@ export class Lowerer {
|
|
|
2878
3846
|
this.moduleOrder = moduleOrder;
|
|
2879
3847
|
// The mode's options, sorted by name; the values derived from them follow.
|
|
2880
3848
|
this.alreadyFlushed = mode.alreadyFlushed ?? new Set();
|
|
3849
|
+
// Lenient forms are IR types of the other pass's shape tables: only the
|
|
3850
|
+
// whole-slot dynamic carries over as is.
|
|
3851
|
+
if (mode.degradedTypes)
|
|
3852
|
+
for (const [id, degraded] of mode.degradedTypes)
|
|
3853
|
+
this.degradedTypes.set(id, {
|
|
3854
|
+
...degraded,
|
|
3855
|
+
lenient: degraded.lenient?.kind === "dyn" ? DYN : null,
|
|
3856
|
+
});
|
|
3857
|
+
this.priorRetriedSymbols = mode.retriedSymbols ?? new Set();
|
|
3858
|
+
this.wholeSlotDegradation = mode.wholeSlotDegradation ?? false;
|
|
2881
3859
|
this.externalTypes = mode.externalTypes ?? new Map();
|
|
2882
3860
|
this.ffiBindingSymbols = mode.ffiBindingSymbols ?? null;
|
|
2883
3861
|
this.ffiImports = mode.ffiImports ?? [];
|
|
2884
3862
|
this.forkTargets = mode.forkTargets ?? [];
|
|
2885
3863
|
this.frontendServices = mode.frontendServices;
|
|
2886
3864
|
this.inlineRequireCycleCalls = mode.inlineRequireCycleCalls ?? new Set();
|
|
3865
|
+
this.dynamicImportRejections = mode.dynamicImportRejections ?? new Map();
|
|
2887
3866
|
this.libraryCallbacks = mode.libraryCallbacks ?? false;
|
|
2888
3867
|
this.projectCheckJs = mode.projectCheckJs ?? false;
|
|
2889
3868
|
this.reachable = mode.reachable ?? null;
|
|
@@ -2904,7 +3883,12 @@ export class Lowerer {
|
|
|
2904
3883
|
this.externalTypeSpecifiersByFile =
|
|
2905
3884
|
mode.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(this.externalTypes);
|
|
2906
3885
|
this.checker = program.getTypeChecker();
|
|
3886
|
+
const islands = this.nodeIslands;
|
|
3887
|
+
const shadow = canonShadowHook(this.checker);
|
|
2907
3888
|
this.typeCtx = {
|
|
3889
|
+
...(islands !== null
|
|
3890
|
+
? { foreignType: (t) => isForeignType(islands, t, this.checker) }
|
|
3891
|
+
: {}),
|
|
2908
3892
|
checker: this.checker,
|
|
2909
3893
|
positionOf: (node) => this.positions.of(node),
|
|
2910
3894
|
shapes: this.shapes,
|
|
@@ -2912,6 +3896,30 @@ export class Lowerer {
|
|
|
2912
3896
|
classNamer: (decl) => this.classNamer(decl),
|
|
2913
3897
|
resolveTypeParam: this.typeParamResolver,
|
|
2914
3898
|
resolveTypeParamTs: this.typeParamTsResolver,
|
|
3899
|
+
resolveBoundAliasTs: this.boundAliasTsResolver,
|
|
3900
|
+
degradedType: (type) => {
|
|
3901
|
+
const id = type.id;
|
|
3902
|
+
if (id === undefined)
|
|
3903
|
+
return null;
|
|
3904
|
+
const degraded = this.degradedTypes.get(id);
|
|
3905
|
+
if (degraded === undefined)
|
|
3906
|
+
return null;
|
|
3907
|
+
// An entry handed over from another pass (the coverage remainder)
|
|
3908
|
+
// re-derives its lenient form in this lowerer's shape tables; the
|
|
3909
|
+
// checked dynamic cuts the knot while it does.
|
|
3910
|
+
if (degraded.lenient === null) {
|
|
3911
|
+
degraded.lenient = DYN;
|
|
3912
|
+
degraded.lenient =
|
|
3913
|
+
(degraded.canonical === true ? this.canonicalType(type) : null) ??
|
|
3914
|
+
this.lenientType(type);
|
|
3915
|
+
}
|
|
3916
|
+
if (degraded.lenient.kind !== "dyn" && degraded.canonical !== true) {
|
|
3917
|
+
this.partialHits[this.partialHits.length - 1]?.add(id);
|
|
3918
|
+
this.partialDegradedTypesMapped = true;
|
|
3919
|
+
}
|
|
3920
|
+
return degraded.lenient;
|
|
3921
|
+
},
|
|
3922
|
+
...(shadow !== undefined ? { canonShadow: shadow } : {}),
|
|
2915
3923
|
isErasing: () => this.erasingDepth > 0,
|
|
2916
3924
|
genericClassInstance: (decl, ref, mapArgument) => this.genericClassInstanceType(decl, ref, mapArgument),
|
|
2917
3925
|
runtimeClassValue: (type) => runtimeClassValueOfType(this, type),
|
|
@@ -2975,6 +3983,7 @@ export class Lowerer {
|
|
|
2975
3983
|
classImplementedProtocol: (type) => this.classImplementedProtocol(type),
|
|
2976
3984
|
isStdlibFile: (sf) => this.isStdlibFile(sf),
|
|
2977
3985
|
isNpmFile: (sf) => this.isNpmFile(sf),
|
|
3986
|
+
isExperimentalFile: (sf) => isExperimentalDeclarationFile(sf, this.experimentalFiles),
|
|
2978
3987
|
// The declaration-typed boundary's generated types (decl-projection.ts)
|
|
2979
3988
|
// describe data, like an explicitly mapped external type surface.
|
|
2980
3989
|
isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))) ||
|
|
@@ -3003,9 +4012,20 @@ export class Lowerer {
|
|
|
3003
4012
|
// moduleOrder BEFORE any pass constructed — lowerToIr runs
|
|
3004
4013
|
// appendDynamicImportModules once on the shared array (a per-pass run
|
|
3005
4014
|
// here would repeatedly extend the graph and duplicate cycle reports).
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
4015
|
+
// A module's tag hashes its stable file name rather than numbering its
|
|
4016
|
+
// place in moduleOrder, so adding or reordering modules leaves the other
|
|
4017
|
+
// modules' function names, and the closure names keyed by them,
|
|
4018
|
+
// unchanged. The native compiler's profile matches functions by name.
|
|
4019
|
+
const tagNumbers = new Set();
|
|
4020
|
+
for (const sf of this.moduleOrder) {
|
|
4021
|
+
if (sf === entry) {
|
|
4022
|
+
this.fileTag.set(sf, "");
|
|
4023
|
+
continue;
|
|
4024
|
+
}
|
|
4025
|
+
const n = moduleTagNumber(this.stableFileName(sf), tagNumbers);
|
|
4026
|
+
tagNumbers.add(n);
|
|
4027
|
+
this.fileTag.set(sf, `%m${n}.`);
|
|
4028
|
+
}
|
|
3009
4029
|
if (this.moduleOrder.length === 0)
|
|
3010
4030
|
this.fileTag.set(entry, "");
|
|
3011
4031
|
const jsDynamic = jsDynamicDeclarations(this.moduleOrder, this.checker);
|
|
@@ -3035,6 +4055,12 @@ export class Lowerer {
|
|
|
3035
4055
|
this.classProtocols ??= new ClassProtocols(this.checker, this.moduleOrder);
|
|
3036
4056
|
return this.classProtocols.usesCheckedIdentity(type);
|
|
3037
4057
|
}
|
|
4058
|
+
/** A record view a Map or Set answers: it keeps protocol identity but
|
|
4059
|
+
* calls the collection's own methods, never a stored member. */
|
|
4060
|
+
classCollectionView(type) {
|
|
4061
|
+
this.classProtocols ??= new ClassProtocols(this.checker, this.moduleOrder);
|
|
4062
|
+
return this.classProtocols.collectionView(type);
|
|
4063
|
+
}
|
|
3038
4064
|
/** Declared class fields may store a DYN value only when its static type
|
|
3039
4065
|
* is `unknown` or `object` (also with `null` or `undefined`, or an array
|
|
3040
4066
|
* of those), names checked protocol identity, is an owned runtime
|
|
@@ -3142,6 +4168,79 @@ export class Lowerer {
|
|
|
3142
4168
|
const path = type.moduleId.slice("file:".length);
|
|
3143
4169
|
return this.moduleOrder.find((sf) => tsgoPath(resolve(sf.fileName)) === path) ?? null;
|
|
3144
4170
|
}
|
|
4171
|
+
/** A module namespace taken as a checked-dynamic value (`const u: unknown
|
|
4172
|
+
* = ns`, `take(ns)`): the runtime's namespace object — one per module,
|
|
4173
|
+
* Node's sorted export keys, live reads through a compiled getter, and
|
|
4174
|
+
* Node's read-only write errors — built by `moduleNamespaceDynValue`.
|
|
4175
|
+
* `node:` builtins have no compiled source and no complete export table,
|
|
4176
|
+
* so they keep their fence. */
|
|
4177
|
+
moduleNamespaceDyn(ns) {
|
|
4178
|
+
if (!ns.type.moduleId.startsWith("file:"))
|
|
4179
|
+
return null;
|
|
4180
|
+
return moduleNamespaceDynValue(this, ns);
|
|
4181
|
+
}
|
|
4182
|
+
/** A `Promise<module namespace>` taken as `Promise<unknown>` (or as
|
|
4183
|
+
* `unknown`): one lifted async mapper per module awaits the promise and
|
|
4184
|
+
* answers the same namespace object a bare namespace value boxes to, so
|
|
4185
|
+
* the settlement is Node's namespace while the value stays a promise.
|
|
4186
|
+
* The import() promise reaches these slots alone, and the runtime's
|
|
4187
|
+
* per-module namespace cache keeps `await mapped === await original`; a
|
|
4188
|
+
* rejection propagates unchanged. */
|
|
4189
|
+
moduleNamespacePromiseDynValue(value) {
|
|
4190
|
+
const inner = value.type.inner;
|
|
4191
|
+
if (inner.kind !== "moduleNs" || !inner.moduleId.startsWith("file:"))
|
|
4192
|
+
return null;
|
|
4193
|
+
const loc = value.loc;
|
|
4194
|
+
const name = `%module.promise:${inner.moduleId}`;
|
|
4195
|
+
const promiseT = { kind: "promise", inner };
|
|
4196
|
+
if (!this.liftedFns.some((fn) => fn.name === name)) {
|
|
4197
|
+
const context = newFnCtx(false, null, null, DYN);
|
|
4198
|
+
context.isAsync = true;
|
|
4199
|
+
const previousClass = this.currentClass;
|
|
4200
|
+
this.currentClass = null;
|
|
4201
|
+
this.fnStack.push(context);
|
|
4202
|
+
let namespace = null;
|
|
4203
|
+
try {
|
|
4204
|
+
const awaited = {
|
|
4205
|
+
kind: "awaitExpr",
|
|
4206
|
+
value: varRef("promise", promiseT, loc),
|
|
4207
|
+
type: inner,
|
|
4208
|
+
loc,
|
|
4209
|
+
};
|
|
4210
|
+
namespace = moduleNamespaceDynValue(this, awaited);
|
|
4211
|
+
if (namespace) {
|
|
4212
|
+
const fn = {
|
|
4213
|
+
name,
|
|
4214
|
+
params: [{ localId: "promise", name: "promise", type: promiseT }],
|
|
4215
|
+
returnType: DYN,
|
|
4216
|
+
locals: [
|
|
4217
|
+
{ id: "promise", name: "promise", type: promiseT, mutable: false },
|
|
4218
|
+
...context.locals,
|
|
4219
|
+
],
|
|
4220
|
+
body: [{ kind: "return", value: namespace, loc }],
|
|
4221
|
+
async: true,
|
|
4222
|
+
loc,
|
|
4223
|
+
};
|
|
4224
|
+
this.liftedFns.push(fn);
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
finally {
|
|
4228
|
+
this.fnStack.pop();
|
|
4229
|
+
this.currentClass = previousClass;
|
|
4230
|
+
}
|
|
4231
|
+
// A namespace with no compiled source has no dynamic value: keep the
|
|
4232
|
+
// promise unconverted so the destination's own fence reports it.
|
|
4233
|
+
if (!namespace)
|
|
4234
|
+
return null;
|
|
4235
|
+
}
|
|
4236
|
+
return {
|
|
4237
|
+
kind: "call",
|
|
4238
|
+
callee: name,
|
|
4239
|
+
args: [value],
|
|
4240
|
+
type: { kind: "promise", inner: DYN },
|
|
4241
|
+
loc,
|
|
4242
|
+
};
|
|
4243
|
+
}
|
|
3145
4244
|
builtinErrorInfoOf(symbol) {
|
|
3146
4245
|
return builtinErrorInfoOf(this, symbol);
|
|
3147
4246
|
}
|
|
@@ -3704,6 +4803,46 @@ export class Lowerer {
|
|
|
3704
4803
|
}
|
|
3705
4804
|
return createRequireProgramModuleOf(this, decl.initializer)?.dep ?? null;
|
|
3706
4805
|
}
|
|
4806
|
+
createRequireBindingTargets = new Map();
|
|
4807
|
+
createRequireElementTargets = new Map();
|
|
4808
|
+
/** The program module a `const x = createRequire(...)("./m")` binding
|
|
4809
|
+
* requires, by the binding's symbol; null for every other binding. Every
|
|
4810
|
+
* reference resolves it (resolveValueSymbol), so it is cached. */
|
|
4811
|
+
createRequireBindingTarget(binding) {
|
|
4812
|
+
const cached = this.createRequireBindingTargets.get(binding);
|
|
4813
|
+
if (cached !== undefined)
|
|
4814
|
+
return cached;
|
|
4815
|
+
const decl = binding.declarations.find(ts.isVariableDeclaration);
|
|
4816
|
+
const target = decl && ts.isIdentifier(decl.name) && decl.initializer
|
|
4817
|
+
? createRequireProgramModuleOf(this, decl.initializer)
|
|
4818
|
+
: null;
|
|
4819
|
+
this.createRequireBindingTargets.set(binding, target);
|
|
4820
|
+
return target;
|
|
4821
|
+
}
|
|
4822
|
+
/** The binding element and required program module of a
|
|
4823
|
+
* `const { m } = createRequire(...)("./m")` binding, by the binding's
|
|
4824
|
+
* symbol; null for every other binding. Cached like
|
|
4825
|
+
* createRequireBindingTarget. */
|
|
4826
|
+
createRequireElementTarget(binding) {
|
|
4827
|
+
const cached = this.createRequireElementTargets.get(binding);
|
|
4828
|
+
if (cached !== undefined)
|
|
4829
|
+
return cached;
|
|
4830
|
+
let found = null;
|
|
4831
|
+
const element = binding.declarations.find(ts.isBindingElement);
|
|
4832
|
+
if (element &&
|
|
4833
|
+
element.name !== undefined &&
|
|
4834
|
+
ts.isIdentifier(element.name) &&
|
|
4835
|
+
ts.isObjectBindingPattern(element.parent)) {
|
|
4836
|
+
const declaration = element.parent.parent;
|
|
4837
|
+
const target = ts.isVariableDeclaration(declaration) && declaration.initializer
|
|
4838
|
+
? createRequireProgramModuleOf(this, declaration.initializer)
|
|
4839
|
+
: null;
|
|
4840
|
+
if (target !== null)
|
|
4841
|
+
found = { element, target };
|
|
4842
|
+
}
|
|
4843
|
+
this.createRequireElementTargets.set(binding, found);
|
|
4844
|
+
return found;
|
|
4845
|
+
}
|
|
3707
4846
|
/** The represented single value behind a createRequire binding, or null
|
|
3708
4847
|
* when the target is a namespace/table module. Collection has already
|
|
3709
4848
|
* registered executable exports before entry-module uses lower, so the
|
|
@@ -3711,10 +4850,7 @@ export class Lowerer {
|
|
|
3711
4850
|
* static storage or callable/class metadata. */
|
|
3712
4851
|
createRequireWholeExportSymbolOf(ident) {
|
|
3713
4852
|
const binding = this.checker.getSymbolAtLocation(ident);
|
|
3714
|
-
const
|
|
3715
|
-
if (!decl || !ts.isIdentifier(decl.name) || !decl.initializer)
|
|
3716
|
-
return null;
|
|
3717
|
-
const target = createRequireProgramModuleOf(this, decl.initializer);
|
|
4853
|
+
const target = binding ? this.createRequireBindingTarget(binding) : null;
|
|
3718
4854
|
if (target === null)
|
|
3719
4855
|
return null;
|
|
3720
4856
|
const moduleSym = this.checker.getSymbolAtLocation(target.dep);
|
|
@@ -3758,18 +4894,10 @@ export class Lowerer {
|
|
|
3758
4894
|
* target module's real export symbol. */
|
|
3759
4895
|
createRequireDestructuredExportSymbolOf(ident) {
|
|
3760
4896
|
const binding = this.checker.getSymbolAtLocation(ident);
|
|
3761
|
-
const
|
|
3762
|
-
if (
|
|
3763
|
-
element.name === undefined ||
|
|
3764
|
-
!ts.isIdentifier(element.name) ||
|
|
3765
|
-
!ts.isObjectBindingPattern(element.parent))
|
|
3766
|
-
return null;
|
|
3767
|
-
const declaration = element.parent.parent;
|
|
3768
|
-
if (!ts.isVariableDeclaration(declaration) || !declaration.initializer)
|
|
3769
|
-
return null;
|
|
3770
|
-
const target = createRequireProgramModuleOf(this, declaration.initializer);
|
|
3771
|
-
if (target === null)
|
|
4897
|
+
const found = binding ? this.createRequireElementTarget(binding) : null;
|
|
4898
|
+
if (found === null)
|
|
3772
4899
|
return null;
|
|
4900
|
+
const { element, target } = found;
|
|
3773
4901
|
const property = element.propertyName;
|
|
3774
4902
|
const name = property && (ts.isIdentifier(property) || ts.isStringLiteralLike(property))
|
|
3775
4903
|
? property.text
|
|
@@ -3893,7 +5021,15 @@ export class Lowerer {
|
|
|
3893
5021
|
return splitFiles(this);
|
|
3894
5022
|
}
|
|
3895
5023
|
collectProgram(parts) {
|
|
3896
|
-
|
|
5024
|
+
collectProgram(this, parts);
|
|
5025
|
+
// The coverage remainder registers the declarations reachable emit
|
|
5026
|
+
// registered with dynamic slots (retryDeferred), so it neither reports
|
|
5027
|
+
// them as unreached nor blocks their uses.
|
|
5028
|
+
for (const symbol of this.priorRetriedSymbols) {
|
|
5029
|
+
const diags = this.deferredDiags.get(symbol);
|
|
5030
|
+
if (diags !== undefined)
|
|
5031
|
+
this.retryDeferred(symbol, diags);
|
|
5032
|
+
}
|
|
3897
5033
|
}
|
|
3898
5034
|
/** Names every file's %init and registers the run-once guard globals
|
|
3899
5035
|
* (EVERY module, the entry included: an admissible import cycle can
|
|
@@ -4278,11 +5414,11 @@ export class Lowerer {
|
|
|
4278
5414
|
const sourceFiles = parts.map((p) => p.sf);
|
|
4279
5415
|
const fnDecls = parts.flatMap((p) => p.fnDecls);
|
|
4280
5416
|
// This fixed-point scan intentionally sees deferred bodies before
|
|
4281
|
-
// reachability is known.
|
|
4282
|
-
// facade's panic fence
|
|
4283
|
-
//
|
|
4284
|
-
// merged-namespace fences, whose
|
|
4285
|
-
|
|
5417
|
+
// reachability is known. Its binding queries were batched through the
|
|
5418
|
+
// facade's panic fence before collection (prefetchProgramSymbols); keep
|
|
5419
|
+
// lookup free of lowering side effects: resolveValueSymbol also flushes
|
|
5420
|
+
// deferred diagnostics and applies merged-namespace fences, whose
|
|
5421
|
+
// authority remains ordinary lowering.
|
|
4286
5422
|
// The facts each fixed-point site reads, by the symbols, nodes and
|
|
4287
5423
|
// element keys they belong to (created with the site list below).
|
|
4288
5424
|
let siteDependencies = null;
|
|
@@ -4717,6 +5853,7 @@ export class Lowerer {
|
|
|
4717
5853
|
sameBinding: (node) => node.text === use.text && symbolOf(node) === symbol,
|
|
4718
5854
|
isUndefined: (node) => node.text === "undefined" &&
|
|
4719
5855
|
((typeOrNull(node)?.flags ?? 0) & ts.TypeFlags.Undefined) !== 0,
|
|
5856
|
+
neverReturns: (call) => ((typeOrNull(call)?.flags ?? 0) & ts.TypeFlags.Never) !== 0,
|
|
4720
5857
|
});
|
|
4721
5858
|
presenceProofs.set(use, proven);
|
|
4722
5859
|
return proven;
|
|
@@ -4883,6 +6020,23 @@ export class Lowerer {
|
|
|
4883
6020
|
return null;
|
|
4884
6021
|
if (!primitive(e.left) || !primitive(e.right))
|
|
4885
6022
|
return null;
|
|
6023
|
+
// A missing read is undefined, and `+` yields a number only when
|
|
6024
|
+
// neither operand is a string: an operand that is always a string
|
|
6025
|
+
// (`"x-" + PAD[i]`) makes the result a string. Only literals,
|
|
6026
|
+
// templates and sums with such an operand are always strings; a
|
|
6027
|
+
// binding or call can hold a missing read.
|
|
6028
|
+
const definitelyString = (part) => {
|
|
6029
|
+
const p = peel(part);
|
|
6030
|
+
if (ts.isStringLiteral(p) || ts.isNoSubstitutionTemplateLiteral(p))
|
|
6031
|
+
return true;
|
|
6032
|
+
if (ts.isTemplateExpression(p))
|
|
6033
|
+
return true;
|
|
6034
|
+
return (ts.isBinaryExpression(p) &&
|
|
6035
|
+
p.operatorToken.kind === ts.SyntaxKind.PlusToken &&
|
|
6036
|
+
(definitelyString(p.left) || definitelyString(p.right)));
|
|
6037
|
+
};
|
|
6038
|
+
if (definitelyString(e.left) || definitelyString(e.right))
|
|
6039
|
+
return null;
|
|
4886
6040
|
return { kind: "union", unionId: this.unions.intern([F64, STRING]) };
|
|
4887
6041
|
};
|
|
4888
6042
|
/** The union of primitive result types, or null when any is missing or
|
|
@@ -5551,20 +6705,33 @@ export class Lowerer {
|
|
|
5551
6705
|
let dynamicViews = null;
|
|
5552
6706
|
// Element ABIs of the native arrays that an `any` or `unknown` value is
|
|
5553
6707
|
// converted to, including arrays nested in the converted value.
|
|
6708
|
+
// Assignments, including the logical ones (`view ??= numbers`).
|
|
6709
|
+
const assignmentOperators = new Set([
|
|
6710
|
+
ts.SyntaxKind.EqualsToken,
|
|
6711
|
+
ts.SyntaxKind.QuestionQuestionEqualsToken,
|
|
6712
|
+
ts.SyntaxKind.BarBarEqualsToken,
|
|
6713
|
+
ts.SyntaxKind.AmpersandAmpersandEqualsToken,
|
|
6714
|
+
]);
|
|
6715
|
+
// Initializers of class properties, parameter defaults and
|
|
6716
|
+
// destructuring defaults, which convert to the binding's type.
|
|
6717
|
+
const initializedBinding = (node) => (ts.isPropertyDeclaration(node) || ts.isParameter(node) || ts.isBindingElement(node)) &&
|
|
6718
|
+
node.initializer !== undefined;
|
|
5554
6719
|
const collectDynamicViews = () => {
|
|
5555
6720
|
const keys = new Set();
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
6721
|
+
// A binding's declared type says whether it holds dynamic data; a flow
|
|
6722
|
+
// type such as `Array.isArray(x)`'s `any[]` only narrows it.
|
|
6723
|
+
const typedNode = (node) => {
|
|
5559
6724
|
const e = peel(node);
|
|
5560
6725
|
const symbol = ts.isIdentifier(e) ? symbolOf(e) : null;
|
|
5561
6726
|
const declaration = symbol ? symbol.valueDeclaration : undefined;
|
|
5562
|
-
|
|
6727
|
+
return declaration &&
|
|
5563
6728
|
(ts.isVariableDeclaration(declaration) || ts.isParameter(declaration)) &&
|
|
5564
6729
|
ts.isIdentifier(declaration.name)
|
|
5565
6730
|
? declaration.name
|
|
5566
|
-
:
|
|
5567
|
-
|
|
6731
|
+
: node;
|
|
6732
|
+
};
|
|
6733
|
+
const dynamicValue = (node) => {
|
|
6734
|
+
const type = typeOrNull(typedNode(node));
|
|
5568
6735
|
if (type === null)
|
|
5569
6736
|
return true;
|
|
5570
6737
|
if ((type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
@@ -5592,55 +6759,335 @@ export class Lowerer {
|
|
|
5592
6759
|
else if (type.kind === "promise")
|
|
5593
6760
|
collect(type.inner, depth + 1);
|
|
5594
6761
|
};
|
|
5595
|
-
const
|
|
6762
|
+
const convert = (type) => {
|
|
5596
6763
|
// An unanswerable target may be any array.
|
|
5597
6764
|
if (type === null)
|
|
5598
6765
|
keys.add("*");
|
|
5599
6766
|
else if (type)
|
|
5600
6767
|
collect(this.mapTypeOf(type), 0);
|
|
5601
6768
|
};
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
node.initializer
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
else if (ts.isBinaryExpression(node) &&
|
|
5611
|
-
node.
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
6769
|
+
/** Each value `node` converts, with the type it converts to. */
|
|
6770
|
+
const conversions = (node, judge) => {
|
|
6771
|
+
if (ts.isAsExpression(node) || ts.isTypeAssertion(node))
|
|
6772
|
+
judge(node.expression, () => typeOrNull(node));
|
|
6773
|
+
else if (ts.isVariableDeclaration(node) && node.type && node.initializer)
|
|
6774
|
+
judge(node.initializer, () => typeOrNull(node.name));
|
|
6775
|
+
else if (initializedBinding(node))
|
|
6776
|
+
judge(node.initializer, () => typeOrNull(node.name ?? node));
|
|
6777
|
+
else if (ts.isBinaryExpression(node) && assignmentOperators.has(node.operatorToken.kind))
|
|
6778
|
+
judge(node.right, () => typeOrNull(node.left));
|
|
6779
|
+
else if ((ts.isReturnStatement(node) || ts.isYieldExpression(node)) && node.expression) {
|
|
6780
|
+
const value = node.expression;
|
|
6781
|
+
judge(value, () => contextualOrNull(value));
|
|
6782
|
+
}
|
|
5616
6783
|
else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
5617
6784
|
for (const arg of node.arguments?.nodes ?? [])
|
|
5618
|
-
if (!ts.isSpreadElement(arg)
|
|
5619
|
-
|
|
6785
|
+
if (!ts.isSpreadElement(arg))
|
|
6786
|
+
judge(arg, () => contextualOrNull(arg));
|
|
6787
|
+
}
|
|
6788
|
+
else if (ts.isPropertyAssignment(node)) {
|
|
6789
|
+
const value = node.initializer;
|
|
6790
|
+
judge(value, () => contextualOrNull(value));
|
|
5620
6791
|
}
|
|
5621
|
-
else if (ts.isPropertyAssignment(node) && dynamicValue(node.initializer))
|
|
5622
|
-
target(contextualOrNull(node.initializer));
|
|
5623
6792
|
else if (ts.isArrayLiteralExpression(node)) {
|
|
5624
6793
|
for (const element of node.elements.nodes)
|
|
5625
|
-
if (!ts.isSpreadElement(element) &&
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
dynamicValue(node.body))
|
|
5633
|
-
target(contextualOrNull(node.body));
|
|
6794
|
+
if (!ts.isSpreadElement(element) && !ts.isOmittedExpression(element))
|
|
6795
|
+
judge(element, () => contextualOrNull(element));
|
|
6796
|
+
}
|
|
6797
|
+
else if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
|
|
6798
|
+
const body = node.body;
|
|
6799
|
+
judge(body, () => contextualOrNull(body));
|
|
6800
|
+
}
|
|
5634
6801
|
};
|
|
6802
|
+
// The values' types in one batch: these bodies' reachability is not
|
|
6803
|
+
// known yet.
|
|
6804
|
+
const typed = [];
|
|
6805
|
+
for (const sf of sourceFiles)
|
|
6806
|
+
ts.walkPreorder(sf, (node) => {
|
|
6807
|
+
panicSafe(() => conversions(node, (value) => typed.push(typedNode(value))), undefined);
|
|
6808
|
+
return undefined;
|
|
6809
|
+
});
|
|
6810
|
+
this.checker.prefetchClassCollection(typed, []);
|
|
5635
6811
|
for (const sf of sourceFiles)
|
|
5636
6812
|
ts.walkPreorder(sf, (node) => {
|
|
5637
6813
|
// A checker panic hides this conversion's target: any array.
|
|
6814
|
+
const judged = panicSafe(() => (conversions(node, (value, target) => {
|
|
6815
|
+
if (dynamicValue(value))
|
|
6816
|
+
convert(target());
|
|
6817
|
+
}),
|
|
6818
|
+
true), false);
|
|
6819
|
+
if (!judged)
|
|
6820
|
+
keys.add("*");
|
|
6821
|
+
return undefined;
|
|
6822
|
+
});
|
|
6823
|
+
return keys;
|
|
6824
|
+
};
|
|
6825
|
+
// Element ABIs of the native arrays a value converted to a dynamic type
|
|
6826
|
+
// can reach: the conversion keeps each such array as a live view, so
|
|
6827
|
+
// stores through the dynamic value write the native storage.
|
|
6828
|
+
// Standard library functions that only read the arguments they take as
|
|
6829
|
+
// `any` or `unknown`: the console methods, String, Number, Boolean,
|
|
6830
|
+
// Array.isArray, Object.is, JSON.stringify without a replacer function,
|
|
6831
|
+
// and util's inspect and format. Any other function can keep an
|
|
6832
|
+
// argument (Promise.resolve, Map.prototype.set, push onto an
|
|
6833
|
+
// `unknown[]`) or pass it to a callback (a JSON.stringify replacer, an
|
|
6834
|
+
// emitted event), which can write through it.
|
|
6835
|
+
const readerGlobals = new Map([
|
|
6836
|
+
["console", null],
|
|
6837
|
+
["JSON", new Set(["stringify"])],
|
|
6838
|
+
["Array", new Set(["isArray"])],
|
|
6839
|
+
["Object", new Set(["is"])],
|
|
6840
|
+
]);
|
|
6841
|
+
const readerFunctions = new Set(["String", "Number", "Boolean"]);
|
|
6842
|
+
const utilReaders = new Set(["inspect", "format"]);
|
|
6843
|
+
const standardLibraryReader = (node) => panicSafe(() => {
|
|
6844
|
+
if (!ts.isCallExpression(node))
|
|
6845
|
+
return false;
|
|
6846
|
+
const callee = peel(node.expression);
|
|
6847
|
+
if (ts.isIdentifier(callee))
|
|
6848
|
+
return [...readerFunctions].some((name) => this.isStdlibGlobal(callee, name));
|
|
6849
|
+
if (!ts.isPropertyAccessExpression(callee))
|
|
6850
|
+
return false;
|
|
6851
|
+
const member = callee.name.text;
|
|
6852
|
+
for (const [global, members] of readerGlobals) {
|
|
6853
|
+
if (!this.isStdlibGlobal(callee.expression, global))
|
|
6854
|
+
continue;
|
|
6855
|
+
if (members !== null && !members.has(member))
|
|
6856
|
+
return false;
|
|
6857
|
+
if (global !== "JSON")
|
|
6858
|
+
return true;
|
|
6859
|
+
const replacer = node.arguments.nodes[1];
|
|
6860
|
+
return (replacer === undefined ||
|
|
6861
|
+
ts.isArrayLiteralExpression(peel(replacer)) ||
|
|
6862
|
+
peel(replacer).kind === ts.SyntaxKind.NullKeyword);
|
|
6863
|
+
}
|
|
6864
|
+
if (!utilReaders.has(member))
|
|
6865
|
+
return false;
|
|
6866
|
+
const declaration = this.checker.getResolvedSignature(node)?.declaration;
|
|
6867
|
+
if (declaration === undefined)
|
|
6868
|
+
return false;
|
|
6869
|
+
const file = ts.getSourceFileOfNode(declaration);
|
|
6870
|
+
return this.isStdlibFile(file) && /[\\/]util\.d\.ts$/.test(file.fileName);
|
|
6871
|
+
}, false);
|
|
6872
|
+
const collectNativeViews = () => {
|
|
6873
|
+
const keys = new Set();
|
|
6874
|
+
const seen = new Set();
|
|
6875
|
+
const collect = (type) => {
|
|
6876
|
+
if (!type)
|
|
6877
|
+
return;
|
|
6878
|
+
const id = typeKey(type);
|
|
6879
|
+
if (seen.has(id))
|
|
6880
|
+
return;
|
|
6881
|
+
seen.add(id);
|
|
6882
|
+
if (type.kind === "array") {
|
|
6883
|
+
if (type.elem.kind !== "dyn")
|
|
6884
|
+
keys.add(typeKey(type.elem));
|
|
6885
|
+
collect(type.elem);
|
|
6886
|
+
}
|
|
6887
|
+
else if (type.kind === "union") {
|
|
6888
|
+
for (const arm of this.unions.get(type.unionId)?.arms ?? [])
|
|
6889
|
+
collect(arm);
|
|
6890
|
+
}
|
|
6891
|
+
else if (type.kind === "record") {
|
|
6892
|
+
for (const field of this.shapes.get(type.shapeId)?.fields ?? [])
|
|
6893
|
+
collect(field.type);
|
|
6894
|
+
}
|
|
6895
|
+
else if (type.kind === "object") {
|
|
6896
|
+
for (const field of this.classes.get(type.className)?.fields.values() ?? [])
|
|
6897
|
+
collect(field);
|
|
6898
|
+
}
|
|
6899
|
+
else if (type.kind === "map") {
|
|
6900
|
+
collect(type.key);
|
|
6901
|
+
collect(type.value);
|
|
6902
|
+
}
|
|
6903
|
+
else if (type.kind === "set")
|
|
6904
|
+
collect(type.elem);
|
|
6905
|
+
else if (type.kind === "promise")
|
|
6906
|
+
collect(type.inner);
|
|
6907
|
+
};
|
|
6908
|
+
const holdsDynamic = (type, depth) => {
|
|
6909
|
+
if (!type || depth > 4)
|
|
6910
|
+
return false;
|
|
6911
|
+
if (type.kind === "dyn")
|
|
6912
|
+
return true;
|
|
6913
|
+
if (type.kind === "array" || type.kind === "set")
|
|
6914
|
+
return holdsDynamic(type.elem, depth + 1);
|
|
6915
|
+
if (type.kind === "map")
|
|
6916
|
+
return holdsDynamic(type.value, depth + 1);
|
|
6917
|
+
if (type.kind === "promise")
|
|
6918
|
+
return holdsDynamic(type.inner, depth + 1);
|
|
6919
|
+
if (type.kind === "union")
|
|
6920
|
+
return (this.unions.get(type.unionId)?.arms ?? []).some((arm) => holdsDynamic(arm, depth + 1));
|
|
6921
|
+
if (type.kind === "record")
|
|
6922
|
+
return (this.shapes.get(type.shapeId)?.fields ?? []).some((field) => holdsDynamic(field.type, depth + 1));
|
|
6923
|
+
return false;
|
|
6924
|
+
};
|
|
6925
|
+
const mapped = (type) => type ? panicSafe(() => this.mapTypeOf(type), null) : null;
|
|
6926
|
+
const flow = (source, target) => {
|
|
6927
|
+
if (target === undefined)
|
|
6928
|
+
return;
|
|
6929
|
+
const into = target === null ? null : mapped(target);
|
|
6930
|
+
// An unanswerable target may be dynamic.
|
|
6931
|
+
if (target !== null && into !== null && !holdsDynamic(into, 0))
|
|
6932
|
+
return;
|
|
6933
|
+
const from = typeOrNull(source);
|
|
6934
|
+
if (from === null)
|
|
6935
|
+
keys.add("*");
|
|
6936
|
+
else
|
|
6937
|
+
collect(mapped(from));
|
|
6938
|
+
};
|
|
6939
|
+
const visit = (node) => {
|
|
6940
|
+
if (ts.isAsExpression(node) || ts.isTypeAssertion(node))
|
|
6941
|
+
flow(node.expression, typeOrNull(node));
|
|
6942
|
+
else if (ts.isVariableDeclaration(node) && node.type && node.initializer)
|
|
6943
|
+
flow(node.initializer, typeOrNull(node.name));
|
|
6944
|
+
else if (initializedBinding(node))
|
|
6945
|
+
flow(node.initializer, typeOrNull(node.name ?? node));
|
|
6946
|
+
else if (ts.isBinaryExpression(node) && assignmentOperators.has(node.operatorToken.kind))
|
|
6947
|
+
flow(node.right, typeOrNull(node.left));
|
|
6948
|
+
else if (ts.isReturnStatement(node) && node.expression)
|
|
6949
|
+
flow(node.expression, contextualOrNull(node.expression));
|
|
6950
|
+
else if (ts.isYieldExpression(node) && node.expression)
|
|
6951
|
+
flow(node.expression, contextualOrNull(node.expression));
|
|
6952
|
+
// A thrown value reaches a catch binding, which is dynamic.
|
|
6953
|
+
else if (ts.isThrowStatement(node))
|
|
6954
|
+
flow(node.expression, null);
|
|
6955
|
+
else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
|
|
6956
|
+
if (!standardLibraryReader(node))
|
|
6957
|
+
for (const arg of node.arguments?.nodes ?? [])
|
|
6958
|
+
flow(ts.isSpreadElement(arg) ? arg.expression : arg, contextualOrNull(arg));
|
|
6959
|
+
}
|
|
6960
|
+
else if (ts.isPropertyAssignment(node))
|
|
6961
|
+
flow(node.initializer, contextualOrNull(node.initializer));
|
|
6962
|
+
else if (ts.isShorthandPropertyAssignment(node)) {
|
|
6963
|
+
const name = node.name;
|
|
6964
|
+
flow(name, contextualOrNull(name));
|
|
6965
|
+
}
|
|
6966
|
+
else if (ts.isArrayLiteralExpression(node)) {
|
|
6967
|
+
for (const element of node.elements.nodes)
|
|
6968
|
+
if (!ts.isSpreadElement(element) && !ts.isOmittedExpression(element))
|
|
6969
|
+
flow(element, contextualOrNull(element));
|
|
6970
|
+
}
|
|
6971
|
+
else if (ts.isArrowFunction(node) && !ts.isBlock(node.body))
|
|
6972
|
+
flow(node.body, contextualOrNull(node.body));
|
|
6973
|
+
};
|
|
6974
|
+
for (const sf of sourceFiles)
|
|
6975
|
+
ts.walkPreorder(sf, (node) => {
|
|
6976
|
+
// A checker panic hides this conversion: any array.
|
|
5638
6977
|
if (!panicSafe(() => (visit(node), true), false))
|
|
5639
6978
|
keys.add("*");
|
|
5640
6979
|
return undefined;
|
|
5641
6980
|
});
|
|
5642
6981
|
return keys;
|
|
5643
6982
|
};
|
|
6983
|
+
// A receiver typed `any`, `unknown` or an array of either can be a live
|
|
6984
|
+
// view of a native array. A receiver of another type (`Worker[]`,
|
|
6985
|
+
// `Record<string, unknown>`) is one only after a lying assertion, even
|
|
6986
|
+
// when its values are dynamic.
|
|
6987
|
+
const dynamicType = (type) => {
|
|
6988
|
+
if ((type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
6989
|
+
return true;
|
|
6990
|
+
if (!this.checker.isArrayType(type) || this.checker.isTupleType(type))
|
|
6991
|
+
return false;
|
|
6992
|
+
const element = this.checker.getTypeArguments(type)[0];
|
|
6993
|
+
return (element !== undefined && (element.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0);
|
|
6994
|
+
};
|
|
6995
|
+
// A binding that only ever holds the array its declaration creates (a
|
|
6996
|
+
// const variable, or a readonly property with an initializer) is never
|
|
6997
|
+
// a view of a native array, even when its elements are dynamic.
|
|
6998
|
+
const freshDynamicStorage = (node, depth) => {
|
|
6999
|
+
const e = peel(node);
|
|
7000
|
+
if (ts.isArrayLiteralExpression(e))
|
|
7001
|
+
return true;
|
|
7002
|
+
if (ts.isNewExpression(e) || ts.isCallExpression(e)) {
|
|
7003
|
+
const callee = peel(e.expression);
|
|
7004
|
+
if (ts.isIdentifier(callee))
|
|
7005
|
+
return this.isStdlibGlobal(callee, "Array");
|
|
7006
|
+
return (ts.isPropertyAccessExpression(callee) &&
|
|
7007
|
+
(callee.name.text === "of" || callee.name.text === "from") &&
|
|
7008
|
+
this.isStdlibGlobal(callee.expression, "Array"));
|
|
7009
|
+
}
|
|
7010
|
+
if (depth > 4 || (!ts.isIdentifier(e) && !ts.isPropertyAccessExpression(e)))
|
|
7011
|
+
return false;
|
|
7012
|
+
// A typed array along the way is the array a view shows.
|
|
7013
|
+
const type = typeOrNull(e);
|
|
7014
|
+
if (type === null || !dynamicType(type))
|
|
7015
|
+
return false;
|
|
7016
|
+
const symbol = panicSafe(() => this.checker.getSymbolAtLocation(ts.isIdentifier(e) ? e : e.name), undefined);
|
|
7017
|
+
const declaration = symbol?.valueDeclaration;
|
|
7018
|
+
if (!symbol || !declaration)
|
|
7019
|
+
return false;
|
|
7020
|
+
// Variables and class properties only: parameters take any argument,
|
|
7021
|
+
// and object literals fill interface properties.
|
|
7022
|
+
if (!(ts.isVariableDeclaration(declaration) && ts.isIdentifier(declaration.name)) &&
|
|
7023
|
+
!ts.isPropertyDeclaration(declaration))
|
|
7024
|
+
return false;
|
|
7025
|
+
const assigned = assignedValues(symbol);
|
|
7026
|
+
if (assigned === null)
|
|
7027
|
+
return false;
|
|
7028
|
+
const values = [
|
|
7029
|
+
...(declaration.initializer ? [declaration.initializer] : []),
|
|
7030
|
+
...(assigned ?? []),
|
|
7031
|
+
];
|
|
7032
|
+
return values.length > 0 && values.every((value) => freshDynamicStorage(value, depth + 1));
|
|
7033
|
+
};
|
|
7034
|
+
// Every value `=` assigns to each variable or property of the program,
|
|
7035
|
+
// by symbol; null for one also written another way (compound or
|
|
7036
|
+
// destructuring assignment). Built on first use.
|
|
7037
|
+
let assignments = null;
|
|
7038
|
+
const assignedValues = (symbol) => {
|
|
7039
|
+
if (assignments === null) {
|
|
7040
|
+
const found = new Map();
|
|
7041
|
+
const add = (target, value) => {
|
|
7042
|
+
const e = peel(target);
|
|
7043
|
+
if (ts.isArrayLiteralExpression(e) || ts.isObjectLiteralExpression(e)) {
|
|
7044
|
+
// Destructuring: every target is written with a part of the value.
|
|
7045
|
+
ts.forEachChild(e, (child) => {
|
|
7046
|
+
if (ts.isIdentifier(child) || ts.isPropertyAccessExpression(child))
|
|
7047
|
+
add(child, null);
|
|
7048
|
+
else if (ts.isSpreadElement(child))
|
|
7049
|
+
add(child.expression, null);
|
|
7050
|
+
else if (ts.isPropertyAssignment(child))
|
|
7051
|
+
add(child.initializer, null);
|
|
7052
|
+
else if (ts.isShorthandPropertyAssignment(child))
|
|
7053
|
+
add(child.name, null);
|
|
7054
|
+
else if (ts.isBinaryExpression(child))
|
|
7055
|
+
add(child.left, null);
|
|
7056
|
+
return undefined;
|
|
7057
|
+
});
|
|
7058
|
+
return;
|
|
7059
|
+
}
|
|
7060
|
+
const name = ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? e.name : null;
|
|
7061
|
+
const written = name
|
|
7062
|
+
? panicSafe(() => this.checker.getSymbolAtLocation(name), undefined)
|
|
7063
|
+
: undefined;
|
|
7064
|
+
if (!written)
|
|
7065
|
+
return;
|
|
7066
|
+
const list = found.get(written);
|
|
7067
|
+
if (list === null)
|
|
7068
|
+
return;
|
|
7069
|
+
if (value === null)
|
|
7070
|
+
found.set(written, null);
|
|
7071
|
+
else if (list)
|
|
7072
|
+
list.push(value);
|
|
7073
|
+
else
|
|
7074
|
+
found.set(written, [value]);
|
|
7075
|
+
};
|
|
7076
|
+
for (const sf of sourceFiles)
|
|
7077
|
+
ts.walkPreorder(sf, (node) => {
|
|
7078
|
+
if (ts.isBinaryExpression(node)) {
|
|
7079
|
+
const op = node.operatorToken.kind;
|
|
7080
|
+
if (op === ts.SyntaxKind.EqualsToken)
|
|
7081
|
+
add(node.left, node.right);
|
|
7082
|
+
else if (op >= ts.SyntaxKind.FirstAssignment && op <= ts.SyntaxKind.LastAssignment)
|
|
7083
|
+
add(node.left, null);
|
|
7084
|
+
}
|
|
7085
|
+
return undefined;
|
|
7086
|
+
});
|
|
7087
|
+
assignments = found;
|
|
7088
|
+
}
|
|
7089
|
+
return assignments.get(symbol);
|
|
7090
|
+
};
|
|
5644
7091
|
// `t[i]!` on a typed array, stored into an array, keeps an invalid
|
|
5645
7092
|
// index's undefined (assertedReadObservesUndefined): `!` performs no
|
|
5646
7093
|
// runtime check. A read whose consumers treat undefined like NaN stores
|
|
@@ -5659,6 +7106,11 @@ export class Lowerer {
|
|
|
5659
7106
|
!nanCoded.isNumericRead(read));
|
|
5660
7107
|
};
|
|
5661
7108
|
const elementStates = new ArrayElementStates({
|
|
7109
|
+
isDynamicArray: (node) => {
|
|
7110
|
+
const type = typeOrNull(node);
|
|
7111
|
+
return (type === null || dynamicType(type)) && !freshDynamicStorage(node, 0);
|
|
7112
|
+
},
|
|
7113
|
+
nativeViewKeys: collectNativeViews,
|
|
5662
7114
|
elementAdmitsUndefined: (key) => {
|
|
5663
7115
|
siteDependencies?.read(key);
|
|
5664
7116
|
return optionalElementKeys.has(key);
|
|
@@ -5822,6 +7274,14 @@ export class Lowerer {
|
|
|
5822
7274
|
else if (ts.isBinaryExpression(node) &&
|
|
5823
7275
|
node.operatorToken.kind === ts.SyntaxKind.EqualsToken)
|
|
5824
7276
|
values.push(node.right);
|
|
7277
|
+
// A for-of loop reads its iterable's array keys.
|
|
7278
|
+
if (ts.isForOfStatement(node))
|
|
7279
|
+
values.push(node.expression);
|
|
7280
|
+
// A property read in such a slot reads its declared type through
|
|
7281
|
+
// its receiver's (widenedType).
|
|
7282
|
+
const receiver = widenedReceiver(node);
|
|
7283
|
+
if (receiver !== null)
|
|
7284
|
+
values.push(receiver);
|
|
5825
7285
|
});
|
|
5826
7286
|
this.checker.prefetchCollectionTypes(values);
|
|
5827
7287
|
scanSites.set(sf, nodes);
|
|
@@ -6379,7 +7839,8 @@ export class Lowerer {
|
|
|
6379
7839
|
siteBase.set(sf, siteCount);
|
|
6380
7840
|
siteCount += sitesOf(sf).length;
|
|
6381
7841
|
}
|
|
6382
|
-
|
|
7842
|
+
// Each function's returns are one more site, after the files' sites.
|
|
7843
|
+
siteDependencies = new SiteDependencies(siteCount + functionDeclBySymbol.size);
|
|
6383
7844
|
let fullPass = true;
|
|
6384
7845
|
for (let changed = true, first = true; changed || !fullPass; first = false) {
|
|
6385
7846
|
fullPass = first || !changed;
|
|
@@ -6395,8 +7856,15 @@ export class Lowerer {
|
|
|
6395
7856
|
for (const sf of sourceFiles)
|
|
6396
7857
|
if (scanFile(sf))
|
|
6397
7858
|
changed = true;
|
|
7859
|
+
let returnSite = siteCount;
|
|
6398
7860
|
for (const [symbol, decl] of functionDeclBySymbol) {
|
|
6399
|
-
|
|
7861
|
+
const site = returnSite++;
|
|
7862
|
+
if (!fullPass && !siteDependencies.isStale(site))
|
|
7863
|
+
continue;
|
|
7864
|
+
siteDependencies.begin(site);
|
|
7865
|
+
const returnsChanged = scanReturns(symbol, decl);
|
|
7866
|
+
siteDependencies.end(returnsChanged);
|
|
7867
|
+
if (!returnsChanged)
|
|
6400
7868
|
continue;
|
|
6401
7869
|
siteDependencies.changed(symbol);
|
|
6402
7870
|
changed = true;
|
|
@@ -6551,6 +8019,7 @@ export class Lowerer {
|
|
|
6551
8019
|
for (const [loop, present] of presentLoops)
|
|
6552
8020
|
if (present)
|
|
6553
8021
|
this.presentElementLoops.add(loop);
|
|
8022
|
+
this.foreignElementKeys = elementStates.foreignKeys();
|
|
6554
8023
|
const globalsById = new Map(this.globalsList.map((global) => [global.id, global]));
|
|
6555
8024
|
for (const [symbol, field] of staticFieldsBySymbol) {
|
|
6556
8025
|
if (!optionalSymbols.has(symbol))
|
|
@@ -6833,6 +8302,7 @@ export class Lowerer {
|
|
|
6833
8302
|
for (const fp of parts)
|
|
6834
8303
|
this.checker.prefetchSourceFile(fp.sf);
|
|
6835
8304
|
}
|
|
8305
|
+
this.prefetchProgramSymbols(parts);
|
|
6836
8306
|
this.collectProgram(parts);
|
|
6837
8307
|
this.speculativeTypeQueries(() => {
|
|
6838
8308
|
extendAssertedRecordMembers(this, parts.map((fp) => fp.sf));
|
|
@@ -6873,18 +8343,24 @@ export class Lowerer {
|
|
|
6873
8343
|
const fn = this.lowerFunction(decl);
|
|
6874
8344
|
if (fn)
|
|
6875
8345
|
functions.push(fn);
|
|
6876
|
-
else
|
|
6877
|
-
this.
|
|
6878
|
-
if (this.
|
|
6879
|
-
this.
|
|
8346
|
+
else {
|
|
8347
|
+
this.skippedBodies.add(decl);
|
|
8348
|
+
if (this.countsSkips()) {
|
|
8349
|
+
this.countSkippedBody(decl);
|
|
8350
|
+
if (this.remainder)
|
|
8351
|
+
this.reportBlockedBody(decl);
|
|
8352
|
+
}
|
|
6880
8353
|
}
|
|
6881
8354
|
}
|
|
6882
8355
|
for (const decl of fp.classDecls) {
|
|
6883
8356
|
const info = this.classes.get(this.classNamer(decl));
|
|
6884
8357
|
if (info)
|
|
6885
8358
|
functions.push(...this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)));
|
|
6886
|
-
else
|
|
6887
|
-
this.
|
|
8359
|
+
else {
|
|
8360
|
+
this.skippedBodies.add(decl);
|
|
8361
|
+
if (this.countsSkips())
|
|
8362
|
+
this.countSkippedBody(decl);
|
|
8363
|
+
}
|
|
6888
8364
|
}
|
|
6889
8365
|
}
|
|
6890
8366
|
// Each file's top-level statements form its run-once init function.
|
|
@@ -6916,13 +8392,39 @@ export class Lowerer {
|
|
|
6916
8392
|
let gc = 0;
|
|
6917
8393
|
let gi = 0;
|
|
6918
8394
|
let es = 0;
|
|
8395
|
+
let rd = 0;
|
|
6919
8396
|
const classDispatch = new ClassDynamicDispatch();
|
|
6920
8397
|
let dispatchChanged = !this.remainder;
|
|
6921
8398
|
while (dispatchChanged ||
|
|
8399
|
+
rd < this.retriedDeclarations.length ||
|
|
6922
8400
|
ec < this.exprClasses.length ||
|
|
6923
8401
|
gc < this.genericClassInstances.length ||
|
|
6924
8402
|
gi < this.instantiationQueue.length ||
|
|
6925
8403
|
es < this.emitSpecQueue.length) {
|
|
8404
|
+
// Localized failure: declarations a flush registered with dynamic
|
|
8405
|
+
// slots (retryDeferred) after the loops above skipped their bodies.
|
|
8406
|
+
while (rd < this.retriedDeclarations.length) {
|
|
8407
|
+
const decl = this.retriedDeclarations[rd++];
|
|
8408
|
+
if (!this.skippedBodies.delete(decl))
|
|
8409
|
+
continue;
|
|
8410
|
+
if (this.countsSkips())
|
|
8411
|
+
this.uncountSkippedBody(decl);
|
|
8412
|
+
if (ts.isFunctionDeclaration(decl)) {
|
|
8413
|
+
const fn = this.lowerFunction(decl);
|
|
8414
|
+
if (fn)
|
|
8415
|
+
functions.push(fn);
|
|
8416
|
+
else {
|
|
8417
|
+
this.skippedBodies.add(decl);
|
|
8418
|
+
if (this.countsSkips())
|
|
8419
|
+
this.countSkippedBody(decl);
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
else if (ts.isClassDeclaration(decl)) {
|
|
8423
|
+
const info = this.classes.get(this.classNamer(decl));
|
|
8424
|
+
if (info)
|
|
8425
|
+
functions.push(...this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)));
|
|
8426
|
+
}
|
|
8427
|
+
}
|
|
6926
8428
|
while (ec < this.exprClasses.length) {
|
|
6927
8429
|
functions.push(...this.lowerClassMembers(this.exprClasses[ec++]));
|
|
6928
8430
|
}
|
|
@@ -6935,13 +8437,9 @@ export class Lowerer {
|
|
|
6935
8437
|
// generic method's this/super fence, a fenced parameter
|
|
6936
8438
|
// default): the diagnostic is recorded — the instance skips
|
|
6937
8439
|
// like a signature-blocked function (lowerFunction's rule).
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
catch (e) {
|
|
6942
|
-
if (!(e instanceof PoisonError))
|
|
6943
|
-
throw e;
|
|
6944
|
-
}
|
|
8440
|
+
const fn = this.lowerUnitDegrading(() => this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)));
|
|
8441
|
+
if (fn !== null)
|
|
8442
|
+
functions.push(fn);
|
|
6945
8443
|
}
|
|
6946
8444
|
// Emit-override specializations queued by the emit sites above (a
|
|
6947
8445
|
// body can queue more — the super-forward chain — and generic
|
|
@@ -7006,6 +8504,8 @@ export class Lowerer {
|
|
|
7006
8504
|
guardFrozenWrites(this, functions);
|
|
7007
8505
|
applyHandleProperties(this, functions);
|
|
7008
8506
|
installBufferValue(functions);
|
|
8507
|
+
installFetchBodyWebStreams(this, functions);
|
|
8508
|
+
returnDispatchReceivers(this, functions);
|
|
7009
8509
|
// Globals typed by a class that never REGISTERED (a JS class whose
|
|
7010
8510
|
// collection fenced — Symbol-keyed fields, an unsupported base): the
|
|
7011
8511
|
// declaration statement and every use compiled to runtime fences, but
|
|
@@ -7095,6 +8595,8 @@ export class Lowerer {
|
|
|
7095
8595
|
// reference are untouched — byte-stability holds.
|
|
7096
8596
|
checkRequireBindingAccesses(this, functions);
|
|
7097
8597
|
refuseX509DynValues(this, functions);
|
|
8598
|
+
markInferredFactChecks(functions, this.program);
|
|
8599
|
+
const sloppyDynWrites = sloppyDynamicWrites(this, functions);
|
|
7098
8600
|
const module = this.diags.length > 0
|
|
7099
8601
|
? null
|
|
7100
8602
|
: {
|
|
@@ -7108,7 +8610,19 @@ export class Lowerer {
|
|
|
7108
8610
|
entry: ENTRY_NAME,
|
|
7109
8611
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
7110
8612
|
...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
|
|
8613
|
+
...(this.usesNodeIsland ? { nodeIsland: this.nodeIslandRecord() } : {}),
|
|
7111
8614
|
...(this.declBoundary ? { declBoundary: true } : {}),
|
|
8615
|
+
...(shapeOverlayFileNames().length > 0
|
|
8616
|
+
? {
|
|
8617
|
+
inferredFactFiles: shapeOverlayFileNames()
|
|
8618
|
+
.map((file) => ({ file, pkg: npmStaticPackageOfPath(file) ?? "" }))
|
|
8619
|
+
.sort((a, b) => (a.file < b.file ? -1 : a.file > b.file ? 1 : 0)),
|
|
8620
|
+
}
|
|
8621
|
+
: {}),
|
|
8622
|
+
...(this.foreignElementKeys.size > 0
|
|
8623
|
+
? { foreignElementKeys: [...this.foreignElementKeys].sort() }
|
|
8624
|
+
: {}),
|
|
8625
|
+
...(this.declOrigins.length > 0 ? { declOrigins: [...this.declOrigins] } : {}),
|
|
7112
8626
|
...(this.threadSlotKeys.size > 0
|
|
7113
8627
|
? { threadSlotKeys: [...this.threadSlotKeys].sort() }
|
|
7114
8628
|
: {}),
|
|
@@ -7116,11 +8630,14 @@ export class Lowerer {
|
|
|
7116
8630
|
? { freezableArrays: [...this.freezableArrays].sort() }
|
|
7117
8631
|
: {}),
|
|
7118
8632
|
...(this.untypedIntegrity ? { untypedIntegrity: true } : {}),
|
|
8633
|
+
...(sloppyDynWrites.length > 0 ? { sloppyDynWrites } : {}),
|
|
7119
8634
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
7120
8635
|
...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
|
|
7121
8636
|
};
|
|
7122
8637
|
if (module)
|
|
7123
8638
|
sanitizeUnregisteredClassTypes(module, (name) => this.classes.has(name));
|
|
8639
|
+
if (module?.declOrigins !== undefined)
|
|
8640
|
+
compactDeclOrigins(module);
|
|
7124
8641
|
if (module)
|
|
7125
8642
|
checkCycleBindingAccesses(this, module);
|
|
7126
8643
|
if (module)
|
|
@@ -7203,6 +8720,23 @@ export class Lowerer {
|
|
|
7203
8720
|
* percentage would overstate how much of the program compiles. Count
|
|
7204
8721
|
* every statement the body holds as attempted and failed, in addition to
|
|
7205
8722
|
* the skipped-function tally. */
|
|
8723
|
+
/** countSkippedBody undone: a flush registered the declaration after
|
|
8724
|
+
* its body was skipped, and the body lowers now. */
|
|
8725
|
+
uncountSkippedBody(decl) {
|
|
8726
|
+
this.stats.functionsSkipped--;
|
|
8727
|
+
if (this.suppressStats)
|
|
8728
|
+
return;
|
|
8729
|
+
const n = countBodyStatements(decl);
|
|
8730
|
+
if (n === 0)
|
|
8731
|
+
return;
|
|
8732
|
+
this.stats.statementsTotal -= n;
|
|
8733
|
+
this.stats.statementsFailed -= n;
|
|
8734
|
+
const file = ts.getSourceFileOfNode(decl).fileName;
|
|
8735
|
+
for (let i = 0; i < n; i++) {
|
|
8736
|
+
this.bumpFileStat(file, "total", -1);
|
|
8737
|
+
this.bumpFileStat(file, "failed", -1);
|
|
8738
|
+
}
|
|
8739
|
+
}
|
|
7206
8740
|
countSkippedBody(decl) {
|
|
7207
8741
|
this.stats.functionsSkipped++;
|
|
7208
8742
|
if (this.suppressStats)
|
|
@@ -7282,6 +8816,7 @@ export class Lowerer {
|
|
|
7282
8816
|
this.onEdge = (name) => {
|
|
7283
8817
|
collectionEdges.add(name);
|
|
7284
8818
|
};
|
|
8819
|
+
this.prefetchProgramSymbols(parts);
|
|
7285
8820
|
this.collectProgram(parts);
|
|
7286
8821
|
this.speculativeTypeQueries(() => {
|
|
7287
8822
|
extendAssertedRecordMembers(this, parts.map((fp) => fp.sf));
|
|
@@ -7372,6 +8907,20 @@ export class Lowerer {
|
|
|
7372
8907
|
roots: classCtorRoots(info),
|
|
7373
8908
|
lower: () => info.localClass && !info.localClass.ready ? null : this.lowerClassCtor(info),
|
|
7374
8909
|
});
|
|
8910
|
+
// The descriptor helpers of a class that extends Array, reached
|
|
8911
|
+
// from its constructor.
|
|
8912
|
+
if (info.extendsArray) {
|
|
8913
|
+
units.set(`%${cName}.arrayFields`, {
|
|
8914
|
+
order: unitOrder++,
|
|
8915
|
+
roots: [],
|
|
8916
|
+
lower: () => arrayClassFieldsFn(this, info),
|
|
8917
|
+
});
|
|
8918
|
+
units.set(`%${cName}.species`, {
|
|
8919
|
+
order: unitOrder++,
|
|
8920
|
+
roots: [],
|
|
8921
|
+
lower: () => arrayClassSpeciesFn(this, info),
|
|
8922
|
+
});
|
|
8923
|
+
}
|
|
7375
8924
|
for (const { mName, member } of this.classMethodMembers(info)) {
|
|
7376
8925
|
units.set(`%${cName}.${mName}`, {
|
|
7377
8926
|
order: unitOrder++,
|
|
@@ -7478,6 +9027,15 @@ export class Lowerer {
|
|
|
7478
9027
|
for (const [owner, methods] of this.virtualEdges)
|
|
7479
9028
|
for (const method of methods)
|
|
7480
9029
|
this.noteVirtualEdge(owner, method);
|
|
9030
|
+
// An instance's [util.inspect.custom] method runs from the runtime
|
|
9031
|
+
// inspect walk (customInspectRegistrations), which no IR edge shows.
|
|
9032
|
+
for (let c = this.classes.get(name.slice(1, -".constructor".length)) ?? null; c; c = c.base) {
|
|
9033
|
+
const custom = `%${c.def.name}.${INSPECT_CUSTOM_MEMBER}`;
|
|
9034
|
+
if (units.has(custom)) {
|
|
9035
|
+
this.onEdge?.(custom);
|
|
9036
|
+
break;
|
|
9037
|
+
}
|
|
9038
|
+
}
|
|
7481
9039
|
}
|
|
7482
9040
|
};
|
|
7483
9041
|
// Class EXPRESSIONS collect while init bodies lower (below): their
|
|
@@ -7487,11 +9045,16 @@ export class Lowerer {
|
|
|
7487
9045
|
const cName = info.def.name;
|
|
7488
9046
|
const register = (name, roots, lower) => {
|
|
7489
9047
|
units.set(name, { order: unitOrder++, roots, lower });
|
|
9048
|
+
this.unitRegistrations++;
|
|
7490
9049
|
if (reachable.has(name))
|
|
7491
9050
|
queue.push(name);
|
|
7492
9051
|
metadataPriority.set(name, [3, expressionMetadataOrder++]);
|
|
7493
9052
|
};
|
|
7494
9053
|
register(`%${cName}.constructor`, classCtorRoots(info), () => info.localClass && !info.localClass.ready ? null : this.lowerClassCtor(info));
|
|
9054
|
+
if (info.extendsArray) {
|
|
9055
|
+
register(`%${cName}.arrayFields`, [], () => arrayClassFieldsFn(this, info));
|
|
9056
|
+
register(`%${cName}.species`, [], () => arrayClassSpeciesFn(this, info));
|
|
9057
|
+
}
|
|
7495
9058
|
for (const { mName, member } of this.classMethodMembers(info)) {
|
|
7496
9059
|
register(`%${cName}.${mName}`, functionRoots(member), () => info.localClass && !info.localClass.ready
|
|
7497
9060
|
? null
|
|
@@ -7505,6 +9068,55 @@ export class Lowerer {
|
|
|
7505
9068
|
register(`%${cName}.set:${prop}`, [], () => this.throwingSetterFn(info, prop));
|
|
7506
9069
|
}
|
|
7507
9070
|
};
|
|
9071
|
+
// Localized failure: a declaration a flush registered with dynamic
|
|
9072
|
+
// slots (retryDeferred) registers its units like a class expression.
|
|
9073
|
+
this.onDeclarationRegistered = (decl) => {
|
|
9074
|
+
if (ts.isFunctionDeclaration(decl)) {
|
|
9075
|
+
if (!decl.body)
|
|
9076
|
+
return;
|
|
9077
|
+
const symbol = declSymbolOf(this, decl);
|
|
9078
|
+
const sig = symbol ? this.fnSigsBySymbol.get(symbol) : undefined;
|
|
9079
|
+
if (!sig || units.has(sig.name))
|
|
9080
|
+
return;
|
|
9081
|
+
units.set(sig.name, {
|
|
9082
|
+
order: unitOrder++,
|
|
9083
|
+
roots: functionRoots(decl),
|
|
9084
|
+
lower: () => this.lowerFunction(decl),
|
|
9085
|
+
});
|
|
9086
|
+
this.unitRegistrations++;
|
|
9087
|
+
if (reachable.has(sig.name))
|
|
9088
|
+
queue.push(sig.name);
|
|
9089
|
+
metadataPriority.set(sig.name, [3, expressionMetadataOrder++]);
|
|
9090
|
+
}
|
|
9091
|
+
else if (ts.isClassDeclaration(decl)) {
|
|
9092
|
+
const info = this.classes.get(this.classNamer(decl));
|
|
9093
|
+
if (!info)
|
|
9094
|
+
return;
|
|
9095
|
+
if (!info.generic) {
|
|
9096
|
+
if (!units.has(`%${info.def.name}.constructor`))
|
|
9097
|
+
this.onExprClassCollected?.(info);
|
|
9098
|
+
return;
|
|
9099
|
+
}
|
|
9100
|
+
// A generic class FAMILY's only units are its statics; its
|
|
9101
|
+
// instantiations lower in the instance drain.
|
|
9102
|
+
if (!info.staticMethods)
|
|
9103
|
+
return;
|
|
9104
|
+
for (const [name, entry] of info.staticMethods) {
|
|
9105
|
+
const unit = `%${info.def.name}.static:${name}`;
|
|
9106
|
+
if (units.has(unit))
|
|
9107
|
+
continue;
|
|
9108
|
+
units.set(unit, {
|
|
9109
|
+
order: unitOrder++,
|
|
9110
|
+
roots: functionRoots(entry.member),
|
|
9111
|
+
lower: () => lowerStaticMethod(this, info, name),
|
|
9112
|
+
});
|
|
9113
|
+
this.unitRegistrations++;
|
|
9114
|
+
if (reachable.has(unit))
|
|
9115
|
+
queue.push(unit);
|
|
9116
|
+
metadataPriority.set(unit, [3, expressionMetadataOrder++]);
|
|
9117
|
+
}
|
|
9118
|
+
}
|
|
9119
|
+
};
|
|
7508
9120
|
const onEdge = this.onEdge;
|
|
7509
9121
|
for (const name of collectionEdges)
|
|
7510
9122
|
onEdge(name);
|
|
@@ -7549,14 +9161,11 @@ export class Lowerer {
|
|
|
7549
9161
|
this.genericDemandPriority.set(inst, ref);
|
|
7550
9162
|
// Body-level poisons skip the instance after retaining the
|
|
7551
9163
|
// diagnostic and every edge fired before poisoning.
|
|
7552
|
-
|
|
7553
|
-
|
|
9164
|
+
const fn = this.lowerUnitDegrading(() => this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)))));
|
|
9165
|
+
if (fn !== null) {
|
|
9166
|
+
instanceFunctions.push(fn);
|
|
7554
9167
|
relieveHeapPressure();
|
|
7555
9168
|
}
|
|
7556
|
-
catch (e) {
|
|
7557
|
-
if (!(e instanceof PoisonError))
|
|
7558
|
-
throw e;
|
|
7559
|
-
}
|
|
7560
9169
|
}
|
|
7561
9170
|
}
|
|
7562
9171
|
// Emit-override specialization bodies fire edges of their own
|
|
@@ -7615,21 +9224,32 @@ export class Lowerer {
|
|
|
7615
9224
|
for (const root of extraRoots ?? [])
|
|
7616
9225
|
rootEdge?.(root);
|
|
7617
9226
|
const shuffle = lowerShuffle();
|
|
9227
|
+
const lowerUnitBody = (name) => {
|
|
9228
|
+
const unit = units.get(name);
|
|
9229
|
+
const priority = metadataPriority.get(name) ?? [3, expressionMetadataOrder++];
|
|
9230
|
+
const owner = demandOwner(priority);
|
|
9231
|
+
return this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(name, unit.lower)));
|
|
9232
|
+
};
|
|
9233
|
+
const recorded = journalMode() === "serial" ? waveStats() : null;
|
|
9234
|
+
const host = recorded === null ? null : this.waveHost(loweredUnits, lowerUnitBody);
|
|
9235
|
+
const dump = recorded === null ? null : journalDump();
|
|
9236
|
+
const recordLines = [];
|
|
7618
9237
|
const drainUnits = () => {
|
|
7619
9238
|
while (queue.length > 0) {
|
|
7620
9239
|
const wave = queue.splice(0);
|
|
7621
9240
|
shuffle?.(wave);
|
|
7622
9241
|
this.checker.prefetchRoots(wave.flatMap((name) => units.get(name).roots));
|
|
9242
|
+
if (host !== null && recorded !== null) {
|
|
9243
|
+
lowerWaveRecorded(host, wave, recorded, dump === null ? null : recordLines);
|
|
9244
|
+
continue;
|
|
9245
|
+
}
|
|
7623
9246
|
for (const name of wave) {
|
|
7624
9247
|
// A body-level poison outside the per-statement catches (a fenced
|
|
7625
9248
|
// constructor/method parameter default lowered by declareParams):
|
|
7626
9249
|
// every edge fired before poisoning remains retained; the diagnostic
|
|
7627
9250
|
// stays recorded and the member stays omitted.
|
|
7628
9251
|
try {
|
|
7629
|
-
const
|
|
7630
|
-
const priority = metadataPriority.get(name) ?? [3, expressionMetadataOrder++];
|
|
7631
|
-
const owner = demandOwner(priority);
|
|
7632
|
-
const fn = this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(name, unit.lower)));
|
|
9252
|
+
const fn = lowerUnitBody(name);
|
|
7633
9253
|
if (fn)
|
|
7634
9254
|
loweredUnits.set(name, fn);
|
|
7635
9255
|
relieveHeapPressure();
|
|
@@ -7679,6 +9299,10 @@ export class Lowerer {
|
|
|
7679
9299
|
this.restoreGenericClassInstanceOrder(clsInstLowered);
|
|
7680
9300
|
}
|
|
7681
9301
|
classDispatch.finalize(this);
|
|
9302
|
+
if (dump !== null)
|
|
9303
|
+
writeRecords(dump, recordLines);
|
|
9304
|
+
if (recorded !== null && process.env["SCRIPTC_TIMING"] === "1")
|
|
9305
|
+
process.stderr.write(`scriptc lowering ${JSON.stringify({ phase: "unit-records", ...recorded })}\n`);
|
|
7682
9306
|
const orderedUnits = unitsInOrder();
|
|
7683
9307
|
this.settleGenericDemandPriorities();
|
|
7684
9308
|
this.shapes.settleDeclaredOrderPriorities();
|
|
@@ -7726,13 +9350,106 @@ export class Lowerer {
|
|
|
7726
9350
|
this.reachableForArtifacts = reachable;
|
|
7727
9351
|
return { reachable, result: this.finishModule(functions) };
|
|
7728
9352
|
}
|
|
9353
|
+
/** The lowerer's side of a recorded wave (unit-journal.ts).
|
|
9354
|
+
* `lowerUnitBody` lowers a unit as reachable emit does. */
|
|
9355
|
+
waveHost(loweredUnits, lowerUnitBody) {
|
|
9356
|
+
const scalars = this.journalScalars();
|
|
9357
|
+
const flags = new Map(scalars.map((scalar) => [scalar.name, scalar]));
|
|
9358
|
+
let instances = new Map();
|
|
9359
|
+
let indexed = -1;
|
|
9360
|
+
const instanceNamed = (name) => {
|
|
9361
|
+
if (indexed !== this.instantiationQueue.length) {
|
|
9362
|
+
instances = new Map(this.instantiationQueue.map(({ inst }) => [inst.name, inst]));
|
|
9363
|
+
indexed = this.instantiationQueue.length;
|
|
9364
|
+
}
|
|
9365
|
+
return instances.get(name);
|
|
9366
|
+
};
|
|
9367
|
+
const classNamed = (name) => {
|
|
9368
|
+
const info = this.classes.get(name);
|
|
9369
|
+
return info !== undefined && info.def.name === name ? info : undefined;
|
|
9370
|
+
};
|
|
9371
|
+
const files = new Map();
|
|
9372
|
+
const statementNode = (event) => {
|
|
9373
|
+
let sf = files.get(event.name);
|
|
9374
|
+
if (sf === undefined && !files.has(event.name)) {
|
|
9375
|
+
sf = this.program.getSourceFile(event.name);
|
|
9376
|
+
files.set(event.name, sf);
|
|
9377
|
+
}
|
|
9378
|
+
if (sf === undefined)
|
|
9379
|
+
return undefined;
|
|
9380
|
+
try {
|
|
9381
|
+
return sf.file.node(event.index);
|
|
9382
|
+
}
|
|
9383
|
+
catch {
|
|
9384
|
+
return undefined;
|
|
9385
|
+
}
|
|
9386
|
+
};
|
|
9387
|
+
return {
|
|
9388
|
+
tables: this.journalTables(),
|
|
9389
|
+
scalars,
|
|
9390
|
+
lowerRecorded: (name, events) => {
|
|
9391
|
+
this.unitEvents = events;
|
|
9392
|
+
try {
|
|
9393
|
+
const fn = lowerUnitBody(name);
|
|
9394
|
+
relieveHeapPressure();
|
|
9395
|
+
return { fn, poisoned: false };
|
|
9396
|
+
}
|
|
9397
|
+
catch (e) {
|
|
9398
|
+
if (!(e instanceof PoisonError))
|
|
9399
|
+
throw e;
|
|
9400
|
+
return { fn: null, poisoned: true };
|
|
9401
|
+
}
|
|
9402
|
+
finally {
|
|
9403
|
+
this.unitEvents = null;
|
|
9404
|
+
}
|
|
9405
|
+
},
|
|
9406
|
+
store: (name, fn) => {
|
|
9407
|
+
if (fn)
|
|
9408
|
+
loweredUnits.set(name, fn);
|
|
9409
|
+
},
|
|
9410
|
+
statementCounts: () => ({
|
|
9411
|
+
total: this.stats.statementsTotal,
|
|
9412
|
+
failed: this.stats.statementsFailed,
|
|
9413
|
+
other: this.stats.functionsSkipped + this.diags.length,
|
|
9414
|
+
}),
|
|
9415
|
+
resolves: (event) => {
|
|
9416
|
+
switch (event.kind) {
|
|
9417
|
+
case "virtualEdge":
|
|
9418
|
+
case "classDemand":
|
|
9419
|
+
return classNamed(event.name) !== undefined;
|
|
9420
|
+
case "functionDemand":
|
|
9421
|
+
return instanceNamed(event.name) !== undefined;
|
|
9422
|
+
case "statement":
|
|
9423
|
+
case "failedStatement":
|
|
9424
|
+
return statementNode(event) !== undefined;
|
|
9425
|
+
case "flag":
|
|
9426
|
+
return flags.get(event.name)?.set !== undefined;
|
|
9427
|
+
default:
|
|
9428
|
+
return true;
|
|
9429
|
+
}
|
|
9430
|
+
},
|
|
9431
|
+
};
|
|
9432
|
+
}
|
|
7729
9433
|
/** Reachability hook (see emitReachable): fires when lowering resolves a
|
|
7730
9434
|
* reference to a lowerable body. */
|
|
7731
9435
|
noteEdge(name) {
|
|
7732
9436
|
// Called as a plain function: the instance is not its receiver.
|
|
7733
9437
|
const onEdge = this.onEdge;
|
|
7734
|
-
|
|
7735
|
-
|
|
9438
|
+
const events = this.unitEvents;
|
|
9439
|
+
if (events === null) {
|
|
9440
|
+
if (onEdge)
|
|
9441
|
+
onEdge(name);
|
|
9442
|
+
return;
|
|
9443
|
+
}
|
|
9444
|
+
events.record(this.superConstructorEdge ? "superConstructorEdge" : "edge", name);
|
|
9445
|
+
events.depth++;
|
|
9446
|
+
try {
|
|
9447
|
+
if (onEdge)
|
|
9448
|
+
onEdge(name);
|
|
9449
|
+
}
|
|
9450
|
+
finally {
|
|
9451
|
+
events.depth--;
|
|
9452
|
+
}
|
|
7736
9453
|
}
|
|
7737
9454
|
/** A subclass constructor's super() edge: the base constructor runs, but
|
|
7738
9455
|
* no instance of exactly the base class is created. */
|
|
@@ -7753,6 +9470,21 @@ export class Lowerer {
|
|
|
7753
9470
|
noteVirtualEdge(info, method) {
|
|
7754
9471
|
if (!this.onEdge)
|
|
7755
9472
|
return;
|
|
9473
|
+
const events = this.unitEvents;
|
|
9474
|
+
if (events === null) {
|
|
9475
|
+
this.virtualEdgeOf(info, method);
|
|
9476
|
+
return;
|
|
9477
|
+
}
|
|
9478
|
+
events.record("virtualEdge", info.def.name, method);
|
|
9479
|
+
events.depth++;
|
|
9480
|
+
try {
|
|
9481
|
+
this.virtualEdgeOf(info, method);
|
|
9482
|
+
}
|
|
9483
|
+
finally {
|
|
9484
|
+
events.depth--;
|
|
9485
|
+
}
|
|
9486
|
+
}
|
|
9487
|
+
virtualEdgeOf(info, method) {
|
|
7756
9488
|
if (this.constructedClasses) {
|
|
7757
9489
|
const methods = this.virtualEdges.get(info) ?? new Set();
|
|
7758
9490
|
methods.add(method);
|
|
@@ -7871,8 +9603,16 @@ export class Lowerer {
|
|
|
7871
9603
|
this.diagSink.push(d);
|
|
7872
9604
|
return;
|
|
7873
9605
|
}
|
|
7874
|
-
|
|
9606
|
+
// A probe's copy of a declaration's flushed diagnostics, committed
|
|
9607
|
+
// after a flush retry registered the declaration: nothing to report.
|
|
9608
|
+
if (pending && this.retriedSymbols.has(pending.symbol))
|
|
9609
|
+
return;
|
|
9610
|
+
if (pending) {
|
|
7875
9611
|
this.commitFlush(pending.symbol, pending.source);
|
|
9612
|
+
const group = this.rejectedGroups.get(pending.symbol);
|
|
9613
|
+
if (group !== undefined)
|
|
9614
|
+
d.rejects ??= group;
|
|
9615
|
+
}
|
|
7876
9616
|
// One site, one report: some declarations map a type twice (module
|
|
7877
9617
|
// globals pre-register before their initializers lower) — an exact
|
|
7878
9618
|
// duplicate (code + span + message) adds noise, not information.
|
|
@@ -7885,6 +9625,19 @@ export class Lowerer {
|
|
|
7885
9625
|
}
|
|
7886
9626
|
this.diags.push(d);
|
|
7887
9627
|
}
|
|
9628
|
+
/** The module's Node island record: the collected module tree, with each
|
|
9629
|
+
* call's caller literal and each load's path literal set to its path in
|
|
9630
|
+
* that tree. The executable build fills in the libnode pack (index.ts). */
|
|
9631
|
+
nodeIslandRecord() {
|
|
9632
|
+
const modules = this.nodeIslandModules.tree();
|
|
9633
|
+
for (const { literal, caller } of this.nodeIslandCallers)
|
|
9634
|
+
literal.value = NodeIslandModuleCollector.callerPath(modules, caller);
|
|
9635
|
+
for (const { literal, caller, target } of this.nodeIslandSpecifiers)
|
|
9636
|
+
literal.value = NodeIslandModuleCollector.relativeSpecifier(caller, target);
|
|
9637
|
+
for (const { literal, path } of this.nodeIslandLoads)
|
|
9638
|
+
literal.value = NodeIslandModuleCollector.loadPath(modules, path);
|
|
9639
|
+
return { libnode: "", nodeVersion: "", ...(modules === null ? {} : { modules }) };
|
|
9640
|
+
}
|
|
7888
9641
|
unsupported(code, node, featureOverride, hintOverride, reason) {
|
|
7889
9642
|
const diag = unsupportedDiag(code, locOf(node), featureOverride, hintOverride);
|
|
7890
9643
|
if (reason !== undefined)
|
|
@@ -7907,6 +9660,315 @@ export class Lowerer {
|
|
|
7907
9660
|
anyOrigin(node) {
|
|
7908
9661
|
return (this.typeOf(node).flags & ts.TypeFlags.Any) !== 0;
|
|
7909
9662
|
}
|
|
9663
|
+
/** badType's commit: the diagnostic carries the structured type
|
|
9664
|
+
* failure (report-only in stage L0), and so does the poison. */
|
|
9665
|
+
typeFail(node, type, family, diag) {
|
|
9666
|
+
const failure = typeFailureOf(node, this.checker.typeToString(type), family);
|
|
9667
|
+
diag.typeFailure = failure;
|
|
9668
|
+
this.failedTypes.set(failure, type);
|
|
9669
|
+
this.pushDiag(diag);
|
|
9670
|
+
throw new PoisonError(failure, type);
|
|
9671
|
+
}
|
|
9672
|
+
/** Localized failure's commit point (design §3.3): `e` poisoned a unit
|
|
9673
|
+
* whose failure is about to enter the build. When it is a degradable type
|
|
9674
|
+
* failure at a slot kind in `slots`, the failing type joins
|
|
9675
|
+
* degradedTypes (its lenient mapping is the checked dynamic, whole slot),
|
|
9676
|
+
* the failure's own diagnostic leaves the build, and the caller lowers
|
|
9677
|
+
* the unit again. Returns the slot to record once that retry succeeds,
|
|
9678
|
+
* or null to commit as today. Never inside a capture buffer (a probe or a
|
|
9679
|
+
* deferred collection) and never under --tier=static-only. */
|
|
9680
|
+
degradeAtCommit(e, slots) {
|
|
9681
|
+
if (this.tierMode !== "auto" || this.diagSink !== null)
|
|
9682
|
+
return null;
|
|
9683
|
+
if (!(e instanceof PoisonError))
|
|
9684
|
+
return null;
|
|
9685
|
+
const failure = e.failure;
|
|
9686
|
+
const type = e.failedType;
|
|
9687
|
+
if (failure === undefined || type === undefined)
|
|
9688
|
+
return null;
|
|
9689
|
+
if (!failure.degradable || failure.family === "dyn-field-policy")
|
|
9690
|
+
return null;
|
|
9691
|
+
if (!slots.has(failure.slot))
|
|
9692
|
+
return null;
|
|
9693
|
+
const id = type.id;
|
|
9694
|
+
// Already degraded to the whole-slot dynamic and still failing: no
|
|
9695
|
+
// progress, commit as today.
|
|
9696
|
+
if (id === undefined || this.degradedTypes.get(id)?.lenient?.kind === "dyn")
|
|
9697
|
+
return null;
|
|
9698
|
+
let committed;
|
|
9699
|
+
for (let i = this.diags.length - 1; i >= 0; i--) {
|
|
9700
|
+
if (this.diags[i].typeFailure !== failure)
|
|
9701
|
+
continue;
|
|
9702
|
+
committed = this.diags[i];
|
|
9703
|
+
this.diags.splice(i, 1);
|
|
9704
|
+
}
|
|
9705
|
+
if (committed === undefined)
|
|
9706
|
+
return null;
|
|
9707
|
+
this.degradeType(type, committed.code, committed.message);
|
|
9708
|
+
const canonical = this.isCanonicalDegraded(id);
|
|
9709
|
+
const partial = this.degradedTypes.get(id)?.lenient?.kind !== "dyn";
|
|
9710
|
+
return {
|
|
9711
|
+
...(canonical ? { canonical: true } : {}),
|
|
9712
|
+
...(partial ? { partial: true } : {}),
|
|
9713
|
+
loc: committed.loc,
|
|
9714
|
+
failure,
|
|
9715
|
+
code: committed.code,
|
|
9716
|
+
reason: committed.message,
|
|
9717
|
+
};
|
|
9718
|
+
}
|
|
9719
|
+
/** A declaration slot whose type maps through degradedTypes is a
|
|
9720
|
+
* dynamic slot too, though only the first such slot failed: record it
|
|
9721
|
+
* (outside probes; the lookup is skipped while nothing is degraded). */
|
|
9722
|
+
noteDegradedSlot(node, type) {
|
|
9723
|
+
if (this.diagSink !== null)
|
|
9724
|
+
return;
|
|
9725
|
+
const degraded = this.degradedTypes.get(type.id ?? -1);
|
|
9726
|
+
// A pushed-down type is one slot, reported where it degraded; only
|
|
9727
|
+
// whole-slot dynamic declarations are reported one by one.
|
|
9728
|
+
if (degraded === undefined || degraded.lenient?.kind !== "dyn")
|
|
9729
|
+
return;
|
|
9730
|
+
const failure = typeFailureOf(node, this.checker.typeToString(type), "unsupported");
|
|
9731
|
+
if (failure.slot === "expression" || failure.slot === "member")
|
|
9732
|
+
return;
|
|
9733
|
+
this.noteDynamicSlot({
|
|
9734
|
+
loc: locOf(node),
|
|
9735
|
+
failure,
|
|
9736
|
+
code: degraded.code,
|
|
9737
|
+
reason: degraded.reason,
|
|
9738
|
+
});
|
|
9739
|
+
}
|
|
9740
|
+
/** Localized failure, statement commit point for declarations a probe
|
|
9741
|
+
* flushed: a statement committing the flushed diagnostics of a deferred
|
|
9742
|
+
* declaration (inside a capture buffer the flush could not retry) reopens
|
|
9743
|
+
* it here, outside every probe. When the declaration's diagnostics are
|
|
9744
|
+
* all retriable, they leave the build, the declaration retries
|
|
9745
|
+
* (retryDeferred), and on success the caller lowers the statement again.
|
|
9746
|
+
* Returns whether some declaration registered. */
|
|
9747
|
+
reopenFlushedAtCommit(diagsBefore) {
|
|
9748
|
+
if (this.tierMode !== "auto" || this.diagSink !== null)
|
|
9749
|
+
return false;
|
|
9750
|
+
const groups = new Set();
|
|
9751
|
+
for (let i = diagsBefore; i < this.diags.length; i++) {
|
|
9752
|
+
const group = this.diags[i].rejects;
|
|
9753
|
+
if (group !== undefined && !group.startsWith("statement @"))
|
|
9754
|
+
groups.add(group);
|
|
9755
|
+
}
|
|
9756
|
+
if (groups.size === 0)
|
|
9757
|
+
return false;
|
|
9758
|
+
let registered = false;
|
|
9759
|
+
for (const [symbol, group] of [...this.rejectedGroups]) {
|
|
9760
|
+
if (!groups.has(group) || !this.deferredCollectors.has(symbol))
|
|
9761
|
+
continue;
|
|
9762
|
+
const committed = this.diags.filter((d) => d.rejects === group);
|
|
9763
|
+
this.diags.splice(0, this.diags.length, ...this.diags.filter((d) => d.rejects !== group));
|
|
9764
|
+
this.flushedSymbols.delete(symbol);
|
|
9765
|
+
this.rejectedGroups.delete(symbol);
|
|
9766
|
+
if (this.retryDeferred(symbol, committed)) {
|
|
9767
|
+
registered = true;
|
|
9768
|
+
continue;
|
|
9769
|
+
}
|
|
9770
|
+
// Not retriable: the declaration's diagnostics commit as before.
|
|
9771
|
+
const last = this.deferredDiags.get(symbol) ?? committed;
|
|
9772
|
+
this.deferredDiags.delete(symbol);
|
|
9773
|
+
this.flushedSymbols.add(symbol);
|
|
9774
|
+
this.noteRejected(symbol, last);
|
|
9775
|
+
for (const d of last)
|
|
9776
|
+
this.pushDiag(d);
|
|
9777
|
+
}
|
|
9778
|
+
return registered;
|
|
9779
|
+
}
|
|
9780
|
+
/** A failed attempt's own diagnostics leave the build before its unit
|
|
9781
|
+
* lowers again; flushed declaration diagnostics (`rejects`) stay, since
|
|
9782
|
+
* the retry will not flush them a second time. */
|
|
9783
|
+
dropAttemptDiags(diagsBefore) {
|
|
9784
|
+
const kept = this.diags
|
|
9785
|
+
.slice(diagsBefore)
|
|
9786
|
+
.filter((d) => d.rejects !== undefined || this.loweredOnceDiags.has(d));
|
|
9787
|
+
this.diags.length = diagsBefore;
|
|
9788
|
+
this.diags.push(...kept);
|
|
9789
|
+
}
|
|
9790
|
+
/** A unit that still fails after its retries commits its first
|
|
9791
|
+
* attempt's own diagnostics (`first`, taken before the first
|
|
9792
|
+
* degradation) in place of the last attempt's. The diagnostics the
|
|
9793
|
+
* retries carry (dropAttemptDiags) stay as they are now: a declaration
|
|
9794
|
+
* reopened since may have registered. */
|
|
9795
|
+
restoreFirstAttemptDiags(diagsBefore, first) {
|
|
9796
|
+
const carried = (d) => d.rejects !== undefined || this.loweredOnceDiags.has(d);
|
|
9797
|
+
const kept = this.diags.slice(diagsBefore).filter(carried);
|
|
9798
|
+
this.diags.length = diagsBefore;
|
|
9799
|
+
this.diags.push(...first.filter((d) => !carried(d)), ...kept);
|
|
9800
|
+
}
|
|
9801
|
+
/** Lowers one unit whose body-level poison skips it (a generic
|
|
9802
|
+
* instance), with localized failure's commit point: a degradable type
|
|
9803
|
+
* failure at one of its declaration slots degrades the type and the unit
|
|
9804
|
+
* lowers again (at most MAX_DECLARATION_RETRIES times). Null when it
|
|
9805
|
+
* still poisons; its diagnostics are then committed as before. */
|
|
9806
|
+
lowerUnitDegrading(lower) {
|
|
9807
|
+
const slots = [];
|
|
9808
|
+
for (let attempt = 0;; attempt++) {
|
|
9809
|
+
const mark = this.diags.length;
|
|
9810
|
+
const hits = new Set();
|
|
9811
|
+
try {
|
|
9812
|
+
const result = this.withPartialHits(hits, lower);
|
|
9813
|
+
for (const slot of slots)
|
|
9814
|
+
this.noteDynamicSlot(slot);
|
|
9815
|
+
return result;
|
|
9816
|
+
}
|
|
9817
|
+
catch (e) {
|
|
9818
|
+
if (!(e instanceof PoisonError))
|
|
9819
|
+
throw e;
|
|
9820
|
+
if (attempt >= MAX_DECLARATION_RETRIES)
|
|
9821
|
+
return null;
|
|
9822
|
+
const slot = this.degradeAtCommit(e, DECLARATION_SLOTS);
|
|
9823
|
+
if (slot === null && !this.widenPartials(hits))
|
|
9824
|
+
return null;
|
|
9825
|
+
if (slot !== null)
|
|
9826
|
+
slots.push(slot);
|
|
9827
|
+
this.dropAttemptDiags(mark);
|
|
9828
|
+
}
|
|
9829
|
+
}
|
|
9830
|
+
}
|
|
9831
|
+
/** Localized failure's lenient mapping (stage L3, push-down): the type
|
|
9832
|
+
* mapped with each failing component as the checked dynamic, so a record
|
|
9833
|
+
* keeps its static members, an array of records its records, and a
|
|
9834
|
+
* function its arity. The whole slot is the checked dynamic when even
|
|
9835
|
+
* that shape does not map. Throwaway context: nothing memoizes. */
|
|
9836
|
+
lenientType(type) {
|
|
9837
|
+
const { typeMemo: _strictMemo, ...strict } = this.typeCtx;
|
|
9838
|
+
const owner = this.checker.typeToString(type);
|
|
9839
|
+
const mapped = mapType(type, {
|
|
9840
|
+
...strict,
|
|
9841
|
+
lenient: true,
|
|
9842
|
+
canMemoizeType: () => false,
|
|
9843
|
+
onLenientPiece: (piece) => {
|
|
9844
|
+
const id = piece.id;
|
|
9845
|
+
if (id !== undefined && !this.lenientPieces.has(id))
|
|
9846
|
+
this.lenientPieces.set(id, owner);
|
|
9847
|
+
},
|
|
9848
|
+
});
|
|
9849
|
+
return mapped === null || mapped.kind === "void" ? DYN : mapped;
|
|
9850
|
+
}
|
|
9851
|
+
/** Degrades a type for a commit point: its lenient (pushed-down) form
|
|
9852
|
+
* first; a type already degraded that still fails falls back to the
|
|
9853
|
+
* whole-slot checked dynamic. False when nothing is left to degrade. */
|
|
9854
|
+
degradeType(type, code, reason) {
|
|
9855
|
+
const id = type.id;
|
|
9856
|
+
if (id === undefined)
|
|
9857
|
+
return false;
|
|
9858
|
+
const known = this.degradedTypes.get(id);
|
|
9859
|
+
if (known !== undefined) {
|
|
9860
|
+
if (known.lenient?.kind === "dyn")
|
|
9861
|
+
return false;
|
|
9862
|
+
this.degradedTypes.set(id, { lenient: DYN, code, reason });
|
|
9863
|
+
return true;
|
|
9864
|
+
}
|
|
9865
|
+
// Canonical normalization (stage N2): a type the per-form rules miss
|
|
9866
|
+
// maps exactly from its canonical form when that form maps; no dynamic
|
|
9867
|
+
// slot then. Otherwise the lenient (pushed-down) form.
|
|
9868
|
+
const canonical = this.canonicalType(type);
|
|
9869
|
+
if (canonical !== null) {
|
|
9870
|
+
this.degradedTypes.set(id, { lenient: canonical, code, reason, canonical: true });
|
|
9871
|
+
return true;
|
|
9872
|
+
}
|
|
9873
|
+
this.degradedTypes.set(id, {
|
|
9874
|
+
lenient: this.wholeSlotDegradation ? DYN : this.lenientType(type),
|
|
9875
|
+
code,
|
|
9876
|
+
reason,
|
|
9877
|
+
});
|
|
9878
|
+
return true;
|
|
9879
|
+
}
|
|
9880
|
+
/** The IR type of a type's canonical form (canon-map.ts), or null when
|
|
9881
|
+
* the form is irreducible, unbound, only the checked dynamic, or holds a
|
|
9882
|
+
* union that mapped to the checked dynamic (such a slot is dynamic in
|
|
9883
|
+
* part, so it degrades like any other). Runs only at localized failure's
|
|
9884
|
+
* commit points, so a program that compiles today never consults it. */
|
|
9885
|
+
canonicalType(type) {
|
|
9886
|
+
try {
|
|
9887
|
+
const resolve = this.typeCtx.resolveTypeParamTs;
|
|
9888
|
+
const c = new Normalizer(this.checker).canon(type, resolve ? (t) => resolve(t) : new Map());
|
|
9889
|
+
if (c.k === "opaque" || c.k === "param")
|
|
9890
|
+
return null;
|
|
9891
|
+
const { typeMemo: _strictMemo, ...strict } = this.typeCtx;
|
|
9892
|
+
const notes = { collapsedToDynamic: false };
|
|
9893
|
+
const mapped = mapCanonical(c, { ...strict, canMemoizeType: () => false }, 0, notes);
|
|
9894
|
+
if (notes.collapsedToDynamic)
|
|
9895
|
+
return null;
|
|
9896
|
+
return mapped === null || mapped.kind === "void" || mapped.kind === "dyn" ? null : mapped;
|
|
9897
|
+
}
|
|
9898
|
+
catch {
|
|
9899
|
+
return null;
|
|
9900
|
+
}
|
|
9901
|
+
}
|
|
9902
|
+
/** The degraded type of `id` maps exactly (canonical form): its slots
|
|
9903
|
+
* are static, not dynamic. */
|
|
9904
|
+
isCanonicalDegraded(id) {
|
|
9905
|
+
return this.degradedTypes.get(id)?.canonical === true;
|
|
9906
|
+
}
|
|
9907
|
+
/** Some degraded type kept a pushed-down (partial) shape, or one was
|
|
9908
|
+
* mapped before a retry widened it: the IR lowered before the retry keeps
|
|
9909
|
+
* that shape. */
|
|
9910
|
+
hasPartialDegradedTypes() {
|
|
9911
|
+
if (this.partialDegradedTypesMapped)
|
|
9912
|
+
return true;
|
|
9913
|
+
for (const degraded of this.degradedTypes.values())
|
|
9914
|
+
if (degraded.canonical !== true &&
|
|
9915
|
+
degraded.lenient !== null &&
|
|
9916
|
+
degraded.lenient.kind !== "dyn")
|
|
9917
|
+
return true;
|
|
9918
|
+
return false;
|
|
9919
|
+
}
|
|
9920
|
+
/** Runs a unit a commit point may retry, recording the pushed-down
|
|
9921
|
+
* types it maps; the frame's hits also count for the enclosing unit. */
|
|
9922
|
+
withPartialHits(hits, run) {
|
|
9923
|
+
this.partialHits.push(hits);
|
|
9924
|
+
try {
|
|
9925
|
+
return run();
|
|
9926
|
+
}
|
|
9927
|
+
finally {
|
|
9928
|
+
this.partialHits.pop();
|
|
9929
|
+
const outer = this.partialHits[this.partialHits.length - 1];
|
|
9930
|
+
if (outer !== undefined)
|
|
9931
|
+
for (const id of hits)
|
|
9932
|
+
outer.add(id);
|
|
9933
|
+
}
|
|
9934
|
+
}
|
|
9935
|
+
/** Push-down is a refinement, never a new failure: a unit that still
|
|
9936
|
+
* fails after mapping pushed-down types falls back to the whole-slot
|
|
9937
|
+
* checked dynamic for them. True when some type widened (retry). */
|
|
9938
|
+
widenPartials(hits) {
|
|
9939
|
+
if (this.tierMode !== "auto" || this.diagSink !== null)
|
|
9940
|
+
return false;
|
|
9941
|
+
let widened = false;
|
|
9942
|
+
for (const id of hits) {
|
|
9943
|
+
const degraded = this.degradedTypes.get(id);
|
|
9944
|
+
if (degraded === undefined || degraded.lenient?.kind === "dyn")
|
|
9945
|
+
continue;
|
|
9946
|
+
degraded.lenient = DYN;
|
|
9947
|
+
widened = true;
|
|
9948
|
+
}
|
|
9949
|
+
return widened;
|
|
9950
|
+
}
|
|
9951
|
+
/** Records a dynamic slot whose unit lowered with it (one per site). */
|
|
9952
|
+
noteDynamicSlot(slot) {
|
|
9953
|
+
if (slot.canonical === true)
|
|
9954
|
+
return;
|
|
9955
|
+
const seen = this.dynamicSlots.some((s) => s.loc.file === slot.loc.file &&
|
|
9956
|
+
s.loc.start === slot.loc.start &&
|
|
9957
|
+
s.loc.end === slot.loc.end);
|
|
9958
|
+
if (!seen)
|
|
9959
|
+
this.dynamicSlots.push(slot);
|
|
9960
|
+
}
|
|
9961
|
+
/** The SC1090 refusal of checked-dynamic class fields in TypeScript
|
|
9962
|
+
* (classFieldStoresDyn): a policy fence, not a missing representation.
|
|
9963
|
+
* A flush retry lifts it (liftDynFieldPolicy), so a reached class with
|
|
9964
|
+
* an 'any' field registers. */
|
|
9965
|
+
dynFieldPolicyFence(node, feature) {
|
|
9966
|
+
const diag = unsupportedDiag("SC1090", locOf(node), feature);
|
|
9967
|
+
const failure = typeFailureOf(node, this.checker.typeToString(this.typeOf(node)), "dyn-field-policy");
|
|
9968
|
+
diag.typeFailure = failure;
|
|
9969
|
+
this.pushDiag(diag);
|
|
9970
|
+
throw new PoisonError(failure, this.typeOf(node));
|
|
9971
|
+
}
|
|
7910
9972
|
badType(node, type) {
|
|
7911
9973
|
const widened = this.checker.getBaseTypeOfLiteralType(type);
|
|
7912
9974
|
// Types declared by the ADOPTED @types/node (Buffer, NodeJS.Timeout,
|
|
@@ -7918,8 +9980,7 @@ export class Lowerer {
|
|
|
7918
9980
|
// applies to node-typed values.
|
|
7919
9981
|
const typeSym = widened.getAliasSymbol() ?? widened.getSymbol();
|
|
7920
9982
|
if (this.nodeTypesOnlySymbol(typeSym)) {
|
|
7921
|
-
this.
|
|
7922
|
-
throw new PoisonError();
|
|
9983
|
+
this.typeFail(node, type, "node-types", noLoweringDiag(this.checker.typeToString(type), locOf(node), undefined, true));
|
|
7923
9984
|
}
|
|
7924
9985
|
// Engine-backed ambient TYPES in a STATIC build report the per-site
|
|
7925
9986
|
// SC2012 rather than the generic supported-types recitation. Native
|
|
@@ -7928,8 +9989,7 @@ export class Lowerer {
|
|
|
7928
9989
|
if (typeSym &&
|
|
7929
9990
|
FETCH_AMBIENT_TYPES.includes(ts.symbolName(typeSym)) &&
|
|
7930
9991
|
this.isStdlibSymbol(typeSym)) {
|
|
7931
|
-
this.
|
|
7932
|
-
throw new PoisonError();
|
|
9992
|
+
this.typeFail(node, type, "fetch-ambient", unsupportedNativeApiDiag(`a value of type '${ts.symbolName(typeSym)}'`, locOf(node)));
|
|
7933
9993
|
}
|
|
7934
9994
|
// ENUM OBJECTS (`typeof e` — a numeric enum's type carries the
|
|
7935
9995
|
// reverse-map index signature, a string enum's just its members):
|
|
@@ -7938,8 +9998,7 @@ export class Lowerer {
|
|
|
7938
9998
|
// as the per-site identifier fence — never the index-signature
|
|
7939
9999
|
// recitation.
|
|
7940
10000
|
if (typeSym && (typeSym.flags & ts.SymbolFlags.Enum) !== 0) {
|
|
7941
|
-
this.
|
|
7942
|
-
throw new PoisonError();
|
|
10001
|
+
this.typeFail(node, type, "enum-object", unsupportedDiag("SC1090", locOf(node), `enum objects as values ('${ts.symbolName(typeSym)}' — member reads like '${ts.symbolName(typeSym)}.X' compile to constants; the object itself has no runtime representation)`));
|
|
7943
10002
|
}
|
|
7944
10003
|
// Would-be records with INDEX SIGNATURES (`Record<string, T>`,
|
|
7945
10004
|
// `{ [k: string]: T }`) get the index-signature fence (SC2006) naming
|
|
@@ -7962,18 +10021,15 @@ export class Lowerer {
|
|
|
7962
10021
|
if (ownSym &&
|
|
7963
10022
|
ownSym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
7964
10023
|
this.isStdlibFile(ts.getSourceFileOfNode(d)))) {
|
|
7965
|
-
this.
|
|
7966
|
-
throw new PoisonError();
|
|
10024
|
+
this.typeFail(node, type, "stdlib-index", noLoweringDiag(this.checker.typeToString(type), locOf(node)));
|
|
7967
10025
|
}
|
|
7968
|
-
this.
|
|
7969
|
-
throw new PoisonError();
|
|
10026
|
+
this.typeFail(node, type, "index-signature", indexSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
7970
10027
|
}
|
|
7971
10028
|
// Attribute an unsupported package type to its package.
|
|
7972
10029
|
{
|
|
7973
10030
|
const pkg = this.npmPackageOf(widened);
|
|
7974
10031
|
if (pkg) {
|
|
7975
|
-
this.
|
|
7976
|
-
throw new PoisonError();
|
|
10032
|
+
this.typeFail(node, type, "package", unsupportedPackageValueDiag(pkg, locOf(node)));
|
|
7977
10033
|
}
|
|
7978
10034
|
}
|
|
7979
10035
|
// A type that keeps a GENERIC call signature (`<T>(x: T) => T` slots,
|
|
@@ -7985,8 +10041,7 @@ export class Lowerer {
|
|
|
7985
10041
|
{
|
|
7986
10042
|
const parts = widened.isUnionType() ? ts.constituentTypes(widened) : [widened];
|
|
7987
10043
|
if (parts.some((p) => this.checker.getCallSignatures(p).some((s) => s.getTypeParameters().length > 0))) {
|
|
7988
|
-
this.
|
|
7989
|
-
throw new PoisonError();
|
|
10044
|
+
this.typeFail(node, type, "generic-signature", genericSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
7990
10045
|
}
|
|
7991
10046
|
}
|
|
7992
10047
|
// STANDARD-LIBRARY nominal provenance, decided once: interface/class
|
|
@@ -8002,16 +10057,14 @@ export class Lowerer {
|
|
|
8002
10057
|
// generic overload set keeps the monomorphization story: a value of a
|
|
8003
10058
|
// multi-signature type has no single compiled signature to hold.
|
|
8004
10059
|
if (!stdlibNominal && this.checker.getCallSignatures(widened).length > 1) {
|
|
8005
|
-
this.
|
|
8006
|
-
throw new PoisonError();
|
|
10060
|
+
this.typeFail(node, type, "overloads", overloadedSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
8007
10061
|
}
|
|
8008
10062
|
// INTERSECTIONS that resolved to no lowering (SC2008). The ones that
|
|
8009
10063
|
// compile never get here: member intersections intern through the
|
|
8010
10064
|
// record path, callable hybrids map to '%call' records, and pinned
|
|
8011
10065
|
// mixin instantiations resolve by chain structure.
|
|
8012
10066
|
if (widened.isIntersectionType()) {
|
|
8013
|
-
this.
|
|
8014
|
-
throw new PoisonError();
|
|
10067
|
+
this.typeFail(node, type, "intersection", intersectionTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
8015
10068
|
}
|
|
8016
10069
|
// SUPPORTED shapes over a component outside its slot (SC2009): the
|
|
8017
10070
|
// Map/Set domains, array/tuple elements, union arms, function
|
|
@@ -8023,8 +10076,7 @@ export class Lowerer {
|
|
|
8023
10076
|
{
|
|
8024
10077
|
const detail = describeComponentBlocker(widened, this.typeCtx);
|
|
8025
10078
|
if (detail !== null) {
|
|
8026
|
-
this.
|
|
8027
|
-
throw new PoisonError();
|
|
10079
|
+
this.typeFail(node, type, "component", componentTypeDiag(this.checker.typeToString(type), detail, locOf(node)));
|
|
8028
10080
|
}
|
|
8029
10081
|
}
|
|
8030
10082
|
// STANDARD-LIBRARY nominal types with no lowering at all: the SC2020
|
|
@@ -8049,20 +10101,17 @@ export class Lowerer {
|
|
|
8049
10101
|
TextEncoder: "TextEncoder instances support encode(string) and encode(); other codec operations require a dedicated lowering",
|
|
8050
10102
|
TextDecoder: "TextDecoder instances support recognized labels, fatal/ignoreBOM option literals, and streaming UTF-8/UTF-16/single-byte decode; runtime option objects remain unsupported",
|
|
8051
10103
|
};
|
|
8052
|
-
this.
|
|
8053
|
-
throw new PoisonError();
|
|
10104
|
+
this.typeFail(node, type, "stdlib-nominal", noLoweringDiag(this.checker.typeToString(type), locOf(node), typeHints[ts.symbolNameOf(stdlibOwnSym) ?? ""]));
|
|
8054
10105
|
}
|
|
8055
10106
|
// USER record shapes blocked by ONE member (SC2009's record arm):
|
|
8056
10107
|
// name the member and its type.
|
|
8057
10108
|
{
|
|
8058
10109
|
const detail = describeRecordMemberBlocker(widened, this.typeCtx);
|
|
8059
10110
|
if (detail !== null) {
|
|
8060
|
-
this.
|
|
8061
|
-
throw new PoisonError();
|
|
10111
|
+
this.typeFail(node, type, "record-member", componentTypeDiag(this.checker.typeToString(type), detail, locOf(node)));
|
|
8062
10112
|
}
|
|
8063
10113
|
}
|
|
8064
|
-
this.
|
|
8065
|
-
throw new PoisonError();
|
|
10114
|
+
this.typeFail(node, type, "unsupported", unsupportedTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
8066
10115
|
}
|
|
8067
10116
|
/** The lib fence (SC2020): a reached use of standard-library surface
|
|
8068
10117
|
* nothing lowers. Poisons the statement like every other rejection.
|
|
@@ -8075,6 +10124,19 @@ export class Lowerer {
|
|
|
8075
10124
|
this.pushDiag(diag);
|
|
8076
10125
|
throw new PoisonError();
|
|
8077
10126
|
}
|
|
10127
|
+
/** The declaration-side refusal of a stdlib-global snapshot read as a
|
|
10128
|
+
* VALUE (stdlibGlobalAliasDecl): report once, at the declaration's name,
|
|
10129
|
+
* naming the type the program asked the compiler to hold when it has a
|
|
10130
|
+
* short spelling. */
|
|
10131
|
+
reportStdlibSnapshot(symbol) {
|
|
10132
|
+
const decl = this.stdlibGlobalAliasDecls.get(symbol);
|
|
10133
|
+
if (decl === undefined || this.stdlibSnapshotReported.has(symbol))
|
|
10134
|
+
return;
|
|
10135
|
+
this.stdlibSnapshotReported.add(symbol);
|
|
10136
|
+
const raw = panicSafe(() => this.checker.typeToString(this.checker.getTypeOfSymbol(symbol)), "");
|
|
10137
|
+
const typeText = raw !== "" && raw.length <= 48 ? raw : undefined;
|
|
10138
|
+
this.pushDiag(stdlibSnapshotValueUseDiag(decl.name.text, decl.alias, typeText, locOf(decl.name)));
|
|
10139
|
+
}
|
|
8078
10140
|
stdlibMemberFence(access) {
|
|
8079
10141
|
return stdlibMemberFence(this, access);
|
|
8080
10142
|
}
|
|
@@ -8429,6 +10491,50 @@ export class Lowerer {
|
|
|
8429
10491
|
const sym = t.getSymbol();
|
|
8430
10492
|
return (sym && this.typeParamTsBindings.get(sym)) ?? null;
|
|
8431
10493
|
};
|
|
10494
|
+
/** The concrete instantiation of a generic alias reference (`Catalog<G,
|
|
10495
|
+
* P>`) the current call-keyed instance's signature declares
|
|
10496
|
+
* (boundAliasInstances), or null when its signature never instantiated
|
|
10497
|
+
* that reference. Inert outside generic function instantiation. */
|
|
10498
|
+
boundAliasTsResolver = (t) => {
|
|
10499
|
+
if (!this.typeParamTsBindings || t.getAliasTypeArguments().length === 0)
|
|
10500
|
+
return null;
|
|
10501
|
+
const tsBindings = this.typeParamTsBindings;
|
|
10502
|
+
return (this.boundAliasInstances.get(t)?.find((entry) => entry.tsBindings === tsBindings)?.instance ??
|
|
10503
|
+
null);
|
|
10504
|
+
};
|
|
10505
|
+
structuredCloneReadCounts = null;
|
|
10506
|
+
/** How often the program reads `workerData` (every expression spelling it,
|
|
10507
|
+
* counted conservatively) and registers a `"message"` listener: a
|
|
10508
|
+
* structured clone read at one site only has no other holder
|
|
10509
|
+
* (narrowing.ts freshDynSource). Computed once per lowering pass. */
|
|
10510
|
+
structuredCloneReads() {
|
|
10511
|
+
if (this.structuredCloneReadCounts)
|
|
10512
|
+
return this.structuredCloneReadCounts;
|
|
10513
|
+
const counts = { workerData: 0, messageListeners: 0 };
|
|
10514
|
+
const visit = (node) => {
|
|
10515
|
+
if (ts.isIdentifier(node) && node.text === "workerData") {
|
|
10516
|
+
const parent = node.parent;
|
|
10517
|
+
const declaresName = parent !== undefined &&
|
|
10518
|
+
(ts.isImportSpecifier(parent) ||
|
|
10519
|
+
ts.isExportSpecifier(parent) ||
|
|
10520
|
+
((ts.isPropertyAssignment(parent) ||
|
|
10521
|
+
ts.isPropertyDeclaration(parent) ||
|
|
10522
|
+
ts.isPropertySignature(parent) ||
|
|
10523
|
+
ts.isMethodDeclaration(parent)) &&
|
|
10524
|
+
parent.name === node));
|
|
10525
|
+
if (!declaresName)
|
|
10526
|
+
counts.workerData++;
|
|
10527
|
+
}
|
|
10528
|
+
else if (ts.isCallExpression(node) && isMessageListenerCall(node)) {
|
|
10529
|
+
counts.messageListeners++;
|
|
10530
|
+
}
|
|
10531
|
+
ts.forEachChild(node, visit);
|
|
10532
|
+
};
|
|
10533
|
+
for (const sf of this.moduleOrder)
|
|
10534
|
+
ts.forEachChild(sf, visit);
|
|
10535
|
+
this.structuredCloneReadCounts = counts;
|
|
10536
|
+
return counts;
|
|
10537
|
+
}
|
|
8432
10538
|
irTypeOf(node) {
|
|
8433
10539
|
const t = this.typeOf(node);
|
|
8434
10540
|
// JS inference can leave mutable fields, accessor parameters and
|
|
@@ -8441,6 +10547,8 @@ export class Lowerer {
|
|
|
8441
10547
|
// f64 — but must not: pre-empt the mapping so the JS fallback below
|
|
8442
10548
|
// answers instead.
|
|
8443
10549
|
const mapped = neverTaintedJsType(this, node, t) ? null : this.mapTypeOf(t);
|
|
10550
|
+
if (mapped !== null && this.degradedTypes.size > 0)
|
|
10551
|
+
this.noteDegradedSlot(node, t);
|
|
8444
10552
|
if (!mapped) {
|
|
8445
10553
|
const argumentsType = jsArgumentsFunctionType(this, t);
|
|
8446
10554
|
if (argumentsType !== null)
|
|
@@ -8662,6 +10770,30 @@ export class Lowerer {
|
|
|
8662
10770
|
const result = this.coerceToExpected(expr.result, expected);
|
|
8663
10771
|
return { ...expr, result, type: result.type };
|
|
8664
10772
|
}
|
|
10773
|
+
// A `Promise<module namespace>` widening into `Promise<unknown>`, or
|
|
10774
|
+
// into an `unknown` slot: map the payload through the namespace's
|
|
10775
|
+
// dynamic value (moduleNamespacePromiseDynValue). A destination that
|
|
10776
|
+
// wants the namespace type itself keeps the promise unchanged; the
|
|
10777
|
+
// union path reuses this through its single-promise-arm conversion.
|
|
10778
|
+
if (expr.type.kind === "promise" &&
|
|
10779
|
+
expr.type.inner.kind === "moduleNs" &&
|
|
10780
|
+
(expected.kind === "dyn" || (expected.kind === "promise" && expected.inner.kind === "dyn"))) {
|
|
10781
|
+
const mapped = this.moduleNamespacePromiseDynValue(expr);
|
|
10782
|
+
if (mapped)
|
|
10783
|
+
expr = mapped;
|
|
10784
|
+
}
|
|
10785
|
+
// An instance of a class declared `extends Array` is its array (the
|
|
10786
|
+
// same object); an array slot of another element type converts it as
|
|
10787
|
+
// an array.
|
|
10788
|
+
if (expr.type.kind === "object" && expected.kind !== "object") {
|
|
10789
|
+
const arrayClass = this.classes.get(expr.type.className);
|
|
10790
|
+
if (arrayClass && arrayRootOf(arrayClass)) {
|
|
10791
|
+
const asArray = arrayOfClassInstance(arrayClass, expr, expr.loc);
|
|
10792
|
+
return typeEquals(asArray.type, expected)
|
|
10793
|
+
? asArray
|
|
10794
|
+
: this.coerceToExpected(asArray, expected);
|
|
10795
|
+
}
|
|
10796
|
+
}
|
|
8665
10797
|
// A destination that holds undefined takes an unassigned deferred-init
|
|
8666
10798
|
// field's slot as is (Node passes the undefined along).
|
|
8667
10799
|
if (expected.kind === "union" && this.armTag(expected.unionId, UNDEFINED_T) >= 0) {
|
|
@@ -8788,6 +10920,15 @@ export class Lowerer {
|
|
|
8788
10920
|
if (object)
|
|
8789
10921
|
return object;
|
|
8790
10922
|
}
|
|
10923
|
+
// A TypeScript source's module namespace as an untyped value: the
|
|
10924
|
+
// runtime's namespace object with live reads, Node's sorted keys and
|
|
10925
|
+
// read-only writes. `node:` builtins have no compiled source or
|
|
10926
|
+
// complete export table here and keep their fence below.
|
|
10927
|
+
if (expr.type.kind === "moduleNs") {
|
|
10928
|
+
const boxed = this.moduleNamespaceDyn(expr);
|
|
10929
|
+
if (boxed)
|
|
10930
|
+
return boxed;
|
|
10931
|
+
}
|
|
8791
10932
|
if (expr.type.kind === "moduleNs" &&
|
|
8792
10933
|
expr.type.moduleId === "builtin:events" &&
|
|
8793
10934
|
isJsSourceFileName(expr.loc.file)) {
|
|
@@ -8824,18 +10965,13 @@ export class Lowerer {
|
|
|
8824
10965
|
const liveRef = liveReference(expr.type) ||
|
|
8825
10966
|
(expr.type.kind === "union" &&
|
|
8826
10967
|
(this.unions.get(expr.type.unionId)?.arms.some(liveReference) ?? false));
|
|
8827
|
-
// A builtin function's adapter boxes under the builtin's name, the
|
|
8828
|
-
// name Node's function carries (`[Function: randomUUID]`).
|
|
8829
|
-
const builtinName = expr.kind === "closure" ? this.builtinCallableValueNames.get(expr.fnName) : undefined;
|
|
8830
|
-
const builtinLength = expr.kind === "closure" ? this.builtinCallableValueLengths.get(expr.fnName) : undefined;
|
|
8831
10968
|
return {
|
|
8832
10969
|
kind: "dynFrom",
|
|
8833
10970
|
value: expr,
|
|
8834
10971
|
type: DYN,
|
|
8835
10972
|
loc: expr.loc,
|
|
8836
10973
|
...(liveRef ? { liveRef: true } : {}),
|
|
8837
|
-
...(
|
|
8838
|
-
...(builtinLength !== undefined ? { fnLength: builtinLength } : {}),
|
|
10974
|
+
...this.builtinFunctionIdentity(expr),
|
|
8839
10975
|
};
|
|
8840
10976
|
}
|
|
8841
10977
|
return expr;
|
|
@@ -8940,7 +11076,13 @@ export class Lowerer {
|
|
|
8940
11076
|
canAdaptDynFuncTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
|
|
8941
11077
|
return {
|
|
8942
11078
|
kind: "dynCheck",
|
|
8943
|
-
value: {
|
|
11079
|
+
value: {
|
|
11080
|
+
kind: "dynFrom",
|
|
11081
|
+
value: expr,
|
|
11082
|
+
type: DYN,
|
|
11083
|
+
loc: expr.loc,
|
|
11084
|
+
...this.builtinFunctionIdentity(expr),
|
|
11085
|
+
},
|
|
8944
11086
|
type: expected,
|
|
8945
11087
|
loc: expr.loc,
|
|
8946
11088
|
};
|
|
@@ -9029,6 +11171,17 @@ export class Lowerer {
|
|
|
9029
11171
|
}
|
|
9030
11172
|
}
|
|
9031
11173
|
if (expected.kind !== "union" || typeEquals(expr.type, expected)) {
|
|
11174
|
+
// A MIXED union of tuples/arrays flowing into one of its own array
|
|
11175
|
+
// arms (`["one"] | string[]` into `string[]`): Node has one array
|
|
11176
|
+
// either way, so every arm converts on its tag (the width plan's
|
|
11177
|
+
// unionArr) rather than the checked extraction trapping on the
|
|
11178
|
+
// tuple arm. The plan promises this conversion exactly when a
|
|
11179
|
+
// non-destination arm converts too.
|
|
11180
|
+
if (expr.type.kind === "union" && expected.kind === "array") {
|
|
11181
|
+
const lift = this.widthLiftPlan(expr.type, expected);
|
|
11182
|
+
if (lift?.how === "unionArr")
|
|
11183
|
+
return this.applyWidthLift(lift, expr, expected, expr.loc);
|
|
11184
|
+
}
|
|
9032
11185
|
// A UNION value flowing into one of its own ARMS: the checker
|
|
9033
11186
|
// proved the narrowing (control flow through a destructured
|
|
9034
11187
|
// binding, `d ?? (d = ...)`, a predicate call — tsc typed the SITE
|
|
@@ -9041,7 +11194,11 @@ export class Lowerer {
|
|
|
9041
11194
|
!isUnitType(expected) &&
|
|
9042
11195
|
expected.kind !== "void" &&
|
|
9043
11196
|
this.armTag(expr.type.unionId, expected) >= 0) {
|
|
9044
|
-
|
|
11197
|
+
// A function's widened inferred return (widenReducedReturn) also
|
|
11198
|
+
// holds records with more fields; those convert instead of throwing.
|
|
11199
|
+
const helper = widensReducedRecords(this, expected, expr.type)
|
|
11200
|
+
? widthNarrowHelper(this, expr.type.unionId, expected, expr.loc)
|
|
11201
|
+
: this.narrowedArmHelper(expr.type.unionId, expected, expr.loc);
|
|
9045
11202
|
if (helper) {
|
|
9046
11203
|
return this.checkedNarrowCall(helper, expr, expected, expr.loc);
|
|
9047
11204
|
}
|
|
@@ -9070,6 +11227,9 @@ export class Lowerer {
|
|
|
9070
11227
|
const w = this.widthCoerce(expr, expected);
|
|
9071
11228
|
if (w)
|
|
9072
11229
|
return w;
|
|
11230
|
+
const asserted = assertedConversion(this, expr, expected);
|
|
11231
|
+
if (asserted)
|
|
11232
|
+
return asserted;
|
|
9073
11233
|
// A UNIT (null/undefined) flowing into a plain non-nullable slot
|
|
9074
11234
|
// the checker approved (`null!` casts, non-strict assignments):
|
|
9075
11235
|
// the stranded-source stance (divergence 38) without a union in
|
|
@@ -9089,7 +11249,7 @@ export class Lowerer {
|
|
|
9089
11249
|
if (helper) {
|
|
9090
11250
|
return { kind: "call", callee: helper, args: [expr], type: expected, loc: expr.loc };
|
|
9091
11251
|
}
|
|
9092
|
-
return expr;
|
|
11252
|
+
return assertedConversion(this, expr, expected) ?? expr;
|
|
9093
11253
|
}
|
|
9094
11254
|
if (expr.type.kind === "void") {
|
|
9095
11255
|
// A void CALL RESULT flowing into a union with an undefined arm
|
|
@@ -9168,6 +11328,31 @@ export class Lowerer {
|
|
|
9168
11328
|
}
|
|
9169
11329
|
}
|
|
9170
11330
|
}
|
|
11331
|
+
// A promise or function value against a union whose ONLY arm of
|
|
11332
|
+
// that kind differs from it (`Promise<T>` into `Promise<unknown> |
|
|
11333
|
+
// undefined`, `() => Promise<string | null>` into an optional
|
|
11334
|
+
// `() => Promise<string | null | undefined>` member): convert into
|
|
11335
|
+
// that arm with the arm-level conversion (the checked payload
|
|
11336
|
+
// widening, the function adapter), then wrap. Several arms of the
|
|
11337
|
+
// kind stay ambiguous and fall through to the union fence.
|
|
11338
|
+
if (expr.type.kind === "promise" || expr.type.kind === "func") {
|
|
11339
|
+
const arms = this.unions.get(expected.unionId)?.arms ?? [];
|
|
11340
|
+
const candidates = arms.filter((arm) => arm.kind === expr.type.kind);
|
|
11341
|
+
const arm = candidates.length === 1 ? candidates[0] : null;
|
|
11342
|
+
if (arm) {
|
|
11343
|
+
const converted = this.coerceToExpected(expr, arm);
|
|
11344
|
+
if (converted !== expr && typeEquals(converted.type, arm)) {
|
|
11345
|
+
return {
|
|
11346
|
+
kind: "unionWrap",
|
|
11347
|
+
unionId: expected.unionId,
|
|
11348
|
+
tag: arms.indexOf(arm),
|
|
11349
|
+
value: converted,
|
|
11350
|
+
type: expected,
|
|
11351
|
+
loc: expr.loc,
|
|
11352
|
+
};
|
|
11353
|
+
}
|
|
11354
|
+
}
|
|
11355
|
+
}
|
|
9171
11356
|
// A width-coercible value against a union: coerce into the SINGLE
|
|
9172
11357
|
// width-liftable arm, then wrap like any arm value (widthLiftPlan's
|
|
9173
11358
|
// liftWrap — several candidate arms are ambiguous and decline).
|
|
@@ -9241,9 +11426,15 @@ export class Lowerer {
|
|
|
9241
11426
|
unionRecordWidthHelper(fromId, target, loc) {
|
|
9242
11427
|
return unionRecordWidthHelper(this, fromId, target, loc);
|
|
9243
11428
|
}
|
|
11429
|
+
unionArrayWidthHelper(fromId, target, loc) {
|
|
11430
|
+
return unionArrayWidthHelper(this, fromId, target, loc);
|
|
11431
|
+
}
|
|
9244
11432
|
recordWidthPlan(fromId, toId) {
|
|
9245
11433
|
return recordWidthPlan(this, fromId, toId);
|
|
9246
11434
|
}
|
|
11435
|
+
recordOvfCapturePlan(fromId, toId) {
|
|
11436
|
+
return recordOvfCapturePlan(this, fromId, toId);
|
|
11437
|
+
}
|
|
9247
11438
|
describeRecordWidthBlocker(fromId, toId) {
|
|
9248
11439
|
return describeRecordWidthBlocker(this, fromId, toId);
|
|
9249
11440
|
}
|
|
@@ -9326,9 +11517,52 @@ export class Lowerer {
|
|
|
9326
11517
|
* wrap implicitly (coerceToExpected), then the exact-type fence runs
|
|
9327
11518
|
* (SC2002 for record shapes, SC2003 for unions). Every slot-directed
|
|
9328
11519
|
* lowering goes through here (via lowerExprExpecting) or calls this
|
|
9329
|
-
* directly when the expression was already lowered.
|
|
11520
|
+
* directly when the expression was already lowered. In package files, a
|
|
11521
|
+
* check this coercion creates names the package declaration that types
|
|
11522
|
+
* the slot (decl-origin.ts). */
|
|
9330
11523
|
coerceInto(node, expr, expected) {
|
|
11524
|
+
if (!this.inPackageFileOf(node))
|
|
11525
|
+
return this.coerceIntoSlot(node, expr, expected);
|
|
11526
|
+
const outer = this.coercionOriginNode;
|
|
11527
|
+
const outerUnion = this.coercionOriginUnion;
|
|
11528
|
+
this.coercionOriginNode = node;
|
|
11529
|
+
this.coercionOriginUnion = expr.type.kind === "union" ? expr.type.unionId : null;
|
|
11530
|
+
let out;
|
|
11531
|
+
try {
|
|
11532
|
+
out = this.coerceIntoSlot(node, expr, expected);
|
|
11533
|
+
}
|
|
11534
|
+
finally {
|
|
11535
|
+
this.coercionOriginNode = outer;
|
|
11536
|
+
this.coercionOriginUnion = outerUnion;
|
|
11537
|
+
}
|
|
11538
|
+
if (out !== expr && out.kind === "dynCheck" && out.origin === undefined) {
|
|
11539
|
+
const origin = this.slotOriginOf(node);
|
|
11540
|
+
if (origin !== null)
|
|
11541
|
+
return { ...out, origin: this.declOriginIndex(origin) };
|
|
11542
|
+
}
|
|
11543
|
+
return out;
|
|
11544
|
+
}
|
|
11545
|
+
coerceIntoSlot(node, expr, expected) {
|
|
9331
11546
|
refuseInferredCallbackDrops(this, node, expr.type, expected);
|
|
11547
|
+
// A union into one of its record arms extracts that arm, trusting the
|
|
11548
|
+
// checker to have excluded the others. A built-in object arm the checker
|
|
11549
|
+
// still types the site with (`c ?? new Map()` into an interface the
|
|
11550
|
+
// untyped Map satisfies only through `any`) holds a value at run time,
|
|
11551
|
+
// and no conversion makes a record of it, so the flow is refused like
|
|
11552
|
+
// the arm's value would be.
|
|
11553
|
+
if (expr.type.kind === "union" &&
|
|
11554
|
+
expected.kind === "record" &&
|
|
11555
|
+
this.armTag(expr.type.unionId, expected) >= 0) {
|
|
11556
|
+
const site = this.mapTypeOf(this.typeOf(node));
|
|
11557
|
+
const siteArms = site?.kind === "union" ? (this.unions.get(site.unionId)?.arms ?? []) : site ? [site] : [];
|
|
11558
|
+
for (const arm of this.unions.get(expr.type.unionId)?.arms ?? []) {
|
|
11559
|
+
if (arm.kind !== "map" && arm.kind !== "set")
|
|
11560
|
+
continue;
|
|
11561
|
+
if (!siteArms.some((s) => typeEquals(s, arm)))
|
|
11562
|
+
continue;
|
|
11563
|
+
this.requireExactShape(node, arm, expected);
|
|
11564
|
+
}
|
|
11565
|
+
}
|
|
9332
11566
|
// An assertion's scalar check whose value goes straight back into a
|
|
9333
11567
|
// checked-dynamic slot (`process.loadEnvFile({} as unknown as string)`)
|
|
9334
11568
|
// keeps the original value: JavaScript erases assertions, so the check
|
|
@@ -9464,6 +11698,19 @@ export class Lowerer {
|
|
|
9464
11698
|
}
|
|
9465
11699
|
}
|
|
9466
11700
|
}
|
|
11701
|
+
// A value the checker types `never` at this site (a read narrowed past
|
|
11702
|
+
// every member of its union) exists only when an assertion lied about
|
|
11703
|
+
// its type, so its layout need not fit the slot: it is evaluated, then a
|
|
11704
|
+
// TypeError is thrown, as checked extraction of an impossible arm does.
|
|
11705
|
+
if (!typeEquals(e.type, expected) && (this.typeOf(node).flags & ts.TypeFlags.Never) !== 0) {
|
|
11706
|
+
return {
|
|
11707
|
+
kind: "seqExpr",
|
|
11708
|
+
stmts: [{ kind: "exprStmt", expr: e, loc: e.loc }],
|
|
11709
|
+
result: nodeThrowExpr(1, "", unionNarrowFailureMessage(e.type, (t) => this.fmt(t)), expected, e.loc),
|
|
11710
|
+
type: expected,
|
|
11711
|
+
loc: e.loc,
|
|
11712
|
+
};
|
|
11713
|
+
}
|
|
9467
11714
|
this.requireExactShape(node, e.type, expected);
|
|
9468
11715
|
return e;
|
|
9469
11716
|
}
|
|
@@ -9749,6 +11996,7 @@ export class Lowerer {
|
|
|
9749
11996
|
!this.mapTypeOf(this.typeOf(x)) ||
|
|
9750
11997
|
this.excessJsContextualProperty(x, parts) ||
|
|
9751
11998
|
this.reshapeableContextualLiteral(x, parts) ||
|
|
11999
|
+
this.untypedLiteralContext(x) ||
|
|
9752
12000
|
holdsEvolvingArray(this, x)) {
|
|
9753
12001
|
return lowerDynObjectLiteral(this, x);
|
|
9754
12002
|
}
|
|
@@ -10256,6 +12504,7 @@ export class Lowerer {
|
|
|
10256
12504
|
const list = this.deferredDiags.get(symbol) ?? [];
|
|
10257
12505
|
list.push(...sink);
|
|
10258
12506
|
this.deferredDiags.set(symbol, list);
|
|
12507
|
+
this.deferredCollectors.set(symbol, { symbolOf, collect });
|
|
10259
12508
|
return symbol;
|
|
10260
12509
|
}
|
|
10261
12510
|
finally {
|
|
@@ -10272,22 +12521,51 @@ export class Lowerer {
|
|
|
10272
12521
|
return;
|
|
10273
12522
|
this.reportDeferred(symbol);
|
|
10274
12523
|
}
|
|
12524
|
+
/** A statement's lowering used a declaration: if that declaration was
|
|
12525
|
+
* rejected, the statement's own failure (if any) is its cascade. */
|
|
12526
|
+
touchRejected(symbol) {
|
|
12527
|
+
const group = this.rejectedGroups.get(symbol);
|
|
12528
|
+
if (group === undefined)
|
|
12529
|
+
return;
|
|
12530
|
+
const frame = this.failureTouches[this.failureTouches.length - 1];
|
|
12531
|
+
if (frame !== undefined)
|
|
12532
|
+
frame.add(group);
|
|
12533
|
+
}
|
|
12534
|
+
/** Records a declaration whose deferred diagnostics reached the build:
|
|
12535
|
+
* its failure group, on the group's diagnostics too. */
|
|
12536
|
+
noteRejected(symbol, diags) {
|
|
12537
|
+
let group = this.rejectedGroups.get(symbol);
|
|
12538
|
+
if (group === undefined) {
|
|
12539
|
+
group = declarationGroupKey(symbol);
|
|
12540
|
+
this.rejectedGroups.set(symbol, group);
|
|
12541
|
+
}
|
|
12542
|
+
for (const d of diags)
|
|
12543
|
+
d.rejects ??= group;
|
|
12544
|
+
}
|
|
10275
12545
|
/** flushDeferred without the collection-pass guard: for declarations
|
|
10276
12546
|
* whose diagnostics must report eagerly (class statements with
|
|
10277
12547
|
* declaration-time code, extended bases — collectClassShapeDeferring). */
|
|
10278
12548
|
reportDeferred(symbol) {
|
|
10279
12549
|
const diags = this.deferredDiags.get(symbol);
|
|
10280
|
-
if (!diags)
|
|
12550
|
+
if (!diags) {
|
|
12551
|
+
this.touchRejected(symbol);
|
|
10281
12552
|
return;
|
|
12553
|
+
}
|
|
10282
12554
|
if (this.alreadyFlushed.has(symbol)) {
|
|
10283
12555
|
this.deferredDiags.delete(symbol); // the emit pass reported these
|
|
10284
12556
|
return;
|
|
10285
12557
|
}
|
|
10286
12558
|
if (this.diagSink === null) {
|
|
12559
|
+
if (this.retryDeferred(symbol, diags))
|
|
12560
|
+
return;
|
|
12561
|
+
// A failed retry leaves the last attempt's diagnostics deferred.
|
|
12562
|
+
const committed = this.deferredDiags.get(symbol) ?? diags;
|
|
10287
12563
|
this.deferredDiags.delete(symbol);
|
|
10288
12564
|
this.flushedSymbols.add(symbol);
|
|
10289
|
-
|
|
12565
|
+
this.noteRejected(symbol, committed);
|
|
12566
|
+
for (const d of committed)
|
|
10290
12567
|
this.pushDiag(d);
|
|
12568
|
+
this.touchRejected(symbol);
|
|
10291
12569
|
return;
|
|
10292
12570
|
}
|
|
10293
12571
|
// A capture buffer is active (a probe, or another declaration's
|
|
@@ -10303,6 +12581,7 @@ export class Lowerer {
|
|
|
10303
12581
|
* (the declaration counts as flushed for the coverage remainder). */
|
|
10304
12582
|
commitFlush(symbol, source) {
|
|
10305
12583
|
this.flushedSymbols.add(symbol);
|
|
12584
|
+
this.noteRejected(symbol, [source]);
|
|
10306
12585
|
const list = this.deferredDiags.get(symbol);
|
|
10307
12586
|
if (!list)
|
|
10308
12587
|
return;
|
|
@@ -10312,10 +12591,167 @@ export class Lowerer {
|
|
|
10312
12591
|
if (list.length === 0)
|
|
10313
12592
|
this.deferredDiags.delete(symbol);
|
|
10314
12593
|
}
|
|
12594
|
+
/** Flushes a deferred class known by its IR name, and answers the class
|
|
12595
|
+
* when the flush registered it (retryDeferred). */
|
|
10315
12596
|
flushDeferredClass(className) {
|
|
10316
12597
|
const symbol = this.deferredClassByName.get(className);
|
|
10317
12598
|
if (symbol)
|
|
10318
12599
|
this.flushDeferred(symbol);
|
|
12600
|
+
return this.classes.get(className);
|
|
12601
|
+
}
|
|
12602
|
+
/** Localized failure's declaration commit point (design §3.3): a
|
|
12603
|
+
* reference is flushing a deferred declaration into the build. When
|
|
12604
|
+
* every deferred diagnostic is a degradable type failure at one of the
|
|
12605
|
+
* declaration's slots, the failing types degrade and the collection
|
|
12606
|
+
* runs again (up to MAX_DECLARATION_RETRIES rounds, each degrading the
|
|
12607
|
+
* types the previous round still failed on). On success the
|
|
12608
|
+
* declaration registers, each degraded slot is an SC6104, and nothing
|
|
12609
|
+
* reports. Otherwise the last round's diagnostics stay deferred for the
|
|
12610
|
+
* caller to commit. */
|
|
12611
|
+
retryDeferred(symbol, diags) {
|
|
12612
|
+
if (this.tierMode !== "auto")
|
|
12613
|
+
return false;
|
|
12614
|
+
if (this.staticInitsPassed.has(symbol))
|
|
12615
|
+
return false;
|
|
12616
|
+
const collector = this.deferredCollectors.get(symbol);
|
|
12617
|
+
if (collector === undefined)
|
|
12618
|
+
return false;
|
|
12619
|
+
const slots = [];
|
|
12620
|
+
// The types this retry degraded (not those of retries its collections
|
|
12621
|
+
// ran) and their entries before it, for retryDeferredAtDeclaration to
|
|
12622
|
+
// restore when it fails.
|
|
12623
|
+
const degraded = [];
|
|
12624
|
+
try {
|
|
12625
|
+
return this.retryDeferredRounds(symbol, collector, diags, slots, degraded);
|
|
12626
|
+
}
|
|
12627
|
+
finally {
|
|
12628
|
+
this.retryDegraded = degraded;
|
|
12629
|
+
}
|
|
12630
|
+
}
|
|
12631
|
+
retryDeferredRounds(symbol, collector, diags, slots, degraded) {
|
|
12632
|
+
let current = diags;
|
|
12633
|
+
for (let round = 0; round < MAX_DECLARATION_RETRIES; round++) {
|
|
12634
|
+
const failing = [];
|
|
12635
|
+
let retriable = false;
|
|
12636
|
+
for (const diag of current) {
|
|
12637
|
+
if (this.retriableDiags.has(diag)) {
|
|
12638
|
+
retriable = true;
|
|
12639
|
+
continue;
|
|
12640
|
+
}
|
|
12641
|
+
const failure = diag.typeFailure;
|
|
12642
|
+
// The dyn class field policy lifts during the retry; nothing to
|
|
12643
|
+
// degrade.
|
|
12644
|
+
if (failure?.family === "dyn-field-policy") {
|
|
12645
|
+
retriable = true;
|
|
12646
|
+
continue;
|
|
12647
|
+
}
|
|
12648
|
+
const type = failure === undefined ? undefined : this.failedTypes.get(failure);
|
|
12649
|
+
const id = type?.id;
|
|
12650
|
+
if (failure === undefined ||
|
|
12651
|
+
type === undefined ||
|
|
12652
|
+
id === undefined ||
|
|
12653
|
+
!failure.degradable ||
|
|
12654
|
+
!DECLARATION_SLOTS.has(failure.slot) ||
|
|
12655
|
+
this.degradedTypes.get(id)?.lenient?.kind === "dyn")
|
|
12656
|
+
return false;
|
|
12657
|
+
failing.push({ diag, failure, type });
|
|
12658
|
+
}
|
|
12659
|
+
// A round makes progress by degrading a type, or (once) by running
|
|
12660
|
+
// a collection that only waited for another declaration.
|
|
12661
|
+
if (failing.length === 0 && !(retriable && round === 0))
|
|
12662
|
+
return false;
|
|
12663
|
+
for (const { diag, failure, type } of failing) {
|
|
12664
|
+
const id = type.id ?? -1;
|
|
12665
|
+
const prior = this.degradedTypes.get(id);
|
|
12666
|
+
degraded.push({
|
|
12667
|
+
id,
|
|
12668
|
+
prior: prior === undefined
|
|
12669
|
+
? undefined
|
|
12670
|
+
: {
|
|
12671
|
+
lenient: prior.lenient,
|
|
12672
|
+
code: prior.code,
|
|
12673
|
+
reason: prior.reason,
|
|
12674
|
+
...(prior.canonical === true ? { canonical: true } : {}),
|
|
12675
|
+
},
|
|
12676
|
+
});
|
|
12677
|
+
this.degradeType(type, diag.code, diag.message);
|
|
12678
|
+
const canonical = this.isCanonicalDegraded(id);
|
|
12679
|
+
const partial = this.degradedTypes.get(id)?.lenient?.kind !== "dyn";
|
|
12680
|
+
slots.push({
|
|
12681
|
+
loc: diag.loc,
|
|
12682
|
+
failure,
|
|
12683
|
+
code: diag.code,
|
|
12684
|
+
reason: diag.message,
|
|
12685
|
+
...(canonical ? { canonical: true } : {}),
|
|
12686
|
+
...(partial ? { partial: true } : {}),
|
|
12687
|
+
});
|
|
12688
|
+
}
|
|
12689
|
+
this.deferredDiags.delete(symbol);
|
|
12690
|
+
const lifted = this.liftDynFieldPolicy;
|
|
12691
|
+
this.liftDynFieldPolicy = true;
|
|
12692
|
+
// Pushed-down types that did not help widen to the whole slot, and the
|
|
12693
|
+
// collection runs again (a few times at most).
|
|
12694
|
+
let registered = false;
|
|
12695
|
+
try {
|
|
12696
|
+
for (let widen = 0; widen < 4; widen++) {
|
|
12697
|
+
const hits = new Set();
|
|
12698
|
+
registered =
|
|
12699
|
+
this.withPartialHits(hits, () => this.collectDeferring(collector.symbolOf, collector.collect)) === null;
|
|
12700
|
+
if (registered || !this.widenPartials(hits))
|
|
12701
|
+
break;
|
|
12702
|
+
this.deferredDiags.delete(symbol);
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12705
|
+
finally {
|
|
12706
|
+
this.liftDynFieldPolicy = lifted;
|
|
12707
|
+
}
|
|
12708
|
+
if (registered) {
|
|
12709
|
+
this.retriedSymbols.add(symbol);
|
|
12710
|
+
this.deferredCollectors.delete(symbol);
|
|
12711
|
+
for (const [name, deferred] of this.deferredClassByName)
|
|
12712
|
+
if (deferred === symbol)
|
|
12713
|
+
this.deferredClassByName.delete(name);
|
|
12714
|
+
for (const slot of slots)
|
|
12715
|
+
this.noteDynamicSlot(slot);
|
|
12716
|
+
for (const decl of symbol.declarations)
|
|
12717
|
+
if (ts.isFunctionDeclaration(decl) || ts.isClassDeclaration(decl)) {
|
|
12718
|
+
this.retriedDeclarations.push(decl);
|
|
12719
|
+
this.onDeclarationRegistered?.(decl);
|
|
12720
|
+
}
|
|
12721
|
+
return true;
|
|
12722
|
+
}
|
|
12723
|
+
current = this.deferredDiags.get(symbol) ?? [];
|
|
12724
|
+
}
|
|
12725
|
+
return false;
|
|
12726
|
+
}
|
|
12727
|
+
retryDegraded = [];
|
|
12728
|
+
/** A deferred class with static field initializers is reached where its
|
|
12729
|
+
* statement evaluates: Node runs the initializers there, referenced or
|
|
12730
|
+
* not. Its file's %init calls this at that place, which retries the class
|
|
12731
|
+
* as a flush would, so the initializers lower in place. A failed retry
|
|
12732
|
+
* reports nothing and leaves the class deferred as it was, and from here
|
|
12733
|
+
* on no flush registers it (staticInitsPassed): it reports instead.
|
|
12734
|
+
* Returns whether the class has registered. */
|
|
12735
|
+
retryDeferredAtDeclaration(symbol) {
|
|
12736
|
+
const diags = this.deferredDiags.get(symbol);
|
|
12737
|
+
let registered = !this.deferredCollectors.has(symbol);
|
|
12738
|
+
if (!registered && diags !== undefined) {
|
|
12739
|
+
this.retryDegraded = [];
|
|
12740
|
+
registered = this.retryDeferred(symbol, diags);
|
|
12741
|
+
if (!registered) {
|
|
12742
|
+
for (let i = this.retryDegraded.length - 1; i >= 0; i--) {
|
|
12743
|
+
const { id, prior } = this.retryDegraded[i];
|
|
12744
|
+
if (prior === undefined)
|
|
12745
|
+
this.degradedTypes.delete(id);
|
|
12746
|
+
else
|
|
12747
|
+
this.degradedTypes.set(id, prior);
|
|
12748
|
+
}
|
|
12749
|
+
this.deferredDiags.set(symbol, [...diags]);
|
|
12750
|
+
}
|
|
12751
|
+
this.retryDegraded = [];
|
|
12752
|
+
}
|
|
12753
|
+
this.staticInitsPassed.add(symbol);
|
|
12754
|
+
return registered;
|
|
10319
12755
|
}
|
|
10320
12756
|
collectSignature(decl) {
|
|
10321
12757
|
return collectSignature(this, decl);
|
|
@@ -10425,6 +12861,13 @@ export class Lowerer {
|
|
|
10425
12861
|
lowerClassExpressionInfo(expr) {
|
|
10426
12862
|
return lowerClassExpressionInfo(this, expr);
|
|
10427
12863
|
}
|
|
12864
|
+
/** Batch-prefetches the symbols of every runtime identifier of the
|
|
12865
|
+
* program's files. Collection's early-binding scan and the runtime-
|
|
12866
|
+
* optional analysis look them up across every body, reached or not;
|
|
12867
|
+
* one batch answers both, instead of one request per identifier. */
|
|
12868
|
+
prefetchProgramSymbols(parts) {
|
|
12869
|
+
this.checker.prefetchSymbolRoots(parts.map((fp) => fp.sf), true);
|
|
12870
|
+
}
|
|
10428
12871
|
/** Depth of the whole-program analyses that query types across every
|
|
10429
12872
|
* file before reachability is known (speculativeTypeQueries). */
|
|
10430
12873
|
speculativeTypeQueryDepth = 0;
|
|
@@ -10523,6 +12966,9 @@ export class Lowerer {
|
|
|
10523
12966
|
* bodies as worklist units (the units map is otherwise built before
|
|
10524
12967
|
* lowering starts). Null in the emit pass. */
|
|
10525
12968
|
onExprClassCollected = null;
|
|
12969
|
+
/** emitReachable's unit registration for a declaration retryDeferred
|
|
12970
|
+
* registered after collection. */
|
|
12971
|
+
onDeclarationRegistered = null;
|
|
10526
12972
|
/** Mixin functions (`(Base: T) => class extends Base {…}`) by their
|
|
10527
12973
|
* function-like node: recognized shape, or null for checked
|
|
10528
12974
|
* non-qualifiers (lower-mixins.ts). */
|
|
@@ -10669,6 +13115,8 @@ export class Lowerer {
|
|
|
10669
13115
|
}
|
|
10670
13116
|
/* ── scoping and captures ─────────────────────────────────────────── */
|
|
10671
13117
|
declareLocal(nameNode, name, type, mutable) {
|
|
13118
|
+
if (this.degradedTypes.size > 0)
|
|
13119
|
+
this.noteDegradedSlot(nameNode, this.typeOf(nameNode));
|
|
10672
13120
|
const symbol = this.checker.getSymbolAtLocation(nameNode);
|
|
10673
13121
|
const local = declareContextLocal(this.ctx, name, type, mutable, symbol, bindingSource(nameNode));
|
|
10674
13122
|
// A binding declared `T | undefined` that receives a missing read: the
|
|
@@ -10727,7 +13175,7 @@ export class Lowerer {
|
|
|
10727
13175
|
const name = nameNode.text;
|
|
10728
13176
|
const fn = decl.parent;
|
|
10729
13177
|
const symbol = this.checker.getSymbolAtLocation(nameNode);
|
|
10730
|
-
const isRead = (id) => id !== nameNode && this
|
|
13178
|
+
const isRead = (id) => id !== nameNode && bindingSymbolOfRead(this, id) === symbol;
|
|
10731
13179
|
const pure = fn !== undefined && symbol !== undefined && onlyForwarded(this, fn, isRead);
|
|
10732
13180
|
// A forwarded-only tuple is never built: a tuple with optional
|
|
10733
13181
|
// positions (`Parameters<(n?: T) => R>`, whose length varies per call)
|
|
@@ -11278,8 +13726,8 @@ export class Lowerer {
|
|
|
11278
13726
|
lowerStmts(stmts) {
|
|
11279
13727
|
return lowerStmts(this, stmts);
|
|
11280
13728
|
}
|
|
11281
|
-
noteBlockedBindings(stmt) {
|
|
11282
|
-
return noteBlockedBindings(this, stmt);
|
|
13729
|
+
noteBlockedBindings(stmt, diags) {
|
|
13730
|
+
return noteBlockedBindings(this, stmt, diags);
|
|
11283
13731
|
}
|
|
11284
13732
|
isBlockedBinding(symbol) {
|
|
11285
13733
|
return isBlockedBinding(this, symbol);
|
|
@@ -11295,6 +13743,18 @@ export class Lowerer {
|
|
|
11295
13743
|
this.pushDiag(blockedBindingUseDiag(name, locOf(node)));
|
|
11296
13744
|
throw new PoisonError();
|
|
11297
13745
|
}
|
|
13746
|
+
// A stdlib-global snapshot read as a VALUE (`return proc` for
|
|
13747
|
+
// `const proc = globalThis.process`): the declaration emitted no
|
|
13748
|
+
// storage — alias plumbing only serves member and call reads — and the
|
|
13749
|
+
// global's own value has no lowering. The cause is the declaration, so
|
|
13750
|
+
// report there (once) and cascade here, instead of the generic
|
|
13751
|
+
// binding-form text that names neither.
|
|
13752
|
+
if (symbol !== null && this.stdlibGlobalAliasDecls.has(symbol)) {
|
|
13753
|
+
this.reportStdlibSnapshot(symbol);
|
|
13754
|
+
this.blockedBindings.add(symbol);
|
|
13755
|
+
this.pushDiag(blockedBindingUseDiag(name, locOf(node)));
|
|
13756
|
+
throw new PoisonError();
|
|
13757
|
+
}
|
|
11298
13758
|
// A binding whose TYPE keeps a generic call signature and whose
|
|
11299
13759
|
// declaration carries no initializer (`declare const o4: undefined |
|
|
11300
13760
|
// (<T>(f: (a: T) => T) => T)` — the optional-chained ambient shape):
|
|
@@ -11471,7 +13931,7 @@ export class Lowerer {
|
|
|
11471
13931
|
* supported-surface provenance check. */
|
|
11472
13932
|
isStdlibFile = (sf) => sf.fileName === this.ambient ||
|
|
11473
13933
|
sf.fileName === this.overridesAmbient ||
|
|
11474
|
-
sf.fileName
|
|
13934
|
+
isFallbackDtsPath(sf.fileName) ||
|
|
11475
13935
|
this.program.isSourceFileDefaultLibrary(sf) ||
|
|
11476
13936
|
(sf.isDeclarationFile && isNodeTypesPath(sf.fileName));
|
|
11477
13937
|
nodeTypesOnlySymbol(sym) {
|
|
@@ -11765,6 +14225,7 @@ export class Lowerer {
|
|
|
11765
14225
|
lowerStaticFetchCompanionCall(this, expr) ??
|
|
11766
14226
|
lowerStaticAbortControllerCall(this, expr) ??
|
|
11767
14227
|
lowerStaticAbortSignalListenerCall(this, expr) ??
|
|
14228
|
+
lowerWebStreamStaticCall(this, expr) ??
|
|
11768
14229
|
lowerStaticReadableStreamCancelCall(this, expr) ??
|
|
11769
14230
|
lowerStaticReadableStreamControllerCall(this, expr) ??
|
|
11770
14231
|
lowerStaticReadableStreamReaderCall(this, expr) ??
|
|
@@ -11776,6 +14237,7 @@ export class Lowerer {
|
|
|
11776
14237
|
lowerEcdhCall(this, expr) ??
|
|
11777
14238
|
lowerDiffieHellmanCall(this, expr) ??
|
|
11778
14239
|
lowerNetAddressCall(this, expr) ??
|
|
14240
|
+
lowerMimeCall(this, expr) ??
|
|
11779
14241
|
lowerFetchElementMethodCall(this, expr) ??
|
|
11780
14242
|
lowerDynamicImportCall(this, expr) ??
|
|
11781
14243
|
lowerCall(this, expr));
|
|
@@ -11793,7 +14255,7 @@ export class Lowerer {
|
|
|
11793
14255
|
return lowerLambda(this, node, checkedReceiver);
|
|
11794
14256
|
}
|
|
11795
14257
|
lowerArrayMethodCall(call, access) {
|
|
11796
|
-
return lowerArrayMethodCall(this, call, access);
|
|
14258
|
+
return lowerWithArraySpecies(this, call, access, () => lowerArrayMethodCall(this, call, access));
|
|
11797
14259
|
}
|
|
11798
14260
|
lowerMapMethodCall(call, access) {
|
|
11799
14261
|
return lowerMapMethodCall(this, call, access);
|
|
@@ -11922,6 +14384,8 @@ export class Lowerer {
|
|
|
11922
14384
|
lowerResponseNew(this, expr) ??
|
|
11923
14385
|
lowerBlobNew(this, expr) ??
|
|
11924
14386
|
lowerNetAddressNew(this, expr) ??
|
|
14387
|
+
lowerMimeNew(this, expr) ??
|
|
14388
|
+
lowerWebStreamNew(this, expr) ??
|
|
11925
14389
|
lowerStaticReadableStreamNew(this, expr) ??
|
|
11926
14390
|
lowerStaticTransformStreamNew(this, expr) ??
|
|
11927
14391
|
lowerConsoleNew(this, expr);
|
|
@@ -11989,6 +14453,16 @@ export class Lowerer {
|
|
|
11989
14453
|
* member access that IS a module in its own right (`fs.promises` — the
|
|
11990
14454
|
* same object as node:fs/promises, Node's rule). Null otherwise. */
|
|
11991
14455
|
builtinNamespaceModuleOf(expr) {
|
|
14456
|
+
// A function declaration is never a module namespace. Answering that
|
|
14457
|
+
// from the symbol skips the type mapping below (every direct call asks).
|
|
14458
|
+
if (ts.isIdentifier(expr)) {
|
|
14459
|
+
const symbol = this.checker.getSymbolAtLocation(expr);
|
|
14460
|
+
if (symbol !== undefined &&
|
|
14461
|
+
(symbol.flags & ts.SymbolFlags.Alias) === 0 &&
|
|
14462
|
+
symbol.declarations.length > 0 &&
|
|
14463
|
+
symbol.declarations.every(ts.isFunctionDeclaration))
|
|
14464
|
+
return null;
|
|
14465
|
+
}
|
|
11992
14466
|
// Default and CommonJS process bindings alias the global object, whose
|
|
11993
14467
|
// methods and properties keep their existing process lowerings.
|
|
11994
14468
|
if (stdlibGlobalNameOf(this, expr) === "process")
|
|
@@ -11996,6 +14470,17 @@ export class Lowerer {
|
|
|
11996
14470
|
const imported = ts.isIdentifier(expr) ? this.builtinImportOf(expr) : null;
|
|
11997
14471
|
if (imported?.module === "util" && imported.member === "types")
|
|
11998
14472
|
return "util/types";
|
|
14473
|
+
// path.win32 / path.posix as NAMED import bindings (`import { win32 }
|
|
14474
|
+
// from "node:path"`): the binding IS that sub-namespace module, so
|
|
14475
|
+
// `win32.normalize(...)` keys the win32 table on every platform —
|
|
14476
|
+
// Node's rule, each namespace answers its own platform's semantics
|
|
14477
|
+
// anywhere.
|
|
14478
|
+
if (imported !== null &&
|
|
14479
|
+
(imported.module === "path" ||
|
|
14480
|
+
imported.module === "path/posix" ||
|
|
14481
|
+
imported.module === "path/win32") &&
|
|
14482
|
+
(imported.member === "win32" || imported.member === "posix"))
|
|
14483
|
+
return `path/${imported.member}`;
|
|
11999
14484
|
const stored = ts.isIdentifier(expr)
|
|
12000
14485
|
? (this.peekLocal(expr)?.type ?? this.globalOf(expr)?.type)
|
|
12001
14486
|
: undefined;
|
|
@@ -12293,11 +14778,13 @@ export class Lowerer {
|
|
|
12293
14778
|
if (bi.module === "crypto" && bi.member === "webcrypto") {
|
|
12294
14779
|
return { kind: "libCall", fn: "webcrypto.object", args: [], type: DYN, loc };
|
|
12295
14780
|
}
|
|
12296
|
-
//
|
|
12297
|
-
//
|
|
12298
|
-
//
|
|
12299
|
-
if (
|
|
12300
|
-
|
|
14781
|
+
// Members that are global objects (`require("stream/web").ReadableStream
|
|
14782
|
+
// === globalThis.ReadableStream`) read in JavaScript sources as their
|
|
14783
|
+
// global spelling does.
|
|
14784
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr))) {
|
|
14785
|
+
const global = globalMemberValue(this, bi, loc);
|
|
14786
|
+
if (global)
|
|
14787
|
+
return global;
|
|
12301
14788
|
}
|
|
12302
14789
|
// A bare `fs.constants` read (not one of the baked bits above).
|
|
12303
14790
|
if (bi.member === "constants" && bi.module === "fs")
|
|
@@ -12334,6 +14821,10 @@ export class Lowerer {
|
|
|
12334
14821
|
return assertion;
|
|
12335
14822
|
if (bi.module === "util" && bi.member === "types")
|
|
12336
14823
|
return utilTypesModuleValue(this, loc);
|
|
14824
|
+
// util.inspect: the function custom inspect methods receive, one
|
|
14825
|
+
// identity per thread.
|
|
14826
|
+
if (bi.module === "util" && bi.member === "inspect")
|
|
14827
|
+
return { kind: "libCall", fn: "insp.inspectFunction", args: [], type: DYN, loc };
|
|
12337
14828
|
if (bi.module === "util/types" && builtinModuleFnOf(this, bi.module, bi.member))
|
|
12338
14829
|
return lowerUtilTypeValue(this, bi.member, loc);
|
|
12339
14830
|
if (bi.module === "util" && bi.member === "getSystemErrorMap")
|
|
@@ -12379,7 +14870,7 @@ export class Lowerer {
|
|
|
12379
14870
|
if (!fnName) {
|
|
12380
14871
|
fnName = keyedHelperName(this, `%builtin.value.${fn.valueFn ?? fn.fn}`, key);
|
|
12381
14872
|
this.builtinCallableValueFns.set(key, fnName);
|
|
12382
|
-
this.builtinCallableValueNames.set(fnName, display.slice(display.lastIndexOf(".") + 1));
|
|
14873
|
+
this.builtinCallableValueNames.set(fnName, fn.valueName ?? display.slice(display.lastIndexOf(".") + 1));
|
|
12383
14874
|
if (fn.valueLength !== undefined)
|
|
12384
14875
|
this.builtinCallableValueLengths.set(fnName, fn.valueLength);
|
|
12385
14876
|
const params = funcType.params.map((type, index) => ({
|
|
@@ -12462,6 +14953,19 @@ export class Lowerer {
|
|
|
12462
14953
|
}
|
|
12463
14954
|
return { kind: "closure", fnName, captures: [], type: funcType, loc };
|
|
12464
14955
|
}
|
|
14956
|
+
/** The name and length a builtin function's adapter boxes under: the ones
|
|
14957
|
+
* Node's function carries (`[Function: randomUUID]`). Empty for any other
|
|
14958
|
+
* value. */
|
|
14959
|
+
builtinFunctionIdentity(expr) {
|
|
14960
|
+
if (expr.kind !== "closure")
|
|
14961
|
+
return {};
|
|
14962
|
+
const name = this.builtinCallableValueNames.get(expr.fnName);
|
|
14963
|
+
const length = this.builtinCallableValueLengths.get(expr.fnName);
|
|
14964
|
+
return {
|
|
14965
|
+
...(name !== undefined ? { fnName: name } : {}),
|
|
14966
|
+
...(length !== undefined ? { fnLength: length } : {}),
|
|
14967
|
+
};
|
|
14968
|
+
}
|
|
12465
14969
|
isBuiltinCallableValue(expr) {
|
|
12466
14970
|
return (expr.kind === "closure" &&
|
|
12467
14971
|
[...this.builtinCallableValueFns.values()].some((name) => name === expr.fnName));
|