@eagleoutice/flowr 2.13.1 → 2.13.3
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 +46 -44
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/cli/flowr.js +21 -5
- package/cli/repl/commands/repl-commands.js +11 -9
- package/cli/repl/commands/repl-query.js +1 -1
- package/cli/repl/commands/repl-signature.js +8 -1
- package/cli/repl/core.js +13 -10
- package/cli/repl/print-version.js +1 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/net.js +15 -0
- package/config.d.ts +37 -0
- package/config.js +63 -3
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/data/sigdb/sigdb.remote.json +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +9 -8
- package/dataflow/environments/identifier.js +21 -13
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
- package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.d.ts +3 -2
- package/dataflow/graph/df-helper.js +11 -15
- package/dataflow/graph/diff-dataflow-graph.js +1 -1
- package/dataflow/graph/graph-helper.js +2 -6
- package/dataflow/graph/graph.d.ts +24 -0
- package/dataflow/graph/graph.js +25 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +10 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +18 -7
- package/linter/linter-rules.d.ts +24 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -4
- package/linter/rules/absolute-path.js +7 -5
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +48 -8
- package/linter/rules/function-finder-util.d.ts +2 -1
- package/linter/rules/syntactically-valid.d.ts +58 -0
- package/linter/rules/syntactically-valid.js +203 -0
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +6 -6
- package/package.json +25 -12
- package/project/context/classify-project-kind.d.ts +40 -0
- package/project/context/classify-project-kind.js +76 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
- package/project/context/flowr-analyzer-dependencies-context.js +30 -3
- package/project/context/flowr-analyzer-files-context.d.ts +10 -8
- package/project/context/flowr-analyzer-files-context.js +26 -67
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +4 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +4 -1
- package/project/sigdb/manifest.js +60 -26
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/project/sigdb/sigdb-download.d.ts +6 -7
- package/project/sigdb/sigdb-download.js +30 -9
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
- package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
- package/queries/catalog/linter-query/linter-query-format.js +9 -2
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +115 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +12 -7
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/r-bridge/retriever.js +6 -1
- package/r-bridge/shell.js +5 -0
- package/search/flowr-search-filters.d.ts +2 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/files.d.ts +6 -4
- package/util/files.js +30 -8
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/text/ansi.d.ts +7 -3
- package/util/text/ansi.js +8 -5
- package/util/version.js +4 -4
package/dataflow/extractor.js
CHANGED
|
@@ -15,6 +15,7 @@ const make_argument_1 = require("./internal/process/functions/call/argument/make
|
|
|
15
15
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
16
16
|
const built_in_source_1 = require("./internal/process/functions/call/built-in/built-in-source");
|
|
17
17
|
const built_in_library_1 = require("./internal/process/functions/call/built-in/built-in-library");
|
|
18
|
+
const graph_1 = require("./graph/graph");
|
|
18
19
|
const extract_cfg_1 = require("../control-flow/extract-cfg");
|
|
19
20
|
const edge_1 = require("./graph/edge");
|
|
20
21
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
@@ -79,7 +80,7 @@ function resolveLinkToSideEffects(ast, graph, ctx) {
|
|
|
79
80
|
const killedRegexes = new Set();
|
|
80
81
|
const handled = new Set();
|
|
81
82
|
for (const s of graph.unknownSideEffects) {
|
|
82
|
-
if (
|
|
83
|
+
if (!graph_1.UnknownSideEffect.isLinked(s)) {
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
if (cf === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import { type DataflowFunctionFlowInformation, DataflowGraph, FunctionArgument } from './graph';
|
|
4
|
-
import {
|
|
4
|
+
import type { IEnvironment, REnvironmentInformation } from '../environments/environment';
|
|
5
5
|
import { type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexArgument, type DataflowGraphVertexAstLink, type DataflowGraphVertexInfo, type DataflowGraphVertexUse, type FunctionOriginInformation } from './vertex';
|
|
6
6
|
import type { ControlDependency, ExitPoint } from '../info';
|
|
7
7
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
@@ -85,7 +85,8 @@ export declare const Dataflow: {
|
|
|
85
85
|
readonly origin: typeof getOriginInDfg;
|
|
86
86
|
/**
|
|
87
87
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
88
|
-
* export (with `purrr` loaded, a `map()` call yields
|
|
88
|
+
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
89
|
+
* `Identifier.make('map', 'purrr')`; an explicit `pkg::fn()` call yields `pkg::fn` unchanged).
|
|
89
90
|
*
|
|
90
91
|
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
91
92
|
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
@@ -93,7 +94,7 @@ export declare const Dataflow: {
|
|
|
93
94
|
* @param graph - The graph the call is part of
|
|
94
95
|
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
95
96
|
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
96
|
-
* Set this to `false` to only qualify what the origins resolve to.
|
|
97
|
+
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
97
98
|
*/
|
|
98
99
|
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
99
100
|
/**
|
|
@@ -56,7 +56,8 @@ exports.Dataflow = {
|
|
|
56
56
|
origin: dfg_get_origin_1.getOriginInDfg,
|
|
57
57
|
/**
|
|
58
58
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
59
|
-
* export (with `purrr` loaded, a `map()` call yields
|
|
59
|
+
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
60
|
+
* `Identifier.make('map', 'purrr')`; an explicit `pkg::fn()` call yields `pkg::fn` unchanged).
|
|
60
61
|
*
|
|
61
62
|
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
62
63
|
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
@@ -64,12 +65,11 @@ exports.Dataflow = {
|
|
|
64
65
|
* @param graph - The graph the call is part of
|
|
65
66
|
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
66
67
|
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
67
|
-
* Set this to `false` to only qualify what the origins resolve to.
|
|
68
|
+
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
68
69
|
*/
|
|
69
70
|
qualify(id, graph, qualifyBaseR = true) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), (0, vertex_1.isFunctionCallVertex)(vertex) ? vertex.name : undefined);
|
|
71
|
+
const vertex = graph.getVertex(id);
|
|
72
|
+
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), (0, vertex_1.isFunctionCallVertex)(vertex) ? vertex.name : undefined, qualifyBaseR);
|
|
73
73
|
},
|
|
74
74
|
/**
|
|
75
75
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
@@ -109,11 +109,9 @@ exports.Dataflow = {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
for (const u of graph.unknownSideEffects) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
else if (select.has(u)) {
|
|
116
|
-
df.markIdForUnknownSideEffects(u);
|
|
112
|
+
const id = graph_1.UnknownSideEffect.id(u);
|
|
113
|
+
if (select.has(id)) {
|
|
114
|
+
df.markIdForUnknownSideEffects(id, graph_1.UnknownSideEffect.linkTo(u));
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
return df;
|
|
@@ -142,11 +140,9 @@ exports.Dataflow = {
|
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
for (const u of graph.unknownSideEffects) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
else if (select.has(u)) {
|
|
149
|
-
df.markIdForUnknownSideEffects(u);
|
|
143
|
+
const id = graph_1.UnknownSideEffect.id(u);
|
|
144
|
+
if (select.has(id)) {
|
|
145
|
+
df.markIdForUnknownSideEffects(id, graph_1.UnknownSideEffect.linkTo(u));
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
return df;
|
|
@@ -58,7 +58,7 @@ function diffOutgoingEdges(ctx) {
|
|
|
58
58
|
}
|
|
59
59
|
function diffRootVertices(ctx) {
|
|
60
60
|
(0, diff_1.setDifference)(ctx.left.rootIds(), ctx.right.rootIds(), { ...ctx, position: `${ctx.position}Root vertices differ in graphs. ` });
|
|
61
|
-
(0, diff_1.setDifference)(new Set(
|
|
61
|
+
(0, diff_1.setDifference)(new Set(ctx.left.unknownSideEffects.values().map(graph_1.UnknownSideEffect.id)), new Set(ctx.right.unknownSideEffects.values().map(graph_1.UnknownSideEffect.id)), { ...ctx, position: `${ctx.position}Unknown side effects differ in graphs. ` });
|
|
62
62
|
}
|
|
63
63
|
function diffFunctionArgumentsReferences(fn, a, b, ctx) {
|
|
64
64
|
if (a === '<value>' || b === '<value>') {
|
|
@@ -93,12 +93,8 @@ exports.GraphHelper = {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
for (const unknown of graph.unknownSideEffects) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
resultGraph.markIdForUnknownSideEffects(resolve(unknown));
|
|
101
|
-
}
|
|
96
|
+
const { id, linkTo } = graph_1.UnknownSideEffect.split(unknown);
|
|
97
|
+
resultGraph.markIdForUnknownSideEffects(resolve(id), linkTo);
|
|
102
98
|
}
|
|
103
99
|
return resultGraph;
|
|
104
100
|
},
|
|
@@ -160,6 +160,30 @@ export type UnknownSideEffect = NodeId | {
|
|
|
160
160
|
id: NodeId;
|
|
161
161
|
linkTo: LinkTo<RegExp>;
|
|
162
162
|
};
|
|
163
|
+
/** A {@link UnknownSideEffect} that carries a {@link LinkTo} target. */
|
|
164
|
+
export type LinkedUnknownSideEffect = {
|
|
165
|
+
id: NodeId;
|
|
166
|
+
linkTo: LinkTo<RegExp>;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
170
|
+
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
|
171
|
+
* checks so the object/non-object discrimination lives in one place.
|
|
172
|
+
*/
|
|
173
|
+
export declare const UnknownSideEffect: {
|
|
174
|
+
readonly name: "UnknownSideEffect";
|
|
175
|
+
/** Whether the effect carries a {@link LinkTo} target (i.e., is the object variant). */
|
|
176
|
+
readonly isLinked: (this: void, effect: UnknownSideEffect) => effect is LinkedUnknownSideEffect;
|
|
177
|
+
/** The affected node id, regardless of whether the effect is plain or linked. */
|
|
178
|
+
readonly id: (this: void, effect: UnknownSideEffect) => NodeId;
|
|
179
|
+
/** The {@link LinkTo} target of the effect, or `undefined` if it is a plain (unlinked) one. */
|
|
180
|
+
readonly linkTo: (this: void, effect: UnknownSideEffect) => LinkTo<RegExp> | undefined;
|
|
181
|
+
/** Both {@link id} and {@link linkTo} in one pass (a single discrimination); use when you need both. */
|
|
182
|
+
readonly split: (this: void, effect: UnknownSideEffect) => {
|
|
183
|
+
id: NodeId;
|
|
184
|
+
linkTo: LinkTo<RegExp> | undefined;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
163
187
|
/**
|
|
164
188
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
165
189
|
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataflowGraph = exports.FunctionArgument = void 0;
|
|
3
|
+
exports.DataflowGraph = exports.UnknownSideEffect = exports.FunctionArgument = void 0;
|
|
4
4
|
const assert_1 = require("../../util/assert");
|
|
5
5
|
const vertex_1 = require("./vertex");
|
|
6
6
|
const arrays_1 = require("../../util/collections/arrays");
|
|
@@ -121,6 +121,30 @@ exports.FunctionArgument = {
|
|
|
121
121
|
return exports.FunctionArgument.isNamed(arg) && arg.name === name;
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
126
|
+
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
|
127
|
+
* checks so the object/non-object discrimination lives in one place.
|
|
128
|
+
*/
|
|
129
|
+
exports.UnknownSideEffect = {
|
|
130
|
+
name: 'UnknownSideEffect',
|
|
131
|
+
/** Whether the effect carries a {@link LinkTo} target (i.e., is the object variant). */
|
|
132
|
+
isLinked(effect) {
|
|
133
|
+
return typeof effect === 'object';
|
|
134
|
+
},
|
|
135
|
+
/** The affected node id, regardless of whether the effect is plain or linked. */
|
|
136
|
+
id(effect) {
|
|
137
|
+
return typeof effect === 'object' ? effect.id : effect;
|
|
138
|
+
},
|
|
139
|
+
/** The {@link LinkTo} target of the effect, or `undefined` if it is a plain (unlinked) one. */
|
|
140
|
+
linkTo(effect) {
|
|
141
|
+
return typeof effect === 'object' ? effect.linkTo : undefined;
|
|
142
|
+
},
|
|
143
|
+
/** Both {@link id} and {@link linkTo} in one pass (a single discrimination); use when you need both. */
|
|
144
|
+
split(effect) {
|
|
145
|
+
return typeof effect === 'object' ? effect : { id: effect, linkTo: undefined };
|
|
146
|
+
}
|
|
147
|
+
};
|
|
124
148
|
/**
|
|
125
149
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
126
150
|
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
|
@@ -4,7 +4,7 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
4
4
|
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
|
-
import {
|
|
7
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import { Identifier, type InGraphIdentifierDefinition } from '../../../../../environments/identifier';
|
|
9
9
|
import type { DataflowGraphVertexFunctionDefinition } from '../../../../../graph/vertex';
|
|
10
10
|
import type { ForceArguments } from '../common';
|
|
@@ -41,7 +41,7 @@ function processAttach(name, args, rootId, data) {
|
|
|
41
41
|
const attachedLayer = new environment_1.Environment(result.environment.current).defineAll(injected);
|
|
42
42
|
/* R attaches below `.GlobalEnv`, so existing global bindings shadow the attached ones */
|
|
43
43
|
return { ...result, environment: {
|
|
44
|
-
current: environment_1.REnvironment.
|
|
44
|
+
current: environment_1.REnvironment.attachAt(result.environment.current, attachedLayer, attachedLayer),
|
|
45
45
|
level: result.environment.level
|
|
46
46
|
} };
|
|
47
47
|
}
|
|
@@ -42,3 +42,10 @@ export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier,
|
|
|
42
42
|
export declare function routeWrittenToCustomEnv(result: DataflowInformation, envDef: NamedInGraphIdentifierDefinition & {
|
|
43
43
|
envState: REnvironmentInformation;
|
|
44
44
|
}, newDefAt: NodeId, definedAt?: NodeId): DataflowInformation;
|
|
45
|
+
/**
|
|
46
|
+
* The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
|
|
47
|
+
* an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown
|
|
48
|
+
* or ambiguous, or it names an entry that is not on the search path; callers then attach at {@link DefaultAttachPosition}
|
|
49
|
+
* (as R does, which warns in the last case).
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveAttachPosition<OtherInfo>(posId: NodeId | undefined, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): number | undefined;
|
|
@@ -6,6 +6,7 @@ exports.resolveArgToEnvir = resolveArgToEnvir;
|
|
|
6
6
|
exports.resolveEnvirArg = resolveEnvirArg;
|
|
7
7
|
exports.resolveSymbolToEnvir = resolveSymbolToEnvir;
|
|
8
8
|
exports.routeWrittenToCustomEnv = routeWrittenToCustomEnv;
|
|
9
|
+
exports.resolveAttachPosition = resolveAttachPosition;
|
|
9
10
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
11
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
11
12
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
@@ -13,8 +14,12 @@ const decode_1 = require("../../../../../../project/sigdb/decode");
|
|
|
13
14
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
14
15
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
15
16
|
const define_1 = require("../../../../../environments/define");
|
|
17
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
16
18
|
const prefix_1 = require("../../../../../../util/prefix");
|
|
17
19
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
20
|
+
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
21
|
+
const general_1 = require("../../../../../eval/values/general");
|
|
22
|
+
const logger_1 = require("../../../../../logger");
|
|
18
23
|
/** A tracked env is a real stack environment (not a private custom env) when its current layer is the global or the built-in/base env. */
|
|
19
24
|
function isStackEnvState(envState) {
|
|
20
25
|
return envState.current.globalEnv === true || envState.current.builtInEnv === true;
|
|
@@ -142,4 +147,50 @@ function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
|
|
|
142
147
|
const newEnvironment = (0, define_1.define)({ ...envDef, definedAt: newDefAt, envState: newEnvState }, false, { current: result.environment.current.removeAll(namesToRemove), level: result.environment.level });
|
|
143
148
|
return { ...result, environment: newEnvironment };
|
|
144
149
|
}
|
|
150
|
+
/** A `search()` position must be an integer and may never displace the global environment (R rejects `pos = 1`). */
|
|
151
|
+
function clampAttachPosition(pos) {
|
|
152
|
+
return Number.isFinite(pos) ? Math.max(environment_1.DefaultAttachPosition, Math.trunc(pos)) : undefined;
|
|
153
|
+
}
|
|
154
|
+
/** The number a value denotes, directly or as the single point of an interval (how a numeric literal resolves). */
|
|
155
|
+
function scalarNumber(value) {
|
|
156
|
+
if (value.type === 'number') {
|
|
157
|
+
return 'num' in value.value ? value.value.num : undefined;
|
|
158
|
+
}
|
|
159
|
+
if (value.type === 'interval' && value.startInclusive && value.endInclusive
|
|
160
|
+
&& value.start.type === 'number' && 'num' in value.start.value
|
|
161
|
+
&& value.end.type === 'number' && 'num' in value.end.value
|
|
162
|
+
&& value.start.value.num === value.end.value.num) {
|
|
163
|
+
return value.start.value.num;
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
|
|
169
|
+
* an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown
|
|
170
|
+
* or ambiguous, or it names an entry that is not on the search path; callers then attach at {@link DefaultAttachPosition}
|
|
171
|
+
* (as R does, which warns in the last case).
|
|
172
|
+
*/
|
|
173
|
+
function resolveAttachPosition(posId, data) {
|
|
174
|
+
if (posId === undefined) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const values = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(posId, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx }));
|
|
178
|
+
if (values?.type !== 'set' || values.elements.length !== 1) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
const element = values.elements[0];
|
|
182
|
+
const asNumber = scalarNumber(element);
|
|
183
|
+
if (asNumber !== undefined) {
|
|
184
|
+
return clampAttachPosition(asNumber);
|
|
185
|
+
}
|
|
186
|
+
if (element.type === 'string' && 'str' in element.value) {
|
|
187
|
+
const found = environment_1.REnvironment.searchPosition(data.environment.current, element.value.str);
|
|
188
|
+
if (found === undefined) {
|
|
189
|
+
logger_1.dataflowLogger.warn(`search-path entry '${element.value.str}' does not exist, attaching at the default position`);
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
return clampAttachPosition(found);
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
145
196
|
//# sourceMappingURL=built-in-envir-utils.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import { type ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
@@ -57,7 +57,7 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
|
|
|
57
57
|
tag: vertex_1.VertexType.Value,
|
|
58
58
|
id: tid,
|
|
59
59
|
cds: undefined,
|
|
60
|
-
value: (0, general_1.valueFromTsValue)(target.value)
|
|
60
|
+
value: (0, general_1.valueFromTsValue)((target).value)
|
|
61
61
|
}, environments, false);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
5
5
|
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
6
|
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import { DataflowGraph } from '../../../../../graph/graph';
|
|
8
|
-
import {
|
|
8
|
+
import type { REnvironmentInformation } from '../../../../../environments/environment';
|
|
9
9
|
import type { ReadOnlyFlowrAnalyzerContext, FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
10
10
|
/**
|
|
11
11
|
* Process a function definition, i.e., `function(a, b) { ... }`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation, ControlDependency } from '../../../../../info';
|
|
3
3
|
import type { DataflowGraph } from '../../../../../graph/graph';
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
@@ -28,6 +28,8 @@ interface AttachSpec {
|
|
|
28
28
|
readonly exclude?: ReadonlySet<string>;
|
|
29
29
|
/** attach every export (`import::from` `.all`, `box::use(pkg[...])`) */
|
|
30
30
|
readonly all?: boolean;
|
|
31
|
+
/** `library(pkg, pos = 3)`: the `search()` position to attach at, {@link DefaultAttachPosition} if unset */
|
|
32
|
+
readonly pos?: number;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Process a library call like `library` or `require`
|
|
@@ -41,7 +43,8 @@ export declare function attachExportVertex(graph: DataflowGraph, builtInId: Node
|
|
|
41
43
|
*/
|
|
42
44
|
export declare function loadNodesForNamespace(env: REnvironmentInformation, pack: string): NodeId[];
|
|
43
45
|
/**
|
|
44
|
-
* Attaches `dependency`'s exports
|
|
46
|
+
* Attaches `dependency`'s exports at `spec`'s {@link AttachSpec#pos|search position} (below the global environment by
|
|
47
|
+
* default, see {@link REnvironment.attachAt|attachPackageAt}) and returns the
|
|
45
48
|
* enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
|
|
46
49
|
* and the transitive side-effect propagation.
|
|
47
50
|
*/
|
|
@@ -30,6 +30,7 @@ const common_1 = require("../common");
|
|
|
30
30
|
const linker_1 = require("../../../../linker");
|
|
31
31
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
32
32
|
const r_base_packages_1 = require("../../../../../../util/r-base-packages");
|
|
33
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
33
34
|
/**
|
|
34
35
|
* Process a library call like `library` or `require`
|
|
35
36
|
*/
|
|
@@ -42,15 +43,19 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
42
43
|
return processUse(name, args, rootId, data);
|
|
43
44
|
}
|
|
44
45
|
/* parse the import selection before the library flow rewrites `args` below */
|
|
45
|
-
const
|
|
46
|
+
const parsedSpec = config.fromImports ? parseFromSpec(args) : { namespaceOnly: config.namespaceOnly };
|
|
46
47
|
const params = {
|
|
47
48
|
'package': 'pkg',
|
|
48
|
-
'character.only': 'char'
|
|
49
|
+
'character.only': 'char',
|
|
50
|
+
/* last, so the positional fallback keeps its previous order */
|
|
51
|
+
'pos': 'pos'
|
|
49
52
|
};
|
|
50
53
|
const resolveArgs = { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx };
|
|
51
54
|
const argMaps = (0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params);
|
|
52
55
|
const packageId = Array.from(new Set(argMaps.get('pkg')));
|
|
53
56
|
const charId = Array.from(new Set(argMaps.get('char')));
|
|
57
|
+
/* `import::from` has no `pos`; its extra arguments name exports */
|
|
58
|
+
const spec = { ...parsedSpec, pos: config.fromImports ? undefined : (0, built_in_envir_utils_1.resolveAttachPosition)(argMaps.get('pos')?.[0], data) };
|
|
54
59
|
let namesToLoad = packageId.map(v => r_argument_1.RArgument.getValue(args, v));
|
|
55
60
|
//check if library name provided
|
|
56
61
|
namesToLoad = namesToLoad.filter(v => v !== undefined && (v.type === type_1.RType.Symbol || v.type === type_1.RType.String));
|
|
@@ -160,7 +165,7 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
160
165
|
// `p::fn` can still link back to this call. requireNamespace/loadNamespace are recorded too, since
|
|
161
166
|
// they equally make `p::fn` valid.
|
|
162
167
|
if (info.environment.level >= 0) {
|
|
163
|
-
info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, data.cds);
|
|
168
|
+
info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, spec.pos, data.cds);
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
}
|
|
@@ -311,7 +316,7 @@ const libraryLoadMarker = ' library-load';
|
|
|
311
316
|
* `definedAt` is the load call. This lets an explicit `pack::fn` link back via {@link loadNodesForNamespace}
|
|
312
317
|
* even without a signature database.
|
|
313
318
|
*/
|
|
314
|
-
function recordUnresolvedLibraryLoad(envInfo, pack, rootId, cds) {
|
|
319
|
+
function recordUnresolvedLibraryLoad(envInfo, pack, rootId, pos, cds) {
|
|
315
320
|
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define({
|
|
316
321
|
name: identifier_1.Identifier.make(libraryLoadMarker, pack),
|
|
317
322
|
type: identifier_1.ReferenceType.Function,
|
|
@@ -319,7 +324,7 @@ function recordUnresolvedLibraryLoad(envInfo, pack, rootId, cds) {
|
|
|
319
324
|
definedAt: rootId,
|
|
320
325
|
cds: cds?.slice()
|
|
321
326
|
});
|
|
322
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
327
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, pos) };
|
|
323
328
|
}
|
|
324
329
|
/**
|
|
325
330
|
* The load calls (`library()`/`require()`) that brought package `pack` into scope without a database, collected from
|
|
@@ -382,7 +387,8 @@ function isSubsetAttach(spec) {
|
|
|
382
387
|
return spec.include !== undefined && !spec.all;
|
|
383
388
|
}
|
|
384
389
|
/**
|
|
385
|
-
* Attaches `dependency`'s exports
|
|
390
|
+
* Attaches `dependency`'s exports at `spec`'s {@link AttachSpec#pos|search position} (below the global environment by
|
|
391
|
+
* default, see {@link REnvironment.attachAt|attachPackageAt}) and returns the
|
|
386
392
|
* enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
|
|
387
393
|
* and the transitive side-effect propagation.
|
|
388
394
|
*/
|
|
@@ -396,14 +402,14 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
|
|
|
396
402
|
const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
|
|
397
403
|
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType)
|
|
398
404
|
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
399
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
405
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
|
|
400
406
|
}
|
|
401
407
|
// full attach: imports layer at the bottom, namespace (exports) layer on top
|
|
402
408
|
let importsEnv = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.Imports);
|
|
403
409
|
importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
|
|
404
410
|
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
|
|
405
411
|
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
406
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
412
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
|
|
407
413
|
}
|
|
408
414
|
/** A namespace-only load is subsumed by any layer for `pack`; a full attach ignores a mere {@link EnvType.LoadedNamespace}. */
|
|
409
415
|
function blocksAttach(layer, namespaceOnly) {
|
|
@@ -513,7 +519,7 @@ function attachProjectImports(env, ctx) {
|
|
|
513
519
|
return env;
|
|
514
520
|
}
|
|
515
521
|
const layer = new environment_1.Environment(env.current).asLibrary(layerNamespace, environment_1.EnvType.Imports).defineAll(toDefine);
|
|
516
|
-
return { level: env.level, current: environment_1.REnvironment.
|
|
522
|
+
return { level: env.level, current: environment_1.REnvironment.attachAt(env.current, layer, layer) };
|
|
517
523
|
}
|
|
518
524
|
/** attach every project-level environment layer in order: base R namespaces, the project's own `importFrom` symbols, then its declared dependencies */
|
|
519
525
|
function attachProject(env, ctx) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** Used to separate S7 dispatch info in identifiers */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** e.g. new_generic(name, dispatch_args, fun=NULL) */
|
|
@@ -25,4 +25,10 @@ export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo &
|
|
|
25
25
|
export declare function processMakeConstructor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
|
|
26
26
|
readonly mode?: readonly ('s7' | 's3' | 's4')[];
|
|
27
27
|
}): DataflowInformation;
|
|
28
|
+
/**
|
|
29
|
+
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
30
|
+
* carry one (`new_class`, `new_generic`, ...). It stands for no argument in the source, so consumers that reason
|
|
31
|
+
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const S7SyntheticFunArgSuffix = "-s7-new-generic-fun-arg";
|
|
28
34
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S7SyntheticFunArgSuffix = void 0;
|
|
3
4
|
exports.processS7NewGeneric = processS7NewGeneric;
|
|
4
5
|
exports.processMakeConstructor = processMakeConstructor;
|
|
5
6
|
const known_call_handling_1 = require("../known-call-handling");
|
|
@@ -88,6 +89,12 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
88
89
|
}
|
|
89
90
|
return info;
|
|
90
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
94
|
+
* carry one (`new_class`, `new_generic`, ...). It stands for no argument in the source, so consumers that reason
|
|
95
|
+
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
96
|
+
*/
|
|
97
|
+
exports.S7SyntheticFunArgSuffix = '-s7-new-generic-fun-arg';
|
|
91
98
|
// 'function([dispatch_args],...) S7_dispatch()'; returns the value id
|
|
92
99
|
function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
93
100
|
const argNameId = rootId + '-s7-new-generic-fun-arg-name';
|
|
@@ -124,7 +131,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
124
131
|
index: 0
|
|
125
132
|
},
|
|
126
133
|
location: r,
|
|
127
|
-
content: identifier_1.Identifier.make('S7_dispatch', '
|
|
134
|
+
content: identifier_1.Identifier.make('S7_dispatch', 'S7'),
|
|
128
135
|
};
|
|
129
136
|
const funcBody = {
|
|
130
137
|
type: type_1.RType.FunctionCall,
|
|
@@ -205,7 +212,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
205
212
|
idMap.set(funcNameId, funcName);
|
|
206
213
|
idMap.set(funcBody.info.id, funcBody);
|
|
207
214
|
idMap.set(fdefId, argValue);
|
|
208
|
-
const argId = rootId +
|
|
215
|
+
const argId = rootId + exports.S7SyntheticFunArgSuffix;
|
|
209
216
|
const argument = {
|
|
210
217
|
type: type_1.RType.Argument,
|
|
211
218
|
lexeme: 'fun',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** e.g. UseMethod(generic, object) */
|
|
@@ -73,8 +73,8 @@ function asSearchPathEnv(name, data) {
|
|
|
73
73
|
if (fixed !== undefined) {
|
|
74
74
|
return fixed;
|
|
75
75
|
}
|
|
76
|
-
if (name.startsWith(
|
|
77
|
-
const pkg = name.slice(
|
|
76
|
+
if (name.startsWith(environment_1.SearchPathPackagePrefix)) {
|
|
77
|
+
const pkg = name.slice(environment_1.SearchPathPackagePrefix.length);
|
|
78
78
|
for (let env = environment_1.REnvironment.findGlobal(data.environment.current).parent; env !== undefined && !env.builtInEnv; env = env.parent) {
|
|
79
79
|
if (env.n === pkg && env.t === environment_1.EnvType.Namespace) {
|
|
80
80
|
return { current: env, level: 0 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|