@eagleoutice/flowr 2.6.3 → 2.7.2
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 +22 -22
- package/abstract-interpretation/absint-visitor.d.ts +160 -0
- package/abstract-interpretation/absint-visitor.js +279 -0
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -7
- package/abstract-interpretation/data-frame/dataframe-domain.js +26 -16
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +6 -4
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +11 -14
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +10 -9
- package/abstract-interpretation/data-frame/mappers/arguments.js +8 -5
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +18 -18
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +53 -58
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +7 -5
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +26 -29
- package/abstract-interpretation/data-frame/semantics.js +48 -44
- package/abstract-interpretation/data-frame/shape-inference.d.ts +52 -28
- package/abstract-interpretation/data-frame/shape-inference.js +67 -90
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -0
- package/abstract-interpretation/domains/abstract-domain.js +3 -2
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +2 -2
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +4 -4
- package/abstract-interpretation/domains/interval-domain.js +3 -6
- package/abstract-interpretation/domains/lattice.d.ts +2 -0
- package/abstract-interpretation/domains/lattice.js +3 -1
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/positive-interval-domain.js +1 -1
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +2 -2
- package/abstract-interpretation/domains/satisfiable-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +104 -0
- package/abstract-interpretation/domains/set-range-domain.js +406 -0
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +2 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.js +2 -2
- package/abstract-interpretation/domains/singleton-domain.d.ts +2 -2
- package/abstract-interpretation/domains/singleton-domain.js +2 -2
- package/benchmark/slicer.d.ts +2 -1
- package/benchmark/slicer.js +50 -29
- package/benchmark/stats/print.js +8 -5
- package/benchmark/stats/stats.d.ts +3 -2
- package/benchmark/summarizer/data.d.ts +11 -8
- package/benchmark/summarizer/first-phase/process.js +11 -8
- package/benchmark/summarizer/second-phase/process.js +24 -18
- package/cli/common/options.d.ts +431 -8
- package/cli/common/options.js +1 -1
- package/cli/common/scripts-info.d.ts +431 -7
- package/cli/flowr-main-options.d.ts +102 -2
- package/cli/flowr.d.ts +102 -2
- package/cli/repl/commands/repl-commands.d.ts +25 -0
- package/cli/repl/commands/repl-query.js +17 -5
- package/cli/wiki.d.ts +13 -0
- package/cli/wiki.js +7 -2
- package/config.d.ts +4 -4
- package/config.js +1 -1
- package/control-flow/basic-cfg-guided-visitor.js +7 -8
- package/control-flow/cfg-dead-code.js +3 -2
- package/control-flow/control-flow-graph.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +4 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +3 -0
- package/core/steps/all/static-slicing/00-slice.js +2 -1
- package/core/steps/pipeline/default-pipelines.d.ts +42 -42
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/append.d.ts +5 -0
- package/dataflow/environments/append.js +6 -20
- package/dataflow/environments/built-in.d.ts +2 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/clone.js +3 -27
- package/dataflow/environments/define.d.ts +7 -3
- package/dataflow/environments/define.js +9 -56
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.d.ts +48 -28
- package/dataflow/environments/environment.js +187 -62
- package/dataflow/environments/overwrite.js +2 -45
- package/dataflow/environments/reference-to-maybe.d.ts +13 -0
- package/dataflow/environments/reference-to-maybe.js +54 -0
- package/dataflow/environments/resolve-by-name.d.ts +6 -1
- package/dataflow/environments/resolve-by-name.js +56 -4
- package/dataflow/environments/scoping.d.ts +2 -2
- package/dataflow/environments/scoping.js +7 -7
- package/dataflow/eval/resolve/alias-tracking.d.ts +10 -4
- package/dataflow/eval/resolve/alias-tracking.js +16 -14
- package/dataflow/eval/resolve/resolve-argument.d.ts +2 -1
- package/dataflow/eval/resolve/resolve-argument.js +8 -8
- package/dataflow/eval/resolve/resolve.d.ts +13 -11
- package/dataflow/eval/resolve/resolve.js +16 -15
- package/dataflow/extractor.js +1 -7
- package/dataflow/fn/higher-order-function.d.ts +2 -1
- package/dataflow/fn/higher-order-function.js +4 -4
- package/dataflow/graph/dataflowgraph-builder.d.ts +9 -5
- package/dataflow/graph/dataflowgraph-builder.js +21 -11
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/graph.d.ts +10 -2
- package/dataflow/graph/graph.js +41 -12
- package/dataflow/graph/invert-dfg.d.ts +3 -2
- package/dataflow/graph/invert-dfg.js +3 -3
- package/dataflow/graph/resolve-graph.d.ts +2 -1
- package/dataflow/graph/resolve-graph.js +2 -2
- package/dataflow/graph/vertex.d.ts +3 -3
- package/dataflow/graph/vertex.js +3 -3
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.d.ts +2 -0
- package/dataflow/internal/linker.js +13 -19
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +7 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +12 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +9 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +8 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -5
- package/dataflow/internal/process/functions/call/common.js +2 -3
- package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-argument.js +1 -1
- package/dataflow/internal/process/process-symbol.js +1 -1
- package/dataflow/internal/process/process-value.d.ts +1 -1
- package/dataflow/internal/process/process-value.js +7 -7
- package/dataflow/processor.d.ts +1 -5
- package/documentation/doc-capabilities.d.ts +1 -1
- package/documentation/doc-readme.d.ts +1 -1
- package/documentation/doc-util/doc-cfg.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +6 -6
- package/documentation/doc-util/doc-cli-option.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +1 -1
- package/documentation/doc-util/doc-dfg.js +3 -2
- package/documentation/doc-util/doc-files.d.ts +3 -0
- package/documentation/doc-util/doc-files.js +4 -1
- package/documentation/doc-util/doc-normalized-ast.js +5 -4
- package/documentation/doc-util/doc-types.d.ts +1 -1
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/issue-linting-rule.d.ts +1 -1
- package/documentation/wiki-analyzer.d.ts +1 -1
- package/documentation/wiki-analyzer.js +14 -1
- package/documentation/wiki-cfg.d.ts +1 -1
- package/documentation/wiki-core.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-engine.d.ts +1 -1
- package/documentation/wiki-engine.js +9 -10
- package/documentation/wiki-faq.d.ts +1 -1
- package/documentation/wiki-faq.js +0 -1
- package/documentation/wiki-interface.d.ts +1 -1
- package/documentation/wiki-interface.js +12 -13
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.d.ts +54 -1
- package/documentation/wiki-mk/doc-context.js +17 -0
- package/documentation/wiki-mk/doc-maker.d.ts +5 -5
- package/documentation/wiki-mk/doc-maker.js +5 -2
- package/documentation/wiki-normalized-ast.d.ts +1 -1
- package/documentation/wiki-onboarding.d.ts +1 -1
- package/documentation/wiki-overview.d.ts +9 -0
- package/documentation/wiki-overview.js +248 -0
- package/documentation/wiki-query.d.ts +1 -1
- package/documentation/wiki-query.js +17 -1
- package/documentation/wiki-search.d.ts +1 -1
- package/documentation/wiki-setup.d.ts +9 -0
- package/documentation/wiki-setup.js +122 -0
- package/linter/linter-rules.d.ts +2 -2
- package/linter/rules/absolute-path.js +4 -4
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +9 -11
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/network-functions.js +1 -1
- package/linter/rules/seeded-randomness.d.ts +1 -1
- package/linter/rules/seeded-randomness.js +5 -5
- package/linter/rules/unused-definition.js +1 -1
- package/package.json +1 -2
- package/project/context/flowr-analyzer-context.d.ts +11 -0
- package/project/context/flowr-analyzer-context.js +3 -0
- package/project/context/flowr-analyzer-environment-context.d.ts +47 -0
- package/project/context/flowr-analyzer-environment-context.js +50 -0
- package/project/context/flowr-analyzer-files-context.d.ts +9 -1
- package/project/context/flowr-analyzer-files-context.js +4 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/plugins/file-plugins/{flowr-description-file.d.ts → files/flowr-description-file.d.ts} +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +75 -0
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +27 -0
- package/project/plugins/file-plugins/files/flowr-news-file.js +152 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +23 -0
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +35 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -1
- package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -4
- package/queries/catalog/control-flow-query/control-flow-query-format.js +3 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +5 -3
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-format.js +2 -2
- package/queries/catalog/files-query/files-query-executor.d.ts +6 -0
- package/queries/catalog/files-query/files-query-executor.js +49 -0
- package/queries/catalog/files-query/files-query-format.d.ts +36 -0
- package/queries/catalog/files-query/files-query-format.js +114 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
- package/queries/catalog/linter-query/linter-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/query.d.ts +10 -1
- package/queries/query.js +3 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +8 -8
- package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +8 -8
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +0 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -1
- package/slicing/static/slice-call.d.ts +3 -2
- package/slicing/static/slice-call.js +4 -4
- package/slicing/static/static-slicer.d.ts +3 -1
- package/slicing/static/static-slicer.js +6 -7
- package/statistics/features/supported/control-flow/control-flow.js +1 -1
- package/statistics/features/supported/data-access/data-access.js +1 -1
- package/statistics/features/supported/used-functions/used-functions.js +1 -1
- package/statistics/features/supported/variables/variables.js +2 -1
- package/util/containers.js +2 -2
- package/util/files.d.ts +0 -7
- package/util/files.js +0 -41
- package/util/mermaid/ast.d.ts +3 -2
- package/util/mermaid/ast.js +13 -7
- package/util/mermaid/cfg.d.ts +3 -2
- package/util/mermaid/cfg.js +26 -6
- package/util/mermaid/dfg.d.ts +2 -7
- package/util/mermaid/dfg.js +10 -6
- package/util/mermaid/info.d.ts +17 -0
- package/util/mermaid/info.js +5 -0
- package/util/prefix.d.ts +9 -5
- package/util/prefix.js +14 -6
- package/util/r-regex.d.ts +21 -0
- package/util/r-regex.js +25 -0
- package/util/simple-df/dfg-view.d.ts +2 -1
- package/util/simple-df/dfg-view.js +2 -2
- package/util/text/args.js +12 -3
- package/util/version.js +1 -1
- package/abstract-interpretation/data-frame/absint-info.d.ts +0 -109
- package/abstract-interpretation/data-frame/absint-info.js +0 -31
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +0 -57
- package/abstract-interpretation/data-frame/absint-visitor.js +0 -176
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +0 -19
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +0 -33
- package/dataflow/environments/remove.d.ts +0 -12
- package/dataflow/environments/remove.js +0 -52
- package/documentation/doc-util/doc-print.d.ts +0 -5
- package/documentation/doc-util/doc-print.js +0 -36
- package/project/plugins/file-plugins/flowr-description-file.js +0 -37
- package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
- package/project/plugins/file-plugins/notebooks/notebook.js +0 -2
- /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.d.ts +0 -0
- /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.js +0 -0
- /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.d.ts +0 -0
- /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.js +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeReferenceMaybe = makeReferenceMaybe;
|
|
4
|
+
exports.makeAllMaybe = makeAllMaybe;
|
|
5
|
+
const identifier_1 = require("./identifier");
|
|
6
|
+
const resolve_by_name_1 = require("./resolve-by-name");
|
|
7
|
+
/**
|
|
8
|
+
* Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
|
|
9
|
+
*/
|
|
10
|
+
function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
|
|
11
|
+
if (includeDefs) {
|
|
12
|
+
const definitions = ref.name ? (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type) : undefined;
|
|
13
|
+
for (const definition of definitions ?? []) {
|
|
14
|
+
if (definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant) {
|
|
15
|
+
if (definition.controlDependencies) {
|
|
16
|
+
if (defaultCd && !definition.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
|
|
17
|
+
definition.controlDependencies.push(defaultCd);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
definition.controlDependencies = defaultCd ? [defaultCd] : [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const node = graph.getVertex(ref.nodeId, true);
|
|
27
|
+
if (node) {
|
|
28
|
+
if (node.cds) {
|
|
29
|
+
if (defaultCd && !node.cds.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
|
|
30
|
+
node.cds.push(defaultCd);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
node.cds = defaultCd ? [defaultCd] : [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (ref.controlDependencies) {
|
|
38
|
+
if (defaultCd && !ref.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
|
|
39
|
+
return { ...ref, controlDependencies: (ref.controlDependencies ?? []).concat(defaultCd ? [defaultCd] : []) };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return { ...ref, controlDependencies: ref.controlDependencies ?? (defaultCd ? [defaultCd] : []) };
|
|
44
|
+
}
|
|
45
|
+
return ref;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Marks all references as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
|
|
49
|
+
* @see {@link makeReferenceMaybe}
|
|
50
|
+
*/
|
|
51
|
+
function makeAllMaybe(references, graph, environments, includeDefs, defaultCd = undefined) {
|
|
52
|
+
return references?.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd)) ?? [];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=reference-to-maybe.js.map
|
|
@@ -3,13 +3,18 @@ import { Ternary } from '../../util/logic';
|
|
|
3
3
|
import { type Identifier, type IdentifierDefinition, ReferenceType } from './identifier';
|
|
4
4
|
/**
|
|
5
5
|
* Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
|
|
6
|
+
* If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
|
|
6
7
|
* @param name - The name of the identifier to resolve
|
|
7
8
|
* @param environment - The current environment used for name resolution
|
|
8
9
|
* @param target - The target (meta) type of the identifier to resolve
|
|
9
10
|
* @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
|
|
10
11
|
* if the identifier is undefined in the current scope/with the current environment information.
|
|
11
12
|
*/
|
|
12
|
-
export declare function resolveByName(name: Identifier, environment: REnvironmentInformation, target
|
|
13
|
+
export declare function resolveByName(name: Identifier, environment: REnvironmentInformation, target: ReferenceType): IdentifierDefinition[] | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The more performant version of {@link resolveByName} when the target type is unknown.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveByNameAnyType(name: Identifier, environment: REnvironmentInformation): IdentifierDefinition[] | undefined;
|
|
13
18
|
/**
|
|
14
19
|
*
|
|
15
20
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveByName = resolveByName;
|
|
4
|
+
exports.resolveByNameAnyType = resolveByNameAnyType;
|
|
4
5
|
exports.resolvesToBuiltInConstant = resolvesToBuiltInConstant;
|
|
5
6
|
const logic_1 = require("../../util/logic");
|
|
6
7
|
const identifier_1 = require("./identifier");
|
|
@@ -22,26 +23,34 @@ const TargetTypePredicate = {
|
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
25
|
* Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
|
|
26
|
+
* If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
|
|
25
27
|
* @param name - The name of the identifier to resolve
|
|
26
28
|
* @param environment - The current environment used for name resolution
|
|
27
29
|
* @param target - The target (meta) type of the identifier to resolve
|
|
28
30
|
* @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
|
|
29
31
|
* if the identifier is undefined in the current scope/with the current environment information.
|
|
30
32
|
*/
|
|
31
|
-
function resolveByName(name, environment, target
|
|
33
|
+
function resolveByName(name, environment, target) {
|
|
34
|
+
if (target === identifier_1.ReferenceType.Unknown) {
|
|
35
|
+
return resolveByNameAnyType(name, environment);
|
|
36
|
+
}
|
|
32
37
|
let current = environment.current;
|
|
33
38
|
let definitions = undefined;
|
|
34
39
|
const wantedType = TargetTypePredicate[target];
|
|
35
40
|
do {
|
|
36
41
|
const definition = current.memory.get(name);
|
|
37
42
|
if (definition !== undefined) {
|
|
38
|
-
const filtered =
|
|
43
|
+
const filtered = definition.filter(wantedType);
|
|
39
44
|
if (filtered.length === definition.length && definition.every(d => (0, info_1.happensInEveryBranch)(d.controlDependencies))) {
|
|
40
45
|
return definition;
|
|
41
46
|
}
|
|
42
47
|
else if (filtered.length > 0) {
|
|
43
|
-
definitions
|
|
44
|
-
|
|
48
|
+
if (definitions) {
|
|
49
|
+
definitions = definitions.concat(filtered);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
definitions = filtered;
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
current = current.parent;
|
|
@@ -54,6 +63,49 @@ function resolveByName(name, environment, target = identifier_1.ReferenceType.Un
|
|
|
54
63
|
return builtIns;
|
|
55
64
|
}
|
|
56
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The more performant version of {@link resolveByName} when the target type is unknown.
|
|
68
|
+
*/
|
|
69
|
+
function resolveByNameAnyType(name, environment) {
|
|
70
|
+
let current = environment.current;
|
|
71
|
+
const g = current.cache?.get(name);
|
|
72
|
+
if (g !== undefined) {
|
|
73
|
+
return g;
|
|
74
|
+
}
|
|
75
|
+
let definitions = undefined;
|
|
76
|
+
do {
|
|
77
|
+
const definition = current.memory.get(name);
|
|
78
|
+
if (definition) {
|
|
79
|
+
if (definition.every(d => (0, info_1.happensInEveryBranch)(d.controlDependencies))) {
|
|
80
|
+
environment.current.cache ??= new Map();
|
|
81
|
+
environment.current.cache?.set(name, definition);
|
|
82
|
+
return definition;
|
|
83
|
+
}
|
|
84
|
+
else if (definition.length > 0) {
|
|
85
|
+
if (definitions) {
|
|
86
|
+
definitions = definitions.concat(definition);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
definitions = definition;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
current = current.parent;
|
|
94
|
+
} while (!current.builtInEnv);
|
|
95
|
+
const builtIns = current.memory.get(name);
|
|
96
|
+
let ret;
|
|
97
|
+
if (definitions) {
|
|
98
|
+
ret = builtIns === undefined ? definitions : definitions.concat(builtIns);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
ret = builtIns;
|
|
102
|
+
}
|
|
103
|
+
if (ret) {
|
|
104
|
+
environment.current.cache ??= new Map();
|
|
105
|
+
environment.current.cache?.set(name, ret);
|
|
106
|
+
}
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
57
109
|
/**
|
|
58
110
|
*
|
|
59
111
|
*/
|
|
@@ -3,9 +3,9 @@ import { type REnvironmentInformation } from './environment';
|
|
|
3
3
|
* Add a new local environment scope to the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone)
|
|
4
4
|
* @see {@link popLocalEnvironment} - to remove the local scope again
|
|
5
5
|
*/
|
|
6
|
-
export declare function pushLocalEnvironment(
|
|
6
|
+
export declare function pushLocalEnvironment({ level, current }: REnvironmentInformation): REnvironmentInformation;
|
|
7
7
|
/**
|
|
8
8
|
* Remove the top local environment scope from the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone)
|
|
9
9
|
* @see {@link pushLocalEnvironment} - to add a local scope
|
|
10
10
|
*/
|
|
11
|
-
export declare function popLocalEnvironment(
|
|
11
|
+
export declare function popLocalEnvironment({ current, level }: REnvironmentInformation): REnvironmentInformation;
|
|
@@ -8,23 +8,23 @@ const assert_1 = require("../../util/assert");
|
|
|
8
8
|
* Add a new local environment scope to the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone)
|
|
9
9
|
* @see {@link popLocalEnvironment} - to remove the local scope again
|
|
10
10
|
*/
|
|
11
|
-
function pushLocalEnvironment(
|
|
11
|
+
function pushLocalEnvironment({ level, current }) {
|
|
12
12
|
return {
|
|
13
|
-
current: new environment_1.Environment(
|
|
14
|
-
level:
|
|
13
|
+
current: new environment_1.Environment(current),
|
|
14
|
+
level: level + 1
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Remove the top local environment scope from the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone)
|
|
19
19
|
* @see {@link pushLocalEnvironment} - to add a local scope
|
|
20
20
|
*/
|
|
21
|
-
function popLocalEnvironment(
|
|
22
|
-
(0, assert_1.guard)(
|
|
23
|
-
const parent =
|
|
21
|
+
function popLocalEnvironment({ current, level }) {
|
|
22
|
+
(0, assert_1.guard)(level > 0, 'cannot remove the global/root environment');
|
|
23
|
+
const parent = current.parent;
|
|
24
24
|
(0, assert_1.guard)(parent !== undefined, 'level is wrong, parent is undefined even though level suggested depth > 0 (starts with 0)');
|
|
25
25
|
return {
|
|
26
26
|
current: parent,
|
|
27
|
-
level:
|
|
27
|
+
level: level - 1
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=scoping.js.map
|
|
@@ -5,6 +5,7 @@ import { type REnvironmentInformation } from '../../environments/environment';
|
|
|
5
5
|
import { type Identifier } from '../../environments/identifier';
|
|
6
6
|
import type { DataflowGraph } from '../../graph/graph';
|
|
7
7
|
import { type Lift, type Value, type ValueSet } from '../values/r-value';
|
|
8
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
8
9
|
export type ResolveResult = Lift<ValueSet<Value[]>>;
|
|
9
10
|
export interface ResolveInfo {
|
|
10
11
|
/** The current environment used for name resolution */
|
|
@@ -16,7 +17,9 @@ export interface ResolveInfo {
|
|
|
16
17
|
/** Whether to track variables */
|
|
17
18
|
full?: boolean;
|
|
18
19
|
/** Variable resolve mode */
|
|
19
|
-
resolve
|
|
20
|
+
resolve?: VariableResolve;
|
|
21
|
+
/** Context used for resolving */
|
|
22
|
+
ctx: ReadOnlyFlowrAnalyzerContext;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Gets the definitions / aliases of a node
|
|
@@ -50,8 +53,9 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
50
53
|
* @param idMap - The id map to resolve the node if given as an id
|
|
51
54
|
* @param full - Whether to track aliases on resolve
|
|
52
55
|
* @param resolve - Variable resolve mode
|
|
56
|
+
* @param ctx - Context used for clean environment
|
|
53
57
|
*/
|
|
54
|
-
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, resolve }: ResolveInfo): ResolveResult;
|
|
58
|
+
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, resolve, ctx }: ResolveInfo): ResolveResult;
|
|
55
59
|
/**
|
|
56
60
|
* Please use {@link resolveIdToValue}
|
|
57
61
|
*
|
|
@@ -60,21 +64,23 @@ export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefine
|
|
|
60
64
|
* @param resolve - Variable resolve mode
|
|
61
65
|
* @param identifier - Identifier to resolve
|
|
62
66
|
* @param use - Environment to use
|
|
67
|
+
* @param ctx - analysis context
|
|
63
68
|
* @param graph - dataflow graph
|
|
64
69
|
* @param idMap - id map of Dataflow graph
|
|
65
70
|
* @returns Value of Identifier or Top
|
|
66
71
|
*/
|
|
67
|
-
export declare function trackAliasInEnvironments(resolve: VariableResolve, identifier: Identifier | undefined, use: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
|
|
72
|
+
export declare function trackAliasInEnvironments(resolve: VariableResolve, identifier: Identifier | undefined, use: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
|
|
68
73
|
/**
|
|
69
74
|
* Please use {@link resolveIdToValue}
|
|
70
75
|
*
|
|
71
76
|
* Tries to resolve the value of a node by traversing the dataflow graph
|
|
72
77
|
* @param id - node to resolve
|
|
78
|
+
* @param ctx - analysis context
|
|
73
79
|
* @param graph - dataflow graph
|
|
74
80
|
* @param idMap - idmap of dataflow graph
|
|
75
81
|
* @returns Value of node or Top/Bottom
|
|
76
82
|
*/
|
|
77
|
-
export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, idMap?: AstIdMap): ResolveResult;
|
|
83
|
+
export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap): ResolveResult;
|
|
78
84
|
/**
|
|
79
85
|
* Please use {@link resolveIdToValue}
|
|
80
86
|
*
|
|
@@ -8,10 +8,8 @@ exports.resolveToConstants = resolveToConstants;
|
|
|
8
8
|
const config_1 = require("../../../config");
|
|
9
9
|
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
10
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
11
|
-
const fingerprint_1 = require("../../../slicing/static/fingerprint");
|
|
12
11
|
const visiting_queue_1 = require("../../../slicing/static/visiting-queue");
|
|
13
12
|
const assert_1 = require("../../../util/assert");
|
|
14
|
-
const environment_1 = require("../../environments/environment");
|
|
15
13
|
const identifier_1 = require("../../environments/identifier");
|
|
16
14
|
const resolve_by_name_1 = require("../../environments/resolve-by-name");
|
|
17
15
|
const edge_1 = require("../../graph/edge");
|
|
@@ -47,7 +45,7 @@ function getUseAlias(sourceId, dataflow, environment) {
|
|
|
47
45
|
if (identifier === undefined) {
|
|
48
46
|
return undefined;
|
|
49
47
|
}
|
|
50
|
-
const defs = (0, resolve_by_name_1.
|
|
48
|
+
const defs = (0, resolve_by_name_1.resolveByNameAnyType)(identifier, environment);
|
|
51
49
|
if (defs === undefined) {
|
|
52
50
|
return undefined;
|
|
53
51
|
}
|
|
@@ -94,7 +92,7 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
94
92
|
definitions.add(def);
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
|
-
return
|
|
95
|
+
return Array.from(definitions);
|
|
98
96
|
}
|
|
99
97
|
/**
|
|
100
98
|
* Evaluates the value of a node in the set domain.
|
|
@@ -114,8 +112,10 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
114
112
|
* @param idMap - The id map to resolve the node if given as an id
|
|
115
113
|
* @param full - Whether to track aliases on resolve
|
|
116
114
|
* @param resolve - Variable resolve mode
|
|
115
|
+
* @param ctx - Context used for clean environment
|
|
117
116
|
*/
|
|
118
|
-
function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve }) {
|
|
117
|
+
function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve, ctx }) {
|
|
118
|
+
const variableResolve = resolve ?? ctx.config.solver.variables;
|
|
119
119
|
if (id === undefined) {
|
|
120
120
|
return r_value_1.Top;
|
|
121
121
|
}
|
|
@@ -128,10 +128,10 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve
|
|
|
128
128
|
case type_1.RType.Argument:
|
|
129
129
|
case type_1.RType.Symbol:
|
|
130
130
|
if (environment) {
|
|
131
|
-
return full ? trackAliasInEnvironments(
|
|
131
|
+
return full ? trackAliasInEnvironments(variableResolve, node.lexeme, environment, ctx, graph, idMap) : r_value_1.Top;
|
|
132
132
|
}
|
|
133
133
|
else if (graph && resolve === config_1.VariableResolve.Alias) {
|
|
134
|
-
return full ? trackAliasesInGraph(node.info.id, graph, idMap) : r_value_1.Top;
|
|
134
|
+
return full ? trackAliasesInGraph(node.info.id, graph, ctx, idMap) : r_value_1.Top;
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
137
|
return r_value_1.Top;
|
|
@@ -141,7 +141,7 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve
|
|
|
141
141
|
case type_1.RType.FunctionCall:
|
|
142
142
|
case type_1.RType.BinaryOp:
|
|
143
143
|
case type_1.RType.UnaryOp:
|
|
144
|
-
return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(
|
|
144
|
+
return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(variableResolve, node, ctx, environment, graph, idMap));
|
|
145
145
|
case type_1.RType.String:
|
|
146
146
|
case type_1.RType.Number:
|
|
147
147
|
case type_1.RType.Logical:
|
|
@@ -158,15 +158,16 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve
|
|
|
158
158
|
* @param resolve - Variable resolve mode
|
|
159
159
|
* @param identifier - Identifier to resolve
|
|
160
160
|
* @param use - Environment to use
|
|
161
|
+
* @param ctx - analysis context
|
|
161
162
|
* @param graph - dataflow graph
|
|
162
163
|
* @param idMap - id map of Dataflow graph
|
|
163
164
|
* @returns Value of Identifier or Top
|
|
164
165
|
*/
|
|
165
|
-
function trackAliasInEnvironments(resolve, identifier, use, graph, idMap) {
|
|
166
|
+
function trackAliasInEnvironments(resolve, identifier, use, ctx, graph, idMap) {
|
|
166
167
|
if (identifier === undefined) {
|
|
167
168
|
return r_value_1.Top;
|
|
168
169
|
}
|
|
169
|
-
const defs = (0, resolve_by_name_1.
|
|
170
|
+
const defs = (0, resolve_by_name_1.resolveByNameAnyType)(identifier, use);
|
|
170
171
|
if (defs === undefined) {
|
|
171
172
|
return r_value_1.Top;
|
|
172
173
|
}
|
|
@@ -186,7 +187,7 @@ function trackAliasInEnvironments(resolve, identifier, use, graph, idMap) {
|
|
|
186
187
|
for (const alias of def.value) {
|
|
187
188
|
const definitionOfAlias = idMap?.get(alias);
|
|
188
189
|
if (definitionOfAlias !== undefined) {
|
|
189
|
-
const value = (0, resolve_1.resolveNode)(resolve, definitionOfAlias, use, graph, idMap);
|
|
190
|
+
const value = (0, resolve_1.resolveNode)(resolve, definitionOfAlias, ctx, use, graph, idMap);
|
|
190
191
|
if ((0, r_value_1.isTop)(value)) {
|
|
191
192
|
return r_value_1.Top;
|
|
192
193
|
}
|
|
@@ -253,19 +254,20 @@ function isNestedInLoop(node, ast) {
|
|
|
253
254
|
*
|
|
254
255
|
* Tries to resolve the value of a node by traversing the dataflow graph
|
|
255
256
|
* @param id - node to resolve
|
|
257
|
+
* @param ctx - analysis context
|
|
256
258
|
* @param graph - dataflow graph
|
|
257
259
|
* @param idMap - idmap of dataflow graph
|
|
258
260
|
* @returns Value of node or Top/Bottom
|
|
259
261
|
*/
|
|
260
|
-
function trackAliasesInGraph(id, graph, idMap) {
|
|
262
|
+
function trackAliasesInGraph(id, graph, ctx, idMap) {
|
|
261
263
|
if (!graph.get(id)) {
|
|
262
264
|
return r_value_1.Bottom;
|
|
263
265
|
}
|
|
264
266
|
idMap ??= graph.idMap;
|
|
265
267
|
(0, assert_1.guard)(idMap !== undefined, 'The ID map is required to get the lineage of a node');
|
|
266
268
|
const queue = new visiting_queue_1.VisitingQueue(25);
|
|
267
|
-
const clean =
|
|
268
|
-
const cleanFingerprint =
|
|
269
|
+
const clean = ctx.env.makeCleanEnv();
|
|
270
|
+
const cleanFingerprint = ctx.env.getCleanEnvFingerprint();
|
|
269
271
|
queue.add(id, clean, cleanFingerprint, false);
|
|
270
272
|
let forceTop = false;
|
|
271
273
|
const resultIds = [];
|
|
@@ -2,7 +2,8 @@ import { type DataflowGraph } from '../../graph/graph';
|
|
|
2
2
|
import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
|
|
3
3
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { VariableResolve } from '../../../config';
|
|
5
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
5
6
|
/**
|
|
6
7
|
* Get the values of all arguments matching the criteria.
|
|
7
8
|
*/
|
|
8
|
-
export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined): Map<NodeId, Set<string | undefined>> | undefined;
|
|
9
|
+
export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined, ctx: ReadOnlyFlowrAnalyzerContext): Map<NodeId, Set<string | undefined>> | undefined;
|
|
@@ -14,7 +14,7 @@ const string_constants_1 = require("../values/string/string-constants");
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the values of all arguments matching the criteria.
|
|
16
16
|
*/
|
|
17
|
-
function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue) {
|
|
17
|
+
function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx) {
|
|
18
18
|
if (argumentName) {
|
|
19
19
|
const arg = vertex?.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && arg.name === argumentName);
|
|
20
20
|
if (arg >= 0) {
|
|
@@ -35,7 +35,7 @@ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, a
|
|
|
35
35
|
}
|
|
36
36
|
if (valueNode) {
|
|
37
37
|
// this should be evaluated in the callee-context
|
|
38
|
-
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
|
|
38
|
+
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue, ctx) ?? [dependencies_query_format_1.Unknown];
|
|
39
39
|
map.set(ref, new Set(values));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -51,17 +51,17 @@ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, a
|
|
|
51
51
|
valueNode = valueNode.value;
|
|
52
52
|
}
|
|
53
53
|
if (valueNode) {
|
|
54
|
-
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
|
|
54
|
+
const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue, ctx) ?? [dependencies_query_format_1.Unknown];
|
|
55
55
|
return new Map([[arg, new Set(values)]]);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
|
-
function hasCharacterOnly(variableResolve, graph, vertex, idMap) {
|
|
60
|
+
function hasCharacterOnly(variableResolve, graph, vertex, idMap, ctx) {
|
|
61
61
|
if (!vertex.args || vertex.args.length === 0 || !idMap) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
const treatAsChar = getArgumentStringValue(variableResolve, graph, vertex, 5, 'character.only', true);
|
|
64
|
+
const treatAsChar = getArgumentStringValue(variableResolve, graph, vertex, 5, 'character.only', true, ctx);
|
|
65
65
|
if (!treatAsChar) {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
@@ -74,13 +74,13 @@ function hasCharacterOnly(variableResolve, graph, vertex, idMap) {
|
|
|
74
74
|
return hasTrue;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environment, idMap, resolveValue) {
|
|
77
|
+
function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environment, idMap, resolveValue, ctx) {
|
|
78
78
|
let full = true;
|
|
79
79
|
if (!resolveValue) {
|
|
80
80
|
full = false;
|
|
81
81
|
}
|
|
82
82
|
if (resolveValue === 'library') {
|
|
83
|
-
const hasChar = hasCharacterOnly(variableResolve, graph, vertex, idMap);
|
|
83
|
+
const hasChar = hasCharacterOnly(variableResolve, graph, vertex, idMap, ctx);
|
|
84
84
|
if (hasChar === false) {
|
|
85
85
|
if (argument.type === type_1.RType.Symbol) {
|
|
86
86
|
return [argument.lexeme];
|
|
@@ -88,7 +88,7 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
88
88
|
full = false;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(argument, { environment, graph, full, resolve: variableResolve }));
|
|
91
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(argument, { environment, graph, full, resolve: variableResolve, ctx }));
|
|
92
92
|
if (resolved) {
|
|
93
93
|
const values = [];
|
|
94
94
|
for (const value of resolved.elements) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
2
|
import type { REnvironmentInformation } from '../../environments/environment';
|
|
3
3
|
import type { DataflowGraph } from '../../graph/graph';
|
|
4
|
-
import { type Lift, type Value, type ValueNumber, type ValueVector
|
|
4
|
+
import { type Lift, Top, type Value, type ValueNumber, type ValueVector } from '../values/r-value';
|
|
5
5
|
import type { VariableResolve } from '../../../config';
|
|
6
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
6
7
|
/**
|
|
7
8
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
8
9
|
* you want to resolve the value of an identifier / node
|
|
@@ -16,21 +17,22 @@ import type { VariableResolve } from '../../../config';
|
|
|
16
17
|
* @param map - Idmap of Dataflow Graph
|
|
17
18
|
* @returns resolved value or top/bottom
|
|
18
19
|
*/
|
|
19
|
-
export declare function resolveNode(resolve: VariableResolve, a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
20
|
+
export declare function resolveNode(resolve: VariableResolve, a: RNodeWithParent, ctx: ReadOnlyFlowrAnalyzerContext, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
|
|
20
21
|
/**
|
|
21
22
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
22
23
|
* you want to resolve the value of an identifier / node
|
|
23
24
|
*
|
|
24
25
|
* This function resolves a vector function call `c` to a {@link ValueVector}
|
|
25
26
|
* by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
|
|
26
|
-
* @param resolve
|
|
27
|
-
* @param node
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
27
|
+
* @param resolve - Variable resolve mode
|
|
28
|
+
* @param node - Node of the vector function to resolve
|
|
29
|
+
* @param environment - Environment to use
|
|
30
|
+
* @param ctx - Analyzer context
|
|
31
|
+
* @param graph - Dataflow graph
|
|
32
|
+
* @param idMap - ID map of the dataflow graph
|
|
31
33
|
* @returns ValueVector or Top
|
|
32
34
|
*/
|
|
33
|
-
export declare function resolveAsVector(resolve: VariableResolve, node: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<Value[]>> | typeof Top;
|
|
35
|
+
export declare function resolveAsVector(resolve: VariableResolve, node: RNodeWithParent, ctx: ReadOnlyFlowrAnalyzerContext, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<Value[]>> | typeof Top;
|
|
34
36
|
/**
|
|
35
37
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
36
38
|
* you want to resolve the value of an identifier / node
|
|
@@ -44,7 +46,7 @@ export declare function resolveAsVector(resolve: VariableResolve, node: RNodeWit
|
|
|
44
46
|
* @param map - Id map of the dataflow graph
|
|
45
47
|
* @returns ValueVector of ValueNumbers or Top
|
|
46
48
|
*/
|
|
47
|
-
export declare function resolveAsSeq(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
49
|
+
export declare function resolveAsSeq(resolve: VariableResolve, operator: RNodeWithParent, ctx: ReadOnlyFlowrAnalyzerContext, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
48
50
|
/**
|
|
49
51
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
50
52
|
* you want to resolve the value of an identifier / node
|
|
@@ -58,7 +60,7 @@ export declare function resolveAsSeq(resolve: VariableResolve, operator: RNodeWi
|
|
|
58
60
|
* @param map - Id map of the dataflow graph
|
|
59
61
|
* @returns ValueNumber, ValueVector of ValueNumbers, or Top
|
|
60
62
|
*/
|
|
61
|
-
export declare function resolveAsPlus(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
63
|
+
export declare function resolveAsPlus(resolve: VariableResolve, operator: RNodeWithParent, ctx: ReadOnlyFlowrAnalyzerContext, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
62
64
|
/**
|
|
63
65
|
* Helper function used by {@link resolveIdToValue}, please use that instead, if
|
|
64
66
|
* you want to resolve the value of an identifier / node
|
|
@@ -72,4 +74,4 @@ export declare function resolveAsPlus(resolve: VariableResolve, operator: RNodeW
|
|
|
72
74
|
* @param map - Id map of the dataflow graph
|
|
73
75
|
* @returns ValueNumber, ValueVector of ValueNumbers, or Top
|
|
74
76
|
*/
|
|
75
|
-
export declare function resolveAsMinus(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
77
|
+
export declare function resolveAsMinus(resolve: VariableResolve, operator: RNodeWithParent, ctx: ReadOnlyFlowrAnalyzerContext, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
|
|
@@ -30,7 +30,7 @@ const scalar_consatnts_1 = require("../values/scalar/scalar-consatnts");
|
|
|
30
30
|
* @param map - Idmap of Dataflow Graph
|
|
31
31
|
* @returns resolved value or top/bottom
|
|
32
32
|
*/
|
|
33
|
-
function resolveNode(resolve, a, env, graph, map) {
|
|
33
|
+
function resolveNode(resolve, a, ctx, env, graph, map) {
|
|
34
34
|
if (a.type === type_1.RType.String) {
|
|
35
35
|
return (0, string_constants_1.stringFrom)(a.content.str);
|
|
36
36
|
}
|
|
@@ -63,7 +63,7 @@ function resolveNode(resolve, a, env, graph, map) {
|
|
|
63
63
|
}
|
|
64
64
|
if (Object.hasOwn(built_in_1.BuiltInEvalHandlerMapper, builtInName)) {
|
|
65
65
|
const handler = built_in_1.BuiltInEvalHandlerMapper[builtInName];
|
|
66
|
-
return handler(resolve, a, env, graph, map);
|
|
66
|
+
return handler(resolve, a, ctx, env, graph, map);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
return r_value_2.Top;
|
|
@@ -74,18 +74,19 @@ function resolveNode(resolve, a, env, graph, map) {
|
|
|
74
74
|
*
|
|
75
75
|
* This function resolves a vector function call `c` to a {@link ValueVector}
|
|
76
76
|
* by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
|
|
77
|
-
* @param resolve
|
|
78
|
-
* @param node
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
77
|
+
* @param resolve - Variable resolve mode
|
|
78
|
+
* @param node - Node of the vector function to resolve
|
|
79
|
+
* @param environment - Environment to use
|
|
80
|
+
* @param ctx - Analyzer context
|
|
81
|
+
* @param graph - Dataflow graph
|
|
82
|
+
* @param idMap - ID map of the dataflow graph
|
|
82
83
|
* @returns ValueVector or Top
|
|
83
84
|
*/
|
|
84
|
-
function resolveAsVector(resolve, node, environment, graph, idMap) {
|
|
85
|
+
function resolveAsVector(resolve, node, ctx, environment, graph, idMap) {
|
|
85
86
|
if (node.type !== type_1.RType.FunctionCall) {
|
|
86
87
|
return r_value_2.Top;
|
|
87
88
|
}
|
|
88
|
-
const resolveInfo = { environment, graph, idMap, full: true, resolve };
|
|
89
|
+
const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx };
|
|
89
90
|
const values = node.arguments.map(arg => arg !== r_function_call_1.EmptyArgument ? (0, alias_tracking_1.resolveIdToValue)(arg.value, resolveInfo) : r_value_2.Top);
|
|
90
91
|
return (0, vector_constants_1.vectorFrom)((0, vector_constants_1.flattenVectorElements)(values));
|
|
91
92
|
}
|
|
@@ -102,11 +103,11 @@ function resolveAsVector(resolve, node, environment, graph, idMap) {
|
|
|
102
103
|
* @param map - Id map of the dataflow graph
|
|
103
104
|
* @returns ValueVector of ValueNumbers or Top
|
|
104
105
|
*/
|
|
105
|
-
function resolveAsSeq(resolve, operator, environment, graph, idMap) {
|
|
106
|
+
function resolveAsSeq(resolve, operator, ctx, environment, graph, idMap) {
|
|
106
107
|
if (operator.type !== type_1.RType.BinaryOp) {
|
|
107
108
|
return r_value_2.Top;
|
|
108
109
|
}
|
|
109
|
-
const resolveInfo = { environment, graph, idMap, full: true, resolve };
|
|
110
|
+
const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx };
|
|
110
111
|
const leftArg = (0, alias_tracking_1.resolveIdToValue)(operator.lhs, resolveInfo);
|
|
111
112
|
const rightArg = (0, alias_tracking_1.resolveIdToValue)(operator.rhs, resolveInfo);
|
|
112
113
|
const leftValue = (0, r_value_1.unliftRValue)(leftArg);
|
|
@@ -129,11 +130,11 @@ function resolveAsSeq(resolve, operator, environment, graph, idMap) {
|
|
|
129
130
|
* @param map - Id map of the dataflow graph
|
|
130
131
|
* @returns ValueNumber, ValueVector of ValueNumbers, or Top
|
|
131
132
|
*/
|
|
132
|
-
function resolveAsPlus(resolve, operator, environment, graph, idMap) {
|
|
133
|
+
function resolveAsPlus(resolve, operator, ctx, environment, graph, idMap) {
|
|
133
134
|
if (operator.type !== type_1.RType.UnaryOp) {
|
|
134
135
|
return r_value_2.Top;
|
|
135
136
|
}
|
|
136
|
-
const resolveInfo = { environment, graph, idMap, full: true, resolve };
|
|
137
|
+
const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx };
|
|
137
138
|
const arg = (0, alias_tracking_1.resolveIdToValue)(operator.operand, resolveInfo);
|
|
138
139
|
const argValue = (0, r_value_1.unliftRValue)(arg);
|
|
139
140
|
if ((0, r_value_1.isRNumberValue)(argValue)) {
|
|
@@ -157,11 +158,11 @@ function resolveAsPlus(resolve, operator, environment, graph, idMap) {
|
|
|
157
158
|
* @param map - Id map of the dataflow graph
|
|
158
159
|
* @returns ValueNumber, ValueVector of ValueNumbers, or Top
|
|
159
160
|
*/
|
|
160
|
-
function resolveAsMinus(resolve, operator, environment, graph, idMap) {
|
|
161
|
+
function resolveAsMinus(resolve, operator, ctx, environment, graph, idMap) {
|
|
161
162
|
if (operator.type !== type_1.RType.UnaryOp) {
|
|
162
163
|
return r_value_2.Top;
|
|
163
164
|
}
|
|
164
|
-
const resolveInfo = { environment, graph, idMap, full: true, resolve };
|
|
165
|
+
const resolveInfo = { environment, graph, idMap, full: true, resolve, ctx };
|
|
165
166
|
const arg = (0, alias_tracking_1.resolveIdToValue)(operator.operand, resolveInfo);
|
|
166
167
|
const argValue = (0, r_value_1.unliftRValue)(arg);
|
|
167
168
|
if ((0, r_value_1.isRNumberValue)(argValue)) {
|
package/dataflow/extractor.js
CHANGED
|
@@ -14,13 +14,11 @@ const named_call_handling_1 = require("./internal/process/functions/call/named-c
|
|
|
14
14
|
const make_argument_1 = require("./internal/process/functions/call/argument/make-argument");
|
|
15
15
|
const range_1 = require("../util/range");
|
|
16
16
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
17
|
-
const environment_1 = require("./environments/environment");
|
|
18
17
|
const built_in_source_1 = require("./internal/process/functions/call/built-in/built-in-source");
|
|
19
18
|
const extract_cfg_1 = require("../control-flow/extract-cfg");
|
|
20
19
|
const edge_1 = require("./graph/edge");
|
|
21
20
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
22
21
|
const built_in_function_definition_1 = require("./internal/process/functions/call/built-in/built-in-function-definition");
|
|
23
|
-
const built_in_config_1 = require("./environments/built-in-config");
|
|
24
22
|
const flowr_file_1 = require("../project/context/flowr-file");
|
|
25
23
|
/**
|
|
26
24
|
* The best friend of {@link produceDataFlowGraph} and {@link processDataflowFor}.
|
|
@@ -95,17 +93,13 @@ function resolveLinkToSideEffects(ast, graph) {
|
|
|
95
93
|
* For the actual, canonical fold entry point, see {@link processDataflowFor}.
|
|
96
94
|
*/
|
|
97
95
|
function produceDataFlowGraph(parser, completeAst, ctx) {
|
|
98
|
-
const builtInsConfig = ctx.config.semantics.environment.overwriteBuiltIns;
|
|
99
|
-
const builtIns = (0, built_in_config_1.getBuiltInDefinitions)(builtInsConfig.definitions, builtInsConfig.loadDefaults);
|
|
100
|
-
const env = (0, environment_1.initializeCleanEnvironments)(builtIns.builtInMemory);
|
|
101
96
|
// we freeze the files here to avoid endless modifications during processing
|
|
102
97
|
const files = completeAst.ast.files.slice();
|
|
103
98
|
ctx.files.addConsideredFile(files[0].filePath ? files[0].filePath : flowr_file_1.FlowrFile.INLINE_PATH);
|
|
104
99
|
const dfData = {
|
|
105
100
|
parser,
|
|
106
101
|
completeAst,
|
|
107
|
-
environment: env,
|
|
108
|
-
builtInEnvironment: env.current.parent,
|
|
102
|
+
environment: ctx.env.makeCleanEnv(),
|
|
109
103
|
processors: exports.processors,
|
|
110
104
|
controlDependencies: undefined,
|
|
111
105
|
referenceChain: [files[0].filePath],
|