@eagleoutice/flowr 2.8.14 → 2.9.0
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 +25 -26
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
- package/abstract-interpretation/data-frame/resolve-args.js +2 -1
- package/benchmark/slicer.d.ts +0 -16
- package/benchmark/slicer.js +0 -47
- package/benchmark/stats/print.js +0 -6
- package/benchmark/stats/stats.d.ts +0 -3
- package/benchmark/summarizer/second-phase/process.js +0 -6
- package/cli/benchmark-app.d.ts +0 -1
- package/cli/benchmark-app.js +0 -1
- package/cli/benchmark-helper-app.d.ts +0 -1
- package/cli/benchmark-helper-app.js +1 -5
- package/cli/common/options.d.ts +0 -10
- package/cli/common/options.js +0 -2
- package/cli/common/scripts-info.d.ts +0 -10
- package/cli/repl/server/connection.js +1 -1
- package/config.d.ts +0 -15
- package/config.js +0 -21
- package/control-flow/cfg-dead-code.js +0 -3
- package/control-flow/extract-cfg.js +5 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +11 -4
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-config.d.ts +1 -0
- package/dataflow/environments/built-in.d.ts +9 -3
- package/dataflow/environments/built-in.js +15 -7
- package/dataflow/environments/default-builtin-config.d.ts +10 -1
- package/dataflow/environments/default-builtin-config.js +6 -4
- package/dataflow/environments/define.d.ts +4 -11
- package/dataflow/environments/define.js +16 -96
- package/dataflow/environments/diff.js +3 -2
- package/dataflow/environments/environment.d.ts +17 -6
- package/dataflow/environments/environment.js +69 -18
- package/dataflow/environments/identifier.d.ts +92 -6
- package/dataflow/environments/identifier.js +159 -1
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.d.ts +4 -4
- package/dataflow/environments/resolve-by-name.js +24 -8
- package/dataflow/eval/resolve/resolve.d.ts +10 -6
- package/dataflow/eval/resolve/resolve.js +12 -7
- package/dataflow/extractor.js +6 -3
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +23 -6
- package/dataflow/fn/higher-order-function.js +7 -7
- package/dataflow/graph/call-graph.d.ts +13 -0
- package/dataflow/graph/call-graph.js +46 -20
- package/dataflow/graph/diff-dataflow-graph.js +6 -4
- package/dataflow/graph/edge.d.ts +48 -31
- package/dataflow/graph/edge.js +66 -60
- package/dataflow/graph/graph.d.ts +18 -9
- package/dataflow/graph/graph.js +29 -13
- package/dataflow/graph/quads.js +1 -1
- package/dataflow/graph/resolve-graph.js +1 -1
- package/dataflow/graph/unknown-replacement.d.ts +2 -1
- package/dataflow/graph/vertex.d.ts +2 -103
- package/dataflow/graph/vertex.js +0 -44
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +27 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +13 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +4 -16
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -1
- package/dataflow/internal/process/process-named-call.js +0 -1
- package/dataflow/internal/process/process-symbol.d.ts +3 -1
- package/dataflow/internal/process/process-symbol.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +2 -2
- package/dataflow/origin/dfg-get-origin.js +4 -4
- package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
- package/documentation/data/interface/doc-writing-code.d.ts +6 -0
- package/documentation/data/interface/doc-writing-code.js +176 -0
- package/documentation/doc-util/doc-types.d.ts +3 -1
- package/documentation/doc-util/doc-types.js +4 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-analyzer.js +17 -2
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-dataflow-graph.js +9 -8
- package/documentation/wiki-interface.js +8 -164
- package/documentation/wiki-mk/doc-context.d.ts +12 -1
- package/documentation/wiki-mk/doc-context.js +21 -4
- package/documentation/wiki-normalized-ast.js +5 -0
- package/linter/linter-rules.d.ts +6 -6
- package/linter/rules/absolute-path.js +23 -23
- package/linter/rules/dataframe-access-validation.js +2 -1
- package/linter/rules/deprecated-functions.d.ts +2 -2
- package/linter/rules/deprecated-functions.js +1 -1
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/network-functions.d.ts +2 -2
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +7 -5
- package/linter/rules/unused-definition.js +4 -4
- package/package.json +5 -5
- package/project/context/flowr-analyzer-context.d.ts +17 -1
- package/project/context/flowr-analyzer-context.js +17 -1
- package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
- package/project/context/flowr-analyzer-meta-context.js +47 -0
- package/project/flowr-analyzer.d.ts +17 -1
- package/project/flowr-analyzer.js +18 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
- package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -4
- package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +14 -4
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
- package/r-bridge/data/data.d.ts +8 -3
- package/r-bridge/data/data.js +9 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +37 -6
- package/search/search-executor/search-enrichers.d.ts +1 -2
- package/search/search-executor/search-enrichers.js +9 -7
- package/slicing/static/slice-call.js +5 -5
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/common-syntax-probability.js +3 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
- package/statistics/features/supported/used-functions/used-functions.js +3 -2
- package/util/mermaid/dfg.js +3 -3
- package/util/simple-df/dfg-ascii.js +5 -5
- package/util/version.js +1 -1
- package/util/containers.d.ts +0 -66
- package/util/containers.js +0 -143
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processList = processList;
|
|
4
|
-
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
-
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
6
4
|
const known_call_handling_1 = require("../known-call-handling");
|
|
7
|
-
const config_1 = require("../../../../../../config");
|
|
8
|
-
const containers_1 = require("../../../../../../util/containers");
|
|
9
5
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
10
6
|
/**
|
|
11
7
|
* Process a list call.
|
|
@@ -16,70 +12,6 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
16
12
|
* ```
|
|
17
13
|
*/
|
|
18
14
|
function processList(name, args, rootId, data) {
|
|
19
|
-
|
|
20
|
-
if (!data.ctx.config.solver.pointerTracking) {
|
|
21
|
-
return fnCall.information;
|
|
22
|
-
}
|
|
23
|
-
const listArgs = [];
|
|
24
|
-
for (const arg of args) {
|
|
25
|
-
// Skip non named arguments
|
|
26
|
-
if (arg === r_function_call_1.EmptyArgument || arg.type !== type_1.RType.Argument || arg.value === undefined) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
let newIndex;
|
|
30
|
-
if (arg.name) {
|
|
31
|
-
// Named argument
|
|
32
|
-
newIndex = {
|
|
33
|
-
identifier: {
|
|
34
|
-
index: arg.info.index,
|
|
35
|
-
lexeme: arg.name.content
|
|
36
|
-
},
|
|
37
|
-
nodeId: arg.info.id,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Unnamed argument
|
|
42
|
-
newIndex = {
|
|
43
|
-
identifier: {
|
|
44
|
-
index: arg.info.index,
|
|
45
|
-
},
|
|
46
|
-
nodeId: arg.value.info.id,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
// Check whether argument value can be resolved
|
|
50
|
-
if (arg.value.type === type_1.RType.Symbol) {
|
|
51
|
-
const indicesCollection = (0, containers_1.resolveIndicesByName)(arg.value.lexeme, data.environment);
|
|
52
|
-
if (indicesCollection) {
|
|
53
|
-
newIndex = {
|
|
54
|
-
...newIndex,
|
|
55
|
-
subIndices: indicesCollection,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Check whether argument is nested container
|
|
61
|
-
const indicesCollection = fnCall.information.graph.getVertex(arg.value.info.id)?.indicesCollection;
|
|
62
|
-
if (indicesCollection) {
|
|
63
|
-
newIndex = {
|
|
64
|
-
...newIndex,
|
|
65
|
-
subIndices: indicesCollection,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
listArgs.push(newIndex);
|
|
70
|
-
}
|
|
71
|
-
if ((0, config_1.isOverPointerAnalysisThreshold)(data.ctx.config, listArgs.length)) {
|
|
72
|
-
return fnCall.information;
|
|
73
|
-
}
|
|
74
|
-
const indices = {
|
|
75
|
-
indices: listArgs,
|
|
76
|
-
isContainer: true,
|
|
77
|
-
};
|
|
78
|
-
// Add resolved indices to vertex
|
|
79
|
-
const vertex = fnCall.information.graph.getVertex(rootId);
|
|
80
|
-
if (vertex) {
|
|
81
|
-
vertex.indicesCollection = [indices];
|
|
82
|
-
}
|
|
83
|
-
return fnCall.information;
|
|
15
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_1.BuiltInProcName.List }).information;
|
|
84
16
|
}
|
|
85
17
|
//# sourceMappingURL=built-in-list.js.map
|
|
@@ -16,13 +16,13 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
16
16
|
function processPipe(name, args, rootId, data) {
|
|
17
17
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_1.BuiltInProcName.Pipe });
|
|
18
18
|
if (args.length !== 2) {
|
|
19
|
-
logger_1.dataflowLogger.warn(`Pipe ${name.content} has something else than 2 arguments, skipping`);
|
|
19
|
+
logger_1.dataflowLogger.warn(`Pipe ${identifier_1.Identifier.toString(name.content)} has something else than 2 arguments, skipping`);
|
|
20
20
|
return information;
|
|
21
21
|
}
|
|
22
22
|
const [lhs, rhs] = args.map(e => (0, unpack_argument_1.unpackNonameArg)(e));
|
|
23
23
|
(0, assert_1.guard)(lhs !== undefined && rhs !== undefined, () => `lhs and rhs must be present, but ${JSON.stringify(lhs)} and ${JSON.stringify(rhs)} were found instead.`);
|
|
24
24
|
if (rhs.type === type_1.RType.FunctionCall) {
|
|
25
|
-
const functionCallNode = information.graph.getVertex(rhs.info.id
|
|
25
|
+
const functionCallNode = information.graph.getVertex(rhs.info.id);
|
|
26
26
|
(0, assert_1.guard)(functionCallNode?.tag === vertex_1.VertexType.FunctionCall, () => `Expected function call node with id ${rhs.info.id} to be a function call node, but got ${functionCallNode?.tag} instead.`);
|
|
27
27
|
// make the lhs an argument node:
|
|
28
28
|
const argId = lhs.info.id;
|
|
@@ -23,7 +23,7 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
23
23
|
else if (processedArg) {
|
|
24
24
|
information.graph.addEdge(rootId, processedArg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
25
25
|
/* nse actually affects _everything_ within that argument! */
|
|
26
|
-
for (const [vtx
|
|
26
|
+
for (const [vtx] of processedArg.graph.vertices(true)) {
|
|
27
27
|
information.graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
/**
|
|
8
|
+
* Processes a built-in 'Recall' function call, linking
|
|
9
|
+
* the recall to the enveloping function closure.
|
|
10
|
+
*/
|
|
11
|
+
export declare function processRecall<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processRecall = processRecall;
|
|
4
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
5
|
+
const built_in_1 = require("../../../../../environments/built-in");
|
|
6
|
+
const log_1 = require("../../../../../../util/log");
|
|
7
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
8
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
9
|
+
const unnamed_call_handling_1 = require("../unnamed-call-handling");
|
|
10
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
11
|
+
/**
|
|
12
|
+
* Processes a built-in 'Recall' function call, linking
|
|
13
|
+
* the recall to the enveloping function closure.
|
|
14
|
+
*/
|
|
15
|
+
function processRecall(name, args, rootId, data) {
|
|
16
|
+
const { information } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
17
|
+
name,
|
|
18
|
+
args,
|
|
19
|
+
rootId,
|
|
20
|
+
data,
|
|
21
|
+
origin: built_in_1.BuiltInProcName.Recall
|
|
22
|
+
});
|
|
23
|
+
let cur = data.environment.current;
|
|
24
|
+
let closure;
|
|
25
|
+
while (cur) {
|
|
26
|
+
if (cur.closure) {
|
|
27
|
+
closure = cur.closure;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
cur = cur.parent;
|
|
31
|
+
}
|
|
32
|
+
if (closure) {
|
|
33
|
+
information.graph.addEdge(rootId, closure, edge_1.EdgeType.Calls);
|
|
34
|
+
// also kill the name of the recall function
|
|
35
|
+
const r = information.graph.getVertex(rootId);
|
|
36
|
+
if ((0, vertex_1.isFunctionCallVertex)(r)) {
|
|
37
|
+
r.name = unnamed_call_handling_1.UnnamedFunctionCallPrefix + rootId + '-' + identifier_1.Identifier.toString(r.name);
|
|
38
|
+
r.environment = information.environment;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
log_1.log.warn('No enclosing function closure found for recall at node', rootId);
|
|
43
|
+
}
|
|
44
|
+
return information;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=built-in-recall.js.map
|
|
@@ -9,6 +9,7 @@ const unpack_argument_1 = require("../argument/unpack-argument");
|
|
|
9
9
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
10
|
const logger_1 = require("../../../../../logger");
|
|
11
11
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
12
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
12
13
|
/**
|
|
13
14
|
* Process a built-in repeat loop function call like `repeat { ... }`.
|
|
14
15
|
* @param name - The name of the function being called.
|
|
@@ -19,7 +20,7 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
19
20
|
*/
|
|
20
21
|
function processRepeatLoop(name, args, rootId, data) {
|
|
21
22
|
if (args.length !== 1 || args[0] === r_function_call_1.EmptyArgument) {
|
|
22
|
-
logger_1.dataflowLogger.warn(`Repeat-Loop ${name.content} does not have 1 argument, skipping`);
|
|
23
|
+
logger_1.dataflowLogger.warn(`Repeat-Loop ${identifier_1.Identifier.toString(name.content)} does not have 1 argument, skipping`);
|
|
23
24
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
24
25
|
}
|
|
25
26
|
const unpacked = (0, unpack_argument_1.unpackNonameArg)(args[0]);
|
|
@@ -39,7 +40,7 @@ function processRepeatLoop(name, args, rootId, data) {
|
|
|
39
40
|
origin: built_in_1.BuiltInProcName.RepeatLoop
|
|
40
41
|
});
|
|
41
42
|
const body = processedArguments[0];
|
|
42
|
-
(0, assert_1.guard)(body !== undefined, () => `Repeat-Loop ${name.content} has no body, impossible!`);
|
|
43
|
+
(0, assert_1.guard)(body !== undefined, () => `Repeat-Loop ${identifier_1.Identifier.toString(name.content)} has no body, impossible!`);
|
|
43
44
|
(0, linker_1.linkCircularRedefinitionsWithinALoop)(information.graph, (0, linker_1.produceNameSharedIdMap)((0, linker_1.findNonLocalReads)(information.graph, [])), body.out);
|
|
44
45
|
(0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences));
|
|
45
46
|
information.exitPoints = (0, info_1.filterOutLoopExitPoints)(information.exitPoints);
|
|
@@ -5,7 +5,6 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import { type RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
7
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
|
-
import { type ContainerIndicesCollection } from '../../../../../graph/vertex';
|
|
9
8
|
/**
|
|
10
9
|
* Process a replacement function call like `<-`, `[[<-`, `$<-`, etc.
|
|
11
10
|
* These are automatically created when doing assignments like `x[y] <- value` or in general `fun(x) <- value` will call `fun<- (x, value)`.
|
|
@@ -16,6 +15,5 @@ args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeI
|
|
|
16
15
|
makeMaybe?: boolean;
|
|
17
16
|
assignmentOperator?: '<-' | '<<-';
|
|
18
17
|
readIndices?: boolean;
|
|
19
|
-
activeIndices?: ContainerIndicesCollection;
|
|
20
18
|
assignRootId?: NodeId;
|
|
21
19
|
} & ForceArguments): DataflowInformation;
|
|
@@ -10,8 +10,6 @@ const logger_1 = require("../../../../../logger");
|
|
|
10
10
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
11
11
|
const graph_1 = require("../../../../../graph/graph");
|
|
12
12
|
const edge_1 = require("../../../../../graph/edge");
|
|
13
|
-
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
14
|
-
const containers_1 = require("../../../../../../util/containers");
|
|
15
13
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
16
14
|
const built_in_access_1 = require("./built-in-access");
|
|
17
15
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
@@ -25,20 +23,15 @@ function processReplacementFunction(name,
|
|
|
25
23
|
/** The last one has to be the value */
|
|
26
24
|
args, rootId, data, config) {
|
|
27
25
|
if (args.length < 2) {
|
|
28
|
-
logger_1.dataflowLogger.warn(`Replacement ${name.content} has less than 2 arguments, skipping`);
|
|
26
|
+
logger_1.dataflowLogger.warn(`Replacement ${identifier_1.Identifier.getName(name.content)} has less than 2 arguments, skipping`);
|
|
29
27
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
30
28
|
}
|
|
31
29
|
/* we only get here if <-, <<-, ... or whatever is part of the replacement is not overwritten */
|
|
32
|
-
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Replacement ${name.content} with ${JSON.stringify(args)}, processing`);
|
|
33
|
-
let indices = config.activeIndices;
|
|
34
|
-
if (data.ctx.config.solver.pointerTracking) {
|
|
35
|
-
indices ??= constructAccessedIndices(name.content, args);
|
|
36
|
-
}
|
|
30
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Replacement ${identifier_1.Identifier.getName(name.content)} with ${JSON.stringify(args)}, processing`);
|
|
37
31
|
/* we assign the first argument by the last for now and maybe mark as maybe!, we can keep the symbol as we now know we have an assignment */
|
|
38
32
|
let res = built_in_1.BuiltInProcessorMapper[built_in_1.BuiltInProcName.Assignment](name, [args[0], args.at(-1)], rootId, data, {
|
|
39
33
|
superAssignment: config.assignmentOperator === '<<-',
|
|
40
|
-
makeMaybe:
|
|
41
|
-
indicesCollection: indices,
|
|
34
|
+
makeMaybe: config.makeMaybe,
|
|
42
35
|
canBeReplacement: true
|
|
43
36
|
});
|
|
44
37
|
const createdVert = res.graph.getVertex(rootId);
|
|
@@ -86,73 +79,19 @@ args, rootId, data, config) {
|
|
|
86
79
|
}
|
|
87
80
|
}
|
|
88
81
|
const fa = (0, unpack_argument_1.unpackNonameArg)(args[0]);
|
|
89
|
-
if (
|
|
82
|
+
if (fa) {
|
|
90
83
|
res = {
|
|
91
84
|
...res,
|
|
92
85
|
in: [...res.in, { name: fa.lexeme, type: identifier_1.ReferenceType.Variable, nodeId: fa.info.id, cds: data.cds }]
|
|
93
86
|
};
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
* Example:
|
|
101
|
-
* ```r
|
|
102
|
-
* a$b <- 1
|
|
103
|
-
* # results in index with lexeme b as identifier
|
|
104
|
-
*
|
|
105
|
-
* a[[1]]$b
|
|
106
|
-
* # results in index with index 1 as identifier with a sub-index with lexeme b as identifier
|
|
107
|
-
* ```
|
|
108
|
-
* @param operation - Operation of replacement function e.g. '$\<-', '[\<-', '[[\<-'
|
|
109
|
-
* @param args - Arguments of the replacement function
|
|
110
|
-
* @returns Accessed indices construct
|
|
111
|
-
*/
|
|
112
|
-
function constructAccessedIndices(operation, args) {
|
|
113
|
-
const { accessedArg, accessArg } = (0, containers_1.getAccessOperands)(args);
|
|
114
|
-
if (accessedArg === undefined || accessArg?.value === undefined || !isSupportedOperation(operation, accessArg.value)) {
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
const constructIdentifier = getIdentifierBuilder(operation);
|
|
118
|
-
const leafIndex = {
|
|
119
|
-
identifier: constructIdentifier(accessArg),
|
|
120
|
-
nodeId: accessedArg.info.parent ?? ''
|
|
121
|
-
};
|
|
122
|
-
const accessIndices = {
|
|
123
|
-
indices: [leafIndex],
|
|
124
|
-
isContainer: false
|
|
125
|
-
};
|
|
126
|
-
// Check for nested access
|
|
127
|
-
let indicesCollection = undefined;
|
|
128
|
-
if (accessedArg.value?.type === type_1.RType.Access) {
|
|
129
|
-
indicesCollection = (0, containers_1.constructNestedAccess)(accessedArg.value, accessIndices, constructIdentifier);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
// use access node as reference to get complete line in slice
|
|
133
|
-
indicesCollection = [accessIndices];
|
|
88
|
+
// dispatches actually as S3:
|
|
89
|
+
const fns = res.in.filter(i => i.nodeId === rootId);
|
|
90
|
+
for (const fn of fns) {
|
|
91
|
+
fn.type = identifier_1.ReferenceType.S3MethodPrefix;
|
|
134
92
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const isNameBasedAccess = (operation === '$<-' || operation === '@<-') && value.type === type_1.RType.Symbol;
|
|
139
|
-
const isNumericalIndexBasedAccess = (operation === '[[<-' || operation === '[<-') && value.type === type_1.RType.Number;
|
|
140
|
-
return isNameBasedAccess || isNumericalIndexBasedAccess;
|
|
141
|
-
}
|
|
142
|
-
function getIdentifierBuilder(operation) {
|
|
143
|
-
if (operation === '$<-' || operation == '@<-') {
|
|
144
|
-
return (arg) => {
|
|
145
|
-
return {
|
|
146
|
-
index: undefined,
|
|
147
|
-
lexeme: arg.lexeme,
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
// [[<- and [<-
|
|
152
|
-
return (arg) => {
|
|
153
|
-
return {
|
|
154
|
-
index: Number(arg.lexeme),
|
|
155
|
-
};
|
|
156
|
-
};
|
|
93
|
+
// link the built-in replacement op
|
|
94
|
+
res.graph.addEdge(rootId, (0, built_in_1.builtInId)(identifier_1.Identifier.getName(name.content)), edge_1.EdgeType.Calls | edge_1.EdgeType.Reads);
|
|
95
|
+
return res;
|
|
157
96
|
}
|
|
158
97
|
//# sourceMappingURL=built-in-replacement.js.map
|
|
@@ -65,8 +65,7 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
65
65
|
info: generic.info,
|
|
66
66
|
content: accessedIdentifiers[0],
|
|
67
67
|
lexeme: accessedIdentifiers[0],
|
|
68
|
-
location: generic.location ?? (0, range_1.invalidRange)()
|
|
69
|
-
namespace: undefined
|
|
68
|
+
location: generic.location ?? (0, range_1.invalidRange)()
|
|
70
69
|
};
|
|
71
70
|
(0, common_1.patchFunctionCall)({
|
|
72
71
|
nextGraph: dfGeneric.graph,
|
|
@@ -5,6 +5,7 @@ const known_call_handling_1 = require("../known-call-handling");
|
|
|
5
5
|
const logger_1 = require("../../../../../logger");
|
|
6
6
|
const edge_1 = require("../../../../../graph/edge");
|
|
7
7
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
8
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
8
9
|
/**
|
|
9
10
|
* Process a special built-in binary operator, possibly lazily.
|
|
10
11
|
* For example, the logical AND `&&` and OR `||` operators only evaluate their right-hand side if necessary.
|
|
@@ -15,7 +16,7 @@ function processSpecialBinOp(name, args, rootId, data, config) {
|
|
|
15
16
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_1.BuiltInProcName.SpecialBinOp }).information;
|
|
16
17
|
}
|
|
17
18
|
else if (args.length != 2) {
|
|
18
|
-
logger_1.dataflowLogger.warn(`Logical bin-op ${name.content} has something else than 2 arguments, skipping`);
|
|
19
|
+
logger_1.dataflowLogger.warn(`Logical bin-op ${identifier_1.Identifier.toString(name.content)} has something else than 2 arguments, skipping`);
|
|
19
20
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'default' }).information;
|
|
20
21
|
}
|
|
21
22
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs,
|
|
@@ -10,6 +10,7 @@ const general_1 = require("../../../../../eval/values/general");
|
|
|
10
10
|
const assert_1 = require("../../../../../../util/assert");
|
|
11
11
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
12
12
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
13
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
14
|
/**
|
|
14
15
|
* Processes a built-in 'stopifnot' function call.
|
|
15
16
|
* This is special in that it may take a number of boolean expressions either via `...` or
|
|
@@ -27,7 +28,7 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
27
28
|
function processStopIfNot(name, args, rootId, data) {
|
|
28
29
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_1.BuiltInProcName.StopIfNot }).information;
|
|
29
30
|
if (args.length === 0) {
|
|
30
|
-
logger_1.dataflowLogger.warn(`stopifnot (${name.content}) has no argument, assuming trivially true and skipping`);
|
|
31
|
+
logger_1.dataflowLogger.warn(`stopifnot (${identifier_1.Identifier.toString(name.content)}) has no argument, assuming trivially true and skipping`);
|
|
31
32
|
return res;
|
|
32
33
|
}
|
|
33
34
|
// R only allows ... or exprs or exprObject, not all, but we over-approximate and collect all, given that they are after '...'
|
|
@@ -51,7 +52,7 @@ function processStopIfNot(name, args, rootId, data) {
|
|
|
51
52
|
const localVal = (0, alias_tracking_1.resolveIdToValue)(localArg?.value?.info.id, resolveArgs);
|
|
52
53
|
const alwaysTrue = (0, general_1.valueSetGuard)(localVal)?.elements.every(d => d.type === 'logical' && d.value === true) ?? false;
|
|
53
54
|
if (!alwaysTrue) {
|
|
54
|
-
logger_1.dataflowLogger.warn(`stopifnot (${name.content}) with non-true 'local' argument is not yet supported, over-approximate`);
|
|
55
|
+
logger_1.dataflowLogger.warn(`stopifnot (${identifier_1.Identifier.toString(name.content)}) with non-true 'local' argument is not yet supported, over-approximate`);
|
|
55
56
|
const cds = (data.cds ?? []).concat(Array.from(ids).map(r => ({
|
|
56
57
|
id: r,
|
|
57
58
|
when: false
|
|
@@ -89,7 +90,7 @@ function processStopIfNot(name, args, rootId, data) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
if (cds.length === 0) {
|
|
92
|
-
logger_1.dataflowLogger.warn(`stopifnot (${name.content}) has no unknown expressions to evaluate, assuming trivially true and skipping`);
|
|
93
|
+
logger_1.dataflowLogger.warn(`stopifnot (${identifier_1.Identifier.toString(name.content)}) has no unknown expressions to evaluate, assuming trivially true and skipping`);
|
|
93
94
|
return res;
|
|
94
95
|
}
|
|
95
96
|
res.exitPoints.push({
|
|
@@ -14,6 +14,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
14
14
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
15
15
|
const unnamed_call_handling_1 = require("../unnamed-call-handling");
|
|
16
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
|
+
const identifier_2 = require("../../../../../environments/identifier");
|
|
17
18
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
18
19
|
const log_1 = require("../../../../../../util/log");
|
|
19
20
|
function getArgsOfName(argMaps, name) {
|
|
@@ -25,7 +26,7 @@ function getArgsOfName(argMaps, name) {
|
|
|
25
26
|
function processTryCatch(name, args, rootId, data, config) {
|
|
26
27
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args: args.map(unpack_argument_1.tryUnpackNoNameArg), rootId, data, origin: built_in_1.BuiltInProcName.Try, forceArgs: 'all' });
|
|
27
28
|
if (args.length < 1 || args[0] === r_function_call_1.EmptyArgument) {
|
|
28
|
-
logger_1.dataflowLogger.warn(`TryCatch Handler ${name.content} does not have 1 argument, skipping`);
|
|
29
|
+
logger_1.dataflowLogger.warn(`TryCatch Handler ${identifier_1.Identifier.toString(name.content)} does not have 1 argument, skipping`);
|
|
29
30
|
return res.information;
|
|
30
31
|
}
|
|
31
32
|
// artificial ids :)
|
|
@@ -135,7 +136,7 @@ function promoteCallToFunction(call, arg, info, data) {
|
|
|
135
136
|
const rid = ref.nodeId;
|
|
136
137
|
info.graph.addEdge(ingoing.nodeId, rid, edge_1.EdgeType.Reads);
|
|
137
138
|
info.graph.addEdge(call, rid, edge_1.EdgeType.Reads); // because the def. is the anonymous call
|
|
138
|
-
if (!(0,
|
|
139
|
+
if (!(0, identifier_2.isReferenceType)(ref.type, identifier_2.ReferenceType.BuiltInConstant | identifier_2.ReferenceType.BuiltInFunction)) {
|
|
139
140
|
allBuiltIn = false;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processVector = processVector;
|
|
4
|
-
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
-
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
6
4
|
const known_call_handling_1 = require("../known-call-handling");
|
|
7
|
-
const config_1 = require("../../../../../../config");
|
|
8
|
-
const containers_1 = require("../../../../../../util/containers");
|
|
9
5
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
10
6
|
/**
|
|
11
7
|
* Process a vector call.
|
|
@@ -16,61 +12,6 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
16
12
|
* ```
|
|
17
13
|
*/
|
|
18
14
|
function processVector(name, args, rootId, data) {
|
|
19
|
-
|
|
20
|
-
if (!data.ctx.config.solver.pointerTracking) {
|
|
21
|
-
return fnCall.information;
|
|
22
|
-
}
|
|
23
|
-
let vectorArgs = [];
|
|
24
|
-
let argIndex = 1;
|
|
25
|
-
for (const arg of args) {
|
|
26
|
-
// Skip invalid argument types
|
|
27
|
-
if (arg === r_function_call_1.EmptyArgument || arg.type !== type_1.RType.Argument || arg.value === undefined) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (isPrimitive(arg.value.type)) {
|
|
31
|
-
vectorArgs.push({
|
|
32
|
-
identifier: { index: argIndex++ },
|
|
33
|
-
nodeId: arg.value.info.id,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// Check whether argument value can be resolved
|
|
38
|
-
let indicesCollection;
|
|
39
|
-
if (arg.value.type === type_1.RType.Symbol) {
|
|
40
|
-
indicesCollection = (0, containers_1.resolveIndicesByName)(arg.value.lexeme, data.environment);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
// Check whether argument is nested container
|
|
44
|
-
indicesCollection = fnCall.information.graph.getVertex(arg.value.info.id)?.indicesCollection;
|
|
45
|
-
}
|
|
46
|
-
const flattenedIndices = indicesCollection?.flatMap(indices => indices.indices)
|
|
47
|
-
.map(index => {
|
|
48
|
-
return {
|
|
49
|
-
identifier: { index: argIndex++ },
|
|
50
|
-
nodeId: index.nodeId,
|
|
51
|
-
};
|
|
52
|
-
}) ?? [];
|
|
53
|
-
vectorArgs = vectorArgs.concat(flattenedIndices);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if ((0, config_1.isOverPointerAnalysisThreshold)(data.ctx.config, vectorArgs.length)) {
|
|
57
|
-
return fnCall.information;
|
|
58
|
-
}
|
|
59
|
-
const indices = {
|
|
60
|
-
indices: vectorArgs,
|
|
61
|
-
isContainer: true,
|
|
62
|
-
};
|
|
63
|
-
// Add resolved indices to vertex
|
|
64
|
-
const vertex = fnCall.information.graph.getVertex(rootId);
|
|
65
|
-
if (vertex) {
|
|
66
|
-
vertex.indicesCollection = [indices];
|
|
67
|
-
}
|
|
68
|
-
return fnCall.information;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks whether the passed type is primitive i.e. number, logical or string.
|
|
72
|
-
*/
|
|
73
|
-
function isPrimitive(type) {
|
|
74
|
-
return type === type_1.RType.Number || type === type_1.RType.Logical || type === type_1.RType.String;
|
|
15
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_1.BuiltInProcName.Vector }).information;
|
|
75
16
|
}
|
|
76
17
|
//# sourceMappingURL=built-in-vector.js.map
|
|
@@ -19,12 +19,12 @@ const built_in_1 = require("../../../../../environments/built-in");
|
|
|
19
19
|
*/
|
|
20
20
|
function processWhileLoop(name, args, rootId, data) {
|
|
21
21
|
if (args.length !== 2 || args[1] === r_function_call_1.EmptyArgument) {
|
|
22
|
-
logger_1.dataflowLogger.warn(`While-Loop ${name.content} does not have 2 arguments, skipping`);
|
|
22
|
+
logger_1.dataflowLogger.warn(`While-Loop ${identifier_1.Identifier.toString(name.content)} does not have 2 arguments, skipping`);
|
|
23
23
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
24
24
|
}
|
|
25
25
|
const unpackedArgs = args.map(e => (0, unpack_argument_1.unpackNonameArg)(e));
|
|
26
26
|
if (unpackedArgs.some(assert_1.isUndefined)) {
|
|
27
|
-
logger_1.dataflowLogger.warn(`While-Loop ${name.content} has empty arguments in ${JSON.stringify(args)}, skipping`);
|
|
27
|
+
logger_1.dataflowLogger.warn(`While-Loop ${identifier_1.Identifier.toString(name.content)} has empty arguments in ${JSON.stringify(args)}, skipping`);
|
|
28
28
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
29
29
|
}
|
|
30
30
|
// we should defer this to the abstract interpretation
|
|
@@ -63,7 +63,7 @@ function processWhileLoop(name, args, rootId, data) {
|
|
|
63
63
|
hooks: condition.hooks
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
(0, assert_1.guard)(condition !== undefined && body !== undefined, () => `While-Loop ${name.content} has no condition or body, impossible!`);
|
|
66
|
+
(0, assert_1.guard)(condition !== undefined && body !== undefined, () => `While-Loop ${identifier_1.Identifier.toString(name.content)} has no condition or body, impossible!`);
|
|
67
67
|
const originalDependency = data.cds;
|
|
68
68
|
if ((0, info_1.alwaysExits)(condition)) {
|
|
69
69
|
logger_1.dataflowLogger.warn(`While-Loop ${rootId} forces exit in condition, skipping rest`);
|
|
@@ -55,6 +55,8 @@ export interface PatchFunctionCallInput<OtherInfo> {
|
|
|
55
55
|
readonly link?: DataflowGraphVertexAstLink;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* Patches a function call vertex into the given dataflow graph.
|
|
59
|
+
* This is mostly useful for built-in processors that have custom argument processing.
|
|
60
|
+
* Otherwise, rely on {@link processKnownFunctionCall} instead.
|
|
59
61
|
*/
|
|
60
62
|
export declare function patchFunctionCall<OtherInfo>({ nextGraph, rootId, name, data, argumentProcessResult, origin, link }: PatchFunctionCallInput<OtherInfo>): void;
|
|
@@ -114,12 +114,7 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
114
114
|
if ((0, info_1.happensInEveryBranch)(resolved.cds) && !(0, identifier_1.isReferenceType)(resolved.type, identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.BuiltInConstant)) {
|
|
115
115
|
assumeItMayHaveAHigherTarget = false;
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
const resolvedInGraphDef = resolved;
|
|
119
|
-
const isContainer = checkForContainer(resolvedInGraphDef?.indicesCollection);
|
|
120
|
-
if (isContainer !== false) {
|
|
121
|
-
finalGraph.addEdge(ingoing.nodeId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
122
|
-
}
|
|
117
|
+
finalGraph.addEdge(ingoing.nodeId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
123
118
|
}
|
|
124
119
|
if (assumeItMayHaveAHigherTarget) {
|
|
125
120
|
remainingReadInArgs.push(ingoing);
|
|
@@ -138,7 +133,9 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
138
133
|
return { finalEnv, callArgs, remainingReadInArgs, processedArguments };
|
|
139
134
|
}
|
|
140
135
|
/**
|
|
141
|
-
*
|
|
136
|
+
* Patches a function call vertex into the given dataflow graph.
|
|
137
|
+
* This is mostly useful for built-in processors that have custom argument processing.
|
|
138
|
+
* Otherwise, rely on {@link processKnownFunctionCall} instead.
|
|
142
139
|
*/
|
|
143
140
|
function patchFunctionCall({ nextGraph, rootId, name, data, argumentProcessResult, origin, link }) {
|
|
144
141
|
nextGraph.addVertex({
|
|
@@ -159,13 +156,4 @@ function patchFunctionCall({ nextGraph, rootId, name, data, argumentProcessResul
|
|
|
159
156
|
}
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Check whether passed {@link indices} are containers or whether their sub-indices are containers.
|
|
164
|
-
*/
|
|
165
|
-
function checkForContainer(indices) {
|
|
166
|
-
return indices?.every((indices) => {
|
|
167
|
-
const areSubIndicesContainers = indices.indices.every(index => 'subIndices' in index && checkForContainer(index.subIndices));
|
|
168
|
-
return indices.isContainer || areSubIndicesContainers;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
159
|
//# sourceMappingURL=common.js.map
|
|
@@ -9,11 +9,15 @@ import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
|
9
9
|
import { type IdentifierReference } from '../../../../environments/identifier';
|
|
10
10
|
import type { FunctionArgument } from '../../../../graph/graph';
|
|
11
11
|
import { DataflowGraph } from '../../../../graph/graph';
|
|
12
|
-
import { type
|
|
12
|
+
import { type FunctionOriginInformation } from '../../../../graph/vertex';
|
|
13
13
|
export interface ProcessKnownFunctionCallInput<OtherInfo> extends ForceArguments {
|
|
14
|
+
/** The name of the function being called. */
|
|
14
15
|
readonly name: RSymbol<OtherInfo & ParentInformation>;
|
|
16
|
+
/** The arguments to the function call. */
|
|
15
17
|
readonly args: readonly (RNode<OtherInfo & ParentInformation> | RFunctionArgument<OtherInfo & ParentInformation>)[];
|
|
18
|
+
/** The node ID to use for the function call vertex. */
|
|
16
19
|
readonly rootId: NodeId;
|
|
20
|
+
/** The dataflow processor information at the point of the function call. */
|
|
17
21
|
readonly data: DataflowProcessorInformation<OtherInfo & ParentInformation>;
|
|
18
22
|
/** should arguments be processed from right to left? This does not affect the order recorded in the call but of the environments */
|
|
19
23
|
readonly reverseOrder?: boolean;
|
|
@@ -49,4 +53,4 @@ export declare function markNonStandardEvaluationEdges(markAsNSE: readonly numbe
|
|
|
49
53
|
* The main processor for function calls for which we know the target but need not
|
|
50
54
|
* add any specific handling.
|
|
51
55
|
*/
|
|
52
|
-
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin }: ProcessKnownFunctionCallInput<OtherInfo
|
|
56
|
+
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
|
|
@@ -32,11 +32,11 @@ function markNonStandardEvaluationEdges(markAsNSE, callArgs, finalGraph, rootId)
|
|
|
32
32
|
* The main processor for function calls for which we know the target but need not
|
|
33
33
|
* add any specific handling.
|
|
34
34
|
*/
|
|
35
|
-
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin }
|
|
35
|
+
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin }) {
|
|
36
36
|
const functionName = (0, processor_1.processDataflowFor)(name, data);
|
|
37
37
|
const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
38
38
|
const functionCallName = name.content;
|
|
39
|
-
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Processing known function call ${functionCallName} with ${args.length} arguments`);
|
|
39
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Processing known function call ${identifier_1.Identifier.toString(functionCallName)} with ${args.length} arguments`);
|
|
40
40
|
const processArgs = reverseOrder ? args.toReversed() : args;
|
|
41
41
|
const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({ functionName, args: processArgs, data, finalGraph, functionRootId: rootId, patchData, forceArgs });
|
|
42
42
|
if (markAsNSE) {
|
|
@@ -51,7 +51,6 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
|
|
|
51
51
|
onlyBuiltin: false,
|
|
52
52
|
cds: data.cds,
|
|
53
53
|
args: reverseOrder ? callArgs.toReversed() : callArgs,
|
|
54
|
-
indicesCollection: indicesCollection,
|
|
55
54
|
origin: origin === 'default' ? [built_in_1.BuiltInProcName.Function] : [origin]
|
|
56
55
|
}, data.ctx.env.makeCleanEnv());
|
|
57
56
|
if (hasUnknownSideEffect) {
|
|
@@ -2,7 +2,7 @@ import { type DataflowProcessorInformation } from '../../../../processor';
|
|
|
2
2
|
import type { DataflowInformation } from '../../../../info';
|
|
3
3
|
import type { RUnnamedFunctionCall } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
4
4
|
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
export declare const UnnamedFunctionCallPrefix = "unnamed-
|
|
5
|
+
export declare const UnnamedFunctionCallPrefix = "unnamed-fc-";
|
|
6
6
|
/**
|
|
7
7
|
* Processes an unnamed function call.
|
|
8
8
|
*/
|
|
@@ -12,7 +12,7 @@ const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
|
12
12
|
const logger_1 = require("../../../../logger");
|
|
13
13
|
const identifier_1 = require("../../../../environments/identifier");
|
|
14
14
|
const built_in_1 = require("../../../../environments/built-in");
|
|
15
|
-
exports.UnnamedFunctionCallPrefix = 'unnamed-
|
|
15
|
+
exports.UnnamedFunctionCallPrefix = 'unnamed-fc-';
|
|
16
16
|
/**
|
|
17
17
|
* Processes an unnamed function call.
|
|
18
18
|
*/
|