@eagleoutice/flowr 2.13.14 → 2.13.16
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 -31
- package/abstract-interpretation/data-frame/resolve-args.js +11 -12
- package/abstract-interpretation/unsupported-functions.d.ts +1 -0
- package/abstract-interpretation/unsupported-functions.js +1 -0
- package/benchmark/summarizer/second-phase/graph.d.ts +23 -0
- package/benchmark/summarizer/second-phase/graph.js +47 -14
- package/cli/repl/commands/repl-cfg.js +2 -42
- package/cli/repl/commands/repl-clipboard.d.ts +7 -0
- package/cli/repl/commands/repl-clipboard.js +53 -0
- package/cli/repl/commands/repl-dataflow.js +5 -70
- package/cli/repl/commands/repl-normalize.js +3 -51
- package/cli/repl/commands/repl-query.js +37 -2
- package/cli/repl/core.js +5 -2
- package/control-flow/cfg-dead-code.js +5 -29
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +2 -0
- package/control-flow/diff-cfg.js +2 -56
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +14 -0
- package/control-flow/useless-loop.js +4 -26
- package/core/steps/all/core/10-normalize.d.ts +8 -0
- package/core/steps/all/core/10-normalize.js +10 -8
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
- package/data/r-base-packages.generated.d.ts +1 -0
- package/data/r-base-packages.generated.js +5 -3
- package/dataflow/environments/built-in-config.d.ts +9 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +4 -0
- package/dataflow/environments/built-in-props.js +3 -3
- package/dataflow/environments/built-in.d.ts +4 -2
- package/dataflow/environments/built-in.js +53 -3
- package/dataflow/environments/data-masking-functions.d.ts +3 -4
- package/dataflow/environments/data-masking-functions.js +7 -8
- package/dataflow/environments/default-builtin-config.d.ts +92 -12
- package/dataflow/environments/default-builtin-config.js +86 -43
- package/dataflow/environments/environment.d.ts +5 -0
- package/dataflow/environments/environment.js +17 -12
- package/dataflow/environments/identifier.d.ts +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +4 -7
- package/dataflow/eval/resolve/node-value.d.ts +51 -0
- package/dataflow/eval/resolve/node-value.js +71 -0
- package/dataflow/eval/resolve/resolve-argument.js +10 -7
- package/dataflow/eval/resolve/resolve-operators.js +1 -2
- package/dataflow/eval/values/general.d.ts +4 -0
- package/dataflow/eval/values/general.js +14 -0
- package/dataflow/eval/values/r-value.d.ts +15 -0
- package/dataflow/eval/values/r-value.js +27 -1
- package/dataflow/extractor.js +2 -0
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +22 -4
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +1 -1
- package/dataflow/graph/df-helper.d.ts +2 -2
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +3 -55
- package/dataflow/graph/graph-helper.d.ts +1 -0
- package/dataflow/graph/graph-helper.js +1 -0
- package/dataflow/graph/graph.d.ts +5 -0
- package/dataflow/graph/graph.js +27 -0
- package/dataflow/graph/vertex.d.ts +5 -0
- package/dataflow/graph/vertex.js +5 -0
- package/dataflow/internal/linker.d.ts +23 -0
- package/dataflow/internal/linker.js +70 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/deferred.d.ts +48 -0
- package/dataflow/internal/process/functions/call/deferred.js +149 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/nse.d.ts +29 -0
- package/dataflow/internal/process/functions/call/nse.js +88 -0
- package/dataflow/internal/process/functions/call/quoted.d.ts +30 -0
- package/dataflow/internal/process/functions/call/quoted.js +191 -0
- package/documentation/doc-util/doc-types.js +15 -9
- package/documentation/wiki-dataflow-graph.js +8 -0
- package/linter/linter-format.d.ts +1 -0
- package/linter/linter-format.js +1 -0
- package/linter/rules/deprecated-functions.js +9 -3
- package/linter/rules/seeded-randomness.js +2 -3
- package/linter/rules/undefined-symbol.js +10 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
- package/project/sigdb/reader.d.ts +9 -0
- package/project/sigdb/reader.js +30 -0
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/query-function-filter.d.ts +21 -0
- package/queries/query-function-filter.js +48 -0
- package/r-bridge/data/data.d.ts +13 -3
- package/r-bridge/data/data.js +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
- package/search/flowr-search-filters.d.ts +5 -1
- package/search/flowr-search-filters.js +31 -21
- package/search/search-executor/search-enrichers.d.ts +24 -4
- package/search/search-executor/search-enrichers.js +22 -9
- package/search/search-executor/search-transformer.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -0
- package/slicing/criterion/parse.js +1 -0
- package/util/diff-graph.d.ts +13 -0
- package/util/diff-graph.js +64 -1
- package/util/files.js +9 -8
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -1
- package/util/r-version.d.ts +2 -0
- package/util/r-version.js +2 -0
- package/util/record.d.ts +1 -0
- package/util/record.js +1 -0
- package/util/version.js +1 -1
package/dataflow/graph/vertex.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
|
13
13
|
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
|
14
14
|
/** Helpers for {@link DataflowGraphVertexValue} vertices. */
|
|
15
15
|
exports.ValueVertex = {
|
|
16
|
+
name: 'ValueVertex',
|
|
16
17
|
/** Whether the given vertex is a value vertex. */
|
|
17
18
|
is(vertex) {
|
|
18
19
|
return vertex?.tag === VertexType.Value;
|
|
@@ -20,6 +21,7 @@ exports.ValueVertex = {
|
|
|
20
21
|
};
|
|
21
22
|
/** Helpers for {@link DataflowGraphVertexUse} vertices. */
|
|
22
23
|
exports.UseVertex = {
|
|
24
|
+
name: 'UseVertex',
|
|
23
25
|
/** Whether the given vertex is a use vertex. */
|
|
24
26
|
is(vertex) {
|
|
25
27
|
return vertex?.tag === VertexType.Use;
|
|
@@ -27,6 +29,7 @@ exports.UseVertex = {
|
|
|
27
29
|
};
|
|
28
30
|
/** Helpers for {@link DataflowGraphVertexFunctionCall} vertices. */
|
|
29
31
|
exports.FunctionCallVertex = {
|
|
32
|
+
name: 'FunctionCallVertex',
|
|
30
33
|
/** Whether the given vertex is a function call vertex. */
|
|
31
34
|
is(vertex) {
|
|
32
35
|
return vertex?.tag === VertexType.FunctionCall;
|
|
@@ -38,6 +41,7 @@ exports.FunctionCallVertex = {
|
|
|
38
41
|
};
|
|
39
42
|
/** Helpers for {@link DataflowGraphVertexVariableDefinition} vertices. */
|
|
40
43
|
exports.VariableDefinitionVertex = {
|
|
44
|
+
name: 'VariableDefinitionVertex',
|
|
41
45
|
/** Whether the given vertex is a variable definition vertex. */
|
|
42
46
|
is(vertex) {
|
|
43
47
|
return vertex?.tag === VertexType.VariableDefinition;
|
|
@@ -45,6 +49,7 @@ exports.VariableDefinitionVertex = {
|
|
|
45
49
|
};
|
|
46
50
|
/** Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices. */
|
|
47
51
|
exports.FunctionDefinitionVertex = {
|
|
52
|
+
name: 'FunctionDefinitionVertex',
|
|
48
53
|
/** Whether the given vertex is a function definition vertex. */
|
|
49
54
|
is(vertex) {
|
|
50
55
|
return vertex?.tag === VertexType.FunctionDefinition;
|
|
@@ -81,6 +81,20 @@ export declare function getAllFunctionCallTargets(call: NodeId, graph: DataflowG
|
|
|
81
81
|
* To know what fdefs the definition of `x` in the first line links to, you can use {@link getAllLinkedFunctionDefinitions|this function}.
|
|
82
82
|
*/
|
|
83
83
|
export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): [Set<Required<DataflowGraphVertexFunctionDefinition>>, Set<BuiltIn>];
|
|
84
|
+
/**
|
|
85
|
+
* This method links a set of read variables to definitions in an environment.
|
|
86
|
+
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
|
|
87
|
+
* @param environmentInformation - The environment information to link against
|
|
88
|
+
* @param givenInputs - The existing list of inputs that might be extended
|
|
89
|
+
* @param graph - The graph to enter the found links
|
|
90
|
+
* @param maybeForRemaining - Each input that can not be linked, will be added to `givenInputs`. If this flag is `true`, it will be marked as `maybe`.
|
|
91
|
+
* @returns the given inputs, possibly extended with the remaining inputs (those of `referencesToLinkAgainstEnvironment` that could not be linked against the environment)
|
|
92
|
+
*/
|
|
93
|
+
/**
|
|
94
|
+
* Links every name in the expression rooted at `expr` against `environment`, as if it were written there, and
|
|
95
|
+
* hands back what stays unresolved. This is how an expression that was captured elsewhere is read here.
|
|
96
|
+
*/
|
|
97
|
+
export declare function linkExpressionIn<Info>(this: void, graph: DataflowGraph, expr: NodeId, environment: REnvironmentInformation, idMap: AstIdMap<Info & ParentInformation>): readonly IdentifierReference[];
|
|
84
98
|
/**
|
|
85
99
|
* This method links a set of read variables to definitions in an environment.
|
|
86
100
|
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
|
|
@@ -110,3 +124,12 @@ export declare function linkCircularRedefinitionsWithinALoop(graph: DataflowGrap
|
|
|
110
124
|
* Reapplies the loop exit points' control dependencies to the given identifier references.
|
|
111
125
|
*/
|
|
112
126
|
export declare function reapplyLoopExitPoints(exits: readonly ExitPoint[], references: readonly IdentifierReference[], graph: DataflowGraph): void;
|
|
127
|
+
/** The open references a function definition still carries into its closure. */
|
|
128
|
+
export declare const ClosureRefs: {
|
|
129
|
+
readonly name: "ClosureRefs";
|
|
130
|
+
/**
|
|
131
|
+
* Resolves the open ingoing references of a definition called anonymously at `callId` against `environment`,
|
|
132
|
+
* links what resolves, and leaves only the references that stay open.
|
|
133
|
+
*/
|
|
134
|
+
readonly resolveOpenIngoing: (this: void, graph: DataflowGraph, callId: NodeId, definition: DataflowGraphVertexFunctionDefinition, environment: REnvironmentInformation) => void;
|
|
135
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClosureRefs = void 0;
|
|
3
4
|
exports.findNonLocalReads = findNonLocalReads;
|
|
4
5
|
exports.produceNameSharedIdMap = produceNameSharedIdMap;
|
|
5
6
|
exports.linkArgumentsOnCall = linkArgumentsOnCall;
|
|
@@ -8,17 +9,19 @@ exports.linkFunctionCallWithSingleTarget = linkFunctionCallWithSingleTarget;
|
|
|
8
9
|
exports.linkFunctionCalls = linkFunctionCalls;
|
|
9
10
|
exports.getAllFunctionCallTargets = getAllFunctionCallTargets;
|
|
10
11
|
exports.getAllLinkedFunctionDefinitions = getAllLinkedFunctionDefinitions;
|
|
12
|
+
exports.linkExpressionIn = linkExpressionIn;
|
|
11
13
|
exports.linkInputs = linkInputs;
|
|
12
14
|
exports.linkCircularRedefinitionsWithinALoop = linkCircularRedefinitionsWithinALoop;
|
|
13
15
|
exports.reapplyLoopExitPoints = reapplyLoopExitPoints;
|
|
14
16
|
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
17
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
18
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
15
19
|
const assert_1 = require("../../util/assert");
|
|
16
20
|
const log_1 = require("../../util/log");
|
|
17
21
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
18
22
|
const identifier_1 = require("../environments/identifier");
|
|
19
23
|
const graph_1 = require("../graph/graph");
|
|
20
24
|
const logger_1 = require("../logger");
|
|
21
|
-
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
22
25
|
const edge_1 = require("../graph/edge");
|
|
23
26
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
24
27
|
const vertex_1 = require("../graph/vertex");
|
|
@@ -366,6 +369,40 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
366
369
|
}
|
|
367
370
|
return [result, builtIns];
|
|
368
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* This method links a set of read variables to definitions in an environment.
|
|
374
|
+
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
|
|
375
|
+
* @param environmentInformation - The environment information to link against
|
|
376
|
+
* @param givenInputs - The existing list of inputs that might be extended
|
|
377
|
+
* @param graph - The graph to enter the found links
|
|
378
|
+
* @param maybeForRemaining - Each input that can not be linked, will be added to `givenInputs`. If this flag is `true`, it will be marked as `maybe`.
|
|
379
|
+
* @returns the given inputs, possibly extended with the remaining inputs (those of `referencesToLinkAgainstEnvironment` that could not be linked against the environment)
|
|
380
|
+
*/
|
|
381
|
+
/**
|
|
382
|
+
* Links every name in the expression rooted at `expr` against `environment`, as if it were written there, and
|
|
383
|
+
* hands back what stays unresolved. This is how an expression that was captured elsewhere is read here.
|
|
384
|
+
*/
|
|
385
|
+
function linkExpressionIn(graph, expr, environment, idMap) {
|
|
386
|
+
const node = idMap.get(expr);
|
|
387
|
+
if (node === undefined) {
|
|
388
|
+
return [];
|
|
389
|
+
}
|
|
390
|
+
const references = [];
|
|
391
|
+
const callees = new Set();
|
|
392
|
+
model_1.RNode.visitAst(node, inner => {
|
|
393
|
+
if (r_function_call_1.RFunctionCall.isNamed(inner)) {
|
|
394
|
+
callees.add(inner.functionName.info.id);
|
|
395
|
+
references.push({ nodeId: inner.functionName.info.id, name: inner.functionName.content, cds: undefined, type: identifier_1.ReferenceType.Function });
|
|
396
|
+
}
|
|
397
|
+
else if (inner.type === type_1.RType.Symbol && !callees.has(inner.info.id)) {
|
|
398
|
+
references.push({ nodeId: inner.info.id, name: inner.content, cds: undefined, type: identifier_1.ReferenceType.Variable });
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
});
|
|
402
|
+
const unresolved = [];
|
|
403
|
+
linkInputs(references, environment, unresolved, graph, false);
|
|
404
|
+
return unresolved;
|
|
405
|
+
}
|
|
369
406
|
/**
|
|
370
407
|
* This method links a set of read variables to definitions in an environment.
|
|
371
408
|
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
|
|
@@ -494,4 +531,36 @@ function reapplyLoopExitPoints(exits, references, graph) {
|
|
|
494
531
|
}
|
|
495
532
|
}
|
|
496
533
|
}
|
|
534
|
+
/** The open references a function definition still carries into its closure. */
|
|
535
|
+
exports.ClosureRefs = {
|
|
536
|
+
name: 'ClosureRefs',
|
|
537
|
+
/**
|
|
538
|
+
* Resolves the open ingoing references of a definition called anonymously at `callId` against `environment`,
|
|
539
|
+
* links what resolves, and leaves only the references that stay open.
|
|
540
|
+
*/
|
|
541
|
+
resolveOpenIngoing(graph, callId, definition, environment) {
|
|
542
|
+
const remainingIn = [];
|
|
543
|
+
for (const ingoing of definition.subflow.in) {
|
|
544
|
+
const resolved = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, environment, ingoing.type) : undefined;
|
|
545
|
+
if (resolved === undefined) {
|
|
546
|
+
remainingIn.push(ingoing);
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Found ${resolved.length} references to open ref ${ingoing.nodeId} in closure of function definition ${callId}`);
|
|
550
|
+
let allBuiltIn = true;
|
|
551
|
+
const inId = ingoing.nodeId;
|
|
552
|
+
for (const { nodeId, type } of resolved) {
|
|
553
|
+
graph.addEdge(inId, nodeId, edge_1.EdgeType.Reads);
|
|
554
|
+
graph.addEdge(callId, nodeId, edge_1.EdgeType.Reads); // because the def. is the anonymous call
|
|
555
|
+
if (!(0, identifier_1.isReferenceType)(type, identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.BuiltInFunction)) {
|
|
556
|
+
allBuiltIn = false;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (allBuiltIn) {
|
|
560
|
+
remainingIn.push(ingoing);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
definition.subflow.in = remainingIn;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
497
566
|
//# sourceMappingURL=linker.js.map
|
|
@@ -15,6 +15,7 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
15
15
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
16
16
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
17
17
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
18
|
+
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
18
19
|
function tableAssignmentProcessor(name, args, rootId, data, outInfo) {
|
|
19
20
|
outInfo.definitionRootNodes.push(rootId);
|
|
20
21
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.TableAssignment }).information;
|
|
@@ -69,7 +70,9 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
69
70
|
if (envState) {
|
|
70
71
|
const fieldNode = (0, unpack_argument_1.unpackArg)(args[1]);
|
|
71
72
|
const fieldName = fieldNode?.type === type_1.RType.String ? fieldNode.content.str : (config.treatIndicesAsString ? fieldNode?.lexeme : undefined);
|
|
72
|
-
const fieldDefs = fieldName
|
|
73
|
+
const fieldDefs = fieldName
|
|
74
|
+
? ((0, built_in_stack_env_1.stackEnvInheritsFields)(head.value) ? (0, resolve_by_name_1.resolveByName)(fieldName, envState, identifier_1.ReferenceType.Unknown) : envState.current.memory.get(fieldName))
|
|
75
|
+
: undefined;
|
|
73
76
|
for (const fd of fieldDefs ?? []) {
|
|
74
77
|
info.graph.addEdge(name.info.id, fd.nodeId, edge_1.EdgeType.Reads);
|
|
75
78
|
if (stackEnvState === undefined && fd.type === identifier_1.ReferenceType.Function) {
|
|
@@ -30,6 +30,8 @@ export interface BuiltInApplyConfiguration extends MergeableRecord {
|
|
|
30
30
|
readonly resolveInEnvironment?: 'global' | 'local';
|
|
31
31
|
/** Should the value of the function be resolved? */
|
|
32
32
|
readonly resolveValue?: boolean;
|
|
33
|
+
/** the call reaches beyond what we can see even when the callee resolves, like `rlang::exec` */
|
|
34
|
+
readonly hasUnknownSideEffects?: boolean;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Process an apply call like `vapply` or `mapply`.
|
|
@@ -10,10 +10,9 @@ const vertex_1 = require("../../../../../graph/vertex");
|
|
|
10
10
|
const edge_1 = require("../../../../../graph/edge");
|
|
11
11
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
12
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
|
-
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
14
13
|
const unnamed_call_handling_1 = require("../unnamed-call-handling");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const linker_1 = require("../../../../linker");
|
|
15
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
17
16
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
18
17
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
19
18
|
/** Resolve the function an argument stands for: a string literal, a symbol, or an inline definition; `undefined` if none. */
|
|
@@ -28,7 +27,7 @@ function resolveFunctionArgument(val, data, opts) {
|
|
|
28
27
|
return undefined;
|
|
29
28
|
}
|
|
30
29
|
const functionName = opts.resolveValue
|
|
31
|
-
?
|
|
30
|
+
? node_value_1.NodeValue.singleStringOf(val.info.id, data)
|
|
32
31
|
: val.content;
|
|
33
32
|
return functionName === undefined ? undefined : { functionId: val.info.id, functionName, anonymous: false, asString: false };
|
|
34
33
|
}
|
|
@@ -36,7 +35,7 @@ function resolveFunctionArgument(val, data, opts) {
|
|
|
36
35
|
* Process an apply call like `vapply` or `mapply`.
|
|
37
36
|
*/
|
|
38
37
|
function processApply(name, args, rootId, data, config) {
|
|
39
|
-
const { indexOfFunction = 1, nameOfFunctionArgument, unquoteFunction, resolveInEnvironment, resolveValue } = config;
|
|
38
|
+
const { indexOfFunction = 1, nameOfFunctionArgument, unquoteFunction, resolveInEnvironment, resolveValue, hasUnknownSideEffects } = config;
|
|
40
39
|
/* as the length is one-based and the argument filter mapping is zero-based, we do not have to subtract 1 */
|
|
41
40
|
const forceArgsMask = new Array(indexOfFunction).fill(false);
|
|
42
41
|
forceArgsMask.push(true);
|
|
@@ -44,6 +43,9 @@ function processApply(name, args, rootId, data, config) {
|
|
|
44
43
|
name, args, rootId, data, forceArgs: forceArgsMask, origin: built_in_proc_name_1.BuiltInProcName.Apply
|
|
45
44
|
});
|
|
46
45
|
let information = resFn.information;
|
|
46
|
+
if (hasUnknownSideEffects) {
|
|
47
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
48
|
+
}
|
|
47
49
|
const processedArguments = resFn.processedArguments;
|
|
48
50
|
let index = indexOfFunction;
|
|
49
51
|
/* search, if one of the arguments actually contains the argument name if given in the config */
|
|
@@ -132,30 +134,7 @@ function processApply(name, args, rootId, data, config) {
|
|
|
132
134
|
};
|
|
133
135
|
const dfVert = information.graph.getVertex(rootId);
|
|
134
136
|
if (dfVert && dfVert.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
135
|
-
|
|
136
|
-
const ingoingRefs = dfVert.subflow.in;
|
|
137
|
-
const remainingIn = [];
|
|
138
|
-
for (const ingoing of ingoingRefs) {
|
|
139
|
-
const resolved = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, data.environment, ingoing.type) : undefined;
|
|
140
|
-
if (resolved === undefined) {
|
|
141
|
-
remainingIn.push(ingoing);
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Found ${resolved.length} references to open ref ${ingoing.nodeId} in closure of function definition ${rootId}`);
|
|
145
|
-
let allBuiltIn = true;
|
|
146
|
-
const inId = ingoing.nodeId;
|
|
147
|
-
for (const { nodeId, type } of resolved) {
|
|
148
|
-
information.graph.addEdge(inId, nodeId, edge_1.EdgeType.Reads);
|
|
149
|
-
information.graph.addEdge(rootId, nodeId, edge_1.EdgeType.Reads); // because the def. is the anonymous call
|
|
150
|
-
if (!(0, identifier_1.isReferenceType)(type, identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.BuiltInFunction)) {
|
|
151
|
-
allBuiltIn = false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (allBuiltIn) {
|
|
155
|
-
remainingIn.push(ingoing);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
dfVert.subflow.in = remainingIn;
|
|
137
|
+
linker_1.ClosureRefs.resolveOpenIngoing(information.graph, rootId, dfVert, data.environment);
|
|
159
138
|
}
|
|
160
139
|
}
|
|
161
140
|
else {
|
|
@@ -5,6 +5,9 @@ exports.processAssignment = processAssignment;
|
|
|
5
5
|
exports.processDefineArgument = processDefineArgument;
|
|
6
6
|
exports.markAsAssignment = markAsAssignment;
|
|
7
7
|
const known_call_handling_1 = require("../known-call-handling");
|
|
8
|
+
const nse_1 = require("../nse");
|
|
9
|
+
const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
|
|
10
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
8
11
|
const log_1 = require("../../../../../../util/log");
|
|
9
12
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
10
13
|
const process_named_call_1 = require("../../../process-named-call");
|
|
@@ -95,6 +98,37 @@ args, rootId, data, config) {
|
|
|
95
98
|
}
|
|
96
99
|
return processAssignment(name, args, rootId, data, { ...config, mayHaveMoreArgs: true });
|
|
97
100
|
}
|
|
101
|
+
/** Within a data-masking call `a := b` is rlang's name-value pair, not data.table's assignment. */
|
|
102
|
+
function isMaskedNamePair(name, rootId, data) {
|
|
103
|
+
if (identifier_1.Identifier.getName(name.content) !== ':=') {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const idMap = data.completeAst.idMap;
|
|
107
|
+
let parent = idMap.get(rootId)?.info.parent;
|
|
108
|
+
while (parent !== undefined) {
|
|
109
|
+
const node = idMap.get(parent);
|
|
110
|
+
if (node === undefined) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
else if (r_argument_1.RArgument.is(node)) {
|
|
114
|
+
parent = node.info.parent;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return r_function_call_1.RFunctionCall.isNamed(node) && data_masking_functions_1.DataMaskingFunctionNames.has(identifier_1.Identifier.getName(node.functionName.content));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
/** Analyzes `a := b` as the named argument it is. */
|
|
123
|
+
function processMaskedNamePair(name, args, rootId, data) {
|
|
124
|
+
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' });
|
|
125
|
+
const target = args[0];
|
|
126
|
+
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.First, {
|
|
127
|
+
kind: known_call_handling_1.NseKind.DataMasked,
|
|
128
|
+
evaluated: nse_1.Nse.unquoted(target === r_function_call_1.EmptyArgument ? undefined : target?.value, nse_1.Unquote.Rlang)
|
|
129
|
+
});
|
|
130
|
+
return information;
|
|
131
|
+
}
|
|
98
132
|
/**
|
|
99
133
|
* Processes an assignment, i.e., `<target> <- <source>`.
|
|
100
134
|
* Handling it as a function call \`<-\` `(<target>, <source>)`.
|
|
@@ -103,6 +137,9 @@ args, rootId, data, config) {
|
|
|
103
137
|
function processAssignment(name,
|
|
104
138
|
/* we expect them to be ordered in the sense that we have (source, target): `<source> <- <target>` */
|
|
105
139
|
args, rootId, data, config) {
|
|
140
|
+
if (isMaskedNamePair(name, rootId, data)) {
|
|
141
|
+
return processMaskedNamePair(name, args, rootId, data);
|
|
142
|
+
}
|
|
106
143
|
if (!config.mayHaveMoreArgs && args.length !== 2) {
|
|
107
144
|
logger_1.dataflowLogger.warn(`Assignment ${identifier_1.Identifier.toString(name.content)} has something else than 2 arguments, skipping`);
|
|
108
145
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'default' }).information;
|
|
@@ -416,12 +453,8 @@ function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignme
|
|
|
416
453
|
}
|
|
417
454
|
information.graph.addEdge(nid, rootIdOfAssignment, edge_1.EdgeType.DefinedBy);
|
|
418
455
|
// kinda dirty, but we have to remove existing read edges for the symbol, added by the child
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
edge.types &= ~edge_1.EdgeType.Reads;
|
|
422
|
-
if (edge.types === 0) {
|
|
423
|
-
out?.delete(id);
|
|
424
|
-
}
|
|
456
|
+
for (const [id] of [...information.graph.outgoingEdges(nodeToDefine.nodeId) ?? []]) {
|
|
457
|
+
information.graph.removeEdgeType(nodeToDefine.nodeId, id, edge_1.EdgeType.Reads);
|
|
425
458
|
}
|
|
426
459
|
}
|
|
427
460
|
/**
|
|
@@ -8,6 +8,7 @@ exports.resolveEnvirArg = resolveEnvirArg;
|
|
|
8
8
|
exports.resolveSymbolToEnvir = resolveSymbolToEnvir;
|
|
9
9
|
exports.routeWrittenToCustomEnv = routeWrittenToCustomEnv;
|
|
10
10
|
exports.resolveAttachPosition = resolveAttachPosition;
|
|
11
|
+
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
11
12
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
12
13
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
13
14
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
@@ -19,8 +20,8 @@ const environment_1 = require("../../../../../environments/environment");
|
|
|
19
20
|
const prefix_1 = require("../../../../../../util/prefix");
|
|
20
21
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
21
22
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
23
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
22
24
|
const resolve_strings_1 = require("../../../../../eval/resolve/resolve-strings");
|
|
23
|
-
const general_1 = require("../../../../../eval/values/general");
|
|
24
25
|
const logger_1 = require("../../../../../logger");
|
|
25
26
|
/** A tracked env is a real stack environment (not a private custom env) when its current layer is the global or the built-in/base env. */
|
|
26
27
|
function isStackEnvState(envState) {
|
|
@@ -73,7 +74,7 @@ function signatureParamNames(data, id, fallback) {
|
|
|
73
74
|
}
|
|
74
75
|
/** The constant string a name-position node denotes at construction time (string literal, aliased variable, or a paste-like join of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
|
|
75
76
|
function resolveConstantString(node, data) {
|
|
76
|
-
const info =
|
|
77
|
+
const info = node_value_1.NodeValue.infoOf(data);
|
|
77
78
|
const unshadowed = new Map();
|
|
78
79
|
const fold = (n) => {
|
|
79
80
|
if (!r_function_call_1.RFunctionCall.isNamed(n)) {
|
|
@@ -155,19 +156,6 @@ function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
|
|
|
155
156
|
function clampAttachPosition(pos) {
|
|
156
157
|
return Number.isFinite(pos) ? Math.max(environment_1.DefaultAttachPosition, Math.trunc(pos)) : undefined;
|
|
157
158
|
}
|
|
158
|
-
/** The number a value denotes, directly or as the single point of an interval (how a numeric literal resolves). */
|
|
159
|
-
function scalarNumber(value) {
|
|
160
|
-
if (value.type === 'number') {
|
|
161
|
-
return 'num' in value.value ? value.value.num : undefined;
|
|
162
|
-
}
|
|
163
|
-
if (value.type === 'interval' && value.startInclusive && value.endInclusive
|
|
164
|
-
&& value.start.type === 'number' && 'num' in value.start.value
|
|
165
|
-
&& value.end.type === 'number' && 'num' in value.end.value
|
|
166
|
-
&& value.start.value.num === value.end.value.num) {
|
|
167
|
-
return value.start.value.num;
|
|
168
|
-
}
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
159
|
/**
|
|
172
160
|
* The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
|
|
173
161
|
* an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown
|
|
@@ -178,19 +166,19 @@ function resolveAttachPosition(posId, data) {
|
|
|
178
166
|
if (posId === undefined) {
|
|
179
167
|
return undefined;
|
|
180
168
|
}
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
169
|
+
const element = node_value_1.NodeValue.soleOf(posId, data);
|
|
170
|
+
if (element === undefined) {
|
|
183
171
|
return undefined;
|
|
184
172
|
}
|
|
185
|
-
const
|
|
186
|
-
const asNumber = scalarNumber(element);
|
|
173
|
+
const asNumber = r_value_1.RValue.numberOf(element);
|
|
187
174
|
if (asNumber !== undefined) {
|
|
188
175
|
return clampAttachPosition(asNumber);
|
|
189
176
|
}
|
|
190
|
-
|
|
191
|
-
|
|
177
|
+
const asString = r_value_1.RValue.stringOf(element);
|
|
178
|
+
if (asString !== undefined) {
|
|
179
|
+
const found = environment_1.REnvironment.searchPosition(data.environment.current, asString);
|
|
192
180
|
if (found === undefined) {
|
|
193
|
-
logger_1.dataflowLogger.warn(`search-path entry '${
|
|
181
|
+
logger_1.dataflowLogger.warn(`search-path entry '${asString}' does not exist, attaching at the default position`);
|
|
194
182
|
return undefined;
|
|
195
183
|
}
|
|
196
184
|
return clampAttachPosition(found);
|
|
@@ -11,37 +11,46 @@ const log_1 = require("../../../../../../util/log");
|
|
|
11
11
|
const built_in_source_1 = require("./built-in-source");
|
|
12
12
|
const edge_1 = require("../../../../../graph/edge");
|
|
13
13
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
14
|
-
const append_1 = require("../../../../../environments/append");
|
|
15
14
|
const assert_1 = require("../../../../../../util/assert");
|
|
16
|
-
const general_1 = require("../../../../../eval/values/general");
|
|
17
|
-
const string_constants_1 = require("../../../../../eval/values/string/string-constants");
|
|
18
15
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
19
|
-
const
|
|
16
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
20
17
|
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
21
18
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
22
19
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
20
|
+
/** the formals of `eval(expr, envir, enclos)` */
|
|
21
|
+
const EvalParameterNames = ['expr', 'envir', 'enclos'];
|
|
23
22
|
/**
|
|
24
23
|
* Process a call to `eval()`, trying to resolve the code being evaluated if possible.
|
|
25
24
|
*/
|
|
26
25
|
function processEvalCall(name, args, rootId, data, config) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, EvalParameterNames);
|
|
27
|
+
/* `evalText` names its formal differently, so a lone argument is the expression whatever it is called */
|
|
28
|
+
const evalArgument = (bound.get('expr') ?? r_function_call_1.RFunctionCall.soleArgument(args))?.value;
|
|
29
|
+
const envirArg = bound.get('envir');
|
|
30
|
+
if (evalArgument === undefined) {
|
|
31
|
+
logger_1.dataflowLogger.warn(`Expected an expression argument for eval, but got ${args.length} argument(s), skipping`);
|
|
32
|
+
const bail = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
33
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(bail.graph, bail.environment, rootId);
|
|
34
|
+
return bail;
|
|
30
35
|
}
|
|
31
36
|
const information = config.includeFunctionCall ?
|
|
32
37
|
(0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: [true], origin: built_in_proc_name_1.BuiltInProcName.Eval }).information
|
|
33
38
|
: info_1.DataflowInformation.initialize(rootId, data);
|
|
34
|
-
const evalArgument = args[0];
|
|
35
39
|
if (config.includeFunctionCall) {
|
|
36
|
-
information.graph.addEdge(rootId,
|
|
40
|
+
information.graph.addEdge(rootId, evalArgument.info.id, edge_1.EdgeType.Returns);
|
|
37
41
|
}
|
|
38
42
|
if (!data.ctx.config.solver.evalStrings) {
|
|
39
43
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping eval call ${JSON.stringify(evalArgument)} (disabled in config file)`);
|
|
40
44
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
41
45
|
return information;
|
|
42
46
|
}
|
|
43
|
-
const code = resolveEvalToCode(evalArgument
|
|
47
|
+
const code = resolveEvalToCode(evalArgument, config, data);
|
|
44
48
|
if (code) {
|
|
49
|
+
if (envirArg !== undefined) {
|
|
50
|
+
/* the code runs in another environment, so its definitions do not land in the current one and
|
|
51
|
+
* pretending they do would produce wrong edges */
|
|
52
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
53
|
+
}
|
|
45
54
|
const idGenerator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(name.lexeme + '::' + rootId, name.location);
|
|
46
55
|
data = {
|
|
47
56
|
...data,
|
|
@@ -58,37 +67,16 @@ function processEvalCall(name, args, rootId, data, config) {
|
|
|
58
67
|
information.graph.addEdge(rootId, e.nodeId, edge_1.EdgeType.Returns);
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
|
-
return {
|
|
62
|
-
graph: result.reduce((acc, r) => acc.mergeWith(r.graph), information.graph),
|
|
63
|
-
environment: result.reduce((acc, r) => (0, append_1.appendEnvironment)(acc, r.environment), information.environment),
|
|
64
|
-
entryPoint: rootId,
|
|
65
|
-
out: information.out.concat(result.flatMap(r => r.out)),
|
|
66
|
-
in: information.in.concat(result.flatMap(r => r.in)),
|
|
67
|
-
unknownReferences: information.unknownReferences.concat(result.flatMap(r => r.unknownReferences)),
|
|
68
|
-
exitPoints: information.exitPoints.concat(result.flatMap(r => r.exitPoints)),
|
|
69
|
-
hooks: information.hooks.concat(result.flatMap(r => r.hooks)),
|
|
70
|
-
};
|
|
70
|
+
return (0, built_in_source_1.mergeSourced)({ ...information, entryPoint: rootId }, result);
|
|
71
71
|
}
|
|
72
72
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(args)} for eval is currently not supported, skipping`);
|
|
73
73
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
74
74
|
return information;
|
|
75
75
|
}
|
|
76
76
|
function resolveEvalToCode(evalArgument, config, data) {
|
|
77
|
-
const ctx = data.ctx;
|
|
78
|
-
const env = data.environment;
|
|
79
|
-
const idMap = data.completeAst.idMap;
|
|
80
77
|
const val = evalArgument;
|
|
81
78
|
if (config.supportFunctionCall) {
|
|
82
|
-
|
|
83
|
-
return [val.content.str];
|
|
84
|
-
}
|
|
85
|
-
else if (val.type === type_1.RType.Symbol) {
|
|
86
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: env, idMap: idMap, resolve: ctx.config.solver.variables, ctx }));
|
|
87
|
-
if (resolved) {
|
|
88
|
-
return (0, string_constants_1.collectStrings)(resolved.elements);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return undefined;
|
|
79
|
+
return getAsString(val, data);
|
|
92
80
|
}
|
|
93
81
|
else {
|
|
94
82
|
if (val.type === type_1.RType.FunctionCall && val.named && val.functionName.content === 'parse') {
|
|
@@ -97,19 +85,10 @@ function resolveEvalToCode(evalArgument, config, data) {
|
|
|
97
85
|
if (nArg !== undefined || arg === undefined || arg === r_function_call_1.EmptyArgument) {
|
|
98
86
|
return undefined;
|
|
99
87
|
}
|
|
100
|
-
if (arg.value?.type === type_1.RType.
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
else if (arg.value?.type === type_1.RType.Symbol) {
|
|
104
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(arg.value.info.id, { environment: env, idMap: idMap, resolve: ctx.config.solver.variables, ctx }));
|
|
105
|
-
if (resolved) {
|
|
106
|
-
return (0, string_constants_1.collectStrings)(resolved.elements);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else if (arg.value?.type === type_1.RType.FunctionCall && arg.value.named && ['paste', 'paste0'].includes(identifier_1.Identifier.getName(arg.value.functionName.content))) {
|
|
110
|
-
return handlePaste(ctx.config, arg.value.arguments, env, idMap, arg.value.functionName.content === 'paste' ? [' '] : [''], ctx);
|
|
88
|
+
if (arg.value?.type === type_1.RType.FunctionCall && arg.value.named && ['paste', 'paste0'].includes(identifier_1.Identifier.getName(arg.value.functionName.content))) {
|
|
89
|
+
return handlePaste(arg.value.arguments, data, arg.value.functionName.content === 'paste' ? [' '] : ['']);
|
|
111
90
|
}
|
|
112
|
-
return
|
|
91
|
+
return getAsString(arg.value, data);
|
|
113
92
|
}
|
|
114
93
|
else if (val.type === type_1.RType.Symbol) {
|
|
115
94
|
// const resolved = resolveValueOfVariable(val.content, env);
|
|
@@ -121,7 +100,7 @@ function resolveEvalToCode(evalArgument, config, data) {
|
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
102
|
}
|
|
124
|
-
function getAsString(
|
|
103
|
+
function getAsString(val, data) {
|
|
125
104
|
if (!val) {
|
|
126
105
|
return undefined;
|
|
127
106
|
}
|
|
@@ -129,17 +108,14 @@ function getAsString(config, val, env, idMap, ctx) {
|
|
|
129
108
|
return [val.content.str];
|
|
130
109
|
}
|
|
131
110
|
else if (val.type === type_1.RType.Symbol) {
|
|
132
|
-
|
|
133
|
-
if (resolved) {
|
|
134
|
-
return (0, string_constants_1.collectStrings)(resolved.elements);
|
|
135
|
-
}
|
|
111
|
+
return node_value_1.NodeValue.stringsOf(val.info.id, data);
|
|
136
112
|
}
|
|
137
113
|
return undefined;
|
|
138
114
|
}
|
|
139
|
-
function handlePaste(
|
|
115
|
+
function handlePaste(args, data, sepDefault) {
|
|
140
116
|
const sepArg = args.find(v => v !== r_function_call_1.EmptyArgument && v.name?.content === 'sep');
|
|
141
117
|
if (sepArg) {
|
|
142
|
-
const res = sepArg !== r_function_call_1.EmptyArgument && sepArg.value ? getAsString(
|
|
118
|
+
const res = sepArg !== r_function_call_1.EmptyArgument && sepArg.value ? getAsString(sepArg.value, data) : undefined;
|
|
143
119
|
if (!res) {
|
|
144
120
|
// sep not resolvable clearly / unknown
|
|
145
121
|
return undefined;
|
|
@@ -148,7 +124,7 @@ function handlePaste(config, args, env, idMap, sepDefault, ctx) {
|
|
|
148
124
|
}
|
|
149
125
|
const allArgs = args
|
|
150
126
|
.filter(v => v !== r_function_call_1.EmptyArgument && v.name?.content !== 'sep' && v.value)
|
|
151
|
-
.map(v => getAsString(
|
|
127
|
+
.map(v => getAsString(v.value, data));
|
|
152
128
|
if (allArgs.some(assert_1.isUndefined)) {
|
|
153
129
|
return undefined;
|
|
154
130
|
}
|
|
@@ -10,8 +10,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
10
10
|
const edge_1 = require("../../../../../graph/edge");
|
|
11
11
|
const append_1 = require("../../../../../environments/append");
|
|
12
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
|
-
const
|
|
14
|
-
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
13
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
15
14
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
16
15
|
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
17
16
|
const linker_1 = require("../../../../linker");
|
|
@@ -64,9 +63,9 @@ function processIfThenElse(name, args, rootId, data, config) {
|
|
|
64
63
|
let then;
|
|
65
64
|
let makeThenMaybe = false;
|
|
66
65
|
// we should defer this to the abstract interpretation
|
|
67
|
-
const values =
|
|
68
|
-
const conditionIsAlwaysFalse =
|
|
69
|
-
const conditionIsAlwaysTrue =
|
|
66
|
+
const values = node_value_1.NodeValue.setOf(condArg?.info.id, data);
|
|
67
|
+
const conditionIsAlwaysFalse = values?.elements.every(d => d.type === 'logical' && d.value === false) ?? false;
|
|
68
|
+
const conditionIsAlwaysTrue = values?.elements.every(d => d.type === 'logical' && d.value === true) ?? false;
|
|
70
69
|
if (!conditionIsAlwaysFalse) {
|
|
71
70
|
then = (0, processor_1.processDataflowFor)(thenArg, data);
|
|
72
71
|
if (then.entryPoint) {
|