@geastack/compiler 1.0.33 → 1.0.35
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 +83 -22
- 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
|
@@ -38,6 +38,9 @@ const refusalDebug = process.env['GEA_SESSION_REFUSALS'] !== undefined;
|
|
|
38
38
|
/** The query kinds whose facts are values and therefore need a grounding witness. */
|
|
39
39
|
const VALUE_CARRYING_KINDS = new Set([
|
|
40
40
|
'value',
|
|
41
|
+
'proxy-result',
|
|
42
|
+
'proxy-target',
|
|
43
|
+
'proxy-handler',
|
|
41
44
|
'slot',
|
|
42
45
|
'stored-slot',
|
|
43
46
|
'parameter',
|
|
@@ -49,7 +52,10 @@ const VALUE_CARRYING_KINDS = new Set([
|
|
|
49
52
|
'frame-argument',
|
|
50
53
|
'frame-parameter',
|
|
51
54
|
'frame-value',
|
|
52
|
-
'frame-completion'
|
|
55
|
+
'frame-completion',
|
|
56
|
+
'constructor-value',
|
|
57
|
+
'constructor-parameter',
|
|
58
|
+
'constructor-completion'
|
|
53
59
|
]);
|
|
54
60
|
const VALUE_ORIGIN = 'source-value-origin';
|
|
55
61
|
// Read once at load, not per value transfer: `process.env` is a native interceptor.
|
|
@@ -119,6 +125,8 @@ export const sourceValueSessionOf = (checker, flow) => {
|
|
|
119
125
|
candidateOrdinaryOwnCallableOperandsOf: (call) => live().candidateOrdinaryOwnCallableOperandsOf(call),
|
|
120
126
|
ordinaryOwnCallableOperandsOf: (call) => live().ordinaryOwnCallableOperandsOf(call),
|
|
121
127
|
ordinaryOwnCallableSourceOf: (call) => live().ordinaryOwnCallableSourceOf(call),
|
|
128
|
+
proxyResultIdentityOf: (expression) => live().proxyResultIdentityOf(expression),
|
|
129
|
+
constructorProxyResultIdentitiesOf: (construction) => live().constructorProxyResultIdentitiesOf(construction),
|
|
122
130
|
valuesOf: (expression) => live().valuesOf(expression),
|
|
123
131
|
closedValuesOf: (expression) => live().closedValuesOf(expression),
|
|
124
132
|
memberValuesOf: (expression, key) => live().memberValuesOf(expression, key),
|
|
@@ -152,6 +160,28 @@ export const sourceValueSessionOf = (checker, flow) => {
|
|
|
152
160
|
export const retireSourceValueSession = (flow) => {
|
|
153
161
|
sessions.get(flow)?.retire();
|
|
154
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* Hands `next` the live session of `previous`, when `next` has none yet.
|
|
165
|
+
*
|
|
166
|
+
* A session's every answer is a function of the checker and its index alone
|
|
167
|
+
* (`createSession` is handed nothing else, and everything it consults is keyed
|
|
168
|
+
* on that index), so two indices that state the same content
|
|
169
|
+
* (`sameValueFlowContent`) have the same session. The binding fixpoint builds
|
|
170
|
+
* one index per round, and the round that settles it rebuilds exactly the
|
|
171
|
+
* index the round before it built: solving that round's session again from
|
|
172
|
+
* nothing reproduced every answer the previous round's solver already held.
|
|
173
|
+
*
|
|
174
|
+
* The two flows then hold ONE session entry: retiring either retires both, so
|
|
175
|
+
* the caller retires only the flow it keeps. Answers `false` -- and changes
|
|
176
|
+
* nothing -- when `previous` has no live session or `next` already has one.
|
|
177
|
+
*/
|
|
178
|
+
export const shareSourceValueSession = (previous, next) => {
|
|
179
|
+
const known = sessions.get(previous);
|
|
180
|
+
if (known === undefined || sessions.has(next))
|
|
181
|
+
return false;
|
|
182
|
+
sessions.set(next, known);
|
|
183
|
+
return true;
|
|
184
|
+
};
|
|
155
185
|
const createSession = (checker, flow) => {
|
|
156
186
|
const isFreshOrdinaryObject = (node) => sourceFreshOrdinaryObjectOf(checker, node);
|
|
157
187
|
const isObjectRoot = (node) => isSpelledObjectRoot(node) || isFreshOrdinaryObject(node);
|
|
@@ -165,6 +195,7 @@ const createSession = (checker, flow) => {
|
|
|
165
195
|
const unary = new Map();
|
|
166
196
|
const slots = new Map();
|
|
167
197
|
const storedSlots = new Map();
|
|
198
|
+
const keyReadQueries = new Map();
|
|
168
199
|
const uses = new Map();
|
|
169
200
|
const publications = new Map();
|
|
170
201
|
const frameQueries = new Map();
|
|
@@ -178,6 +209,22 @@ const createSession = (checker, flow) => {
|
|
|
178
209
|
return census.usesByOwner.get(body);
|
|
179
210
|
};
|
|
180
211
|
const undefinedValue = ts.factory.createVoidZero();
|
|
212
|
+
const conditionTruthOf = (root) => {
|
|
213
|
+
if (root === undefinedValue ||
|
|
214
|
+
ts.isVoidExpression(root) ||
|
|
215
|
+
root.kind === ts.SyntaxKind.NullKeyword ||
|
|
216
|
+
root.kind === ts.SyntaxKind.FalseKeyword)
|
|
217
|
+
return false;
|
|
218
|
+
if (root.kind === ts.SyntaxKind.TrueKeyword || isObjectRoot(root) || isBody(root))
|
|
219
|
+
return true;
|
|
220
|
+
if (ts.isStringLiteralLike(root))
|
|
221
|
+
return root.text.length !== 0;
|
|
222
|
+
if (ts.isNumericLiteral(root)) {
|
|
223
|
+
const value = Number(root.text);
|
|
224
|
+
return Number.isNaN(value) ? null : value !== 0;
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
};
|
|
181
228
|
const arrayLengths = new Map();
|
|
182
229
|
const keyValues = new Map();
|
|
183
230
|
const keyValue = (root, key) => {
|
|
@@ -340,6 +387,26 @@ const createSession = (checker, flow) => {
|
|
|
340
387
|
* solver carries on a large program. It is one node's fact, asked once per container.
|
|
341
388
|
*/
|
|
342
389
|
const unknownReadsOf = (container) => nodeQuery('unknown-reads', container);
|
|
390
|
+
/**
|
|
391
|
+
* The named reads of `key` (and of the keys that alias it on an array)
|
|
392
|
+
* whose receiver can hold THIS container.
|
|
393
|
+
*
|
|
394
|
+
* The same question `unknownReadsOf` answers for unspelled keys, and it
|
|
395
|
+
* does not depend on WHICH value was stored under the key either: every
|
|
396
|
+
* value a container publishes under one key used to run the scan itself,
|
|
397
|
+
* so a container holding N values re-subscribed to the same reads N times.
|
|
398
|
+
* As its own node it is asked once per (container, key) and found by
|
|
399
|
+
* reverse lookup rather than by subscribing to every read of the key.
|
|
400
|
+
*/
|
|
401
|
+
const keyReadsOf = (container, key) => {
|
|
402
|
+
let keys = keyReadQueries.get(container);
|
|
403
|
+
if (!keys)
|
|
404
|
+
keyReadQueries.set(container, (keys = new Map()));
|
|
405
|
+
let query = keys.get(key);
|
|
406
|
+
if (!query)
|
|
407
|
+
keys.set(key, (query = { kind: 'key-reads', node: container, key }));
|
|
408
|
+
return query;
|
|
409
|
+
};
|
|
343
410
|
const targets = (call) => nodeQuery('targets', call);
|
|
344
411
|
const superTargets = (call) => nodeQuery('super-targets', call);
|
|
345
412
|
/**
|
|
@@ -490,7 +557,15 @@ const createSession = (checker, flow) => {
|
|
|
490
557
|
// A literal that spells every key it has proves the absence of every
|
|
491
558
|
// key it does not. This is asked while walking the literal's OWN uses,
|
|
492
559
|
// so a store that added an unspelled key is a refusal in the same walk.
|
|
493
|
-
|
|
560
|
+
// A key the literal DOES spell is not absent, whether or not
|
|
561
|
+
// `descriptorOf` can describe it: `{ get baking() { ... } }` spells
|
|
562
|
+
// `baking` as an accessor, which `descriptorOf` (data entries only)
|
|
563
|
+
// answers false for. Reading it as absent claimed the read falls through
|
|
564
|
+
// to `Object.prototype` -- a read that runs the getter, modelled as one
|
|
565
|
+
// that yields `undefined` -- and raised an `Object.prototype`
|
|
566
|
+
// obligation for a key the object itself has.
|
|
567
|
+
const spelled = literalSpelledKeys(root);
|
|
568
|
+
if (spelled === null || spelled.includes(key) || descriptorOf(root, key) || hasUnnamedWrite(root))
|
|
494
569
|
return false;
|
|
495
570
|
}
|
|
496
571
|
else if (ts.isNewExpression(root)) {
|
|
@@ -536,6 +611,39 @@ const createSession = (checker, flow) => {
|
|
|
536
611
|
unknownReadsByReceiver.set(entry.receiver, (entries = []));
|
|
537
612
|
entries.push(entry);
|
|
538
613
|
}
|
|
614
|
+
const namedReadsByReceiver = new Map();
|
|
615
|
+
{
|
|
616
|
+
let order = 0;
|
|
617
|
+
for (const access of flow.propertyAccesses) {
|
|
618
|
+
const key = accessKey(access);
|
|
619
|
+
const position = order++;
|
|
620
|
+
if (key === null)
|
|
621
|
+
continue;
|
|
622
|
+
const receiver = value(access.expression);
|
|
623
|
+
let byKey = namedReadsByReceiver.get(receiver);
|
|
624
|
+
if (!byKey)
|
|
625
|
+
namedReadsByReceiver.set(receiver, (byKey = new Map()));
|
|
626
|
+
let entries = byKey.get(key);
|
|
627
|
+
if (!entries)
|
|
628
|
+
byKey.set(key, (entries = []));
|
|
629
|
+
entries.push({ access, receiver, key, order: position });
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* The read keys that can reach slot `key` of `container`: the key itself,
|
|
634
|
+
* and on an array literal the element key and the canonical indices, which
|
|
635
|
+
* alias one another (`keyReaches`).
|
|
636
|
+
*/
|
|
637
|
+
let indexReadKeys = null;
|
|
638
|
+
const readKeysReaching = (container, key) => ts.isArrayLiteralExpression(container)
|
|
639
|
+
? key === ELEMENT_KEY
|
|
640
|
+
? (indexReadKeys ??= [...readsByKey.keys()].filter((candidate) => candidate === ELEMENT_KEY || isCanonicalIndex(candidate)))
|
|
641
|
+
: isCanonicalIndex(key)
|
|
642
|
+
? [key, ELEMENT_KEY]
|
|
643
|
+
: [key]
|
|
644
|
+
: [key];
|
|
645
|
+
/** Keys whose reads' receivers are seeded: `holdersOf` finds only seeded states. */
|
|
646
|
+
const seededReadKeys = new Set();
|
|
539
647
|
/**
|
|
540
648
|
* Writes that go THROUGH some object, grouped by the name they write.
|
|
541
649
|
*
|
|
@@ -650,7 +758,132 @@ const createSession = (checker, flow) => {
|
|
|
650
758
|
return nodeQuery('binding-element', holder);
|
|
651
759
|
return ts.isVariableDeclaration(holder) && holder.initializer ? value(holder.initializer) : null;
|
|
652
760
|
};
|
|
761
|
+
/**
|
|
762
|
+
* A use `visitUse` ends without doing anything, whatever the root: the
|
|
763
|
+
* value is discarded (`x;`, `void x`), only tested (`!x`, `if ( x )`,
|
|
764
|
+
* `x === y`, `typeof x`, `k in x`, a conditional's test), enumerated by
|
|
765
|
+
* `for...in`, or the reference is the cell being declared or assigned
|
|
766
|
+
* rather than a read of it. Its node would hold no fact, read nothing, owe
|
|
767
|
+
* no obligation and be locally complete, so requiring it changes no
|
|
768
|
+
* answer -- and minting it is a state, an edge and a seal per (root,
|
|
769
|
+
* reference). A method returning a value is followed into EVERY call of
|
|
770
|
+
* the method, so every discarded `v.set( ... );` in the program was such a
|
|
771
|
+
* node for every root the method can return: hundreds of thousands on a
|
|
772
|
+
* large program.
|
|
773
|
+
*
|
|
774
|
+
* These are exactly the early returns of `visitUse` that precede any read,
|
|
775
|
+
* fact or refusal and do not depend on the root; anything else is a real use.
|
|
776
|
+
*/
|
|
777
|
+
const inertUses = new Map();
|
|
778
|
+
const inertUse = (reference) => {
|
|
779
|
+
let inert = inertUses.get(reference);
|
|
780
|
+
if (inert === undefined)
|
|
781
|
+
inertUses.set(reference, (inert = inertUseUncached(reference)));
|
|
782
|
+
return inert;
|
|
783
|
+
};
|
|
784
|
+
const inertUseUncached = (reference) => {
|
|
785
|
+
if (isTypePositionReference(reference))
|
|
786
|
+
return true;
|
|
787
|
+
const parent = reference.parent;
|
|
788
|
+
if (!parent || outermostErasureOf(reference) !== reference)
|
|
789
|
+
return false;
|
|
790
|
+
if (ts.isVariableDeclaration(parent) || ts.isParameter(parent))
|
|
791
|
+
return parent.name === reference;
|
|
792
|
+
if (ts.isBinaryExpression(parent)) {
|
|
793
|
+
const operator = parent.operatorToken.kind;
|
|
794
|
+
if (operator === ts.SyntaxKind.EqualsToken)
|
|
795
|
+
return parent.left === reference;
|
|
796
|
+
if (operator === ts.SyntaxKind.InKeyword)
|
|
797
|
+
return parent.right === reference;
|
|
798
|
+
return operator === ts.SyntaxKind.EqualsEqualsEqualsToken || operator === ts.SyntaxKind.ExclamationEqualsEqualsToken;
|
|
799
|
+
}
|
|
800
|
+
if (ts.isConditionalExpression(parent))
|
|
801
|
+
return parent.condition === reference;
|
|
802
|
+
return ((ts.isForInStatement(parent) && parent.expression === reference) ||
|
|
803
|
+
ts.isExpressionStatement(parent) ||
|
|
804
|
+
ts.isTypeOfExpression(parent) ||
|
|
805
|
+
ts.isVoidExpression(parent) ||
|
|
806
|
+
(ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.ExclamationToken) ||
|
|
807
|
+
(ts.isIfStatement(parent) && parent.expression === reference));
|
|
808
|
+
};
|
|
809
|
+
const NO_VALUES = new Set();
|
|
810
|
+
/**
|
|
811
|
+
* `return this` in a body's own frame (not in a nested arrow, whose return
|
|
812
|
+
* is the arrow's): the completion is the frame's receiver.
|
|
813
|
+
*
|
|
814
|
+
* A root reaches a non-arrow body's receiver only by being the receiver of
|
|
815
|
+
* a call that enters it -- `root.m()`, `m.call( root )`, `super.m()` from a
|
|
816
|
+
* frame it is the receiver of -- and each of those is a `forward` from the
|
|
817
|
+
* root's own use walk, holding the exact call. A plain call `F()` of a
|
|
818
|
+
* constructor function runs with some OTHER receiver. So the root comes
|
|
819
|
+
* back out of `return this` at exactly the calls it went in through, and
|
|
820
|
+
* nowhere else. Following it into every caller of the body instead (what a
|
|
821
|
+
* returned VALUE needs) made each root reaching a chainable method --
|
|
822
|
+
* `copy`, `set`, `add` on a vector or a color -- a use of the result of
|
|
823
|
+
* every such call in the program: roots x call sites, millions of nodes on
|
|
824
|
+
* a large program, every one of them a root the value never is.
|
|
825
|
+
*/
|
|
826
|
+
const ownReceiverReturns = new Map();
|
|
827
|
+
const returnsOwnReceiver = (body) => {
|
|
828
|
+
let answer = ownReceiverReturns.get(body);
|
|
829
|
+
if (answer === undefined) {
|
|
830
|
+
answer = flow.receiverReferencesToDeclaration(body).some((reference) => isOwnReceiverReturn(outermostErasureOf(reference), body));
|
|
831
|
+
ownReceiverReturns.set(body, answer);
|
|
832
|
+
}
|
|
833
|
+
return answer;
|
|
834
|
+
};
|
|
835
|
+
/** `reference` is `return`ed (or erased-and-returned) `this` of `body`'s own frame. */
|
|
836
|
+
const isOwnReceiverReturn = (reference, body) => {
|
|
837
|
+
if (!isBody(body) || ts.isArrowFunction(body))
|
|
838
|
+
return false;
|
|
839
|
+
const returned = reference.parent;
|
|
840
|
+
if (!returned || !ts.isReturnStatement(returned) || ts.findAncestor(returned, ts.isFunctionLike) !== body)
|
|
841
|
+
return false;
|
|
842
|
+
if (!ts.isExpression(reference))
|
|
843
|
+
return false;
|
|
844
|
+
const inner = unwrapErasedExpression(reference);
|
|
845
|
+
return (inner.kind === ts.SyntaxKind.ThisKeyword &&
|
|
846
|
+
flow.receiverOwnerOf(inner) === body &&
|
|
847
|
+
outermostErasureOf(inner) === reference);
|
|
848
|
+
};
|
|
653
849
|
const construction = (root) => exactSourceConstructionOf(checker, flow, root);
|
|
850
|
+
// A specific direct base construction enters this body even if that body
|
|
851
|
+
// returns a replacement object. This says nothing about any OTHER entry.
|
|
852
|
+
// Derived super lookup needs live constructor/prototype integrity and is
|
|
853
|
+
// deliberately not inferred from the declared heritage chain here.
|
|
854
|
+
const directBaseConstructorOf = (call) => {
|
|
855
|
+
if (!sites.has(call))
|
|
856
|
+
return null;
|
|
857
|
+
const selections = sourceConstructorSelectionsOf(checker, flow, call.expression);
|
|
858
|
+
const owner = selections?.length === 1 ? selections[0] : null;
|
|
859
|
+
if (!owner ||
|
|
860
|
+
(!ts.isClassDeclaration(owner) && !ts.isClassExpression(owner)) ||
|
|
861
|
+
owner.heritageClauses?.some((one) => one.token === ts.SyntaxKind.ExtendsKeyword))
|
|
862
|
+
return null;
|
|
863
|
+
const constructors = owner.members.filter(ts.isConstructorDeclaration);
|
|
864
|
+
return constructors.find((one) => one.body !== undefined) ?? null;
|
|
865
|
+
};
|
|
866
|
+
const proxyOperandsOf = (node) => {
|
|
867
|
+
if (node.arguments?.length !== 2)
|
|
868
|
+
return null;
|
|
869
|
+
const [target, handler] = node.arguments;
|
|
870
|
+
if (!target || !handler || ts.isSpreadElement(target) || ts.isSpreadElement(handler))
|
|
871
|
+
return null;
|
|
872
|
+
const callee = unwrapErasedExpression(node.expression);
|
|
873
|
+
const symbol = checker.getSymbolAtLocation(callee);
|
|
874
|
+
const declaration = checker.getResolvedSignature(node)?.getDeclaration();
|
|
875
|
+
const owner = declaration?.parent;
|
|
876
|
+
if (!ts.isIdentifier(callee) ||
|
|
877
|
+
callee.text !== 'Proxy' ||
|
|
878
|
+
!symbol?.valueDeclaration?.getSourceFile().hasNoDefaultLib ||
|
|
879
|
+
!owner ||
|
|
880
|
+
!ts.isInterfaceDeclaration(owner) ||
|
|
881
|
+
owner.name.text !== 'ProxyConstructor' ||
|
|
882
|
+
!owner.getSourceFile().hasNoDefaultLib ||
|
|
883
|
+
deferredIntrinsicProtocolLedgerOf(flow)?.requireStandardGlobalBinding('Proxy', node) !== true)
|
|
884
|
+
return null;
|
|
885
|
+
return [target, handler];
|
|
886
|
+
};
|
|
654
887
|
/**
|
|
655
888
|
* What a key names on this construction: its data member, or the method the
|
|
656
889
|
* call through it dispatches to.
|
|
@@ -977,6 +1210,48 @@ const createSession = (checker, flow) => {
|
|
|
977
1210
|
};
|
|
978
1211
|
/** Every name a body can be reached by: its own, and every cell it is stored in. */
|
|
979
1212
|
const bodyNames = new Map();
|
|
1213
|
+
/**
|
|
1214
|
+
* The callable objects installed as an own member of a Function -- through
|
|
1215
|
+
* `Reflect.set` or a plain member store -- found in one pass over the calls
|
|
1216
|
+
* and writes. `namesOf` asked it per body as two whole-program scans, each
|
|
1217
|
+
* site re-deriving its installation; on a large program that per-body scan
|
|
1218
|
+
* was a third of the session's time.
|
|
1219
|
+
*/
|
|
1220
|
+
let installedCallableObjects = null;
|
|
1221
|
+
const installedCallableObjectsOf = () => {
|
|
1222
|
+
if (installedCallableObjects !== null)
|
|
1223
|
+
return installedCallableObjects;
|
|
1224
|
+
const found = new Set();
|
|
1225
|
+
for (const site of flow.calls) {
|
|
1226
|
+
const installed = ts.isCallExpression(site.call) ? sourceCallableReflectSetOf(checker, site.call) : null;
|
|
1227
|
+
if (installed !== null)
|
|
1228
|
+
found.add(sourceCallableObjectOf(checker, flow, installed.value));
|
|
1229
|
+
}
|
|
1230
|
+
for (const write of flow.allWrites)
|
|
1231
|
+
if (write.propertyAccess !== null && write.value !== null)
|
|
1232
|
+
found.add(sourceCallableObjectOf(checker, flow, write.value));
|
|
1233
|
+
found.delete(null);
|
|
1234
|
+
found.delete(undefined);
|
|
1235
|
+
return (installedCallableObjects = found);
|
|
1236
|
+
};
|
|
1237
|
+
/** Every write, by the body its value is (`namesOf`'s other whole-program scan). */
|
|
1238
|
+
let writesByBodyValue = null;
|
|
1239
|
+
const writesOfBodyValue = (body) => {
|
|
1240
|
+
if (writesByBodyValue === null) {
|
|
1241
|
+
const index = new Map();
|
|
1242
|
+
for (const write of flow.allWrites) {
|
|
1243
|
+
if (write.value === undefined || write.value === null)
|
|
1244
|
+
continue;
|
|
1245
|
+
const held = unwrapErasedExpression(write.value);
|
|
1246
|
+
let writes = index.get(held);
|
|
1247
|
+
if (!writes)
|
|
1248
|
+
index.set(held, (writes = []));
|
|
1249
|
+
writes.push(write);
|
|
1250
|
+
}
|
|
1251
|
+
writesByBodyValue = index;
|
|
1252
|
+
}
|
|
1253
|
+
return writesByBodyValue.get(body) ?? [];
|
|
1254
|
+
};
|
|
980
1255
|
const namesOf = (body) => {
|
|
981
1256
|
const known = bodyNames.get(body);
|
|
982
1257
|
if (known !== undefined)
|
|
@@ -986,11 +1261,7 @@ const createSession = (checker, flow) => {
|
|
|
986
1261
|
// A value installed on a Function can be read through any immutable alias
|
|
987
1262
|
// of that own member. Its declaration's spelling does not enumerate those
|
|
988
1263
|
// callers, so keep the complete indexed call set for this bounded family.
|
|
989
|
-
if (
|
|
990
|
-
const installed = ts.isCallExpression(site.call) ? sourceCallableReflectSetOf(checker, site.call) : null;
|
|
991
|
-
return installed !== null && sourceCallableObjectOf(checker, flow, installed.value) === body;
|
|
992
|
-
}) ||
|
|
993
|
-
flow.allWrites.some((write) => write.propertyAccess !== null && write.value !== null && sourceCallableObjectOf(checker, flow, write.value) === body)) {
|
|
1264
|
+
if (installedCallableObjectsOf().has(body)) {
|
|
994
1265
|
bodyNames.set(body, null);
|
|
995
1266
|
return null;
|
|
996
1267
|
}
|
|
@@ -1006,9 +1277,7 @@ const createSession = (checker, flow) => {
|
|
|
1006
1277
|
// write whose VALUE is this body names one such cell; a write this layer
|
|
1007
1278
|
// cannot name means the body can be reached by a name it cannot enumerate.
|
|
1008
1279
|
if (!declared || ts.isFunctionExpression(body) || ts.isArrowFunction(body))
|
|
1009
|
-
for (const write of
|
|
1010
|
-
if (write.value === undefined || write.value === null || unwrapErasedExpression(write.value) !== body)
|
|
1011
|
-
continue;
|
|
1280
|
+
for (const write of writesOfBodyValue(body)) {
|
|
1012
1281
|
const named = write.member ?? (write.naming && ts.isIdentifier(write.naming) ? write.naming.text : null);
|
|
1013
1282
|
if (named === null) {
|
|
1014
1283
|
bodyNames.set(body, null);
|
|
@@ -1124,6 +1393,24 @@ const createSession = (checker, flow) => {
|
|
|
1124
1393
|
callerCandidates.set(owner, answer);
|
|
1125
1394
|
return answer;
|
|
1126
1395
|
};
|
|
1396
|
+
const callerCandidateIndexes = new Map();
|
|
1397
|
+
const callerCandidateIndexOf = (owner) => {
|
|
1398
|
+
const known = callerCandidateIndexes.get(owner);
|
|
1399
|
+
if (known !== undefined)
|
|
1400
|
+
return known;
|
|
1401
|
+
const list = callerCandidatesOf(owner);
|
|
1402
|
+
const positions = new Map();
|
|
1403
|
+
const unconditional = [];
|
|
1404
|
+
list.forEach((candidate, position) => {
|
|
1405
|
+
if (candidate.call === null)
|
|
1406
|
+
unconditional.push(position);
|
|
1407
|
+
else if (!positions.has(candidate.call))
|
|
1408
|
+
positions.set(candidate.call, position);
|
|
1409
|
+
});
|
|
1410
|
+
const index = { list, positions, unconditional, seeded: false };
|
|
1411
|
+
callerCandidateIndexes.set(owner, index);
|
|
1412
|
+
return index;
|
|
1413
|
+
};
|
|
1127
1414
|
let constructionsByOwner = null;
|
|
1128
1415
|
/**
|
|
1129
1416
|
* Every site that constructs: a `new`, or a `super(...)` standing in for one.
|
|
@@ -1141,6 +1428,7 @@ const createSession = (checker, flow) => {
|
|
|
1141
1428
|
* it, the answer is the same set and the edges are none.
|
|
1142
1429
|
*/
|
|
1143
1430
|
const NO_READS = [];
|
|
1431
|
+
const NO_NAMED_READS = [];
|
|
1144
1432
|
const NO_SITES = [];
|
|
1145
1433
|
let constructionSitesByTarget = null;
|
|
1146
1434
|
const constructionSitesTargeting = (owner) => {
|
|
@@ -1318,7 +1606,8 @@ const createSession = (checker, flow) => {
|
|
|
1318
1606
|
let finalCauses = [];
|
|
1319
1607
|
let finalGrounding = [];
|
|
1320
1608
|
let seeded = false;
|
|
1321
|
-
|
|
1609
|
+
// Allocated on the first answer: most nodes never ask an own-key question.
|
|
1610
|
+
let ownKeysAnswers = null;
|
|
1322
1611
|
const evaluate = (required, observe, holdersOf, sealing) => {
|
|
1323
1612
|
const facts = new Set();
|
|
1324
1613
|
const causes = [];
|
|
@@ -1343,6 +1632,8 @@ const createSession = (checker, flow) => {
|
|
|
1343
1632
|
grounding.add(dependency);
|
|
1344
1633
|
return read(dependency);
|
|
1345
1634
|
};
|
|
1635
|
+
/** `read(use(root, reference))`, without minting the node for a use that does nothing (`inertUse`). */
|
|
1636
|
+
const readUse = (root, reference) => inertUse(reference) ? NO_VALUES : read(use(root, reference));
|
|
1346
1637
|
const add = (values) => {
|
|
1347
1638
|
for (const held of values)
|
|
1348
1639
|
facts.add(held);
|
|
@@ -1458,7 +1749,7 @@ const createSession = (checker, flow) => {
|
|
|
1458
1749
|
// round; the re-entry is unknown, and only the outer answer is kept.
|
|
1459
1750
|
if (activeOwnKeys.has(root))
|
|
1460
1751
|
return null;
|
|
1461
|
-
const kept = ownKeysAnswers
|
|
1752
|
+
const kept = ownKeysAnswers?.get(root);
|
|
1462
1753
|
if (kept !== undefined && kept.stamps.every(([held, size]) => held.size === size) && holdersUnchanged(kept.holderStamps)) {
|
|
1463
1754
|
for (const stamps of stampLists)
|
|
1464
1755
|
stamps.push(...kept.stamps);
|
|
@@ -1475,7 +1766,7 @@ const createSession = (checker, flow) => {
|
|
|
1475
1766
|
try {
|
|
1476
1767
|
const answer = ownKeysUncached(root);
|
|
1477
1768
|
ownKeys.set(root, answer);
|
|
1478
|
-
ownKeysAnswers.set(root, { keys: answer, stamps, holderStamps });
|
|
1769
|
+
(ownKeysAnswers ??= new Map()).set(root, { keys: answer, stamps, holderStamps });
|
|
1479
1770
|
return answer;
|
|
1480
1771
|
}
|
|
1481
1772
|
finally {
|
|
@@ -1669,8 +1960,8 @@ const createSession = (checker, flow) => {
|
|
|
1669
1960
|
* Mentions of an exported cell in the modules that import it, or null
|
|
1670
1961
|
* when the set of modules that can read it is not enumerable.
|
|
1671
1962
|
*
|
|
1672
|
-
* `export const
|
|
1673
|
-
*
|
|
1963
|
+
* `export const store = new AppStore()` -- an app's entire store, and
|
|
1964
|
+
* the receiver of every `this.<method>()` in it. An export
|
|
1674
1965
|
* was refused outright unless NOTHING imported it, which reads "someone
|
|
1675
1966
|
* imports this" as "this escaped". It is not an escape while every
|
|
1676
1967
|
* module that can read the name is enumerated: the importers' mentions
|
|
@@ -1703,10 +1994,10 @@ const createSession = (checker, flow) => {
|
|
|
1703
1994
|
readsAfterRebinding(declaration, reference) &&
|
|
1704
1995
|
parameterRebindingsOf(declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
1705
1996
|
continue;
|
|
1706
|
-
add(
|
|
1997
|
+
add(readUse(root, reference));
|
|
1707
1998
|
}
|
|
1708
1999
|
for (const reference of importerMentions(declaration) ?? [])
|
|
1709
|
-
add(
|
|
2000
|
+
add(readUse(root, reference));
|
|
1710
2001
|
};
|
|
1711
2002
|
/**
|
|
1712
2003
|
* A binding pattern taken apart over this value: every element reads one
|
|
@@ -1760,7 +2051,7 @@ const createSession = (checker, flow) => {
|
|
|
1760
2051
|
return false;
|
|
1761
2052
|
for (const setter of bodies)
|
|
1762
2053
|
for (const reference of flow.receiverReferencesToDeclaration(setter))
|
|
1763
|
-
add(
|
|
2054
|
+
add(readUse(root, reference));
|
|
1764
2055
|
return true;
|
|
1765
2056
|
};
|
|
1766
2057
|
/**
|
|
@@ -1842,7 +2133,7 @@ const createSession = (checker, flow) => {
|
|
|
1842
2133
|
continue;
|
|
1843
2134
|
if (writeEdgeByAccess.has(fact) || !keysOf(fact).includes(key))
|
|
1844
2135
|
continue;
|
|
1845
|
-
add(
|
|
2136
|
+
add(readUse(root, fact));
|
|
1846
2137
|
}
|
|
1847
2138
|
};
|
|
1848
2139
|
const setterStores = (setter) => {
|
|
@@ -1932,7 +2223,7 @@ const createSession = (checker, flow) => {
|
|
|
1932
2223
|
continue;
|
|
1933
2224
|
}
|
|
1934
2225
|
for (const mention of spread)
|
|
1935
|
-
add(
|
|
2226
|
+
add(readUse(root, mention));
|
|
1936
2227
|
const parameter = runtimeParametersOf(body)[position];
|
|
1937
2228
|
if (parameter?.dotDotDotToken)
|
|
1938
2229
|
fail('rest-frame', parameter);
|
|
@@ -1954,9 +2245,15 @@ const createSession = (checker, flow) => {
|
|
|
1954
2245
|
if (receiver) {
|
|
1955
2246
|
// `arguments` never holds the receiver, so an arguments-using body
|
|
1956
2247
|
// says nothing about where `this` goes.
|
|
1957
|
-
if (!ts.isArrowFunction(body))
|
|
2248
|
+
if (!ts.isArrowFunction(body)) {
|
|
1958
2249
|
for (const reference of flow.receiverReferencesToDeclaration(body))
|
|
1959
|
-
add(
|
|
2250
|
+
add(readUse(root, reference));
|
|
2251
|
+
// `return this`: the call evaluates to its own receiver, so the
|
|
2252
|
+
// root comes back out HERE, at the call it entered through --
|
|
2253
|
+
// see `returnsOwnReceiver`.
|
|
2254
|
+
if (returnsOwnReceiver(body) && callableCompletionSummaryOf(flow, body)?.execution === 'sync')
|
|
2255
|
+
add(readUse(root, site.call));
|
|
2256
|
+
}
|
|
1960
2257
|
}
|
|
1961
2258
|
else {
|
|
1962
2259
|
const mentions = argumentsReads(body);
|
|
@@ -1965,7 +2262,7 @@ const createSession = (checker, flow) => {
|
|
|
1965
2262
|
continue;
|
|
1966
2263
|
}
|
|
1967
2264
|
for (const mention of mentions)
|
|
1968
|
-
add(
|
|
2265
|
+
add(readUse(root, mention));
|
|
1969
2266
|
const parameter = runtimeParametersOf(body)[position];
|
|
1970
2267
|
if (parameter?.dotDotDotToken)
|
|
1971
2268
|
fail('rest-frame', parameter);
|
|
@@ -1987,7 +2284,7 @@ const createSession = (checker, flow) => {
|
|
|
1987
2284
|
const positioned = outermostErasureOf(reference);
|
|
1988
2285
|
if (positioned !== reference) {
|
|
1989
2286
|
if (ts.isExpression(positioned))
|
|
1990
|
-
add(
|
|
2287
|
+
add(readUse(root, positioned));
|
|
1991
2288
|
else
|
|
1992
2289
|
fail('unindexed-use', positioned);
|
|
1993
2290
|
return;
|
|
@@ -2021,7 +2318,7 @@ const createSession = (checker, flow) => {
|
|
|
2021
2318
|
fail('unmatched-commonjs-export', reference);
|
|
2022
2319
|
else
|
|
2023
2320
|
for (const alias of moduleUses)
|
|
2024
|
-
add(
|
|
2321
|
+
add(readUse(root, alias));
|
|
2025
2322
|
return;
|
|
2026
2323
|
}
|
|
2027
2324
|
const left = unwrapNaming(parent.left);
|
|
@@ -2051,8 +2348,8 @@ const createSession = (checker, flow) => {
|
|
|
2051
2348
|
fail('unproven-intrinsic-member-installation', left);
|
|
2052
2349
|
else
|
|
2053
2350
|
for (const access of installed.reads)
|
|
2054
|
-
add(
|
|
2055
|
-
add(
|
|
2351
|
+
add(readUse(root, access));
|
|
2352
|
+
add(readUse(root, parent));
|
|
2056
2353
|
return;
|
|
2057
2354
|
}
|
|
2058
2355
|
const keys = keysOf(left);
|
|
@@ -2097,14 +2394,14 @@ const createSession = (checker, flow) => {
|
|
|
2097
2394
|
}
|
|
2098
2395
|
else
|
|
2099
2396
|
fail('unmodelled-store', left);
|
|
2100
|
-
add(
|
|
2397
|
+
add(readUse(root, parent));
|
|
2101
2398
|
return;
|
|
2102
2399
|
}
|
|
2103
2400
|
if (parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken ||
|
|
2104
2401
|
parent.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
2105
2402
|
parent.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
|
|
2106
2403
|
parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
2107
|
-
add(
|
|
2404
|
+
add(readUse(root, parent));
|
|
2108
2405
|
return;
|
|
2109
2406
|
}
|
|
2110
2407
|
if (parent.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
@@ -2124,7 +2421,7 @@ const createSession = (checker, flow) => {
|
|
|
2124
2421
|
}
|
|
2125
2422
|
if (ts.isConditionalExpression(parent)) {
|
|
2126
2423
|
if (parent.condition !== reference)
|
|
2127
|
-
add(
|
|
2424
|
+
add(readUse(root, parent));
|
|
2128
2425
|
return;
|
|
2129
2426
|
}
|
|
2130
2427
|
if (ts.isPropertyAssignment(parent) && parent.initializer === reference) {
|
|
@@ -2179,7 +2476,7 @@ const createSession = (checker, flow) => {
|
|
|
2179
2476
|
// sites as a key coercion, so `this.run()` had no callable slot at
|
|
2180
2477
|
// all -- the one place a member name is not a key being coerced.
|
|
2181
2478
|
if (ts.isPropertyAccessExpression(parent) && parent.name === reference) {
|
|
2182
|
-
add(
|
|
2479
|
+
add(readUse(root, parent));
|
|
2183
2480
|
return;
|
|
2184
2481
|
}
|
|
2185
2482
|
fail('coercing-property-key', reference);
|
|
@@ -2371,7 +2668,7 @@ const createSession = (checker, flow) => {
|
|
|
2371
2668
|
// intrinsic returns it, whoever reads the call.
|
|
2372
2669
|
facts.add(parent);
|
|
2373
2670
|
if (plan.returnsTarget && !ts.isExpressionStatement(parent.parent))
|
|
2374
|
-
add(
|
|
2671
|
+
add(readUse(root, parent));
|
|
2375
2672
|
}
|
|
2376
2673
|
else if (parent.arguments[2] === reference) {
|
|
2377
2674
|
// The descriptor literal: its `value` is copied into the target
|
|
@@ -2394,7 +2691,7 @@ const createSession = (checker, flow) => {
|
|
|
2394
2691
|
// not a literal could run getters, which this does not enter.
|
|
2395
2692
|
facts.add(parent);
|
|
2396
2693
|
if (bulk.target === reference)
|
|
2397
|
-
add(
|
|
2694
|
+
add(readUse(root, parent));
|
|
2398
2695
|
else if (!ts.isObjectLiteralExpression(root))
|
|
2399
2696
|
fail('bulk-assign-source-unmodelled', reference);
|
|
2400
2697
|
return;
|
|
@@ -2420,7 +2717,7 @@ const createSession = (checker, flow) => {
|
|
|
2420
2717
|
const continuations = collectionValueContinuationsOf(checker, flow, parent, reference, nativeProtocolClosed);
|
|
2421
2718
|
if (continuations !== null) {
|
|
2422
2719
|
for (const continued of continuations)
|
|
2423
|
-
add(
|
|
2720
|
+
add(readUse(root, continued));
|
|
2424
2721
|
return;
|
|
2425
2722
|
}
|
|
2426
2723
|
}
|
|
@@ -2444,9 +2741,14 @@ const createSession = (checker, flow) => {
|
|
|
2444
2741
|
return;
|
|
2445
2742
|
}
|
|
2446
2743
|
read(closure(body));
|
|
2744
|
+
// The body's own receiver, returned: it reaches only the calls it was
|
|
2745
|
+
// the receiver of, and `forward` continues it at each of those. See
|
|
2746
|
+
// `returnsOwnReceiver`.
|
|
2747
|
+
if (isOwnReceiverReturn(reference, body))
|
|
2748
|
+
return;
|
|
2447
2749
|
for (const call of read(callersOf(body)))
|
|
2448
2750
|
if (ts.isCallExpression(call))
|
|
2449
|
-
add(
|
|
2751
|
+
add(readUse(root, call));
|
|
2450
2752
|
return;
|
|
2451
2753
|
}
|
|
2452
2754
|
// Enumerating an object reads its KEY SET and nothing else: no slot is
|
|
@@ -2721,6 +3023,36 @@ const createSession = (checker, flow) => {
|
|
|
2721
3023
|
fail('unmodelled-value-origin');
|
|
2722
3024
|
break;
|
|
2723
3025
|
}
|
|
3026
|
+
case 'proxy-result': {
|
|
3027
|
+
if (proxyOperandsOf(query.node) === null) {
|
|
3028
|
+
fail('unproven-proxy-construction');
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
read(nodeQuery('proxy-target', query.node));
|
|
3032
|
+
read(nodeQuery('proxy-handler', query.node));
|
|
3033
|
+
// This identity domain is deliberately separate from generic value
|
|
3034
|
+
// roots: existing class-field consumers interpret NewExpression
|
|
3035
|
+
// origins as physical data, which is not a Proxy get-trap proof.
|
|
3036
|
+
facts.add(query.node);
|
|
3037
|
+
seeded = true;
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
case 'proxy-target':
|
|
3041
|
+
case 'proxy-handler': {
|
|
3042
|
+
const operands = proxyOperandsOf(query.node);
|
|
3043
|
+
if (operands === null) {
|
|
3044
|
+
fail('unproven-proxy-construction');
|
|
3045
|
+
break;
|
|
3046
|
+
}
|
|
3047
|
+
const operand = operands[query.kind === 'proxy-target' ? 0 : 1];
|
|
3048
|
+
for (const root of carry(value(operand))) {
|
|
3049
|
+
if (!isObjectRoot(root))
|
|
3050
|
+
fail('non-object-proxy-operand', operand);
|
|
3051
|
+
else
|
|
3052
|
+
facts.add(root);
|
|
3053
|
+
}
|
|
3054
|
+
break;
|
|
3055
|
+
}
|
|
2724
3056
|
case 'slot':
|
|
2725
3057
|
case 'stored-slot': {
|
|
2726
3058
|
const root = query.node;
|
|
@@ -2822,7 +3154,7 @@ const createSession = (checker, flow) => {
|
|
|
2822
3154
|
// the read yields what the getter's completions yield.
|
|
2823
3155
|
for (const getter of getterRead.getters) {
|
|
2824
3156
|
for (const reference of flow.receiverReferencesToDeclaration(getter))
|
|
2825
|
-
add(
|
|
3157
|
+
add(readUse(root, reference));
|
|
2826
3158
|
const summary = callableCompletionSummaryOf(flow, getter);
|
|
2827
3159
|
if (summary === null || summary.execution !== 'sync')
|
|
2828
3160
|
fail('unmodelled-getter-completion', getter);
|
|
@@ -3010,10 +3342,17 @@ const createSession = (checker, flow) => {
|
|
|
3010
3342
|
// select, and the receiver walk would otherwise end at `new Map()`
|
|
3011
3343
|
// as an opaque construction. The stores themselves continue at
|
|
3012
3344
|
// these reads (`visitUse` below), so the two are one graph.
|
|
3345
|
+
// A key no `set` stored completes `undefined` (Map.prototype.get
|
|
3346
|
+
// step 5): nothing here proves the key present, so that value is
|
|
3347
|
+
// always one of the completions. Without it, the `!list` of
|
|
3348
|
+
// `let list = map.get( k ); if ( !list ) { ...install... }` was
|
|
3349
|
+
// proved object-truthy and the install branch pruned.
|
|
3013
3350
|
const stored = collectionStoredValuesOf(checker, flow, query.node, nativeProtocolClosed);
|
|
3014
3351
|
if (stored !== null) {
|
|
3015
3352
|
for (const candidate of stored)
|
|
3016
3353
|
add(carry(value(candidate)));
|
|
3354
|
+
facts.add(undefinedValue);
|
|
3355
|
+
seeded = true;
|
|
3017
3356
|
break;
|
|
3018
3357
|
}
|
|
3019
3358
|
}
|
|
@@ -3039,6 +3378,119 @@ const createSession = (checker, flow) => {
|
|
|
3039
3378
|
seeded = true;
|
|
3040
3379
|
break;
|
|
3041
3380
|
}
|
|
3381
|
+
case 'constructor-value':
|
|
3382
|
+
case 'constructor-parameter':
|
|
3383
|
+
case 'constructor-completion': {
|
|
3384
|
+
if (!ts.isNewExpression(query.node) ||
|
|
3385
|
+
!ts.isConstructorDeclaration(query.body) ||
|
|
3386
|
+
directBaseConstructorOf(query.node) !== query.body) {
|
|
3387
|
+
fail('unproven-base-constructor-context', query.node);
|
|
3388
|
+
break;
|
|
3389
|
+
}
|
|
3390
|
+
const contextual = (expression) => frameQuery('constructor-value', query.node, query.body, unwrapErasedExpression(expression));
|
|
3391
|
+
if (query.kind === 'constructor-completion') {
|
|
3392
|
+
const summary = callableCompletionSummaryOf(flow, query.body);
|
|
3393
|
+
if (!summary || summary.execution !== 'sync' || summary.mayCompleteUndefined || summary.values.length === 0)
|
|
3394
|
+
fail('incomplete-constructor-object-completion', query.body);
|
|
3395
|
+
else
|
|
3396
|
+
for (const returned of summary.values)
|
|
3397
|
+
add(carry(contextual(returned)));
|
|
3398
|
+
break;
|
|
3399
|
+
}
|
|
3400
|
+
const subject = query.subject;
|
|
3401
|
+
if (!subject) {
|
|
3402
|
+
fail('unindexed-constructor-context');
|
|
3403
|
+
break;
|
|
3404
|
+
}
|
|
3405
|
+
if (query.kind === 'constructor-parameter') {
|
|
3406
|
+
if (!ts.isParameter(subject) ||
|
|
3407
|
+
subject.parent !== query.body ||
|
|
3408
|
+
subject.dotDotDotToken ||
|
|
3409
|
+
flow
|
|
3410
|
+
.writesToDeclaration(subject)
|
|
3411
|
+
.some((write) => write.slot === 'whole' && !['call-argument', 'super-argument', 'default-parameter'].includes(write.edge))) {
|
|
3412
|
+
fail('unmodelled-constructor-parameter', subject);
|
|
3413
|
+
break;
|
|
3414
|
+
}
|
|
3415
|
+
const layout = sourceInvocationFrameLayoutOf(flow, query.node, query.body);
|
|
3416
|
+
const slot = layout?.arguments.kind === 'positional' ? layout.arguments.slots.find((one) => one.parameter === subject) : null;
|
|
3417
|
+
if (!slot || slot.kind !== 'single') {
|
|
3418
|
+
fail('unindexed-constructor-parameter', subject);
|
|
3419
|
+
break;
|
|
3420
|
+
}
|
|
3421
|
+
if (!slot.actual) {
|
|
3422
|
+
if (slot.defaultValue)
|
|
3423
|
+
add(carry(contextual(slot.defaultValue)));
|
|
3424
|
+
else {
|
|
3425
|
+
facts.add(undefinedValue);
|
|
3426
|
+
seeded = true;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
else
|
|
3430
|
+
for (const candidate of carry(value(slot.actual))) {
|
|
3431
|
+
if (ts.isVoidExpression(candidate) && slot.defaultValue)
|
|
3432
|
+
add(carry(contextual(slot.defaultValue)));
|
|
3433
|
+
else
|
|
3434
|
+
facts.add(candidate);
|
|
3435
|
+
}
|
|
3436
|
+
break;
|
|
3437
|
+
}
|
|
3438
|
+
if (ts.isParameter(subject)) {
|
|
3439
|
+
fail('unindexed-constructor-value', subject);
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
const expression = unwrapErasedExpression(subject);
|
|
3443
|
+
const declaration = ts.isIdentifier(expression) ? flow.targetOf(expression)?.declaration : null;
|
|
3444
|
+
if (declaration && ts.isParameter(declaration) && declaration.parent === query.body)
|
|
3445
|
+
add(carry(frameQuery('constructor-parameter', query.node, query.body, declaration)));
|
|
3446
|
+
else if (declaration && ts.isVariableDeclaration(declaration) && ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
3447
|
+
const incoming = sourceBindingValuesOf(checker, flow, declaration, iterationValuesAt);
|
|
3448
|
+
if (incoming === null)
|
|
3449
|
+
fail('unaccounted-constructor-binding', declaration);
|
|
3450
|
+
else
|
|
3451
|
+
for (const entry of incoming)
|
|
3452
|
+
add(carry(contextual(entry)));
|
|
3453
|
+
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3454
|
+
facts.add(undefinedValue);
|
|
3455
|
+
seeded = true;
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
else if (expression.kind === ts.SyntaxKind.ThisKeyword && flow.receiverOwnerOf(expression) === query.body) {
|
|
3459
|
+
// This token belongs ONLY to the explicit allocation domain. It
|
|
3460
|
+
// never passes through value(new C()) or class-field inference.
|
|
3461
|
+
facts.add(query.node);
|
|
3462
|
+
seeded = true;
|
|
3463
|
+
}
|
|
3464
|
+
else if (ts.isNewExpression(expression) && proxyOperandsOf(expression) !== null) {
|
|
3465
|
+
const operands = proxyOperandsOf(expression);
|
|
3466
|
+
for (const operand of operands) {
|
|
3467
|
+
const roots = carry(contextual(operand));
|
|
3468
|
+
if (sealing && roots.size === 0)
|
|
3469
|
+
fail('unresolved-constructor-proxy-operand', operand);
|
|
3470
|
+
for (const root of roots)
|
|
3471
|
+
if (!isObjectRoot(root) || (ts.isNewExpression(root) && root !== query.node && proxyOperandsOf(root) !== null))
|
|
3472
|
+
fail('unsupported-constructor-proxy-operand', operand);
|
|
3473
|
+
}
|
|
3474
|
+
facts.add(expression);
|
|
3475
|
+
seeded = true;
|
|
3476
|
+
}
|
|
3477
|
+
else if (ts.isConditionalExpression(expression)) {
|
|
3478
|
+
// Require the complete condition family, not its first discovered
|
|
3479
|
+
// value or checker nullability. New facts can only add branch
|
|
3480
|
+
// dependencies. An unknown-truth root keeps both arms; an opaque
|
|
3481
|
+
// condition refuses this context rather than dropping that path.
|
|
3482
|
+
for (const condition of read(contextual(expression.condition))) {
|
|
3483
|
+
const truth = conditionTruthOf(condition);
|
|
3484
|
+
if (truth !== false)
|
|
3485
|
+
add(carry(contextual(expression.whenTrue)));
|
|
3486
|
+
if (truth !== true)
|
|
3487
|
+
add(carry(contextual(expression.whenFalse)));
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
else
|
|
3491
|
+
add(carry(value(expression)));
|
|
3492
|
+
break;
|
|
3493
|
+
}
|
|
3042
3494
|
case 'frame-receiver':
|
|
3043
3495
|
case 'frame-argument':
|
|
3044
3496
|
case 'frame-parameter':
|
|
@@ -3344,10 +3796,34 @@ const createSession = (checker, flow) => {
|
|
|
3344
3796
|
for (const instance of familyInstancesOf(owner.parent, 'member-family-open') ?? [])
|
|
3345
3797
|
read(closure(instance));
|
|
3346
3798
|
}
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3799
|
+
// Which candidates target this owner is asked the other way round:
|
|
3800
|
+
// the `targets` states that hold the owner, from the reverse index,
|
|
3801
|
+
// looked up in the owner's candidate positions. Observing every
|
|
3802
|
+
// candidate's `targets` instead stored one edge per (owner,
|
|
3803
|
+
// candidate) pair -- for a body reached by name or handed to a host
|
|
3804
|
+
// callee, every same-named or unspelled call in the program -- and
|
|
3805
|
+
// that was the second-largest share of a large program's edges.
|
|
3806
|
+
const candidates = callerCandidateIndexOf(owner);
|
|
3807
|
+
if (!candidates.seeded) {
|
|
3808
|
+
candidates.seeded = true;
|
|
3809
|
+
for (const candidate of candidates.list)
|
|
3810
|
+
if (candidate.call !== null)
|
|
3811
|
+
seed(targets(candidate.call));
|
|
3350
3812
|
}
|
|
3813
|
+
const matched = [];
|
|
3814
|
+
for (const holder of holdersOf(owner)) {
|
|
3815
|
+
if (holder.kind !== 'targets')
|
|
3816
|
+
continue;
|
|
3817
|
+
const position = candidates.positions.get(holder.node);
|
|
3818
|
+
if (position !== undefined)
|
|
3819
|
+
matched.push(position);
|
|
3820
|
+
}
|
|
3821
|
+
for (const position of candidates.unconditional)
|
|
3822
|
+
matched.push(position);
|
|
3823
|
+
// Candidate order, the order the scan this replaces added them in.
|
|
3824
|
+
matched.sort((a, b) => a - b);
|
|
3825
|
+
for (const position of matched)
|
|
3826
|
+
facts.add(candidates.list[position].site.call);
|
|
3351
3827
|
break;
|
|
3352
3828
|
}
|
|
3353
3829
|
case 'closure': {
|
|
@@ -3373,7 +3849,7 @@ const createSession = (checker, flow) => {
|
|
|
3373
3849
|
refs(root, root);
|
|
3374
3850
|
}
|
|
3375
3851
|
else if (ts.isExpression(root))
|
|
3376
|
-
add(
|
|
3852
|
+
add(readUse(root, root));
|
|
3377
3853
|
else
|
|
3378
3854
|
fail('unmodelled-root');
|
|
3379
3855
|
if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
@@ -3385,14 +3861,14 @@ const createSession = (checker, flow) => {
|
|
|
3385
3861
|
for (const owner of owners) {
|
|
3386
3862
|
if (!isClassSpelledSourceClass(owner)) {
|
|
3387
3863
|
for (const reference of flow.receiverReferencesToDeclaration(owner))
|
|
3388
|
-
add(
|
|
3864
|
+
add(readUse(root, reference));
|
|
3389
3865
|
continue;
|
|
3390
3866
|
}
|
|
3391
3867
|
for (const member of owner.members) {
|
|
3392
3868
|
if (ts.isConstructorDeclaration(member) ||
|
|
3393
3869
|
(ts.isPropertyDeclaration(member) && (ts.getCombinedModifierFlags(member) & ts.ModifierFlags.Static) === 0))
|
|
3394
3870
|
for (const reference of flow.receiverReferencesToDeclaration(member))
|
|
3395
|
-
add(
|
|
3871
|
+
add(readUse(root, reference));
|
|
3396
3872
|
}
|
|
3397
3873
|
}
|
|
3398
3874
|
}
|
|
@@ -3414,6 +3890,37 @@ const createSession = (checker, flow) => {
|
|
|
3414
3890
|
facts.add(entry.access);
|
|
3415
3891
|
break;
|
|
3416
3892
|
}
|
|
3893
|
+
case 'key-reads': {
|
|
3894
|
+
// `unknown-reads`' inversion for the reads that spell their key:
|
|
3895
|
+
// the receivers holding this container, from the reverse index,
|
|
3896
|
+
// then the reads of a reaching key made through each. A receiver
|
|
3897
|
+
// is a holder only once it is seeded, so every receiver of every
|
|
3898
|
+
// reaching key is seeded first -- the states the per-read
|
|
3899
|
+
// `observe` this replaces created as a side effect.
|
|
3900
|
+
const container = query.node;
|
|
3901
|
+
const reaching = readKeysReaching(container, query.key);
|
|
3902
|
+
for (const key of reaching) {
|
|
3903
|
+
if (seededReadKeys.has(key))
|
|
3904
|
+
continue;
|
|
3905
|
+
seededReadKeys.add(key);
|
|
3906
|
+
for (const entry of readsByKey.get(key) ?? NO_READS)
|
|
3907
|
+
seed(entry.receiver);
|
|
3908
|
+
}
|
|
3909
|
+
const found = [];
|
|
3910
|
+
for (const holder of holdersOf(container)) {
|
|
3911
|
+
const byKey = namedReadsByReceiver.get(holder);
|
|
3912
|
+
if (byKey === undefined)
|
|
3913
|
+
continue;
|
|
3914
|
+
for (const key of reaching)
|
|
3915
|
+
for (const entry of byKey.get(key) ?? NO_NAMED_READS)
|
|
3916
|
+
found.push(entry);
|
|
3917
|
+
}
|
|
3918
|
+
// Program order, the order the scan this replaces discovered them in.
|
|
3919
|
+
found.sort((a, b) => a.order - b.order);
|
|
3920
|
+
for (const entry of found)
|
|
3921
|
+
facts.add(entry.access);
|
|
3922
|
+
break;
|
|
3923
|
+
}
|
|
3417
3924
|
case 'own-keys': {
|
|
3418
3925
|
const root = query.node;
|
|
3419
3926
|
const keys = ownKeysOf(root);
|
|
@@ -3479,20 +3986,12 @@ const createSession = (checker, flow) => {
|
|
|
3479
3986
|
for (const key of plan.keys)
|
|
3480
3987
|
add(read(publication(query.root, held, key)));
|
|
3481
3988
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
: [query.key];
|
|
3489
|
-
for (const alias of aliases)
|
|
3490
|
-
for (const entry of readsByKey.get(alias) ?? NO_READS) {
|
|
3491
|
-
if (!observe(entry.receiver).has(query.node))
|
|
3492
|
-
continue;
|
|
3493
|
-
if (keyReaches(query.node, keysOf(entry.access), query.key))
|
|
3494
|
-
add(read(use(query.root, entry.access)));
|
|
3495
|
-
}
|
|
3989
|
+
// Discovery-only, as the per-read receiver test it replaces was.
|
|
3990
|
+
for (const access of observe(keyReadsOf(query.node, query.key))) {
|
|
3991
|
+
if (!ts.isPropertyAccessExpression(access) && !ts.isElementAccessExpression(access))
|
|
3992
|
+
continue;
|
|
3993
|
+
add(readUse(query.root, access));
|
|
3994
|
+
}
|
|
3496
3995
|
// Discovery-only, exactly as the receiver test it replaces was: a
|
|
3497
3996
|
// publication never required the unknown reads to have settled, it
|
|
3498
3997
|
// only had to see the ones that had.
|
|
@@ -3500,7 +3999,7 @@ const createSession = (checker, flow) => {
|
|
|
3500
3999
|
if (!ts.isPropertyAccessExpression(access) && !ts.isElementAccessExpression(access))
|
|
3501
4000
|
continue;
|
|
3502
4001
|
if (keyReaches(query.node, keysOf(access), query.key))
|
|
3503
|
-
add(
|
|
4002
|
+
add(readUse(query.root, access));
|
|
3504
4003
|
}
|
|
3505
4004
|
// The value this key holds also reaches every cell a binding element
|
|
3506
4005
|
// of this container declares. Enumerating only `propertyAccesses`
|
|
@@ -4024,6 +4523,46 @@ const createSession = (checker, flow) => {
|
|
|
4024
4523
|
return false;
|
|
4025
4524
|
},
|
|
4026
4525
|
invocationTargetsOf,
|
|
4526
|
+
proxyResultIdentityOf: (expression) => {
|
|
4527
|
+
if (proxyOperandsOf(expression) === null)
|
|
4528
|
+
return null;
|
|
4529
|
+
const result = admitted(nodeQuery('proxy-result', expression));
|
|
4530
|
+
const targets = admitted(nodeQuery('proxy-target', expression));
|
|
4531
|
+
const handlers = admitted(nodeQuery('proxy-handler', expression));
|
|
4532
|
+
return result?.length === 1 && result[0] === expression && targets?.length && handlers?.length
|
|
4533
|
+
? { result: expression, targets, handlers }
|
|
4534
|
+
: null;
|
|
4535
|
+
},
|
|
4536
|
+
constructorProxyResultIdentitiesOf: (construction) => {
|
|
4537
|
+
const body = directBaseConstructorOf(construction);
|
|
4538
|
+
if (body === null)
|
|
4539
|
+
return null;
|
|
4540
|
+
const results = admitted(frameQuery('constructor-completion', construction, body));
|
|
4541
|
+
if (!results?.length)
|
|
4542
|
+
return null;
|
|
4543
|
+
const answer = [];
|
|
4544
|
+
for (const result of results) {
|
|
4545
|
+
if (!ts.isNewExpression(result))
|
|
4546
|
+
return null;
|
|
4547
|
+
const operands = proxyOperandsOf(result);
|
|
4548
|
+
if (operands === null)
|
|
4549
|
+
return null;
|
|
4550
|
+
const targets = admitted(frameQuery('constructor-value', construction, body, operands[0]));
|
|
4551
|
+
const handlers = admitted(frameQuery('constructor-value', construction, body, operands[1]));
|
|
4552
|
+
if (!targets?.length || !handlers?.length)
|
|
4553
|
+
return null;
|
|
4554
|
+
answer.push({
|
|
4555
|
+
construction,
|
|
4556
|
+
constructor: body,
|
|
4557
|
+
result,
|
|
4558
|
+
handlers,
|
|
4559
|
+
targets: targets.map((target) => target === construction
|
|
4560
|
+
? { kind: 'base-constructor-allocation', construction, constructor: body }
|
|
4561
|
+
: { kind: 'source-object', value: target })
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
return answer;
|
|
4565
|
+
},
|
|
4027
4566
|
valuesOf: (expression) => admitted(value(expression)),
|
|
4028
4567
|
closedValuesOf: (expression) => {
|
|
4029
4568
|
const roots = admitted(value(expression));
|