@eagleoutice/flowr 2.8.15 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -26
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
- package/abstract-interpretation/data-frame/resolve-args.js +2 -1
- package/benchmark/slicer.d.ts +0 -16
- package/benchmark/slicer.js +0 -47
- package/benchmark/stats/print.js +0 -6
- package/benchmark/stats/stats.d.ts +0 -3
- package/benchmark/summarizer/second-phase/process.js +0 -6
- package/cli/benchmark-app.d.ts +0 -1
- package/cli/benchmark-app.js +0 -1
- package/cli/benchmark-helper-app.d.ts +0 -1
- package/cli/benchmark-helper-app.js +1 -5
- package/cli/common/options.d.ts +0 -10
- package/cli/common/options.js +0 -2
- package/cli/common/scripts-info.d.ts +0 -10
- package/cli/repl/server/connection.js +1 -1
- package/config.d.ts +0 -15
- package/config.js +0 -21
- package/control-flow/cfg-dead-code.js +0 -3
- package/control-flow/extract-cfg.js +4 -0
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +11 -4
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-config.d.ts +1 -0
- package/dataflow/environments/built-in.d.ts +9 -3
- package/dataflow/environments/built-in.js +15 -7
- package/dataflow/environments/default-builtin-config.d.ts +10 -1
- package/dataflow/environments/default-builtin-config.js +6 -4
- package/dataflow/environments/define.d.ts +4 -11
- package/dataflow/environments/define.js +16 -96
- package/dataflow/environments/diff.js +3 -2
- package/dataflow/environments/environment.d.ts +17 -6
- package/dataflow/environments/environment.js +69 -18
- package/dataflow/environments/identifier.d.ts +92 -6
- package/dataflow/environments/identifier.js +159 -1
- package/dataflow/environments/resolve-by-name.d.ts +4 -4
- package/dataflow/environments/resolve-by-name.js +24 -8
- package/dataflow/eval/resolve/resolve.d.ts +10 -6
- package/dataflow/eval/resolve/resolve.js +12 -7
- package/dataflow/extractor.js +6 -3
- package/dataflow/fn/higher-order-function.js +4 -4
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +10 -8
- package/dataflow/graph/diff-dataflow-graph.js +6 -4
- package/dataflow/graph/edge.d.ts +48 -31
- package/dataflow/graph/edge.js +66 -60
- package/dataflow/graph/graph.d.ts +7 -7
- package/dataflow/graph/quads.js +1 -1
- package/dataflow/graph/resolve-graph.js +1 -1
- package/dataflow/graph/unknown-replacement.d.ts +2 -1
- package/dataflow/graph/vertex.d.ts +2 -103
- package/dataflow/graph/vertex.js +0 -44
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +26 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +12 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +4 -16
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -1
- package/dataflow/internal/process/process-named-call.js +0 -1
- package/dataflow/internal/process/process-symbol.d.ts +3 -1
- package/dataflow/internal/process/process-symbol.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +2 -2
- package/dataflow/origin/dfg-get-origin.js +4 -4
- package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
- package/documentation/data/interface/doc-writing-code.d.ts +6 -0
- package/documentation/data/interface/doc-writing-code.js +176 -0
- package/documentation/doc-util/doc-types.d.ts +3 -1
- package/documentation/doc-util/doc-types.js +4 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-analyzer.js +17 -2
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-dataflow-graph.js +9 -8
- package/documentation/wiki-interface.js +8 -164
- package/documentation/wiki-mk/doc-context.d.ts +12 -1
- package/documentation/wiki-mk/doc-context.js +21 -4
- package/documentation/wiki-normalized-ast.js +5 -0
- package/linter/linter-rules.d.ts +3 -3
- package/linter/rules/absolute-path.js +23 -23
- package/linter/rules/dataframe-access-validation.js +2 -1
- package/linter/rules/deprecated-functions.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +1 -1
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/seeded-randomness.d.ts +2 -2
- package/linter/rules/seeded-randomness.js +5 -4
- package/linter/rules/unused-definition.js +4 -4
- package/package.json +5 -5
- package/project/context/flowr-analyzer-context.d.ts +17 -1
- package/project/context/flowr-analyzer-context.js +17 -1
- package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
- package/project/context/flowr-analyzer-meta-context.js +47 -0
- package/project/flowr-analyzer.d.ts +17 -1
- package/project/flowr-analyzer.js +18 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
- package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
- package/r-bridge/data/data.d.ts +8 -3
- package/r-bridge/data/data.js +9 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-filters.js +2 -1
- package/search/search-executor/search-enrichers.d.ts +1 -2
- package/search/search-executor/search-enrichers.js +2 -1
- package/slicing/static/slice-call.js +5 -5
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/common-syntax-probability.js +3 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
- package/statistics/features/supported/used-functions/used-functions.js +3 -2
- package/util/mermaid/dfg.js +3 -3
- package/util/simple-df/dfg-ascii.js +5 -5
- package/util/version.js +1 -1
- package/util/containers.d.ts +0 -66
- package/util/containers.js +0 -143
package/util/mermaid/dfg.js
CHANGED
|
@@ -131,7 +131,7 @@ function mermaidNodeBrackets(tag) {
|
|
|
131
131
|
* Prints an identifier definition in a human-readable format.
|
|
132
132
|
*/
|
|
133
133
|
function printIdentifier(id) {
|
|
134
|
-
return `**${id.name}** (id: ${id.nodeId}, type: ${identifier_1.ReferenceTypeReverseMapping.get(id.type)},${id.cds ? ' cds: {' + id.cds.map(c => c.id + (c.when ? '+' : '-')).join(',') + '},' : ''} def. @${id.definedAt})`;
|
|
134
|
+
return `**${id.name ? identifier_1.Identifier.toString(id.name) : 'undefined'}** (id: ${id.nodeId}, type: ${identifier_1.ReferenceTypeReverseMapping.get(id.type)},${id.cds ? ' cds: {' + id.cds.map(c => c.id + (c.when ? '+' : '-')).join(',') + '},' : ''} def. @${id.definedAt})`;
|
|
135
135
|
}
|
|
136
136
|
function printEnvironmentToLines(env) {
|
|
137
137
|
if (env === undefined) {
|
|
@@ -190,12 +190,12 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
190
190
|
}
|
|
191
191
|
const originalTarget = target;
|
|
192
192
|
target = (0, mermaid_1.escapeId)(target);
|
|
193
|
-
const edgeTypes = typeof edge.types == 'number' ? new Set(
|
|
193
|
+
const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
|
|
194
194
|
const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
|
|
195
195
|
if (!mermaid.presentEdges.has(edgeId)) {
|
|
196
196
|
mermaid.presentEdges.add(edgeId);
|
|
197
197
|
const style = (0, built_in_1.isBuiltIn)(target) ? '-.->' : '-->';
|
|
198
|
-
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ?
|
|
198
|
+
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ? edge_1.DfEdge.typeToName(e) : e).join(', ')}"| ${idPrefix}${target}`);
|
|
199
199
|
if (mermaid.mark?.has(id + '->' + target)) {
|
|
200
200
|
// who invented this syntax?!
|
|
201
201
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dfgToAscii = dfgToAscii;
|
|
4
4
|
const dagre_1 = require("dagre");
|
|
5
|
-
const edge_1 = require("../../dataflow/graph/edge");
|
|
6
5
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
7
6
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
7
|
+
const edge_1 = require("../../dataflow/graph/edge");
|
|
8
8
|
function combineAscii(has, add) {
|
|
9
9
|
if (has === ' ' || has === add) {
|
|
10
10
|
return add;
|
|
@@ -97,12 +97,12 @@ function dfgToAscii(dfg) {
|
|
|
97
97
|
let longestId = 0;
|
|
98
98
|
for (const [from, edges] of dfg.edges()) {
|
|
99
99
|
longestId = Math.max(longestId, String(from).length);
|
|
100
|
-
for (const [to,
|
|
100
|
+
for (const [to, e] of edges) {
|
|
101
101
|
if (!g.hasNode(String(from)) || !g.hasNode(String(to)) || edgesDone.has(`${to}-${from}`)) {
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
longestId = Math.max(longestId, String(to).length);
|
|
105
|
-
g.setEdge(String(from), String(to),
|
|
105
|
+
g.setEdge(String(from), String(to), edge_1.DfEdge.typesToNames(e));
|
|
106
106
|
edgesDone.add(`${from}-${to}`);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -116,11 +116,11 @@ function dfgToAscii(dfg) {
|
|
|
116
116
|
const edgeLines = [];
|
|
117
117
|
// add all edges
|
|
118
118
|
for (const [from, edges] of dfg.edges()) {
|
|
119
|
-
for (const [to,
|
|
119
|
+
for (const [to, e] of edges) {
|
|
120
120
|
if (!g.hasNode(String(from)) || !g.hasNode(String(to))) {
|
|
121
121
|
continue;
|
|
122
122
|
}
|
|
123
|
-
edgeLines.push(`${from.toString().padStart(longestId, ' ')} -> ${to.toString().padStart(longestId, ' ')}: ${Array.from(
|
|
123
|
+
edgeLines.push(`${from.toString().padStart(longestId, ' ')} -> ${to.toString().padStart(longestId, ' ')}: ${Array.from(edge_1.DfEdge.typesToNames(e)).join(', ')}`);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
// always merge two edgelines with padding
|
package/util/version.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
|
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const assert_1 = require("./assert");
|
|
8
8
|
// this is automatically replaced with the current version by release-it
|
|
9
|
-
const version = '2.
|
|
9
|
+
const version = '2.9.0';
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
12
12
|
*/
|
package/util/containers.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { REnvironmentInformation } from '../dataflow/environments/environment';
|
|
2
|
-
import type { Identifier } from '../dataflow/environments/identifier';
|
|
3
|
-
import { type ContainerIndices, type ContainerIndicesCollection, type IndexIdentifier } from '../dataflow/graph/vertex';
|
|
4
|
-
import type { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access';
|
|
5
|
-
import type { RArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
6
|
-
import { type RFunctionArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
|
-
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
|
-
/**
|
|
9
|
-
* Returns the accessed and access argument of an access operation by filtering the operation arguments.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getAccessOperands<OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[]): {
|
|
12
|
-
accessedArg: RArgument<OtherInfo & ParentInformation> | undefined;
|
|
13
|
-
accessArg: RArgument<OtherInfo & ParentInformation> | undefined;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Resolves the passed name within the passed environment and returns the indicesCollection of the resolved definitions.
|
|
17
|
-
* @param name - Name to resolve
|
|
18
|
-
* @param environment - Environment in which name is resolved
|
|
19
|
-
* @returns The indicesCollection of the resolved definitions
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveIndicesByName(name: Identifier, environment: REnvironmentInformation): ContainerIndices[] | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
|
|
24
|
-
*
|
|
25
|
-
* If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
|
|
26
|
-
* @param accessedArg - The argument to resolve
|
|
27
|
-
* @param accessArg - The argument which is used to filter the indices
|
|
28
|
-
* @param environment - The environment in which {@link accessedArg} is resolved
|
|
29
|
-
* @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
|
|
30
|
-
* @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
|
|
31
|
-
*/
|
|
32
|
-
export declare function resolveSingleIndex(accessedArg: {
|
|
33
|
-
lexeme: string;
|
|
34
|
-
}, accessArg: {
|
|
35
|
-
lexeme: string;
|
|
36
|
-
}, environment: REnvironmentInformation, isIndexBasedAccess: boolean): ContainerIndicesCollection;
|
|
37
|
-
/**
|
|
38
|
-
* Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
|
|
39
|
-
* @param indicesCollection - The {@link ContainerIndicesCollection} to filter
|
|
40
|
-
* @param accessArg - The argument which is used to filter {@link indicesCollection}
|
|
41
|
-
* @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
|
|
42
|
-
* @returns The filtered copy of {@link indicesCollection}
|
|
43
|
-
*/
|
|
44
|
-
export declare function filterIndices(indicesCollection: ContainerIndicesCollection, accessArg: {
|
|
45
|
-
lexeme: string;
|
|
46
|
-
}, isIndexBasedAccess: boolean): ContainerIndicesCollection;
|
|
47
|
-
/**
|
|
48
|
-
* Constructs the definition of a nested access.
|
|
49
|
-
*
|
|
50
|
-
* Example:
|
|
51
|
-
* ```r
|
|
52
|
-
* person$credentials$username
|
|
53
|
-
* ```
|
|
54
|
-
* would result in a list with the index `credentials`, which has the subIndex `username`.
|
|
55
|
-
* @param accessedArg - The top level argument that is accessed
|
|
56
|
-
* @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
|
|
57
|
-
* @param constructIdentifier - A function that constructs the identifier for the index from the argument
|
|
58
|
-
* @returns The constructed nested access
|
|
59
|
-
*/
|
|
60
|
-
export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices, constructIdentifier: (arg: RArgument<OtherInfo & ParentInformation>) => IndexIdentifier): ContainerIndices[];
|
|
61
|
-
/**
|
|
62
|
-
* Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
|
|
63
|
-
* @param indicesCollection - Indices where to add the sub indices.
|
|
64
|
-
* @param leafSubIndices - Indices that are added to the leaf indices.
|
|
65
|
-
*/
|
|
66
|
-
export declare function addSubIndicesToLeafIndices(indicesCollection: ContainerIndices[], leafSubIndices: ContainerIndices[]): ContainerIndices[];
|
package/util/containers.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessOperands = getAccessOperands;
|
|
4
|
-
exports.resolveIndicesByName = resolveIndicesByName;
|
|
5
|
-
exports.resolveSingleIndex = resolveSingleIndex;
|
|
6
|
-
exports.filterIndices = filterIndices;
|
|
7
|
-
exports.constructNestedAccess = constructNestedAccess;
|
|
8
|
-
exports.addSubIndicesToLeafIndices = addSubIndicesToLeafIndices;
|
|
9
|
-
const resolve_by_name_1 = require("../dataflow/environments/resolve-by-name");
|
|
10
|
-
const vertex_1 = require("../dataflow/graph/vertex");
|
|
11
|
-
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
12
|
-
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
13
|
-
/**
|
|
14
|
-
* Returns the accessed and access argument of an access operation by filtering the operation arguments.
|
|
15
|
-
*/
|
|
16
|
-
function getAccessOperands(args) {
|
|
17
|
-
const nonEmptyArgs = args.filter(arg => arg !== r_function_call_1.EmptyArgument);
|
|
18
|
-
const accessedArg = nonEmptyArgs.find(arg => arg.info.role === "accessed" /* RoleInParent.Accessed */);
|
|
19
|
-
const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-acc" /* RoleInParent.IndexAccess */);
|
|
20
|
-
return { accessedArg, accessArg };
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the passed name within the passed environment and returns the indicesCollection of the resolved definitions.
|
|
24
|
-
* @param name - Name to resolve
|
|
25
|
-
* @param environment - Environment in which name is resolved
|
|
26
|
-
* @returns The indicesCollection of the resolved definitions
|
|
27
|
-
*/
|
|
28
|
-
function resolveIndicesByName(name, environment) {
|
|
29
|
-
const definitions = (0, resolve_by_name_1.resolveByNameAnyType)(name, environment);
|
|
30
|
-
return definitions?.flatMap(def => def?.indicesCollection ?? []);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
|
|
34
|
-
*
|
|
35
|
-
* If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
|
|
36
|
-
* @param accessedArg - The argument to resolve
|
|
37
|
-
* @param accessArg - The argument which is used to filter the indices
|
|
38
|
-
* @param environment - The environment in which {@link accessedArg} is resolved
|
|
39
|
-
* @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
|
|
40
|
-
* @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
|
|
41
|
-
*/
|
|
42
|
-
function resolveSingleIndex(accessedArg, accessArg, environment, isIndexBasedAccess) {
|
|
43
|
-
const indicesCollection = resolveIndicesByName(accessedArg.lexeme, environment);
|
|
44
|
-
const accessedIndicesCollection = filterIndices(indicesCollection, accessArg, isIndexBasedAccess);
|
|
45
|
-
// If the accessed indices couldn't be resolved, overapproximate by returning the original indices.
|
|
46
|
-
// This could also be the case, when nothing is acccessed, but we better be safe.
|
|
47
|
-
if (accessedIndicesCollection === undefined) {
|
|
48
|
-
return indicesCollection;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return accessedIndicesCollection;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
|
|
56
|
-
* @param indicesCollection - The {@link ContainerIndicesCollection} to filter
|
|
57
|
-
* @param accessArg - The argument which is used to filter {@link indicesCollection}
|
|
58
|
-
* @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
|
|
59
|
-
* @returns The filtered copy of {@link indicesCollection}
|
|
60
|
-
*/
|
|
61
|
-
function filterIndices(indicesCollection, accessArg, isIndexBasedAccess) {
|
|
62
|
-
let accessedIndicesCollection = undefined;
|
|
63
|
-
for (const indices of indicesCollection ?? []) {
|
|
64
|
-
const filteredIndices = indices.indices.filter(index => (0, vertex_1.isAccessed)(index, accessArg.lexeme, isIndexBasedAccess));
|
|
65
|
-
if (filteredIndices.length === 0) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
accessedIndicesCollection ??= [];
|
|
69
|
-
accessedIndicesCollection.push({
|
|
70
|
-
indices: filteredIndices,
|
|
71
|
-
isContainer: indices.isContainer
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return accessedIndicesCollection;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Constructs the definition of a nested access.
|
|
78
|
-
*
|
|
79
|
-
* Example:
|
|
80
|
-
* ```r
|
|
81
|
-
* person$credentials$username
|
|
82
|
-
* ```
|
|
83
|
-
* would result in a list with the index `credentials`, which has the subIndex `username`.
|
|
84
|
-
* @param accessedArg - The top level argument that is accessed
|
|
85
|
-
* @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
|
|
86
|
-
* @param constructIdentifier - A function that constructs the identifier for the index from the argument
|
|
87
|
-
* @returns The constructed nested access
|
|
88
|
-
*/
|
|
89
|
-
function constructNestedAccess(accessedArg, leafIndices, constructIdentifier) {
|
|
90
|
-
const accessed = accessedArg.accessed;
|
|
91
|
-
const accesses = accessedArg.access.filter(arg => arg !== r_function_call_1.EmptyArgument).map(arg => arg);
|
|
92
|
-
const indices = [];
|
|
93
|
-
for (const access of accesses) {
|
|
94
|
-
const newIndices = {
|
|
95
|
-
indices: [
|
|
96
|
-
{
|
|
97
|
-
identifier: constructIdentifier(access),
|
|
98
|
-
nodeId: access.info.id,
|
|
99
|
-
subIndices: [leafIndices],
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
isContainer: false,
|
|
103
|
-
};
|
|
104
|
-
if (accessed.type === type_1.RType.Access) {
|
|
105
|
-
const nestedIndices = constructNestedAccess(accessed, newIndices, constructIdentifier);
|
|
106
|
-
indices.push(...nestedIndices);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
indices.push(newIndices);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return indices;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
|
|
116
|
-
* @param indicesCollection - Indices where to add the sub indices.
|
|
117
|
-
* @param leafSubIndices - Indices that are added to the leaf indices.
|
|
118
|
-
*/
|
|
119
|
-
function addSubIndicesToLeafIndices(indicesCollection, leafSubIndices) {
|
|
120
|
-
const result = [];
|
|
121
|
-
for (const indices of indicesCollection) {
|
|
122
|
-
const newIndices = [];
|
|
123
|
-
for (const index of indices.indices) {
|
|
124
|
-
let newSubIndices = [];
|
|
125
|
-
if ((0, vertex_1.isParentContainerIndex)(index)) {
|
|
126
|
-
newSubIndices = addSubIndicesToLeafIndices(index.subIndices, leafSubIndices);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
newSubIndices = leafSubIndices;
|
|
130
|
-
}
|
|
131
|
-
newIndices.push({
|
|
132
|
-
...index,
|
|
133
|
-
subIndices: newSubIndices,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
result.push({
|
|
137
|
-
...indices,
|
|
138
|
-
indices: newIndices,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=containers.js.map
|