@eagleoutice/flowr 2.13.9 → 2.13.11
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 +40 -40
- package/config.d.ts +50 -2
- package/config.js +37 -6
- package/dataflow/environments/apply-kill.js +4 -4
- package/dataflow/environments/built-in-props.d.ts +28 -4
- package/dataflow/environments/built-in-props.js +31 -8
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +10 -12
- package/dataflow/environments/default-builtin-config.d.ts +46 -6
- package/dataflow/environments/default-builtin-config.js +30 -16
- package/dataflow/environments/environment.d.ts +16 -0
- package/dataflow/environments/environment.js +114 -26
- package/dataflow/environments/identifier.d.ts +6 -0
- package/dataflow/environments/identifier.js +18 -5
- package/dataflow/environments/query-fn-props.js +34 -2
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.js +16 -6
- package/dataflow/environments/resolve-helper.d.ts +43 -0
- package/dataflow/environments/resolve-helper.js +47 -0
- package/dataflow/eval/resolve/alias-tracking.js +45 -1
- package/dataflow/eval/resolve/resolve-argument.js +25 -17
- package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
- package/dataflow/eval/resolve/resolve-strings.js +16 -9
- package/dataflow/eval/resolve/resolve.js +3 -1
- package/dataflow/graph/call-graph.d.ts +7 -0
- package/dataflow/graph/call-graph.js +103 -0
- package/dataflow/graph/df-helper.d.ts +50 -1
- package/dataflow/graph/df-helper.js +63 -0
- package/dataflow/graph/graph.d.ts +5 -8
- package/dataflow/graph/graph.js +24 -13
- package/dataflow/internal/linker.d.ts +5 -5
- package/dataflow/internal/linker.js +31 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
- package/documentation/data/faq/faqs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +3 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +5 -0
- package/documentation/doc-util/doc-files.js +13 -3
- package/documentation/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-analyzer.js +10 -10
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +3 -3
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-linting-and-testing.js +13 -13
- package/documentation/wiki-mk/doc-context.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.js +9 -5
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-overview.js +2 -2
- package/documentation/wiki-query.js +4 -1
- package/documentation/wiki-setup.js +3 -3
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +12 -1
- package/linter/rules/syntactically-valid.js +88 -17
- package/package.json +7 -8
- package/project/attached-packages.d.ts +13 -0
- package/project/attached-packages.js +30 -0
- package/project/context/flowr-analyzer-context.d.ts +15 -0
- package/project/context/flowr-analyzer-context.js +14 -3
- package/project/context/flowr-analyzer-files-context.d.ts +11 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
- package/project/context/flowr-analyzer-loading-order-context.js +23 -2
- package/project/dependency-version-space.d.ts +33 -11
- package/project/dependency-version-space.js +58 -32
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/manifest.js +9 -5
- package/project/sigdb/reader.d.ts +20 -0
- package/project/sigdb/reader.js +93 -10
- package/project/sigdb/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
- package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
- package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
- package/queries/catalog/dependencies-query/link-devices.js +104 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
- package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
- package/queries/catalog/input-sources-query/input-types.js +10 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
- package/queries/catalog/slice-query-options.d.ts +11 -1
- package/queries/catalog/slice-query-options.js +8 -4
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
- package/r-bridge/lang-4.x/ast/model/model.js +44 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -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-binary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/reconstruct/reconstruct.d.ts +9 -0
- package/reconstruct/reconstruct.js +1 -0
- package/search/flowr-search-filters.d.ts +25 -1
- package/search/flowr-search-filters.js +42 -7
- package/search/search-executor/search-generators.js +7 -2
- package/search/search-executor/search-transformer.js +4 -1
- package/slicing/criterion/parse.d.ts +5 -25
- package/slicing/criterion/parse.js +15 -20
- package/slicing/static/fingerprint.js +18 -6
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/slicer-types.d.ts +10 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +29 -6
- package/slicing/static/visiting-queue.d.ts +12 -2
- package/slicing/static/visiting-queue.js +28 -3
- package/util/arg-matching.d.ts +18 -0
- package/util/arg-matching.js +70 -0
- package/util/collections/bimap.d.ts +21 -1
- package/util/collections/bimap.js +43 -7
- package/util/r-regex.js +19 -1
- package/util/range.d.ts +7 -8
- package/util/range.js +10 -11
- package/util/version.js +1 -1
|
@@ -23,7 +23,7 @@ const edge_1 = require("../graph/edge");
|
|
|
23
23
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
24
24
|
const vertex_1 = require("../graph/vertex");
|
|
25
25
|
const resolve_by_name_1 = require("../environments/resolve-by-name");
|
|
26
|
-
const
|
|
26
|
+
const arg_matching_1 = require("../../util/arg-matching");
|
|
27
27
|
const info_1 = require("../info");
|
|
28
28
|
const unnamed_call_handling_1 = require("./process/functions/call/unnamed-call-handling");
|
|
29
29
|
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
@@ -71,72 +71,40 @@ function produceNameSharedIdMap(references) {
|
|
|
71
71
|
}
|
|
72
72
|
return nameIdShares;
|
|
73
73
|
}
|
|
74
|
+
/** the argument names as {@link matchArgumentsToParameters} wants them */
|
|
75
|
+
function argumentNames(args) {
|
|
76
|
+
return args.map(a => graph_1.FunctionArgument.isNamed(a) ? a.name : undefined);
|
|
77
|
+
}
|
|
74
78
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching
|
|
78
|
-
* This returns the resolved map from argument ids to parameter ids.
|
|
79
|
+
* {@link matchArgumentsToParameters|Matches} the arguments to the parameters and links them in the graph,
|
|
80
|
+
* returning the resolved map from argument ids to parameter ids.
|
|
79
81
|
* If you just want to match by name, use {@link pMatch}.
|
|
80
82
|
*/
|
|
81
83
|
function linkArgumentsOnCall(args, params, graph) {
|
|
82
|
-
const
|
|
83
|
-
const nameParamMap = new Map(params.filter(p => p?.name?.content !== undefined)
|
|
84
|
-
.map(p => [p.name.content, p]));
|
|
84
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), params.map(p => p?.special ? arg_matching_1.DotsParameterName : p?.name?.content));
|
|
85
85
|
const maps = new Map();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// all parameters matched by name
|
|
89
|
-
const matchedParameters = new Set();
|
|
90
|
-
const paramNames = nameParamMap.keys().toArray();
|
|
91
|
-
// first map names
|
|
92
|
-
for (const [name, { nodeId: argId }] of nameArgMap) {
|
|
93
|
-
const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, paramNames) ?? name;
|
|
94
|
-
const param = nameParamMap.get(pmatchName);
|
|
95
|
-
if (param?.name) {
|
|
96
|
-
const pid = param.name.info.id;
|
|
97
|
-
graph.addEdge(argId, pid, edge_1.EdgeType.DefinesOnCall);
|
|
98
|
-
graph.addEdge(pid, argId, edge_1.EdgeType.DefinedByOnCall);
|
|
99
|
-
maps.set(argId, pid);
|
|
100
|
-
matchedParameters.add(name);
|
|
101
|
-
}
|
|
102
|
-
else if (sid) {
|
|
103
|
-
graph.addEdge(argId, sid, edge_1.EdgeType.DefinesOnCall);
|
|
104
|
-
graph.addEdge(sid, argId, edge_1.EdgeType.DefinedByOnCall);
|
|
105
|
-
maps.set(argId, sid);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const remainingParameter = params.filter(p => !p?.name || !matchedParameters.has(p.name.content));
|
|
109
|
-
const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
|
|
110
|
-
for (let i = 0; i < remainingArguments.length; i++) {
|
|
111
|
-
const arg = remainingArguments[i];
|
|
86
|
+
for (let i = 0; i < args.length; i++) {
|
|
87
|
+
const arg = args[i];
|
|
112
88
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
113
89
|
continue;
|
|
114
90
|
}
|
|
91
|
+
const param = matched[i];
|
|
92
|
+
const pid = param === undefined ? undefined : params[param].name?.info.id;
|
|
115
93
|
const aid = arg.nodeId;
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
graph.addEdge(aid, sid, edge_1.EdgeType.DefinesOnCall);
|
|
119
|
-
graph.addEdge(sid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
120
|
-
maps.set(aid, sid);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
logger_1.dataflowLogger.warn(`skipping argument ${i} as there is no corresponding parameter - R should block that`);
|
|
124
|
-
}
|
|
94
|
+
if (pid === undefined) {
|
|
95
|
+
logger_1.dataflowLogger.warn(`skipping argument ${i} (id: ${aid}) as there is no corresponding parameter - R should block that`);
|
|
125
96
|
continue;
|
|
126
97
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const pid = param.name.info.id;
|
|
131
|
-
graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
|
|
132
|
-
graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
133
|
-
maps.set(aid, pid);
|
|
134
|
-
}
|
|
98
|
+
graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
|
|
99
|
+
graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
100
|
+
maps.set(aid, pid);
|
|
135
101
|
}
|
|
136
102
|
return maps;
|
|
137
103
|
}
|
|
138
104
|
/**
|
|
139
|
-
*
|
|
105
|
+
* {@link matchArgumentsToParameters|Matches} the arguments against a parameter specification, returning the
|
|
106
|
+
* arguments bound to each target. Unlike {@link linkArgumentsOnCall} this touches no graph, so it also works
|
|
107
|
+
* for a specification without parameters in the AST.
|
|
140
108
|
* @example
|
|
141
109
|
* ```ts
|
|
142
110
|
* const parameterSpec = {
|
|
@@ -155,50 +123,21 @@ function linkArgumentsOnCall(args, params, graph) {
|
|
|
155
123
|
* or convert them with {@link convertFnArguments}.
|
|
156
124
|
*/
|
|
157
125
|
function pMatch(args, params) {
|
|
158
|
-
const nameArgMap = new Map(args.filter(graph_1.FunctionArgument.isNamed).map(a => [a.name, a]));
|
|
159
|
-
const maps = new Map();
|
|
160
|
-
function addToMaps(key, value) {
|
|
161
|
-
const e = maps.get(key);
|
|
162
|
-
if (e) {
|
|
163
|
-
e.push(value);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
maps.set(key, [value]);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const sid = params['...'];
|
|
170
126
|
const paramNames = Object.keys(params);
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const param = params[pmatchName];
|
|
177
|
-
if (param) {
|
|
178
|
-
addToMaps(param, argId);
|
|
179
|
-
matchedParameters.add(name);
|
|
180
|
-
}
|
|
181
|
-
else if (sid) {
|
|
182
|
-
addToMaps(sid, argId);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const remainingParameter = paramNames.filter(p => !matchedParameters.has(p));
|
|
186
|
-
const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
|
|
187
|
-
for (let i = 0; i < remainingArguments.length; i++) {
|
|
188
|
-
const arg = remainingArguments[i];
|
|
189
|
-
if (arg === r_function_call_1.EmptyArgument) {
|
|
127
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), paramNames);
|
|
128
|
+
const maps = new Map();
|
|
129
|
+
for (let i = 0; i < args.length; i++) {
|
|
130
|
+
const arg = args[i], param = matched[i];
|
|
131
|
+
if (arg === r_function_call_1.EmptyArgument || param === undefined) {
|
|
190
132
|
continue;
|
|
191
133
|
}
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
continue;
|
|
134
|
+
const target = params[paramNames[param]];
|
|
135
|
+
const known = maps.get(target);
|
|
136
|
+
if (known) {
|
|
137
|
+
known.push(arg.nodeId);
|
|
198
138
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
addToMaps(param, aid);
|
|
139
|
+
else {
|
|
140
|
+
maps.set(target, [arg.nodeId]);
|
|
202
141
|
}
|
|
203
142
|
}
|
|
204
143
|
return maps;
|
|
@@ -117,7 +117,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
|
|
|
117
117
|
const existing = data.environment.current.memory.get(':=');
|
|
118
118
|
const outInfo = { definitionRootNodes: [] };
|
|
119
119
|
const tableAssignId = node_id_1.NodeId.toBuiltIn(':=-table');
|
|
120
|
-
data.environment.current.
|
|
120
|
+
data.environment.current.writableMemory.set(':=', [{
|
|
121
121
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
122
122
|
definedAt: tableAssignId,
|
|
123
123
|
cds: undefined,
|
|
@@ -128,7 +128,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
|
|
|
128
128
|
const fnCall = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: built_in_proc_name_1.BuiltInProcName.Access });
|
|
129
129
|
/* recover the environment */
|
|
130
130
|
if (existing !== undefined) {
|
|
131
|
-
data.environment.current.
|
|
131
|
+
data.environment.current.writableMemory.set(':=', existing);
|
|
132
132
|
}
|
|
133
133
|
if (head.value && outInfo.definitionRootNodes.length > 0) {
|
|
134
134
|
(0, built_in_assignment_1.markAsAssignment)(fnCall.information, { type: identifier_1.ReferenceType.Variable, name: head.value.lexeme ?? '', nodeId: head.value.info.id, definedAt: rootId, cds: [] }, outInfo.definitionRootNodes, rootId, data);
|
|
@@ -21,12 +21,6 @@ export interface EnvirResolution<OtherInfo> {
|
|
|
21
21
|
/** `true` when this resolves to a real stack environment (`globalenv()`/`.GlobalEnv`), not a tracked custom env. */
|
|
22
22
|
readonly isStackEnv?: boolean;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
|
|
26
|
-
* Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
|
|
27
|
-
* Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
|
|
28
|
-
*/
|
|
29
|
-
export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
|
|
30
24
|
/**
|
|
31
25
|
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
32
26
|
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
@@ -38,10 +32,10 @@ export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorIn
|
|
|
38
32
|
export declare function resolveConstantString<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): string | undefined;
|
|
39
33
|
/** The `returnsEnvState` of the first reaching definition that carries one, else `undefined`. */
|
|
40
34
|
export declare function findReturnsEnvState(defs: readonly IdentifierDefinition[] | undefined): REnvironmentInformation | undefined;
|
|
41
|
-
/** Resolves a single already-found argument (e.g. from {@link
|
|
35
|
+
/** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
42
36
|
export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
|
|
43
|
-
/** Resolves the `argName` argument (default `'envir'
|
|
44
|
-
export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string
|
|
37
|
+
/** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
|
|
38
|
+
export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string): EnvirResolution<OtherInfo> | undefined;
|
|
45
39
|
/** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
|
|
46
40
|
export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier, nodeId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
|
|
47
41
|
/** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bindArgs = bindArgs;
|
|
4
3
|
exports.signatureParamNames = signatureParamNames;
|
|
5
4
|
exports.resolveConstantString = resolveConstantString;
|
|
6
5
|
exports.findReturnsEnvState = findReturnsEnvState;
|
|
@@ -61,14 +60,6 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
|
|
|
61
60
|
};
|
|
62
61
|
return { envirData: { ...data, environment: mergedEnvState }, envDef, envirNodeId: nodeId };
|
|
63
62
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
|
|
66
|
-
* Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
|
|
67
|
-
* Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
|
|
68
|
-
*/
|
|
69
|
-
function bindArgs(args, paramNames) {
|
|
70
|
-
return r_function_call_1.RFunctionCall.matchArgsToParams(args, paramNames);
|
|
71
|
-
}
|
|
72
63
|
/**
|
|
73
64
|
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
74
65
|
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
@@ -107,7 +98,7 @@ function resolveConstantString(node, data) {
|
|
|
107
98
|
function findReturnsEnvState(defs) {
|
|
108
99
|
return defs?.find((d) => d.returnsEnvState !== undefined)?.returnsEnvState;
|
|
109
100
|
}
|
|
110
|
-
/** Resolves a single already-found argument (e.g. from {@link
|
|
101
|
+
/** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
111
102
|
function resolveArgToEnvir(arg, data) {
|
|
112
103
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
113
104
|
return undefined;
|
|
@@ -135,30 +126,13 @@ function stackEnvirResolution(envState, nodeId, lexeme, data) {
|
|
|
135
126
|
};
|
|
136
127
|
return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, isStackEnv: true };
|
|
137
128
|
}
|
|
138
|
-
/** Resolves the `argName` argument (default `'envir'
|
|
139
|
-
function resolveEnvirArg(args, data, argName = 'envir'
|
|
140
|
-
/* named pass: pmatch against the full parameter list */
|
|
129
|
+
/** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
|
|
130
|
+
function resolveEnvirArg(args, data, argName = 'envir') {
|
|
141
131
|
for (const arg of args) {
|
|
142
|
-
if (arg
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if ((0, prefix_1.findByPrefixIfUnique)(arg.name.content, allParamNames) === argName) {
|
|
132
|
+
if (arg !== r_function_call_1.EmptyArgument && arg.name !== undefined && (0, prefix_1.findByPrefixIfUnique)(arg.name.content, [argName]) === argName) {
|
|
146
133
|
return resolveArgToEnvir(arg, data);
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
|
-
/* positional fallback (only when no named match existed) */
|
|
150
|
-
if (positionalFallbackIndex !== undefined) {
|
|
151
|
-
let pos = 0;
|
|
152
|
-
for (const arg of args) {
|
|
153
|
-
if (arg === r_function_call_1.EmptyArgument || arg.name !== undefined) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (pos === positionalFallbackIndex) {
|
|
157
|
-
return resolveArgToEnvir(arg, data);
|
|
158
|
-
}
|
|
159
|
-
pos++;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
136
|
return undefined;
|
|
163
137
|
}
|
|
164
138
|
/** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
|
|
@@ -47,7 +47,8 @@ function processForLoop(name, args, rootId, data) {
|
|
|
47
47
|
const writtenIds = new Set();
|
|
48
48
|
for (const write of writtenVariable) {
|
|
49
49
|
writtenIds.add(write.nodeId);
|
|
50
|
-
headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable
|
|
50
|
+
headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable,
|
|
51
|
+
value: [vectorArg.info.id], iterated: true }, false, headEnvironments);
|
|
51
52
|
}
|
|
52
53
|
data.environment = headEnvironments;
|
|
53
54
|
const body = (0, processor_1.processDataflowFor)(bodyArg, data);
|
|
@@ -484,7 +484,7 @@ function groupBodyWrites(out) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
for (const writes of byName.values()) {
|
|
487
|
-
writes.sort((a, b) => String(
|
|
487
|
+
writes.sort((a, b) => String(b.nodeId).localeCompare(String(a.nodeId)));
|
|
488
488
|
}
|
|
489
489
|
return byName;
|
|
490
490
|
}
|
|
@@ -25,6 +25,7 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
25
25
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
26
26
|
const general_1 = require("../../../../../eval/values/general");
|
|
27
27
|
const package_1 = require("../../../../../../project/plugins/package-version-plugins/package");
|
|
28
|
+
const attached_packages_1 = require("../../../../../../project/attached-packages");
|
|
28
29
|
const flowr_namespace_file_1 = require("../../../../../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
29
30
|
const common_1 = require("../common");
|
|
30
31
|
const linker_1 = require("../../../../linker");
|
|
@@ -406,7 +407,12 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
|
|
|
406
407
|
importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
|
|
407
408
|
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
|
|
408
409
|
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
409
|
-
|
|
410
|
+
const attached = { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
|
|
411
|
+
/* whatever R puts on the search path with it, `pack` first so a dependency cycle stays finite (the guard above stops it) */
|
|
412
|
+
return (0, attached_packages_1.attachedAlongside)(pack, ctx.deps.signatureSources()).reduce((env, alongside) => {
|
|
413
|
+
const dependency = ctx.deps.getDependency(alongside);
|
|
414
|
+
return dependency === undefined ? env : attachDependencyToEnvironment(dependency, env, ctx, spec, definedAt);
|
|
415
|
+
}, attached);
|
|
410
416
|
}
|
|
411
417
|
/** A namespace-only load is subsumed by any layer for `pack`; a full attach ignores a mere {@link EnvType.LoadedNamespace}. */
|
|
412
418
|
function blocksAttach(layer, namespaceOnly) {
|
|
@@ -222,12 +222,12 @@ function sexpTypeToReferenceType(type) {
|
|
|
222
222
|
function getArguments(args, data) {
|
|
223
223
|
// prefer R's real `base::load` signature from the database, falling back to the known formals when it is absent
|
|
224
224
|
const loadParams = (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make('load', "base" /* PkgName.Base */), ['file', 'envir', 'verbose']);
|
|
225
|
-
const bound =
|
|
225
|
+
const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, loadParams);
|
|
226
226
|
const fileArgBound = bound.get('file');
|
|
227
227
|
const envirArg = bound.get('envir');
|
|
228
228
|
const verboseArgBound = bound.get('verbose');
|
|
229
|
-
const fileArg = fileArgBound
|
|
230
|
-
const verboseArg = verboseArgBound
|
|
229
|
+
const fileArg = fileArgBound ? (0, unpack_argument_1.unpackArg)(fileArgBound) : undefined;
|
|
230
|
+
const verboseArg = verboseArgBound ? (0, unpack_argument_1.unpackArg)(verboseArgBound) : undefined;
|
|
231
231
|
return { fileArg, envirArg, verboseArg };
|
|
232
232
|
}
|
|
233
233
|
//# sourceMappingURL=built-in-load.js.map
|
|
@@ -2,7 +2,7 @@ import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
import
|
|
5
|
+
import { 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 { BrandedIdentifier } from '../../../../../environments/identifier';
|
|
8
8
|
/**
|
|
@@ -6,6 +6,7 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
6
6
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
7
7
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
8
|
const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
|
|
9
|
+
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
9
10
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
10
11
|
const logger_1 = require("../../../../../logger");
|
|
11
12
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -99,8 +100,11 @@ function processPipe(name, args, rootId, data, { pipePlaceholderName, assignLhs,
|
|
|
99
100
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
100
101
|
continue;
|
|
101
102
|
}
|
|
103
|
+
/* only the symbols may name columns, the rest is evaluated in the caller's frame */
|
|
102
104
|
model_1.RNode.visitAst(arg, node => {
|
|
103
|
-
|
|
105
|
+
if (r_symbol_1.RSymbol.is(node)) {
|
|
106
|
+
information.graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
|
|
107
|
+
}
|
|
104
108
|
return false;
|
|
105
109
|
});
|
|
106
110
|
}
|
|
@@ -14,8 +14,8 @@ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/proce
|
|
|
14
14
|
* - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
|
|
15
15
|
* - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
|
|
16
16
|
*
|
|
17
|
-
* Arguments are resolved
|
|
18
|
-
*
|
|
17
|
+
* Arguments are resolved with {@link RFunctionCall.matchArgsToParams}, so `with(expr=x, data=e)` and
|
|
18
|
+
* `with(dat=e, x)` are handled correctly.
|
|
19
19
|
*
|
|
20
20
|
* Falls back to a normal function-call analysis when the data argument cannot be resolved
|
|
21
21
|
* to a tracked environment.
|
|
@@ -15,7 +15,7 @@ const withParamsFallback = ['data', 'expr'];
|
|
|
15
15
|
/** Normal call analysis, marking the data-masked arguments (columns of the data) as NSE. */
|
|
16
16
|
function markAsMaskedFallback(name, args, rootId, data) {
|
|
17
17
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With });
|
|
18
|
-
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.AllButFirst);
|
|
18
|
+
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.AllButFirst, known_call_handling_1.NseKind.DataMasked);
|
|
19
19
|
return information;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -28,8 +28,8 @@ function markAsMaskedFallback(name, args, rootId, data) {
|
|
|
28
28
|
* - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
|
|
29
29
|
* - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
|
|
30
30
|
*
|
|
31
|
-
* Arguments are resolved
|
|
32
|
-
*
|
|
31
|
+
* Arguments are resolved with {@link RFunctionCall.matchArgsToParams}, so `with(expr=x, data=e)` and
|
|
32
|
+
* `with(dat=e, x)` are handled correctly.
|
|
33
33
|
*
|
|
34
34
|
* Falls back to a normal function-call analysis when the data argument cannot be resolved
|
|
35
35
|
* to a tracked environment.
|
|
@@ -40,13 +40,12 @@ function processWithEnv(name, args, rootId, data) {
|
|
|
40
40
|
}
|
|
41
41
|
// prefer R's real `base::with` signature from the database, falling back to the known formals when it is absent
|
|
42
42
|
// use the call's own name (`with` or `within`) qualified to base, so each gets its real signature
|
|
43
|
-
const bound =
|
|
43
|
+
const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make(identifier_1.Identifier.getName(name.content), "base" /* PkgName.Base */), withParamsFallback));
|
|
44
44
|
const dataArg = bound.get('data');
|
|
45
45
|
const exprArg = bound.get('expr');
|
|
46
46
|
// when we cannot resolve the data to a tracked environment, `expr` is still data-masked: its symbols name
|
|
47
47
|
// columns of `data`, not variables in scope, so mark the non-data arguments as non-standard-evaluated
|
|
48
|
-
if (dataArg ===
|
|
49
|
-
exprArg === r_function_call_1.EmptyArgument || exprArg?.value === undefined) {
|
|
48
|
+
if (dataArg?.value === undefined || exprArg?.value === undefined) {
|
|
50
49
|
return markAsMaskedFallback(name, args, rootId, data);
|
|
51
50
|
}
|
|
52
51
|
const envirResolution = (0, built_in_envir_utils_1.resolveArgToEnvir)(dataArg, data);
|
|
@@ -136,24 +136,37 @@ function attachedPackages(_id, fdef) {
|
|
|
136
136
|
}
|
|
137
137
|
return packages;
|
|
138
138
|
}
|
|
139
|
-
/** The
|
|
140
|
-
function
|
|
141
|
-
const defs = [];
|
|
142
|
-
// skip the function's own frame; outer-scope definitions escaped
|
|
139
|
+
/** The scopes outside a function's own frame, i.e. those a definition of its body can have escaped into. */
|
|
140
|
+
function* escapeTargetFrames(fdef) {
|
|
143
141
|
for (let e = fdef.subflow.environment.current.parent; e !== undefined && !e.builtInEnv; e = e.parent) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
yield e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The non-built-in definitions a function body lets escape to an outer scope (e.g. a `<<-` super-assignment),
|
|
147
|
+
* as a callback for {@link computeCallGraphSummaries}. Nested definitions share their outer frames, and a frame is
|
|
148
|
+
* dominated by the built-ins it holds, so filtering each frame once per pass saves the bulk of the work.
|
|
149
|
+
*/
|
|
150
|
+
function escapedDefinitions() {
|
|
151
|
+
const perFrame = new Map();
|
|
152
|
+
return (_id, fdef) => {
|
|
153
|
+
const defs = [];
|
|
154
|
+
for (const e of escapeTargetFrames(fdef)) {
|
|
155
|
+
let escaped = perFrame.get(e.memory);
|
|
156
|
+
if (escaped === undefined) {
|
|
157
|
+
escaped = [...e.memory.values()].flatMap(ds => ds.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId)).map(d => d.nodeId));
|
|
158
|
+
perFrame.set(e.memory, escaped);
|
|
159
|
+
}
|
|
160
|
+
for (const d of escaped) {
|
|
161
|
+
defs.push(d);
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
return defs;
|
|
165
|
+
};
|
|
153
166
|
}
|
|
154
167
|
/** Emits {@link EdgeType.SideEffectOnCall} edges for definitions that escape a function transitively. */
|
|
155
168
|
function propagateTransitiveDefinitions(graph, environment, ctx) {
|
|
156
|
-
const summary = computeCallGraphSummaries(graph, escapedDefinitions);
|
|
169
|
+
const summary = computeCallGraphSummaries(graph, escapedDefinitions());
|
|
157
170
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
158
171
|
if (vertex.tag !== vertex_1.VertexType.FunctionCall) {
|
|
159
172
|
continue;
|
|
@@ -206,11 +219,16 @@ function propagateTransitivePackages(graph, environment, ctx) {
|
|
|
206
219
|
/** Maps each escaped definition's node id to its full (name-carrying) definition. */
|
|
207
220
|
function escapedDefinitionMap(graph) {
|
|
208
221
|
const map = new Map();
|
|
222
|
+
const seen = new Set();
|
|
209
223
|
for (const [, vertex] of graph.vertices(true)) {
|
|
210
224
|
if (vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
|
|
211
225
|
continue;
|
|
212
226
|
}
|
|
213
|
-
for (
|
|
227
|
+
for (const e of escapeTargetFrames(vertex)) {
|
|
228
|
+
if (seen.has(e.memory)) {
|
|
229
|
+
continue; // a frame shared with an already-visited definition contributes the same entries
|
|
230
|
+
}
|
|
231
|
+
seen.add(e.memory);
|
|
214
232
|
for (const definitions of e.memory.values()) {
|
|
215
233
|
for (const def of definitions) {
|
|
216
234
|
if (!node_id_1.NodeId.isBuiltIn(def.nodeId) && def.name !== undefined) {
|
|
@@ -228,7 +246,7 @@ function escapedDefinitionMap(graph) {
|
|
|
228
246
|
* @returns the enriched environment and whether it grew (so the extractor can re-resolve open reads and re-run).
|
|
229
247
|
*/
|
|
230
248
|
function propagateTransitiveEscapedDefinitions(graph, environment) {
|
|
231
|
-
const summary = computeCallGraphSummaries(graph, escapedDefinitions);
|
|
249
|
+
const summary = computeCallGraphSummaries(graph, escapedDefinitions());
|
|
232
250
|
const defs = escapedDefinitionMap(graph);
|
|
233
251
|
const names = new Set();
|
|
234
252
|
let grew = false;
|
|
@@ -58,11 +58,23 @@ export declare enum NseArguments {
|
|
|
58
58
|
First = "first"
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
|
|
61
|
+
* How an argument escapes standard evaluation, which decides what is marked
|
|
62
|
+
* {@link EdgeType.NonStandardEvaluation}.
|
|
64
63
|
*/
|
|
65
|
-
export declare
|
|
64
|
+
export declare enum NseKind {
|
|
65
|
+
/** the argument is not evaluated at all (`quote(x + y)`), so nothing within it is */
|
|
66
|
+
Quoted = "quoted",
|
|
67
|
+
/** the argument is evaluated in a data mask (`subset(d, a > k)`), where only its symbols may name columns */
|
|
68
|
+
DataMasked = "data-masked"
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}, so they are recognised as not being
|
|
72
|
+
* evaluated the standard way. A {@link NseKind.Quoted|quoted} argument is marked entirely, as none of it is
|
|
73
|
+
* evaluated. A {@link NseKind.DataMasked|data-masked} one is evaluated in the caller's frame, with only the
|
|
74
|
+
* names the mask supplies (those that resolve to nothing else) taken from the data, so only those are marked.
|
|
75
|
+
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly, `undefined` marks nothing.
|
|
76
|
+
*/
|
|
77
|
+
export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[] | undefined, kind?: NseKind): void;
|
|
66
78
|
/**
|
|
67
79
|
* Marks the given arguments as being involved in R's non-standard evaluation.
|
|
68
80
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NseArguments = void 0;
|
|
3
|
+
exports.NseKind = exports.NseArguments = void 0;
|
|
4
4
|
exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluation;
|
|
5
5
|
exports.markNonStandardEvaluationEdges = markNonStandardEvaluationEdges;
|
|
6
6
|
exports.processKnownFunctionCall = processKnownFunctionCall;
|
|
@@ -27,20 +27,41 @@ var NseArguments;
|
|
|
27
27
|
NseArguments["First"] = "first";
|
|
28
28
|
})(NseArguments || (exports.NseArguments = NseArguments = {}));
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
|
|
30
|
+
* How an argument escapes standard evaluation, which decides what is marked
|
|
31
|
+
* {@link EdgeType.NonStandardEvaluation}.
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
var NseKind;
|
|
34
|
+
(function (NseKind) {
|
|
35
|
+
/** the argument is not evaluated at all (`quote(x + y)`), so nothing within it is */
|
|
36
|
+
NseKind["Quoted"] = "quoted";
|
|
37
|
+
/** the argument is evaluated in a data mask (`subset(d, a > k)`), where only its symbols may name columns */
|
|
38
|
+
NseKind["DataMasked"] = "data-masked";
|
|
39
|
+
})(NseKind || (exports.NseKind = NseKind = {}));
|
|
40
|
+
/**
|
|
41
|
+
* Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}, so they are recognised as not being
|
|
42
|
+
* evaluated the standard way. A {@link NseKind.Quoted|quoted} argument is marked entirely, as none of it is
|
|
43
|
+
* evaluated. A {@link NseKind.DataMasked|data-masked} one is evaluated in the caller's frame, with only the
|
|
44
|
+
* names the mask supplies (those that resolve to nothing else) taken from the data, so only those are marked.
|
|
45
|
+
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly, `undefined` marks nothing.
|
|
46
|
+
*/
|
|
47
|
+
function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which, kind = NseKind.Quoted) {
|
|
48
|
+
if (which === undefined) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
35
51
|
const end = which === NseArguments.First ? 1 : processedArguments.length;
|
|
36
52
|
for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
|
|
37
53
|
const arg = processedArguments[i];
|
|
38
54
|
if (arg === undefined || (typeof which !== 'string' && !which.includes(i))) {
|
|
39
55
|
continue;
|
|
40
56
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
if (kind === NseKind.Quoted) {
|
|
58
|
+
graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
59
|
+
}
|
|
60
|
+
for (const [vtx, info] of arg.graph.vertices(true)) {
|
|
61
|
+
/* a masked name the caller does not bind is the one the data supplies */
|
|
62
|
+
if (kind === NseKind.Quoted || (vertex_1.UseVertex.is(info) && !arg.graph.outgoingEdges(vtx)?.values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads)))) {
|
|
63
|
+
graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
|
|
64
|
+
}
|
|
44
65
|
}
|
|
45
66
|
}
|
|
46
67
|
}
|
|
@@ -51,7 +51,7 @@ ${(0, doc_code_1.codeBlock)('shell', 'npm run wiki:watch')}
|
|
|
51
51
|
`)
|
|
52
52
|
.addFaq('Why can\'t I pass *arguments* when running flowR *with npm*?', `
|
|
53
53
|
With \`npm\` you have to pass arguments in a specific way. The \`--\` operator is used to separate the \`npm\` arguments from the script arguments. For example, if you want to run \`flowR\` with the \`--help\` argument, you can use the following command:
|
|
54
|
-
${(0, doc_code_1.codeBlock)('shell', 'npm run
|
|
54
|
+
${(0, doc_code_1.codeBlock)('shell', 'npm run flowr -- --help')}
|
|
55
55
|
`)
|
|
56
56
|
.addFaq('How to do *logging* in flowR?', `
|
|
57
57
|
Check out the ${ctx.linkPage('wiki/Linting and Testing', 'Logging Section in the Linting and Testing wiki page', 'logging')} for more information on how to do logging in *flowR*.
|
|
@@ -10,6 +10,7 @@ const FlowrFaqTopics = {
|
|
|
10
10
|
'r.packages': '📦 R Packages',
|
|
11
11
|
'editor.configs': '⚙️ Recommended Editor Configs'
|
|
12
12
|
};
|
|
13
|
+
const FlowrFaqMainTitle = '💮 <i>flowR</i> FAQ';
|
|
13
14
|
/**
|
|
14
15
|
* Manage all questions and answers by topic.
|
|
15
16
|
*/
|
|
@@ -50,7 +51,7 @@ class FaqStore {
|
|
|
50
51
|
toMarkdown() {
|
|
51
52
|
return `
|
|
52
53
|
${(0, doc_structure_1.collapsibleToc)({
|
|
53
|
-
[
|
|
54
|
+
[FlowrFaqMainTitle]: {
|
|
54
55
|
[FlowrFaqTopics['flowr.development']]: {},
|
|
55
56
|
[FlowrFaqTopics['flowr.use']]: {}
|
|
56
57
|
},
|
|
@@ -62,7 +63,7 @@ ${(0, doc_structure_1.collapsibleToc)({
|
|
|
62
63
|
}
|
|
63
64
|
})}
|
|
64
65
|
|
|
65
|
-
${(0, doc_structure_1.section)(
|
|
66
|
+
${(0, doc_structure_1.section)(FlowrFaqMainTitle, 2)}
|
|
66
67
|
|
|
67
68
|
${this.printAllTopics(/^flowr.*$/)}
|
|
68
69
|
|