@eagleoutice/flowr 2.15.9 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -41
- package/abstract-interpretation/absint-inference.d.ts +2 -2
- package/abstract-interpretation/absint-inference.js +32 -79
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/benchmark/slicer.d.ts +0 -1
- package/benchmark/slicer.js +1 -2
- package/cli/repl/commands/repl-signature.js +12 -3
- package/config.d.ts +5 -1
- package/control-flow/cfg-properties.js +0 -22
- package/control-flow/happens-before.d.ts +7 -2
- package/control-flow/happens-before.js +55 -31
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/apply-kill.js +6 -2
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-props.d.ts +16 -1
- package/dataflow/environments/built-in-props.js +33 -20
- package/dataflow/environments/built-in.d.ts +8 -3
- package/dataflow/environments/built-in.js +52 -82
- package/dataflow/environments/default-builtin-config.d.ts +551 -21
- package/dataflow/environments/default-builtin-config.js +121 -45
- package/dataflow/environments/define.d.ts +3 -2
- package/dataflow/environments/define.js +4 -3
- package/dataflow/environments/deprecation-info.d.ts +45 -0
- package/dataflow/environments/deprecation-info.js +13 -0
- package/dataflow/environments/environment.d.ts +7 -5
- package/dataflow/environments/environment.js +55 -121
- package/dataflow/environments/identifier.d.ts +6 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +180 -58
- package/dataflow/fn/class-declaration.d.ts +8 -13
- package/dataflow/fn/class-declaration.js +95 -116
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.d.ts +9 -1
- package/dataflow/fn/higher-order-function.js +27 -24
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +291 -123
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +13 -1
- package/dataflow/graph/graph.js +74 -66
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +17 -8
- package/dataflow/internal/linker.js +286 -213
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +4 -4
- package/dataflow/internal/process/functions/call/common.js +49 -71
- package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
- package/dataflow/internal/process/functions/call/deferred.js +81 -63
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +257 -154
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +4 -3
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/data/faq/faqs.js +3 -3
- package/documentation/data/interface/doc-writing-code.js +1 -2
- package/documentation/data/server/doc-data-server-messages.js +7 -7
- package/documentation/doc-capabilities.js +80 -34
- package/documentation/doc-util/doc-query.d.ts +0 -3
- package/documentation/doc-util/doc-query.js +4 -3
- package/documentation/wiki-analyzer.js +1 -1
- package/documentation/wiki-cfg.js +5 -6
- package/documentation/wiki-core.js +8 -8
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linting-and-testing.js +3 -3
- package/documentation/wiki-overview.js +6 -6
- package/documentation/wiki-query.js +9 -101
- package/documentation/wiki-setup.js +23 -0
- package/documentation/wiki-signature-database.js +1 -1
- package/linter/linter-rules.d.ts +18 -9
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/deprecated-functions.d.ts +1 -45
- package/linter/rules/deprecated-functions.js +24 -33
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.d.ts +2 -0
- package/project/flowr-analyzer.js +28 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
- package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +4 -0
- package/project/sigdb/manifest.d.ts +2 -0
- package/project/sigdb/manifest.js +10 -1
- package/project/sigdb/reader.js +23 -61
- package/project/sigdb/sigdb-download.d.ts +29 -6
- package/project/sigdb/sigdb-download.js +212 -64
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
- package/queries/catalog/call-context-query/cascade-action.js +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/data/data.d.ts +21 -14
- package/r-bridge/data/data.js +28 -20
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +2 -0
- package/util/files.js +3 -1
- package/util/mermaid/mermaid.js +6 -2
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withAppliedCds = withAppliedCds;
|
|
4
|
+
exports.applyCdsToDefinitions = applyCdsToDefinitions;
|
|
4
5
|
exports.makeReferenceMaybe = makeReferenceMaybe;
|
|
5
6
|
exports.makeAllMaybe = makeAllMaybe;
|
|
6
7
|
exports.applyCdsToAllInGraphButConstants = applyCdsToAllInGraphButConstants;
|
|
@@ -29,22 +30,16 @@ function replaceDefinitions(env, key, toUpdate, defaultCd) {
|
|
|
29
30
|
* environments (e.g., snapshots stored in the dataflow graph) keep their state.
|
|
30
31
|
*/
|
|
31
32
|
function applyCdsToDefinitions(environments, name, type, definitions, nodeId, defaultCd) {
|
|
32
|
-
const toUpdate = new Set(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
&& definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant
|
|
36
|
-
&& (defaultCd !== undefined || definition.cds === undefined)) {
|
|
37
|
-
toUpdate.add(definition);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
33
|
+
const toUpdate = new Set(definitions.filter(definition => definition.nodeId === nodeId
|
|
34
|
+
&& definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant
|
|
35
|
+
&& (defaultCd !== undefined || definition.cds === undefined)));
|
|
40
36
|
if (toUpdate.size === 0) {
|
|
41
37
|
return;
|
|
42
38
|
}
|
|
43
39
|
const [plainName] = identifier_1.Identifier.toArray(name);
|
|
44
40
|
const prefix = type === identifier_1.ReferenceType.S3MethodPrefix ? plainName + '.'
|
|
45
41
|
: type === identifier_1.ReferenceType.S7MethodPrefix ? plainName + built_in_s_seven_dispatch_1.S7DispatchSeparator : undefined;
|
|
46
|
-
let current = environments.current;
|
|
47
|
-
while (!current.builtInEnv) {
|
|
42
|
+
for (let current = environments.current; !current.builtInEnv; current = current.parent) {
|
|
48
43
|
if (prefix === undefined) {
|
|
49
44
|
replaceDefinitions(current, plainName, toUpdate, defaultCd);
|
|
50
45
|
}
|
|
@@ -55,7 +50,14 @@ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, de
|
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function addCds(target, cds) {
|
|
56
|
+
if (target.cds) {
|
|
57
|
+
(0, info_1.appendCds)(target.cds, cds);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
target.cds = cds ? Array.from(cds) : [];
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
@@ -72,70 +74,40 @@ function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = u
|
|
|
72
74
|
}
|
|
73
75
|
const node = graph.getVertex(ref.nodeId);
|
|
74
76
|
if (node) {
|
|
75
|
-
|
|
76
|
-
(0, info_1.appendCds)(node.cds, defaultCd);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
node.cds = defaultCd ? Array.from(defaultCd) : [];
|
|
80
|
-
}
|
|
77
|
+
addCds(node, defaultCd);
|
|
81
78
|
}
|
|
82
|
-
if (ref.cds) {
|
|
83
|
-
if (defaultCd) {
|
|
84
|
-
return { ...ref, cds: (0, info_1.withCds)(ref.cds, defaultCd) };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
79
|
+
if (ref.cds === undefined) {
|
|
88
80
|
return { ...ref, cds: defaultCd ? Array.from(defaultCd) : [] };
|
|
89
81
|
}
|
|
90
|
-
return ref;
|
|
82
|
+
return defaultCd ? { ...ref, cds: (0, info_1.withCds)(ref.cds, defaultCd) } : ref;
|
|
91
83
|
}
|
|
92
84
|
/**
|
|
93
85
|
* Marks all references as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
|
|
94
86
|
* @see {@link makeReferenceMaybe}
|
|
95
87
|
*/
|
|
96
88
|
function makeAllMaybe(references, graph, environments, includeDefs, applyCds = undefined) {
|
|
97
|
-
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
return references.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, applyCds));
|
|
89
|
+
return references?.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, applyCds)) ?? [];
|
|
101
90
|
}
|
|
102
91
|
/**
|
|
103
92
|
* apply the given cds to all elements in the graph and also transform the given references similar to {@link makeAllMaybe}.
|
|
104
93
|
*/
|
|
105
94
|
function applyCdsToAllInGraphButConstants(graph, references, cds) {
|
|
106
95
|
for (const [, v] of graph.vertices(true)) {
|
|
107
|
-
if (vertex_1.DfgVertex.isValue(v)) {
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
if (v.cds) {
|
|
111
|
-
(0, info_1.appendCds)(v.cds, cds);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
v.cds = Array.from(cds);
|
|
96
|
+
if (!vertex_1.DfgVertex.isValue(v)) {
|
|
97
|
+
addCds(v, cds);
|
|
115
98
|
}
|
|
116
99
|
}
|
|
117
100
|
for (const ref of references) {
|
|
118
|
-
|
|
119
|
-
(0, info_1.appendCds)(ref.cds, cds);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
ref.cds = Array.from(cds);
|
|
123
|
-
}
|
|
101
|
+
addCds(ref, cds);
|
|
124
102
|
}
|
|
125
103
|
}
|
|
126
104
|
/**
|
|
127
105
|
* apply the given cds to all given references, but not to the graph. This is useful if we want to mark the references as maybe without marking all other nodes in the graph as maybe.
|
|
128
106
|
*/
|
|
129
107
|
function applyCdToReferences(references, cds) {
|
|
130
|
-
if (cds.length
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
for (const ref of references) {
|
|
134
|
-
if (ref.cds) {
|
|
135
|
-
(0, info_1.appendCds)(ref.cds, cds);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
ref.cds = Array.from(cds);
|
|
108
|
+
if (cds.length > 0) {
|
|
109
|
+
for (const ref of references) {
|
|
110
|
+
addCds(ref, cds);
|
|
139
111
|
}
|
|
140
112
|
}
|
|
141
113
|
}
|
|
@@ -14,10 +14,7 @@ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id"
|
|
|
14
14
|
const TailCacheCap = 4096;
|
|
15
15
|
/** A namespaced lookup only sees its matching layer; a bare lookup skips loaded-but-unattached namespaces (`requireNamespace`). */
|
|
16
16
|
function layerSkipped(layer, ns) {
|
|
17
|
-
|
|
18
|
-
return layer.n !== ns;
|
|
19
|
-
}
|
|
20
|
-
return layer.t === environment_1.EnvType.LoadedNamespace;
|
|
17
|
+
return ns !== undefined ? layer.n !== ns : layer.t === environment_1.EnvType.LoadedNamespace;
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
20
|
* What the built-in environment states about `pkg::name` for a package nothing attached: `pkg::fn` reaches its
|
|
@@ -34,7 +31,6 @@ const BuiltInFunctionTargetTypes = identifier_1.ReferenceType.BuiltInFunction |
|
|
|
34
31
|
const NonFunctionTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument | identifier_1.ReferenceType.Unknown
|
|
35
32
|
| identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant;
|
|
36
33
|
const inEveryBranch = (d) => (0, info_1.happensInEveryBranch)(d.cds);
|
|
37
|
-
const notAParameter = (d) => d.type !== identifier_1.ReferenceType.Parameter;
|
|
38
34
|
const TargetTypePredicate = {
|
|
39
35
|
[identifier_1.ReferenceType.Unknown]: () => true,
|
|
40
36
|
[identifier_1.ReferenceType.Function]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
|
|
@@ -77,6 +73,14 @@ function resolveByName(id, environment, target) {
|
|
|
77
73
|
const found = resolveByTargetType(id, environment, target);
|
|
78
74
|
return found === undefined && target === identifier_1.ReferenceType.NonFunction ? ownDefinitions(id, environment) : found;
|
|
79
75
|
}
|
|
76
|
+
function tailCacheOf(env, target) {
|
|
77
|
+
env.tailCache ??= new Map();
|
|
78
|
+
let memo = env.tailCache.get(target);
|
|
79
|
+
if (memo === undefined) {
|
|
80
|
+
env.tailCache.set(target, memo = new Map());
|
|
81
|
+
}
|
|
82
|
+
return memo;
|
|
83
|
+
}
|
|
80
84
|
/** {@link resolveByName} without its two special targets, i.e. the plain walk up the environments. */
|
|
81
85
|
function resolveByTargetType(id, environment, target) {
|
|
82
86
|
/* read piecewise, `Identifier.toArray` would allocate a tuple per resolution */
|
|
@@ -95,12 +99,12 @@ function resolveByTargetType(id, environment, target) {
|
|
|
95
99
|
* walk through them is done once per name and target instead of once per resolution */
|
|
96
100
|
const flatten = ns === undefined && internal !== false && typeof id === 'string'
|
|
97
101
|
&& target !== identifier_1.ReferenceType.S3MethodPrefix && target !== identifier_1.ReferenceType.S7MethodPrefix;
|
|
98
|
-
const key = flatten ? `${target}\u0000${name}` : '';
|
|
99
102
|
let flattenAt;
|
|
100
103
|
do {
|
|
101
104
|
if (flatten && flattenAt === undefined && definitions === undefined && (current.t !== undefined || current.builtInEnv)) {
|
|
102
|
-
const
|
|
103
|
-
|
|
105
|
+
const memo = current.tailCache?.get(target);
|
|
106
|
+
const cached = memo?.get(name);
|
|
107
|
+
if (cached !== undefined || memo?.has(name)) {
|
|
104
108
|
return cached;
|
|
105
109
|
}
|
|
106
110
|
flattenAt = current;
|
|
@@ -113,13 +117,7 @@ function resolveByTargetType(id, environment, target) {
|
|
|
113
117
|
if (target === identifier_1.ReferenceType.S3MethodPrefix || target === identifier_1.ReferenceType.S7MethodPrefix) {
|
|
114
118
|
// S3 method prefixes only resolve to functions, S3s must not match the exported criteria!
|
|
115
119
|
const prefix = name + (target === identifier_1.ReferenceType.S3MethodPrefix ? '.' : built_in_s_seven_dispatch_1.S7DispatchSeparator);
|
|
116
|
-
|
|
117
|
-
for (const defName of current.memory.keys()) {
|
|
118
|
-
if (defName.startsWith(prefix)) {
|
|
119
|
-
hits.push(...current.memory.get(defName) ?? []);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
definition = hits;
|
|
120
|
+
definition = current.memory.entries().filter(([defName]) => defName.startsWith(prefix)).flatMap(([, defs]) => defs).toArray();
|
|
123
121
|
}
|
|
124
122
|
else {
|
|
125
123
|
definition = current.lookup(name);
|
|
@@ -138,25 +136,19 @@ function resolveByTargetType(id, environment, target) {
|
|
|
138
136
|
allOk = false;
|
|
139
137
|
break;
|
|
140
138
|
}
|
|
141
|
-
if (allOk && ((checkParameters &&
|
|
139
|
+
if (allOk && ((checkParameters && def.type === identifier_1.ReferenceType.Parameter) || !inEveryBranch(def))) {
|
|
142
140
|
allOk = false;
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
143
|
if (allOk) {
|
|
146
144
|
if (flattenAt !== undefined) {
|
|
147
|
-
(flattenAt
|
|
145
|
+
tailCacheOf(flattenAt, target).set(name, definition);
|
|
148
146
|
}
|
|
149
147
|
return definition;
|
|
150
148
|
}
|
|
151
|
-
|
|
152
|
-
const filtered = allWanted ? definition.slice() : definition.filter(wantedType);
|
|
149
|
+
const filtered = allWanted ? definition : definition.filter(wantedType);
|
|
153
150
|
if (filtered.length > 0) {
|
|
154
|
-
|
|
155
|
-
definitions.push(...filtered);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
definitions = filtered;
|
|
159
|
-
}
|
|
151
|
+
(definitions ??= []).push(...filtered);
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
154
|
current = current.parent;
|
|
@@ -169,11 +161,11 @@ function resolveByTargetType(id, environment, target) {
|
|
|
169
161
|
? (builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns))
|
|
170
162
|
: (builtIns === undefined || builtIns.length > 0 ? builtIns : undefined);
|
|
171
163
|
if (flattenAt !== undefined) {
|
|
172
|
-
const memo = flattenAt
|
|
164
|
+
const memo = tailCacheOf(flattenAt, target);
|
|
173
165
|
if (memo.size >= TailCacheCap) {
|
|
174
166
|
memo.clear();
|
|
175
167
|
}
|
|
176
|
-
memo.set(
|
|
168
|
+
memo.set(name, result);
|
|
177
169
|
}
|
|
178
170
|
return result;
|
|
179
171
|
}
|
|
@@ -184,25 +176,19 @@ function resolveByTargetType(id, environment, target) {
|
|
|
184
176
|
function resolveByNameAnyType(id, environment) {
|
|
185
177
|
let current = environment.current;
|
|
186
178
|
/* only cache plain names: namespaced ids are arrays (no stable map key) and must not answer plain lookups */
|
|
187
|
-
|
|
188
|
-
if (cacheable) {
|
|
179
|
+
if (typeof id === 'string') {
|
|
189
180
|
const g = current.cache?.get(id);
|
|
190
181
|
if (g !== undefined) {
|
|
191
182
|
return g;
|
|
192
183
|
}
|
|
193
184
|
}
|
|
194
185
|
const name = identifier_1.Identifier.getName(id);
|
|
195
|
-
const ns = identifier_1.Identifier.getNamespace(id);
|
|
196
|
-
const internal = identifier_1.Identifier.accessesInternal(id);
|
|
197
186
|
/* `current` can already be the built-in environment itself */
|
|
198
187
|
if (current.builtInEnv) {
|
|
199
|
-
|
|
200
|
-
if (ret && cacheable) {
|
|
201
|
-
current.cache ??= new Map();
|
|
202
|
-
current.cache.set(id, ret);
|
|
203
|
-
}
|
|
204
|
-
return ret;
|
|
188
|
+
return remember(environment, id, current.lookup(name));
|
|
205
189
|
}
|
|
190
|
+
const ns = identifier_1.Identifier.getNamespace(id);
|
|
191
|
+
const internal = identifier_1.Identifier.accessesInternal(id);
|
|
206
192
|
let definitions = undefined;
|
|
207
193
|
do {
|
|
208
194
|
if (layerSkipped(current, ns)) {
|
|
@@ -215,36 +201,25 @@ function resolveByNameAnyType(id, environment) {
|
|
|
215
201
|
definition = definition.filter(({ name }) => name === undefined || !identifier_1.Identifier.accessesInternal(name));
|
|
216
202
|
}
|
|
217
203
|
if (definition.every(inEveryBranch)) {
|
|
218
|
-
|
|
219
|
-
environment.current.cache ??= new Map();
|
|
220
|
-
environment.current.cache.set(id, definition);
|
|
221
|
-
}
|
|
222
|
-
return definition;
|
|
204
|
+
return remember(environment, id, definition);
|
|
223
205
|
}
|
|
224
206
|
else if (definition.length > 0) {
|
|
225
|
-
|
|
226
|
-
definitions = definitions.concat(definition);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
definitions = definition;
|
|
230
|
-
}
|
|
207
|
+
definitions = definitions ? definitions.concat(definition) : definition;
|
|
231
208
|
}
|
|
232
209
|
}
|
|
233
210
|
current = current.parent;
|
|
234
211
|
} while (!current.builtInEnv);
|
|
235
212
|
const builtIns = statedIn(current, name, ns) ?? current.lookup(name);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
ret = builtIns === undefined ? definitions : definitions.concat(builtIns);
|
|
213
|
+
if (definitions === undefined) {
|
|
214
|
+
return remember(environment, id, builtIns);
|
|
239
215
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
environment.current.cache ??= new Map();
|
|
245
|
-
environment.current.cache.set(id, ret);
|
|
216
|
+
return remember(environment, id, builtIns === undefined ? definitions : definitions.concat(builtIns));
|
|
217
|
+
}
|
|
218
|
+
function remember(environment, id, definitions) {
|
|
219
|
+
if (definitions !== undefined && typeof id === 'string') {
|
|
220
|
+
(environment.current.cache ??= new Map()).set(id, definitions);
|
|
246
221
|
}
|
|
247
|
-
return
|
|
222
|
+
return definitions;
|
|
248
223
|
}
|
|
249
224
|
/**
|
|
250
225
|
* Whether every definition `name` may refer to is the built-in one (or there is none), i.e., the name is not
|
|
@@ -266,28 +241,14 @@ function resolvesToBuiltIn(name, environment, target) {
|
|
|
266
241
|
* @useInstead {@link Resolve.toBuiltIn}
|
|
267
242
|
*/
|
|
268
243
|
function resolvesToBuiltInConstant(name, environment, wantedValue) {
|
|
269
|
-
|
|
270
|
-
return logic_1.Ternary.Never;
|
|
271
|
-
}
|
|
272
|
-
const definition = resolveByName(name, environment, identifier_1.ReferenceType.Constant);
|
|
244
|
+
const definition = name === undefined ? undefined : resolveByName(name, environment, identifier_1.ReferenceType.Constant);
|
|
273
245
|
if (definition === undefined) {
|
|
274
246
|
return logic_1.Ternary.Never;
|
|
275
247
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
for (const def of definition) {
|
|
279
|
-
if (def.type === identifier_1.ReferenceType.BuiltInConstant && def.value === wantedValue) {
|
|
280
|
-
some = true;
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
all = false;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (all) {
|
|
248
|
+
const isWanted = (def) => def.type === identifier_1.ReferenceType.BuiltInConstant && def.value === wantedValue;
|
|
249
|
+
if (definition.every(isWanted)) {
|
|
287
250
|
return logic_1.Ternary.Always;
|
|
288
251
|
}
|
|
289
|
-
|
|
290
|
-
return some ? logic_1.Ternary.Maybe : logic_1.Ternary.Never;
|
|
291
|
-
}
|
|
252
|
+
return definition.some(isWanted) ? logic_1.Ternary.Maybe : logic_1.Ternary.Never;
|
|
292
253
|
}
|
|
293
254
|
//# sourceMappingURL=resolve-by-name.js.map
|
|
@@ -3,7 +3,9 @@ import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
|
|
|
3
3
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { VariableResolve } from '../../../config';
|
|
5
5
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
6
|
+
/** The index of the argument of `vertex` that binds the formal `argumentName`, R's matching when the formals are known and the `argumentIndex`-th unnamed argument otherwise. */
|
|
7
|
+
export declare function boundArgumentIndex<Idx extends number | 'unnamed' | undefined>(graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: Idx, argumentName: string, ctx: ReadOnlyFlowrAnalyzerContext): Idx | number;
|
|
6
8
|
/**
|
|
7
|
-
* Get the values of all arguments matching the criteria.
|
|
9
|
+
* Get the values of all arguments matching the criteria, keyed by the id of the argument.
|
|
8
10
|
*/
|
|
9
11
|
export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined, ctx: ReadOnlyFlowrAnalyzerContext): Map<NodeId, Set<string | undefined>> | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.boundArgumentIndex = boundArgumentIndex;
|
|
3
4
|
exports.getArgumentStringValue = getArgumentStringValue;
|
|
4
5
|
const graph_1 = require("../../graph/graph");
|
|
5
6
|
const r_value_1 = require("../values/r-value");
|
|
6
7
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
|
+
const match_args_1 = require("../../graph/match-args");
|
|
7
9
|
const assert_1 = require("../../../util/assert");
|
|
8
10
|
const vertex_1 = require("../../graph/vertex");
|
|
9
11
|
const edge_1 = require("../../graph/edge");
|
|
@@ -19,51 +21,65 @@ const string_constants_1 = require("../values/string/string-constants");
|
|
|
19
21
|
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
20
22
|
const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
21
23
|
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
24
|
+
/** The index of the argument of `vertex` that binds the formal `argumentName`, R's matching when the formals are known and the `argumentIndex`-th unnamed argument otherwise. */
|
|
25
|
+
function boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx) {
|
|
26
|
+
const call = graph.idMap?.get(vertex.id);
|
|
27
|
+
const formals = r_function_call_1.RFunctionCall.is(call) ? match_args_1.MatchArgs.formalsOf(call, graph, ctx) : undefined;
|
|
28
|
+
if (formals?.includes(argumentName)) {
|
|
29
|
+
const bound = match_args_1.MatchArgs.toSpec(vertex.args, Object.fromEntries(formals.map(f => [f, f]))).get(argumentName)?.[0];
|
|
30
|
+
return bound === undefined ? vertex.args.length : vertex.args.findIndex(a => a !== r_function_call_1.EmptyArgument && a.nodeId === bound);
|
|
31
|
+
}
|
|
32
|
+
const arg = vertex.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && arg.name === argumentName);
|
|
33
|
+
if (arg >= 0) {
|
|
34
|
+
return arg;
|
|
35
|
+
}
|
|
36
|
+
else if (typeof argumentIndex === 'number') {
|
|
37
|
+
/* a named argument takes no position, so the parameter binds the matching unnamed one */
|
|
38
|
+
const unnamed = vertex.args.flatMap((a, i) => a === r_function_call_1.EmptyArgument || !a.name ? [i] : []);
|
|
39
|
+
return unnamed[argumentIndex] ?? vertex.args.length;
|
|
40
|
+
}
|
|
41
|
+
return argumentIndex;
|
|
42
|
+
}
|
|
22
43
|
/**
|
|
23
|
-
* Get the values of all arguments matching the criteria.
|
|
44
|
+
* Get the values of all arguments matching the criteria, keyed by the id of the argument.
|
|
24
45
|
*/
|
|
25
46
|
function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx) {
|
|
26
|
-
if (argumentName) {
|
|
27
|
-
|
|
28
|
-
if (arg >= 0) {
|
|
29
|
-
argumentIndex = arg;
|
|
30
|
-
}
|
|
47
|
+
if (argumentName && argumentIndex !== 'unnamed') {
|
|
48
|
+
argumentIndex = boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx);
|
|
31
49
|
}
|
|
32
|
-
if (
|
|
50
|
+
if (argumentIndex === undefined) {
|
|
33
51
|
return undefined;
|
|
34
52
|
}
|
|
35
53
|
if (argumentIndex === 'unnamed') {
|
|
36
|
-
// return all unnamed arguments
|
|
37
|
-
const references = vertex.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference).filter(assert_1.isNotUndefined);
|
|
38
54
|
const map = new Map();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
|
|
55
|
+
/* all unnamed arguments, and the one named `argumentName`, which is evaluated rather than taken as a name */
|
|
56
|
+
for (const arg of vertex.args) {
|
|
57
|
+
if (arg === r_function_call_1.EmptyArgument || (arg.name && arg.name !== argumentName)) {
|
|
58
|
+
continue;
|
|
43
59
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
const ref = graph_1.FunctionArgument.getReference(arg);
|
|
61
|
+
const resolveAs = graph_1.FunctionArgument.isNamed(arg) && resolveValue === 'library' ? true : resolveValue;
|
|
62
|
+
const values = argumentValues(variableResolve, graph, vertex, ref, resolveAs, ctx);
|
|
63
|
+
if (ref !== undefined && values !== undefined) {
|
|
64
|
+
map.set(ref, values);
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
67
|
return map;
|
|
51
68
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (valueNode) {
|
|
62
|
-
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue, ctx) ?? openedResourceOf(variableResolve, graph, valueNode.info.id, ctx) ?? [dependencies_query_format_1.Unknown];
|
|
63
|
-
return new Map([[arg, new Set(values)]]);
|
|
64
|
-
}
|
|
69
|
+
const ref = argumentIndex < vertex.args.length ? graph_1.FunctionArgument.getReference(vertex.args[argumentIndex]) : undefined;
|
|
70
|
+
const values = argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx);
|
|
71
|
+
return ref === undefined || values === undefined ? undefined : new Map([[ref, values]]);
|
|
72
|
+
}
|
|
73
|
+
/** The values of the argument `ref` passes to `vertex`, falling back to the resource a call it reads from opens, and to {@link Unknown}. */
|
|
74
|
+
function argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx) {
|
|
75
|
+
const valueNode = ref === undefined ? undefined : r_argument_1.RArgument.valueOf(graph.idMap?.get(ref));
|
|
76
|
+
if (valueNode === undefined) {
|
|
77
|
+
return undefined;
|
|
65
78
|
}
|
|
66
|
-
|
|
79
|
+
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, resolveValue, ctx)
|
|
80
|
+
?? openedResourceOf(variableResolve, graph, valueNode.info.id, ctx)
|
|
81
|
+
?? [dependencies_query_format_1.Unknown];
|
|
82
|
+
return new Set(values);
|
|
67
83
|
}
|
|
68
84
|
function openedResourceOf(variableResolve, graph, argument, ctx) {
|
|
69
85
|
for (const id of df_helper_1.Dataflow.provenance(argument, graph, undefined, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall)) {
|
|
@@ -78,8 +94,8 @@ function openedResourceOf(variableResolve, graph, argument, ctx) {
|
|
|
78
94
|
}
|
|
79
95
|
return undefined;
|
|
80
96
|
}
|
|
81
|
-
function hasCharacterOnly(variableResolve, graph, vertex,
|
|
82
|
-
if (
|
|
97
|
+
function hasCharacterOnly(variableResolve, graph, vertex, ctx) {
|
|
98
|
+
if (vertex.args.length === 0 || !graph.idMap) {
|
|
83
99
|
return false;
|
|
84
100
|
}
|
|
85
101
|
const treatAsChar = getArgumentStringValue(variableResolve, graph, vertex, 5, 'character.only', true, ctx);
|
|
@@ -87,40 +103,21 @@ function hasCharacterOnly(variableResolve, graph, vertex, idMap, ctx) {
|
|
|
87
103
|
return false;
|
|
88
104
|
}
|
|
89
105
|
const hasTrue = treatAsChar.values().some(set => set?.has('TRUE'));
|
|
90
|
-
const hasFalse = hasTrue
|
|
91
|
-
|
|
92
|
-
return 'maybe';
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
return hasTrue;
|
|
96
|
-
}
|
|
106
|
+
const hasFalse = hasTrue && treatAsChar.values().some(set => set === undefined || set.has('FALSE'));
|
|
107
|
+
return hasTrue && hasFalse ? 'maybe' : hasTrue;
|
|
97
108
|
}
|
|
98
|
-
function resolveBasedOnConfig(variableResolve, graph, vertex, argument,
|
|
99
|
-
let full =
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (resolveValue === 'library') {
|
|
104
|
-
const hasChar = hasCharacterOnly(variableResolve, graph, vertex, idMap, ctx);
|
|
105
|
-
if (hasChar === false) {
|
|
106
|
-
if (r_symbol_1.RSymbol.is(argument)) {
|
|
107
|
-
return [argument.lexeme];
|
|
108
|
-
}
|
|
109
|
-
full = false;
|
|
109
|
+
function resolveBasedOnConfig(variableResolve, graph, vertex, argument, resolveValue, ctx) {
|
|
110
|
+
let full = !!resolveValue;
|
|
111
|
+
if (resolveValue === 'library' && hasCharacterOnly(variableResolve, graph, vertex, ctx) === false) {
|
|
112
|
+
if (r_symbol_1.RSymbol.is(argument)) {
|
|
113
|
+
return [argument.lexeme];
|
|
110
114
|
}
|
|
115
|
+
full = false;
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const strings = (0, r_value_2.isValue)(value) ? stringsOfValue(value, full) : undefined;
|
|
117
|
-
if (strings === undefined) {
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
values.push(...strings);
|
|
121
|
-
}
|
|
122
|
-
return values;
|
|
123
|
-
}
|
|
117
|
+
// this should be evaluated in the callee-context
|
|
118
|
+
const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(argument, { environment: vertex.environment, graph, full, resolve: variableResolve, ctx }));
|
|
119
|
+
const strings = resolved?.elements.map(value => (0, r_value_2.isValue)(value) ? stringsOfValue(value, full) : undefined);
|
|
120
|
+
return strings?.every(assert_1.isNotUndefined) ? strings.flat() : undefined;
|
|
124
121
|
}
|
|
125
122
|
/**
|
|
126
123
|
* The strings a resolved value stands for. A value that is no string is data given inline and hence reported as
|
|
@@ -17,13 +17,19 @@ export interface WorkingDirectoryResolution {
|
|
|
17
17
|
readonly certain: boolean;
|
|
18
18
|
}
|
|
19
19
|
type Guards = readonly ControlDependency[];
|
|
20
|
+
/** apply one `setwd(dir)`: an absolute (or `~`-rooted) `dir` replaces `current`, a relative `dir` joins onto it */
|
|
21
|
+
declare function applyChange(current: string, dir: string): string;
|
|
20
22
|
declare function resolveAt(target: NodeId, targetCds: Guards, baseWd: string, changes: readonly WorkingDirectoryChange[], cfg: ControlFlowGraph): WorkingDirectoryResolution;
|
|
21
23
|
declare function collect(graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): WorkingDirectoryChange[];
|
|
22
24
|
/** Resolve R's process-global working directory (sensitive to `setwd`) at a program point; path-sensitive, unbounded rather than wrong under loops/functions. */
|
|
23
25
|
export declare const WorkingDirectory: {
|
|
24
26
|
readonly collect: typeof collect;
|
|
25
27
|
readonly resolveAt: typeof resolveAt;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
readonly applyChange: typeof applyChange;
|
|
29
|
+
/** reusable `(callId, scriptFile?) => candidate roots`, collecting the changes once for the whole graph; `pinned` when a `setwd` decides them */
|
|
30
|
+
readonly rootsResolver: (graph: DataflowGraph, cfg: ControlFlowGraph, ctx: ReadOnlyFlowrAnalyzerContext) => (id: NodeId, file?: string) => {
|
|
31
|
+
roots: readonly string[];
|
|
32
|
+
pinned: boolean;
|
|
33
|
+
};
|
|
28
34
|
};
|
|
29
35
|
export {};
|
|
@@ -10,10 +10,11 @@ const dependencies_query_format_1 = require("../../../queries/catalog/dependenci
|
|
|
10
10
|
const strings_1 = require("../../../util/text/strings");
|
|
11
11
|
const info_1 = require("../../info");
|
|
12
12
|
const edge_1 = require("../../graph/edge");
|
|
13
|
+
const frame_reflection_1 = require("../../fn/frame-reflection");
|
|
14
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
13
15
|
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
14
16
|
const files_1 = require("../../../util/files");
|
|
15
17
|
const built_in_source_1 = require("../../internal/process/functions/call/built-in/built-in-source");
|
|
16
|
-
const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
17
18
|
const arrays_1 = require("../../../util/collections/arrays");
|
|
18
19
|
/** functions recognized as changing the working directory; a registry so more (e.g. `withr::with_dir`) can be added */
|
|
19
20
|
const ChangeFunctions = [
|
|
@@ -21,9 +22,6 @@ const ChangeFunctions = [
|
|
|
21
22
|
];
|
|
22
23
|
const CandidateCap = 64;
|
|
23
24
|
function matchSpec(name) {
|
|
24
|
-
if (name === undefined) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
25
|
const bare = identifier_1.Identifier.getName(name);
|
|
28
26
|
const ns = identifier_1.Identifier.getNamespace(name);
|
|
29
27
|
return ChangeFunctions.find(s => s.name === bare && (ns === undefined || ns === s.namespace));
|
|
@@ -36,7 +34,7 @@ function applyChange(current, dir) {
|
|
|
36
34
|
return isAbsoluteDir(dir) ? files_1.RPath.normalize(dir) : files_1.RPath.join(current, dir);
|
|
37
35
|
}
|
|
38
36
|
function guardIn(g, set) {
|
|
39
|
-
return set.some(b =>
|
|
37
|
+
return set.some(b => info_1.ControlDependency.same(b, g));
|
|
40
38
|
}
|
|
41
39
|
function subsumed(inner, outer) {
|
|
42
40
|
return inner.every(g => guardIn(g, outer));
|
|
@@ -64,15 +62,7 @@ function topoOrder(changes, cfg) {
|
|
|
64
62
|
return result;
|
|
65
63
|
}
|
|
66
64
|
function enclosingFunction(idMap, id) {
|
|
67
|
-
|
|
68
|
-
while (cursor !== undefined) {
|
|
69
|
-
const node = idMap?.get(cursor);
|
|
70
|
-
if (r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
71
|
-
return node.info.id;
|
|
72
|
-
}
|
|
73
|
-
cursor = node?.info.parent;
|
|
74
|
-
}
|
|
75
|
-
return undefined;
|
|
65
|
+
return idMap === undefined ? undefined : model_1.RNode.strictlyEnclosingFunction(id, idMap);
|
|
76
66
|
}
|
|
77
67
|
function isIterated(cds, idMap) {
|
|
78
68
|
return cds.some(cd => info_1.ControlDependency.isIterated(cd, idMap));
|
|
@@ -140,10 +130,7 @@ function collect(graph, ctx) {
|
|
|
140
130
|
// a function's setwd is propagated to its call sites; only a lone unconditional setwd has a site-independent effect
|
|
141
131
|
for (const [fn, setwds] of byFn.entries()) {
|
|
142
132
|
const net = setwds.length === 1 && setwds[0].cds.length === 0 && !setwds[0].iterated ? setwds[0].dir : undefined;
|
|
143
|
-
for (const
|
|
144
|
-
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
133
|
+
for (const site of (0, frame_reflection_1.edgeSources)(graph, fn, edge_1.EdgeType.Calls)) {
|
|
147
134
|
const cds = graph.getVertex(site)?.cds ?? [];
|
|
148
135
|
out.push({ id: site, dir: net, cds, iterated: isIterated(cds, graph.idMap), enclosedInFunction: enclosingFunction(graph.idMap, site) !== undefined });
|
|
149
136
|
}
|
|
@@ -154,10 +141,15 @@ function collect(graph, ctx) {
|
|
|
154
141
|
exports.WorkingDirectory = {
|
|
155
142
|
collect,
|
|
156
143
|
resolveAt,
|
|
157
|
-
|
|
144
|
+
applyChange,
|
|
145
|
+
/** reusable `(callId, scriptFile?) => candidate roots`, collecting the changes once for the whole graph; `pinned` when a `setwd` decides them */
|
|
158
146
|
rootsResolver(graph, cfg, ctx) {
|
|
159
147
|
const changes = collect(graph, ctx);
|
|
160
|
-
return (id, file) =>
|
|
148
|
+
return (id, file) => {
|
|
149
|
+
const base = file ? (0, built_in_source_1.platformDirname)(file) : '.';
|
|
150
|
+
const roots = resolveAt(id, graph.getVertex(id)?.cds ?? [], base, changes, cfg).candidates;
|
|
151
|
+
return { roots, pinned: roots.length > 0 && (roots.length > 1 || roots[0] !== base) };
|
|
152
|
+
};
|
|
161
153
|
}
|
|
162
154
|
};
|
|
163
155
|
//# sourceMappingURL=resolve-working-directory.js.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
2
|
+
import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
1
3
|
import type { BuiltInEvalHandlerArgs } from '../../environments/built-in';
|
|
2
4
|
import { type Lift, Top, type Value, type ValueNumber, type ValueVector } from '../values/r-value';
|
|
5
|
+
/** Whether the operator only combines literals (`1 + 2`), which alone fold while the analysis runs, as a name may still change its value. */
|
|
6
|
+
export declare function onlyLiterals(node: RNode<ParentInformation>): boolean;
|
|
3
7
|
/**
|
|
4
8
|
* Converts an RNode to its Value, either directly for a constant or by handing the node to the
|
|
5
9
|
* {@link BuiltInEvalHandler} its built-in declares, which may resolve further nodes recursively.
|