@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
|
@@ -8,6 +8,7 @@ exports.attachBaseRNamespaces = attachBaseRNamespaces;
|
|
|
8
8
|
exports.attachDeclaredDependencies = attachDeclaredDependencies;
|
|
9
9
|
exports.attachProjectImports = attachProjectImports;
|
|
10
10
|
exports.attachProject = attachProject;
|
|
11
|
+
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
11
12
|
const known_call_handling_1 = require("../known-call-handling");
|
|
12
13
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
14
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
@@ -22,8 +23,7 @@ const environment_1 = require("../../../../../environments/environment");
|
|
|
22
23
|
const edge_1 = require("../../../../../graph/edge");
|
|
23
24
|
const assert_1 = require("../../../../../../util/assert");
|
|
24
25
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
25
|
-
const
|
|
26
|
-
const general_1 = require("../../../../../eval/values/general");
|
|
26
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
27
27
|
const package_1 = require("../../../../../../project/plugins/package-version-plugins/package");
|
|
28
28
|
const attached_packages_1 = require("../../../../../../project/attached-packages");
|
|
29
29
|
const flowr_namespace_file_1 = require("../../../../../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
@@ -51,7 +51,6 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
51
51
|
/* last, so the positional fallback keeps its previous order */
|
|
52
52
|
'pos': 'pos'
|
|
53
53
|
};
|
|
54
|
-
const resolveArgs = { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx };
|
|
55
54
|
const argMaps = (0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params);
|
|
56
55
|
const packageId = Array.from(new Set(argMaps.get('pkg')));
|
|
57
56
|
const charId = Array.from(new Set(argMaps.get('char')));
|
|
@@ -71,7 +70,7 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
71
70
|
}
|
|
72
71
|
let isCharacterOnly = config.characterOnly === true;
|
|
73
72
|
if (!config.characterOnly && charId.length >= 1) {
|
|
74
|
-
const values =
|
|
73
|
+
const values = node_value_1.NodeValue.setOf(charId[0], data);
|
|
75
74
|
if (values?.type === 'set' && values?.elements.length > 0) {
|
|
76
75
|
let hasTrue = 0;
|
|
77
76
|
let hasFalse = 0;
|
|
@@ -109,11 +108,12 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
109
108
|
//case: true or maybe
|
|
110
109
|
if (isCharacterOnly) {
|
|
111
110
|
for (const nameToLoad of namesToLoad) {
|
|
112
|
-
const values =
|
|
111
|
+
const values = node_value_1.NodeValue.setOf(nameToLoad.info.id, data);
|
|
113
112
|
if (values?.type === 'set' && values.elements.length !== 0) {
|
|
114
113
|
for (const elem of values.elements) {
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const name = r_value_1.RValue.stringOf(elem);
|
|
115
|
+
if (name !== undefined) {
|
|
116
|
+
packetName.push(name);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -12,8 +12,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
12
12
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
13
13
|
const edge_1 = require("../../../../../graph/edge");
|
|
14
14
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
15
|
-
const
|
|
16
|
-
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
15
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
17
16
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
18
17
|
const assert_1 = require("../../../../../../util/assert");
|
|
19
18
|
const range_1 = require("../../../../../../util/range");
|
|
@@ -47,7 +46,7 @@ function processLoadCall(name, args, rootId, data) {
|
|
|
47
46
|
sourceFile = [(0, retriever_1.removeRQuotes)(fileArg.lexeme)];
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
|
-
const resolved =
|
|
49
|
+
const resolved = node_value_1.NodeValue.setOf(fileArg.info.id, data, { environment: envirResolution?.envirData.environment ?? data.environment });
|
|
51
50
|
sourceFile = resolved?.elements.map(r => r.type === 'string' && (0, r_value_1.isValue)(r.value) ? r.value.str : undefined).filter(assert_1.isNotUndefined);
|
|
52
51
|
}
|
|
53
52
|
if (sourceFile) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processPipe = processPipe;
|
|
4
4
|
const known_call_handling_1 = require("../known-call-handling");
|
|
5
|
+
const nse_1 = require("../nse");
|
|
5
6
|
const assert_1 = require("../../../../../../util/assert");
|
|
6
7
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
7
8
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
@@ -17,6 +18,23 @@ const make_argument_1 = require("../argument/make-argument");
|
|
|
17
18
|
const built_in_assignment_1 = require("./built-in-assignment");
|
|
18
19
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
19
20
|
const log_1 = require("../../../../../../util/log");
|
|
21
|
+
/** Piping the data in shifts the arguments, so the call's own `all-but-first` marking misses them. */
|
|
22
|
+
function markPipedDataMask(rhs, graph) {
|
|
23
|
+
for (const arg of rhs.arguments) {
|
|
24
|
+
if (arg === r_function_call_1.EmptyArgument) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
model_1.RNode.visitAst(arg, node => {
|
|
28
|
+
if (nse_1.Nse.isUnquote(node, nse_1.Unquote.Rlang)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (r_symbol_1.RSymbol.is(node) && nse_1.Nse.suppliedByMask(graph, node.info.id)) {
|
|
32
|
+
graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
20
38
|
/**
|
|
21
39
|
* Support for R's pipe functions like `|>` or magrittr's `%>%`
|
|
22
40
|
*/
|
|
@@ -96,18 +114,7 @@ function processPipe(name, args, rootId, data, { pipePlaceholderName, assignLhs,
|
|
|
96
114
|
information.graph.addEdge(functionCallNode.id, argId, edge_1.EdgeType.Argument | edge_1.EdgeType.Reads);
|
|
97
115
|
}
|
|
98
116
|
if (r_function_call_1.RFunctionCall.isNamed(rhs) && data_masking_functions_1.DataMaskingFunctionNames.has(identifier_1.Identifier.getName(rhs.functionName.content))) {
|
|
99
|
-
|
|
100
|
-
if (arg === r_function_call_1.EmptyArgument) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
/* only the symbols may name columns, the rest is evaluated in the caller's frame */
|
|
104
|
-
model_1.RNode.visitAst(arg, node => {
|
|
105
|
-
if (r_symbol_1.RSymbol.is(node)) {
|
|
106
|
-
information.graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
117
|
+
markPipedDataMask(rhs, information.graph);
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
120
|
else {
|
|
@@ -27,7 +27,8 @@ function linkOnSymbol(rootId, filteredArgs, node, graph, data) {
|
|
|
27
27
|
// If the target directly maps to a function definition AST, try to link arguments to parameters
|
|
28
28
|
let linked = data.completeAst.idMap.get(def.nodeId);
|
|
29
29
|
if (linked?.type !== type_1.RType.FunctionDefinition) {
|
|
30
|
-
|
|
30
|
+
const values = def.value;
|
|
31
|
+
for (const vid of Array.isArray(values) ? values : []) {
|
|
31
32
|
const candidate = data.completeAst.idMap.get(vid);
|
|
32
33
|
if (candidate && candidate.type === type_1.RType.FunctionDefinition) {
|
|
33
34
|
linked = candidate;
|
|
@@ -5,9 +5,12 @@ import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-
|
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { ForceArguments } from '../common';
|
|
8
|
+
import { Unquote } from '../nse';
|
|
8
9
|
interface QuoteConfig extends ForceArguments {
|
|
9
10
|
quoteArgumentsWithIndex: number;
|
|
10
11
|
envArgIndex?: number;
|
|
12
|
+
/** which unquote escape the function supports, {@link Unquote.None} if unset */
|
|
13
|
+
unquote?: Unquote;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Process a call to `quote` or similar nse/substitution functions.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processQuote = processQuote;
|
|
4
4
|
const known_call_handling_1 = require("../known-call-handling");
|
|
5
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
6
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
6
7
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
7
8
|
const logger_1 = require("../../../../../logger");
|
|
@@ -9,6 +10,8 @@ const df_helper_1 = require("../../../../../graph/df-helper");
|
|
|
9
10
|
const edge_1 = require("../../../../../graph/edge");
|
|
10
11
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
11
12
|
const graph_1 = require("../../../../../graph/graph");
|
|
13
|
+
const nse_1 = require("../nse");
|
|
14
|
+
const linker_1 = require("../../../../linker");
|
|
12
15
|
/**
|
|
13
16
|
* Process a call to `quote` or similar nse/substitution functions.
|
|
14
17
|
*/
|
|
@@ -27,66 +30,33 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const inRefs = [fnRef];
|
|
34
|
+
const outRefs = [];
|
|
35
|
+
const unknownRefs = [];
|
|
36
|
+
const quotedArg = args[config.quoteArgumentsWithIndex];
|
|
37
|
+
const evaluated = nse_1.Nse.unquoted(quotedArg === r_function_call_1.EmptyArgument ? undefined : quotedArg?.value, config.unquote ?? nse_1.Unquote.None);
|
|
33
38
|
for (let i = 0; i < args.length; i++) {
|
|
34
39
|
const processedArg = processedArguments[i];
|
|
35
|
-
if (processedArg && i !== config
|
|
36
|
-
inRefs
|
|
37
|
-
outRefs
|
|
38
|
-
unknownRefs
|
|
40
|
+
if (processedArg && i !== config.quoteArgumentsWithIndex) {
|
|
41
|
+
inRefs.push(...processedArg.in);
|
|
42
|
+
outRefs.push(...processedArg.out);
|
|
43
|
+
unknownRefs.push(...processedArg.unknownReferences);
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
const quotedProcessed = processedArguments[config.quoteArgumentsWithIndex];
|
|
47
|
+
if (quotedProcessed) {
|
|
48
|
+
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, [config.quoteArgumentsWithIndex], { evaluated });
|
|
49
|
+
if (evaluated) {
|
|
50
|
+
/* the argument was processed in a clean env, so the escaped reads need linking by hand */
|
|
51
|
+
const escaped = [...quotedProcessed.in, ...quotedProcessed.unknownReferences].filter(r => evaluated.has(r.nodeId));
|
|
52
|
+
(0, linker_1.linkInputs)(escaped, lastEnv, inRefs, information.graph, false);
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
|
-
if (config
|
|
55
|
+
if (config.envArgIndex !== undefined) {
|
|
49
56
|
const envProcessed = processedArguments[config.envArgIndex];
|
|
50
57
|
const exprProcessed = processedArguments[config.quoteArgumentsWithIndex];
|
|
51
58
|
if (envProcessed && exprProcessed) {
|
|
52
|
-
|
|
53
|
-
// traverse the env processed DFG to find list calls (prefix-aware handling)
|
|
54
|
-
df_helper_1.Dataflow.visitDfg(envProcessed.graph, envProcessed.entryPoint, (vtx) => {
|
|
55
|
-
if (vtx.tag !== vertex_1.VertexType.FunctionCall) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.List)) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
const useMap = new Map();
|
|
62
|
-
for (const vType of [vertex_1.VertexType.Use, vertex_1.VertexType.FunctionCall]) {
|
|
63
|
-
for (const [useId] of exprProcessed.graph.verticesOfType(vType)) {
|
|
64
|
-
const rn = (0, node_id_1.recoverName)(useId, exprProcessed.graph.idMap);
|
|
65
|
-
if (rn) {
|
|
66
|
-
const arr = useMap.get(rn) ?? [];
|
|
67
|
-
arr.push(useId);
|
|
68
|
-
useMap.set(rn, arr);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (useMap.size === 0) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
const listFields = vtx.args.filter(graph_1.FunctionArgument.isNamed);
|
|
76
|
-
for (const field of listFields) {
|
|
77
|
-
const uses = useMap.get(field.name);
|
|
78
|
-
if (uses) {
|
|
79
|
-
for (const useId of uses) {
|
|
80
|
-
information.graph.addEdge(useId, field.nodeId, edge_1.EdgeType.Reads);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
logger_1.dataflowLogger.warn('Failed to apply substitute-style env list replacement in quote-like call', { error: e });
|
|
89
|
-
}
|
|
59
|
+
applyEnvListReplacement(information, envProcessed, exprProcessed);
|
|
90
60
|
}
|
|
91
61
|
}
|
|
92
62
|
return {
|
|
@@ -97,4 +67,51 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
97
67
|
unknownReferences: unknownRefs
|
|
98
68
|
};
|
|
99
69
|
}
|
|
70
|
+
/** The uses within `expr`, by name, to match a `substitute` env list against. */
|
|
71
|
+
function usesByName(expr) {
|
|
72
|
+
const useMap = new Map();
|
|
73
|
+
for (const vType of [vertex_1.VertexType.Use, vertex_1.VertexType.FunctionCall]) {
|
|
74
|
+
for (const [useId] of expr.graph.verticesOfType(vType)) {
|
|
75
|
+
const rn = (0, node_id_1.recoverName)(useId, expr.graph.idMap);
|
|
76
|
+
if (rn) {
|
|
77
|
+
const arr = useMap.get(rn);
|
|
78
|
+
if (arr) {
|
|
79
|
+
arr.push(useId);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
useMap.set(rn, [useId]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return useMap;
|
|
88
|
+
}
|
|
89
|
+
/** `substitute(expr, list(a = 1))` replaces the listed names within `expr`. */
|
|
90
|
+
function applyEnvListReplacement(information, env, expr) {
|
|
91
|
+
let useMap = undefined;
|
|
92
|
+
try {
|
|
93
|
+
/* traverse the env processed DFG to find list calls (prefix-aware handling) */
|
|
94
|
+
df_helper_1.Dataflow.visitDfg(env.graph, env.entryPoint, (vtx) => {
|
|
95
|
+
if (vtx.tag !== vertex_1.VertexType.FunctionCall) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!vtx.origin.includes(built_in_proc_name_1.BuiltInProcName.List)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
useMap ??= usesByName(expr);
|
|
102
|
+
if (useMap.size === 0) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
for (const field of vtx.args.filter(graph_1.FunctionArgument.isNamed)) {
|
|
106
|
+
for (const useId of useMap.get(field.name) ?? []) {
|
|
107
|
+
information.graph.addEdge(useId, field.nodeId, edge_1.EdgeType.Reads);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
logger_1.dataflowLogger.warn('Failed to apply substitute-style env list replacement in quote-like call', { error: e });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
100
117
|
//# sourceMappingURL=built-in-quote.js.map
|
|
@@ -25,8 +25,8 @@ function processRecall(name, args, rootId, data, config) {
|
|
|
25
25
|
});
|
|
26
26
|
// If requested, treat Recall as an unknown side effect when a single argument is provided and it is not the numeric literal 0.
|
|
27
27
|
if (config?.unknownOnNonZeroArg) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const v = r_function_call_1.RFunctionCall.soleArgument(args)?.value;
|
|
29
|
+
if (v) {
|
|
30
30
|
// only allow the normal recall handling if the single arg is the literal 0
|
|
31
31
|
if (!(v.type === type_1.RType.Number && v.content.num === 0)) {
|
|
32
32
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
@@ -7,6 +7,7 @@ const linker_1 = require("../../../../linker");
|
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
9
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
10
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
10
11
|
const general_1 = require("../../../../../eval/values/general");
|
|
11
12
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
12
13
|
const range_1 = require("../../../../../../util/range");
|
|
@@ -61,14 +62,7 @@ function processRegisterHook(name, args, rootId, data, config) {
|
|
|
61
62
|
}
|
|
62
63
|
});
|
|
63
64
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args: transformed, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.RegisterHook });
|
|
64
|
-
const resolveArgs = {
|
|
65
|
-
graph: res.information.graph,
|
|
66
|
-
environment: res.information.environment,
|
|
67
|
-
resolve: data.ctx.config.solver.variables,
|
|
68
|
-
ctx: data.ctx,
|
|
69
|
-
idMap: data.completeAst.idMap,
|
|
70
|
-
full: true
|
|
71
|
-
};
|
|
65
|
+
const resolveArgs = node_value_1.NodeValue.infoOf(data, { graph: res.information.graph, environment: res.information.environment });
|
|
72
66
|
const shouldAdd = addIds.size === 0 ? config.args.add?.default :
|
|
73
67
|
Array.from(addIds).flatMap(id => (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(id, resolveArgs))?.elements ?? [])
|
|
74
68
|
.some(v => v.type === 'logical' && v.value !== false);
|
|
@@ -8,8 +8,7 @@ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
|
8
8
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
9
9
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
10
10
|
const prefix_1 = require("../../../../../../util/prefix");
|
|
11
|
-
const
|
|
12
|
-
const general_1 = require("../../../../../eval/values/general");
|
|
11
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
13
12
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
14
13
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
15
14
|
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
@@ -63,12 +62,7 @@ function collectListArg(targets, value, data) {
|
|
|
63
62
|
targets.all = true;
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
|
-
const elements =
|
|
67
|
-
environment: data.environment,
|
|
68
|
-
idMap: data.completeAst.idMap,
|
|
69
|
-
resolve: data.ctx.config.solver.variables,
|
|
70
|
-
ctx: data.ctx
|
|
71
|
-
}))?.elements;
|
|
65
|
+
const elements = node_value_1.NodeValue.setOf(value.info.id, data)?.elements;
|
|
72
66
|
if (!elements || elements.length === 0) {
|
|
73
67
|
targets.unknown = true;
|
|
74
68
|
}
|
|
@@ -15,7 +15,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
15
15
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
16
16
|
const assert_1 = require("../../../../../../util/assert");
|
|
17
17
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
18
|
-
const
|
|
18
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
19
19
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
20
20
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
21
21
|
const range_1 = require("../../../../../../util/range");
|
|
@@ -41,7 +41,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
41
41
|
if (!genName) {
|
|
42
42
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
43
43
|
}
|
|
44
|
-
const n =
|
|
44
|
+
const n = node_value_1.NodeValue.of(genName.info.id, data);
|
|
45
45
|
const accessedIdentifiers = [];
|
|
46
46
|
if (n.type === 'set') {
|
|
47
47
|
for (const elem of n.elements) {
|
|
@@ -8,7 +8,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
8
8
|
const linker_1 = require("../../../../linker");
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
11
|
-
const
|
|
11
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
12
12
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
13
13
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
14
14
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -68,7 +68,7 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
68
68
|
unknownReferences: []
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
const n =
|
|
71
|
+
const n = node_value_1.NodeValue.of(generic.info.id, data);
|
|
72
72
|
const accessedIdentifiers = [];
|
|
73
73
|
if (n.type === 'set') {
|
|
74
74
|
for (const elem of n.elements) {
|
|
@@ -45,8 +45,13 @@ export declare function processSourceCall<OtherInfo>(name: RSymbol<OtherInfo & P
|
|
|
45
45
|
* Processes a source request with the given dataflow processor information and existing dataflow information
|
|
46
46
|
* Otherwise, this can be an {@link RProjectFile} representing a standalone source file
|
|
47
47
|
*/
|
|
48
|
-
export declare function sourceRequest<OtherInfo>(rootId: NodeId, request: RParseRequest | RProjectFile<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation, makeMaybe: boolean, getId?: IdGenerator<NoInfo
|
|
48
|
+
export declare function sourceRequest<OtherInfo>(rootId: NodeId, request: RParseRequest | RProjectFile<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation, makeMaybe: boolean, getId?: IdGenerator<NoInfo>, evaluatedByRoot?: boolean): DataflowInformation;
|
|
49
49
|
/**
|
|
50
50
|
* Processes a standalone source file (i.e., not from a source function call)
|
|
51
51
|
*/
|
|
52
52
|
export declare function standaloneSourceFile<OtherInfo>(idx: number, file: RProjectFile<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation): DataflowInformation;
|
|
53
|
+
/**
|
|
54
|
+
* Folds the results of analyzing sourced code back into the information of the call that asked for it, which
|
|
55
|
+
* `eval` and the string templates both need: the code contributes everything it reads, writes, and leaves open.
|
|
56
|
+
*/
|
|
57
|
+
export declare function mergeSourced(information: DataflowInformation, sourced: readonly DataflowInformation[]): DataflowInformation;
|
|
@@ -10,7 +10,9 @@ exports.findSource = findSource;
|
|
|
10
10
|
exports.processSourceCall = processSourceCall;
|
|
11
11
|
exports.sourceRequest = sourceRequest;
|
|
12
12
|
exports.standaloneSourceFile = standaloneSourceFile;
|
|
13
|
+
exports.mergeSourced = mergeSourced;
|
|
13
14
|
const processor_1 = require("../../../../../processor");
|
|
15
|
+
const append_1 = require("../../../../../environments/append");
|
|
14
16
|
const info_1 = require("../../../../../info");
|
|
15
17
|
const config_1 = require("../../../../../../config");
|
|
16
18
|
const known_call_handling_1 = require("../known-call-handling");
|
|
@@ -26,10 +28,9 @@ const shell_executor_1 = require("../../../../../../r-bridge/shell-executor");
|
|
|
26
28
|
const assert_1 = require("../../../../../../util/assert");
|
|
27
29
|
const path_1 = __importDefault(require("path"));
|
|
28
30
|
const gas_1 = require("../../../../../../gas");
|
|
29
|
-
const general_1 = require("../../../../../eval/values/general");
|
|
30
31
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
31
32
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
32
|
-
const
|
|
33
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
33
34
|
const edge_1 = require("../../../../../graph/edge");
|
|
34
35
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
35
36
|
/**
|
|
@@ -151,7 +152,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
151
152
|
sourceFile = [(0, retriever_1.removeRQuotes)(sourceFileArgument.lexeme)];
|
|
152
153
|
}
|
|
153
154
|
else if (sourceFileArgument !== r_function_call_1.EmptyArgument) {
|
|
154
|
-
const resolved =
|
|
155
|
+
const resolved = node_value_1.NodeValue.setOf(sourceFileArgument.info.id, data);
|
|
155
156
|
sourceFile = resolved?.elements.map(r => r.type === 'string' && (0, r_value_1.isValue)(r.value) ? r.value.str : undefined).filter(assert_1.isNotUndefined);
|
|
156
157
|
}
|
|
157
158
|
if (sourceFile?.length === 1) {
|
|
@@ -192,7 +193,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
192
193
|
* Processes a source request with the given dataflow processor information and existing dataflow information
|
|
193
194
|
* Otherwise, this can be an {@link RProjectFile} representing a standalone source file
|
|
194
195
|
*/
|
|
195
|
-
function sourceRequest(rootId, request, data, information, makeMaybe, getId) {
|
|
196
|
+
function sourceRequest(rootId, request, data, information, makeMaybe, getId, evaluatedByRoot = false) {
|
|
196
197
|
// parse, normalize and dataflow the sourced file
|
|
197
198
|
let dataflow;
|
|
198
199
|
let fst;
|
|
@@ -260,7 +261,13 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId) {
|
|
|
260
261
|
}
|
|
261
262
|
// take the entry point as well as all the written references, and give them a control dependency to the source call to show that they are conditional
|
|
262
263
|
if (!String(rootId).startsWith('file-')) {
|
|
263
|
-
if (
|
|
264
|
+
if (evaluatedByRoot) {
|
|
265
|
+
/* the call evaluates the code and builds its result from it, so the value flows into the call */
|
|
266
|
+
for (const exit of dataflow.exitPoints) {
|
|
267
|
+
dataflow.graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (makeMaybe) {
|
|
264
271
|
if (dataflow.graph.hasVertex(dataflow.entryPoint)) {
|
|
265
272
|
dataflow.graph.addControlDependency(dataflow.entryPoint, rootId, true);
|
|
266
273
|
}
|
|
@@ -305,4 +312,23 @@ function standaloneSourceFile(idx, file, data, information) {
|
|
|
305
312
|
referenceChain: [...data.referenceChain, file.filePath]
|
|
306
313
|
}, information, false);
|
|
307
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Folds the results of analyzing sourced code back into the information of the call that asked for it, which
|
|
317
|
+
* `eval` and the string templates both need: the code contributes everything it reads, writes, and leaves open.
|
|
318
|
+
*/
|
|
319
|
+
function mergeSourced(information, sourced) {
|
|
320
|
+
if (sourced.length === 0) {
|
|
321
|
+
return information;
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
...information,
|
|
325
|
+
graph: sourced.reduce((acc, r) => acc.mergeWith(r.graph), information.graph),
|
|
326
|
+
environment: sourced.reduce((acc, r) => (0, append_1.appendEnvironment)(acc, r.environment), information.environment),
|
|
327
|
+
in: information.in.concat(sourced.flatMap(r => r.in)),
|
|
328
|
+
out: information.out.concat(sourced.flatMap(r => r.out)),
|
|
329
|
+
unknownReferences: information.unknownReferences.concat(sourced.flatMap(r => r.unknownReferences)),
|
|
330
|
+
exitPoints: information.exitPoints.concat(sourced.flatMap(r => r.exitPoints)),
|
|
331
|
+
hooks: information.hooks.concat(sourced.flatMap(r => r.hooks))
|
|
332
|
+
};
|
|
333
|
+
}
|
|
308
334
|
//# sourceMappingURL=built-in-source.js.map
|
|
@@ -7,10 +7,11 @@ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/proce
|
|
|
7
7
|
import type { ForceArguments } from '../common';
|
|
8
8
|
/**
|
|
9
9
|
* Process a special built-in binary operator, possibly lazily.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Only `&&`/`||` short-circuit: their right-hand side gets a control dependency and only the left is read.
|
|
11
|
+
* The vectorized `&`/`|` evaluate both and hence use `lazy: false`.
|
|
12
|
+
* Not related to R's special binary operators like `%in%`.
|
|
12
13
|
*/
|
|
13
14
|
export declare function processSpecialBinOp<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
|
|
14
|
-
lazy: boolean;
|
|
15
|
-
evalRhsWhen
|
|
15
|
+
readonly lazy: boolean;
|
|
16
|
+
readonly evalRhsWhen?: boolean;
|
|
16
17
|
} & ForceArguments): DataflowInformation;
|
|
@@ -8,21 +8,19 @@ const identifier_1 = require("../../../../../environments/identifier");
|
|
|
8
8
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
9
9
|
/**
|
|
10
10
|
* Process a special built-in binary operator, possibly lazily.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Only `&&`/`||` short-circuit: their right-hand side gets a control dependency and only the left is read.
|
|
12
|
+
* The vectorized `&`/`|` evaluate both and hence use `lazy: false`.
|
|
13
|
+
* Not related to R's special binary operators like `%in%`.
|
|
13
14
|
*/
|
|
14
15
|
function processSpecialBinOp(name, args, rootId, data, config) {
|
|
15
|
-
if (
|
|
16
|
-
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.SpecialBinOp }).information;
|
|
17
|
-
}
|
|
18
|
-
else if (args.length != 2) {
|
|
16
|
+
if (args.length != 2) {
|
|
19
17
|
logger_1.dataflowLogger.warn(`Logical bin-op ${identifier_1.Identifier.toString(name.content)} has something else than 2 arguments, skipping`);
|
|
20
18
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'default' }).information;
|
|
21
19
|
}
|
|
22
20
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs,
|
|
23
21
|
patchData: (d, i) => {
|
|
24
|
-
if (i === 1) {
|
|
25
|
-
return { ...d, cds: [...d.cds ?? [], { id:
|
|
22
|
+
if (config.lazy && i === 1) {
|
|
23
|
+
return { ...d, cds: [...d.cds ?? [], { id: rootId, when: config.evalRhsWhen ?? true }] };
|
|
26
24
|
}
|
|
27
25
|
return d;
|
|
28
26
|
},
|
|
@@ -30,9 +28,8 @@ function processSpecialBinOp(name, args, rootId, data, config) {
|
|
|
30
28
|
});
|
|
31
29
|
for (const arg of processedArguments) {
|
|
32
30
|
if (arg) {
|
|
33
|
-
information.graph.addEdge(
|
|
31
|
+
information.graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Reads);
|
|
34
32
|
}
|
|
35
|
-
// only do first if lazy
|
|
36
33
|
if (config.lazy) {
|
|
37
34
|
break;
|
|
38
35
|
}
|
|
@@ -20,6 +20,11 @@ export declare function processStackEnv<OtherInfo>(name: RSymbol<OtherInfo & Par
|
|
|
20
20
|
* or a named search-path entry via `as.environment("package:x")`. Returns `undefined` otherwise.
|
|
21
21
|
*/
|
|
22
22
|
export declare function resolveNodeToStackEnv<Info>(node: RNode<Info> | undefined, data: StackEnvContext): REnvironmentInformation | undefined;
|
|
23
|
-
/**
|
|
23
|
+
/** The stack environment `sourceInfo`'s entry call refers to (`e <- globalenv()`, `e <- environment()`), or `undefined`. */
|
|
24
24
|
export declare function stackEnvStateFromSource(sourceInfo: DataflowInformation, data: StackEnvContext): REnvironmentInformation | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a `$`/`[[` on the stack env `node` denotes reads through the enclosing scopes.
|
|
27
|
+
* Only the rlang pronoun `.env` does: it names the surrounding scope, while `$` on a real environment stays in its frame.
|
|
28
|
+
*/
|
|
29
|
+
export declare function stackEnvInheritsFields<Info>(node: RNode<Info> | undefined): boolean;
|
|
25
30
|
export {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processStackEnv = processStackEnv;
|
|
4
4
|
exports.resolveNodeToStackEnv = resolveNodeToStackEnv;
|
|
5
5
|
exports.stackEnvStateFromSource = stackEnvStateFromSource;
|
|
6
|
+
exports.stackEnvInheritsFields = stackEnvInheritsFields;
|
|
6
7
|
const known_call_handling_1 = require("../known-call-handling");
|
|
7
8
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
8
9
|
const environment_1 = require("../../../../../environments/environment");
|
|
@@ -10,6 +11,8 @@ const vertex_1 = require("../../../../../graph/vertex");
|
|
|
10
11
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
11
12
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
12
13
|
const default_builtin_config_1 = require("../../../../../environments/default-builtin-config");
|
|
14
|
+
/** The rlang pronoun for the scope surrounding a data mask. */
|
|
15
|
+
const EnvPronoun = '.env';
|
|
13
16
|
/** The stack env kind a builtin/constant `name` denotes, or `undefined`. */
|
|
14
17
|
function stackEnvKind(name) {
|
|
15
18
|
return default_builtin_config_1.StackEnvBuiltins[name];
|
|
@@ -85,12 +88,26 @@ function asSearchPathEnv(name, data) {
|
|
|
85
88
|
}
|
|
86
89
|
return undefined;
|
|
87
90
|
}
|
|
88
|
-
/**
|
|
91
|
+
/** The stack environment `sourceInfo`'s entry call refers to (`e <- globalenv()`, `e <- environment()`), or `undefined`. */
|
|
89
92
|
function stackEnvStateFromSource(sourceInfo, data) {
|
|
90
93
|
const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
|
|
91
|
-
if (!vertex_1.FunctionCallVertex.is(vertex) || vertex.name === undefined
|
|
94
|
+
if (!vertex_1.FunctionCallVertex.is(vertex) || vertex.name === undefined) {
|
|
92
95
|
return undefined;
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
const kind = stackEnvKind(String(vertex.name));
|
|
98
|
+
if (vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.StackEnv)) {
|
|
99
|
+
return fixedStackEnv(kind, data);
|
|
100
|
+
}
|
|
101
|
+
/* `environment()` goes through the default processor; with an argument it denotes a closure's env instead */
|
|
102
|
+
return kind === default_builtin_config_1.StackEnvKind.Current && vertex.args.length === 0 && vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Default)
|
|
103
|
+
? { current: data.environment.current, level: data.environment.level }
|
|
104
|
+
: undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether a `$`/`[[` on the stack env `node` denotes reads through the enclosing scopes.
|
|
108
|
+
* Only the rlang pronoun `.env` does: it names the surrounding scope, while `$` on a real environment stays in its frame.
|
|
109
|
+
*/
|
|
110
|
+
function stackEnvInheritsFields(node) {
|
|
111
|
+
return node?.type === type_1.RType.Symbol && String(node.content) === EnvPronoun;
|
|
95
112
|
}
|
|
96
113
|
//# sourceMappingURL=built-in-stack-env.js.map
|