@geastack/compiler 1.0.43 → 1.0.44
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/dist/cli.js +8 -2
- package/dist/ir/callable-class-flow.js +48 -13
- package/dist/ir/lower-operands.js +6 -1
- package/dist/ir/shake.js +21 -0
- package/dist/semantics/frontend.js +18 -14
- package/dist/semantics/normalize/flow/component-solver.js +37 -2
- package/dist/semantics/normalize/flow/source-value-session.d.ts +3 -0
- package/dist/semantics/normalize/flow/source-value-session.js +343 -138
- package/dist/semantics/normalize/global-host-mutations.js +14 -6
- package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +11 -10
- package/dist/semantics/normalize/implicit-arguments-tuple.js +15 -3
- package/dist/semantics/normalize/structural-mutable-method.js +88 -2
- package/dist/targets/cpp/borrowed-call-entry.d.ts +41 -2
- package/dist/targets/cpp/borrowed-call-entry.js +91 -6
- package/dist/targets/cpp/emit-callable.js +62 -29
- package/dist/targets/cpp/host/emit-host-object.js +69 -2
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +1 -1
- package/dist/targets/cpp/translation-unit.js +59 -22
- package/dist/targets/cpp/virtual-methods.js +9 -4
- package/package.json +1 -1
- package/src/targets/cpp/runtime/gea_runtime.h +187 -13
|
@@ -147,6 +147,8 @@ const exactListOf = (set) => {
|
|
|
147
147
|
};
|
|
148
148
|
// Read once at load, not per value transfer: `process.env` is a native interceptor.
|
|
149
149
|
const noArrayKeys = process.env['GEA_NO_ARRAY_KEYS'] !== undefined;
|
|
150
|
+
// `GEA_JOINED_ONLY_OFF` re-runs every transfer in full (`joinedOnly`), so the claim stays checkable from one build.
|
|
151
|
+
const joinedOnlyEnabled = process.env['GEA_JOINED_ONLY_OFF'] === undefined;
|
|
150
152
|
/**
|
|
151
153
|
* The element slot of an array root: every position at once. A computed
|
|
152
154
|
* index names no single key (`this.items[ i ]` in a constructor that fills
|
|
@@ -550,6 +552,20 @@ const createSession = (checker, flow) => {
|
|
|
550
552
|
* solver carries on a large program. It is one node's fact, asked once per container.
|
|
551
553
|
*/
|
|
552
554
|
const unknownReadsOf = (container) => nodeQuery('unknown-reads', container);
|
|
555
|
+
/**
|
|
556
|
+
* The places in a container's closure that can copy a key's value into
|
|
557
|
+
* another container: an `Object.assign` call, an object spread, or a
|
|
558
|
+
* `defineProperty` call. The test is syntax alone and does not depend on
|
|
559
|
+
* the value or the key, yet every key's uses (`key-uses`, one per key of
|
|
560
|
+
* the container) ran it over the container's whole closure, twice, on every
|
|
561
|
+
* re-evaluation. Asked once per container, a key's uses walk only the
|
|
562
|
+
* candidates and apply the same value tests to them they applied to every
|
|
563
|
+
* closure entry before, so their reads, facts and ledger requirements are
|
|
564
|
+
* what they were.
|
|
565
|
+
*/
|
|
566
|
+
const copySitesOf = (container) => nodeQuery('copy-sites', container);
|
|
567
|
+
const isCopySite = (stored) => (ts.isCallExpression(stored) && (definitionPlans.has(stored) || isGlobalObjectAssign(checker, stored))) ||
|
|
568
|
+
(ts.isExpression(stored) && ts.isSpreadAssignment(outermostErasureOf(stored).parent));
|
|
553
569
|
/**
|
|
554
570
|
* The named reads of `key` (and of the keys that alias it on an array)
|
|
555
571
|
* whose receiver can hold THIS container.
|
|
@@ -930,6 +946,20 @@ const createSession = (checker, flow) => {
|
|
|
930
946
|
*/
|
|
931
947
|
const familyTokens = new Map();
|
|
932
948
|
const familyReps = new Set();
|
|
949
|
+
/**
|
|
950
|
+
* Every object literal shares one walk the same way. The walk asks a
|
|
951
|
+
* literal about itself only through the keys it reads or stores through it
|
|
952
|
+
* (whether the literal has the key, and what holds it there), its whole key
|
|
953
|
+
* set (a spread of it, a `JSON.stringify` of it), a destructuring of it,
|
|
954
|
+
* and whether a parameter rebinding stores it. Each of those is left to the
|
|
955
|
+
* literal as a gate; everything else the walk meets -- where the literal is
|
|
956
|
+
* passed, stored, returned and published -- is the same for every literal
|
|
957
|
+
* that reaches it. On a large three.js program the uniform and option
|
|
958
|
+
* literals handed to materials were each walked through the same seven
|
|
959
|
+
* thousand uses of the renderer.
|
|
960
|
+
*/
|
|
961
|
+
let literalToken = null;
|
|
962
|
+
const literalReps = new Set();
|
|
933
963
|
const tokens = new Map();
|
|
934
964
|
const classIds = new Map();
|
|
935
965
|
const classIdOf = (owner) => {
|
|
@@ -955,10 +985,16 @@ const createSession = (checker, flow) => {
|
|
|
955
985
|
token = representative;
|
|
956
986
|
}
|
|
957
987
|
}
|
|
988
|
+
else if (ts.isObjectLiteralExpression(root)) {
|
|
989
|
+
if (literalToken === null)
|
|
990
|
+
literalReps.add((literalToken = root));
|
|
991
|
+
token = literalToken;
|
|
992
|
+
}
|
|
958
993
|
tokens.set(root, token);
|
|
959
994
|
return token;
|
|
960
995
|
};
|
|
961
996
|
const isFamilyMember = (root) => familyReps.has(tokenOf(root));
|
|
997
|
+
const isLiteralGroupMember = (root) => literalReps.has(tokenOf(root));
|
|
962
998
|
/**
|
|
963
999
|
* Every construction in the program a family token stands for, from the
|
|
964
1000
|
* call index: what `family-slot` joins. Built once, and only when a slot
|
|
@@ -1093,7 +1129,6 @@ const createSession = (checker, flow) => {
|
|
|
1093
1129
|
(ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.ExclamationToken) ||
|
|
1094
1130
|
(ts.isIfStatement(parent) && parent.expression === reference));
|
|
1095
1131
|
};
|
|
1096
|
-
const NO_VALUES = new Set();
|
|
1097
1132
|
/**
|
|
1098
1133
|
* `return this` in a body's own frame (not in a nested arrow, whose return
|
|
1099
1134
|
* is the arrow's): the completion is the frame's receiver.
|
|
@@ -1923,6 +1958,9 @@ const createSession = (checker, flow) => {
|
|
|
1923
1958
|
* one evaluation's own (`seeded`, and the causes and grounding a seal reads
|
|
1924
1959
|
* back through `outcome`) or a per-node cache kept in a map below.
|
|
1925
1960
|
*/
|
|
1961
|
+
const transferInputs = new Map();
|
|
1962
|
+
/** Counts transfers and seals: what `obligations` keeps is good until the next one. */
|
|
1963
|
+
const graphRevision = { value: 0 };
|
|
1926
1964
|
const definition = (() => {
|
|
1927
1965
|
// A node's map is allocated on its first answer: most nodes never ask an
|
|
1928
1966
|
// own-key question.
|
|
@@ -1946,10 +1984,29 @@ const createSession = (checker, flow) => {
|
|
|
1946
1984
|
gateLogs.set(query, (log = { list: [], seen: new Set() }));
|
|
1947
1985
|
return log;
|
|
1948
1986
|
};
|
|
1949
|
-
const evaluate = (query, required,
|
|
1987
|
+
const evaluate = (query, required, observeFrom, holdersOfFrom, sealing, outcome) => {
|
|
1950
1988
|
let seeded = false;
|
|
1951
1989
|
let ownKeysAnswers = ownKeysAnswersByQuery.get(query) ?? null;
|
|
1952
1990
|
const facts = new Set();
|
|
1991
|
+
// A transfer's inputs, kept for `joinedOnly` (seals keep none).
|
|
1992
|
+
const inputs = outcome === null ? { tested: [], testedSizes: [], holders: [], joined: [], joinedSizes: [] } : null;
|
|
1993
|
+
const joinedHere = inputs === null ? null : new Set();
|
|
1994
|
+
const tested = (held) => {
|
|
1995
|
+
if (inputs !== null) {
|
|
1996
|
+
inputs.tested.push(held);
|
|
1997
|
+
inputs.testedSizes.push(held.size);
|
|
1998
|
+
}
|
|
1999
|
+
return held;
|
|
2000
|
+
};
|
|
2001
|
+
const observe = (dependency) => tested(observeFrom(dependency));
|
|
2002
|
+
const holdersOf = (fact) => {
|
|
2003
|
+
const found = holdersOfFrom(fact);
|
|
2004
|
+
if (inputs === null)
|
|
2005
|
+
return found;
|
|
2006
|
+
const list = Array.isArray(found) ? found : [...found];
|
|
2007
|
+
inputs.holders.push([fact, list.length]);
|
|
2008
|
+
return list;
|
|
2009
|
+
};
|
|
1953
2010
|
const causes = [];
|
|
1954
2011
|
const grounding = new Set();
|
|
1955
2012
|
const fail = (reason, node = query.node) => {
|
|
@@ -1967,13 +2024,36 @@ const createSession = (checker, flow) => {
|
|
|
1967
2024
|
// single self-time entry in a large program's profile once the state lookup
|
|
1968
2025
|
// beside it was gone -- and a duplicate of the whole proof graph in a
|
|
1969
2026
|
// solve that was already running out of heap.
|
|
1970
|
-
const read = required;
|
|
2027
|
+
const read = (dependency) => tested(required(dependency));
|
|
2028
|
+
/** A required edge whose facts this transfer does not look at: an input of its answer's completeness only. */
|
|
2029
|
+
const need = (dependency) => void required(dependency);
|
|
1971
2030
|
const carry = (dependency) => {
|
|
1972
2031
|
grounding.add(dependency);
|
|
1973
2032
|
return read(dependency);
|
|
1974
2033
|
};
|
|
1975
|
-
/**
|
|
1976
|
-
|
|
2034
|
+
/**
|
|
2035
|
+
* `add(read( dependency ))`: the dependency's facts become this node's and
|
|
2036
|
+
* nothing else is asked of them, so it is a joined input rather than a
|
|
2037
|
+
* tested one (`joinedOnly`).
|
|
2038
|
+
*/
|
|
2039
|
+
const join = (dependency) => {
|
|
2040
|
+
const held = required(dependency);
|
|
2041
|
+
if (joinedHere !== null && held instanceof FactState && !joinedHere.has(held)) {
|
|
2042
|
+
joinedHere.add(held);
|
|
2043
|
+
inputs.joined.push(held);
|
|
2044
|
+
inputs.joinedSizes.push(held.size);
|
|
2045
|
+
}
|
|
2046
|
+
add(held);
|
|
2047
|
+
};
|
|
2048
|
+
const joinCarried = (dependency) => {
|
|
2049
|
+
grounding.add(dependency);
|
|
2050
|
+
join(dependency);
|
|
2051
|
+
};
|
|
2052
|
+
/** `join(use(root, reference))`, without minting the node for a use that does nothing (`inertUse`). */
|
|
2053
|
+
const joinUse = (root, reference) => {
|
|
2054
|
+
if (!inertUse(reference))
|
|
2055
|
+
join(use(root, reference));
|
|
2056
|
+
};
|
|
1977
2057
|
/**
|
|
1978
2058
|
* The gates this node answers for its own root (`resolveGates`), when it
|
|
1979
2059
|
* is the closure of a family member or reads a family walk for one: a
|
|
@@ -1982,6 +2062,8 @@ const createSession = (checker, flow) => {
|
|
|
1982
2062
|
let gating = null;
|
|
1983
2063
|
/** This node walks a family token: identity questions become gates. */
|
|
1984
2064
|
let familyWalk = false;
|
|
2065
|
+
/** This node walks an object literal group's token: a key the group does not spell, or its key set, becomes a gate. */
|
|
2066
|
+
let literalWalk = false;
|
|
1985
2067
|
/** The reference a `use` node walks: a root gate re-walks it. */
|
|
1986
2068
|
let walkedReference = null;
|
|
1987
2069
|
const add = (values) => {
|
|
@@ -2046,9 +2128,9 @@ const createSession = (checker, flow) => {
|
|
|
2046
2128
|
for (let at = 0; at < log.list.length; at++) {
|
|
2047
2129
|
const gate = gates.get(log.list[at]);
|
|
2048
2130
|
if (gate.declaration === null)
|
|
2049
|
-
|
|
2131
|
+
join(rootUse(root, gate.reference));
|
|
2050
2132
|
else if (!parameterRebindingsOf(gate.declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
2051
|
-
|
|
2133
|
+
joinUse(root, gate.reference);
|
|
2052
2134
|
}
|
|
2053
2135
|
};
|
|
2054
2136
|
/**
|
|
@@ -2168,6 +2250,11 @@ const createSession = (checker, flow) => {
|
|
|
2168
2250
|
stamps.push(...kept.stamps);
|
|
2169
2251
|
for (const stamps of holderStampLists)
|
|
2170
2252
|
stamps.push(...kept.holderStamps);
|
|
2253
|
+
// Replayed without being read again, so the sets the answer was read
|
|
2254
|
+
// from are this transfer's inputs too (the holders are asked again in
|
|
2255
|
+
// `holdersUnchanged`).
|
|
2256
|
+
for (const [held] of kept.stamps)
|
|
2257
|
+
tested(held);
|
|
2171
2258
|
ownKeys.set(root, kept.keys);
|
|
2172
2259
|
return kept.keys;
|
|
2173
2260
|
}
|
|
@@ -2406,7 +2493,7 @@ const createSession = (checker, flow) => {
|
|
|
2406
2493
|
if (key !== 'name' && key !== 'length' && sourceCallableOwnDataWriteOf(checker, flow, root, key, access) === null)
|
|
2407
2494
|
fail('unproven-callable-data-read', access);
|
|
2408
2495
|
else
|
|
2409
|
-
|
|
2496
|
+
joinCarried(slot(root, key));
|
|
2410
2497
|
}
|
|
2411
2498
|
return;
|
|
2412
2499
|
}
|
|
@@ -2414,17 +2501,17 @@ const createSession = (checker, flow) => {
|
|
|
2414
2501
|
? enumerationHeadOf(access.argumentExpression)
|
|
2415
2502
|
: null;
|
|
2416
2503
|
if (enumerated !== null) {
|
|
2417
|
-
|
|
2504
|
+
joinCarried(enumeratedSlots(enumerated, root));
|
|
2418
2505
|
return;
|
|
2419
2506
|
}
|
|
2420
2507
|
const family = coveringFamilyOf(root, receivers);
|
|
2421
2508
|
if (family === null)
|
|
2422
2509
|
for (const key of keys)
|
|
2423
|
-
|
|
2510
|
+
joinCarried(slot(root, key));
|
|
2424
2511
|
else if (!familiesRead.has(family)) {
|
|
2425
2512
|
familiesRead.add(family);
|
|
2426
2513
|
for (const key of keys)
|
|
2427
|
-
|
|
2514
|
+
joinCarried(familySlot(family, key));
|
|
2428
2515
|
}
|
|
2429
2516
|
};
|
|
2430
2517
|
// A root this lane cannot read refuses the binding, and the literal
|
|
@@ -2501,17 +2588,17 @@ const createSession = (checker, flow) => {
|
|
|
2501
2588
|
// longer reachable through it. Whether one stores it is a question
|
|
2502
2589
|
// about the root, so a family walk leaves it to each root.
|
|
2503
2590
|
if (ts.isParameter(declaration) && readsAfterRebinding(declaration, reference)) {
|
|
2504
|
-
if (familyWalk) {
|
|
2591
|
+
if (familyWalk || literalWalk) {
|
|
2505
2592
|
facts.add(gateOf(reference, declaration));
|
|
2506
2593
|
continue;
|
|
2507
2594
|
}
|
|
2508
2595
|
if (parameterRebindingsOf(declaration).every((write) => write.value !== null && !read(value(write.value)).has(root)))
|
|
2509
2596
|
continue;
|
|
2510
2597
|
}
|
|
2511
|
-
|
|
2598
|
+
joinUse(root, reference);
|
|
2512
2599
|
}
|
|
2513
2600
|
for (const reference of importerMentions(declaration) ?? [])
|
|
2514
|
-
|
|
2601
|
+
joinUse(root, reference);
|
|
2515
2602
|
};
|
|
2516
2603
|
/**
|
|
2517
2604
|
* A binding pattern taken apart over this value: every element reads one
|
|
@@ -2530,12 +2617,12 @@ const createSession = (checker, flow) => {
|
|
|
2530
2617
|
fail('non-object-destructured-container', pattern);
|
|
2531
2618
|
return;
|
|
2532
2619
|
}
|
|
2533
|
-
if (familyWalk &&
|
|
2620
|
+
if ((familyWalk || literalWalk) &&
|
|
2534
2621
|
pattern.elements.some((element) => {
|
|
2535
2622
|
if (ts.isOmittedExpression(element) || element.dotDotDotToken)
|
|
2536
2623
|
return false;
|
|
2537
2624
|
const key = bindingElementKey(element);
|
|
2538
|
-
return key !== null && definitionDecides(root, key);
|
|
2625
|
+
return key !== null && (literalWalk || definitionDecides(root, key));
|
|
2539
2626
|
})) {
|
|
2540
2627
|
facts.add(gateOf(walkedReference, null));
|
|
2541
2628
|
return;
|
|
@@ -2575,7 +2662,7 @@ const createSession = (checker, flow) => {
|
|
|
2575
2662
|
return false;
|
|
2576
2663
|
for (const setter of bodies)
|
|
2577
2664
|
for (const reference of flow.receiverReferencesToDeclaration(setter))
|
|
2578
|
-
|
|
2665
|
+
joinUse(root, reference);
|
|
2579
2666
|
return true;
|
|
2580
2667
|
};
|
|
2581
2668
|
/**
|
|
@@ -2657,7 +2744,7 @@ const createSession = (checker, flow) => {
|
|
|
2657
2744
|
continue;
|
|
2658
2745
|
if (writeEdgeByAccess.has(fact) || !keysOf(fact).includes(key))
|
|
2659
2746
|
continue;
|
|
2660
|
-
|
|
2747
|
+
joinUse(root, fact);
|
|
2661
2748
|
}
|
|
2662
2749
|
};
|
|
2663
2750
|
const setterStores = (setter) => {
|
|
@@ -2702,7 +2789,7 @@ const createSession = (checker, flow) => {
|
|
|
2702
2789
|
if (write.value === null || !['property-assignment', 'index-assignment', 'logical-assignment'].includes(write.edge))
|
|
2703
2790
|
fail('unmodelled-setter-store', write.site);
|
|
2704
2791
|
else
|
|
2705
|
-
|
|
2792
|
+
joinCarried(value(write.value));
|
|
2706
2793
|
}
|
|
2707
2794
|
};
|
|
2708
2795
|
/**
|
|
@@ -2747,7 +2834,7 @@ const createSession = (checker, flow) => {
|
|
|
2747
2834
|
continue;
|
|
2748
2835
|
}
|
|
2749
2836
|
for (const mention of spread)
|
|
2750
|
-
|
|
2837
|
+
joinUse(root, mention);
|
|
2751
2838
|
const parameter = runtimeParametersOf(body)[position];
|
|
2752
2839
|
if (parameter?.dotDotDotToken)
|
|
2753
2840
|
fail('rest-frame', parameter);
|
|
@@ -2771,12 +2858,12 @@ const createSession = (checker, flow) => {
|
|
|
2771
2858
|
// says nothing about where `this` goes.
|
|
2772
2859
|
if (!ts.isArrowFunction(body)) {
|
|
2773
2860
|
for (const reference of flow.receiverReferencesToDeclaration(body))
|
|
2774
|
-
|
|
2861
|
+
joinUse(root, reference);
|
|
2775
2862
|
// `return this`: the call evaluates to its own receiver, so the
|
|
2776
2863
|
// root comes back out HERE, at the call it entered through --
|
|
2777
2864
|
// see `returnsOwnReceiver`.
|
|
2778
2865
|
if (returnsOwnReceiver(body) && callableCompletionSummaryOf(flow, body)?.execution === 'sync')
|
|
2779
|
-
|
|
2866
|
+
joinUse(root, site.call);
|
|
2780
2867
|
}
|
|
2781
2868
|
}
|
|
2782
2869
|
else {
|
|
@@ -2786,7 +2873,7 @@ const createSession = (checker, flow) => {
|
|
|
2786
2873
|
continue;
|
|
2787
2874
|
}
|
|
2788
2875
|
for (const mention of mentions)
|
|
2789
|
-
|
|
2876
|
+
joinUse(root, mention);
|
|
2790
2877
|
const parameter = runtimeParametersOf(body)[position];
|
|
2791
2878
|
if (parameter?.dotDotDotToken)
|
|
2792
2879
|
fail('rest-frame', parameter);
|
|
@@ -2808,7 +2895,7 @@ const createSession = (checker, flow) => {
|
|
|
2808
2895
|
const positioned = outermostErasureOf(reference);
|
|
2809
2896
|
if (positioned !== reference) {
|
|
2810
2897
|
if (ts.isExpression(positioned))
|
|
2811
|
-
|
|
2898
|
+
joinUse(root, positioned);
|
|
2812
2899
|
else
|
|
2813
2900
|
fail('unindexed-use', positioned);
|
|
2814
2901
|
return;
|
|
@@ -2842,7 +2929,7 @@ const createSession = (checker, flow) => {
|
|
|
2842
2929
|
fail('unmatched-commonjs-export', reference);
|
|
2843
2930
|
else
|
|
2844
2931
|
for (const alias of moduleUses)
|
|
2845
|
-
|
|
2932
|
+
joinUse(root, alias);
|
|
2846
2933
|
return;
|
|
2847
2934
|
}
|
|
2848
2935
|
const left = unwrapNaming(parent.left);
|
|
@@ -2872,8 +2959,8 @@ const createSession = (checker, flow) => {
|
|
|
2872
2959
|
fail('unproven-intrinsic-member-installation', left);
|
|
2873
2960
|
else
|
|
2874
2961
|
for (const access of installed.reads)
|
|
2875
|
-
|
|
2876
|
-
|
|
2962
|
+
joinUse(root, access);
|
|
2963
|
+
joinUse(root, parent);
|
|
2877
2964
|
return;
|
|
2878
2965
|
}
|
|
2879
2966
|
const keys = keysOf(left);
|
|
@@ -2893,13 +2980,13 @@ const createSession = (checker, flow) => {
|
|
|
2893
2980
|
}
|
|
2894
2981
|
for (const key of keys) {
|
|
2895
2982
|
if (descriptorOf(container, key)) {
|
|
2896
|
-
|
|
2983
|
+
join(publication(root, container, key));
|
|
2897
2984
|
continue;
|
|
2898
2985
|
}
|
|
2899
2986
|
// A store to an accessor key hands the value to the
|
|
2900
2987
|
// SETTER's parameter, never to a slot of the container.
|
|
2901
2988
|
if (ts.isNewExpression(container) && dataStoreOf(container, key)) {
|
|
2902
|
-
|
|
2989
|
+
join(publication(root, container, key));
|
|
2903
2990
|
continue;
|
|
2904
2991
|
}
|
|
2905
2992
|
const setters = ts.isNewExpression(container) ? settersOf(container, key) : null;
|
|
@@ -2918,14 +3005,14 @@ const createSession = (checker, flow) => {
|
|
|
2918
3005
|
}
|
|
2919
3006
|
else
|
|
2920
3007
|
fail('unmodelled-store', left);
|
|
2921
|
-
|
|
3008
|
+
joinUse(root, parent);
|
|
2922
3009
|
return;
|
|
2923
3010
|
}
|
|
2924
3011
|
if (parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken ||
|
|
2925
3012
|
parent.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
|
|
2926
3013
|
parent.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
|
|
2927
3014
|
parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
2928
|
-
|
|
3015
|
+
joinUse(root, parent);
|
|
2929
3016
|
return;
|
|
2930
3017
|
}
|
|
2931
3018
|
if (parent.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
@@ -2945,7 +3032,7 @@ const createSession = (checker, flow) => {
|
|
|
2945
3032
|
}
|
|
2946
3033
|
if (ts.isConditionalExpression(parent)) {
|
|
2947
3034
|
if (parent.condition !== reference)
|
|
2948
|
-
|
|
3035
|
+
joinUse(root, parent);
|
|
2949
3036
|
return;
|
|
2950
3037
|
}
|
|
2951
3038
|
if (ts.isPropertyAssignment(parent) && parent.initializer === reference) {
|
|
@@ -2953,10 +3040,14 @@ const createSession = (checker, flow) => {
|
|
|
2953
3040
|
if (key === null || key === '__proto__')
|
|
2954
3041
|
fail('computed-publication', parent);
|
|
2955
3042
|
else
|
|
2956
|
-
|
|
3043
|
+
join(publication(root, parent.parent, key));
|
|
2957
3044
|
return;
|
|
2958
3045
|
}
|
|
2959
3046
|
if (ts.isSpreadAssignment(parent) && parent.expression === reference && ts.isObjectLiteralExpression(root)) {
|
|
3047
|
+
if (literalWalk) {
|
|
3048
|
+
facts.add(gateOf(reference, null));
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
2960
3051
|
// CopyDataProperties observes own data slots without retaining the
|
|
2961
3052
|
// source owner. Copied identities continue through publication below;
|
|
2962
3053
|
// the same complete key/storage queries still reject opaque readers.
|
|
@@ -2964,13 +3055,13 @@ const createSession = (checker, flow) => {
|
|
|
2964
3055
|
if (!ts.isStringLiteral(key))
|
|
2965
3056
|
fail('unmodelled-own-key-value', root);
|
|
2966
3057
|
else
|
|
2967
|
-
|
|
3058
|
+
need(storedSlot(root, key.text));
|
|
2968
3059
|
}
|
|
2969
3060
|
facts.add(reference);
|
|
2970
3061
|
return;
|
|
2971
3062
|
}
|
|
2972
3063
|
if (ts.isShorthandPropertyAssignment(parent)) {
|
|
2973
|
-
|
|
3064
|
+
join(publication(root, parent.parent, parent.name.text));
|
|
2974
3065
|
return;
|
|
2975
3066
|
}
|
|
2976
3067
|
if (ts.isPropertyDeclaration(parent) && parent.initializer === reference) {
|
|
@@ -2980,14 +3071,14 @@ const createSession = (checker, flow) => {
|
|
|
2980
3071
|
return;
|
|
2981
3072
|
}
|
|
2982
3073
|
for (const construction of constructionsOf(parent))
|
|
2983
|
-
|
|
3074
|
+
join(publication(root, construction, key));
|
|
2984
3075
|
return;
|
|
2985
3076
|
}
|
|
2986
3077
|
if (ts.isArrayLiteralExpression(parent)) {
|
|
2987
3078
|
if (parent.elements.some(ts.isSpreadElement))
|
|
2988
3079
|
fail('spread-publication', parent);
|
|
2989
3080
|
else
|
|
2990
|
-
|
|
3081
|
+
join(publication(root, parent, String(parent.elements.indexOf(reference))));
|
|
2991
3082
|
return;
|
|
2992
3083
|
}
|
|
2993
3084
|
if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {
|
|
@@ -3000,7 +3091,7 @@ const createSession = (checker, flow) => {
|
|
|
3000
3091
|
// sites as a key coercion, so `this.run()` had no callable slot at
|
|
3001
3092
|
// all -- the one place a member name is not a key being coerced.
|
|
3002
3093
|
if (ts.isPropertyAccessExpression(parent) && parent.name === reference) {
|
|
3003
|
-
|
|
3094
|
+
joinUse(root, parent);
|
|
3004
3095
|
return;
|
|
3005
3096
|
}
|
|
3006
3097
|
fail('coercing-property-key', reference);
|
|
@@ -3088,6 +3179,10 @@ const createSession = (checker, flow) => {
|
|
|
3088
3179
|
facts.add(gateOf(reference, null));
|
|
3089
3180
|
return;
|
|
3090
3181
|
}
|
|
3182
|
+
if (literalWalk) {
|
|
3183
|
+
facts.add(gateOf(reference, null));
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3091
3186
|
// `instance.constructor` READS the class object off the prototype
|
|
3092
3187
|
// -- a value this graph does not carry, and one whose escape opens
|
|
3093
3188
|
// the family: `unknown( value.constructor )` can construct and
|
|
@@ -3117,7 +3212,7 @@ const createSession = (checker, flow) => {
|
|
|
3117
3212
|
if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {
|
|
3118
3213
|
if (parent.expression === reference) {
|
|
3119
3214
|
if (reference.kind === ts.SyntaxKind.SuperKeyword && ts.isCallExpression(parent) && ts.isNewExpression(root)) {
|
|
3120
|
-
|
|
3215
|
+
need(nodeQuery('construct-targets', parent));
|
|
3121
3216
|
return;
|
|
3122
3217
|
}
|
|
3123
3218
|
if (!isBody(root))
|
|
@@ -3146,6 +3241,10 @@ const createSession = (checker, flow) => {
|
|
|
3146
3241
|
if (parent.arguments.length === 1 &&
|
|
3147
3242
|
parent.arguments[0] === reference &&
|
|
3148
3243
|
intrinsicJsonStringifyQueryOf(checker, unwrapErasedExpression(parent.expression))) {
|
|
3244
|
+
if (literalWalk) {
|
|
3245
|
+
facts.add(gateOf(reference, null));
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
3149
3248
|
// This bounded observation has no replacer or coercing space
|
|
3150
3249
|
// argument, and enters no toJSON/getter/recursive object frame.
|
|
3151
3250
|
// Actual stored values and all future keys remain solver inputs.
|
|
@@ -3190,7 +3289,7 @@ const createSession = (checker, flow) => {
|
|
|
3190
3289
|
if (installation.target === reference)
|
|
3191
3290
|
facts.add(parent);
|
|
3192
3291
|
else
|
|
3193
|
-
|
|
3292
|
+
join(publication(root, held, installation.key));
|
|
3194
3293
|
}
|
|
3195
3294
|
return;
|
|
3196
3295
|
}
|
|
@@ -3205,7 +3304,7 @@ const createSession = (checker, flow) => {
|
|
|
3205
3304
|
// intrinsic returns it, whoever reads the call.
|
|
3206
3305
|
facts.add(parent);
|
|
3207
3306
|
if (plan.returnsTarget && !ts.isExpressionStatement(parent.parent))
|
|
3208
|
-
|
|
3307
|
+
joinUse(root, parent);
|
|
3209
3308
|
}
|
|
3210
3309
|
else if (parent.arguments[2] === reference) {
|
|
3211
3310
|
// The descriptor literal: its `value` is copied into the target
|
|
@@ -3228,7 +3327,7 @@ const createSession = (checker, flow) => {
|
|
|
3228
3327
|
// not a literal could run getters, which this does not enter.
|
|
3229
3328
|
facts.add(parent);
|
|
3230
3329
|
if (bulk.target === reference)
|
|
3231
|
-
|
|
3330
|
+
joinUse(root, parent);
|
|
3232
3331
|
else if (!ts.isObjectLiteralExpression(root))
|
|
3233
3332
|
fail('bulk-assign-source-unmodelled', reference);
|
|
3234
3333
|
return;
|
|
@@ -3254,7 +3353,7 @@ const createSession = (checker, flow) => {
|
|
|
3254
3353
|
const continuations = collectionValueContinuationsOf(checker, flow, parent, reference, nativeProtocolClosed);
|
|
3255
3354
|
if (continuations !== null) {
|
|
3256
3355
|
for (const continued of continuations)
|
|
3257
|
-
|
|
3356
|
+
joinUse(root, continued);
|
|
3258
3357
|
return;
|
|
3259
3358
|
}
|
|
3260
3359
|
}
|
|
@@ -3277,7 +3376,7 @@ const createSession = (checker, flow) => {
|
|
|
3277
3376
|
fail('deferred-completion', parent);
|
|
3278
3377
|
return;
|
|
3279
3378
|
}
|
|
3280
|
-
|
|
3379
|
+
need(closure(body));
|
|
3281
3380
|
// The body's own receiver, returned: it reaches only the calls it was
|
|
3282
3381
|
// the receiver of, and `forward` continues it at each of those. See
|
|
3283
3382
|
// `returnsOwnReceiver`.
|
|
@@ -3285,7 +3384,7 @@ const createSession = (checker, flow) => {
|
|
|
3285
3384
|
return;
|
|
3286
3385
|
for (const call of read(callersOf(body)))
|
|
3287
3386
|
if (ts.isCallExpression(call))
|
|
3288
|
-
|
|
3387
|
+
joinUse(root, call);
|
|
3289
3388
|
return;
|
|
3290
3389
|
}
|
|
3291
3390
|
// Enumerating an object reads its KEY SET and nothing else: no slot is
|
|
@@ -3334,12 +3433,12 @@ const createSession = (checker, flow) => {
|
|
|
3334
3433
|
return;
|
|
3335
3434
|
}
|
|
3336
3435
|
if (isBody(owner))
|
|
3337
|
-
|
|
3436
|
+
need(closure(owner));
|
|
3338
3437
|
for (const site of constructionSitesTargeting(owner))
|
|
3339
|
-
|
|
3438
|
+
joinCarried(frameQuery('frame-argument', site.call, owner, parameter));
|
|
3340
3439
|
for (const call of read(callersOf(owner)))
|
|
3341
3440
|
if (ts.isCallExpression(call) || ts.isNewExpression(call))
|
|
3342
|
-
|
|
3441
|
+
joinCarried(frameQuery('frame-argument', call, owner, parameter));
|
|
3343
3442
|
for (const write of flow.writesToDeclaration(parameter)) {
|
|
3344
3443
|
if (write.site === excluded)
|
|
3345
3444
|
continue;
|
|
@@ -3357,7 +3456,7 @@ const createSession = (checker, flow) => {
|
|
|
3357
3456
|
fail('unmodelled-parameter-write', write.site);
|
|
3358
3457
|
continue;
|
|
3359
3458
|
}
|
|
3360
|
-
|
|
3459
|
+
joinCarried(value(write.value));
|
|
3361
3460
|
}
|
|
3362
3461
|
};
|
|
3363
3462
|
seeded = false;
|
|
@@ -3366,7 +3465,7 @@ const createSession = (checker, flow) => {
|
|
|
3366
3465
|
const expression = query.node;
|
|
3367
3466
|
const moduleExport = sourceCommonJsExportValueOf(flow, expression);
|
|
3368
3467
|
if (moduleExport !== null) {
|
|
3369
|
-
|
|
3468
|
+
joinCarried(value(moduleExport));
|
|
3370
3469
|
break;
|
|
3371
3470
|
}
|
|
3372
3471
|
if (isObjectRoot(expression)) {
|
|
@@ -3384,7 +3483,7 @@ const createSession = (checker, flow) => {
|
|
|
3384
3483
|
// frame a call would be. Anything else under `new` that is not
|
|
3385
3484
|
// a source construction stays opaque.
|
|
3386
3485
|
if (constructorFunctionCalleeOf(expression) !== null)
|
|
3387
|
-
|
|
3486
|
+
joinCarried(nodeQuery('completion', expression));
|
|
3388
3487
|
else
|
|
3389
3488
|
fail('opaque-construction');
|
|
3390
3489
|
}
|
|
@@ -3444,7 +3543,7 @@ const createSession = (checker, flow) => {
|
|
|
3444
3543
|
if (write.slot !== 'whole' || write.edge === 'return' || write.edge === 'yield')
|
|
3445
3544
|
continue;
|
|
3446
3545
|
if (write.value && ['identifier-assignment', 'logical-assignment'].includes(write.edge))
|
|
3447
|
-
|
|
3546
|
+
joinCarried(value(write.value));
|
|
3448
3547
|
else
|
|
3449
3548
|
fail('unmodelled-callable-binding-write', write.site);
|
|
3450
3549
|
}
|
|
@@ -3455,7 +3554,7 @@ const createSession = (checker, flow) => {
|
|
|
3455
3554
|
fail('unaccounted-binding-write', declaration);
|
|
3456
3555
|
else
|
|
3457
3556
|
for (const entry of incoming)
|
|
3458
|
-
|
|
3557
|
+
joinCarried(value(entry));
|
|
3459
3558
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3460
3559
|
facts.add(undefinedValue);
|
|
3461
3560
|
seeded = true;
|
|
@@ -3470,12 +3569,12 @@ const createSession = (checker, flow) => {
|
|
|
3470
3569
|
// source include its own target.
|
|
3471
3570
|
const rebinding = rebindingAfterRead(declaration, expression);
|
|
3472
3571
|
if (rebinding === null)
|
|
3473
|
-
|
|
3572
|
+
joinCarried(nodeQuery('parameter', declaration));
|
|
3474
3573
|
else
|
|
3475
3574
|
parameterValues(declaration, rebinding);
|
|
3476
3575
|
}
|
|
3477
3576
|
else if (declaration && ts.isBindingElement(declaration))
|
|
3478
|
-
|
|
3577
|
+
joinCarried(nodeQuery('binding-element', declaration));
|
|
3479
3578
|
else if (expression.text === 'undefined' && (!declaration || declaration.getSourceFile().hasNoDefaultLib)) {
|
|
3480
3579
|
facts.add(undefinedValue);
|
|
3481
3580
|
seeded = true;
|
|
@@ -3488,7 +3587,7 @@ const createSession = (checker, flow) => {
|
|
|
3488
3587
|
if (!owner)
|
|
3489
3588
|
fail('unindexed-receiver');
|
|
3490
3589
|
else
|
|
3491
|
-
|
|
3590
|
+
joinCarried(nodeQuery('receiver', owner));
|
|
3492
3591
|
}
|
|
3493
3592
|
else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
3494
3593
|
if (sourceIntrinsicMemberMayBeWrittenOf(checker, flow, expression)) {
|
|
@@ -3496,8 +3595,8 @@ const createSession = (checker, flow) => {
|
|
|
3496
3595
|
if (installed === null)
|
|
3497
3596
|
fail('unproven-intrinsic-member-read', expression);
|
|
3498
3597
|
else {
|
|
3499
|
-
|
|
3500
|
-
|
|
3598
|
+
joinCarried(value(installed.value));
|
|
3599
|
+
need(closure(installed.body));
|
|
3501
3600
|
}
|
|
3502
3601
|
break;
|
|
3503
3602
|
}
|
|
@@ -3525,18 +3624,18 @@ const createSession = (checker, flow) => {
|
|
|
3525
3624
|
seeded = true;
|
|
3526
3625
|
}
|
|
3527
3626
|
else if (ts.isCallExpression(expression))
|
|
3528
|
-
|
|
3627
|
+
joinCarried(nodeQuery('completion', expression));
|
|
3529
3628
|
else if (ts.isConditionalExpression(expression)) {
|
|
3530
|
-
|
|
3531
|
-
|
|
3629
|
+
joinCarried(value(expression.whenTrue));
|
|
3630
|
+
joinCarried(value(expression.whenFalse));
|
|
3532
3631
|
}
|
|
3533
3632
|
else if (ts.isBinaryExpression(expression) &&
|
|
3534
3633
|
[ts.SyntaxKind.EqualsToken, ts.SyntaxKind.CommaToken].includes(expression.operatorToken.kind))
|
|
3535
|
-
|
|
3634
|
+
joinCarried(value(expression.right));
|
|
3536
3635
|
else if (ts.isBinaryExpression(expression) &&
|
|
3537
3636
|
[ts.SyntaxKind.BarBarToken, ts.SyntaxKind.AmpersandAmpersandToken, ts.SyntaxKind.QuestionQuestionToken].includes(expression.operatorToken.kind)) {
|
|
3538
|
-
|
|
3539
|
-
|
|
3637
|
+
joinCarried(value(expression.left));
|
|
3638
|
+
joinCarried(value(expression.right));
|
|
3540
3639
|
}
|
|
3541
3640
|
else if (ts.isLiteralExpression(expression) ||
|
|
3542
3641
|
expression.kind === ts.SyntaxKind.NullKeyword ||
|
|
@@ -3557,8 +3656,8 @@ const createSession = (checker, flow) => {
|
|
|
3557
3656
|
fail('unproven-proxy-construction');
|
|
3558
3657
|
break;
|
|
3559
3658
|
}
|
|
3560
|
-
|
|
3561
|
-
|
|
3659
|
+
need(nodeQuery('proxy-target', query.node));
|
|
3660
|
+
need(nodeQuery('proxy-handler', query.node));
|
|
3562
3661
|
// This identity domain is deliberately separate from generic value
|
|
3563
3662
|
// roots: existing class-field consumers interpret NewExpression
|
|
3564
3663
|
// origins as physical data, which is not a Proxy get-trap proof.
|
|
@@ -3593,7 +3692,7 @@ const createSession = (checker, flow) => {
|
|
|
3593
3692
|
// `options.attachment` on the `{}` a parameter defaults to.
|
|
3594
3693
|
if ((ts.isObjectLiteralExpression(root) || isFreshOrdinaryObject(root)) &&
|
|
3595
3694
|
absentOwnKey(root, key, root, descriptorOf, hasUnnamedWrite)) {
|
|
3596
|
-
|
|
3695
|
+
need(closure(root));
|
|
3597
3696
|
if (query.kind === 'slot') {
|
|
3598
3697
|
facts.add(undefinedValue);
|
|
3599
3698
|
seeded = true;
|
|
@@ -3604,7 +3703,7 @@ const createSession = (checker, flow) => {
|
|
|
3604
3703
|
break;
|
|
3605
3704
|
}
|
|
3606
3705
|
}
|
|
3607
|
-
|
|
3706
|
+
need(closure(root));
|
|
3608
3707
|
if (isSourceCallableObject(root)) {
|
|
3609
3708
|
if (key === 'name' || key === 'length') {
|
|
3610
3709
|
const parameters = runtimeParametersOf(root);
|
|
@@ -3627,15 +3726,15 @@ const createSession = (checker, flow) => {
|
|
|
3627
3726
|
if (installed === null)
|
|
3628
3727
|
fail('unproven-callable-data-slot', root);
|
|
3629
3728
|
else
|
|
3630
|
-
|
|
3729
|
+
joinCarried(value(installed.value));
|
|
3631
3730
|
}
|
|
3632
3731
|
}
|
|
3633
3732
|
else if (ts.isObjectLiteralExpression(root)) {
|
|
3634
3733
|
for (const entry of ownEntries(root, key) ?? []) {
|
|
3635
3734
|
if (ts.isPropertyAssignment(entry))
|
|
3636
|
-
|
|
3735
|
+
joinCarried(value(entry.initializer));
|
|
3637
3736
|
else if (ts.isShorthandPropertyAssignment(entry))
|
|
3638
|
-
|
|
3737
|
+
joinCarried(value(entry.name));
|
|
3639
3738
|
else if (ts.isMethodDeclaration(entry)) {
|
|
3640
3739
|
facts.add(entry);
|
|
3641
3740
|
seeded = true;
|
|
@@ -3647,7 +3746,7 @@ const createSession = (checker, flow) => {
|
|
|
3647
3746
|
// Every position at once; an index never written reads undefined.
|
|
3648
3747
|
for (const element of root.elements)
|
|
3649
3748
|
if (!ts.isOmittedExpression(element))
|
|
3650
|
-
|
|
3749
|
+
joinCarried(value(element));
|
|
3651
3750
|
facts.add(undefinedValue);
|
|
3652
3751
|
seeded = true;
|
|
3653
3752
|
}
|
|
@@ -3661,7 +3760,7 @@ const createSession = (checker, flow) => {
|
|
|
3661
3760
|
else {
|
|
3662
3761
|
const element = root.elements[Number(key)];
|
|
3663
3762
|
if (element !== undefined && !ts.isOmittedExpression(element))
|
|
3664
|
-
|
|
3763
|
+
joinCarried(value(element));
|
|
3665
3764
|
else {
|
|
3666
3765
|
facts.add(undefinedValue);
|
|
3667
3766
|
seeded = true;
|
|
@@ -3676,14 +3775,14 @@ const createSession = (checker, flow) => {
|
|
|
3676
3775
|
}
|
|
3677
3776
|
if (ts.isPropertyDeclaration(declaration)) {
|
|
3678
3777
|
if (declaration.initializer)
|
|
3679
|
-
|
|
3778
|
+
joinCarried(value(declaration.initializer));
|
|
3680
3779
|
else {
|
|
3681
3780
|
facts.add(undefinedValue);
|
|
3682
3781
|
seeded = true;
|
|
3683
3782
|
}
|
|
3684
3783
|
}
|
|
3685
3784
|
if (ts.isParameter(declaration))
|
|
3686
|
-
|
|
3785
|
+
joinCarried(nodeQuery('parameter', declaration));
|
|
3687
3786
|
}
|
|
3688
3787
|
if (getterRead !== null) {
|
|
3689
3788
|
// The getter runs with this construction as its receiver, and
|
|
@@ -3694,13 +3793,13 @@ const createSession = (checker, flow) => {
|
|
|
3694
3793
|
gating = gateLogOf(query);
|
|
3695
3794
|
for (const getter of getterRead.getters) {
|
|
3696
3795
|
for (const reference of flow.receiverReferencesToDeclaration(getter))
|
|
3697
|
-
|
|
3796
|
+
joinUse(root, reference);
|
|
3698
3797
|
const summary = callableCompletionSummaryOf(flow, getter);
|
|
3699
3798
|
if (summary === null || summary.execution !== 'sync')
|
|
3700
3799
|
fail('unmodelled-getter-completion', getter);
|
|
3701
3800
|
else {
|
|
3702
3801
|
for (const completion of summary.values)
|
|
3703
|
-
|
|
3802
|
+
joinCarried(value(completion));
|
|
3704
3803
|
if (summary.mayCompleteUndefined) {
|
|
3705
3804
|
facts.add(undefinedValue);
|
|
3706
3805
|
seeded = true;
|
|
@@ -3736,7 +3835,7 @@ const createSession = (checker, flow) => {
|
|
|
3736
3835
|
if (isSourceCallableObject(root) && ts.isCallExpression(stored)) {
|
|
3737
3836
|
const installation = sourceCallableReflectSetOf(checker, stored);
|
|
3738
3837
|
if (installation && installation.key === key && read(value(installation.target)).has(root))
|
|
3739
|
-
|
|
3838
|
+
joinCarried(value(installation.value));
|
|
3740
3839
|
continue;
|
|
3741
3840
|
}
|
|
3742
3841
|
if (ts.isCallExpression(stored) && definitionPlans.has(stored)) {
|
|
@@ -3748,7 +3847,7 @@ const createSession = (checker, flow) => {
|
|
|
3748
3847
|
seeded = true;
|
|
3749
3848
|
}
|
|
3750
3849
|
for (const defined of plan.values)
|
|
3751
|
-
|
|
3850
|
+
joinCarried(value(defined));
|
|
3752
3851
|
continue;
|
|
3753
3852
|
}
|
|
3754
3853
|
if (ts.isCallExpression(stored)) {
|
|
@@ -3768,7 +3867,7 @@ const createSession = (checker, flow) => {
|
|
|
3768
3867
|
else if (literalSpelledKeys(held) === null || hasUnnamedWrite(held))
|
|
3769
3868
|
fail('bulk-assign-source-keys-open', source);
|
|
3770
3869
|
else if (ownKeysOf(held)?.includes(key))
|
|
3771
|
-
|
|
3870
|
+
joinCarried(storedSlot(held, key));
|
|
3772
3871
|
}
|
|
3773
3872
|
continue;
|
|
3774
3873
|
}
|
|
@@ -3799,7 +3898,7 @@ const createSession = (checker, flow) => {
|
|
|
3799
3898
|
fail('unmodelled-property-write', stored);
|
|
3800
3899
|
continue;
|
|
3801
3900
|
}
|
|
3802
|
-
|
|
3901
|
+
joinCarried(value(write.value));
|
|
3803
3902
|
}
|
|
3804
3903
|
break;
|
|
3805
3904
|
}
|
|
@@ -3837,7 +3936,7 @@ const createSession = (checker, flow) => {
|
|
|
3837
3936
|
case 'targets': {
|
|
3838
3937
|
const site = sites.get(query.node);
|
|
3839
3938
|
if (site?.operands && !site.explicitThis && site.operands.dispatch.kind === 'lexical-super') {
|
|
3840
|
-
|
|
3939
|
+
joinCarried(superTargets(query.node));
|
|
3841
3940
|
break;
|
|
3842
3941
|
}
|
|
3843
3942
|
// `super()` selects a BASE CONSTRUCTOR, which is the construction
|
|
@@ -3845,7 +3944,7 @@ const createSession = (checker, flow) => {
|
|
|
3845
3944
|
// `new Base()` makes, reached from the subclass's heritage instead of
|
|
3846
3945
|
// from a spelled callee.
|
|
3847
3946
|
if (site?.operands && !site.explicitThis && site.operands.dispatch.kind === 'super-constructor') {
|
|
3848
|
-
|
|
3947
|
+
joinCarried(nodeQuery('construct-targets', query.node));
|
|
3849
3948
|
break;
|
|
3850
3949
|
}
|
|
3851
3950
|
// `.call`/`.apply` needs no separate resolver here: `operands.callee`
|
|
@@ -3874,7 +3973,7 @@ const createSession = (checker, flow) => {
|
|
|
3874
3973
|
if (ts.isCallExpression(query.node)) {
|
|
3875
3974
|
const bulk = bulkAssignOf(query.node);
|
|
3876
3975
|
if (bulk !== null) {
|
|
3877
|
-
|
|
3976
|
+
joinCarried(value(bulk.target));
|
|
3878
3977
|
break;
|
|
3879
3978
|
}
|
|
3880
3979
|
// `store.get( key )` on a native Map this program alone fills:
|
|
@@ -3894,7 +3993,7 @@ const createSession = (checker, flow) => {
|
|
|
3894
3993
|
const stored = collectionStoredValuesOf(checker, flow, query.node, nativeProtocolClosed);
|
|
3895
3994
|
if (stored !== null) {
|
|
3896
3995
|
for (const candidate of stored)
|
|
3897
|
-
|
|
3996
|
+
joinCarried(value(candidate));
|
|
3898
3997
|
facts.add(undefinedValue);
|
|
3899
3998
|
seeded = true;
|
|
3900
3999
|
break;
|
|
@@ -3906,7 +4005,7 @@ const createSession = (checker, flow) => {
|
|
|
3906
4005
|
flow.callableBodyIsIndexed(candidate) &&
|
|
3907
4006
|
candidate === constructorFunctionCalleeOf(query.node) &&
|
|
3908
4007
|
constructionYieldsCompletionOf(flow, candidate))
|
|
3909
|
-
|
|
4008
|
+
joinCarried(frameQuery('frame-completion', query.node, candidate));
|
|
3910
4009
|
else
|
|
3911
4010
|
fail('opaque-construction', candidate);
|
|
3912
4011
|
}
|
|
@@ -3916,7 +4015,7 @@ const createSession = (checker, flow) => {
|
|
|
3916
4015
|
if (!isBody(body))
|
|
3917
4016
|
fail('unindexed-body', body);
|
|
3918
4017
|
else
|
|
3919
|
-
|
|
4018
|
+
joinCarried(frameQuery('frame-completion', query.node, body));
|
|
3920
4019
|
}
|
|
3921
4020
|
if (ts.isCallExpression(query.node) && lookupThrows(query.node))
|
|
3922
4021
|
seeded = true;
|
|
@@ -3938,7 +4037,7 @@ const createSession = (checker, flow) => {
|
|
|
3938
4037
|
fail('incomplete-constructor-object-completion', query.body);
|
|
3939
4038
|
else
|
|
3940
4039
|
for (const returned of summary.values)
|
|
3941
|
-
|
|
4040
|
+
joinCarried(contextual(returned));
|
|
3942
4041
|
break;
|
|
3943
4042
|
}
|
|
3944
4043
|
const subject = query.subject;
|
|
@@ -3964,7 +4063,7 @@ const createSession = (checker, flow) => {
|
|
|
3964
4063
|
}
|
|
3965
4064
|
if (!slot.actual) {
|
|
3966
4065
|
if (slot.defaultValue)
|
|
3967
|
-
|
|
4066
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3968
4067
|
else {
|
|
3969
4068
|
facts.add(undefinedValue);
|
|
3970
4069
|
seeded = true;
|
|
@@ -3973,7 +4072,7 @@ const createSession = (checker, flow) => {
|
|
|
3973
4072
|
else
|
|
3974
4073
|
for (const candidate of carry(value(slot.actual))) {
|
|
3975
4074
|
if (ts.isVoidExpression(candidate) && slot.defaultValue)
|
|
3976
|
-
|
|
4075
|
+
joinCarried(contextual(slot.defaultValue));
|
|
3977
4076
|
else
|
|
3978
4077
|
facts.add(candidate);
|
|
3979
4078
|
}
|
|
@@ -3986,14 +4085,14 @@ const createSession = (checker, flow) => {
|
|
|
3986
4085
|
const expression = unwrapErasedExpression(subject);
|
|
3987
4086
|
const declaration = ts.isIdentifier(expression) ? flow.targetOf(expression)?.declaration : null;
|
|
3988
4087
|
if (declaration && ts.isParameter(declaration) && declaration.parent === query.body)
|
|
3989
|
-
|
|
4088
|
+
joinCarried(frameQuery('constructor-parameter', query.node, query.body, declaration));
|
|
3990
4089
|
else if (declaration && ts.isVariableDeclaration(declaration) && ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
3991
4090
|
const incoming = sourceBindingValuesOf(checker, flow, declaration, iterationValuesAt);
|
|
3992
4091
|
if (incoming === null)
|
|
3993
4092
|
fail('unaccounted-constructor-binding', declaration);
|
|
3994
4093
|
else
|
|
3995
4094
|
for (const entry of incoming)
|
|
3996
|
-
|
|
4095
|
+
joinCarried(contextual(entry));
|
|
3997
4096
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
3998
4097
|
facts.add(undefinedValue);
|
|
3999
4098
|
seeded = true;
|
|
@@ -4026,13 +4125,13 @@ const createSession = (checker, flow) => {
|
|
|
4026
4125
|
for (const condition of read(contextual(expression.condition))) {
|
|
4027
4126
|
const truth = conditionTruthOf(condition);
|
|
4028
4127
|
if (truth !== false)
|
|
4029
|
-
|
|
4128
|
+
joinCarried(contextual(expression.whenTrue));
|
|
4030
4129
|
if (truth !== true)
|
|
4031
|
-
|
|
4130
|
+
joinCarried(contextual(expression.whenFalse));
|
|
4032
4131
|
}
|
|
4033
4132
|
}
|
|
4034
4133
|
else
|
|
4035
|
-
|
|
4134
|
+
joinCarried(value(expression));
|
|
4036
4135
|
break;
|
|
4037
4136
|
}
|
|
4038
4137
|
case 'frame-receiver':
|
|
@@ -4071,7 +4170,7 @@ const createSession = (checker, flow) => {
|
|
|
4071
4170
|
}
|
|
4072
4171
|
}
|
|
4073
4172
|
else if (receiver.kind === 'constructed')
|
|
4074
|
-
|
|
4173
|
+
joinCarried(value(receiver.call));
|
|
4075
4174
|
else if (receiver.kind === 'lexical' && receiver.source !== 'arrow') {
|
|
4076
4175
|
// `super.m()` and `super()` run with the calling frame's own
|
|
4077
4176
|
// `this`; the class the layout names is only where the lookup
|
|
@@ -4088,7 +4187,7 @@ const createSession = (checker, flow) => {
|
|
|
4088
4187
|
if (keyword === null)
|
|
4089
4188
|
fail('unresolved-super-home', query.node);
|
|
4090
4189
|
else
|
|
4091
|
-
|
|
4190
|
+
joinCarried(value(keyword));
|
|
4092
4191
|
}
|
|
4093
4192
|
else if (receiver.kind === 'lexical' && receiver.owner) {
|
|
4094
4193
|
if (ts.isSourceFile(receiver.owner)) {
|
|
@@ -4100,7 +4199,7 @@ const createSession = (checker, flow) => {
|
|
|
4100
4199
|
fail('global-object-receiver-origin', receiver.owner);
|
|
4101
4200
|
}
|
|
4102
4201
|
else
|
|
4103
|
-
|
|
4202
|
+
joinCarried(nodeQuery('receiver', receiver.owner));
|
|
4104
4203
|
}
|
|
4105
4204
|
else
|
|
4106
4205
|
fail(receiver.kind === 'unsupported' ? receiver.reason : 'global-object-receiver-origin');
|
|
@@ -4112,7 +4211,7 @@ const createSession = (checker, flow) => {
|
|
|
4112
4211
|
break;
|
|
4113
4212
|
}
|
|
4114
4213
|
if (query.kind === 'frame-parameter') {
|
|
4115
|
-
|
|
4214
|
+
joinCarried(frameQuery('frame-argument', query.node, query.body, parameter));
|
|
4116
4215
|
for (const write of flow.writesToDeclaration(parameter)) {
|
|
4117
4216
|
if (write.edge === 'call-argument' || write.edge === 'super-argument' || write.edge === 'default-parameter')
|
|
4118
4217
|
continue;
|
|
@@ -4121,7 +4220,7 @@ const createSession = (checker, flow) => {
|
|
|
4121
4220
|
if (!['identifier-assignment', 'logical-assignment'].includes(write.edge) || !write.value)
|
|
4122
4221
|
fail('unmodelled-parameter-write', write.site);
|
|
4123
4222
|
else
|
|
4124
|
-
|
|
4223
|
+
joinCarried(contextual(write.value));
|
|
4125
4224
|
}
|
|
4126
4225
|
break;
|
|
4127
4226
|
}
|
|
@@ -4137,13 +4236,13 @@ const createSession = (checker, flow) => {
|
|
|
4137
4236
|
if (slot.actual) {
|
|
4138
4237
|
for (const candidate of carry(value(slot.actual))) {
|
|
4139
4238
|
if (ts.isVoidExpression(candidate) && slot.defaultValue)
|
|
4140
|
-
|
|
4239
|
+
joinCarried(contextual(slot.defaultValue));
|
|
4141
4240
|
else
|
|
4142
4241
|
facts.add(candidate);
|
|
4143
4242
|
}
|
|
4144
4243
|
}
|
|
4145
4244
|
else if (slot.defaultValue)
|
|
4146
|
-
|
|
4245
|
+
joinCarried(contextual(slot.defaultValue));
|
|
4147
4246
|
else {
|
|
4148
4247
|
facts.add(undefinedValue);
|
|
4149
4248
|
seeded = true;
|
|
@@ -4155,7 +4254,7 @@ const createSession = (checker, flow) => {
|
|
|
4155
4254
|
fail('deferred-completion', query.body);
|
|
4156
4255
|
else {
|
|
4157
4256
|
for (const expression of summary.values)
|
|
4158
|
-
|
|
4257
|
+
joinCarried(contextual(expression));
|
|
4159
4258
|
if (summary.mayCompleteUndefined || (ts.isCallExpression(query.node) && ts.isCallChain(query.node))) {
|
|
4160
4259
|
facts.add(undefinedValue);
|
|
4161
4260
|
seeded = true;
|
|
@@ -4170,7 +4269,7 @@ const createSession = (checker, flow) => {
|
|
|
4170
4269
|
}
|
|
4171
4270
|
const declaration = ts.isIdentifier(expression) ? flow.targetOf(expression)?.declaration : null;
|
|
4172
4271
|
if (declaration && ts.isParameter(declaration) && declaration.parent === query.body)
|
|
4173
|
-
|
|
4272
|
+
joinCarried(frameQuery('frame-parameter', query.node, query.body, declaration));
|
|
4174
4273
|
else if (declaration &&
|
|
4175
4274
|
ts.isVariableDeclaration(declaration) &&
|
|
4176
4275
|
ts.findAncestor(declaration, ts.isFunctionLike) === query.body) {
|
|
@@ -4179,7 +4278,7 @@ const createSession = (checker, flow) => {
|
|
|
4179
4278
|
fail('unaccounted-binding-write', declaration);
|
|
4180
4279
|
else
|
|
4181
4280
|
for (const entry of incoming)
|
|
4182
|
-
|
|
4281
|
+
joinCarried(contextual(entry));
|
|
4183
4282
|
if (incoming !== null && bindingReadMayPrecedeFirstWrite(declaration, expression)) {
|
|
4184
4283
|
facts.add(undefinedValue);
|
|
4185
4284
|
seeded = true;
|
|
@@ -4187,10 +4286,10 @@ const createSession = (checker, flow) => {
|
|
|
4187
4286
|
}
|
|
4188
4287
|
else if ((expression.kind === ts.SyntaxKind.ThisKeyword || expression.kind === ts.SyntaxKind.SuperKeyword) &&
|
|
4189
4288
|
(ts.isArrowFunction(query.body) || flow.receiverOwnerOf(expression) === query.body))
|
|
4190
|
-
|
|
4289
|
+
joinCarried(frameQuery('frame-receiver', query.node, query.body));
|
|
4191
4290
|
else if (ts.isConditionalExpression(expression)) {
|
|
4192
|
-
|
|
4193
|
-
|
|
4291
|
+
joinCarried(contextual(expression.whenTrue));
|
|
4292
|
+
joinCarried(contextual(expression.whenFalse));
|
|
4194
4293
|
}
|
|
4195
4294
|
else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) {
|
|
4196
4295
|
const keys = keysOf(expression);
|
|
@@ -4204,14 +4303,14 @@ const createSession = (checker, flow) => {
|
|
|
4204
4303
|
}
|
|
4205
4304
|
else if (ts.isBinaryExpression(expression) &&
|
|
4206
4305
|
[ts.SyntaxKind.EqualsToken, ts.SyntaxKind.CommaToken].includes(expression.operatorToken.kind))
|
|
4207
|
-
|
|
4306
|
+
joinCarried(contextual(expression.right));
|
|
4208
4307
|
else if (ts.isBinaryExpression(expression) &&
|
|
4209
4308
|
[ts.SyntaxKind.BarBarToken, ts.SyntaxKind.AmpersandAmpersandToken, ts.SyntaxKind.QuestionQuestionToken].includes(expression.operatorToken.kind)) {
|
|
4210
|
-
|
|
4211
|
-
|
|
4309
|
+
joinCarried(contextual(expression.left));
|
|
4310
|
+
joinCarried(contextual(expression.right));
|
|
4212
4311
|
}
|
|
4213
4312
|
else
|
|
4214
|
-
|
|
4313
|
+
joinCarried(value(expression));
|
|
4215
4314
|
}
|
|
4216
4315
|
break;
|
|
4217
4316
|
}
|
|
@@ -4268,7 +4367,7 @@ const createSession = (checker, flow) => {
|
|
|
4268
4367
|
sourceCallableOwnDataWriteOf(checker, flow, root, key, element) === null)
|
|
4269
4368
|
fail('unproven-callable-data-read', element);
|
|
4270
4369
|
else if (isObjectRoot(root))
|
|
4271
|
-
|
|
4370
|
+
joinCarried(slot(root, key));
|
|
4272
4371
|
else
|
|
4273
4372
|
fail('non-object-destructured-container', element);
|
|
4274
4373
|
}
|
|
@@ -4287,15 +4386,15 @@ const createSession = (checker, flow) => {
|
|
|
4287
4386
|
ts.isGetAccessorDeclaration(owner) ||
|
|
4288
4387
|
ts.isSetAccessorDeclaration(owner)) {
|
|
4289
4388
|
for (const construction of constructionsOf(owner))
|
|
4290
|
-
|
|
4389
|
+
joinCarried(value(construction));
|
|
4291
4390
|
}
|
|
4292
4391
|
else if (isBody(owner)) {
|
|
4293
|
-
|
|
4392
|
+
need(closure(owner));
|
|
4294
4393
|
for (const construction of constructionsOf(owner))
|
|
4295
|
-
|
|
4394
|
+
joinCarried(value(construction));
|
|
4296
4395
|
for (const call of read(callersOf(owner)))
|
|
4297
4396
|
if (ts.isCallExpression(call))
|
|
4298
|
-
|
|
4397
|
+
joinCarried(frameQuery('frame-receiver', call, owner));
|
|
4299
4398
|
}
|
|
4300
4399
|
else
|
|
4301
4400
|
fail('unmodelled-receiver-owner');
|
|
@@ -4340,7 +4439,7 @@ const createSession = (checker, flow) => {
|
|
|
4340
4439
|
fail('static-member-callers-open', owner);
|
|
4341
4440
|
else
|
|
4342
4441
|
for (const instance of familyInstancesOf(owner.parent, 'member-family-open') ?? [])
|
|
4343
|
-
|
|
4442
|
+
need(closure(instance));
|
|
4344
4443
|
}
|
|
4345
4444
|
// Which candidates target this owner is asked the other way round:
|
|
4346
4445
|
// the `targets` states that hold the owner, from the reverse index,
|
|
@@ -4403,7 +4502,7 @@ const createSession = (checker, flow) => {
|
|
|
4403
4502
|
}
|
|
4404
4503
|
case 'closure': {
|
|
4405
4504
|
const root = query.node;
|
|
4406
|
-
if (isFamilyMember(root))
|
|
4505
|
+
if (isFamilyMember(root) || isLiteralGroupMember(root))
|
|
4407
4506
|
gating = gateLogOf(query);
|
|
4408
4507
|
if (ts.isFunctionDeclaration(root)) {
|
|
4409
4508
|
// `refs` follows the same import inventory as stored cells. A
|
|
@@ -4420,13 +4519,13 @@ const createSession = (checker, flow) => {
|
|
|
4420
4519
|
if (key === null)
|
|
4421
4520
|
fail('computed-method');
|
|
4422
4521
|
else
|
|
4423
|
-
|
|
4522
|
+
join(publication(root, root.parent, key));
|
|
4424
4523
|
}
|
|
4425
4524
|
else
|
|
4426
4525
|
refs(root, root);
|
|
4427
4526
|
}
|
|
4428
4527
|
else if (ts.isExpression(root))
|
|
4429
|
-
|
|
4528
|
+
joinUse(root, root);
|
|
4430
4529
|
else
|
|
4431
4530
|
fail('unmodelled-root');
|
|
4432
4531
|
if (ts.isNewExpression(root) && !isFreshOrdinaryObject(root)) {
|
|
@@ -4437,14 +4536,14 @@ const createSession = (checker, flow) => {
|
|
|
4437
4536
|
for (const owner of owners) {
|
|
4438
4537
|
if (!isClassSpelledSourceClass(owner)) {
|
|
4439
4538
|
for (const reference of flow.receiverReferencesToDeclaration(owner))
|
|
4440
|
-
|
|
4539
|
+
joinUse(root, reference);
|
|
4441
4540
|
continue;
|
|
4442
4541
|
}
|
|
4443
4542
|
for (const member of owner.members) {
|
|
4444
4543
|
if (ts.isConstructorDeclaration(member) ||
|
|
4445
4544
|
(ts.isPropertyDeclaration(member) && (ts.getCombinedModifierFlags(member) & ts.ModifierFlags.Static) === 0))
|
|
4446
4545
|
for (const reference of flow.receiverReferencesToDeclaration(member))
|
|
4447
|
-
|
|
4546
|
+
joinUse(root, reference);
|
|
4448
4547
|
}
|
|
4449
4548
|
}
|
|
4450
4549
|
}
|
|
@@ -4454,6 +4553,7 @@ const createSession = (checker, flow) => {
|
|
|
4454
4553
|
}
|
|
4455
4554
|
case 'use':
|
|
4456
4555
|
familyWalk = familyReps.has(query.root);
|
|
4556
|
+
literalWalk = literalReps.has(query.root);
|
|
4457
4557
|
walkedReference = query.node;
|
|
4458
4558
|
visitUse(query.root, query.node);
|
|
4459
4559
|
break;
|
|
@@ -4473,6 +4573,12 @@ const createSession = (checker, flow) => {
|
|
|
4473
4573
|
facts.add(entry.access);
|
|
4474
4574
|
break;
|
|
4475
4575
|
}
|
|
4576
|
+
case 'copy-sites': {
|
|
4577
|
+
for (const stored of read(closure(query.node)))
|
|
4578
|
+
if (isCopySite(stored))
|
|
4579
|
+
facts.add(stored);
|
|
4580
|
+
break;
|
|
4581
|
+
}
|
|
4476
4582
|
case 'key-reads': {
|
|
4477
4583
|
// `unknown-reads`' inversion for the reads that spell their key:
|
|
4478
4584
|
// the receivers holding this container, from the reverse index,
|
|
@@ -4505,14 +4611,14 @@ const createSession = (checker, flow) => {
|
|
|
4505
4611
|
}
|
|
4506
4612
|
case 'family-slot': {
|
|
4507
4613
|
for (const member of familyMembersOf(query.node))
|
|
4508
|
-
|
|
4614
|
+
joinCarried(slot(member, query.key));
|
|
4509
4615
|
break;
|
|
4510
4616
|
}
|
|
4511
4617
|
case 'enumerated-slots': {
|
|
4512
4618
|
const root = query.root;
|
|
4513
4619
|
const head = nodeQuery('enumerated-keys', query.node);
|
|
4514
4620
|
for (const key of enumeratedKeyListOf(head, read(head)))
|
|
4515
|
-
|
|
4621
|
+
joinCarried(slot(root, key));
|
|
4516
4622
|
break;
|
|
4517
4623
|
}
|
|
4518
4624
|
case 'enumerated-keys': {
|
|
@@ -4562,16 +4668,17 @@ const createSession = (checker, flow) => {
|
|
|
4562
4668
|
// The value continues at every reference the container's key is used
|
|
4563
4669
|
// at (`keyUsesOf`), which is the same for every value it holds.
|
|
4564
4670
|
for (const reference of read(keyUsesOf(query.node, query.key)))
|
|
4565
|
-
|
|
4671
|
+
joinUse(query.root, reference);
|
|
4566
4672
|
break;
|
|
4567
4673
|
}
|
|
4568
4674
|
case 'key-uses': {
|
|
4569
4675
|
const container = query.node;
|
|
4570
4676
|
const key = query.key;
|
|
4571
|
-
|
|
4677
|
+
need(closure(container));
|
|
4678
|
+
const copySites = read(copySitesOf(container));
|
|
4572
4679
|
// A container merged into another by `Object.assign` hands this
|
|
4573
4680
|
// key's value to the target as well.
|
|
4574
|
-
for (const stored of
|
|
4681
|
+
for (const stored of copySites) {
|
|
4575
4682
|
if (!ts.isCallExpression(stored))
|
|
4576
4683
|
continue;
|
|
4577
4684
|
const bulk = bulkAssignOf(stored);
|
|
@@ -4579,12 +4686,12 @@ const createSession = (checker, flow) => {
|
|
|
4579
4686
|
continue;
|
|
4580
4687
|
for (const held of read(value(bulk.target)))
|
|
4581
4688
|
if (isObjectRoot(held))
|
|
4582
|
-
|
|
4689
|
+
join(keyUsesOf(held, key));
|
|
4583
4690
|
}
|
|
4584
|
-
for (const stored of
|
|
4691
|
+
for (const stored of copySites) {
|
|
4585
4692
|
const copied = ts.isExpression(stored) ? outermostErasureOf(stored).parent : undefined;
|
|
4586
4693
|
if (copied && ts.isSpreadAssignment(copied) && read(value(copied.expression)).has(container))
|
|
4587
|
-
|
|
4694
|
+
join(keyUsesOf(copied.parent, key));
|
|
4588
4695
|
if (!ts.isCallExpression(stored) || !definitionPlans.has(stored) || key !== 'value')
|
|
4589
4696
|
continue;
|
|
4590
4697
|
const plan = definitionOf(stored);
|
|
@@ -4593,7 +4700,7 @@ const createSession = (checker, flow) => {
|
|
|
4593
4700
|
for (const held of read(value(stored.arguments[0])))
|
|
4594
4701
|
if (isObjectRoot(held))
|
|
4595
4702
|
for (const defined of plan.keys)
|
|
4596
|
-
|
|
4703
|
+
join(keyUsesOf(held, defined));
|
|
4597
4704
|
}
|
|
4598
4705
|
// Discovery-only, as the per-read receiver test it replaces was.
|
|
4599
4706
|
for (const access of observe(keyReadsOf(container, key))) {
|
|
@@ -4657,9 +4764,77 @@ const createSession = (checker, flow) => {
|
|
|
4657
4764
|
grounding.size === 0 ? NO_GROUNDING : grounding.size === 1 ? grounding.values().next().value : exactListOf(grounding);
|
|
4658
4765
|
outcome.seeded = seeded;
|
|
4659
4766
|
}
|
|
4767
|
+
// A node answering gates for its root keeps a gate log across its
|
|
4768
|
+
// evaluations and asks every gate again each time; it always runs in full.
|
|
4769
|
+
if (inputs !== null && !gateLogs.has(query))
|
|
4770
|
+
transferInputs.set(query, inputs);
|
|
4771
|
+
return facts;
|
|
4772
|
+
};
|
|
4773
|
+
/**
|
|
4774
|
+
* A transfer re-run only because something it joined grew: the joined
|
|
4775
|
+
* facts it has not handed back yet, without running it again.
|
|
4776
|
+
*
|
|
4777
|
+
* Most of a node's re-evaluations are of that kind -- a closure is woken
|
|
4778
|
+
* each time one of its uses gains a place, a publication each time one of
|
|
4779
|
+
* its key's uses does -- and a full re-run repeated all of the node's own
|
|
4780
|
+
* work to hand back only the joined facts' growth. A transfer is a
|
|
4781
|
+
* function of what it tests (its other reads, each a set that only grows,
|
|
4782
|
+
* so an unchanged size is the same set), the holders it asks for and the
|
|
4783
|
+
* program; a joined input it only adds whole. So while every tested set
|
|
4784
|
+
* and holder count is as the last full run left it, that run would do
|
|
4785
|
+
* everything the same and hand back, in the same order, exactly the joined
|
|
4786
|
+
* inputs' new facts. Seals and any change still run the transfer in full.
|
|
4787
|
+
*/
|
|
4788
|
+
const joinedOnly = (query, holdersOf) => {
|
|
4789
|
+
if (!joinedOnlyEnabled)
|
|
4790
|
+
return null;
|
|
4791
|
+
const inputs = transferInputs.get(query);
|
|
4792
|
+
if (inputs === undefined)
|
|
4793
|
+
return null;
|
|
4794
|
+
for (let index = 0; index < inputs.tested.length; index++)
|
|
4795
|
+
if (inputs.tested[index].size !== inputs.testedSizes[index])
|
|
4796
|
+
return null;
|
|
4797
|
+
for (const [fact, count] of inputs.holders) {
|
|
4798
|
+
let now = 0;
|
|
4799
|
+
for (const _holder of holdersOf(fact))
|
|
4800
|
+
now++;
|
|
4801
|
+
if (now !== count)
|
|
4802
|
+
return null;
|
|
4803
|
+
}
|
|
4804
|
+
const facts = new Set();
|
|
4805
|
+
let through = addedThrough.get(query);
|
|
4806
|
+
for (let index = 0; index < inputs.joined.length; index++) {
|
|
4807
|
+
const held = inputs.joined[index];
|
|
4808
|
+
const size = held.size;
|
|
4809
|
+
if (size === inputs.joinedSizes[index])
|
|
4810
|
+
continue;
|
|
4811
|
+
inputs.joinedSizes[index] = size;
|
|
4812
|
+
// `add`, for a transfer: past `DELTA_MINIMUM` from where the last one stopped.
|
|
4813
|
+
if (size <= DELTA_MINIMUM) {
|
|
4814
|
+
for (const value of held)
|
|
4815
|
+
facts.add(value);
|
|
4816
|
+
continue;
|
|
4817
|
+
}
|
|
4818
|
+
if (through === undefined)
|
|
4819
|
+
addedThrough.set(query, (through = new Map()));
|
|
4820
|
+
const before = through.get(held) ?? 0;
|
|
4821
|
+
let at = 0;
|
|
4822
|
+
for (const value of held)
|
|
4823
|
+
if (at++ >= before)
|
|
4824
|
+
facts.add(value);
|
|
4825
|
+
through.set(held, size);
|
|
4826
|
+
}
|
|
4660
4827
|
return facts;
|
|
4661
4828
|
};
|
|
4662
4829
|
const run = (query, read, observe, holdersOf, sealing, outcome) => {
|
|
4830
|
+
graphRevision.value++;
|
|
4831
|
+
// Before the ledger capture: a transfer that is not re-run raises no
|
|
4832
|
+
// obligation, and must keep the ones its last full run raised.
|
|
4833
|
+
if (outcome === null) {
|
|
4834
|
+
const joined = joinedOnly(query, holdersOf);
|
|
4835
|
+
if (joined !== null)
|
|
4836
|
+
return joined;
|
|
4837
|
+
}
|
|
4663
4838
|
const ledger = deferredIntrinsicProtocolLedgerOf(flow);
|
|
4664
4839
|
if (!ledger)
|
|
4665
4840
|
return evaluate(query, read, observe, holdersOf, sealing, outcome);
|
|
@@ -4729,7 +4904,16 @@ const createSession = (checker, flow) => {
|
|
|
4729
4904
|
}
|
|
4730
4905
|
};
|
|
4731
4906
|
})();
|
|
4732
|
-
const { solve, requiredDependenciesOf, seed } = dependencyFactSolver(definition, 'grounding-domains', true);
|
|
4907
|
+
const { solve: solveGraph, requiredDependenciesOf, seed } = dependencyFactSolver(definition, 'grounding-domains', true);
|
|
4908
|
+
// A node's transfer inputs serve the re-runs of one solve; a later root wakes few nodes, and keeping them all would hold a second copy of every edge.
|
|
4909
|
+
const solve = (query) => {
|
|
4910
|
+
try {
|
|
4911
|
+
return solveGraph(query);
|
|
4912
|
+
}
|
|
4913
|
+
finally {
|
|
4914
|
+
transferInputs.clear();
|
|
4915
|
+
}
|
|
4916
|
+
};
|
|
4733
4917
|
// `case 'unknown-reads'` now asks `holdersOf` for the receivers that hold a
|
|
4734
4918
|
// container, instead of `observe`-ing all 968 of them itself -- but a
|
|
4735
4919
|
// reverse index only finds states that already EXIST and have already run.
|
|
@@ -4745,23 +4929,44 @@ const createSession = (checker, flow) => {
|
|
|
4745
4929
|
// `hasUnnamedWrite` asks the same reverse question of every computed write's receiver.
|
|
4746
4930
|
for (const receiver of computedWriteReceiverQueries)
|
|
4747
4931
|
seed(receiver);
|
|
4932
|
+
/**
|
|
4933
|
+
* Every obligation a root's answer rests on: a walk of its whole required
|
|
4934
|
+
* graph, which for a root in a large program's main component is half the
|
|
4935
|
+
* session. The same roots are asked again and again once the solver has
|
|
4936
|
+
* stopped growing (the structural censuses ask most of them), so an answer
|
|
4937
|
+
* is kept while no transfer or seal has run since (`graphRevision`): only
|
|
4938
|
+
* those change the required edges or a node's obligations.
|
|
4939
|
+
*/
|
|
4940
|
+
let obligationsRevision = -1;
|
|
4941
|
+
const obligationsByRoot = new Map();
|
|
4748
4942
|
const obligations = (root) => {
|
|
4943
|
+
if (obligationsRevision !== graphRevision.value) {
|
|
4944
|
+
obligationsByRoot.clear();
|
|
4945
|
+
obligationsRevision = graphRevision.value;
|
|
4946
|
+
}
|
|
4947
|
+
const known = obligationsByRoot.get(root);
|
|
4948
|
+
if (known !== undefined)
|
|
4949
|
+
return known;
|
|
4749
4950
|
const found = [];
|
|
4750
|
-
|
|
4951
|
+
// Marked when queued rather than when taken: a node is visited at its
|
|
4952
|
+
// first place in the queue either way, and the queue no longer holds an
|
|
4953
|
+
// entry per edge into it.
|
|
4954
|
+
const visited = new Set([root]);
|
|
4751
4955
|
const queue = [root];
|
|
4752
4956
|
for (let index = 0; index < queue.length; index++) {
|
|
4753
4957
|
const query = queue[index];
|
|
4754
|
-
if (visited.has(query))
|
|
4755
|
-
continue;
|
|
4756
|
-
visited.add(query);
|
|
4757
4958
|
const held = requirements.get(query);
|
|
4758
4959
|
if (Array.isArray(held))
|
|
4759
4960
|
found.push(...held);
|
|
4760
4961
|
else if (held !== undefined)
|
|
4761
4962
|
found.push(held);
|
|
4762
4963
|
for (const dependency of requiredDependenciesOf(query))
|
|
4763
|
-
|
|
4964
|
+
if (!visited.has(dependency)) {
|
|
4965
|
+
visited.add(dependency);
|
|
4966
|
+
queue.push(dependency);
|
|
4967
|
+
}
|
|
4764
4968
|
}
|
|
4969
|
+
obligationsByRoot.set(root, found);
|
|
4765
4970
|
return found;
|
|
4766
4971
|
};
|
|
4767
4972
|
// A literal's function-valued entry (`convert: function ( ... ) { ... }`)
|