@scriptc/compiler 0.4.6 → 0.4.7
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/events.d.ts +6 -1
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +54 -10
- package/ambient/node-fallback/http.d.ts +3 -1
- package/ambient/node-fallback/net.d.ts +19 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/scriptc-node-fallback.d.ts +58 -13
- package/dist/backend/executable-features.js +13 -0
- 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.js +2 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.d.ts +11 -0
- package/dist/backend/linker.js +31 -3
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +7 -2
- package/dist/backend/lld.js +5 -3
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +10 -4
- package/dist/backend/lld.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.js +6 -5
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +53 -1
- package/dist/backend/llvm/dyn.js +221 -9
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +1 -1
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +148 -50
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +39 -19
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +29 -2
- package/dist/backend/llvm/emitter.js +86 -7
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +20 -4
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +209 -16
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +94 -11
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +42 -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-ic.d.ts +38 -0
- package/dist/backend/llvm/js-ic.js +295 -1
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +20 -0
- 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-process.js +136 -24
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +70 -0
- 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/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 +20 -2
- package/dist/backend/llvm/loop-state.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 +52 -11
- package/dist/backend/llvm/map-number-lookup.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/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +139 -10
- 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-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +3 -0
- package/dist/backend/llvm/shapes.js +18 -3
- 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/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.js +1 -1
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +54 -0
- package/dist/backend/native/executable.js +87 -5
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +5 -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.js +3 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +43 -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 +31 -7
- package/dist/backend/runtime-pack-core.js +21 -1
- 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 +3 -11
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/vendor-archives.d.ts +4 -1
- package/dist/backend/vendor-archives.js +264 -3
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +36 -0
- package/dist/backend/vendor-inputs.js +42 -0
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +28 -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 +23 -10
- 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/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +6 -0
- package/dist/diagnostics/codes.js +6 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +50 -0
- package/dist/diagnostics/diagnostic.js +142 -3
- 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/executable/executable-cache.d.ts +29 -0
- package/dist/executable/executable-cache.js +18 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +5 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +271 -18
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +14 -0
- package/dist/frontend/early-errors.js +305 -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 +42 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +23 -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/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +65 -1
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.js +9 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/builtin-namespaces.js +19 -2
- package/dist/frontend/lowering/builtin-namespaces.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 +50 -10
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.js +5 -1
- package/dist/frontend/lowering/builtins/child-process.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.js +47 -16
- 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/module-calls.js +39 -2
- 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/operating-system.d.ts +3 -2
- package/dist/frontend/lowering/builtins/operating-system.js +5 -4
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +17 -1
- package/dist/frontend/lowering/builtins/process.js +285 -19
- package/dist/frontend/lowering/builtins/process.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.js +21 -3
- 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 +20 -1
- 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/call-signatures.js +77 -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-dynamic-dispatch.d.ts +5 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +114 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.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-runtime-statics.js +15 -0
- package/dist/frontend/lowering/class-runtime-statics.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 +54 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +7 -0
- package/dist/frontend/lowering/coercions/state.js +7 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +60 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +29 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +132 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +16 -5
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +16 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +4 -0
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +11 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +53 -0
- package/dist/frontend/lowering/containers/callback-arguments.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/expressions/array-literals.d.ts +14 -0
- package/dist/frontend/lowering/expressions/array-literals.js +26 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +104 -12
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +121 -4
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +143 -3
- 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.js +25 -1
- 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 +778 -229
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +66 -20
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +31 -0
- package/dist/frontend/lowering/expressions/property-access.js +796 -12
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +29 -1
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +17 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +132 -17
- 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 +5 -3
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +49 -0
- package/dist/frontend/lowering/generic-functions.js +365 -7
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-values.d.ts +9 -0
- package/dist/frontend/lowering/global-values.js +44 -0
- 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/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +546 -5
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +14 -0
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +110 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +332 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +22 -1
- package/dist/frontend/lowering/lower-calls.js +427 -48
- 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 +78 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +16 -5
- package/dist/frontend/lowering/lower-classes.js +168 -51
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +9 -0
- package/dist/frontend/lowering/lower-event-emitter.js +383 -41
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +14 -0
- package/dist/frontend/lowering/lower-exprs.js +25 -0
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +80 -33
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +87 -25
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +456 -61
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +160 -9
- 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 +32 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +21 -4
- package/dist/frontend/lowering/lower-stmts.js +580 -103
- 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 +133 -21
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +139 -3
- package/dist/frontend/lowering/lowerer.js +579 -43
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +1 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- 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/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/partial-assertions.d.ts +39 -0
- package/dist/frontend/lowering/partial-assertions.js +195 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +220 -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-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/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/surfaces.d.ts +27 -0
- package/dist/frontend/lowering/surfaces.js +135 -62
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +128 -17
- package/dist/frontend/lowering/unit-journal.js +310 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +91 -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/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 +17 -2
- package/dist/frontend/npm-static.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 +4 -0
- package/dist/frontend/pipeline.js +68 -7
- package/dist/frontend/pipeline.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 +9 -0
- package/dist/frontend/program.js +159 -7
- package/dist/frontend/program.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.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 +116 -2
- 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/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.js +70 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +7 -2
- package/dist/frontend/type-mapper.js +148 -1
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +152 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/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 +53 -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 +211 -10
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5274 -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/fields.generated.d.ts +20 -10
- package/dist/ir/fields.generated.js +1031 -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/function-references.d.ts +5 -4
- package/dist/ir/function-references.js +8 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -0
- package/dist/ir/function-references.test.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 +944 -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/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +75 -44
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +28 -20
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +10 -2
- 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/parameter-versions.d.ts +2 -1
- package/dist/ir/parameter-versions.js +3 -1
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +60 -1
- package/dist/ir/runtime-features.js +277 -2
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +165 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/saturating-loop-jams.d.ts +8 -1
- package/dist/ir/saturating-loop-jams.js +46 -7
- 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/self-captures.js +8 -1
- 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 +3 -2
- package/dist/ir/serialize.js +6 -2
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.js +82 -4
- 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/ir-policy.js +3 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cache.js +2 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +8 -2
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/prepare.js +32 -3
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +53 -3
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +88 -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 +25 -1
- package/dist/node-islands/boundary.js +28 -2
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/detect.d.ts +18 -1
- package/dist/node-islands/detect.js +365 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +151 -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/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.test.js +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +4 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +7 -1
- package/dist/node-islands/scan.js +51 -2
- 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/package.json +20 -20
- package/surface-manifest.json +43 -11
|
@@ -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 guardEarlyBindingCall(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,
|
|
@@ -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,10 +987,34 @@ 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);
|
|
1017
|
+
params.push(...declared.params, ...captureParams);
|
|
950
1018
|
const body = [...receiverInit, ...declared.prologue];
|
|
951
1019
|
const bodyBlock = blockBodyOf(decl);
|
|
952
1020
|
if (bodyBlock) {
|
|
@@ -1002,6 +1070,7 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
1002
1070
|
params,
|
|
1003
1071
|
returnType: bodyReturn,
|
|
1004
1072
|
locals: lowerer.ctx.locals,
|
|
1073
|
+
...(envForm ? { captures: fnCtx.captures } : {}),
|
|
1005
1074
|
body,
|
|
1006
1075
|
loc: locOf(decl),
|
|
1007
1076
|
};
|
|
@@ -1026,6 +1095,18 @@ export function lowerGenericInstance(lowerer, info, inst) {
|
|
|
1026
1095
|
lowerer.erasingDepth--;
|
|
1027
1096
|
}
|
|
1028
1097
|
}
|
|
1098
|
+
/** Records that `instance` is one of `info`'s value instances (see
|
|
1099
|
+
* `valueInstances`). Written as its own statements rather than
|
|
1100
|
+
* `(x ??= new Set()).add(...)`: the self-hosted frontend fences a Set method
|
|
1101
|
+
* call on a non-Set receiver, and this compiler compiles its own source. */
|
|
1102
|
+
function noteValueInstance(info, instance) {
|
|
1103
|
+
let instances = info.valueInstances;
|
|
1104
|
+
if (instances === undefined) {
|
|
1105
|
+
instances = new Set();
|
|
1106
|
+
info.valueInstances = instances;
|
|
1107
|
+
}
|
|
1108
|
+
instances.add(instance);
|
|
1109
|
+
}
|
|
1029
1110
|
/** A generic function taken as a VALUE, monomorphized by flow. A function
|
|
1030
1111
|
* value needs ONE concrete signature; tsc pins one at exactly two
|
|
1031
1112
|
* reference shapes — an instantiation EXPRESSION (`identity<number>`,
|
|
@@ -1046,6 +1127,7 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
1046
1127
|
// closure per function, so `f === f` holds like any declaration).
|
|
1047
1128
|
if (info.implicitParams) {
|
|
1048
1129
|
const inst = implicitDefaultInstance(lowerer, ref, info);
|
|
1130
|
+
noteValueInstance(info, inst.name);
|
|
1049
1131
|
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
1050
1132
|
lowerer.requireExactArityValue(ref, ref, inst.params, funcType);
|
|
1051
1133
|
lowerer.noteEdge(inst.name);
|
|
@@ -1087,10 +1169,47 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
1087
1169
|
target = callable[0][0];
|
|
1088
1170
|
}
|
|
1089
1171
|
}
|
|
1172
|
+
if (!target) {
|
|
1173
|
+
target = identityComparisonPin(lowerer, ref);
|
|
1174
|
+
if (target)
|
|
1175
|
+
lowerer.genericIdentityPins.push({ info, node: ref });
|
|
1176
|
+
}
|
|
1090
1177
|
if (!target)
|
|
1091
1178
|
fenceUnpinned();
|
|
1092
1179
|
return guardEarlyBindingValue(lowerer, info, ref, pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned));
|
|
1093
1180
|
}
|
|
1181
|
+
/** The pinning signature of a generic declaration compared by identity
|
|
1182
|
+
* (`held === ident`, `held !== ident`, and the loose forms): the other
|
|
1183
|
+
* operand's one concrete call signature. A held value of that type that is
|
|
1184
|
+
* this declaration is its instance at that signature, whose interned
|
|
1185
|
+
* closure is the one this reference names, so the comparison answers as
|
|
1186
|
+
* in JavaScript, provided the program holds the declaration at that one
|
|
1187
|
+
* signature only (checkGenericIdentityPins). Null when the other operand
|
|
1188
|
+
* has no single concrete call signature (another generic value, a union of
|
|
1189
|
+
* callables, a non-function). */
|
|
1190
|
+
function identityComparisonPin(lowerer, ref) {
|
|
1191
|
+
let operand = ref;
|
|
1192
|
+
if (ref.parent !== undefined &&
|
|
1193
|
+
ts.isPropertyAccessExpression(ref.parent) &&
|
|
1194
|
+
ref.parent.name === ref)
|
|
1195
|
+
operand = ref.parent;
|
|
1196
|
+
while (operand.parent !== undefined && ts.isParenthesizedExpression(operand.parent))
|
|
1197
|
+
operand = operand.parent;
|
|
1198
|
+
const bin = operand.parent;
|
|
1199
|
+
if (bin === undefined || !ts.isBinaryExpression(bin))
|
|
1200
|
+
return null;
|
|
1201
|
+
const op = bin.operatorToken.kind;
|
|
1202
|
+
if (op !== ts.SyntaxKind.EqualsEqualsEqualsToken &&
|
|
1203
|
+
op !== ts.SyntaxKind.ExclamationEqualsEqualsToken &&
|
|
1204
|
+
op !== ts.SyntaxKind.EqualsEqualsToken &&
|
|
1205
|
+
op !== ts.SyntaxKind.ExclamationEqualsToken)
|
|
1206
|
+
return null;
|
|
1207
|
+
const other = bin.left === operand ? bin.right : bin.left;
|
|
1208
|
+
const sigs = lowerer.checker.getCallSignatures(lowerer.typeOf(other));
|
|
1209
|
+
if (sigs.length !== 1 || sigs[0].getTypeParameters()?.length)
|
|
1210
|
+
return null;
|
|
1211
|
+
return sigs[0];
|
|
1212
|
+
}
|
|
1094
1213
|
/** The value a generic binding declared inside a function stores when a
|
|
1095
1214
|
* nested function read it before the declaration lowered (`const read =
|
|
1096
1215
|
* () => id; const id: (x: number) => number = <T>(x: T): T => x`): such
|
|
@@ -1173,6 +1292,7 @@ function pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned) {
|
|
|
1173
1292
|
if (info.typeParams.some((tp) => !bindings.get(tp)))
|
|
1174
1293
|
fenceUnpinned();
|
|
1175
1294
|
const inst = genericValueInstance(lowerer, ref, info, bindings);
|
|
1295
|
+
noteValueInstance(info, inst.name);
|
|
1176
1296
|
// The value's type is the completed ABI signature. Typed rest keeps its
|
|
1177
1297
|
// packed-array slot; dynRest stays hidden behind the rest marker.
|
|
1178
1298
|
const funcType = funcTypeFromParamShapes(inst.params, inst.returnType);
|
|
@@ -1213,12 +1333,139 @@ export function erasedGenericInstance(lowerer, blame, info) {
|
|
|
1213
1333
|
try {
|
|
1214
1334
|
const instance = genericValueInstance(lowerer, blame, info, new Map(info.typeParams.map((tp) => [tp, DYN])));
|
|
1215
1335
|
instance.erased = true;
|
|
1336
|
+
noteValueInstance(info, instance.name);
|
|
1216
1337
|
return instance;
|
|
1217
1338
|
}
|
|
1218
1339
|
finally {
|
|
1219
1340
|
lowerer.erasingDepth--;
|
|
1220
1341
|
}
|
|
1221
1342
|
}
|
|
1343
|
+
/** After every body lowered: an identity comparison of a generic
|
|
1344
|
+
* declaration is exact only when the program holds the declaration as one
|
|
1345
|
+
* function object. Otherwise a held value may be another instance's
|
|
1346
|
+
* closure, where JavaScript has one function, so the comparison is
|
|
1347
|
+
* refused instead of answering false. */
|
|
1348
|
+
export function checkGenericIdentityPins(lowerer) {
|
|
1349
|
+
if (lowerer.genericIdentityCheckDone)
|
|
1350
|
+
return;
|
|
1351
|
+
lowerer.genericIdentityCheckDone = true;
|
|
1352
|
+
const seen = new Map();
|
|
1353
|
+
const report = (info, node, dynamic) => {
|
|
1354
|
+
let infos = seen.get(node);
|
|
1355
|
+
if (infos === undefined)
|
|
1356
|
+
seen.set(node, (infos = new Set()));
|
|
1357
|
+
if (infos.has(info))
|
|
1358
|
+
return;
|
|
1359
|
+
infos.add(info);
|
|
1360
|
+
const held = info.valueInstances?.size ?? 0;
|
|
1361
|
+
if (held <= 1)
|
|
1362
|
+
return;
|
|
1363
|
+
const through = dynamic ? " through a dynamic value" : "";
|
|
1364
|
+
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`));
|
|
1365
|
+
};
|
|
1366
|
+
for (const { info, node } of lowerer.genericIdentityPins)
|
|
1367
|
+
report(info, node, false);
|
|
1368
|
+
// Dynamic comparisons resolve their provenance only when some declaration
|
|
1369
|
+
// is held at more than one signature: the symbol lookups are the
|
|
1370
|
+
// expensive part, and every other program answers them all at one
|
|
1371
|
+
// instance. Recorded at lowering, resolved here so the pins' instance
|
|
1372
|
+
// sets are complete.
|
|
1373
|
+
let ambiguous = false;
|
|
1374
|
+
for (const info of lowerer.genericFnsBySymbol.values()) {
|
|
1375
|
+
if ((info.valueInstances?.size ?? 0) > 1) {
|
|
1376
|
+
ambiguous = true;
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
if (!ambiguous)
|
|
1381
|
+
return;
|
|
1382
|
+
for (const { node, left, right } of lowerer.dynIdentityComparisons) {
|
|
1383
|
+
for (const operand of [left, right]) {
|
|
1384
|
+
const info = genericDeclarationBehindValue(lowerer, operand);
|
|
1385
|
+
if (info)
|
|
1386
|
+
report(info, node, true);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/** The generic declaration whose value instance an expression names, when
|
|
1391
|
+
* the expression is a binding initialized (directly, or through casts,
|
|
1392
|
+
* aliasing bindings and property initializers) from that declaration. Used
|
|
1393
|
+
* where a comparison reads the value through `unknown`/`any`, so the
|
|
1394
|
+
* declaration is not syntactically at the compared site. */
|
|
1395
|
+
export function genericDeclarationBehindValue(lowerer, node) {
|
|
1396
|
+
let current = node;
|
|
1397
|
+
const seen = new Set();
|
|
1398
|
+
while (current !== undefined && !seen.has(current)) {
|
|
1399
|
+
seen.add(current);
|
|
1400
|
+
if (ts.isParenthesizedExpression(current) ||
|
|
1401
|
+
ts.isAsExpression(current) ||
|
|
1402
|
+
ts.isSatisfiesExpression(current) ||
|
|
1403
|
+
ts.isNonNullExpression(current)) {
|
|
1404
|
+
current = current.expression;
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
if (!ts.isIdentifier(current) && !ts.isPropertyAccessExpression(current))
|
|
1408
|
+
return null;
|
|
1409
|
+
const symbol = lowerer.checker.getSymbolAtLocation(ts.isPropertyAccessExpression(current) ? current.name : current);
|
|
1410
|
+
if (symbol === undefined)
|
|
1411
|
+
return null;
|
|
1412
|
+
const info = lowerer.genericFnsBySymbol.get(symbol);
|
|
1413
|
+
if (info !== undefined)
|
|
1414
|
+
return info;
|
|
1415
|
+
const decl = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
1416
|
+
if (decl === undefined)
|
|
1417
|
+
return null;
|
|
1418
|
+
if (!ts.isVariableDeclaration(decl) && !ts.isPropertyDeclaration(decl) && !ts.isParameter(decl))
|
|
1419
|
+
return null;
|
|
1420
|
+
current = decl.initializer;
|
|
1421
|
+
}
|
|
1422
|
+
return null;
|
|
1423
|
+
}
|
|
1424
|
+
/** An identity comparison at the dynamic boundary (`unknown`/`any`
|
|
1425
|
+
* operands): when either operand reads a generic declaration's value
|
|
1426
|
+
* instance, the comparison is exact only while the program holds that
|
|
1427
|
+
* declaration at one signature (checkGenericIdentityPins). */
|
|
1428
|
+
export function noteDynamicIdentityComparison(lowerer, node, left, right) {
|
|
1429
|
+
// A function compared with a string, number, boolean, bigint or symbol
|
|
1430
|
+
// is unequal whichever instance it is, as in JavaScript.
|
|
1431
|
+
if (isPrimitiveTyped(lowerer, left) || isPrimitiveTyped(lowerer, right))
|
|
1432
|
+
return;
|
|
1433
|
+
// The only work done while lowering. No instance count can gate this:
|
|
1434
|
+
// a value reference's instance is interned when its binding settles,
|
|
1435
|
+
// which can be later than the comparison that reads it, so the notes
|
|
1436
|
+
// are resolved at the end of lowering, when every instance is known.
|
|
1437
|
+
if (mightNameBinding(left) || mightNameBinding(right))
|
|
1438
|
+
lowerer.dynIdentityComparisons.push({ node, left, right });
|
|
1439
|
+
}
|
|
1440
|
+
const PRIMITIVE_TYPE_FLAGS = ts.TypeFlags.StringLike |
|
|
1441
|
+
ts.TypeFlags.NumberLike |
|
|
1442
|
+
ts.TypeFlags.BooleanLike |
|
|
1443
|
+
ts.TypeFlags.BigIntLike |
|
|
1444
|
+
ts.TypeFlags.ESSymbolLike;
|
|
1445
|
+
/** Whether the checker types `node` as a string, number, boolean, bigint or
|
|
1446
|
+
* symbol (a union with any other member is not). */
|
|
1447
|
+
function isPrimitiveTyped(lowerer, node) {
|
|
1448
|
+
return (lowerer.typeOf(node).flags & PRIMITIVE_TYPE_FLAGS) !== 0;
|
|
1449
|
+
}
|
|
1450
|
+
/** Whether an expression could name a binding at all — an identifier or a
|
|
1451
|
+
* property access, through parentheses and casts. A literal, a call, an
|
|
1452
|
+
* operator expression: nothing to resolve. */
|
|
1453
|
+
function mightNameBinding(node) {
|
|
1454
|
+
let current = node;
|
|
1455
|
+
for (let hops = 0; hops < 16 && current !== undefined; hops++) {
|
|
1456
|
+
if (ts.isIdentifier(current) || ts.isPropertyAccessExpression(current))
|
|
1457
|
+
return true;
|
|
1458
|
+
if (ts.isParenthesizedExpression(current) ||
|
|
1459
|
+
ts.isAsExpression(current) ||
|
|
1460
|
+
ts.isNonNullExpression(current) ||
|
|
1461
|
+
ts.isSatisfiesExpression(current)) {
|
|
1462
|
+
current = current.expression;
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
return false;
|
|
1466
|
+
}
|
|
1467
|
+
return false;
|
|
1468
|
+
}
|
|
1222
1469
|
/** The instance a pinned VALUE reference names: the declaration's modes
|
|
1223
1470
|
* over the DECLARED types mapped under the bindings (mapType's resolver
|
|
1224
1471
|
* substitutes — the instance-body trick), which is the same result the
|
|
@@ -2173,6 +2420,110 @@ function capturesEnclosingFrame(lowerer, fn, decl, scope) {
|
|
|
2173
2420
|
scan(scope);
|
|
2174
2421
|
return captures;
|
|
2175
2422
|
}
|
|
2423
|
+
/** The enclosing-frame VALUES `fn`, bound by `decl`, reads — in first-use
|
|
2424
|
+
* order, the order the instances take them as trailing parameters. The
|
|
2425
|
+
* shape is the one the instance body resolves: a binding declared by an
|
|
2426
|
+
* enclosing function (a local, a parameter, a local function or class).
|
|
2427
|
+
*
|
|
2428
|
+
* Module-scope declarations and the binding itself are reachable from the
|
|
2429
|
+
* module functions the instances compile to, so they are not captures; nor
|
|
2430
|
+
* are type-only declarations, whose mapping is static. `this`, `super`,
|
|
2431
|
+
* `arguments`, `new.target`, and an enclosing generic's type parameter
|
|
2432
|
+
* have no value a parameter can stand in for and stay fenced. A
|
|
2433
|
+
* reassigned binding is shared through the environment form instead of
|
|
2434
|
+
* copied. */
|
|
2435
|
+
function enclosingFrameCaptures(lowerer, fn, decl, scope, name) {
|
|
2436
|
+
const file = ts.getSourceFileOfNode(decl);
|
|
2437
|
+
const self = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
2438
|
+
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)`);
|
|
2439
|
+
const captures = [];
|
|
2440
|
+
const seen = new Set();
|
|
2441
|
+
const scan = (n) => {
|
|
2442
|
+
if (n.kind === ts.SyntaxKind.ThisKeyword ||
|
|
2443
|
+
n.kind === ts.SyntaxKind.SuperKeyword ||
|
|
2444
|
+
ts.isMetaProperty(n)) {
|
|
2445
|
+
// Arrow bodies see the ENCLOSING this; function expressions
|
|
2446
|
+
// rebind their own — but a bare `this` there is untyped JS
|
|
2447
|
+
// dynamism either way. Reject both, cheaply and soundly.
|
|
2448
|
+
frameFence();
|
|
2449
|
+
}
|
|
2450
|
+
if (ts.isIdentifier(n)) {
|
|
2451
|
+
const s = lowerer.checker.getSymbolAtLocation(n);
|
|
2452
|
+
if (s === undefined) {
|
|
2453
|
+
if (n.text === "arguments")
|
|
2454
|
+
frameFence();
|
|
2455
|
+
}
|
|
2456
|
+
else if (s !== self && !seen.has(s)) {
|
|
2457
|
+
for (const d of s.declarations) {
|
|
2458
|
+
if (ts.getSourceFileOfNode(d) !== file || (d.pos >= fn.pos && d.end <= fn.end))
|
|
2459
|
+
continue;
|
|
2460
|
+
let enclosing = false;
|
|
2461
|
+
for (let p = d.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
2462
|
+
if (ts.isFunctionLike(p)) {
|
|
2463
|
+
enclosing = true;
|
|
2464
|
+
break;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
if (!enclosing)
|
|
2468
|
+
continue;
|
|
2469
|
+
// A type parameter (of the enclosing function or class) keys
|
|
2470
|
+
// the enclosing instantiation; the instance would need that
|
|
2471
|
+
// frame's type arguments, which this binding cannot carry.
|
|
2472
|
+
if ((s.flags & ts.SymbolFlags.TypeParameter) !== 0)
|
|
2473
|
+
frameFence();
|
|
2474
|
+
// Type-only declarations cost no runtime slot.
|
|
2475
|
+
if ((s.flags & ts.SymbolFlags.Value) === 0)
|
|
2476
|
+
break;
|
|
2477
|
+
// A trailing-parameter COPY is exact only while the original
|
|
2478
|
+
// never changes; a binding written anywhere in the file puts the
|
|
2479
|
+
// whole binding in the environment form (GenericFnInfo.captureMode).
|
|
2480
|
+
const reassigned = !bindingNeverReassigned(lowerer, s, d);
|
|
2481
|
+
// ...and exact only once the original is INITIALIZED. A capture
|
|
2482
|
+
// declared after the binding could be read from a call that runs
|
|
2483
|
+
// before its initializer — a temporal dead zone JavaScript would
|
|
2484
|
+
// throw on. Declared before, the copy is always the initialized
|
|
2485
|
+
// value: reaching the binding's own declaration ran it.
|
|
2486
|
+
if (d.pos > decl.pos)
|
|
2487
|
+
frameFence();
|
|
2488
|
+
// The declaration's own identifier (a binding element's for a
|
|
2489
|
+
// destructured name): lowering it resolves the SYMBOL, so the
|
|
2490
|
+
// instance body reads the parameter we declare for it.
|
|
2491
|
+
const declaredName = d.name;
|
|
2492
|
+
const nameNode = declaredName !== undefined && ts.isIdentifier(declaredName) ? declaredName : d;
|
|
2493
|
+
const type = lowerer.irTypeOf(nameNode);
|
|
2494
|
+
captures.push({
|
|
2495
|
+
symbol: s,
|
|
2496
|
+
nameNode,
|
|
2497
|
+
name: ts.isIdentifier(nameNode) ? nameNode.text : ts.symbolName(s),
|
|
2498
|
+
type,
|
|
2499
|
+
reassigned,
|
|
2500
|
+
});
|
|
2501
|
+
seen.add(s);
|
|
2502
|
+
break;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
ts.forEachChild(n, scan);
|
|
2507
|
+
};
|
|
2508
|
+
scan(scope);
|
|
2509
|
+
// A capture's type is fixed when the info is registered, once per
|
|
2510
|
+
// binding, while an enclosing generic function or class re-lowers its
|
|
2511
|
+
// frame per instantiation: the second instantiation's value would have a
|
|
2512
|
+
// different type than the parameter the shared instance declares.
|
|
2513
|
+
// Generic enclosing scopes keep the fence; non-generic ones carry no
|
|
2514
|
+
// type argument for the instance to miss.
|
|
2515
|
+
if (captures.length > 0) {
|
|
2516
|
+
for (let p = fn.parent; p && !ts.isSourceFile(p); p = p.parent) {
|
|
2517
|
+
if (!ts.isFunctionLike(p) && !ts.isClassLikeDeclaration(p))
|
|
2518
|
+
continue;
|
|
2519
|
+
const typeParameters = p
|
|
2520
|
+
.typeParameters;
|
|
2521
|
+
if (typeParameters !== undefined && typeParameters.nodes.length > 0)
|
|
2522
|
+
frameFence();
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
return captures;
|
|
2526
|
+
}
|
|
2176
2527
|
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
2177
2528
|
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
2178
2529
|
* bindingGenericFnInfoOf shape: the info enters genericFnsBySymbol under
|
|
@@ -2345,14 +2696,19 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2345
2696
|
const name = decl.name.text;
|
|
2346
2697
|
if (fnNode.asteriskToken)
|
|
2347
2698
|
lowerer.unsupported("SC1071", fnNode);
|
|
2348
|
-
// Inside a function, the compiled instances are module functions
|
|
2349
|
-
// the initializer
|
|
2699
|
+
// Inside a function, the compiled instances are module functions: the
|
|
2700
|
+
// values the initializer reads from the enclosing frame travel as
|
|
2701
|
+
// trailing parameters (FrameCapture), or through a closure environment
|
|
2702
|
+
// when one of them is reassigned (captureMode). `this`, `arguments` and
|
|
2703
|
+
// an enclosing generic's type parameters have no value to pass and stay
|
|
2704
|
+
// fenced.
|
|
2350
2705
|
let functionScoped = false;
|
|
2706
|
+
let captures;
|
|
2351
2707
|
for (let n = decl.parent; n !== undefined && !ts.isSourceFile(n); n = n.parent) {
|
|
2352
2708
|
if (ts.isFunctionLike(n)) {
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2709
|
+
const found = enclosingFrameCaptures(lowerer, fnNode, decl, fnNode, name);
|
|
2710
|
+
if (found.length > 0)
|
|
2711
|
+
captures = found;
|
|
2356
2712
|
functionScoped = true;
|
|
2357
2713
|
break;
|
|
2358
2714
|
}
|
|
@@ -2394,6 +2750,8 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2394
2750
|
typeParams,
|
|
2395
2751
|
instances: new Map(),
|
|
2396
2752
|
...(functionScoped ? { functionScoped: true } : {}),
|
|
2753
|
+
...(captures ? { captures } : {}),
|
|
2754
|
+
...(captures?.some((capture) => capture.reassigned) ? { captureMode: "env" } : {}),
|
|
2397
2755
|
bindingDecl: decl,
|
|
2398
2756
|
};
|
|
2399
2757
|
lowerer.bindingGenericFns.set(fnNode, info);
|