@eagleoutice/flowr 2.14.0 → 2.14.1
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 +39 -28
- package/benchmark/calibration.d.ts +13 -11
- package/benchmark/calibration.js +25 -26
- package/benchmark/slicer.d.ts +2 -1
- package/benchmark/slicer.js +6 -3
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -0
- package/cli/common/options.js +1 -0
- package/cli/common/scripts-info.d.ts +5 -0
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/config.js +5 -6
- package/dataflow/environments/apply-kill.js +1 -1
- package/dataflow/environments/built-in-props.d.ts +6 -2
- package/dataflow/environments/built-in-props.js +5 -1
- package/dataflow/environments/default-builtin-config.d.ts +76 -1
- package/dataflow/environments/default-builtin-config.js +30 -5
- package/dataflow/environments/environment.d.ts +9 -1
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +20 -0
- package/dataflow/environments/resolve-by-name.js +14 -2
- package/dataflow/eval/resolve/resolve-operators.js +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +1 -2
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +85 -38
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +337 -0
- package/dataflow/graph/df-helper.d.ts +9 -1
- package/dataflow/graph/df-helper.js +19 -3
- package/dataflow/graph/graph.d.ts +28 -2
- package/dataflow/graph/graph.js +59 -2
- package/dataflow/info.d.ts +26 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +27 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +1 -0
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-query.js +53 -0
- package/linter/linter-output.js +1 -1
- package/linter/linter-rules.d.ts +24 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/package.json +4 -7
- package/project/dependency-version-space.d.ts +3 -3
- package/project/dependency-version-space.js +2 -2
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/manifest.d.ts +3 -1
- package/project/sigdb/manifest.js +50 -9
- package/project/sigdb/reader.js +1 -1
- package/project/sigdb/schema.d.ts +2 -2
- package/project/sigdb/schema.js +2 -2
- package/queries/catalog/dependencies-query/link-devices.js +2 -8
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/search/flowr-search-filters.js +1 -13
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +2 -2
- package/slicing/static/fingerprint.js +1 -1
- package/util/objects.d.ts +12 -0
- package/util/objects.js +48 -0
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/name-rank.d.ts +1 -1
- package/util/text/name-rank.js +1 -1
- package/util/version.js +1 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strictnessOfFunction = strictnessOfFunction;
|
|
4
|
+
exports.strictnessOfFunctions = strictnessOfFunctions;
|
|
5
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
6
|
+
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
7
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
|
+
const graph_1 = require("../graph/graph");
|
|
9
|
+
const edge_1 = require("../graph/edge");
|
|
10
|
+
const vertex_1 = require("../graph/vertex");
|
|
11
|
+
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
12
|
+
const built_in_props_1 = require("../environments/built-in-props");
|
|
13
|
+
const query_fn_props_1 = require("../environments/query-fn-props");
|
|
14
|
+
const identifier_1 = require("../environments/identifier");
|
|
15
|
+
const logic_1 = require("../../util/logic");
|
|
16
|
+
/**
|
|
17
|
+
* What an argument is used for when the call never evaluates it: quoted or read in another frame
|
|
18
|
+
* ({@link ArgProp.Nse}), or looked at only for having been supplied ({@link ArgProp.Presence}).
|
|
19
|
+
*/
|
|
20
|
+
const NotEvaluated = built_in_props_1.ArgProp.Nse | built_in_props_1.ArgProp.Presence;
|
|
21
|
+
/**
|
|
22
|
+
* The processors whose calls reach their first argument and the rest only on the way the run happens to
|
|
23
|
+
* take: `switch` picks one of its branches, and `try`/`tryCatch` reach a handler only when one is needed.
|
|
24
|
+
*/
|
|
25
|
+
const LazyAfterFirst = [built_in_proc_name_1.BuiltInProcName.Switch, built_in_proc_name_1.BuiltInProcName.Try];
|
|
26
|
+
/**
|
|
27
|
+
* The processors putting off what they are given until a moment that may never come: a hook runs when the
|
|
28
|
+
* function exits, and `Recall` starts the same function over rather than reading anything itself.
|
|
29
|
+
*/
|
|
30
|
+
const LazyThroughout = [built_in_proc_name_1.BuiltInProcName.RegisterHook, built_in_proc_name_1.BuiltInProcName.Recall];
|
|
31
|
+
/** The processors dispatching to a method chosen at run time. */
|
|
32
|
+
const DispatchProcessors = [
|
|
33
|
+
built_in_proc_name_1.BuiltInProcName.S3Dispatch, built_in_proc_name_1.BuiltInProcName.S3DispatchNext, built_in_proc_name_1.BuiltInProcName.S7Dispatch
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Whether the call hands the work to a method chosen at run time: flowR's own dispatch processors say so for
|
|
37
|
+
* `UseMethod` and `NextMethod`, and {@link DispatchCallees} covers the ones it has no processor for.
|
|
38
|
+
*/
|
|
39
|
+
function isDispatch(vertex) {
|
|
40
|
+
return hasProcessor(vertex, DispatchProcessors) || built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name));
|
|
41
|
+
}
|
|
42
|
+
/** Whether the call belongs to one of the given processors. */
|
|
43
|
+
function hasProcessor(vertex, of) {
|
|
44
|
+
return vertex.origin !== 'unnamed' && of.some(p => vertex.origin.includes(p));
|
|
45
|
+
}
|
|
46
|
+
/** The definition a node sits in. */
|
|
47
|
+
function enclosingDefinition(id, idMap, graph) {
|
|
48
|
+
let node = idMap.get(id);
|
|
49
|
+
while (node !== undefined) {
|
|
50
|
+
if (vertex_1.FunctionDefinitionVertex.is(graph.getVertex(node.info.id))) {
|
|
51
|
+
return node.info.id;
|
|
52
|
+
}
|
|
53
|
+
node = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
function makeState(graph, ctx) {
|
|
58
|
+
const idMap = graph.idMap;
|
|
59
|
+
const owner = new Map();
|
|
60
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
61
|
+
for (const param of Object.keys(vertex.params)) {
|
|
62
|
+
owner.set(node_id_1.NodeId.normalize(param), id);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const dispatch = new Map();
|
|
66
|
+
if (idMap !== undefined) {
|
|
67
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
68
|
+
if (!isDispatch(vertex) || typeof node_id_1.NodeId.normalize(id) !== 'number') {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const within = enclosingDefinition(id, idMap, graph);
|
|
72
|
+
if (within === undefined) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const node = idMap.get(id);
|
|
76
|
+
const known = dispatch.get(within);
|
|
77
|
+
const named = (node?.type === type_1.RType.FunctionCall && (node.arguments?.length ?? 0) > 1) || (known?.named ?? false);
|
|
78
|
+
const certain = !underCondition(vertex.cds, graph.getVertex(within)?.cds) || (known?.certain ?? false);
|
|
79
|
+
const next = [...known?.next ?? []];
|
|
80
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
81
|
+
if (target !== within && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.FunctionDefinitionVertex.is(graph.getVertex(target))) {
|
|
82
|
+
next.push(target);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
dispatch.set(within, { named, certain, next });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const environment = ctx?.env.makeCleanEnv();
|
|
89
|
+
const props = environment === undefined
|
|
90
|
+
? (name) => query_fn_props_1.BuiltInIndex.default().get(name)?.sig
|
|
91
|
+
: (name) => (0, query_fn_props_1.queryFnProps)(name, { environment })?.sig;
|
|
92
|
+
return { graph, idMap, owner, dispatch, sigs: new Map(), props, known: new Map(), asking: new Set(), assumed: false };
|
|
93
|
+
}
|
|
94
|
+
/** What is certain becomes a possibility once something may intervene. */
|
|
95
|
+
function weaken(value) {
|
|
96
|
+
return value === logic_1.Ternary.Always ? logic_1.Ternary.Maybe : value;
|
|
97
|
+
}
|
|
98
|
+
/** What several answers amount to when only one applies and nothing says which. */
|
|
99
|
+
function agree(values) {
|
|
100
|
+
if (values.length === 0) {
|
|
101
|
+
return logic_1.Ternary.Never;
|
|
102
|
+
}
|
|
103
|
+
return values.every(v => v === values[0]) ? values[0] : logic_1.Ternary.Maybe;
|
|
104
|
+
}
|
|
105
|
+
/** Whether the control dependencies exceed the ones the definition itself stands under. */
|
|
106
|
+
function underCondition(cds, definition) {
|
|
107
|
+
return cds?.some(c => !definition?.some(d => d.id === c.id && d.when === c.when)) ?? false;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Built-ins force what they are given, and the ones that do not (`quote` and its relatives) leave no read of
|
|
111
|
+
* the argument in the graph in the first place, so there is nothing to hold back here. A call of something
|
|
112
|
+
* the code worked out for itself (`obj$method(...)`) is none of them, whichever way it was written.
|
|
113
|
+
*/
|
|
114
|
+
function isBuiltInCall(vertex) {
|
|
115
|
+
return vertex.origin !== 'unnamed'
|
|
116
|
+
&& !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Function)
|
|
117
|
+
&& !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Unnamed);
|
|
118
|
+
}
|
|
119
|
+
/** The node whose value an argument stands for, carrying the link to the parameter it binds to. */
|
|
120
|
+
function argumentValue(id, idMap) {
|
|
121
|
+
const node = idMap.get(id);
|
|
122
|
+
return node?.type === type_1.RType.Argument ? node.value?.info.id ?? id : id;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Where the given node stands in the call's arguments. The graph names an argument by the value it wraps,
|
|
126
|
+
* while the walk arrives at the argument itself, so both count as a hit; `-1` when neither does, which a
|
|
127
|
+
* call whose arguments flowR rewrote (`on.exit` and the other deferred ones) is enough to bring about.
|
|
128
|
+
*/
|
|
129
|
+
function argumentIndex(call, child, idMap) {
|
|
130
|
+
const value = argumentValue(child, idMap);
|
|
131
|
+
return call.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && (arg.nodeId === child || arg.nodeId === value));
|
|
132
|
+
}
|
|
133
|
+
/** Whether the node is the function a call is of rather than something handed to it. */
|
|
134
|
+
function isCallee(call, child, idMap) {
|
|
135
|
+
const node = idMap.get(call);
|
|
136
|
+
if (!r_function_call_1.RFunctionCall.is(node)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return (r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.info.id : node.calledFunction.info.id) === child;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* What flowR states the argument at `index` of the call is used for. A `...` covers every position from
|
|
143
|
+
* where it is declared, which {@link FnSig.propAt} takes care of.
|
|
144
|
+
*/
|
|
145
|
+
function argProps(vertex, index, state) {
|
|
146
|
+
const name = identifier_1.Identifier.getName(vertex.name);
|
|
147
|
+
let sig = state.sigs.get(name);
|
|
148
|
+
if (sig === undefined && !state.sigs.has(name)) {
|
|
149
|
+
state.sigs.set(name, sig = state.props(vertex.name));
|
|
150
|
+
}
|
|
151
|
+
return sig === undefined || index < 0 ? 0 : built_in_props_1.FnSig.propAt(built_in_props_1.FnSig.layout(sig), index);
|
|
152
|
+
}
|
|
153
|
+
/** The verdict a callee's parameter carries over to what is handed to it. */
|
|
154
|
+
function handedTo(param, state) {
|
|
155
|
+
const owner = state.owner.get(param);
|
|
156
|
+
return owner === undefined ? logic_1.Ternary.Maybe : strictnessOf(owner, state).parameters[param] ?? logic_1.Ternary.Maybe;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Whether handing `argument` to `call` forces it. An argument the call passes on is forced exactly as the
|
|
160
|
+
* function receiving it forces the parameter it binds to; a call flowR cannot resolve, and one whose argument
|
|
161
|
+
* it cannot match to a parameter, leave the question open.
|
|
162
|
+
*/
|
|
163
|
+
function forcedByCallee(call, argument, idMap, state) {
|
|
164
|
+
const resolved = [...state.graph.outgoingEdges(call.id) ?? graph_1.NoEdges]
|
|
165
|
+
.some(([target, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.FunctionDefinitionVertex.is(state.graph.getVertex(target)));
|
|
166
|
+
if (!resolved) {
|
|
167
|
+
return logic_1.Ternary.Maybe;
|
|
168
|
+
}
|
|
169
|
+
const bound = [];
|
|
170
|
+
for (const from of new Set([argument, argumentValue(argument, idMap)])) {
|
|
171
|
+
for (const [target, edge] of state.graph.outgoingEdges(from) ?? graph_1.NoEdges) {
|
|
172
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinesOnCall)) {
|
|
173
|
+
bound.push(handedTo(target, state));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return bound.length === 0 ? logic_1.Ternary.Maybe : agree(bound);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* How far the given read of a parameter is unavoidable: it has to stand under no condition the definition
|
|
181
|
+
* does not already stand under, must not sit in a function or a default of its own that may never be
|
|
182
|
+
* reached, and must not merely be handed to something that leaves it alone.
|
|
183
|
+
*/
|
|
184
|
+
function forces(read, definition, state) {
|
|
185
|
+
const idMap = state.idMap;
|
|
186
|
+
if (idMap === undefined) {
|
|
187
|
+
return logic_1.Ternary.Maybe;
|
|
188
|
+
}
|
|
189
|
+
let certain = true;
|
|
190
|
+
let child = read;
|
|
191
|
+
let node = idMap.get(read);
|
|
192
|
+
while (node !== undefined && node.info.id !== definition.id) {
|
|
193
|
+
const vertex = state.graph.getVertex(node.info.id);
|
|
194
|
+
if (underCondition(vertex?.cds, definition.cds)) {
|
|
195
|
+
certain = false;
|
|
196
|
+
}
|
|
197
|
+
if (node.info.id !== read) {
|
|
198
|
+
if (vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
199
|
+
/* nothing says the nested definition is ever called */
|
|
200
|
+
certain = false;
|
|
201
|
+
}
|
|
202
|
+
else if (node.type === type_1.RType.Parameter) {
|
|
203
|
+
/* a default is evaluated only when the argument is left out */
|
|
204
|
+
certain = false;
|
|
205
|
+
}
|
|
206
|
+
else if (vertex_1.FunctionCallVertex.is(vertex) && !isDispatch(vertex) && !isCallee(node.info.id, child, idMap)) {
|
|
207
|
+
if (!isBuiltInCall(vertex)) {
|
|
208
|
+
const handed = forcedByCallee(vertex, child, idMap, state);
|
|
209
|
+
return certain ? handed : weaken(handed);
|
|
210
|
+
}
|
|
211
|
+
const index = argumentIndex(vertex, child, idMap);
|
|
212
|
+
const props = argProps(vertex, index, state);
|
|
213
|
+
if ((props & NotEvaluated) !== 0) {
|
|
214
|
+
return logic_1.Ternary.Never;
|
|
215
|
+
}
|
|
216
|
+
else if ((props & built_in_props_1.ArgProp.Forced) === 0
|
|
217
|
+
&& (hasProcessor(vertex, LazyThroughout) || (index !== 0 && hasProcessor(vertex, LazyAfterFirst)))) {
|
|
218
|
+
certain = false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
child = node.info.id;
|
|
223
|
+
node = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
224
|
+
}
|
|
225
|
+
if (node === undefined) {
|
|
226
|
+
return logic_1.Ternary.Never;
|
|
227
|
+
}
|
|
228
|
+
return certain ? logic_1.Ternary.Always : logic_1.Ternary.Maybe;
|
|
229
|
+
}
|
|
230
|
+
function strictnessOfParameter(param, definition, state) {
|
|
231
|
+
const reads = [];
|
|
232
|
+
for (const [read, edge] of state.graph.ingoingEdges(param) ?? graph_1.NoEdges) {
|
|
233
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
|
|
234
|
+
reads.push(forces(read, definition, state));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const dispatch = state.dispatch.get(definition.id);
|
|
238
|
+
if (dispatch !== undefined) {
|
|
239
|
+
const methods = [];
|
|
240
|
+
for (const [target, edge] of state.graph.outgoingEdges(param) ?? graph_1.NoEdges) {
|
|
241
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinesOnCall)) {
|
|
242
|
+
methods.push(handedTo(target, state));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
reads.push(dispatch.certain ? agree(methods) : weaken(agree(methods)));
|
|
246
|
+
if (dispatch.next.length > 0) {
|
|
247
|
+
const at = parameterIds(definition.id, state.idMap).indexOf(param);
|
|
248
|
+
const along = at < 0 ? [] : dispatch.next.map(method => {
|
|
249
|
+
const same = parameterIds(method, state.idMap)[at];
|
|
250
|
+
return same === undefined ? logic_1.Ternary.Maybe : strictnessOf(method, state).parameters[same] ?? logic_1.Ternary.Maybe;
|
|
251
|
+
});
|
|
252
|
+
reads.push(dispatch.certain ? agree(along) : weaken(agree(along)));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return logic_1.TernaryLogic.or(...reads);
|
|
256
|
+
}
|
|
257
|
+
/** The parameters of a definition in the order they are written. */
|
|
258
|
+
function parameterIds(definition, idMap) {
|
|
259
|
+
const node = idMap?.get(definition);
|
|
260
|
+
return node?.type === type_1.RType.FunctionDefinition ? node.parameters.map(p => p.name.info.id) : [];
|
|
261
|
+
}
|
|
262
|
+
function strictnessOf(id, state) {
|
|
263
|
+
const known = state.known.get(id);
|
|
264
|
+
if (known !== undefined) {
|
|
265
|
+
return known;
|
|
266
|
+
}
|
|
267
|
+
const vertex = state.graph.getVertex(id);
|
|
268
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
269
|
+
return { strict: logic_1.Ternary.Never, parameters: {} };
|
|
270
|
+
}
|
|
271
|
+
const params = Object.keys(vertex.params);
|
|
272
|
+
if (state.asking.has(id)) {
|
|
273
|
+
/* the answer is the one still being worked out */
|
|
274
|
+
state.assumed = true;
|
|
275
|
+
return { strict: logic_1.Ternary.Maybe, parameters: Object.fromEntries(params.map(param => [param, logic_1.Ternary.Maybe])) };
|
|
276
|
+
}
|
|
277
|
+
state.asking.add(id);
|
|
278
|
+
const parameters = {};
|
|
279
|
+
for (const param of params) {
|
|
280
|
+
parameters[param] = strictnessOfParameter(node_id_1.NodeId.normalize(param), vertex, state);
|
|
281
|
+
}
|
|
282
|
+
const dispatch = state.dispatch.get(id);
|
|
283
|
+
if (dispatch !== undefined) {
|
|
284
|
+
for (const param of params) {
|
|
285
|
+
parameters[param] = logic_1.TernaryLogic.or(parameters[param], logic_1.Ternary.Maybe);
|
|
286
|
+
}
|
|
287
|
+
const object = dispatch.named ? undefined : parameterIds(id, state.idMap)[0];
|
|
288
|
+
if (object !== undefined && parameters[object] !== undefined) {
|
|
289
|
+
parameters[object] = dispatch.certain ? logic_1.Ternary.Always : logic_1.TernaryLogic.or(parameters[object], logic_1.Ternary.Maybe);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
state.asking.delete(id);
|
|
293
|
+
const result = { strict: logic_1.TernaryLogic.and(...Object.values(parameters)), parameters };
|
|
294
|
+
if (!state.assumed) {
|
|
295
|
+
state.known.set(id, result);
|
|
296
|
+
}
|
|
297
|
+
else if (state.asking.size === 0) {
|
|
298
|
+
state.assumed = false;
|
|
299
|
+
}
|
|
300
|
+
return result;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Determines whether the function with the given id is strict, i.e., whether calling it forces its arguments.
|
|
304
|
+
* {@link Ternary#Always} says every call forces every parameter, {@link Ternary#Never} that no call forces
|
|
305
|
+
* all of them, and {@link Ternary#Maybe} that it depends on the path taken, on the caller, or on a function
|
|
306
|
+
* flowR could not resolve. A definition without parameters has nothing to leave unforced and is strict.
|
|
307
|
+
*
|
|
308
|
+
* The analysis follows an argument that is handed on into the function receiving it, and treats a read in a
|
|
309
|
+
* default, in a loop, in a branch, or in a nested definition as one that may not happen. What a built-in
|
|
310
|
+
* does with an argument is not guessed from its name: an argument stated {@link ArgProp.Nse} or
|
|
311
|
+
* {@link ArgProp.Presence} is never evaluated, one stated {@link ArgProp.Forced} always is, and the calls
|
|
312
|
+
* reaching an argument only on the way the run takes are the ones flowR hands to the processor that says so
|
|
313
|
+
* (`switch` picking a branch, `try` reaching a handler, a hook running at exit).
|
|
314
|
+
* For a generic, the methods reached by S3 dispatch decide: they agree on a parameter or it is left open,
|
|
315
|
+
* while the object the dispatch is on is forced by the dispatch itself. A `NextMethod` carries the same
|
|
316
|
+
* question on to the methods it reaches, matched by the position the parameter is written in.
|
|
317
|
+
* An argument in `...` is followed to the parameter it binds to, whereas the method of an object flowR
|
|
318
|
+
* cannot resolve (`obj$m(x)`) is one more thing it cannot claim anything about.
|
|
319
|
+
* Cyclic dependencies between functions and calls flowR cannot resolve answer {@link Ternary#Maybe}, so this
|
|
320
|
+
* only claims certainty where the code gives it.
|
|
321
|
+
* What a built-in does with an argument comes from the {@link ArgProp} bits its signature states, so a
|
|
322
|
+
* configured or overwritten built-in is the one that answers when the analyzer context is handed along.
|
|
323
|
+
* @see {@link strictnessOfFunctions} - to ask about several definitions at once, sharing the work
|
|
324
|
+
*/
|
|
325
|
+
function strictnessOfFunction(id, graph, ctx) {
|
|
326
|
+
return strictnessOf(id, makeState(graph, ctx));
|
|
327
|
+
}
|
|
328
|
+
/** The {@link strictnessOfFunction|strictness} of several definitions, sharing the work between them. */
|
|
329
|
+
function strictnessOfFunctions(ids, graph, ctx) {
|
|
330
|
+
const state = makeState(graph, ctx);
|
|
331
|
+
const result = {};
|
|
332
|
+
for (const id of ids) {
|
|
333
|
+
result[id] = strictnessOf(id, state);
|
|
334
|
+
}
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=strict-function.js.map
|
|
@@ -14,7 +14,8 @@ import { Identifier } from '../environments/identifier';
|
|
|
14
14
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
15
15
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
16
16
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
17
|
-
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call
|
|
17
|
+
* - {@link Dataflow.qualify}/{@link Dataflow.qualifyAll} - for the package-qualified `pkg::fn` identifier of a call
|
|
18
|
+
* from its id and graph, or of every call of a graph at once,
|
|
18
19
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
19
20
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
20
21
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
@@ -139,6 +140,13 @@ export declare const Dataflow: {
|
|
|
139
140
|
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
140
141
|
*/
|
|
141
142
|
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* The qualified name of every call of the graph, `undefined` for the calls that do not qualify.
|
|
145
|
+
* Prefer this over asking call by call: it resolves each call once for both `qualifyBaseR` variants.
|
|
146
|
+
* @param graph - The graph to qualify
|
|
147
|
+
* @param qualifyBaseR - Which of the two results to return, see {@link Dataflow.qualify}
|
|
148
|
+
*/
|
|
149
|
+
readonly qualifyAll: (this: void, graph: DataflowGraph, qualifyBaseR?: boolean) => ReadonlyMap<NodeId, Identifier | undefined>;
|
|
142
150
|
/**
|
|
143
151
|
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
144
152
|
* This is what a selection needs, which is not what the program loads: a `library()` whose exports the
|
|
@@ -20,7 +20,8 @@ const r_base_packages_1 = require("../../util/r-base-packages");
|
|
|
20
20
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
21
21
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
22
22
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
23
|
-
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call
|
|
23
|
+
* - {@link Dataflow.qualify}/{@link Dataflow.qualifyAll} - for the package-qualified `pkg::fn` identifier of a call
|
|
24
|
+
* from its id and graph, or of every call of a graph at once,
|
|
24
25
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
25
26
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
26
27
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
@@ -86,8 +87,16 @@ exports.Dataflow = {
|
|
|
86
87
|
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
87
88
|
*/
|
|
88
89
|
qualify(id, graph, qualifyBaseR = true) {
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
return graph.qualify(id, qualifyBaseR, resolveQualification);
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* The qualified name of every call of the graph, `undefined` for the calls that do not qualify.
|
|
94
|
+
* Prefer this over asking call by call: it resolves each call once for both `qualifyBaseR` variants.
|
|
95
|
+
* @param graph - The graph to qualify
|
|
96
|
+
* @param qualifyBaseR - Which of the two results to return, see {@link Dataflow.qualify}
|
|
97
|
+
*/
|
|
98
|
+
qualifyAll(graph, qualifyBaseR = true) {
|
|
99
|
+
return graph.qualifyAll(qualifyBaseR, resolveQualification);
|
|
91
100
|
},
|
|
92
101
|
/**
|
|
93
102
|
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
@@ -312,4 +321,11 @@ exports.Dataflow = {
|
|
|
312
321
|
return exports.Dataflow.reduceGraph(graph, exports.Dataflow.provenance(id, graph, consider));
|
|
313
322
|
}
|
|
314
323
|
};
|
|
324
|
+
/** both qualifications of a call from a single origin resolution, as the base-R step only adds to what the origins gave */
|
|
325
|
+
const resolveQualification = (graph, id, vertex) => {
|
|
326
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(graph, id);
|
|
327
|
+
const name = vertex_1.FunctionCallVertex.is(vertex) ? vertex.name : undefined;
|
|
328
|
+
const bare = identifier_1.Identifier.toQualified(origins, name, false);
|
|
329
|
+
return [bare, bare ?? identifier_1.Identifier.toQualified(origins, name, true)];
|
|
330
|
+
};
|
|
315
331
|
//# sourceMappingURL=df-helper.js.map
|
|
@@ -3,7 +3,7 @@ import { DfEdge } from './edge';
|
|
|
3
3
|
import type { DataflowInformation } from '../info';
|
|
4
4
|
import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from './vertex';
|
|
5
5
|
import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
|
-
import type { BrandedIdentifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
6
|
+
import type { BrandedIdentifier, Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
|
|
7
7
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import { type EnvType, type REnvironmentInformation } from '../environments/environment';
|
|
9
9
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
@@ -142,6 +142,11 @@ export type OutgoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
|
|
|
142
142
|
* In other words, it maps the source to the edge information.
|
|
143
143
|
*/
|
|
144
144
|
export type IngoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
|
|
145
|
+
/**
|
|
146
|
+
* {@link IngoingEdges} as handed out by {@link DataflowGraph#ingoingEdges|ingoingEdges()}: a vertex without any
|
|
147
|
+
* shares the single {@link NoEdges}, so what a caller gets back is not theirs to write into.
|
|
148
|
+
*/
|
|
149
|
+
export type ReadonlyIngoingEdges<Edge extends DfEdge = DfEdge> = ReadonlyMap<NodeId, Edge>;
|
|
145
150
|
/**
|
|
146
151
|
* The shared answer for a vertex without edges. Use it instead of a fresh `[]` fallback, the lookups sit in
|
|
147
152
|
* traversal loops where a miss is the common case.
|
|
@@ -151,6 +156,11 @@ export type IngoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
|
|
|
151
156
|
* ```
|
|
152
157
|
*/
|
|
153
158
|
export declare const NoEdges: ReadonlyMap<NodeId, never>;
|
|
159
|
+
/**
|
|
160
|
+
* Resolves the `pkg::fn` name of the call `id`, without and with the base-R qualification.
|
|
161
|
+
* Passed to {@link DataflowGraph#qualify}, which caches what it returns.
|
|
162
|
+
*/
|
|
163
|
+
export type CallQualifier = (graph: DataflowGraph, id: NodeId, vertex: DataflowGraphVertexInfo | undefined) => readonly [bare: Identifier | undefined, baseR: Identifier | undefined];
|
|
154
164
|
/**
|
|
155
165
|
* The structure of the serialized {@link DataflowGraph}.
|
|
156
166
|
*/
|
|
@@ -219,6 +229,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
219
229
|
private edgeInformation;
|
|
220
230
|
private incomingIndex?;
|
|
221
231
|
private readonly types;
|
|
232
|
+
private qualifiedNames?;
|
|
222
233
|
toJSON(): DataflowGraphJson;
|
|
223
234
|
/**
|
|
224
235
|
* Get the {@link DataflowGraphVertexInfo} attached to a node as well as all outgoing edges.
|
|
@@ -245,7 +256,22 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
245
256
|
*/
|
|
246
257
|
getRootVertex(id: NodeId): Vertex | undefined;
|
|
247
258
|
outgoingEdges(id: NodeId): OutgoingEdges | undefined;
|
|
248
|
-
ingoingEdges(id: NodeId):
|
|
259
|
+
ingoingEdges(id: NodeId): ReadonlyIngoingEdges | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* The cached `pkg::fn` name of the call `id`, asking `resolve` only for a call the cache does not know yet.
|
|
262
|
+
* @useInstead {@link Dataflow.qualify} - which passes the resolution
|
|
263
|
+
*/
|
|
264
|
+
qualify(id: NodeId, qualifyBaseR: boolean, resolve: CallQualifier): Identifier | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* The cached `pkg::fn` name of every call, resolving the calls that are still missing.
|
|
267
|
+
* @useInstead {@link Dataflow.qualifyAll} - which passes the resolution
|
|
268
|
+
*/
|
|
269
|
+
qualifyAll(qualifyBaseR: boolean, resolve: CallQualifier): ReadonlyMap<NodeId, Identifier | undefined>;
|
|
270
|
+
private qualifications;
|
|
271
|
+
/** one resolution fills both variants: what costs is resolving the call, not qualifying it */
|
|
272
|
+
private resolveInto;
|
|
273
|
+
/** Drops the cached qualifications, as the graph may no longer imply them */
|
|
274
|
+
private dropQualifications;
|
|
249
275
|
/**
|
|
250
276
|
* Given a node in the normalized AST this either:
|
|
251
277
|
* returns the id if the node directly exists in the DFG
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -194,6 +194,8 @@ class DataflowGraph {
|
|
|
194
194
|
* edges of many nodes scan the whole graph once per node */
|
|
195
195
|
incomingIndex;
|
|
196
196
|
types = new Map();
|
|
197
|
+
/* the qualified call names, built on demand and dropped on every change, as vertices and edges both decide them */
|
|
198
|
+
qualifiedNames;
|
|
197
199
|
toJSON() {
|
|
198
200
|
return {
|
|
199
201
|
rootVertices: Array.from(this.rootVertices),
|
|
@@ -256,8 +258,56 @@ class DataflowGraph {
|
|
|
256
258
|
}
|
|
257
259
|
this.incomingIndex = index;
|
|
258
260
|
}
|
|
259
|
-
/* the historic contract is an (possibly empty) map for every id, never `undefined
|
|
260
|
-
|
|
261
|
+
/* the historic contract is an (possibly empty) map for every id, never `undefined`; the miss is the common
|
|
262
|
+
* case in traversal loops, so it answers with the shared empty map rather than a fresh one */
|
|
263
|
+
return this.incomingIndex.get(id) ?? exports.NoEdges;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The cached `pkg::fn` name of the call `id`, asking `resolve` only for a call the cache does not know yet.
|
|
267
|
+
* @useInstead {@link Dataflow.qualify} - which passes the resolution
|
|
268
|
+
*/
|
|
269
|
+
qualify(id, qualifyBaseR, resolve) {
|
|
270
|
+
const cache = this.qualifications();
|
|
271
|
+
const wanted = qualifyBaseR ? cache.baseR : cache.bare;
|
|
272
|
+
const hit = wanted.get(id);
|
|
273
|
+
if (hit !== undefined || wanted.has(id)) {
|
|
274
|
+
return hit;
|
|
275
|
+
}
|
|
276
|
+
this.resolveInto(cache, id, this.vertexInformation.get(id), resolve);
|
|
277
|
+
return wanted.get(id);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The cached `pkg::fn` name of every call, resolving the calls that are still missing.
|
|
281
|
+
* @useInstead {@link Dataflow.qualifyAll} - which passes the resolution
|
|
282
|
+
*/
|
|
283
|
+
qualifyAll(qualifyBaseR, resolve) {
|
|
284
|
+
const cache = this.qualifications();
|
|
285
|
+
const wanted = qualifyBaseR ? cache.baseR : cache.bare;
|
|
286
|
+
if (cache.complete) {
|
|
287
|
+
return wanted;
|
|
288
|
+
}
|
|
289
|
+
for (const id of this.types.get(vertex_1.VertexType.FunctionCall) ?? []) {
|
|
290
|
+
if (!wanted.has(id)) {
|
|
291
|
+
this.resolveInto(cache, id, this.vertexInformation.get(id), resolve);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
cache.complete = true;
|
|
295
|
+
return wanted;
|
|
296
|
+
}
|
|
297
|
+
qualifications() {
|
|
298
|
+
return this.qualifiedNames ??= { bare: new Map(), baseR: new Map(), complete: false };
|
|
299
|
+
}
|
|
300
|
+
/** one resolution fills both variants: what costs is resolving the call, not qualifying it */
|
|
301
|
+
resolveInto(cache, id, vertex, resolve) {
|
|
302
|
+
const [bare, baseR] = resolve(this, id, vertex);
|
|
303
|
+
cache.bare.set(id, bare);
|
|
304
|
+
cache.baseR.set(id, baseR);
|
|
305
|
+
}
|
|
306
|
+
/** Drops the cached qualifications, as the graph may no longer imply them */
|
|
307
|
+
dropQualifications() {
|
|
308
|
+
if (this.qualifiedNames !== undefined) {
|
|
309
|
+
this.qualifiedNames = undefined;
|
|
310
|
+
}
|
|
261
311
|
}
|
|
262
312
|
/**
|
|
263
313
|
* Given a node in the normalized AST this either:
|
|
@@ -350,6 +400,7 @@ class DataflowGraph {
|
|
|
350
400
|
if (edge === undefined || targets === undefined) {
|
|
351
401
|
return this;
|
|
352
402
|
}
|
|
403
|
+
this.dropQualifications();
|
|
353
404
|
edge.types &= ~type;
|
|
354
405
|
if (edge_1.DfEdge.hasAnyType(edge)) {
|
|
355
406
|
/* the reverse index holds this very object, so a narrowed type is already visible through it */
|
|
@@ -381,6 +432,7 @@ class DataflowGraph {
|
|
|
381
432
|
if (this.vertexInformation.has(vid) && !overwrite) {
|
|
382
433
|
return this;
|
|
383
434
|
}
|
|
435
|
+
this.dropQualifications();
|
|
384
436
|
const vtag = vertex.tag;
|
|
385
437
|
// keep a clone of the original environment, isolating the snapshot from later updates
|
|
386
438
|
vertex.environment = vertex.environment ? (0, clone_1.cloneEnvironmentInformation)(vertex.environment) : (vtag === vertex_1.VertexType.FunctionDefinition || (vtag === vertex_1.VertexType.FunctionCall && !vertex.onlyBuiltin) ? fallbackEnv : undefined);
|
|
@@ -401,6 +453,7 @@ class DataflowGraph {
|
|
|
401
453
|
if (fromId === toId) {
|
|
402
454
|
return this;
|
|
403
455
|
}
|
|
456
|
+
this.dropQualifications();
|
|
404
457
|
const fromEdges = this.edgeInformation.get(fromId);
|
|
405
458
|
const existing = fromEdges?.get(toId);
|
|
406
459
|
if (existing !== undefined) {
|
|
@@ -456,6 +509,7 @@ class DataflowGraph {
|
|
|
456
509
|
return this;
|
|
457
510
|
}
|
|
458
511
|
mergeVertices(otherGraph, mergeRootVertices = true) {
|
|
512
|
+
this.dropQualifications();
|
|
459
513
|
// merge root ids
|
|
460
514
|
if (mergeRootVertices) {
|
|
461
515
|
for (const root of otherGraph.rootVertices) {
|
|
@@ -471,6 +525,7 @@ class DataflowGraph {
|
|
|
471
525
|
}
|
|
472
526
|
}
|
|
473
527
|
mergeEdges(otherGraph) {
|
|
528
|
+
this.dropQualifications();
|
|
474
529
|
this.incomingIndex = undefined;
|
|
475
530
|
for (const [id, edges] of otherGraph.edgeInformation.entries()) {
|
|
476
531
|
let existing = this.edgeInformation.get(id);
|
|
@@ -497,6 +552,7 @@ class DataflowGraph {
|
|
|
497
552
|
* @param sourceIds - The id of the source vertex of the def, if available
|
|
498
553
|
*/
|
|
499
554
|
setDefinitionOfVertex(reference, sourceIds) {
|
|
555
|
+
this.dropQualifications();
|
|
500
556
|
const vertex = this.getVertex(reference.nodeId);
|
|
501
557
|
(0, assert_1.guard)(vertex !== undefined, () => `node must be defined for ${JSON.stringify(reference)} to set reference`);
|
|
502
558
|
if (vertex_2.FunctionDefinitionVertex.is(vertex) || vertex_2.VariableDefinitionVertex.is(vertex)) {
|
|
@@ -529,6 +585,7 @@ class DataflowGraph {
|
|
|
529
585
|
* @param info - The information about the new function call node
|
|
530
586
|
*/
|
|
531
587
|
updateToFunctionCall(info) {
|
|
588
|
+
this.dropQualifications();
|
|
532
589
|
const infoId = info.id;
|
|
533
590
|
const vertex = this.getVertex(infoId);
|
|
534
591
|
(0, assert_1.guard)(vertex !== undefined && (vertex_2.UseVertex.is(vertex) || vertex_2.ValueVertex.is(vertex)), () => `node must be a use or value node for ${JSON.stringify(info.id)} to update it to a function call but is ${vertex?.tag}`);
|
package/dataflow/info.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { REnvironmentInformation } from './environments/environment';
|
|
|
5
5
|
import { DataflowGraph } from './graph/graph';
|
|
6
6
|
import type { GenericDifferenceInformation, WriteableDifferenceReport } from '../util/diff';
|
|
7
7
|
import type { HookInformation } from './hooks';
|
|
8
|
+
import type { AstIdMap } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
9
|
/**
|
|
9
10
|
* A control dependency links a vertex to the control flow element which
|
|
10
11
|
* may have an influence on its execution.
|
|
@@ -24,6 +25,30 @@ export interface ControlDependency {
|
|
|
24
25
|
*/
|
|
25
26
|
readonly file?: string;
|
|
26
27
|
}
|
|
28
|
+
/** Whether the two control dependencies trigger on the same condition and branch. */
|
|
29
|
+
declare function sameControlDependency(a: ControlDependency, b: ControlDependency): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Utility functions to work with {@link ControlDependency|control dependencies}.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ControlDependency: {
|
|
34
|
+
readonly name: "ControlDependency";
|
|
35
|
+
/** Whether the two trigger on the same condition and branch. */
|
|
36
|
+
readonly same: typeof sameControlDependency;
|
|
37
|
+
/** @see {@link appendCds} */
|
|
38
|
+
readonly append: typeof appendCds;
|
|
39
|
+
/** @see {@link withCds} */
|
|
40
|
+
readonly with: typeof withCds;
|
|
41
|
+
/** @see {@link negateControlDependency} */
|
|
42
|
+
readonly negate: typeof negateControlDependency;
|
|
43
|
+
/** @see {@link happensInEveryBranch} */
|
|
44
|
+
readonly happensInEveryBranch: typeof happensInEveryBranch;
|
|
45
|
+
/** @see {@link happensInEveryBranchSet} */
|
|
46
|
+
readonly happensInEveryBranchSet: typeof happensInEveryBranchSet;
|
|
47
|
+
/** Whether the dependency stems from a loop, so what it guards may happen more than once. */
|
|
48
|
+
readonly isIterated: (this: void, cd: ControlDependency, idMap: AstIdMap | undefined) => boolean;
|
|
49
|
+
/** The dependencies of `a` that `b` is not subject to as well. */
|
|
50
|
+
readonly minus: (this: void, a: readonly ControlDependency[], b: readonly ControlDependency[]) => ControlDependency[];
|
|
51
|
+
};
|
|
27
52
|
/** Appends the given control dependencies to `target`, skipping the ones that are already in there. */
|
|
28
53
|
export declare function appendCds(target: ControlDependency[], toAdd: readonly ControlDependency[] | undefined): void;
|
|
29
54
|
/** A copy of `base` with `toAdd` appended, skipping the control dependencies that are already in there. */
|
|
@@ -201,3 +226,4 @@ export declare function diffControlDependency<Report extends WriteableDifference
|
|
|
201
226
|
* Calculates the difference between two lists of control dependencies.
|
|
202
227
|
*/
|
|
203
228
|
export declare function diffControlDependencies<Report extends WriteableDifferenceReport>(a: ControlDependency[] | undefined, b: ControlDependency[] | undefined, info: GenericDifferenceInformation<Report>): void;
|
|
229
|
+
export {};
|