@geastack/compiler 1.0.33 → 1.0.34
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/README.md +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +14 -6
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +9 -4
- package/dist/ir/model.d.ts +39 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.js +6 -1
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +99 -13
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2399 -676
- package/dist/representation/any-null-record-members.d.ts +0 -41
- package/dist/representation/any-null-record-members.js +0 -115
- package/dist/semantics/any-null-member-declarations.d.ts +0 -32
- package/dist/semantics/any-null-member-declarations.js +0 -90
- package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
- package/dist/semantics/normalize/fresh-array-result.js +0 -125
|
@@ -1595,8 +1595,8 @@ moduleRecords = emptyCommonJsModuleRecordCensus) => {
|
|
|
1595
1595
|
return upstream;
|
|
1596
1596
|
// `Array.isArray(pattern) ? pattern[0] : p` reads the tuple the
|
|
1597
1597
|
// predicate narrowed to, not the receiver's declared union: resolving
|
|
1598
|
-
// the receiver through its declaration loses the narrowing, and
|
|
1599
|
-
// trie
|
|
1598
|
+
// the receiver through its declaration loses the narrowing, and a
|
|
1599
|
+
// trie router's `key` stayed `any` and was boxed into every lookup.
|
|
1600
1600
|
const predicateNarrowed = arrayPredicateNarrowedElementTypeOf(checker, node);
|
|
1601
1601
|
if (predicateNarrowed)
|
|
1602
1602
|
return predicateNarrowed;
|
|
@@ -2413,7 +2413,16 @@ hostProvided = noHostProvidedNames) => {
|
|
|
2413
2413
|
const contracts = contractsFor(declaration) ?? [];
|
|
2414
2414
|
const contractTypes = [];
|
|
2415
2415
|
for (const contract of contracts) {
|
|
2416
|
-
|
|
2416
|
+
// An intrinsic Array frame holds only while the method and the indices
|
|
2417
|
+
// it reads are the intrinsic's. The obligation joins the answer being
|
|
2418
|
+
// published: inference asks under `protocolLedger.capture`, and the
|
|
2419
|
+
// seal below re-asks an answer that already carries it.
|
|
2420
|
+
if ('intrinsic' in contract) {
|
|
2421
|
+
if (!protocolLedger)
|
|
2422
|
+
return { refused: 'callback-contract-intrinsic-protocol-unavailable' };
|
|
2423
|
+
protocolLedger.include(contract.requirements);
|
|
2424
|
+
}
|
|
2425
|
+
const type = callbackContractParameterType(checker, contract, parameterIndex, propagatingTypeAt);
|
|
2417
2426
|
if (!type)
|
|
2418
2427
|
return { refused: 'callback-contract-has-no-parameter' };
|
|
2419
2428
|
contractTypes.push(type);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourceNativeIterable } from './source-native-iterable.js';
|
|
1
2
|
import type { AbsentGlobalCensus } from './absent-globals.js';
|
|
2
3
|
import type { DeadMethodCopies } from './dead-method-copies.js';
|
|
3
4
|
import type { ArgumentsObjectCensus } from './arguments-objects.js';
|
|
@@ -51,6 +52,7 @@ import type { SourceCallableReadonlySet } from './flow/source-callable-readonly-
|
|
|
51
52
|
* them into one.
|
|
52
53
|
*/
|
|
53
54
|
export interface ProducerContext {
|
|
55
|
+
readonly nativeIterableAt?: (source: ts.Expression, consumer: ts.CallExpression | null) => SourceNativeIterable | null;
|
|
54
56
|
readonly readonlyCallableSetAt?: (access: ts.PropertyAccessExpression | ts.ElementAccessExpression) => SourceCallableReadonlySet | null;
|
|
55
57
|
/** Exact source slots after shared Object.assign and prototype obligations are discharged. `describedKeysOf` is the
|
|
56
58
|
* caller's representation key authority for a source no closed family describes (see `SourceValueSession.ownAssignmentOf`). */
|
|
@@ -237,6 +239,9 @@ export interface ProducerContext {
|
|
|
237
239
|
readonly absentRequirePackageOf: (specifier: string, containingFile: string) => boolean;
|
|
238
240
|
/** The Program's canonical source-file object for that resolver's target path. */
|
|
239
241
|
readonly sourceFileOf: (fileName: string) => ts.SourceFile | null;
|
|
242
|
+
/** Actual project-selected automatic JSX runtime, through the same frontend
|
|
243
|
+
* resolver. Absent/ambiguous per-file overrides carry no provider witness. */
|
|
244
|
+
readonly jsxRuntimeModuleOf?: (containingFile: string) => ts.SourceFile | null;
|
|
240
245
|
/**
|
|
241
246
|
* Which ambient globals an installed host declares it does NOT provide.
|
|
242
247
|
*
|
|
@@ -17,6 +17,8 @@ import ts from 'typescript';
|
|
|
17
17
|
export const bindingKindOf = (declaration) => {
|
|
18
18
|
if (ts.isFunctionExpression(declaration) && declaration.name)
|
|
19
19
|
return { mutable: false, temporalDeadZone: false };
|
|
20
|
+
if (ts.isClassDeclaration(declaration) || (ts.isClassExpression(declaration) && declaration.name))
|
|
21
|
+
return { mutable: ts.isClassDeclaration(declaration), temporalDeadZone: true };
|
|
20
22
|
const list = ts.isVariableDeclaration(declaration) ? declaration.parent : undefined;
|
|
21
23
|
if (!list || !ts.isVariableDeclarationList(list))
|
|
22
24
|
return { mutable: true, temporalDeadZone: false };
|
|
@@ -11,8 +11,8 @@ import type { ProducerContext } from '../producer-context.js';
|
|
|
11
11
|
* - An `Object.create(null)` call, which publishes the carrier
|
|
12
12
|
* `objectCreateResultOverride` mints rather than the ambient `any`.
|
|
13
13
|
*
|
|
14
|
-
* A citation that re-asked the checker boxed the value at the citation:
|
|
15
|
-
* trie
|
|
14
|
+
* A citation that re-asked the checker boxed the value at the citation: a
|
|
15
|
+
* trie router's `Node` does `this.#children = children || Object.create(null)`;
|
|
16
16
|
* the merge cited the call as `any` and the field write cited the merge as
|
|
17
17
|
* `any`, so the optional parameter was boxed and unboxed into the field.
|
|
18
18
|
*/
|
|
@@ -12,8 +12,8 @@ import { logicalMergeTypeOf } from './logical-merge-type.js';
|
|
|
12
12
|
* - An `Object.create(null)` call, which publishes the carrier
|
|
13
13
|
* `objectCreateResultOverride` mints rather than the ambient `any`.
|
|
14
14
|
*
|
|
15
|
-
* A citation that re-asked the checker boxed the value at the citation:
|
|
16
|
-
* trie
|
|
15
|
+
* A citation that re-asked the checker boxed the value at the citation: a
|
|
16
|
+
* trie router's `Node` does `this.#children = children || Object.create(null)`;
|
|
17
17
|
* the merge cited the call as `any` and the field write cited the merge as
|
|
18
18
|
* `any`, so the optional parameter was boxed and unboxed into the field.
|
|
19
19
|
*/
|
|
@@ -225,6 +225,7 @@ export const createClassLifecycleProducer = (context) => {
|
|
|
225
225
|
...(allocated === 'class-constructor-object' && ts.isClassLike(node)
|
|
226
226
|
? {
|
|
227
227
|
classDeclaration: context.identities.declarationIdOf(node),
|
|
228
|
+
...(candidate.classConstructionDeferred ? { classConstructionDeferred: true } : {}),
|
|
228
229
|
functionName: staticClassNameOf(node),
|
|
229
230
|
functionLength: staticClassLengthOf(node)
|
|
230
231
|
}
|
|
@@ -361,7 +362,8 @@ export const createClassLifecycleProducer = (context) => {
|
|
|
361
362
|
allocates: true,
|
|
362
363
|
callsUserCode: false
|
|
363
364
|
}),
|
|
364
|
-
...(candidate.classLayoutOnly ? { classLayoutOnly: true } : {})
|
|
365
|
+
...(candidate.classLayoutOnly ? { classLayoutOnly: true } : {}),
|
|
366
|
+
...(candidate.classConstructionDeferred ? { classConstructionDeferred: true } : {})
|
|
365
367
|
};
|
|
366
368
|
operations.push(bindOperation);
|
|
367
369
|
if (heritageOperation)
|
|
@@ -407,7 +409,7 @@ export const createClassLifecycleProducer = (context) => {
|
|
|
407
409
|
edges.push({ kind: 'value', result: classValue.id, to: nameId, role: 'initializer', ordinal: 0 });
|
|
408
410
|
}
|
|
409
411
|
const written = writtenConstructorOf(node);
|
|
410
|
-
const writtenConstructor = candidate.classLayoutOnly ? null : writtenConstructorAllocationOf(candidate, node);
|
|
412
|
+
const writtenConstructor = candidate.classLayoutOnly || candidate.classConstructionDeferred ? null : writtenConstructorAllocationOf(candidate, node);
|
|
411
413
|
if (writtenConstructor)
|
|
412
414
|
operations.push(writtenConstructor);
|
|
413
415
|
// A parameter property is two declarations written as one:
|
|
@@ -779,7 +781,10 @@ export const createClassLifecycleProducer = (context) => {
|
|
|
779
781
|
(ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer)) &&
|
|
780
782
|
context.specializations.isGeneric(node.initializer) &&
|
|
781
783
|
context.specializations.specializationsOf(context.identities.genericSubjectOf(node.initializer)).length === 0;
|
|
782
|
-
if (node.initializer &&
|
|
784
|
+
if (node.initializer &&
|
|
785
|
+
!candidate.classLayoutOnly &&
|
|
786
|
+
(isStatic || !candidate.classConstructionDeferred) &&
|
|
787
|
+
!uninstantiatedGenericInitializer) {
|
|
783
788
|
// An instance field initializer runs with the new instance as `this`;
|
|
784
789
|
// a static field initializer runs during class evaluation with the
|
|
785
790
|
// constructor object as `this`. These are different physical carriers,
|
|
@@ -880,15 +885,40 @@ export const createClassLifecycleProducer = (context) => {
|
|
|
880
885
|
const source = candidate.id;
|
|
881
886
|
const declaration = context.identities.declarationIdOf(node);
|
|
882
887
|
const classId = context.identities.declarationIdOf(classNode);
|
|
888
|
+
// Like a static field initializer, a block is invoked once with this
|
|
889
|
+
// exact evaluated class value. Giving its body a real receiver ABI also
|
|
890
|
+
// keeps each factory evaluation's constructor identity intact.
|
|
891
|
+
const receiver = context.types.valueTypeAt(classNode);
|
|
892
|
+
const shape = context.table.intern({
|
|
893
|
+
kind: 'signature',
|
|
894
|
+
call: [{ parameters: [], minimumArity: 0, thisParameter: receiver, implicitReceiver: true, result: voidType }],
|
|
895
|
+
construct: []
|
|
896
|
+
});
|
|
897
|
+
const allocationId = mintOperationId(context.ordinals, source, 'allocation');
|
|
898
|
+
const allocation = {
|
|
899
|
+
id: allocationId,
|
|
900
|
+
family: 'allocation',
|
|
901
|
+
allocated: 'function-object',
|
|
902
|
+
shape,
|
|
903
|
+
callable: context.identities.functionIdOf(node),
|
|
904
|
+
caller: candidate.caller,
|
|
905
|
+
operands: [],
|
|
906
|
+
results: [mintResult(allocationId, 'value', shape)],
|
|
907
|
+
completion: normalCompletion,
|
|
908
|
+
effects: { ...pureEffects, allocates: true },
|
|
909
|
+
evaluationOrdinal: candidate.evaluationOrdinal
|
|
910
|
+
};
|
|
911
|
+
const initializer = resultOf(allocation, 'value');
|
|
883
912
|
const id = mintOperationId(context.ordinals, source, 'class-lifecycle');
|
|
884
|
-
const operation = buildOperation(id, candidate.caller, context.evaluationOrdinals.next(candidate.caller), 'run-static-block', declaration, classId, null, null, [],
|
|
913
|
+
const operation = buildOperation(id, candidate.caller, context.evaluationOrdinals.next(candidate.caller), 'run-static-block', declaration, classId, null, null, [operand('initializer', 0, { kind: 'result', result: initializer.id }, shape)],
|
|
885
914
|
// The block body can throw and can read/write arbitrary state; its own
|
|
886
|
-
// statements are
|
|
887
|
-
// census already creates, so this operation is the block's entry point.
|
|
915
|
+
// statements are normalized under this callable's owner.
|
|
888
916
|
throwingCompletion, { readsMutableState: true, writesMutableState: true, allocates: false, callsUserCode: true });
|
|
889
|
-
const edges = [
|
|
890
|
-
|
|
891
|
-
|
|
917
|
+
const edges = [
|
|
918
|
+
{ kind: 'evaluation', from: ready, to: operation.id },
|
|
919
|
+
{ kind: 'value', result: initializer.id, to: operation.id, role: 'initializer', ordinal: 0 }
|
|
920
|
+
];
|
|
921
|
+
return { kind: 'operations', operations: [allocation, operation], edges };
|
|
892
922
|
};
|
|
893
923
|
/**
|
|
894
924
|
* A class expression's `evaluate-heritage` event -- the one lifecycle step
|
|
@@ -8,6 +8,7 @@ import { isAssignmentOperatorKind, logicalAssignmentOperators, sourceForValue, s
|
|
|
8
8
|
import { normalCompletion, pureEffects, throwingCompletion } from '../../model/operands.js';
|
|
9
9
|
import { propertyExpressionValueTypeAt } from './properties.js';
|
|
10
10
|
import { citedValueTypeAt } from './cited-value-type.js';
|
|
11
|
+
import { constantConditionalGuardId, constantConditionalGuardResult } from './conditional-guard.js';
|
|
11
12
|
import { ordinaryObjectDataWriteIsAbsent } from '../callable-data-write.js';
|
|
12
13
|
const tokenText = (kind) => ts.tokenToString(kind) ?? ts.SyntaxKind[kind];
|
|
13
14
|
/**
|
|
@@ -137,8 +138,8 @@ const finishComputation = (context, candidate, node, form, operatorText, operand
|
|
|
137
138
|
// checker subtype-reduces `cond ? xs.map(f) : []` to the populated arm
|
|
138
139
|
// for the same reason, and `structural.ts` drops the identical arm from
|
|
139
140
|
// a checker union. Kept as a second arm, the merge was a tagged union of
|
|
140
|
-
// two arrays the binding had to select from (
|
|
141
|
-
// `ownRoute`), where `mergeIncoming` builds the empty literal directly
|
|
141
|
+
// two arrays the binding had to select from (a regular-expression
|
|
142
|
+
// router's `ownRoute`), where `mergeIncoming` builds the empty literal directly
|
|
142
143
|
// in the populated arm's carrier.
|
|
143
144
|
const shapeOf = (id) => (context.table.isOpen(id) ? undefined : context.table.get(id).shape);
|
|
144
145
|
const elementless = (id) => {
|
|
@@ -333,11 +334,34 @@ const contributeLogicalAssignment = (context, candidate, node, kind) => {
|
|
|
333
334
|
};
|
|
334
335
|
};
|
|
335
336
|
const contributeConditional = (context, candidate, node) => {
|
|
336
|
-
const
|
|
337
|
+
const rawCondition = sourceForValue(context, node.condition);
|
|
338
|
+
let conditionSource = rawCondition;
|
|
339
|
+
let materialized = null;
|
|
340
|
+
if (rawCondition.kind === 'constant') {
|
|
341
|
+
// A literal is normally an inline operand. A lazy branch additionally
|
|
342
|
+
// needs a citable result so the generic subtree-gating pass can place all
|
|
343
|
+
// branch effects under the same guard. This single-value comma preserves
|
|
344
|
+
// the literal's type/value without coercion or an invented runtime call.
|
|
345
|
+
const id = constantConditionalGuardId(node.condition, context);
|
|
346
|
+
const type = context.types.typeAt(node.condition);
|
|
347
|
+
materialized = {
|
|
348
|
+
id,
|
|
349
|
+
family: 'computation',
|
|
350
|
+
form: 'comma',
|
|
351
|
+
operator: ',',
|
|
352
|
+
caller: candidate.caller,
|
|
353
|
+
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
354
|
+
operands: [operand('value', 0, rawCondition, type)],
|
|
355
|
+
results: [mintResult(id, 'value', type)],
|
|
356
|
+
completion: normalCompletion,
|
|
357
|
+
effects: pureEffects
|
|
358
|
+
};
|
|
359
|
+
conditionSource = { kind: 'result', result: constantConditionalGuardResult(node.condition, context) };
|
|
360
|
+
}
|
|
337
361
|
if (conditionSource.kind !== 'result') {
|
|
338
362
|
return {
|
|
339
363
|
kind: 'blocked',
|
|
340
|
-
blocker: blocked(candidate.id, 'computation', 'a conditional expression needs a producible condition result
|
|
364
|
+
blocker: blocked(candidate.id, 'computation', 'a conditional expression needs a producible condition result; this or super is not modelled', 'P0')
|
|
341
365
|
};
|
|
342
366
|
}
|
|
343
367
|
const condition = operand('condition', 0, conditionSource, context.types.typeAt(node.condition));
|
|
@@ -354,7 +378,14 @@ const contributeConditional = (context, candidate, node) => {
|
|
|
354
378
|
guard: conditionSource.result,
|
|
355
379
|
takenWhen: 'falsy'
|
|
356
380
|
});
|
|
357
|
-
|
|
381
|
+
const contribution = finishComputation(context, candidate, node, 'conditional', '?:', [condition, consequent, alternate], normalCompletion, pureEffects);
|
|
382
|
+
if (!materialized || contribution.kind !== 'operations')
|
|
383
|
+
return contribution;
|
|
384
|
+
return {
|
|
385
|
+
...contribution,
|
|
386
|
+
operations: [materialized, ...contribution.operations],
|
|
387
|
+
edges: [...valueEdgesInto(materialized.id, materialized.operands), ...contribution.edges]
|
|
388
|
+
};
|
|
358
389
|
};
|
|
359
390
|
const contributeTemplate = (context, candidate, node) => {
|
|
360
391
|
// The literal text between the substitutions is part of the value, so it is
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type ts from 'typescript';
|
|
2
|
+
import type { CitationFacts } from './references.js';
|
|
3
|
+
/** A literal condition has no ordinary operation. The conditional producer
|
|
4
|
+
* publishes this value coordinate; subtree gating cites exactly that result. */
|
|
5
|
+
export declare const constantConditionalGuardId: (condition: ts.Expression, facts: CitationFacts) => import("../../../identity/ids.js").OperationId;
|
|
6
|
+
export declare const constantConditionalGuardResult: (condition: ts.Expression, facts: CitationFacts) => import("../../../identity/ids.js").SemanticResultId;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { operationId, semanticResultId } from '../../../identity/ids.js';
|
|
2
|
+
/** A literal condition has no ordinary operation. The conditional producer
|
|
3
|
+
* publishes this value coordinate; subtree gating cites exactly that result. */
|
|
4
|
+
export const constantConditionalGuardId = (condition, facts) => operationId(facts.identities.nodeIdOf(condition), 'computation', 0);
|
|
5
|
+
export const constantConditionalGuardResult = (condition, facts) => semanticResultId(constantConditionalGuardId(condition, facts), 'value');
|
|
@@ -5,6 +5,7 @@ import { familyOf, isFieldInitializerBody } from '../census.js';
|
|
|
5
5
|
import { blocked, mintOperationId, mintResult, operand } from './mint.js';
|
|
6
6
|
import { contributePlainLoop, contributeTailTestedLoop } from './control-loops.js';
|
|
7
7
|
import { resolveExpressionOperand } from './boundary.js';
|
|
8
|
+
import { unsharedReturnedArray } from '../unshared-array-result.js';
|
|
8
9
|
import { unwrapErasedExpression } from './erasure.js';
|
|
9
10
|
import { isDynamicIterationSource, mintIteratorSteps } from './protocol.js';
|
|
10
11
|
import { hasNativeEnumerationCursor, hasNativeIterationCursor, isGeneratorType, presentIterationArm, nativeCollectionIterationViewOf, valueEdgesInto } from './shared.js';
|
|
@@ -468,7 +469,12 @@ const contributeReturn = (context, candidate, node) => {
|
|
|
468
469
|
const resolved = resolveExpressionOperand(context, node.expression);
|
|
469
470
|
if (!resolved)
|
|
470
471
|
return blockedContribution(candidate, 'no normalized operation identifies the returned value');
|
|
471
|
-
valueOperand = {
|
|
472
|
+
valueOperand = {
|
|
473
|
+
...operand('value', 0, resolved.source, resolved.type),
|
|
474
|
+
...(resolved.asserted ? { asserted: true } : {}),
|
|
475
|
+
// A `finally` runs after the value is taken and may still fill the local.
|
|
476
|
+
...(!nearestInterceptingFinally(node) && unsharedReturnedArray(context.checker, node) ? { unsharedFreshArray: true } : {})
|
|
477
|
+
};
|
|
472
478
|
}
|
|
473
479
|
else {
|
|
474
480
|
const undefinedType = context.table.intern({ kind: 'primitive', primitive: 'undefined' });
|
|
@@ -7,6 +7,7 @@ import { normalCompletion, throwingCompletion } from '../../model/operands.js';
|
|
|
7
7
|
import { mintOperationId, mintResult, operand } from './mint.js';
|
|
8
8
|
import { asBlocked, hasNativeIterationCursor, isFixedArityTupleType, isGeneratorType, isStrictContext, resultEdge, unwrapErased, valueEdgesInto } from './shared.js';
|
|
9
9
|
import { citeExpressionResult } from './references.js';
|
|
10
|
+
import { keyOf } from './properties.js';
|
|
10
11
|
import { memberTypeOf } from '../derived-expression-type.js';
|
|
11
12
|
import { bindingKindOf } from './binding-kind.js';
|
|
12
13
|
import { iteratorYieldStructuralType, iteratorYieldTypesOf } from './iteration-yield.js';
|
|
@@ -1135,13 +1136,11 @@ export const createDestructuringProducer = (context) => {
|
|
|
1135
1136
|
const receiver = citeExpressionResult(access.expression, context);
|
|
1136
1137
|
if (receiver.kind === 'unmodelled')
|
|
1137
1138
|
return refuse(receiver.reason);
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
if (targetKey === null)
|
|
1144
|
-
return refuse('computed array assignment target keys are not yet modelled');
|
|
1139
|
+
// Destructuring stores use the same typed property-key authority as
|
|
1140
|
+
// ordinary indexed stores; the cited key remains a real SSA operand.
|
|
1141
|
+
const key = keyOf(access, context);
|
|
1142
|
+
if (key.kind === 'blocked')
|
|
1143
|
+
return refuse(key.reason);
|
|
1145
1144
|
const id = mintOperationId(context.ordinals, candidate.id, 'property');
|
|
1146
1145
|
const receiverType = context.types.typeAt(access.expression);
|
|
1147
1146
|
write = {
|
|
@@ -1149,13 +1148,13 @@ export const createDestructuringProducer = (context) => {
|
|
|
1149
1148
|
family: 'property',
|
|
1150
1149
|
internalMethod: 'set',
|
|
1151
1150
|
strict: isStrictContext(access, context.buildIsStrict),
|
|
1152
|
-
keyIsComputed:
|
|
1151
|
+
keyIsComputed: key.computed,
|
|
1153
1152
|
descriptor: null,
|
|
1154
1153
|
caller: candidate.caller,
|
|
1155
1154
|
evaluationOrdinal: candidate.evaluationOrdinal,
|
|
1156
1155
|
operands: [
|
|
1157
1156
|
operand('receiver', 0, receiver.source, receiverType, { kind: 'provenance' }),
|
|
1158
|
-
operand('key', 0,
|
|
1157
|
+
operand('key', 0, key.source, key.type),
|
|
1159
1158
|
operand('value', 0, value, boundType)
|
|
1160
1159
|
],
|
|
1161
1160
|
results: [mintResult(id, 'value', receiverType)],
|
|
@@ -14,7 +14,7 @@ import { isFabricatedSignatureShape, structuralCallSignatures } from '../structu
|
|
|
14
14
|
import { contextualArrayConstructTypeAt, contextualCollectionTypeAt, statedCollectionTypeAt } from '../structural-array-element.js';
|
|
15
15
|
import { implementationSignatureOf } from '../structural-declarations.js';
|
|
16
16
|
import { physicalGeneratorOverloadResultAt, physicalInheritedCallableReturnAt } from '../physical-overload-result.js';
|
|
17
|
-
import { unsharedArrayResultBodyOf } from '../unshared-array-result.js';
|
|
17
|
+
import { readOnlyArrayArgumentAt, unsharedArrayResultBodyOf } from '../unshared-array-result.js';
|
|
18
18
|
import { regionId, semanticResultId, withoutSpecialization } from '../../../identity/ids.js';
|
|
19
19
|
import { bindingKindOf } from './binding-kind.js';
|
|
20
20
|
import { declaresExactArms } from './exact-arms.js';
|
|
@@ -505,6 +505,33 @@ const exactFunctionTarget = (context, node, signature) => {
|
|
|
505
505
|
]
|
|
506
506
|
};
|
|
507
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* The body a call runs and the formal an argument binds, by the same exact
|
|
510
|
+
* target proof `buildTarget` publishes: a never-reassigned binding that holds
|
|
511
|
+
* exactly one source function. Positions after a spread are not known.
|
|
512
|
+
*/
|
|
513
|
+
const argumentFormalOf = (context) => (call, argument) => {
|
|
514
|
+
const index = call.arguments.indexOf(argument);
|
|
515
|
+
if (index < 0 || call.arguments.slice(0, index + 1).some(ts.isSpreadElement))
|
|
516
|
+
return null;
|
|
517
|
+
const signature = context.checker.getResolvedSignature(call);
|
|
518
|
+
if (!signature || exactFunctionTarget(context, call, signature) === null)
|
|
519
|
+
return null;
|
|
520
|
+
const declaration = sourceImplementationSignatureOf(context, signature, 'generic-too')?.declaration ?? signature.declaration;
|
|
521
|
+
return declaration && isFunctionLikeSourceDeclaration(declaration) ? { callee: declaration, index } : null;
|
|
522
|
+
};
|
|
523
|
+
/** See `SemanticOperand.readOnlyArrayArgument`: an argument the call may take as an element-wise copy. */
|
|
524
|
+
const readOnlyArrayArgumentsOf = (context, node, args, operands) => {
|
|
525
|
+
if (!ts.isCallExpression(node) || args.some(ts.isSpreadElement))
|
|
526
|
+
return operands;
|
|
527
|
+
const formalOf = argumentFormalOf(context);
|
|
528
|
+
return operands.map((entry) => {
|
|
529
|
+
const argument = entry.role === 'argument' ? args[entry.ordinal] : undefined;
|
|
530
|
+
return argument !== undefined && readOnlyArrayArgumentAt(context.checker, argument, formalOf)
|
|
531
|
+
? { ...entry, readOnlyArrayArgument: true }
|
|
532
|
+
: entry;
|
|
533
|
+
});
|
|
534
|
+
};
|
|
508
535
|
/** See `InvocationOperation.unsharedArrayResult`; asked only of a call whose own result is an Array. */
|
|
509
536
|
const unsharedArrayResultFactOf = (context, node) => {
|
|
510
537
|
if (!ts.isCallExpression(node))
|
|
@@ -547,6 +574,31 @@ const freshIntrinsicArrayResultFactOf = (context, node) => {
|
|
|
547
574
|
});
|
|
548
575
|
return lib ? { freshIntrinsicArrayResult: true } : {};
|
|
549
576
|
};
|
|
577
|
+
/**
|
|
578
|
+
* `Array.from(...)` / `Array.of(...)`: the standard library's own static
|
|
579
|
+
* factories, which answer an array they just created (ECMA-262 ArrayCreate on
|
|
580
|
+
* the intrinsic `%Array%` receiver) and hold no reference to it. Only while
|
|
581
|
+
* neither the `Array` binding nor the member was replaced
|
|
582
|
+
* (`intrinsicStaticMemberIsIntact`). See `InvocationOperation.freshIntrinsicArrayFactory`.
|
|
583
|
+
*/
|
|
584
|
+
const freshIntrinsicArrayFactoryFactOf = (context, node) => {
|
|
585
|
+
if (!ts.isCallExpression(node) || ts.isOptionalChain(node))
|
|
586
|
+
return {};
|
|
587
|
+
const callee = node.expression;
|
|
588
|
+
if (!ts.isPropertyAccessExpression(callee) || !ts.isIdentifier(callee.name) || !ts.isIdentifier(callee.expression))
|
|
589
|
+
return {};
|
|
590
|
+
if (callee.expression.text !== 'Array' || (callee.name.text !== 'from' && callee.name.text !== 'of'))
|
|
591
|
+
return {};
|
|
592
|
+
if (!context.checker.isArrayType(context.checker.getTypeAtLocation(node)))
|
|
593
|
+
return {};
|
|
594
|
+
const member = context.checker.getSymbolAtLocation(callee.name);
|
|
595
|
+
const owner = context.checker.getSymbolAtLocation(callee.expression);
|
|
596
|
+
const statics = (member?.declarations ?? []).every((declaration) => {
|
|
597
|
+
const parent = declaration.parent;
|
|
598
|
+
return ts.isInterfaceDeclaration(parent) && parent.name.text === 'ArrayConstructor';
|
|
599
|
+
});
|
|
600
|
+
return statics && intrinsicStaticMemberIsIntact(context, owner, member, callee) ? { freshIntrinsicArrayFactory: true } : {};
|
|
601
|
+
};
|
|
550
602
|
const implicitSourceConstructorTarget = (context, node) => {
|
|
551
603
|
// HOLDS: what `new`'s own callee expression refers to, read the
|
|
552
604
|
// census-aware way (`context.types.rawTypeAt`) rather than the bare
|
|
@@ -1841,7 +1893,7 @@ export const createInvocationProducer = (context) => ({
|
|
|
1841
1893
|
}
|
|
1842
1894
|
const expansions = argumentList.operations;
|
|
1843
1895
|
const expansionEdges = argumentList.edges;
|
|
1844
|
-
operands.push(...argumentList.operands);
|
|
1896
|
+
operands.push(...readOnlyArrayArgumentsOf(context, node, args, argumentList.operands));
|
|
1845
1897
|
// This call's own published result stays the checker's real, un-awaited
|
|
1846
1898
|
// type -- an un-awaited async call yields a genuine `Promise<T>` value
|
|
1847
1899
|
// now that `promise` is a real carrier
|
|
@@ -2144,6 +2196,7 @@ export const createInvocationProducer = (context) => ({
|
|
|
2144
2196
|
: {}),
|
|
2145
2197
|
...unsharedArrayResultFactOf(context, node),
|
|
2146
2198
|
...freshIntrinsicArrayResultFactOf(context, node),
|
|
2199
|
+
...freshIntrinsicArrayFactoryFactOf(context, node),
|
|
2147
2200
|
...deadEventCallFactOf(context, node),
|
|
2148
2201
|
...(intrinsicPropertyCall === 'get' ||
|
|
2149
2202
|
intrinsicPropertyCall === 'set' ||
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { type StructuralTypeId } from '../../../identity/ids.js';
|
|
3
|
+
import type { PrimitiveFamily } from '../../model/coverage.js';
|
|
4
|
+
import { type OperandSource } from '../../model/operands.js';
|
|
3
5
|
import type { FamilyProducer } from '../contribution.js';
|
|
4
6
|
import type { ProducerContext } from '../producer-context.js';
|
|
5
7
|
type AccessNode = ts.PropertyAccessExpression | ts.ElementAccessExpression;
|
|
8
|
+
type KeyResolution = {
|
|
9
|
+
readonly kind: 'key';
|
|
10
|
+
readonly computed: boolean;
|
|
11
|
+
readonly source: OperandSource;
|
|
12
|
+
readonly type: StructuralTypeId;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'blocked';
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
readonly missingPrimitive: PrimitiveFamily | null;
|
|
17
|
+
};
|
|
18
|
+
export declare const keyOf: (node: AccessNode, context: ProducerContext) => KeyResolution;
|
|
6
19
|
/**
|
|
7
20
|
* The value type published for this exact property expression.
|
|
8
21
|
*
|
|
@@ -16,6 +16,7 @@ import { assertsType, enclosingCallIfCallee, outermostErasureOf, unwrapErasedExp
|
|
|
16
16
|
import { isScriptGlobalObjectPropertyDeclaration } from '../script-global-redefinition.js';
|
|
17
17
|
import { primitivePropertyIsAbsent } from '../primitive-property-absence.js';
|
|
18
18
|
import { nativeOwnSlotOf } from './native-own-assignment.js';
|
|
19
|
+
import { isUnsharedFreshTableStore } from '../fresh-table-last-use.js';
|
|
19
20
|
import { nativeCallableReadonlySetSourceOf } from './native-callable-readonly-set.js';
|
|
20
21
|
import { assertedReceiverArmMayLackMember } from '../asserted-arm-absence.js';
|
|
21
22
|
import { keySetTouches } from '../host-mutation-keys.js';
|
|
@@ -88,7 +89,7 @@ const intentOf = (node) => {
|
|
|
88
89
|
}
|
|
89
90
|
return { kind: 'get' };
|
|
90
91
|
};
|
|
91
|
-
const keyOf = (node, context) => {
|
|
92
|
+
export const keyOf = (node, context) => {
|
|
92
93
|
// A static key is a String, whatever the property it names holds. Asking the
|
|
93
94
|
// checker for the type at the name node answers a different question -- it
|
|
94
95
|
// gives the *property's* type -- and taking that answer spells the key with
|
|
@@ -636,7 +637,12 @@ const observablyAbsentElementTypeOf = (context, node, valueType) => {
|
|
|
636
637
|
members: [valueType, context.table.intern({ kind: 'primitive', primitive: 'undefined' })]
|
|
637
638
|
});
|
|
638
639
|
}
|
|
639
|
-
|
|
640
|
+
// An equality test against `undefined` consumes nothing either: three's
|
|
641
|
+
// `if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined )`
|
|
642
|
+
// reads an array it fills in that very branch, so the read is out of range
|
|
643
|
+
// on its first pass, and the bare element carrier aborted the program at
|
|
644
|
+
// the comparison meant to observe that absence.
|
|
645
|
+
if (!ts.isElementAccessExpression(node) || !(testsItsOperand(node) || comparesWithUndefined(context, node)))
|
|
640
646
|
return valueType;
|
|
641
647
|
// Each constituent, because a union of array types indexes the same way:
|
|
642
648
|
// a parameter declared `middleware: [[Function, unknown], unknown][] |
|
|
@@ -818,6 +824,12 @@ const buildOperations = (candidate, node, intent, key, receiverSource, context,
|
|
|
818
824
|
return sourceForValue(context, parent.right);
|
|
819
825
|
return { kind: 'result', result: semanticResultId(operationId(context.identities.nodeIdOf(parent), 'computation', 0), 'value') };
|
|
820
826
|
};
|
|
827
|
+
// See `SemanticOperand.unsharedFreshTable`: only a plain `=` whose
|
|
828
|
+
// right-hand side is the local itself.
|
|
829
|
+
const unsharedFreshTableStore = () => {
|
|
830
|
+
const parent = outermostErasureOf(node).parent;
|
|
831
|
+
return (ts.isBinaryExpression(parent) && parent.left === outermostErasureOf(node) && isUnsharedFreshTableStore(context.checker, parent.right));
|
|
832
|
+
};
|
|
821
833
|
const makeOperation = (internalMethod, receiverEvaluation, keyEvaluation, effects) => {
|
|
822
834
|
const id = mintOperationId(context.ordinals, candidate.id, 'property');
|
|
823
835
|
const stored = internalMethod === 'set' ? storedValue() : null;
|
|
@@ -931,7 +943,13 @@ const buildOperations = (candidate, node, intent, key, receiverSource, context,
|
|
|
931
943
|
? { ...operand('receiver', 0, receiverSource, receiverType, receiverEvaluation), asserted: true }
|
|
932
944
|
: operand('receiver', 0, receiverSource, receiverType, receiverEvaluation),
|
|
933
945
|
operand('key', 0, key.source, key.type, keyEvaluation),
|
|
934
|
-
...(stored
|
|
946
|
+
...(stored
|
|
947
|
+
? [
|
|
948
|
+
unsharedFreshTableStore()
|
|
949
|
+
? { ...operand('value', 0, stored, valueType), unsharedFreshTable: true }
|
|
950
|
+
: operand('value', 0, stored, valueType)
|
|
951
|
+
]
|
|
952
|
+
: []),
|
|
935
953
|
...(guardSource && guardExpression
|
|
936
954
|
? [operand('short-circuit-guard', 0, guardSource, context.types.typeAt(guardExpression), { kind: 'provenance' })]
|
|
937
955
|
: [])
|
|
@@ -5,7 +5,7 @@ import { enclosingCallIfCallee, flowNarrowsType, unwrapErasedExpression } from '
|
|
|
5
5
|
import { publishesShortCircuit } from './optional-chain.js';
|
|
6
6
|
import { operationId, regionId, semanticResultId } from '../../../identity/ids.js';
|
|
7
7
|
import { normalCompletion, pureEffects, throwingCompletion } from '../../model/operands.js';
|
|
8
|
-
import { familyOf } from '../census.js';
|
|
8
|
+
import { familyOf, isClassElementNameEvaluation } from '../census.js';
|
|
9
9
|
import { bindingKindOf } from './binding-kind.js';
|
|
10
10
|
import { blocked, mintOperationId, mintResult, operand } from './mint.js';
|
|
11
11
|
import { valueSymbolAt } from '../unresolvable-names.js';
|
|
@@ -765,6 +765,8 @@ const thisCanThrow = (node) => {
|
|
|
765
765
|
*/
|
|
766
766
|
const nearestOwningScopeIsArrow = (node) => {
|
|
767
767
|
for (let current = node.parent; current; current = current.parent) {
|
|
768
|
+
if (isClassElementNameEvaluation(node, current))
|
|
769
|
+
continue;
|
|
768
770
|
if (ts.isArrowFunction(current))
|
|
769
771
|
return true;
|
|
770
772
|
if (ts.isFunctionDeclaration(current) ||
|
|
@@ -780,9 +782,11 @@ const nearestOwningScopeIsArrow = (node) => {
|
|
|
780
782
|
}
|
|
781
783
|
return false;
|
|
782
784
|
};
|
|
783
|
-
/** The class whose constructor object a static `this` denotes, plus whether the nearest owner is a
|
|
785
|
+
/** The class whose constructor object a static `this` denotes, plus whether the nearest source owner is a static block. */
|
|
784
786
|
const staticThisOwner = (node) => {
|
|
785
787
|
for (let current = node.parent; current; current = current.parent) {
|
|
788
|
+
if (isClassElementNameEvaluation(node, current))
|
|
789
|
+
continue;
|
|
786
790
|
if (ts.isArrowFunction(current))
|
|
787
791
|
continue;
|
|
788
792
|
if (ts.isClassStaticBlockDeclaration(current)) {
|
|
@@ -795,7 +799,7 @@ const staticThisOwner = (node) => {
|
|
|
795
799
|
const isStatic = (ts.getCombinedModifierFlags(current) & ts.ModifierFlags.Static) !== 0;
|
|
796
800
|
return isStatic && ts.isClassLike(current.parent) ? { classNode: current.parent, block: false } : null;
|
|
797
801
|
}
|
|
798
|
-
if (ts.isFunctionLike(current)
|
|
802
|
+
if (ts.isFunctionLike(current))
|
|
799
803
|
return null;
|
|
800
804
|
}
|
|
801
805
|
return null;
|
|
@@ -865,7 +869,7 @@ const buildThisReference = (candidate, node, context) => {
|
|
|
865
869
|
// evaluates it, and an operand that claimed to would order an evaluation
|
|
866
870
|
// the language does not perform.
|
|
867
871
|
operands: [
|
|
868
|
-
operand(
|
|
872
|
+
operand(captured ? 'captured-receiver' : staticOwner?.block ? 'static-class-receiver' : 'receiver', 0, { kind: 'receiver' }, type, {
|
|
869
873
|
kind: 'provenance'
|
|
870
874
|
})
|
|
871
875
|
],
|
|
@@ -65,9 +65,11 @@ import ts from 'typescript';
|
|
|
65
65
|
*
|
|
66
66
|
* ## The second granularity: a class member
|
|
67
67
|
*
|
|
68
|
-
* A live class
|
|
69
|
-
*
|
|
70
|
-
*
|
|
68
|
+
* A live class retains its definition effects and layout. Constructor bodies
|
|
69
|
+
* and instance initializers run only for construction-live classes; unknown
|
|
70
|
+
* construction and escaped/exported constructor values retain them conservatively.
|
|
71
|
+
* A method body runs only when a dispatch names it, and a dispatch has to name
|
|
72
|
+
* it. `C.m` resolves to one declaration, so a static
|
|
71
73
|
* member is opened by symbol. An instance member cannot be: a structurally
|
|
72
74
|
* typed parameter, a base-class reference and an interface-typed call all land
|
|
73
75
|
* on a member the receiver's static type does not identify, and an override is
|
|
@@ -131,6 +133,7 @@ export interface ProgramReachability {
|
|
|
131
133
|
*/
|
|
132
134
|
readonly memberIsPruned: (node: ts.Node) => boolean;
|
|
133
135
|
readonly classIsLayoutOnly: (node: ts.ClassDeclaration) => boolean;
|
|
136
|
+
readonly classConstructionIsReachable?: (node: ts.ClassDeclaration) => boolean;
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
136
139
|
* Every statement of every file: the answer when nothing may be pruned.
|
|
@@ -189,6 +192,15 @@ export interface ReachabilityInput {
|
|
|
189
192
|
* `import {} from 'x'` and does. `typeOnlyModuleUse` is the one answer.
|
|
190
193
|
*/
|
|
191
194
|
readonly verbatimModuleSyntax?: boolean;
|
|
195
|
+
/** Canonical runtime export binding; only proven absence may drop an export. */
|
|
196
|
+
readonly runtimeExportOf?: (file: ts.SourceFile, name: string) => {
|
|
197
|
+
readonly kind: 'binding';
|
|
198
|
+
readonly symbol: ts.Symbol;
|
|
199
|
+
} | {
|
|
200
|
+
readonly kind: 'missing' | 'refused';
|
|
201
|
+
};
|
|
202
|
+
/** Closed source construction selections; null retains conservative type-compatible alternatives. */
|
|
203
|
+
readonly constructorTargetsOf?: (expression: ts.Expression) => readonly ts.ClassDeclaration[] | null;
|
|
192
204
|
}
|
|
193
205
|
/**
|
|
194
206
|
* Whether the statements this program REACHES in `file` evaluate anything.
|