@scriptc/compiler 0.4.6 → 0.4.8
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/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +29 -6
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +57 -12
- package/ambient/node-fallback/http.d.ts +26 -18
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +25 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +95 -20
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +22 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +12 -1
- package/dist/backend/immutability.js +50 -4
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/immutability.test.js +95 -1
- package/dist/backend/immutability.test.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +18 -5
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +20 -2
- package/dist/backend/linker.js +221 -35
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +15 -6
- package/dist/backend/lld.js +24 -16
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +13 -5
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +50 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +34 -9
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +64 -3
- package/dist/backend/llvm/dyn.js +251 -15
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +68 -5
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +226 -77
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +138 -34
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +142 -10
- package/dist/backend/llvm/emitter.js +523 -73
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +38 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +237 -23
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +123 -12
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +59 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +2 -0
- package/dist/backend/llvm/integer-values.js +6 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +57 -1
- package/dist/backend/llvm/js-ic.js +389 -22
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +152 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +116 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +180 -27
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +139 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +67 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
- package/dist/backend/llvm/loop-entry-versions.js +43 -21
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +7 -1
- package/dist/backend/llvm/loop-state.js +26 -3
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
- package/dist/backend/llvm/map-number-lookup.js +7 -3
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +58 -17
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
- package/dist/backend/llvm/receiver-brackets.test.js +68 -0
- package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +147 -12
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/record-views.test.js +76 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +4 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +36 -3
- package/dist/backend/llvm/shapes.js +201 -16
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +4 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +10 -1
- package/dist/backend/llvm/speculative-integers.js +59 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +3 -3
- package/dist/backend/llvm/unwind-abi.js +8 -3
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +47 -3
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +94 -0
- package/dist/backend/native/executable.js +134 -10
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +10 -2
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +8 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +30 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +72 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +1 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-profile.d.ts +4 -1
- package/dist/backend/native-profile.js +12 -1
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +10 -0
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/publication.d.ts +4 -1
- package/dist/backend/publication.js +4 -2
- 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 +46 -7
- package/dist/backend/runtime-pack-core.js +37 -2
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +18 -1
- package/dist/backend/runtime-pack-native.js +138 -29
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.js +166 -4
- package/dist/backend/runtime-pack-native.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -0
- package/dist/backend/runtime-pack.js +25 -3
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +213 -12
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +8 -1
- package/dist/backend/vendor-archives.js +313 -8
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +60 -3
- package/dist/backend/vendor-inputs.js +109 -3
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +62 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +2 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +7 -1
- package/dist/compat/fetch-profile.js +25 -12
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/contracts/check.d.ts +3 -0
- package/dist/contracts/check.js +18 -5
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +14 -0
- package/dist/diagnostics/codes.js +14 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +68 -0
- package/dist/diagnostics/diagnostic.js +186 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.js +3 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +48 -0
- package/dist/executable/executable-cache.js +38 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +127 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +438 -234
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +24 -0
- package/dist/frontend/early-errors.js +836 -0
- package/dist/frontend/early-errors.js.map +1 -0
- package/dist/frontend/early-errors.test.d.ts +1 -0
- package/dist/frontend/early-errors.test.js +207 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +47 -0
- package/dist/frontend/input-tracker.js +173 -36
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +86 -2
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/js-inference.d.ts +2 -0
- package/dist/frontend/js-inference.js +18 -0
- package/dist/frontend/js-inference.js.map +1 -0
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +86 -4
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +13 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +41 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +565 -28
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
- package/dist/frontend/lowering/builtins/dates.js +23 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
- package/dist/frontend/lowering/builtins/environment.js +213 -2
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
- package/dist/frontend/lowering/builtins/filesystem.js +185 -16
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +42 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
- package/dist/frontend/lowering/builtins/operating-system.js +101 -20
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +18 -2
- package/dist/frontend/lowering/builtins/process.js +386 -25
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
- package/dist/frontend/lowering/builtins/querystring.js +202 -18
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +200 -38
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +60 -1
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +55 -13
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
- package/dist/frontend/lowering/builtins/v8.js +7 -5
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +180 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.js +5 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +59 -10
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +35 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/class-views.d.ts +13 -0
- package/dist/frontend/lowering/class-views.js +51 -0
- package/dist/frontend/lowering/class-views.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +15 -0
- package/dist/frontend/lowering/coercions/state.js +24 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +39 -2
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +37 -8
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +30 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +450 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
- package/dist/frontend/lowering/expressions/array-literals.js +88 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +216 -14
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +272 -11
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +173 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +195 -18
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
- package/dist/frontend/lowering/expressions/object-literals.js +951 -240
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
- package/dist/frontend/lowering/expressions/property-access.js +1141 -87
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +262 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +25 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +156 -22
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +6 -0
- package/dist/frontend/lowering/frozen-records.js +10 -4
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
- package/dist/frontend/lowering/frozen-records.test.js +44 -0
- package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
- package/dist/frontend/lowering/function-names.d.ts +9 -0
- package/dist/frontend/lowering/function-names.js +95 -0
- package/dist/frontend/lowering/function-names.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +42 -13
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +75 -0
- package/dist/frontend/lowering/generic-functions.js +790 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +15 -4
- package/dist/frontend/lowering/global-values.js +67 -9
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.js +34 -1
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +571 -9
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +25 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +140 -16
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +342 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -1
- package/dist/frontend/lowering/lower-calls.js +1354 -273
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-calls.test.js +121 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +36 -5
- package/dist/frontend/lowering/lower-classes.js +630 -89
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
- package/dist/frontend/lowering/lower-event-emitter.js +610 -98
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
- package/dist/frontend/lowering/lower-exprs.js +96 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +27 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +713 -92
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +135 -27
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +472 -67
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +463 -96
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.js +13 -1
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
- package/dist/frontend/lowering/lower-stdlib.js +77 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
- package/dist/frontend/lowering/lower-stmts.js +831 -136
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +126 -8
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +243 -48
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +363 -21
- package/dist/frontend/lowering/lowerer.js +1224 -129
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +19 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/module-namespace-elements.js +15 -0
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +2 -2
- package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
- package/dist/frontend/lowering/partial-assertions.js +189 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +221 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
- package/dist/frontend/lowering/private-statics.d.ts +46 -0
- package/dist/frontend/lowering/private-statics.js +322 -0
- package/dist/frontend/lowering/private-statics.js.map +1 -0
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +12 -1
- package/dist/frontend/lowering/record-sources.js +60 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.d.ts +4 -0
- package/dist/frontend/lowering/strict-equality.js +14 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +42 -1
- package/dist/frontend/lowering/surfaces.js +212 -71
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +136 -17
- package/dist/frontend/lowering/unit-journal.js +324 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +126 -3
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
- package/dist/frontend/lowering/unit-reuse.js +1008 -0
- package/dist/frontend/lowering/unit-reuse.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +12 -0
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-file-import.test.d.ts +1 -0
- package/dist/frontend/npm-file-import.test.js +76 -0
- package/dist/frontend/npm-file-import.test.js.map +1 -0
- package/dist/frontend/npm-static.js +95 -11
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/npm.d.ts +9 -0
- package/dist/frontend/npm.js +82 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/pipeline-native.js +2 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +9 -4
- package/dist/frontend/pipeline.js +162 -38
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-node.d.ts +3 -0
- package/dist/frontend/program-node.js +13 -6
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +71 -2
- package/dist/frontend/program.js +836 -411
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +4 -0
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.d.ts +14 -0
- package/dist/frontend/services.js +52 -2
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +61 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +5 -0
- package/dist/frontend/shape-inference/analyze.js +104 -4
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/domain.js +0 -1
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/index.js +5 -1
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/memo.d.ts +2 -1
- package/dist/frontend/shape-inference/memo.js +6 -2
- package/dist/frontend/shape-inference/memo.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.d.ts +1 -1
- package/dist/frontend/shape-inference/overlay.js +184 -4
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.js +11 -6
- package/dist/frontend/shape-inference/static-objects.js.map +1 -1
- package/dist/frontend/source-phase-imports.test.d.ts +1 -0
- package/dist/frontend/source-phase-imports.test.js +37 -0
- package/dist/frontend/source-phase-imports.test.js.map +1 -0
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +12 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.js +3 -5
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +13 -0
- package/dist/frontend/ts7/checker-backend.js +84 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +126 -2
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +22 -1
- package/dist/frontend/ts7/program-host.js +49 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +83 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.d.ts +16 -1
- package/dist/frontend/ts7/rpc-process.js +170 -92
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js +49 -21
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +956 -101
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +98 -11
- package/dist/frontend/type-mapper.js +770 -182
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/build.d.ts +3 -2
- package/dist/ir/build.js +4 -2
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +96 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +453 -26
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5350 -0
- package/dist/ir/codec.generated.js.map +1 -0
- package/dist/ir/codec.js +325 -0
- package/dist/ir/codec.js.map +1 -0
- package/dist/ir/codec.test.d.ts +1 -0
- package/dist/ir/codec.test.js +225 -0
- package/dist/ir/codec.test.js.map +1 -0
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +29 -10
- package/dist/ir/fields.generated.js +1039 -11
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/fields.test.js +46 -2
- package/dist/ir/fields.test.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +6 -4
- package/dist/ir/function-references.js +11 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +14 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-sources.js +4 -1
- package/dist/ir/inline-array-sources.js.map +1 -1
- package/dist/ir/inline-array-views.d.ts +13 -0
- package/dist/ir/inline-array-views.js +945 -0
- package/dist/ir/inline-array-views.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +7 -0
- package/dist/ir/inline-arrays.js +190 -55
- package/dist/ir/inline-arrays.js.map +1 -1
- package/dist/ir/inline-arrays.test.js +140 -2
- package/dist/ir/inline-arrays.test.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +130 -44
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +58 -25
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +37 -3
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/jsval.js +374 -63
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +96 -2
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.js +112 -9
- package/dist/ir/loop-entry-ranges.js.map +1 -1
- package/dist/ir/loop-entry-ranges.test.js +40 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -3
- package/dist/ir/parameter-versions.js +63 -40
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +139 -5
- package/dist/ir/runtime-features.js +397 -19
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +135 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +11 -2
- package/dist/ir/saturating-loop-jams.js +56 -16
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/saturating-loop-jams.test.js +39 -1
- package/dist/ir/saturating-loop-jams.test.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +40 -28
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/self-captures.test.js +15 -0
- package/dist/ir/self-captures.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +8 -2
- package/dist/ir/serialize.js +92 -24
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +170 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +46 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +4 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +49 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +26 -5
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +74 -28
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +63 -4
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +93 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.js +9 -2
- package/dist/native/toolchain.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +37 -1
- package/dist/node-islands/boundary.js +65 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +27 -1
- package/dist/node-islands/detect.js +475 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +175 -4
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/effect-gate.js +30 -20
- package/dist/node-islands/effect-gate.js.map +1 -1
- package/dist/node-islands/effect-gate.test.js +4 -1
- package/dist/node-islands/effect-gate.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/libnode.d.ts +1 -1
- package/dist/node-islands/libnode.js +1 -1
- package/dist/node-islands/libnode.js.map +1 -1
- package/dist/node-islands/modules.d.ts +28 -0
- package/dist/node-islands/modules.js +156 -0
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +105 -1
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/policy.js +2 -3
- package/dist/node-islands/policy.js.map +1 -1
- package/dist/node-islands/probe-recorder.d.ts +1 -0
- package/dist/node-islands/probe-recorder.js +596 -0
- package/dist/node-islands/probe-recorder.js.map +1 -0
- package/dist/node-islands/probe-recorder.test.d.ts +1 -0
- package/dist/node-islands/probe-recorder.test.js +80 -0
- package/dist/node-islands/probe-recorder.test.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +4 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +9 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +16 -1
- package/dist/node-islands/scan.js +110 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/node-islands/snapshot.d.ts +38 -1
- package/dist/node-islands/snapshot.js +165 -161
- package/dist/node-islands/snapshot.js.map +1 -1
- package/dist/node-islands/snapshot.test.js +63 -2
- package/dist/node-islands/snapshot.test.js.map +1 -1
- package/dist/node-islands/summary.js +8 -0
- package/dist/node-islands/summary.js.map +1 -1
- package/dist/node-islands/type-strip.d.ts +11 -0
- package/dist/node-islands/type-strip.js +157 -0
- package/dist/node-islands/type-strip.js.map +1 -0
- package/dist/node-islands/type-strip.test.d.ts +1 -0
- package/dist/node-islands/type-strip.test.js +31 -0
- package/dist/node-islands/type-strip.test.js.map +1 -0
- package/dist/project-config.d.ts +4 -0
- package/dist/project-config.js +19 -0
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +10 -0
- package/dist/project-config.test.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +221 -122
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shapeOverlayAnnotated } from "../shape-inference/index.js";
|
|
2
|
-
import { documentedParameter } from "./call-signatures.js";
|
|
2
|
+
import { documentedParameter, generatorParamsBindAtCall } from "./call-signatures.js";
|
|
3
3
|
import { staticNameBindings } from "./static-function-names.js";
|
|
4
4
|
import { positionTag } from "./structural-positions.js";
|
|
5
5
|
import { keyedHelperName } from "./stable-names.js";
|
|
@@ -8,6 +8,7 @@ import { heritageElementTarget, isHeritageTypeReference } from "../heritage-elem
|
|
|
8
8
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
9
9
|
import { BOOL, DYN, STRING, VOID, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
10
10
|
import { helperLoc, nodeThrowExpr } from "../../ir/build.js";
|
|
11
|
+
import { unsupportedDiag } from "../../diagnostics/diagnostic.js";
|
|
11
12
|
import { isJsSourceFile, locOf } from "../program.js";
|
|
12
13
|
import { typeKey } from "../type-mapper.js";
|
|
13
14
|
import { functionCanReturnUndefined } from "../function-completion.js";
|
|
@@ -22,6 +23,7 @@ import { isVarDeclared, jsBindingHasOpenWrites } from "./lower-stmts.js";
|
|
|
22
23
|
import { paramShapes, generatorMeta, funcTypeFromParamShapes, } from "./call-signatures.js";
|
|
23
24
|
import { fenceGenericSignatureResult, blockBodyOf, resolveInferredReturn, appendImplicitUndefinedReturn, hasExplicitJsDocReturn, promiseCarriesDyn, } from "./function-returns.js";
|
|
24
25
|
import { bindingNeverReassigned, stripValueWrappers } from "./binding-analysis.js";
|
|
26
|
+
import { declareContextLocal } from "./function-context.js";
|
|
25
27
|
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION, } from "./instantiation-path.js";
|
|
26
28
|
/** Defaults bind during inference; collection only resolves symbols in
|
|
27
29
|
* declaration order and preserves each declaration form's diagnostic. */
|
|
@@ -91,6 +93,45 @@ export function lowerGenericCall(lowerer, expr, info) {
|
|
|
91
93
|
? implicitCallInstance(lowerer, expr, info)
|
|
92
94
|
: genericCallInstance(lowerer, expr, info);
|
|
93
95
|
const args = lowerer.completeArgs(expr.arguments.nodes, instance.params, loc, expr);
|
|
96
|
+
if (info.captureMode === "env") {
|
|
97
|
+
// The environment form: a closure over this call site's boxes of the
|
|
98
|
+
// captured bindings (resolveKey threads them through any closures in
|
|
99
|
+
// between and boxes the origin), called at once. Arguments evaluate
|
|
100
|
+
// after the callee, as in JavaScript; building the closure only reads
|
|
101
|
+
// the boxes.
|
|
102
|
+
if (instance.params.some((p) => p.mode === "rest" || p.mode === "dynRest" || p.mode === "arguments")) {
|
|
103
|
+
lowerer.unsupported("SC1090", expr, `generic arrow/function-expression bindings with rest parameters that write the frames of their enclosing functions ('${info.baseName}')`);
|
|
104
|
+
}
|
|
105
|
+
const sources = info.captures.map((capture) => {
|
|
106
|
+
const local = lowerer.resolveKey(capture.symbol, expr);
|
|
107
|
+
if (local === null || !typeEquals(local.type, capture.type)) {
|
|
108
|
+
lowerer.unsupported("SC1090", expr, `generic arrow/function-expression bindings sharing '${capture.name}' with their enclosing function when its storage differs from its declared type ('${info.baseName}')`);
|
|
109
|
+
}
|
|
110
|
+
// An origin read from its own frame is not boxed by resolveKey; the
|
|
111
|
+
// closure needs the box (captureContextBinding's origin rule).
|
|
112
|
+
local.boxed = true;
|
|
113
|
+
return local.id;
|
|
114
|
+
});
|
|
115
|
+
const call = {
|
|
116
|
+
kind: "callValue",
|
|
117
|
+
callee: {
|
|
118
|
+
kind: "closure",
|
|
119
|
+
fnName: instance.name,
|
|
120
|
+
captures: sources,
|
|
121
|
+
type: funcTypeFromParamShapes(instance.params, instance.returnType),
|
|
122
|
+
loc,
|
|
123
|
+
},
|
|
124
|
+
args,
|
|
125
|
+
type: instance.returnType,
|
|
126
|
+
loc,
|
|
127
|
+
};
|
|
128
|
+
return guardEarlyCall(lowerer, info, expr, call);
|
|
129
|
+
}
|
|
130
|
+
// The enclosing-frame values follow the declared arguments, the order
|
|
131
|
+
// the instance takes them in (lowerGenericInstance).
|
|
132
|
+
for (const capture of info.captures ?? []) {
|
|
133
|
+
args.push(lowerer.lowerExprExpecting(capture.nameNode, capture.type));
|
|
134
|
+
}
|
|
94
135
|
const call = {
|
|
95
136
|
kind: "call",
|
|
96
137
|
callee: instance.name,
|
|
@@ -98,7 +139,7 @@ export function lowerGenericCall(lowerer, expr, info) {
|
|
|
98
139
|
type: instance.returnType,
|
|
99
140
|
loc,
|
|
100
141
|
};
|
|
101
|
-
return
|
|
142
|
+
return guardEarlyCall(lowerer, info, expr, call);
|
|
102
143
|
}
|
|
103
144
|
/** The instance a CALL of a generic function-like names: resolved
|
|
104
145
|
* signature → mapped param shapes/return → interned instance. Shared by
|
|
@@ -903,7 +944,10 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
903
944
|
let bodyReturn = isGenerator
|
|
904
945
|
? lowerer.genBodyReturnType(inst.returnType)
|
|
905
946
|
: lowerer.bodyReturnType(isAsync, inst.returnType);
|
|
906
|
-
|
|
947
|
+
// The environment form lowers as a LIFTED function: its captures arrive
|
|
948
|
+
// in the closure environment, never as parameters.
|
|
949
|
+
const envForm = info.captureMode === "env";
|
|
950
|
+
const fnCtx = newFnCtx(envForm, null, null, bodyReturn);
|
|
907
951
|
fnCtx.isAsync = isAsync;
|
|
908
952
|
// Instances lower on demand, on top of whichever caller reached them.
|
|
909
953
|
fnCtx.thisBoundary = true;
|
|
@@ -943,11 +987,43 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
943
987
|
const thisLocal = lowerer.declareThis(thisType);
|
|
944
988
|
params.push({ localId: thisLocal.id, name: "this", type: thisType });
|
|
945
989
|
}
|
|
990
|
+
// Environment form: one boxed capture entry per captured binding, in
|
|
991
|
+
// FrameCapture order (the call sites' closure caps[] order), keyed by
|
|
992
|
+
// the binding's symbol so the body (parameter defaults included)
|
|
993
|
+
// reads and writes the shared box. Pre-registering them also keeps
|
|
994
|
+
// resolution from walking past this instance's frame.
|
|
995
|
+
if (envForm) {
|
|
996
|
+
for (const capture of info.captures) {
|
|
997
|
+
const entry = declareContextLocal(fnCtx, capture.name, capture.type, capture.reassigned, undefined, undefined);
|
|
998
|
+
entry.boxed = true;
|
|
999
|
+
fnCtx.captureBySymbol.set(capture.symbol, entry);
|
|
1000
|
+
fnCtx.captures.push({ localId: entry.id, name: entry.name, type: entry.type });
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
// The enclosing-frame values travel as TRAILING parameters, after the
|
|
1004
|
+
// declared ones: a call lowers its arguments first (JavaScript's
|
|
1005
|
+
// order), then reads the captures. Binding each local to the captured
|
|
1006
|
+
// symbol is what lets the body resolve the reference; the locals are
|
|
1007
|
+
// bound before the declared parameters so that a default initializer
|
|
1008
|
+
// reading a capture resolves it too.
|
|
1009
|
+
const captureParams = [];
|
|
1010
|
+
for (const capture of envForm ? [] : (info.captures ?? [])) {
|
|
1011
|
+
const local = lowerer.declareLocal(capture.nameNode, capture.name, capture.type, false);
|
|
1012
|
+
captureParams.push({ localId: local.id, name: capture.name, type: capture.type });
|
|
1013
|
+
}
|
|
946
1014
|
// Default-param initializers lower per instance, with the bindings
|
|
947
1015
|
// threaded — a default mentioning T resolves like any body expression.
|
|
948
1016
|
const declared = lowerer.declareParams(decl.parameters.nodes, inst.params);
|
|
949
|
-
params.push(...declared.params);
|
|
950
|
-
|
|
1017
|
+
params.push(...declared.params, ...captureParams);
|
|
1018
|
+
// See lowerFunction: a generator binds its parameters at the CALL
|
|
1019
|
+
// exactly when that is observable. The receiver materialization
|
|
1020
|
+
// (`staticReceiver`) is call machinery, not parameter binding.
|
|
1021
|
+
const bindsAtCall = isGenerator && declared.prologue.length > 0 && generatorParamsBindAtCall(decl);
|
|
1022
|
+
const body = [
|
|
1023
|
+
...receiverInit,
|
|
1024
|
+
...declared.prologue,
|
|
1025
|
+
...(bindsAtCall ? [{ kind: "genBindBarrier", loc: locOf(decl) }] : []),
|
|
1026
|
+
];
|
|
951
1027
|
const bodyBlock = blockBodyOf(decl);
|
|
952
1028
|
if (bodyBlock) {
|
|
953
1029
|
body.push(...lowerer.lowerStmts(bodyBlock.statements.nodes));
|
|
@@ -1002,13 +1078,14 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
1002
1078
|
params,
|
|
1003
1079
|
returnType: bodyReturn,
|
|
1004
1080
|
locals: lowerer.ctx.locals,
|
|
1081
|
+
...(envForm ? { captures: fnCtx.captures } : {}),
|
|
1005
1082
|
body,
|
|
1006
1083
|
loc: locOf(decl),
|
|
1007
1084
|
};
|
|
1008
1085
|
if (isAsync)
|
|
1009
1086
|
fn.async = true;
|
|
1010
1087
|
if (fnCtx.generator)
|
|
1011
|
-
fn.generator = fnCtx.generator;
|
|
1088
|
+
fn.generator = bindsAtCall ? { ...fnCtx.generator, bindAtCall: true } : fnCtx.generator;
|
|
1012
1089
|
return fn;
|
|
1013
1090
|
}
|
|
1014
1091
|
finally {
|
|
@@ -1026,6 +1103,37 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
1026
1103
|
lowerer.erasingDepth--;
|
|
1027
1104
|
}
|
|
1028
1105
|
}
|
|
1106
|
+
/** Records that `instance` is one of `info`'s value instances (see
|
|
1107
|
+
* `valueInstances`). Written as its own statements rather than
|
|
1108
|
+
* `(x ??= new Set()).add(...)`: the self-hosted frontend fences a Set method
|
|
1109
|
+
* call on a non-Set receiver, and this compiler compiles its own source. */
|
|
1110
|
+
function noteValueInstance(info, instance) {
|
|
1111
|
+
let instances = info.valueInstances;
|
|
1112
|
+
if (instances === undefined) {
|
|
1113
|
+
instances = new Set();
|
|
1114
|
+
info.valueInstances = instances;
|
|
1115
|
+
}
|
|
1116
|
+
instances.add(instance);
|
|
1117
|
+
}
|
|
1118
|
+
/** Records the instance a pinned binding holds (`const f: Fn = ident`,
|
|
1119
|
+
* `const i = identity<number>`) under its declaration, so an identity
|
|
1120
|
+
* comparison between two bindings compares the closures they name
|
|
1121
|
+
* (checkGenericIdentityPins). */
|
|
1122
|
+
function notePinnedBinding(lowerer, ref, info, instance) {
|
|
1123
|
+
let node = ref;
|
|
1124
|
+
if (node.parent !== undefined &&
|
|
1125
|
+
ts.isPropertyAccessExpression(node.parent) &&
|
|
1126
|
+
node.parent.name === node)
|
|
1127
|
+
node = node.parent;
|
|
1128
|
+
while (node.parent !== undefined && ts.isParenthesizedExpression(node.parent))
|
|
1129
|
+
node = node.parent;
|
|
1130
|
+
const parent = node.parent;
|
|
1131
|
+
if (parent === undefined || !ts.isVariableDeclaration(parent) || parent.initializer !== node)
|
|
1132
|
+
return;
|
|
1133
|
+
if (!ts.isIdentifier(parent.name))
|
|
1134
|
+
return;
|
|
1135
|
+
lowerer.pinnedValueInstances.set(parent, { info, instance });
|
|
1136
|
+
}
|
|
1029
1137
|
/** A generic function taken as a VALUE, monomorphized by flow. A function
|
|
1030
1138
|
* value needs ONE concrete signature; tsc pins one at exactly two
|
|
1031
1139
|
* reference shapes — an instantiation EXPRESSION (`identity<number>`,
|
|
@@ -1046,10 +1154,18 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
1046
1154
|
// closure per function, so `f === f` holds like any declaration).
|
|
1047
1155
|
if (info.implicitParams) {
|
|
1048
1156
|
const inst = implicitDefaultInstance(lowerer, ref, info);
|
|
1157
|
+
noteValueInstance(info, inst.name);
|
|
1158
|
+
notePinnedBinding(lowerer, ref, info, inst.name);
|
|
1049
1159
|
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
1050
1160
|
lowerer.requireExactArityValue(ref, ref, inst.params, funcType);
|
|
1051
1161
|
lowerer.noteEdge(inst.name);
|
|
1052
|
-
return
|
|
1162
|
+
return aliasTdzGuard(lowerer, ref, {
|
|
1163
|
+
kind: "closure",
|
|
1164
|
+
fnName: inst.name,
|
|
1165
|
+
captures: [],
|
|
1166
|
+
type: funcType,
|
|
1167
|
+
loc,
|
|
1168
|
+
});
|
|
1053
1169
|
}
|
|
1054
1170
|
// Each call of the enclosing function makes a new function object for a
|
|
1055
1171
|
// binding declared inside it (`make() !== make()` when make returns
|
|
@@ -1087,9 +1203,110 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
1087
1203
|
target = callable[0][0];
|
|
1088
1204
|
}
|
|
1089
1205
|
}
|
|
1090
|
-
if (!target)
|
|
1091
|
-
|
|
1092
|
-
|
|
1206
|
+
if (!target) {
|
|
1207
|
+
target = identityComparisonPin(lowerer, ref);
|
|
1208
|
+
if (target)
|
|
1209
|
+
lowerer.genericIdentityPins.push({ info, node: ref });
|
|
1210
|
+
}
|
|
1211
|
+
// No concrete pin, or a pin that keeps its own type parameters (the slot
|
|
1212
|
+
// type is the generic signature itself, as a record field of a generic
|
|
1213
|
+
// method or a generic result flows): the value is the ERASED instance —
|
|
1214
|
+
// the one function JavaScript runs for every type argument — and each
|
|
1215
|
+
// instantiating call converts its arguments in and its result out
|
|
1216
|
+
// (lower-calls.ts, genericValueCall). `f === f` still holds: the erased
|
|
1217
|
+
// instance is one interned closure per declaration.
|
|
1218
|
+
if (!target || target.getTypeParameters().length > 0) {
|
|
1219
|
+
return aliasTdzGuard(lowerer, ref, guardEarlyBindingValue(lowerer, info, ref, erasedGenericFnValue(lowerer, ref, info)));
|
|
1220
|
+
}
|
|
1221
|
+
return aliasTdzGuard(lowerer, ref, guardEarlyBindingValue(lowerer, info, ref, pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned)));
|
|
1222
|
+
}
|
|
1223
|
+
/** A read of a generic ALIAS binding (`const h = id`) that can run before
|
|
1224
|
+
* the alias's declaration: the alias has no binding storage, so JavaScript
|
|
1225
|
+
* reaches its temporal dead zone through the flag the declaration sets —
|
|
1226
|
+
* the read throws before it hands out the function. Reads that can only
|
|
1227
|
+
* run after the declaration stay direct. A `var` alias reads `undefined`
|
|
1228
|
+
* there, which is no function value to hand out, so that read is
|
|
1229
|
+
* refused. */
|
|
1230
|
+
function aliasTdzGuard(lowerer, ref, value) {
|
|
1231
|
+
const presence = earlyAliasPresence(lowerer, ref);
|
|
1232
|
+
if (presence === undefined)
|
|
1233
|
+
return value;
|
|
1234
|
+
if (!presence.lexical)
|
|
1235
|
+
lowerer.unsupported("SC1090", ref, `generic 'var' aliases read as values before their declaration runs (Node reads undefined there; declare '${presence.name}' with const)`);
|
|
1236
|
+
const loc = value.loc;
|
|
1237
|
+
const flag = { kind: "varRef", localId: presence.flagId, type: BOOL, loc };
|
|
1238
|
+
return {
|
|
1239
|
+
kind: "seqExpr",
|
|
1240
|
+
stmts: [tdzCheck(flag, presence.name, loc)],
|
|
1241
|
+
result: value,
|
|
1242
|
+
type: value.type,
|
|
1243
|
+
loc,
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
/** The flag of a generic ALIAS binding that `node`, a reference to it,
|
|
1247
|
+
* can reach before its declaration runs — undefined when the node names no
|
|
1248
|
+
* alias, or names one whose declaration has already run. */
|
|
1249
|
+
function earlyAliasPresence(lowerer, node) {
|
|
1250
|
+
const ident = ts.isIdentifier(node)
|
|
1251
|
+
? node
|
|
1252
|
+
: ts.isExpressionWithTypeArguments(node) && ts.isIdentifier(node.expression)
|
|
1253
|
+
? node.expression
|
|
1254
|
+
: undefined;
|
|
1255
|
+
if (ident === undefined)
|
|
1256
|
+
return undefined;
|
|
1257
|
+
const symbol = lowerer.resolveValueSymbol(ident);
|
|
1258
|
+
const presence = symbol === null ? undefined : lowerer.genericAliasPresence.get(symbol);
|
|
1259
|
+
if (presence === undefined)
|
|
1260
|
+
return undefined;
|
|
1261
|
+
if (useRunsAfter(lowerer, presence.decl, ident, presence.ordering, new Set()))
|
|
1262
|
+
return undefined;
|
|
1263
|
+
return presence;
|
|
1264
|
+
}
|
|
1265
|
+
/** The value of a generic declaration read where no concrete instantiation
|
|
1266
|
+
* pins it: the declaration's erased instance's closure — the ONE function
|
|
1267
|
+
* JavaScript has, whose parameters and result are `unknown`, so arguments
|
|
1268
|
+
* entering it box (records, arrays, maps and sets as live capsules;
|
|
1269
|
+
* identity preserved) and results leaving it are checked against the
|
|
1270
|
+
* instantiated signature at the call. */
|
|
1271
|
+
function erasedGenericFnValue(lowerer, ref, info) {
|
|
1272
|
+
const loc = locOf(ref);
|
|
1273
|
+
const inst = erasedGenericInstance(lowerer, ref, info);
|
|
1274
|
+
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
1275
|
+
lowerer.requireExactArityValue(ref, ref, inst.params, funcType);
|
|
1276
|
+
lowerer.noteEdge(inst.name);
|
|
1277
|
+
return { kind: "closure", fnName: inst.name, captures: [], type: funcType, loc };
|
|
1278
|
+
}
|
|
1279
|
+
/** The pinning signature of a generic declaration compared by identity
|
|
1280
|
+
* (`held === ident`, `held !== ident`, and the loose forms): the other
|
|
1281
|
+
* operand's one concrete call signature. A held value of that type that is
|
|
1282
|
+
* this declaration is its instance at that signature, whose interned
|
|
1283
|
+
* closure is the one this reference names, so the comparison answers as
|
|
1284
|
+
* in JavaScript, provided the program holds the declaration at that one
|
|
1285
|
+
* signature only (checkGenericIdentityPins). Null when the other operand
|
|
1286
|
+
* has no single concrete call signature (another generic value, a union of
|
|
1287
|
+
* callables, a non-function). */
|
|
1288
|
+
function identityComparisonPin(lowerer, ref) {
|
|
1289
|
+
let operand = ref;
|
|
1290
|
+
if (ref.parent !== undefined &&
|
|
1291
|
+
ts.isPropertyAccessExpression(ref.parent) &&
|
|
1292
|
+
ref.parent.name === ref)
|
|
1293
|
+
operand = ref.parent;
|
|
1294
|
+
while (operand.parent !== undefined && ts.isParenthesizedExpression(operand.parent))
|
|
1295
|
+
operand = operand.parent;
|
|
1296
|
+
const bin = operand.parent;
|
|
1297
|
+
if (bin === undefined || !ts.isBinaryExpression(bin))
|
|
1298
|
+
return null;
|
|
1299
|
+
const op = bin.operatorToken.kind;
|
|
1300
|
+
if (op !== ts.SyntaxKind.EqualsEqualsEqualsToken &&
|
|
1301
|
+
op !== ts.SyntaxKind.ExclamationEqualsEqualsToken &&
|
|
1302
|
+
op !== ts.SyntaxKind.EqualsEqualsToken &&
|
|
1303
|
+
op !== ts.SyntaxKind.ExclamationEqualsToken)
|
|
1304
|
+
return null;
|
|
1305
|
+
const other = bin.left === operand ? bin.right : bin.left;
|
|
1306
|
+
const sigs = lowerer.checker.getCallSignatures(lowerer.typeOf(other));
|
|
1307
|
+
if (sigs.length !== 1 || sigs[0].getTypeParameters()?.length)
|
|
1308
|
+
return null;
|
|
1309
|
+
return sigs[0];
|
|
1093
1310
|
}
|
|
1094
1311
|
/** The value a generic binding declared inside a function stores when a
|
|
1095
1312
|
* nested function read it before the declaration lowered (`const read =
|
|
@@ -1173,6 +1390,8 @@ function pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned) {
|
|
|
1173
1390
|
if (info.typeParams.some((tp) => !bindings.get(tp)))
|
|
1174
1391
|
fenceUnpinned();
|
|
1175
1392
|
const inst = genericValueInstance(lowerer, ref, info, bindings);
|
|
1393
|
+
noteValueInstance(info, inst.name);
|
|
1394
|
+
notePinnedBinding(lowerer, ref, info, inst.name);
|
|
1176
1395
|
// The value's type is the completed ABI signature. Typed rest keeps its
|
|
1177
1396
|
// packed-array slot; dynRest stays hidden behind the rest marker.
|
|
1178
1397
|
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
@@ -1213,12 +1432,288 @@ export function erasedGenericInstance(lowerer, blame, info) {
|
|
|
1213
1432
|
try {
|
|
1214
1433
|
const instance = genericValueInstance(lowerer, blame, info, new Map(info.typeParams.map((tp) => [tp, DYN])));
|
|
1215
1434
|
instance.erased = true;
|
|
1435
|
+
noteValueInstance(info, instance.name);
|
|
1216
1436
|
return instance;
|
|
1217
1437
|
}
|
|
1218
1438
|
finally {
|
|
1219
1439
|
lowerer.erasingDepth--;
|
|
1220
1440
|
}
|
|
1221
1441
|
}
|
|
1442
|
+
/** After every body lowered: an identity comparison of a generic
|
|
1443
|
+
* declaration is exact only when the program holds the declaration as one
|
|
1444
|
+
* function object. Otherwise a held value may be another instance's
|
|
1445
|
+
* closure, where JavaScript has one function, so the comparison is
|
|
1446
|
+
* refused instead of answering false. */
|
|
1447
|
+
export function checkGenericIdentityPins(lowerer) {
|
|
1448
|
+
if (lowerer.genericIdentityCheckDone)
|
|
1449
|
+
return;
|
|
1450
|
+
lowerer.genericIdentityCheckDone = true;
|
|
1451
|
+
const seen = new Map();
|
|
1452
|
+
const report = (info, node, dynamic) => {
|
|
1453
|
+
let infos = seen.get(node);
|
|
1454
|
+
if (infos === undefined)
|
|
1455
|
+
seen.set(node, (infos = new Set()));
|
|
1456
|
+
if (infos.has(info))
|
|
1457
|
+
return;
|
|
1458
|
+
infos.add(info);
|
|
1459
|
+
const held = info.valueInstances?.size ?? 0;
|
|
1460
|
+
if (held <= 1)
|
|
1461
|
+
return;
|
|
1462
|
+
const through = dynamic ? " through a dynamic value" : "";
|
|
1463
|
+
lowerer.pushDiag(unsupportedDiag("SC1090", locOf(node), `comparing the generic function '${info.baseName}' by identity${through} while the program holds it at ${held} different signatures (each is a separate compiled function object; JavaScript has one) — compare against a value pinned once, or hold '${info.baseName}' at a single signature`));
|
|
1464
|
+
};
|
|
1465
|
+
for (const { info, node } of lowerer.genericIdentityPins)
|
|
1466
|
+
report(info, node, false);
|
|
1467
|
+
// Dynamic comparisons resolve their provenance only when some declaration
|
|
1468
|
+
// is held at more than one signature: the symbol lookups are the
|
|
1469
|
+
// expensive part, and every other program answers them all at one
|
|
1470
|
+
// instance. Recorded at lowering, resolved here so the pins' instance
|
|
1471
|
+
// sets are complete.
|
|
1472
|
+
let ambiguous = false;
|
|
1473
|
+
for (const info of lowerer.genericFnsBySymbol.values()) {
|
|
1474
|
+
if ((info.valueInstances?.size ?? 0) > 1) {
|
|
1475
|
+
ambiguous = true;
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (!ambiguous)
|
|
1480
|
+
return;
|
|
1481
|
+
for (const { node, left, right } of lowerer.dynIdentityComparisons) {
|
|
1482
|
+
for (const operand of [left, right]) {
|
|
1483
|
+
const info = genericDeclarationBehindValue(lowerer, operand);
|
|
1484
|
+
if (info)
|
|
1485
|
+
report(info, node, true);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
// A typed function-vs-function comparison (`g === h`) whose two operands
|
|
1489
|
+
// are pins of ONE declaration at different signatures: the closures the
|
|
1490
|
+
// operands name are different function objects, so the pointer compare
|
|
1491
|
+
// answers false while JavaScript has one function — a silent divergence.
|
|
1492
|
+
for (const { node, left, right, leftInstance, rightInstance, } of lowerer.pinnedIdentityComparisons) {
|
|
1493
|
+
const leftPin = pinnedInstanceBehind(lowerer, left, leftInstance);
|
|
1494
|
+
if (leftPin === null)
|
|
1495
|
+
continue;
|
|
1496
|
+
const rightPin = pinnedInstanceBehind(lowerer, right, rightInstance);
|
|
1497
|
+
if (rightPin === null || rightPin.info !== leftPin.info)
|
|
1498
|
+
continue;
|
|
1499
|
+
if (rightPin.instance === leftPin.instance)
|
|
1500
|
+
continue;
|
|
1501
|
+
let infos = seen.get(node);
|
|
1502
|
+
if (infos === undefined)
|
|
1503
|
+
seen.set(node, (infos = new Set()));
|
|
1504
|
+
if (infos.has(leftPin.info))
|
|
1505
|
+
continue;
|
|
1506
|
+
infos.add(leftPin.info);
|
|
1507
|
+
lowerer.pushDiag(unsupportedDiag("SC1090", locOf(node), `comparing two values of the generic function '${leftPin.info.baseName}' pinned at different signatures by identity (each pinned signature is a separate compiled function object; JavaScript has one) — hold '${leftPin.info.baseName}' at a single signature, or compare values pinned to the same signature`));
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
/** The value instance an identity operand names: the closure name it
|
|
1511
|
+
* lowered to when it is an inline pin (`identity<number>`), else the
|
|
1512
|
+
* binding it reads, resolved through casts and aliasing bindings. Null for
|
|
1513
|
+
* a value with no recorded pin (a call result, a parameter, a binding the
|
|
1514
|
+
* program rewrites). */
|
|
1515
|
+
function pinnedInstanceBehind(lowerer, node, directInstance) {
|
|
1516
|
+
let current = node;
|
|
1517
|
+
const seen = new Set();
|
|
1518
|
+
while (current !== undefined && !seen.has(current)) {
|
|
1519
|
+
seen.add(current);
|
|
1520
|
+
if (ts.isParenthesizedExpression(current) ||
|
|
1521
|
+
ts.isAsExpression(current) ||
|
|
1522
|
+
ts.isSatisfiesExpression(current) ||
|
|
1523
|
+
ts.isNonNullExpression(current) ||
|
|
1524
|
+
ts.isExpressionWithTypeArguments(current)) {
|
|
1525
|
+
current = current.expression;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (!ts.isIdentifier(current) && !ts.isPropertyAccessExpression(current))
|
|
1529
|
+
return null;
|
|
1530
|
+
const symbol = lowerer.checker.getSymbolAtLocation(ts.isPropertyAccessExpression(current) ? current.name : current);
|
|
1531
|
+
if (symbol === undefined)
|
|
1532
|
+
return null;
|
|
1533
|
+
const info = lowerer.genericFnsBySymbol.get(symbol);
|
|
1534
|
+
if (info !== undefined) {
|
|
1535
|
+
// The bare declaration itself: a pin only where the comparison
|
|
1536
|
+
// names it directly (the direct rule covers that shape).
|
|
1537
|
+
return directInstance === undefined ? null : { info, instance: directInstance };
|
|
1538
|
+
}
|
|
1539
|
+
const decl = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
1540
|
+
if (decl === undefined)
|
|
1541
|
+
return null;
|
|
1542
|
+
// A binding the program later rewrites may hold another function at
|
|
1543
|
+
// the comparison: resolve it, and alias it through its initializer,
|
|
1544
|
+
// only where it is never written.
|
|
1545
|
+
if (!holdsItsInitializer(lowerer, decl))
|
|
1546
|
+
return null;
|
|
1547
|
+
const recorded = lowerer.pinnedValueInstances.get(decl);
|
|
1548
|
+
if (recorded !== undefined)
|
|
1549
|
+
return recorded;
|
|
1550
|
+
current = decl
|
|
1551
|
+
.initializer;
|
|
1552
|
+
}
|
|
1553
|
+
return null;
|
|
1554
|
+
}
|
|
1555
|
+
/** Whether `decl` is a variable or property that keeps the value it starts
|
|
1556
|
+
* with: a variable with an identifier name that nothing writes, or a
|
|
1557
|
+
* readonly property its class never assigns (a constructor can). A
|
|
1558
|
+
* parameter's default is not its value: a call can pass any function for
|
|
1559
|
+
* it. */
|
|
1560
|
+
function holdsItsInitializer(lowerer, decl) {
|
|
1561
|
+
if (ts.isPropertyDeclaration(decl))
|
|
1562
|
+
return ((ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Readonly) !== 0 &&
|
|
1563
|
+
!classWritesField(decl));
|
|
1564
|
+
if (!ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name))
|
|
1565
|
+
return false;
|
|
1566
|
+
const binding = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1567
|
+
return binding !== undefined && bindingNeverReassigned(lowerer, binding, decl);
|
|
1568
|
+
}
|
|
1569
|
+
/** Whether the class that declares `field` assigns a property of its name
|
|
1570
|
+
* anywhere in its body: a readonly field can still be assigned in a
|
|
1571
|
+
* constructor or a static block. Any receiver counts, which only
|
|
1572
|
+
* over-approximates. */
|
|
1573
|
+
function classWritesField(field) {
|
|
1574
|
+
const name = field.name;
|
|
1575
|
+
if (!ts.isIdentifier(name) && !ts.isStringLiteral(name))
|
|
1576
|
+
return true;
|
|
1577
|
+
const text = name.text;
|
|
1578
|
+
const targets = (target) => {
|
|
1579
|
+
let e = target;
|
|
1580
|
+
while (ts.isParenthesizedExpression(e))
|
|
1581
|
+
e = e.expression;
|
|
1582
|
+
if (ts.isPropertyAccessExpression(e))
|
|
1583
|
+
return e.name.text === text;
|
|
1584
|
+
if (ts.isElementAccessExpression(e))
|
|
1585
|
+
return !ts.isStringLiteralLike(e.argumentExpression) || e.argumentExpression.text === text;
|
|
1586
|
+
return false;
|
|
1587
|
+
};
|
|
1588
|
+
let written = false;
|
|
1589
|
+
const visit = (node) => {
|
|
1590
|
+
if (written)
|
|
1591
|
+
return;
|
|
1592
|
+
if (ts.isBinaryExpression(node) &&
|
|
1593
|
+
node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
1594
|
+
node.operatorToken.kind <= ts.SyntaxKind.LastAssignment &&
|
|
1595
|
+
targets(node.left))
|
|
1596
|
+
written = true;
|
|
1597
|
+
else if ((ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node)) &&
|
|
1598
|
+
(node.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
1599
|
+
node.operator === ts.SyntaxKind.MinusMinusToken) &&
|
|
1600
|
+
targets(node.operand))
|
|
1601
|
+
written = true;
|
|
1602
|
+
else
|
|
1603
|
+
ts.forEachChild(node, visit);
|
|
1604
|
+
};
|
|
1605
|
+
if (field.parent !== undefined)
|
|
1606
|
+
visit(field.parent);
|
|
1607
|
+
return written;
|
|
1608
|
+
}
|
|
1609
|
+
/** The generic declaration whose value instance an expression names, when
|
|
1610
|
+
* the expression is a binding initialized (directly, or through casts,
|
|
1611
|
+
* aliasing bindings and property initializers) from that declaration. Used
|
|
1612
|
+
* where a comparison reads the value through `unknown`/`any`, so the
|
|
1613
|
+
* declaration is not syntactically at the compared site. */
|
|
1614
|
+
export function genericDeclarationBehindValue(lowerer, node,
|
|
1615
|
+
// A comparison answers for the VALUE the binding holds at that point, so
|
|
1616
|
+
// only a binding the program cannot reassign may stand for the
|
|
1617
|
+
// declaration its initializer reads.
|
|
1618
|
+
requireConst = false) {
|
|
1619
|
+
let current = node;
|
|
1620
|
+
const seen = new Set();
|
|
1621
|
+
while (current !== undefined && !seen.has(current)) {
|
|
1622
|
+
seen.add(current);
|
|
1623
|
+
if (ts.isParenthesizedExpression(current) ||
|
|
1624
|
+
ts.isAsExpression(current) ||
|
|
1625
|
+
ts.isSatisfiesExpression(current) ||
|
|
1626
|
+
ts.isNonNullExpression(current)) {
|
|
1627
|
+
current = current.expression;
|
|
1628
|
+
continue;
|
|
1629
|
+
}
|
|
1630
|
+
// An instantiation expression (`identity<number>`) names the
|
|
1631
|
+
// declaration its type arguments apply to.
|
|
1632
|
+
if (ts.isExpressionWithTypeArguments(current)) {
|
|
1633
|
+
current = current.expression;
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
if (!ts.isIdentifier(current) && !ts.isPropertyAccessExpression(current))
|
|
1637
|
+
return null;
|
|
1638
|
+
const symbol = lowerer.checker.getSymbolAtLocation(ts.isPropertyAccessExpression(current) ? current.name : current);
|
|
1639
|
+
if (symbol === undefined)
|
|
1640
|
+
return null;
|
|
1641
|
+
const info = lowerer.genericFnsBySymbol.get(symbol);
|
|
1642
|
+
if (info !== undefined)
|
|
1643
|
+
return info;
|
|
1644
|
+
const decl = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
1645
|
+
if (decl === undefined)
|
|
1646
|
+
return null;
|
|
1647
|
+
if (!ts.isVariableDeclaration(decl) && !ts.isPropertyDeclaration(decl) && !ts.isParameter(decl))
|
|
1648
|
+
return null;
|
|
1649
|
+
if (requireConst &&
|
|
1650
|
+
(!ts.isVariableDeclaration(decl) ||
|
|
1651
|
+
!ts.isVariableDeclarationList(decl.parent) ||
|
|
1652
|
+
(decl.parent.flags & ts.NodeFlags.Const) === 0))
|
|
1653
|
+
return null;
|
|
1654
|
+
current = decl.initializer;
|
|
1655
|
+
}
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
/** An identity comparison at the dynamic boundary (`unknown`/`any`
|
|
1659
|
+
* operands): when either operand reads a generic declaration's value
|
|
1660
|
+
* instance, the comparison is exact only while the program holds that
|
|
1661
|
+
* declaration at one signature (checkGenericIdentityPins). */
|
|
1662
|
+
export function noteDynamicIdentityComparison(lowerer, node, left, right) {
|
|
1663
|
+
// A function compared with a string, number, boolean, bigint or symbol
|
|
1664
|
+
// is unequal whichever instance it is, as in JavaScript.
|
|
1665
|
+
if (isPrimitiveTyped(lowerer, left) || isPrimitiveTyped(lowerer, right))
|
|
1666
|
+
return;
|
|
1667
|
+
// The only work done while lowering. No instance count can gate this:
|
|
1668
|
+
// a value reference's instance is interned when its binding settles,
|
|
1669
|
+
// which can be later than the comparison that reads it, so the notes
|
|
1670
|
+
// are resolved at the end of lowering, when every instance is known.
|
|
1671
|
+
if (mightNameBinding(left) || mightNameBinding(right))
|
|
1672
|
+
lowerer.dynIdentityComparisons.push({ node, left, right });
|
|
1673
|
+
}
|
|
1674
|
+
/** An identity comparison of two function-typed values (`g === h`), where
|
|
1675
|
+
* either side may name a value instance of a generic declaration: two pins
|
|
1676
|
+
* of one declaration at different signatures are separate compiled
|
|
1677
|
+
* closures, so the pointer compare would answer false where JavaScript
|
|
1678
|
+
* answers true (one function object). Resolved by
|
|
1679
|
+
* checkGenericIdentityPins, where every instance is known. */
|
|
1680
|
+
export function notePinnedIdentityComparison(lowerer, node, left, right, leftInstance, rightInstance) {
|
|
1681
|
+
if (mightNameBinding(left) || mightNameBinding(right))
|
|
1682
|
+
lowerer.pinnedIdentityComparisons.push({ node, left, right, leftInstance, rightInstance });
|
|
1683
|
+
}
|
|
1684
|
+
const PRIMITIVE_TYPE_FLAGS = ts.TypeFlags.StringLike |
|
|
1685
|
+
ts.TypeFlags.NumberLike |
|
|
1686
|
+
ts.TypeFlags.BooleanLike |
|
|
1687
|
+
ts.TypeFlags.BigIntLike |
|
|
1688
|
+
ts.TypeFlags.ESSymbolLike;
|
|
1689
|
+
/** Whether the checker types `node` as a string, number, boolean, bigint or
|
|
1690
|
+
* symbol (a union with any other member is not). */
|
|
1691
|
+
function isPrimitiveTyped(lowerer, node) {
|
|
1692
|
+
return (lowerer.typeOf(node).flags & PRIMITIVE_TYPE_FLAGS) !== 0;
|
|
1693
|
+
}
|
|
1694
|
+
/** Whether an expression could name a binding at all — an identifier or a
|
|
1695
|
+
* property access, through parentheses and casts. A literal, a call, an
|
|
1696
|
+
* operator expression: nothing to resolve. */
|
|
1697
|
+
function mightNameBinding(node) {
|
|
1698
|
+
let current = node;
|
|
1699
|
+
for (let hops = 0; hops < 16 && current !== undefined; hops++) {
|
|
1700
|
+
if (ts.isIdentifier(current) || ts.isPropertyAccessExpression(current))
|
|
1701
|
+
return true;
|
|
1702
|
+
if (ts.isExpressionWithTypeArguments(current)) {
|
|
1703
|
+
current = current.expression;
|
|
1704
|
+
continue;
|
|
1705
|
+
}
|
|
1706
|
+
if (ts.isParenthesizedExpression(current) ||
|
|
1707
|
+
ts.isAsExpression(current) ||
|
|
1708
|
+
ts.isNonNullExpression(current) ||
|
|
1709
|
+
ts.isSatisfiesExpression(current)) {
|
|
1710
|
+
current = current.expression;
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
return false;
|
|
1714
|
+
}
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1222
1717
|
/** The instance a pinned VALUE reference names: the declaration's modes
|
|
1223
1718
|
* over the DECLARED types mapped under the bindings (mapType's resolver
|
|
1224
1719
|
* substitutes — the instance-body trick), which is the same result the
|
|
@@ -2173,6 +2668,200 @@ function capturesEnclosingFrame(lowerer, fn, decl, scope) {
|
|
|
2173
2668
|
scan(scope);
|
|
2174
2669
|
return captures;
|
|
2175
2670
|
}
|
|
2671
|
+
/** Whether a captured value's type can change between two instantiations of
|
|
2672
|
+
* the enclosing generic scopes: true when a type parameter reaches the type
|
|
2673
|
+
* (directly, through a union, or as a type argument), and true for the shapes
|
|
2674
|
+
* whose contents the walk cannot name — a mapped type, an inferred object
|
|
2675
|
+
* literal, a signature — so those keep the fence they had. */
|
|
2676
|
+
function typeVariesWithEnclosingTypeParameters(lowerer, type) {
|
|
2677
|
+
const seen = new Set();
|
|
2678
|
+
const walk = (part, depth) => {
|
|
2679
|
+
if ((part.flags & ts.TypeFlags.TypeParameter) !== 0)
|
|
2680
|
+
return true;
|
|
2681
|
+
if (depth > 8)
|
|
2682
|
+
return true;
|
|
2683
|
+
if (seen.has(part))
|
|
2684
|
+
return false;
|
|
2685
|
+
seen.add(part);
|
|
2686
|
+
if (part.isUnionType())
|
|
2687
|
+
return ts.constituentTypes(part).some((p) => walk(p, depth + 1));
|
|
2688
|
+
if ((part.flags & ts.TypeFlags.Intersection) !== 0)
|
|
2689
|
+
return ts.constituentTypes(part).some((p) => walk(p, depth + 1));
|
|
2690
|
+
if (part.getAliasTypeArguments().some((p) => walk(p, depth + 1)))
|
|
2691
|
+
return true;
|
|
2692
|
+
// An indexed access, a conditional, a substitution or an index type is
|
|
2693
|
+
// resolved from a source type this walk would have to reduce.
|
|
2694
|
+
if ((part.flags &
|
|
2695
|
+
(ts.TypeFlags.Index |
|
|
2696
|
+
ts.TypeFlags.IndexedAccess |
|
|
2697
|
+
ts.TypeFlags.Conditional |
|
|
2698
|
+
ts.TypeFlags.Substitution)) !==
|
|
2699
|
+
0)
|
|
2700
|
+
return true;
|
|
2701
|
+
if ((part.flags & ts.TypeFlags.Object) === 0)
|
|
2702
|
+
return false;
|
|
2703
|
+
const flags = part.objectFlags;
|
|
2704
|
+
// A reference names its type arguments — a class instance, an interface,
|
|
2705
|
+
// an array, a tuple.
|
|
2706
|
+
if ((flags & ts.ObjectFlags.Reference) !== 0)
|
|
2707
|
+
return lowerer.checker
|
|
2708
|
+
.getTypeArguments(part)
|
|
2709
|
+
.some((p) => walk(p, depth + 1));
|
|
2710
|
+
// A mapped type reduces to its source's keys and type arguments.
|
|
2711
|
+
if ((flags & ts.ObjectFlags.Mapped) !== 0)
|
|
2712
|
+
return true;
|
|
2713
|
+
// An index signature names its value type directly, and its key is never
|
|
2714
|
+
// a type parameter: `{ [key: string]: T }` varies exactly as `T` does,
|
|
2715
|
+
// whether the type is an object literal's or a named one's.
|
|
2716
|
+
for (const info of lowerer.checker.getIndexInfosOfType(part)) {
|
|
2717
|
+
if (walk(info.type, depth + 1))
|
|
2718
|
+
return true;
|
|
2719
|
+
}
|
|
2720
|
+
// A nominal instance whose type arguments the reference test above did
|
|
2721
|
+
// not see carries none to miss.
|
|
2722
|
+
if ((flags & ts.ObjectFlags.ClassOrInterface) !== 0)
|
|
2723
|
+
return false;
|
|
2724
|
+
// An inferred object literal or a type alias's object type names its
|
|
2725
|
+
// members instead of type arguments: read them, with a bounded width so
|
|
2726
|
+
// a wide type cannot make this walk expensive.
|
|
2727
|
+
let budget = 0;
|
|
2728
|
+
for (const prop of lowerer.checker.getPropertiesOfType(part)) {
|
|
2729
|
+
if (++budget > 64)
|
|
2730
|
+
return true;
|
|
2731
|
+
if (walk(lowerer.checker.getTypeOfSymbol(prop), depth + 1))
|
|
2732
|
+
return true;
|
|
2733
|
+
}
|
|
2734
|
+
for (const sig of [
|
|
2735
|
+
...lowerer.checker.getCallSignatures(part),
|
|
2736
|
+
...lowerer.checker.getConstructSignatures(part),
|
|
2737
|
+
]) {
|
|
2738
|
+
for (const param of sig.getParameters()) {
|
|
2739
|
+
if (walk(lowerer.checker.getTypeOfSymbol(param), depth + 1))
|
|
2740
|
+
return true;
|
|
2741
|
+
}
|
|
2742
|
+
if (walk(lowerer.checker.getReturnTypeOfSignature(sig), depth + 1))
|
|
2743
|
+
return true;
|
|
2744
|
+
}
|
|
2745
|
+
return false;
|
|
2746
|
+
};
|
|
2747
|
+
return walk(type, 0);
|
|
2748
|
+
}
|
|
2749
|
+
/** The enclosing-frame VALUES `fn`, bound by `decl`, reads — in first-use
|
|
2750
|
+
* order, the order the instances take them as trailing parameters. The
|
|
2751
|
+
* shape is the one the instance body resolves: a binding declared by an
|
|
2752
|
+
* enclosing function (a local, a parameter, a local function or class).
|
|
2753
|
+
*
|
|
2754
|
+
* Module-scope declarations and the binding itself are reachable from the
|
|
2755
|
+
* module functions the instances compile to, so they are not captures; nor
|
|
2756
|
+
* are type-only declarations, whose mapping is static. `this`, `super`,
|
|
2757
|
+
* `arguments`, `new.target`, and an enclosing generic's type parameter
|
|
2758
|
+
* have no value a parameter can stand in for and stay fenced. A
|
|
2759
|
+
* reassigned binding is shared through the environment form instead of
|
|
2760
|
+
* copied. */
|
|
2761
|
+
function enclosingFrameCaptures(lowerer, fn, decl, scope, name) {
|
|
2762
|
+
const file = ts.getSourceFileOfNode(decl);
|
|
2763
|
+
const self = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
2764
|
+
const frameFence = () => lowerer.unsupported("SC1090", fn, `generic arrow/function-expression bindings that use the frames of their enclosing functions (the compiled instantiations of '${name}' are module functions and cannot capture its locals, parameters, type parameters or 'this' — pass them as arguments, or declare the binding at module scope)`);
|
|
2765
|
+
const captures = [];
|
|
2766
|
+
const seen = new Set();
|
|
2767
|
+
const scan = (n) => {
|
|
2768
|
+
if (n.kind === ts.SyntaxKind.ThisKeyword ||
|
|
2769
|
+
n.kind === ts.SyntaxKind.SuperKeyword ||
|
|
2770
|
+
ts.isMetaProperty(n)) {
|
|
2771
|
+
// Arrow bodies see the ENCLOSING this; function expressions
|
|
2772
|
+
// rebind their own — but a bare `this` there is untyped JS
|
|
2773
|
+
// dynamism either way. Reject both, cheaply and soundly.
|
|
2774
|
+
frameFence();
|
|
2775
|
+
}
|
|
2776
|
+
if (ts.isIdentifier(n)) {
|
|
2777
|
+
const s = lowerer.checker.getSymbolAtLocation(n);
|
|
2778
|
+
if (s === undefined) {
|
|
2779
|
+
if (n.text === "arguments")
|
|
2780
|
+
frameFence();
|
|
2781
|
+
}
|
|
2782
|
+
else if (s !== self && !seen.has(s)) {
|
|
2783
|
+
for (const d of s.declarations) {
|
|
2784
|
+
if (ts.getSourceFileOfNode(d) !== file || (d.pos >= fn.pos && d.end <= fn.end))
|
|
2785
|
+
continue;
|
|
2786
|
+
let enclosing = false;
|
|
2787
|
+
for (let p = d.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
2788
|
+
if (ts.isFunctionLike(p)) {
|
|
2789
|
+
enclosing = true;
|
|
2790
|
+
break;
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
if (!enclosing)
|
|
2794
|
+
continue;
|
|
2795
|
+
// A type parameter (of the enclosing function or class) keys
|
|
2796
|
+
// the enclosing instantiation; the instance would need that
|
|
2797
|
+
// frame's type arguments, which this binding cannot carry.
|
|
2798
|
+
if ((s.flags & ts.SymbolFlags.TypeParameter) !== 0)
|
|
2799
|
+
frameFence();
|
|
2800
|
+
// Type-only declarations cost no runtime slot.
|
|
2801
|
+
if ((s.flags & ts.SymbolFlags.Value) === 0)
|
|
2802
|
+
break;
|
|
2803
|
+
// A trailing-parameter COPY is exact only while the original
|
|
2804
|
+
// never changes; a binding written anywhere in the file puts the
|
|
2805
|
+
// whole binding in the environment form (GenericFnInfo.captureMode).
|
|
2806
|
+
const reassigned = !bindingNeverReassigned(lowerer, s, d);
|
|
2807
|
+
// ...and exact only once the original is INITIALIZED. A capture
|
|
2808
|
+
// declared after the binding could be read from a call that runs
|
|
2809
|
+
// before its initializer — a temporal dead zone JavaScript would
|
|
2810
|
+
// throw on. Declared before, the copy is always the initialized
|
|
2811
|
+
// value: reaching the binding's own declaration ran it.
|
|
2812
|
+
if (d.pos > decl.pos)
|
|
2813
|
+
frameFence();
|
|
2814
|
+
// The declaration's own identifier (a binding element's for a
|
|
2815
|
+
// destructured name): lowering it resolves the SYMBOL, so the
|
|
2816
|
+
// instance body reads the parameter we declare for it.
|
|
2817
|
+
const declaredName = d.name;
|
|
2818
|
+
const nameNode = declaredName !== undefined && ts.isIdentifier(declaredName) ? declaredName : d;
|
|
2819
|
+
const type = lowerer.irTypeOf(nameNode);
|
|
2820
|
+
captures.push({
|
|
2821
|
+
symbol: s,
|
|
2822
|
+
nameNode,
|
|
2823
|
+
name: ts.isIdentifier(nameNode) ? nameNode.text : ts.symbolName(s),
|
|
2824
|
+
type,
|
|
2825
|
+
reassigned,
|
|
2826
|
+
});
|
|
2827
|
+
seen.add(s);
|
|
2828
|
+
break;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
ts.forEachChild(n, scan);
|
|
2833
|
+
};
|
|
2834
|
+
scan(scope);
|
|
2835
|
+
// A capture's type is fixed when the info is registered, once per
|
|
2836
|
+
// binding, while an enclosing generic function or class re-lowers its
|
|
2837
|
+
// frame per instantiation: the second instantiation's value would have a
|
|
2838
|
+
// different type than the parameter the shared instance declares. The
|
|
2839
|
+
// fence is about that TYPE, not about genericity: a capture whose type
|
|
2840
|
+
// reads none of the enclosing type parameters is the same type in every
|
|
2841
|
+
// instantiation, and the instance reads it exactly (the getSlot shape:
|
|
2842
|
+
// a generic arrow closing over a Map and a counter inside a generic
|
|
2843
|
+
// provider function).
|
|
2844
|
+
if (captures.length > 0) {
|
|
2845
|
+
let genericEnclosing = false;
|
|
2846
|
+
for (let p = fn.parent; p && !ts.isSourceFile(p); p = p.parent) {
|
|
2847
|
+
if (!ts.isFunctionLike(p) && !ts.isClassLikeDeclaration(p))
|
|
2848
|
+
continue;
|
|
2849
|
+
const typeParameters = p
|
|
2850
|
+
.typeParameters;
|
|
2851
|
+
if (typeParameters !== undefined && typeParameters.nodes.length > 0) {
|
|
2852
|
+
genericEnclosing = true;
|
|
2853
|
+
break;
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
if (genericEnclosing) {
|
|
2857
|
+
for (const capture of captures) {
|
|
2858
|
+
if (typeVariesWithEnclosingTypeParameters(lowerer, lowerer.typeOf(capture.nameNode)))
|
|
2859
|
+
frameFence();
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return captures;
|
|
2864
|
+
}
|
|
2176
2865
|
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
2177
2866
|
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
2178
2867
|
* bindingGenericFnInfoOf shape: the info enters genericFnsBySymbol under
|
|
@@ -2345,14 +3034,19 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2345
3034
|
const name = decl.name.text;
|
|
2346
3035
|
if (fnNode.asteriskToken)
|
|
2347
3036
|
lowerer.unsupported("SC1071", fnNode);
|
|
2348
|
-
// Inside a function, the compiled instances are module functions
|
|
2349
|
-
// the initializer
|
|
3037
|
+
// Inside a function, the compiled instances are module functions: the
|
|
3038
|
+
// values the initializer reads from the enclosing frame travel as
|
|
3039
|
+
// trailing parameters (FrameCapture), or through a closure environment
|
|
3040
|
+
// when one of them is reassigned (captureMode). `this`, `arguments` and
|
|
3041
|
+
// an enclosing generic's type parameters have no value to pass and stay
|
|
3042
|
+
// fenced.
|
|
2350
3043
|
let functionScoped = false;
|
|
3044
|
+
let captures;
|
|
2351
3045
|
for (let n = decl.parent; n !== undefined && !ts.isSourceFile(n); n = n.parent) {
|
|
2352
3046
|
if (ts.isFunctionLike(n)) {
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
3047
|
+
const found = enclosingFrameCaptures(lowerer, fnNode, decl, fnNode, name);
|
|
3048
|
+
if (found.length > 0)
|
|
3049
|
+
captures = found;
|
|
2356
3050
|
functionScoped = true;
|
|
2357
3051
|
break;
|
|
2358
3052
|
}
|
|
@@ -2394,6 +3088,8 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2394
3088
|
typeParams,
|
|
2395
3089
|
instances: new Map(),
|
|
2396
3090
|
...(functionScoped ? { functionScoped: true } : {}),
|
|
3091
|
+
...(captures ? { captures } : {}),
|
|
3092
|
+
...(captures?.some((capture) => capture.reassigned) ? { captureMode: "env" } : {}),
|
|
2397
3093
|
bindingDecl: decl,
|
|
2398
3094
|
};
|
|
2399
3095
|
lowerer.bindingGenericFns.set(fnNode, info);
|
|
@@ -2572,8 +3268,13 @@ function guardEarlyBindingCall(lowerer, info, expr, call) {
|
|
|
2572
3268
|
type: call.type,
|
|
2573
3269
|
loc,
|
|
2574
3270
|
};
|
|
2575
|
-
|
|
2576
|
-
|
|
3271
|
+
return earlyUnassignedCall(lowerer, call, flag, info.baseName, loc);
|
|
3272
|
+
}
|
|
3273
|
+
/** A call whose callee is an unassigned `var` binding — or a `var` alias
|
|
3274
|
+
* — before its initializer runs: arguments first, in order, then the
|
|
3275
|
+
* check. Node evaluates them before it finds the callee is not
|
|
3276
|
+
* callable. */
|
|
3277
|
+
function earlyUnassignedCall(lowerer, call, flag, name, loc) {
|
|
2577
3278
|
const stmts = [];
|
|
2578
3279
|
const args = call.args.map((arg) => {
|
|
2579
3280
|
const id = `%earlyCallArg.${lowerer.ctx.locals.length}`;
|
|
@@ -2588,7 +3289,7 @@ function guardEarlyBindingCall(lowerer, info, expr, call) {
|
|
|
2588
3289
|
kind: "ternary",
|
|
2589
3290
|
cond: flag,
|
|
2590
3291
|
then: { ...call, args },
|
|
2591
|
-
else_: nodeThrowExpr(1, "", `${
|
|
3292
|
+
else_: nodeThrowExpr(1, "", `${name} is not a function`, call.type, loc),
|
|
2592
3293
|
type: call.type,
|
|
2593
3294
|
loc,
|
|
2594
3295
|
},
|
|
@@ -2614,6 +3315,29 @@ function guardEarlyBindingValue(lowerer, info, ref, value) {
|
|
|
2614
3315
|
loc,
|
|
2615
3316
|
};
|
|
2616
3317
|
}
|
|
3318
|
+
/** A call of a generic binding or ALIAS that can run before the
|
|
3319
|
+
* declaration. Through an ALIAS (`h(3)`), JavaScript reads the alias first:
|
|
3320
|
+
* a `let`/`const` alias is in its temporal dead zone, so the call throws
|
|
3321
|
+
* before the arguments evaluate, while a `var` alias is `undefined`, so the
|
|
3322
|
+
* arguments run and the call throws "is not a function" — the alias names
|
|
3323
|
+
* no binding the callee could have read, so no check of the aliased
|
|
3324
|
+
* binding's own flag applies. Other calls check the binding's flag. */
|
|
3325
|
+
function guardEarlyCall(lowerer, info, expr, call) {
|
|
3326
|
+
const presence = earlyAliasPresence(lowerer, expr.expression);
|
|
3327
|
+
if (presence === undefined)
|
|
3328
|
+
return guardEarlyBindingCall(lowerer, info, expr, call);
|
|
3329
|
+
const loc = call.loc;
|
|
3330
|
+
const flag = { kind: "varRef", localId: presence.flagId, type: BOOL, loc };
|
|
3331
|
+
if (!presence.lexical)
|
|
3332
|
+
return earlyUnassignedCall(lowerer, call, flag, presence.name, loc);
|
|
3333
|
+
return {
|
|
3334
|
+
kind: "seqExpr",
|
|
3335
|
+
stmts: [tdzCheck(flag, presence.name, loc)],
|
|
3336
|
+
result: guardEarlyBindingCall(lowerer, info, expr, call),
|
|
3337
|
+
type: call.type,
|
|
3338
|
+
loc,
|
|
3339
|
+
};
|
|
3340
|
+
}
|
|
2617
3341
|
/** The presence flag a use that can run before the declaration checks.
|
|
2618
3342
|
* Only module-scope bindings have one: a binding inside a function would
|
|
2619
3343
|
* need a per-call flag that its closures share. */
|
|
@@ -2671,8 +3395,56 @@ export function bindingGenericFnAliasInfoOf(lowerer, decl) {
|
|
|
2671
3395
|
const name = decl.name.text;
|
|
2672
3396
|
requireStableGenericBinding(lowerer, decl, sym, name);
|
|
2673
3397
|
lowerer.genericFnsBySymbol.set(sym, target);
|
|
3398
|
+
noteAliasPresence(lowerer, decl, sym, name);
|
|
2674
3399
|
return target;
|
|
2675
3400
|
}
|
|
3401
|
+
/** Records the temporal-dead-zone flag of a module-scope alias whose reads
|
|
3402
|
+
* can run before its declaration — a hoisted function called during module
|
|
3403
|
+
* evaluation reads the binding while JavaScript still has it in its dead
|
|
3404
|
+
* zone, and the alias has no storage of its own to throw from. The
|
|
3405
|
+
* declaration statement sets the flag (genericAliasPresenceStore) and the
|
|
3406
|
+
* early reads check it. Aliases declared inside functions keep the
|
|
3407
|
+
* existing fences: a per-call flag would need a closure shared with every
|
|
3408
|
+
* reader. */
|
|
3409
|
+
function noteAliasPresence(lowerer, decl, symbol, name) {
|
|
3410
|
+
const stmt = decl.parent?.parent;
|
|
3411
|
+
const list = stmt?.parent;
|
|
3412
|
+
if (stmt === undefined || list === undefined)
|
|
3413
|
+
return;
|
|
3414
|
+
if (!ts.isSourceFile(list) && !ts.isModuleBlock(list))
|
|
3415
|
+
return;
|
|
3416
|
+
const nameNode = decl.name;
|
|
3417
|
+
const ordering = new Map();
|
|
3418
|
+
const early = bindingReferences(lowerer, ts.getSourceFileOfNode(decl), symbol, nameNode).some((ref) => !useRunsAfter(lowerer, decl, ref, ordering, new Set()));
|
|
3419
|
+
if (!early)
|
|
3420
|
+
return;
|
|
3421
|
+
const flagId = `%g.${lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(lowerer, stmt, decl) + name)}%initialized`;
|
|
3422
|
+
lowerer.globalsList.push({ id: flagId, name: "%initialized", type: BOOL, mutable: true });
|
|
3423
|
+
lowerer.genericAliasPresence.set(symbol, {
|
|
3424
|
+
flagId,
|
|
3425
|
+
name,
|
|
3426
|
+
decl,
|
|
3427
|
+
lexical: !isVarDeclared(decl),
|
|
3428
|
+
ordering,
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
/** The statement that records a generic alias's declaration as run, for
|
|
3432
|
+
* an alias with a presence flag. */
|
|
3433
|
+
export function genericAliasPresenceStore(lowerer, decl) {
|
|
3434
|
+
if (!ts.isIdentifier(decl.name))
|
|
3435
|
+
return null;
|
|
3436
|
+
const symbol = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
3437
|
+
const presence = symbol === undefined ? undefined : lowerer.genericAliasPresence.get(symbol);
|
|
3438
|
+
if (presence === undefined)
|
|
3439
|
+
return null;
|
|
3440
|
+
const loc = locOf(decl);
|
|
3441
|
+
return {
|
|
3442
|
+
kind: "assign",
|
|
3443
|
+
localId: presence.flagId,
|
|
3444
|
+
value: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
3445
|
+
loc,
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
2676
3448
|
/** Static resolution stands in for the receiver's runtime value, so an
|
|
2677
3449
|
* object-literal generic-method receiver must provably HOLD the defining
|
|
2678
3450
|
* literal: a direct read of a binding whose initializer IS that literal
|