@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
|
@@ -70,7 +70,81 @@ const invalidatableComponentSolver = (expand, mode) => {
|
|
|
70
70
|
* admitted here unconditionally, before any edge is walked.
|
|
71
71
|
*/
|
|
72
72
|
const NO_DOMAINS = new Set();
|
|
73
|
+
const NO_MEMBERS = [];
|
|
73
74
|
const groundingCache = new Map();
|
|
75
|
+
/**
|
|
76
|
+
* Whether a node reaches a witness of `domain` over edges labelled with
|
|
77
|
+
* `domain`, for every node any walk has settled. A node's own seed counts.
|
|
78
|
+
*
|
|
79
|
+
* This is what makes the walk below linear in the graph rather than in
|
|
80
|
+
* (nodes asked x nodes reached). A per-root search that remembered only
|
|
81
|
+
* its root's answer re-walked the same region from every member of a
|
|
82
|
+
* cyclic component; on a large program the component is most of the graph
|
|
83
|
+
* and a region with no witness in it is walked whole, once per member --
|
|
84
|
+
* quadratic, and the reason a solve that had already converged never
|
|
85
|
+
* finished. One walk settles every node it reaches: the region it visits is
|
|
86
|
+
* closed under the domain's edges (an edge leaving it ends at a node already
|
|
87
|
+
* settled), so each visited node's answer is exactly "a witness is reachable
|
|
88
|
+
* inside the region or through a settled node", which a backward pass from
|
|
89
|
+
* the witnesses decides for all of them at once.
|
|
90
|
+
*
|
|
91
|
+
* Invalidated with everything else: a domain edge is also a required edge
|
|
92
|
+
* (checked in `nodeOf`), so a node whose answer could have read a changed
|
|
93
|
+
* node is one of the required dependents `invalidate` already evicts.
|
|
94
|
+
*/
|
|
95
|
+
const groundedIn = new Map();
|
|
96
|
+
const groundedFor = (domain, start) => {
|
|
97
|
+
let settled = groundedIn.get(domain);
|
|
98
|
+
if (settled === undefined)
|
|
99
|
+
groundedIn.set(domain, (settled = new Map()));
|
|
100
|
+
const known = settled.get(start);
|
|
101
|
+
if (known !== undefined)
|
|
102
|
+
return known;
|
|
103
|
+
// Forward over the domain's edges, stopping at settled nodes.
|
|
104
|
+
const region = [start];
|
|
105
|
+
const inRegion = new Set(region);
|
|
106
|
+
const predecessors = new Map();
|
|
107
|
+
const witnesses = [];
|
|
108
|
+
for (let cursor = 0; cursor < region.length; cursor++) {
|
|
109
|
+
const key = region[cursor];
|
|
110
|
+
const node = nodeOf(key);
|
|
111
|
+
if (node.groundingSeeds?.includes(domain)) {
|
|
112
|
+
witnesses.push(key);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const edge of node.groundingDependencies ?? []) {
|
|
116
|
+
if (edge.domain !== domain)
|
|
117
|
+
continue;
|
|
118
|
+
const dependency = edge.dependency;
|
|
119
|
+
const answer = settled.get(dependency);
|
|
120
|
+
if (answer === true) {
|
|
121
|
+
witnesses.push(key);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (answer === false)
|
|
125
|
+
continue;
|
|
126
|
+
let incoming = predecessors.get(dependency);
|
|
127
|
+
if (incoming === undefined)
|
|
128
|
+
predecessors.set(dependency, (incoming = []));
|
|
129
|
+
incoming.push(key);
|
|
130
|
+
if (!inRegion.has(dependency)) {
|
|
131
|
+
inRegion.add(dependency);
|
|
132
|
+
region.push(dependency);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Backward from the witnesses: everything that reaches one is grounded.
|
|
137
|
+
const grounded = new Set(witnesses);
|
|
138
|
+
for (let cursor = 0; cursor < witnesses.length; cursor++)
|
|
139
|
+
for (const predecessor of predecessors.get(witnesses[cursor]) ?? [])
|
|
140
|
+
if (!grounded.has(predecessor)) {
|
|
141
|
+
grounded.add(predecessor);
|
|
142
|
+
witnesses.push(predecessor);
|
|
143
|
+
}
|
|
144
|
+
for (const key of region)
|
|
145
|
+
settled.set(key, grounded.has(key));
|
|
146
|
+
return grounded.has(start);
|
|
147
|
+
};
|
|
74
148
|
const groundingDomainsFrom = (root) => {
|
|
75
149
|
const known = groundingCache.get(root);
|
|
76
150
|
if (known !== undefined)
|
|
@@ -85,32 +159,12 @@ const invalidatableComponentSolver = (expand, mode) => {
|
|
|
85
159
|
groundingCache.set(root, NO_DOMAINS);
|
|
86
160
|
return NO_DOMAINS;
|
|
87
161
|
}
|
|
162
|
+
// The root's own seeds, whatever their domain, and each domain one of its
|
|
163
|
+
// edges is labelled with when that edge leads to a witness of it.
|
|
88
164
|
const found = new Set(rootNode.groundingSeeds ?? []);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for (const edge of node.groundingDependencies ?? [])
|
|
93
|
-
if (domain === null || edge.domain === domain)
|
|
94
|
-
frontier.push({ key: edge.dependency, domain: edge.domain });
|
|
95
|
-
};
|
|
96
|
-
follow(rootNode, null);
|
|
97
|
-
for (let cursor = 0; cursor < frontier.length; cursor++) {
|
|
98
|
-
const { key, domain } = frontier[cursor];
|
|
99
|
-
if (found.has(domain))
|
|
100
|
-
continue;
|
|
101
|
-
let visited = seen.get(domain);
|
|
102
|
-
if (visited === undefined)
|
|
103
|
-
seen.set(domain, (visited = new Set()));
|
|
104
|
-
if (visited.has(key))
|
|
105
|
-
continue;
|
|
106
|
-
visited.add(key);
|
|
107
|
-
const node = nodeOf(key);
|
|
108
|
-
if (node.groundingSeeds?.includes(domain)) {
|
|
109
|
-
found.add(domain);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
follow(node, domain);
|
|
113
|
-
}
|
|
165
|
+
for (const edge of rootNode.groundingDependencies ?? [])
|
|
166
|
+
if (!found.has(edge.domain) && groundedFor(edge.domain, edge.dependency))
|
|
167
|
+
found.add(edge.domain);
|
|
114
168
|
groundingCache.set(root, found);
|
|
115
169
|
return found;
|
|
116
170
|
};
|
|
@@ -278,7 +332,11 @@ const invalidatableComponentSolver = (expand, mode) => {
|
|
|
278
332
|
if (unseededDomains.size > 0)
|
|
279
333
|
complete = false;
|
|
280
334
|
}
|
|
281
|
-
|
|
335
|
+
// Kept for `explain`, and empty for nearly every component: the shared
|
|
336
|
+
// empties keep a Set and an array per node of a large graph off the heap.
|
|
337
|
+
const component = unseededDomains.size === 0
|
|
338
|
+
? { members, unseededCycle, unseededDomains: NO_DOMAINS, unmet: NO_MEMBERS }
|
|
339
|
+
: { members, unseededCycle, unseededDomains, unmet };
|
|
282
340
|
for (const current of members) {
|
|
283
341
|
componentOf.set(current, component);
|
|
284
342
|
results.set(current, { status: complete ? 'complete' : 'refused', grounded });
|
|
@@ -300,12 +358,21 @@ const invalidatableComponentSolver = (expand, mode) => {
|
|
|
300
358
|
results.delete(key);
|
|
301
359
|
componentOf.delete(key);
|
|
302
360
|
groundingCache.delete(key);
|
|
361
|
+
for (const settled of groundedIn.values())
|
|
362
|
+
settled.delete(key);
|
|
303
363
|
for (const dependent of requiredDependentsOf(key))
|
|
304
364
|
queue.push(dependent);
|
|
305
365
|
}
|
|
306
366
|
};
|
|
307
367
|
return { solve, invalidate };
|
|
308
368
|
};
|
|
369
|
+
/** `GEA_SOLVER_COUNTS` exit reports of the solvers still alive at exit. */
|
|
370
|
+
const exitReports = new Set();
|
|
371
|
+
if (process.env['GEA_SOLVER_COUNTS'] !== undefined)
|
|
372
|
+
process.on('exit', () => {
|
|
373
|
+
for (const report of exitReports)
|
|
374
|
+
report.deref()?.();
|
|
375
|
+
});
|
|
309
376
|
export const dependencyFactSolver = (expand, mode) => {
|
|
310
377
|
const states = new Map();
|
|
311
378
|
// States, not keys: `propagate` used to hold keys and call `stateOf(key)`
|
|
@@ -333,16 +400,16 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
333
400
|
const stateOf = (key) => {
|
|
334
401
|
let state = states.get(key);
|
|
335
402
|
if (state === undefined) {
|
|
403
|
+
// No edge readers kept on the state: three closures and their context
|
|
404
|
+
// for the life of every state, when only a running transfer or seal ever
|
|
405
|
+
// calls them. `transferOf`/`sealOf` mint them for that call.
|
|
336
406
|
const built = {
|
|
337
407
|
key,
|
|
338
408
|
definition: expand(key),
|
|
339
|
-
observedDependencies:
|
|
340
|
-
requiredDependencies:
|
|
409
|
+
observedDependencies: null,
|
|
410
|
+
requiredDependencies: null,
|
|
341
411
|
facts: new Set(),
|
|
342
|
-
dependents:
|
|
343
|
-
read: (dependency) => readFrom(built, dependency),
|
|
344
|
-
observe: (dependency) => observeFrom(built, dependency),
|
|
345
|
-
holdersOf: (fact) => holdersOfFrom(built, fact),
|
|
412
|
+
dependents: null,
|
|
346
413
|
indexed: false
|
|
347
414
|
};
|
|
348
415
|
state = built;
|
|
@@ -415,20 +482,31 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
415
482
|
// for a state the caller is already holding was, on a large program, a quarter
|
|
416
483
|
// of the whole compile.
|
|
417
484
|
const factsFrom = (ownerState, dependency, required) => {
|
|
418
|
-
let
|
|
485
|
+
let observed = ownerState.observedDependencies;
|
|
486
|
+
let dependencyState = observed === null ? undefined : observed.get(dependency);
|
|
419
487
|
let changed = false;
|
|
420
488
|
if (dependencyState === undefined) {
|
|
421
489
|
dependencyState = stateOf(dependency);
|
|
422
|
-
|
|
423
|
-
|
|
490
|
+
if (observed === null)
|
|
491
|
+
ownerState.observedDependencies = observed = new Map();
|
|
492
|
+
observed.set(dependency, dependencyState);
|
|
493
|
+
let dependents = dependencyState.dependents;
|
|
494
|
+
if (dependents === null)
|
|
495
|
+
dependencyState.dependents = dependents = new Set();
|
|
496
|
+
dependents.add(ownerState);
|
|
424
497
|
dependencyRevision++;
|
|
425
498
|
changed = true;
|
|
426
499
|
}
|
|
427
|
-
if (required
|
|
428
|
-
ownerState.requiredDependencies
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
500
|
+
if (required) {
|
|
501
|
+
let requiredDependencies = ownerState.requiredDependencies;
|
|
502
|
+
if (requiredDependencies === null)
|
|
503
|
+
ownerState.requiredDependencies = requiredDependencies = new Set();
|
|
504
|
+
if (!requiredDependencies.has(dependency)) {
|
|
505
|
+
requiredDependencies.add(dependency);
|
|
506
|
+
componentDirty.add(ownerState.key);
|
|
507
|
+
dependencyRevision++;
|
|
508
|
+
changed = true;
|
|
509
|
+
}
|
|
432
510
|
}
|
|
433
511
|
// A new observation may expose facts on the next pass. An upgrade also
|
|
434
512
|
// invalidates the current seal even though the fact edge already existed.
|
|
@@ -445,6 +523,10 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
445
523
|
};
|
|
446
524
|
const readFrom = (ownerState, dependency) => factsFrom(ownerState, dependency, true);
|
|
447
525
|
const observeFrom = (ownerState, dependency) => factsFrom(ownerState, dependency, false);
|
|
526
|
+
// A state's edge readers, minted per transfer or seal call rather than kept
|
|
527
|
+
// on every state (see `stateOf`).
|
|
528
|
+
const transferOf = (state) => state.definition.transfer((dependency) => readFrom(state, dependency), (dependency) => observeFrom(state, dependency), (fact) => holdersOfFrom(state, fact));
|
|
529
|
+
const sealOf = (state) => state.definition.seal((dependency) => readFrom(state, dependency), (dependency) => observeFrom(state, dependency), (fact) => holdersOfFrom(state, fact));
|
|
448
530
|
const propagate = () => {
|
|
449
531
|
for (let cursor = 0; cursor < queue.length; cursor++) {
|
|
450
532
|
const state = queue[cursor];
|
|
@@ -457,14 +539,17 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
457
539
|
// dependent already queued. The set can still grow mid-transfer (a state
|
|
458
540
|
// that reads itself), and then the newcomer must be woken too.
|
|
459
541
|
let wokenSize = -1;
|
|
460
|
-
for (const fact of
|
|
542
|
+
for (const fact of transferOf(state)) {
|
|
461
543
|
if (state.facts.has(fact))
|
|
462
544
|
continue;
|
|
463
545
|
state.facts.add(fact);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
546
|
+
const dependents = state.dependents;
|
|
547
|
+
const size = dependents === null ? 0 : dependents.size;
|
|
548
|
+
if (wokenSize !== size) {
|
|
549
|
+
wokenSize = size;
|
|
550
|
+
if (dependents !== null)
|
|
551
|
+
for (const dependent of dependents)
|
|
552
|
+
enqueue(dependent);
|
|
468
553
|
}
|
|
469
554
|
// Recorded at the exact point a fact is genuinely NEW, so `holders`
|
|
470
555
|
// never grows for a re-observed fact.
|
|
@@ -486,10 +571,10 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
486
571
|
const componentDirty = new Set();
|
|
487
572
|
const requiredDependentsOf = function* (key) {
|
|
488
573
|
const state = states.get(key);
|
|
489
|
-
if (state === undefined)
|
|
574
|
+
if (state === undefined || state.dependents === null)
|
|
490
575
|
return;
|
|
491
576
|
for (const dependent of state.dependents)
|
|
492
|
-
if (dependent.requiredDependencies
|
|
577
|
+
if (dependent.requiredDependencies?.has(key) === true)
|
|
493
578
|
yield dependent.key;
|
|
494
579
|
};
|
|
495
580
|
// A changed seal evicts every cached component answer that reaches it, so
|
|
@@ -535,9 +620,9 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
535
620
|
// falls back to a single 'unknown' bucket for any key not shaped this way.
|
|
536
621
|
const perKind = new Map();
|
|
537
622
|
for (const state of states.values()) {
|
|
538
|
-
observed += state.observedDependencies
|
|
539
|
-
required += state.requiredDependencies
|
|
540
|
-
dependents += state.dependents
|
|
623
|
+
observed += state.observedDependencies?.size ?? 0;
|
|
624
|
+
required += state.requiredDependencies?.size ?? 0;
|
|
625
|
+
dependents += state.dependents?.size ?? 0;
|
|
541
626
|
facts += state.facts.size;
|
|
542
627
|
const kind = state.key.kind;
|
|
543
628
|
const bucketKey = typeof kind === 'string' ? kind : 'unknown';
|
|
@@ -545,8 +630,8 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
545
630
|
if (bucket === undefined)
|
|
546
631
|
perKind.set(bucketKey, (bucket = { states: 0, observed: 0, required: 0, facts: 0 }));
|
|
547
632
|
bucket.states++;
|
|
548
|
-
bucket.observed += state.observedDependencies
|
|
549
|
-
bucket.required += state.requiredDependencies
|
|
633
|
+
bucket.observed += state.observedDependencies?.size ?? 0;
|
|
634
|
+
bucket.required += state.requiredDependencies?.size ?? 0;
|
|
550
635
|
bucket.facts += state.facts.size;
|
|
551
636
|
}
|
|
552
637
|
const byKind = [...perKind]
|
|
@@ -580,8 +665,12 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
580
665
|
return;
|
|
581
666
|
console.error(`[SOLVER] roots=${counts.roots} states=${states.size} transfers=${counts.transfers} seals=${counts.seals} component-expansions=${counts.componentNodes}${sizes()}${describeRoot()}`);
|
|
582
667
|
};
|
|
668
|
+
// Weakly: an exit listener closing over `report` kept every solver's whole
|
|
669
|
+
// graph alive for the rest of the process, so a run measured with counts on
|
|
670
|
+
// held each retired census round's session (~3 GB apiece on a large program)
|
|
671
|
+
// and ran out of heap where the same run without counts did not.
|
|
583
672
|
if (countsEnabled)
|
|
584
|
-
|
|
673
|
+
exitReports.add(new WeakRef(report));
|
|
585
674
|
const NO_DEPENDENCIES = [];
|
|
586
675
|
const solve = (root) => {
|
|
587
676
|
counts.roots++;
|
|
@@ -605,7 +694,7 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
605
694
|
counts.seals++;
|
|
606
695
|
if (countsEnabled && counts.seals % 200000 === 0)
|
|
607
696
|
report();
|
|
608
|
-
const next =
|
|
697
|
+
const next = sealOf(state);
|
|
609
698
|
if (sealChanged(sealed.get(key), next))
|
|
610
699
|
componentDirty.add(key);
|
|
611
700
|
sealed.set(key, next);
|
|
@@ -631,7 +720,7 @@ export const dependencyFactSolver = (expand, mode) => {
|
|
|
631
720
|
const local = sealed.get(key);
|
|
632
721
|
if (state === undefined || local === undefined)
|
|
633
722
|
throw new Error('unsealed dependency fact node');
|
|
634
|
-
return { ...local, dependencies: [...state.requiredDependencies] };
|
|
723
|
+
return { ...local, dependencies: state.requiredDependencies === null ? NO_DEPENDENCIES : [...state.requiredDependencies] };
|
|
635
724
|
}, mode);
|
|
636
725
|
else if (componentDirty.size > 0)
|
|
637
726
|
componentSolver.invalidate(componentDirty, requiredDependentsOf);
|
|
@@ -37,6 +37,15 @@ export type ParameterValuesAt = (parameter: ts.ParameterDeclaration) => readonly
|
|
|
37
37
|
* visible allocation: handing its constructor elsewhere can create instances
|
|
38
38
|
* with inherited method slots that the local construction list does not name. */
|
|
39
39
|
export declare const classConstructorKeepsInstanceOf: (checker: ts.TypeChecker, flow: ValueFlowIndex, instance: ts.InterfaceType) => boolean;
|
|
40
|
+
/** Closed constructor-binding consumers, without claiming that `new`
|
|
41
|
+
* returns its initial receiver. In particular, a returned Proxy remains a
|
|
42
|
+
* distinct value. Instance/result closure is a separate obligation: a result
|
|
43
|
+
* can expose its constructor without another reference to this binding.
|
|
44
|
+
* Consumers also owe allocation position/prototype effects; this is not an
|
|
45
|
+
* instanceof proof or a complete constructor-entry inventory by itself.
|
|
46
|
+
* @semanticCategory generic-primitive
|
|
47
|
+
*/
|
|
48
|
+
export declare const classConstructorBindingUsesAreClosed: (checker: ts.TypeChecker, flow: ValueFlowIndex, instance: ts.InterfaceType) => boolean;
|
|
40
49
|
/** The complete source constructor proof shared by receiver observations. */
|
|
41
50
|
export declare const ordinarySourceClassInstanceTestOf: (checker: ts.TypeChecker, flow: ValueFlowIndex, expression: ts.BinaryExpression) => boolean;
|
|
42
51
|
/** Actual allocations reaching a held reference through the shared write and
|
|
@@ -360,6 +360,7 @@ export const sourceConstructorReturnValuesOf = (checker, flow, owner) => {
|
|
|
360
360
|
* round. Without this the same class was re-walked, base chain and every
|
|
361
361
|
* member reference included, once per proof that touched it. */
|
|
362
362
|
const keptInstances = new WeakMap();
|
|
363
|
+
const closedConstructorBindings = new WeakMap();
|
|
363
364
|
const allocationOrigins = new WeakMap();
|
|
364
365
|
/** Constructor/prototype references must be closed even for a subclass with no
|
|
365
366
|
* visible allocation: handing its constructor elsewhere can create instances
|
|
@@ -375,7 +376,26 @@ export const classConstructorKeepsInstanceOf = (checker, flow, instance) => {
|
|
|
375
376
|
held.set(instance, answer);
|
|
376
377
|
return answer;
|
|
377
378
|
};
|
|
378
|
-
|
|
379
|
+
/** Closed constructor-binding consumers, without claiming that `new`
|
|
380
|
+
* returns its initial receiver. In particular, a returned Proxy remains a
|
|
381
|
+
* distinct value. Instance/result closure is a separate obligation: a result
|
|
382
|
+
* can expose its constructor without another reference to this binding.
|
|
383
|
+
* Consumers also owe allocation position/prototype effects; this is not an
|
|
384
|
+
* instanceof proof or a complete constructor-entry inventory by itself.
|
|
385
|
+
* @semanticCategory generic-primitive
|
|
386
|
+
*/
|
|
387
|
+
export const classConstructorBindingUsesAreClosed = (checker, flow, instance) => {
|
|
388
|
+
let held = closedConstructorBindings.get(flow);
|
|
389
|
+
if (!held)
|
|
390
|
+
closedConstructorBindings.set(flow, (held = new Map()));
|
|
391
|
+
const known = held.get(instance);
|
|
392
|
+
if (known !== undefined)
|
|
393
|
+
return known;
|
|
394
|
+
const answer = classConstructorKeepsInstanceUncached(checker, flow, instance, 'binding-uses');
|
|
395
|
+
held.set(instance, answer);
|
|
396
|
+
return answer;
|
|
397
|
+
};
|
|
398
|
+
const classConstructorKeepsInstanceUncached = (checker, flow, instance, role = 'result') => {
|
|
379
399
|
const seen = new Set();
|
|
380
400
|
/**
|
|
381
401
|
* The class binding reached a call argument. A call is not an escape when it
|
|
@@ -554,6 +574,10 @@ const classConstructorKeepsInstanceUncached = (checker, flow, instance) => {
|
|
|
554
574
|
owner.getSourceFile().isDeclarationFile ||
|
|
555
575
|
!sourceBindingIsUnwritten(flow, owner))
|
|
556
576
|
return false;
|
|
577
|
+
if (role === 'binding-uses' &&
|
|
578
|
+
isModuleExportedDeclaration(checker, owner, null) &&
|
|
579
|
+
inProgramImportReferencesOf(checker, flow, owner) === null)
|
|
580
|
+
return false;
|
|
557
581
|
if (!referenceUsesAreClosed(owner, owner.name, type))
|
|
558
582
|
return false;
|
|
559
583
|
// The member walk below asks two questions of CLASS syntax: does a static
|
|
@@ -577,9 +601,11 @@ const classConstructorKeepsInstanceUncached = (checker, flow, instance) => {
|
|
|
577
601
|
(ts.isArrowFunction(unwrapNaming(member.initializer)) || unwrapNaming(member.initializer).kind === ts.SyntaxKind.ThisKeyword)))
|
|
578
602
|
return false;
|
|
579
603
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
604
|
+
if (role === 'result') {
|
|
605
|
+
const completions = sourceConstructorReturnValuesOf(checker, flow, owner);
|
|
606
|
+
if (completions === null || completions.some((value) => unwrapErasedExpression(value).kind !== ts.SyntaxKind.ThisKeyword))
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
583
609
|
return (checker.getBaseTypes(type) ?? []).every((base) => {
|
|
584
610
|
const declared = heritageClassOrInterfaceOf(base);
|
|
585
611
|
return declared !== null && visit(declared);
|
|
@@ -88,5 +88,7 @@ export declare const hypothesisStats: {
|
|
|
88
88
|
struck: number;
|
|
89
89
|
discarded: number;
|
|
90
90
|
};
|
|
91
|
+
/** Runs `settle` when the open guard on `key` closes having settled as truth; never otherwise. */
|
|
92
|
+
export declare const whenHypothesisSettles: (key: object, settle: () => void) => void;
|
|
91
93
|
export declare const exitHypothesisGuard: (key: object, confirmed?: boolean, settled?: boolean) => void;
|
|
92
94
|
export declare const hypothesisGuardIsOpen: (key: object) => boolean;
|
|
@@ -180,6 +180,26 @@ export const registerGuardedAnswer = (answer, discard) => {
|
|
|
180
180
|
*/
|
|
181
181
|
/** TEMPORARY INSTRUMENT -- not for landing. Counts how the discharge actually settles. */
|
|
182
182
|
export const hypothesisStats = { registered: 0, confirmed: 0, struck: 0, discarded: 0 };
|
|
183
|
+
/**
|
|
184
|
+
* Work waiting on a guard's settlement. A REFUSAL stored while a re-entry
|
|
185
|
+
* guard was open assumes that guard: it may only be replayed while the same
|
|
186
|
+
* question is still open, because the guard's re-entries were handed
|
|
187
|
+
* "unknown". When the guard then settles as truth -- the question's real
|
|
188
|
+
* answer was the refusal it handed out -- the refusal lost nothing by leaning
|
|
189
|
+
* on it, which is exactly why a memo already discharges such a key when it
|
|
190
|
+
* has closed before the memo stores (`hypothesisSettledAsTruth`). A key that
|
|
191
|
+
* closes only after the store is the same fact arriving later.
|
|
192
|
+
*/
|
|
193
|
+
const settlementWaiters = new Map();
|
|
194
|
+
/** Runs `settle` when the open guard on `key` closes having settled as truth; never otherwise. */
|
|
195
|
+
export const whenHypothesisSettles = (key, settle) => {
|
|
196
|
+
if (!openGuards.has(key))
|
|
197
|
+
return;
|
|
198
|
+
let waiting = settlementWaiters.get(key);
|
|
199
|
+
if (!waiting)
|
|
200
|
+
settlementWaiters.set(key, (waiting = []));
|
|
201
|
+
waiting.push(settle);
|
|
202
|
+
};
|
|
183
203
|
export const exitHypothesisGuard = (key, confirmed, settled) => {
|
|
184
204
|
const remaining = (openGuards.get(key) ?? 0) - 1;
|
|
185
205
|
if (remaining > 0) {
|
|
@@ -189,6 +209,13 @@ export const exitHypothesisGuard = (key, confirmed, settled) => {
|
|
|
189
209
|
openGuards.delete(key);
|
|
190
210
|
if (settled === true)
|
|
191
211
|
settledAsTruth.add(key);
|
|
212
|
+
const waiting = settlementWaiters.get(key);
|
|
213
|
+
if (waiting !== undefined) {
|
|
214
|
+
settlementWaiters.delete(key);
|
|
215
|
+
if (settled === true)
|
|
216
|
+
for (const settle of waiting)
|
|
217
|
+
settle();
|
|
218
|
+
}
|
|
192
219
|
const dependents = guardDependents.get(key);
|
|
193
220
|
if (dependents === undefined)
|
|
194
221
|
return;
|
|
@@ -2,9 +2,11 @@ import ts from 'typescript';
|
|
|
2
2
|
import { isGlobalObjectConstructor, isStandardGlobalValue } from '../derived-expression-type.js';
|
|
3
3
|
import { unwrapErasedExpression } from '../producers/erasure.js';
|
|
4
4
|
import { localBindingValuesOf } from './value-provenance.js';
|
|
5
|
-
import { deferredIntrinsicProtocolLedgerOf } from '../deferred-intrinsic-protocols.js';
|
|
5
|
+
import { deferredIntrinsicProtocolLedgerOf, intrinsicProtocolRequirementKind } from '../deferred-intrinsic-protocols.js';
|
|
6
6
|
import { intrinsicPrototypeKeyIsAbsent } from '../intrinsic-prototype.js';
|
|
7
7
|
import { sourceGlobalCallableBindingIsClosed } from './source-global-binding.js';
|
|
8
|
+
import { closedScriptScopeOf } from './targets.js';
|
|
9
|
+
import { sourceCommonJsExportIdentitiesOf } from './source-commonjs-exports.js';
|
|
8
10
|
export const isSourceCallableObject = (node) => ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node);
|
|
9
11
|
/** Exact allocation identity, independently of the checker's inherited Function
|
|
10
12
|
* member signature. Closure of all uses remains a source-value-session demand.
|
|
@@ -86,26 +88,97 @@ export const sourceCallableReflectSetOf = (checker, call) => {
|
|
|
86
88
|
return null;
|
|
87
89
|
return { site: call, target: call.arguments[0], key: key.text, value: call.arguments[2], call };
|
|
88
90
|
};
|
|
91
|
+
const callableOwnerWriteIndexes = new WeakMap();
|
|
92
|
+
const callableOwnerWriteIndexOf = (checker, flow) => {
|
|
93
|
+
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
94
|
+
// Including nothing files nothing; it only answers whether a capture is active.
|
|
95
|
+
const capturing = ledger?.include([]) === true;
|
|
96
|
+
const scriptScope = closedScriptScopeOf(flow);
|
|
97
|
+
const commonJs = sourceCommonJsExportIdentitiesOf(flow);
|
|
98
|
+
let variants = callableOwnerWriteIndexes.get(flow);
|
|
99
|
+
if (!variants)
|
|
100
|
+
callableOwnerWriteIndexes.set(flow, (variants = new Map()));
|
|
101
|
+
const known = variants.get(capturing);
|
|
102
|
+
if (known && known.checker === checker && known.ledger === ledger && known.scriptScope === scriptScope && known.commonJs === commonJs)
|
|
103
|
+
return known;
|
|
104
|
+
const writesByOwner = new Map();
|
|
105
|
+
const obligations = [];
|
|
106
|
+
const filed = new Map();
|
|
107
|
+
let position = 0;
|
|
108
|
+
for (const write of flow.allWrites) {
|
|
109
|
+
position++;
|
|
110
|
+
const access = write.propertyAccess;
|
|
111
|
+
if (!access)
|
|
112
|
+
continue;
|
|
113
|
+
let owner;
|
|
114
|
+
if (capturing && ledger) {
|
|
115
|
+
const resolved = ledger.capture(() => sourceCallableObjectOf(checker, flow, access.expression));
|
|
116
|
+
owner = resolved.value;
|
|
117
|
+
for (const requirement of resolved.requirements) {
|
|
118
|
+
let kinds = filed.get(requirement.location);
|
|
119
|
+
if (!kinds)
|
|
120
|
+
filed.set(requirement.location, (kinds = new Set()));
|
|
121
|
+
const kind = `${requirement.intrinsic}\0${intrinsicProtocolRequirementKind(requirement) ?? ''}`;
|
|
122
|
+
if (kinds.has(kind))
|
|
123
|
+
continue;
|
|
124
|
+
kinds.add(kind);
|
|
125
|
+
obligations.push({ position, requirement });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
owner = sourceCallableObjectOf(checker, flow, access.expression);
|
|
130
|
+
if (owner === null)
|
|
131
|
+
continue;
|
|
132
|
+
let writes = writesByOwner.get(owner);
|
|
133
|
+
if (!writes)
|
|
134
|
+
writesByOwner.set(owner, (writes = []));
|
|
135
|
+
writes.push({ position, access });
|
|
136
|
+
}
|
|
137
|
+
const index = { checker, ledger, capturing, scriptScope, commonJs, writesByOwner, obligations };
|
|
138
|
+
variants.set(capturing, index);
|
|
139
|
+
return index;
|
|
140
|
+
};
|
|
141
|
+
const intrinsicInstallationCalls = new WeakMap();
|
|
142
|
+
const INSTALLATION_MEMBERS = new Set(['set', 'defineProperty', 'deleteProperty', 'defineProperties', 'setPrototypeOf']);
|
|
143
|
+
const intrinsicInstallationCallsOf = (flow) => {
|
|
144
|
+
let calls = intrinsicInstallationCalls.get(flow);
|
|
145
|
+
if (!calls) {
|
|
146
|
+
calls = flow.calls.flatMap(({ call }) => {
|
|
147
|
+
if (!ts.isCallExpression(call) || call.arguments.length < 2)
|
|
148
|
+
return [];
|
|
149
|
+
const callee = unwrapErasedExpression(call.expression);
|
|
150
|
+
return ts.isPropertyAccessExpression(callee) && INSTALLATION_MEMBERS.has(callee.name.text) ? [{ call, callee }] : [];
|
|
151
|
+
});
|
|
152
|
+
intrinsicInstallationCalls.set(flow, calls);
|
|
153
|
+
}
|
|
154
|
+
return calls;
|
|
155
|
+
};
|
|
89
156
|
/** A possible own write partitions dispatch before installation is proved.
|
|
90
157
|
* Conditional stores and unsupported Receiver/key frames must not fall back
|
|
91
158
|
* to the checker's inherited call/apply wrapper after their proof fails.
|
|
92
159
|
*/
|
|
93
160
|
const callableOwnDataMayBeWritten = (checker, flow, root, key) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
continue;
|
|
161
|
+
const index = callableOwnerWriteIndexOf(checker, flow);
|
|
162
|
+
let stop = Infinity;
|
|
163
|
+
for (const { position, access } of index.writesByOwner.get(root) ?? []) {
|
|
98
164
|
const name = keyOf(access);
|
|
99
|
-
if (name === null || name === key || name === '__proto__')
|
|
100
|
-
|
|
165
|
+
if (name === null || name === key || name === '__proto__') {
|
|
166
|
+
stop = position;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
101
169
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
170
|
+
if (index.capturing && index.ledger && index.obligations.length > 0) {
|
|
171
|
+
const replayed = [];
|
|
172
|
+
for (const { position, requirement } of index.obligations) {
|
|
173
|
+
if (position > stop)
|
|
174
|
+
break;
|
|
175
|
+
replayed.push(requirement);
|
|
176
|
+
}
|
|
177
|
+
index.ledger.include(replayed);
|
|
178
|
+
}
|
|
179
|
+
if (stop !== Infinity)
|
|
180
|
+
return true;
|
|
181
|
+
for (const { call, callee } of intrinsicInstallationCallsOf(flow)) {
|
|
109
182
|
// The receiver is recognised by declaration identity, never by its
|
|
110
183
|
// spelling: `globalThis.Reflect.set` and an alias of `Object` reach the
|
|
111
184
|
// same intrinsic, and a local binding that happens to be named `Object`
|
|
@@ -13,3 +13,5 @@ export declare const attachSourceCommonJsExportIdentities: (flow: ValueFlowIndex
|
|
|
13
13
|
export declare const sourceCommonJsExportValueOf: (flow: ValueFlowIndex, expression: ts.Expression) => ts.Expression | null;
|
|
14
14
|
export declare const sourceCommonJsExportUsesOf: (flow: ValueFlowIndex, assignment: ts.BinaryExpression) => readonly ts.Expression[] | null;
|
|
15
15
|
export declare const sourceCommonJsScopeIsClosed: (flow: ValueFlowIndex, file: ts.SourceFile) => boolean;
|
|
16
|
+
/** The sealed identities attached to `flow`, for caches whose answers read them. */
|
|
17
|
+
export declare const sourceCommonJsExportIdentitiesOf: (flow: ValueFlowIndex) => SourceCommonJsExportIdentities | null;
|
|
@@ -5,3 +5,5 @@ export const attachSourceCommonJsExportIdentities = (flow, source) => {
|
|
|
5
5
|
export const sourceCommonJsExportValueOf = (flow, expression) => identities.get(flow)?.values.get(expression) ?? null;
|
|
6
6
|
export const sourceCommonJsExportUsesOf = (flow, assignment) => identities.get(flow)?.publications.get(assignment) ?? null;
|
|
7
7
|
export const sourceCommonJsScopeIsClosed = (flow, file) => identities.get(flow)?.scopes.has(file) === true;
|
|
8
|
+
/** The sealed identities attached to `flow`, for caches whose answers read them. */
|
|
9
|
+
export const sourceCommonJsExportIdentitiesOf = (flow) => identities.get(flow) ?? null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { NativeIterableProvider } from '../../../plugins/native-iterable-providers.js';
|
|
3
|
+
import type { ValueFlowIndex } from './model.js';
|
|
4
|
+
/** Exact source inventory, not a provider's assertion of method immutability.
|
|
5
|
+
* @semanticCategory generic-primitive
|
|
6
|
+
*/
|
|
7
|
+
export interface SourceNativeIterableIntegrity {
|
|
8
|
+
readonly source: ts.Expression;
|
|
9
|
+
readonly provider: NativeIterableProvider;
|
|
10
|
+
readonly writes: readonly ts.Node[];
|
|
11
|
+
readonly calls: readonly (ts.CallExpression | ts.NewExpression)[];
|
|
12
|
+
}
|
|
13
|
+
/** A closed first domain: unknown receivers and opaque consumers remain
|
|
14
|
+
* possible mutation routes. Narrow annotations cannot erase actual alias
|
|
15
|
+
* inputs; source value transport is consulted before native carrier facts.
|
|
16
|
+
*/
|
|
17
|
+
export declare const sourceNativeIterableIntegrityOf: (checker: ts.TypeChecker, flow: ValueFlowIndex, source: ts.Expression, provider: NativeIterableProvider, nativeCarrierOf: (type: ts.Type, at: ts.Node) => string | null, readOnlyCalls: ReadonlySet<ts.CallExpression | ts.NewExpression>) => SourceNativeIterableIntegrity | null;
|