@eagleoutice/flowr 2.13.16 → 2.14.1
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 +36 -25
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/benchmark/calibration.d.ts +16 -7
- package/benchmark/calibration.js +44 -17
- package/benchmark/slicer.d.ts +3 -2
- package/benchmark/slicer.js +9 -5
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -31
- package/cli/common/options.js +2 -8
- package/cli/common/scripts-info.d.ts +5 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +83 -5
- package/control-flow/extract-cfg.js +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 +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/apply-kill.js +1 -1
- package/dataflow/environments/built-in-props.d.ts +13 -2
- package/dataflow/environments/built-in-props.js +23 -1
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +518 -11
- package/dataflow/environments/default-builtin-config.js +218 -23
- package/dataflow/environments/environment.d.ts +10 -2
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +8 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +22 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +44 -7
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +5 -4
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +3 -3
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +87 -39
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +337 -0
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +24 -1
- package/dataflow/graph/df-helper.js +29 -7
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +3 -4
- package/dataflow/graph/graph-helper.js +4 -5
- package/dataflow/graph/graph.d.ts +39 -3
- package/dataflow/graph/graph.js +75 -7
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- package/dataflow/info.d.ts +26 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- 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.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +29 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +44 -20
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
- package/dataflow/internal/process/functions/call/nse.js +113 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
- package/dataflow/internal/process/functions/call/quoted.js +21 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +18 -18
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-query.js +53 -0
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/linter-output.js +1 -1
- package/linter/linter-rules.d.ts +24 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +38 -51
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.d.ts +3 -3
- package/project/dependency-version-space.js +3 -4
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -4
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +36 -7
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.d.ts +3 -1
- package/project/sigdb/manifest.js +68 -27
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +14 -14
- package/project/sigdb/schema.d.ts +2 -2
- package/project/sigdb/schema.js +2 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +3 -9
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -14
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +5 -5
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/objects.d.ts +12 -0
- package/util/objects.js +48 -0
- package/util/quads.js +19 -6
- package/util/schema.js +2 -2
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuiltInIndex = void 0;
|
|
4
4
|
exports.queryFnProps = queryFnProps;
|
|
5
|
+
exports.callFnProps = callFnProps;
|
|
5
6
|
exports.inferFnProps = inferFnProps;
|
|
6
7
|
exports.builtInNames = builtInNames;
|
|
7
8
|
const built_in_props_1 = require("./built-in-props");
|
|
@@ -9,7 +10,9 @@ const default_builtin_config_1 = require("./default-builtin-config");
|
|
|
9
10
|
const environment_1 = require("./environment");
|
|
10
11
|
const identifier_1 = require("./identifier");
|
|
11
12
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
|
-
const
|
|
13
|
+
const resolve_helper_1 = require("./resolve-helper");
|
|
14
|
+
const vertex_1 = require("../graph/vertex");
|
|
15
|
+
const df_helper_1 = require("../graph/df-helper");
|
|
13
16
|
/**
|
|
14
17
|
* What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR
|
|
15
18
|
* states nothing about it. `library(pkg)` binds every export itself, and that binding hides the built-in layer.
|
|
@@ -60,7 +63,7 @@ function ofDefinitions(definitions) {
|
|
|
60
63
|
function queryFnProps(name, { environment, builtIns, signatures, version }) {
|
|
61
64
|
let info;
|
|
62
65
|
if (environment !== undefined) {
|
|
63
|
-
const resolved =
|
|
66
|
+
const resolved = resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.Function);
|
|
64
67
|
const stated = resolved === undefined ? undefined : withStatedBuiltIns(resolved, environment);
|
|
65
68
|
if (stated?.some(d => d.type !== identifier_1.ReferenceType.BuiltInFunction)) {
|
|
66
69
|
return undefined;
|
|
@@ -80,6 +83,23 @@ function queryFnProps(name, { environment, builtIns, signatures, version }) {
|
|
|
80
83
|
}
|
|
81
84
|
return { sig: info?.sig ?? known.sig, props: (info?.props ?? 0) | (known.props ?? 0) };
|
|
82
85
|
}
|
|
86
|
+
/** What flowR states about the call `id` makes, together with the name the call resolved to. */
|
|
87
|
+
function callFnProps(id, { graph, environment }) {
|
|
88
|
+
const vertex = graph.getVertex(id);
|
|
89
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
/* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
|
|
93
|
+
* flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
|
|
94
|
+
const known = vertex.environment ?? environment;
|
|
95
|
+
const name = df_helper_1.Dataflow.qualify(id, graph, false) ?? vertex.name;
|
|
96
|
+
return {
|
|
97
|
+
name,
|
|
98
|
+
...queryFnProps(name, {
|
|
99
|
+
environment: vertex.onlyBuiltin ? { level: 0, current: environment_1.REnvironment.findBuiltIn(known.current) } : known
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
}
|
|
83
103
|
/**
|
|
84
104
|
* What the signature database implies for a package function: what its own entry states
|
|
85
105
|
* (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively.
|
|
@@ -7,9 +7,9 @@ exports.applyCdsToAllInGraphButConstants = applyCdsToAllInGraphButConstants;
|
|
|
7
7
|
exports.applyCdToReferences = applyCdToReferences;
|
|
8
8
|
const identifier_1 = require("./identifier");
|
|
9
9
|
const info_1 = require("../info");
|
|
10
|
-
const resolve_by_name_1 = require("./resolve-by-name");
|
|
11
|
-
const vertex_1 = require("../graph/vertex");
|
|
12
10
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
11
|
+
const vertex_1 = require("../graph/vertex");
|
|
12
|
+
const resolve_helper_1 = require("./resolve-helper");
|
|
13
13
|
/** copy of the definition with the given cds attached, marking it as maybe */
|
|
14
14
|
function withAppliedCds(definition, defaultCd) {
|
|
15
15
|
return { ...definition, cds: (0, info_1.withCds)(definition.cds, defaultCd) };
|
|
@@ -49,7 +49,7 @@ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, de
|
|
|
49
49
|
replaceDefinitions(current, plainName, toUpdate, defaultCd);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
for (const key of
|
|
52
|
+
for (const key of current.memory.keys()) {
|
|
53
53
|
if (key.startsWith(prefix)) {
|
|
54
54
|
replaceDefinitions(current, key, toUpdate, defaultCd);
|
|
55
55
|
}
|
|
@@ -65,7 +65,7 @@ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, de
|
|
|
65
65
|
*/
|
|
66
66
|
function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
|
|
67
67
|
if (includeDefs && ref.name) {
|
|
68
|
-
const definitions =
|
|
68
|
+
const definitions = resolve_helper_1.Resolve.byNameAndType(ref.name, environments, ref.type);
|
|
69
69
|
if (definitions && definitions.length > 0) {
|
|
70
70
|
applyCdsToDefinitions(environments, ref.name, ref.type, definitions, ref.nodeId, defaultCd);
|
|
71
71
|
}
|
|
@@ -104,7 +104,7 @@ function makeAllMaybe(references, graph, environments, includeDefs, applyCds = u
|
|
|
104
104
|
*/
|
|
105
105
|
function applyCdsToAllInGraphButConstants(graph, references, cds) {
|
|
106
106
|
for (const [, v] of graph.vertices(true)) {
|
|
107
|
-
if (
|
|
107
|
+
if (vertex_1.ValueVertex.is(v)) {
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
if (v.cds) {
|
|
@@ -9,10 +9,12 @@ import { Identifier, type IdentifierDefinition, ReferenceType } from './identifi
|
|
|
9
9
|
* @param target - The target (meta) type of the identifier to resolve
|
|
10
10
|
* @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
|
|
11
11
|
* if the identifier is undefined in the current scope/with the current environment information.
|
|
12
|
+
* @useInstead {@link Resolve.byNameAndType}
|
|
12
13
|
*/
|
|
13
14
|
export declare function resolveByName(id: Identifier, environment: REnvironmentInformation, target: ReferenceType): readonly IdentifierDefinition[] | undefined;
|
|
14
15
|
/**
|
|
15
16
|
* The more performant version of {@link resolveByName} when the target type is unknown.
|
|
17
|
+
* @useInstead {@link Resolve.byName}
|
|
16
18
|
*/
|
|
17
19
|
export declare function resolveByNameAnyType(id: Identifier, environment: REnvironmentInformation): IdentifierDefinition[] | undefined;
|
|
18
20
|
/**
|
|
@@ -21,5 +23,6 @@ export declare function resolveByNameAnyType(id: Identifier, environment: REnvir
|
|
|
21
23
|
* @param environment - The current environment used for name resolution
|
|
22
24
|
* @param wantedValue - The built-in constant value to check for
|
|
23
25
|
* @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
|
|
26
|
+
* @useInstead {@link Resolve.toBuiltIn}
|
|
24
27
|
*/
|
|
25
28
|
export declare function resolvesToBuiltInConstant(name: Identifier | undefined, environment: REnvironmentInformation, wantedValue: unknown): Ternary;
|
|
@@ -8,6 +8,7 @@ const logic_1 = require("../../util/logic");
|
|
|
8
8
|
const identifier_1 = require("./identifier");
|
|
9
9
|
const info_1 = require("../info");
|
|
10
10
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
11
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
12
|
/** A namespaced lookup only sees its matching layer; a bare lookup skips loaded-but-unattached namespaces (`requireNamespace`). */
|
|
12
13
|
function layerSkipped(layer, ns) {
|
|
13
14
|
if (ns !== undefined) {
|
|
@@ -20,6 +21,8 @@ const VariableTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.R
|
|
|
20
21
|
const ConstantTargetTypes = identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
|
|
21
22
|
const BuiltInConstantTargetTypes = identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
|
|
22
23
|
const BuiltInFunctionTargetTypes = identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.Unknown;
|
|
24
|
+
const NonFunctionTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument | identifier_1.ReferenceType.Unknown
|
|
25
|
+
| identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant;
|
|
23
26
|
const inEveryBranch = (d) => (0, info_1.happensInEveryBranch)(d.cds);
|
|
24
27
|
const notAParameter = (d) => d.type !== identifier_1.ReferenceType.Parameter;
|
|
25
28
|
const TargetTypePredicate = {
|
|
@@ -33,7 +36,20 @@ const TargetTypePredicate = {
|
|
|
33
36
|
[identifier_1.ReferenceType.BuiltInFunction]: ({ type }) => (0, identifier_1.isReferenceType)(type, BuiltInFunctionTargetTypes),
|
|
34
37
|
[identifier_1.ReferenceType.S3MethodPrefix]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
|
|
35
38
|
[identifier_1.ReferenceType.S7MethodPrefix]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
|
|
39
|
+
[identifier_1.ReferenceType.NonFunction]: ({ type }) => (0, identifier_1.isReferenceType)(type, NonFunctionTargetTypes),
|
|
36
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* What the script itself defines under `id`, ignoring everything flowR carries or a database attached.
|
|
43
|
+
* This is the fallback of a value position ({@link ReferenceType.NonFunction}), and the two halves answer
|
|
44
|
+
* the two ways a value position meets a function of its name. In a project that attaches packages,
|
|
45
|
+
* `library(dplyr)` puts a function `id` in scope, and `filter(df, id > 2)` means the column, never that
|
|
46
|
+
* function. A script writing `x <- function() 1` and then `x > 2` has only that one `x` to mean, wrong as
|
|
47
|
+
* the comparison is, so the read stays: dropping it would leave the definition looking unused.
|
|
48
|
+
*/
|
|
49
|
+
function ownDefinitions(id, environment) {
|
|
50
|
+
const own = resolveByNameAnyType(id, environment)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId));
|
|
51
|
+
return own !== undefined && own.length > 0 ? own : undefined;
|
|
52
|
+
}
|
|
37
53
|
/**
|
|
38
54
|
* Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
|
|
39
55
|
* If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
|
|
@@ -42,11 +58,17 @@ const TargetTypePredicate = {
|
|
|
42
58
|
* @param target - The target (meta) type of the identifier to resolve
|
|
43
59
|
* @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
|
|
44
60
|
* if the identifier is undefined in the current scope/with the current environment information.
|
|
61
|
+
* @useInstead {@link Resolve.byNameAndType}
|
|
45
62
|
*/
|
|
46
63
|
function resolveByName(id, environment, target) {
|
|
47
64
|
if (target === identifier_1.ReferenceType.Unknown) {
|
|
48
65
|
return resolveByNameAnyType(id, environment);
|
|
49
66
|
}
|
|
67
|
+
const found = resolveByTargetType(id, environment, target);
|
|
68
|
+
return found === undefined && target === identifier_1.ReferenceType.NonFunction ? ownDefinitions(id, environment) : found;
|
|
69
|
+
}
|
|
70
|
+
/** {@link resolveByName} without its two special targets, i.e. the plain walk up the environments. */
|
|
71
|
+
function resolveByTargetType(id, environment, target) {
|
|
50
72
|
/* read piecewise, `Identifier.toArray` would allocate a tuple per resolution */
|
|
51
73
|
const name = identifier_1.Identifier.getName(id);
|
|
52
74
|
const ns = identifier_1.Identifier.getNamespace(id);
|
|
@@ -81,8 +103,20 @@ function resolveByName(id, environment, target) {
|
|
|
81
103
|
}
|
|
82
104
|
if (definition !== undefined && definition.length > 0) {
|
|
83
105
|
/* ask before filtering: the common case wants all of them and needs no copy */
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
let allWanted = true;
|
|
107
|
+
let allOk = true;
|
|
108
|
+
const checkParameters = target === identifier_1.ReferenceType.Function;
|
|
109
|
+
for (const def of definition) {
|
|
110
|
+
if (!wantedType(def)) {
|
|
111
|
+
allWanted = false;
|
|
112
|
+
allOk = false;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (allOk && ((checkParameters && !notAParameter(def)) || !inEveryBranch(def))) {
|
|
116
|
+
allOk = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (allOk) {
|
|
86
120
|
return definition;
|
|
87
121
|
}
|
|
88
122
|
/* never alias the environment's own array, it is appended to below */
|
|
@@ -98,16 +132,18 @@ function resolveByName(id, environment, target) {
|
|
|
98
132
|
}
|
|
99
133
|
current = current.parent;
|
|
100
134
|
} while (!current.builtInEnv);
|
|
101
|
-
|
|
135
|
+
/* the built-in layer is handed over as it is, except to a value position: `filter(df, c > 2)` means the
|
|
136
|
+
column `c`, never `base::c`, and only with nothing left does `ownDefinitions` have its say */
|
|
137
|
+
const known = current.memory.get(name);
|
|
138
|
+
const builtIns = target === identifier_1.ReferenceType.NonFunction ? known?.filter(wantedType) : known;
|
|
102
139
|
if (definitions) {
|
|
103
|
-
return builtIns === undefined ? definitions : definitions.concat(builtIns);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return builtIns;
|
|
140
|
+
return builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns);
|
|
107
141
|
}
|
|
142
|
+
return builtIns === undefined || builtIns.length > 0 ? builtIns : undefined;
|
|
108
143
|
}
|
|
109
144
|
/**
|
|
110
145
|
* The more performant version of {@link resolveByName} when the target type is unknown.
|
|
146
|
+
* @useInstead {@link Resolve.byName}
|
|
111
147
|
*/
|
|
112
148
|
function resolveByNameAnyType(id, environment) {
|
|
113
149
|
let current = environment.current;
|
|
@@ -180,6 +216,7 @@ function resolveByNameAnyType(id, environment) {
|
|
|
180
216
|
* @param environment - The current environment used for name resolution
|
|
181
217
|
* @param wantedValue - The built-in constant value to check for
|
|
182
218
|
* @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
|
|
219
|
+
* @useInstead {@link Resolve.toBuiltIn}
|
|
183
220
|
*/
|
|
184
221
|
function resolvesToBuiltInConstant(name, environment, wantedValue) {
|
|
185
222
|
if (name === undefined) {
|
|
@@ -12,6 +12,12 @@ import { resolveIdToArgName, resolveIdToArgStringVector, resolveIdToArgValue, re
|
|
|
12
12
|
* - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
|
|
13
13
|
* Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
|
|
14
14
|
* - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* Resolve.byName('x', environment); // every definition `x` may refer to
|
|
18
|
+
* Resolve.toValue(id, { graph, ctx }); // the value(s) the node may hold
|
|
19
|
+
* Resolve.argument.value(call, 'file', ...); // the value of a named argument
|
|
20
|
+
* ```
|
|
15
21
|
*/
|
|
16
22
|
export declare const Resolve: {
|
|
17
23
|
readonly name: "Resolve";
|
|
@@ -15,6 +15,12 @@ const resolve_args_1 = require("../../abstract-interpretation/data-frame/resolve
|
|
|
15
15
|
* - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
|
|
16
16
|
* Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
|
|
17
17
|
* - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* Resolve.byName('x', environment); // every definition `x` may refer to
|
|
21
|
+
* Resolve.toValue(id, { graph, ctx }); // the value(s) the node may hold
|
|
22
|
+
* Resolve.argument.value(call, 'file', ...); // the value of a named argument
|
|
23
|
+
* ```
|
|
18
24
|
*/
|
|
19
25
|
exports.Resolve = {
|
|
20
26
|
name: 'Resolve',
|
|
@@ -57,9 +57,13 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
57
57
|
* @param resolve - Variable resolve mode
|
|
58
58
|
* @param ctx - Context used for clean environment
|
|
59
59
|
* @param blocked - If set, the ids that should not be considered during resolution (=>top)
|
|
60
|
+
* @useInstead {@link Resolve.toValue}
|
|
60
61
|
*/
|
|
61
62
|
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
|
|
62
63
|
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
64
|
+
/**
|
|
65
|
+
* @useInstead {@link Resolve.toSingleString}
|
|
66
|
+
*/
|
|
63
67
|
export declare function resolveIdToSingleString(id: NodeId | RNodeWithParent | undefined, info: ResolveInfo): string | undefined;
|
|
64
68
|
/**
|
|
65
69
|
* Please use {@link resolveIdToValue}
|
|
@@ -91,5 +95,6 @@ export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ct
|
|
|
91
95
|
* @param name - Identifier to resolve
|
|
92
96
|
* @param environment - Environment to use
|
|
93
97
|
* @returns Value of Constant or Top
|
|
98
|
+
* @useInstead {@link Resolve.toConstants}
|
|
94
99
|
*/
|
|
95
100
|
export declare function resolveToConstants(name: Identifier | undefined, environment: REnvironmentInformation): ResolveResult;
|
|
@@ -12,7 +12,6 @@ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
|
12
12
|
const visiting_queue_1 = require("../../../slicing/static/visiting-queue");
|
|
13
13
|
const assert_1 = require("../../../util/assert");
|
|
14
14
|
const identifier_1 = require("../../environments/identifier");
|
|
15
|
-
const resolve_by_name_1 = require("../../environments/resolve-by-name");
|
|
16
15
|
const edge_1 = require("../../graph/edge");
|
|
17
16
|
const r_for_loop_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop");
|
|
18
17
|
const unknown_replacement_1 = require("../../graph/unknown-replacement");
|
|
@@ -23,6 +22,9 @@ const r_value_1 = require("../values/r-value");
|
|
|
23
22
|
const set_constants_1 = require("../values/sets/set-constants");
|
|
24
23
|
const resolve_1 = require("./resolve");
|
|
25
24
|
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
25
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
26
|
+
const node_value_1 = require("./node-value");
|
|
27
|
+
const graph_1 = require("../../graph/graph");
|
|
26
28
|
const AliasHandler = {
|
|
27
29
|
[vertex_1.VertexType.Value]: (sourceId) => [sourceId],
|
|
28
30
|
[vertex_1.VertexType.Use]: getUseAlias,
|
|
@@ -33,11 +35,11 @@ const AliasHandler = {
|
|
|
33
35
|
function getFunctionCallAlias(sourceId, dataflow, environment) {
|
|
34
36
|
const vertex = dataflow.getVertex(sourceId);
|
|
35
37
|
/* the lexeme of an infix call like `a %% b` is the whole expression, so we prefer the effective name of the vertex */
|
|
36
|
-
const identifier =
|
|
38
|
+
const identifier = vertex_1.FunctionCallVertex.is(vertex) ? vertex.name : (0, node_id_1.recoverName)(sourceId, dataflow.idMap);
|
|
37
39
|
if (identifier === undefined) {
|
|
38
40
|
return undefined;
|
|
39
41
|
}
|
|
40
|
-
const defs =
|
|
42
|
+
const defs = resolve_helper_1.Resolve.byNameAndType(identifier, environment, identifier_1.ReferenceType.Function);
|
|
41
43
|
if (defs?.length !== 1) {
|
|
42
44
|
return undefined;
|
|
43
45
|
}
|
|
@@ -50,7 +52,7 @@ function getUseAlias(sourceId, dataflow, environment) {
|
|
|
50
52
|
if (identifier === undefined) {
|
|
51
53
|
return undefined;
|
|
52
54
|
}
|
|
53
|
-
const defs =
|
|
55
|
+
const defs = resolve_helper_1.Resolve.byName(identifier, environment);
|
|
54
56
|
if (defs === undefined) {
|
|
55
57
|
return undefined;
|
|
56
58
|
}
|
|
@@ -92,7 +94,7 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
92
94
|
if (info === undefined) {
|
|
93
95
|
return undefined;
|
|
94
96
|
}
|
|
95
|
-
else if (
|
|
97
|
+
else if (vertex_1.FunctionDefinitionVertex.is(info)) {
|
|
96
98
|
definitions.add(sourceId);
|
|
97
99
|
continue;
|
|
98
100
|
}
|
|
@@ -123,6 +125,7 @@ function getAliases(sourceIds, dataflow, environment) {
|
|
|
123
125
|
* @param resolve - Variable resolve mode
|
|
124
126
|
* @param ctx - Context used for clean environment
|
|
125
127
|
* @param blocked - If set, the ids that should not be considered during resolution (=>top)
|
|
128
|
+
* @useInstead {@link Resolve.toValue}
|
|
126
129
|
*/
|
|
127
130
|
function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, resolve = ctx.config.solver.variables, blocked }) {
|
|
128
131
|
blocked ??= new Set();
|
|
@@ -167,8 +170,11 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
173
|
+
/**
|
|
174
|
+
* @useInstead {@link Resolve.toSingleString}
|
|
175
|
+
*/
|
|
170
176
|
function resolveIdToSingleString(id, info) {
|
|
171
|
-
const element =
|
|
177
|
+
const element = node_value_1.NodeValue.sole((0, general_1.valueSetGuard)(resolveIdToValue(id, info)), 'string');
|
|
172
178
|
return element !== undefined && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
|
|
173
179
|
}
|
|
174
180
|
/** the values one element of a sequence may take: a vector contributes its elements, a set what its members do */
|
|
@@ -195,7 +201,7 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
|
|
|
195
201
|
if (identifier === undefined) {
|
|
196
202
|
return r_value_1.Top;
|
|
197
203
|
}
|
|
198
|
-
const defs =
|
|
204
|
+
const defs = resolve_helper_1.Resolve.byName(identifier, environment);
|
|
199
205
|
if (defs === undefined) {
|
|
200
206
|
return r_value_1.Top;
|
|
201
207
|
}
|
|
@@ -292,7 +298,7 @@ function isParameterDefault(node, idMap) {
|
|
|
292
298
|
*/
|
|
293
299
|
function iteratedSequence(id, graph, idMap) {
|
|
294
300
|
let sequence;
|
|
295
|
-
for (const [target, edge] of graph.outgoingEdges(id) ??
|
|
301
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
296
302
|
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
|
|
297
303
|
continue;
|
|
298
304
|
}
|
|
@@ -371,19 +377,19 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
|
|
|
371
377
|
continue;
|
|
372
378
|
}
|
|
373
379
|
const isFn = t === vertex_1.VertexType.FunctionCall;
|
|
374
|
-
const outgoingEdges = graph.outgoingEdges(id) ??
|
|
380
|
+
const outgoingEdges = graph.outgoingEdges(id) ?? graph_1.NoEdges;
|
|
375
381
|
let foundRetuns = false;
|
|
376
382
|
// travel all read and defined-by edges
|
|
377
|
-
for (const [targetId,
|
|
383
|
+
for (const [targetId, edge] of outgoingEdges) {
|
|
378
384
|
if (isFn) {
|
|
379
|
-
if (
|
|
385
|
+
if (edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.Returns) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedByOnCall) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedBy)) {
|
|
380
386
|
queue.add(targetId, baseEnvironment, cleanFingerprint, false);
|
|
381
387
|
}
|
|
382
|
-
foundRetuns ||= edge_1.DfEdge.includesType(
|
|
388
|
+
foundRetuns ||= edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns);
|
|
383
389
|
continue;
|
|
384
390
|
}
|
|
385
391
|
// currently, they have to be exact!
|
|
386
|
-
if (
|
|
392
|
+
if (edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.Reads) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedBy) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedByOnCall)) {
|
|
387
393
|
queue.add(targetId, baseEnvironment, cleanFingerprint, false);
|
|
388
394
|
}
|
|
389
395
|
}
|
|
@@ -427,12 +433,13 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
|
|
|
427
433
|
* @param name - Identifier to resolve
|
|
428
434
|
* @param environment - Environment to use
|
|
429
435
|
* @returns Value of Constant or Top
|
|
436
|
+
* @useInstead {@link Resolve.toConstants}
|
|
430
437
|
*/
|
|
431
438
|
function resolveToConstants(name, environment) {
|
|
432
439
|
if (name === undefined) {
|
|
433
440
|
return r_value_1.Top;
|
|
434
441
|
}
|
|
435
|
-
const definitions =
|
|
442
|
+
const definitions = resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.Constant);
|
|
436
443
|
if (definitions === undefined) {
|
|
437
444
|
return r_value_1.Top;
|
|
438
445
|
}
|
|
@@ -17,6 +17,12 @@ declare function infoOf<OtherInfo>(this: void, data: DataflowProcessorInformatio
|
|
|
17
17
|
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
18
18
|
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
19
19
|
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* NodeValue.of(id, data); // during processing
|
|
23
|
+
* NodeValue.inGraph(id, graph, ctx); // on a finished graph
|
|
24
|
+
* NodeValue.sole(NodeValue.setOf(id, data)); // the single value, if there is exactly one
|
|
25
|
+
* ```
|
|
20
26
|
*/
|
|
21
27
|
export declare const NodeValue: {
|
|
22
28
|
readonly name: "NodeValue";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeValue = void 0;
|
|
4
|
-
const
|
|
4
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
5
5
|
const general_1 = require("../values/general");
|
|
6
6
|
const string_constants_1 = require("../values/string/string-constants");
|
|
7
7
|
function infoOf(data, overrides) {
|
|
@@ -24,6 +24,12 @@ function graphInfoOf(graph, ctx, overrides) {
|
|
|
24
24
|
* This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
|
|
25
25
|
* constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
|
|
26
26
|
* Anything needing an abstract state lives in `src/abstract-interpretation/`.
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* NodeValue.of(id, data); // during processing
|
|
30
|
+
* NodeValue.inGraph(id, graph, ctx); // on a finished graph
|
|
31
|
+
* NodeValue.sole(NodeValue.setOf(id, data)); // the single value, if there is exactly one
|
|
32
|
+
* ```
|
|
27
33
|
*/
|
|
28
34
|
exports.NodeValue = {
|
|
29
35
|
name: 'NodeValue',
|
|
@@ -31,40 +37,40 @@ exports.NodeValue = {
|
|
|
31
37
|
infoOf,
|
|
32
38
|
/** The value(s) the node may hold. */
|
|
33
39
|
of(id, data, overrides) {
|
|
34
|
-
return
|
|
40
|
+
return resolve_helper_1.Resolve.toValue(id, infoOf(data, overrides));
|
|
35
41
|
},
|
|
36
42
|
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
37
43
|
setOf(id, data, overrides) {
|
|
38
|
-
return (0, general_1.valueSetGuard)(
|
|
44
|
+
return (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(data, overrides)));
|
|
39
45
|
},
|
|
40
46
|
/** The strings the node may hold, `undefined` if it does not resolve to strings. */
|
|
41
47
|
stringsOf(id, data, overrides) {
|
|
42
|
-
const resolved = (0, general_1.valueSetGuard)(
|
|
48
|
+
const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(data, overrides)));
|
|
43
49
|
return resolved ? (0, string_constants_1.collectStrings)(resolved.elements) : undefined;
|
|
44
50
|
},
|
|
45
51
|
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
46
52
|
singleStringOf(id, data, overrides) {
|
|
47
|
-
return
|
|
53
|
+
return resolve_helper_1.Resolve.toSingleString(id, infoOf(data, overrides));
|
|
48
54
|
},
|
|
49
55
|
/** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
|
|
50
56
|
sole: general_1.soleValue,
|
|
51
57
|
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
52
58
|
soleOf(id, data, type, overrides) {
|
|
53
|
-
return (0, general_1.soleValue)((0, general_1.valueSetGuard)(
|
|
59
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(data, overrides))), type);
|
|
54
60
|
},
|
|
55
61
|
/** The same questions, asked of a finished dataflow graph instead of a running processor. */
|
|
56
62
|
inGraph: {
|
|
57
63
|
/** The value set the node may hold, `undefined` if it resolves to top or bottom. */
|
|
58
64
|
setOf(id, graph, ctx, overrides) {
|
|
59
|
-
return (0, general_1.valueSetGuard)(
|
|
65
|
+
return (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, graphInfoOf(graph, ctx, overrides)));
|
|
60
66
|
},
|
|
61
67
|
/** The single string the node resolves to, `undefined` if it is not exactly one. */
|
|
62
68
|
singleStringOf(id, graph, ctx, overrides) {
|
|
63
|
-
return
|
|
69
|
+
return resolve_helper_1.Resolve.toSingleString(id, graphInfoOf(graph, ctx, overrides));
|
|
64
70
|
},
|
|
65
71
|
/** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
|
|
66
72
|
soleOf(id, graph, ctx, type, overrides) {
|
|
67
|
-
return (0, general_1.soleValue)((0, general_1.valueSetGuard)(
|
|
73
|
+
return (0, general_1.soleValue)((0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, graphInfoOf(graph, ctx, overrides))), type);
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
};
|
|
@@ -8,10 +8,10 @@ const assert_1 = require("../../../util/assert");
|
|
|
8
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
9
|
const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
10
10
|
const general_1 = require("../values/general");
|
|
11
|
-
const alias_tracking_1 = require("./alias-tracking");
|
|
12
11
|
const r_value_2 = require("../values/r-value");
|
|
13
12
|
const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
|
|
14
13
|
const string_constants_1 = require("../values/string/string-constants");
|
|
14
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
15
15
|
/**
|
|
16
16
|
* Get the values of all arguments matching the criteria.
|
|
17
17
|
*/
|
|
@@ -89,7 +89,7 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environm
|
|
|
89
89
|
full = false;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const resolved = (0, general_1.valueSetGuard)(
|
|
92
|
+
const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(argument, { environment, graph, full, resolve: variableResolve, ctx }));
|
|
93
93
|
if (resolved) {
|
|
94
94
|
const values = [];
|
|
95
95
|
for (const value of resolved.elements) {
|
|
@@ -8,8 +8,8 @@ const r_value_1 = require("../../../util/r-value");
|
|
|
8
8
|
const r_value_2 = require("../values/r-value");
|
|
9
9
|
const interval_constants_1 = require("../values/intervals/interval-constants");
|
|
10
10
|
const vector_constants_1 = require("../values/vectors/vector-constants");
|
|
11
|
-
const alias_tracking_1 = require("./alias-tracking");
|
|
12
11
|
const match_arguments_1 = require("./match-arguments");
|
|
12
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
13
13
|
/** R breaks a tie to the even neighbor, unlike `Math.round`, which always goes up */
|
|
14
14
|
function roundHalfEven(x, digits = 0) {
|
|
15
15
|
const scale = 10 ** digits;
|
|
@@ -81,7 +81,7 @@ exports.NumericFns = {
|
|
|
81
81
|
};
|
|
82
82
|
/** the number an operand folds to, with a logical counting as its `0`/`1` just like R would coerce it */
|
|
83
83
|
function numeric(node, args) {
|
|
84
|
-
const value = (0, r_value_1.unliftRValue)(
|
|
84
|
+
const value = (0, r_value_1.unliftRValue)(resolve_helper_1.Resolve.toValue(node, args));
|
|
85
85
|
if (typeof value === 'boolean') {
|
|
86
86
|
return Number(value);
|
|
87
87
|
}
|
|
@@ -11,10 +11,11 @@ const r_value_1 = require("../../../util/r-value");
|
|
|
11
11
|
const logical_constants_1 = require("../values/logical/logical-constants");
|
|
12
12
|
const r_value_2 = require("../values/r-value");
|
|
13
13
|
const general_1 = require("../values/general");
|
|
14
|
-
const
|
|
14
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
15
|
+
const node_value_1 = require("./node-value");
|
|
15
16
|
/** the scalar an operand folds to, with a logical counting as its `0`/`1` just like R would coerce it */
|
|
16
17
|
function operand(node, args) {
|
|
17
|
-
const value = (0, r_value_1.unliftRValue)(
|
|
18
|
+
const value = (0, r_value_1.unliftRValue)(resolve_helper_1.Resolve.toValue(node, args));
|
|
18
19
|
if (typeof value === 'boolean') {
|
|
19
20
|
return Number(value);
|
|
20
21
|
}
|
|
@@ -23,7 +24,7 @@ function operand(node, args) {
|
|
|
23
24
|
}
|
|
24
25
|
return typeof value === 'object' && value !== null && 'str' in value ? value.str : undefined;
|
|
25
26
|
}
|
|
26
|
-
/** as a condition, R takes any non-zero number for `TRUE`; `NA`, strings and everything else do not fold */
|
|
27
|
+
/** as a condition, R takes any non-zero number for `TRUE`; `NA`, strings, and everything else do not fold */
|
|
27
28
|
function asLogical(node, args) {
|
|
28
29
|
const value = operand(node, args);
|
|
29
30
|
return typeof value === 'number' && !Number.isNaN(value) ? value !== 0 : undefined;
|
|
@@ -109,6 +110,6 @@ function resolveAsGroup(args) {
|
|
|
109
110
|
return r_value_2.Top;
|
|
110
111
|
}
|
|
111
112
|
/* unwrap the set again, as the caller of a handler wraps the returned value in one */
|
|
112
|
-
return
|
|
113
|
+
return node_value_1.NodeValue.sole((0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(node.children[0], args))) ?? r_value_2.Top;
|
|
113
114
|
}
|
|
114
115
|
//# sourceMappingURL=resolve-operators.js.map
|
|
@@ -8,8 +8,8 @@ const identifier_1 = require("../../environments/identifier");
|
|
|
8
8
|
const r_value_1 = require("../values/r-value");
|
|
9
9
|
const string_constants_1 = require("../values/string/string-constants");
|
|
10
10
|
const interval_constants_1 = require("../values/intervals/interval-constants");
|
|
11
|
-
const alias_tracking_1 = require("./alias-tracking");
|
|
12
11
|
const match_arguments_1 = require("./match-arguments");
|
|
12
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
13
13
|
/** everything after the last separator, with trailing separators dropped first (`a/b/` is `b`, `/` is the empty string) */
|
|
14
14
|
function basename(path) {
|
|
15
15
|
const trimmed = path.replace(/\/+$/, '');
|
|
@@ -81,7 +81,7 @@ function foldStringCall(node, resolveArg) {
|
|
|
81
81
|
for (const [at, slot] of matched.entries()) {
|
|
82
82
|
if (Array.isArray(slot)) {
|
|
83
83
|
const parts = slot.map(resolveArg);
|
|
84
|
-
if (parts.
|
|
84
|
+
if (parts.includes(undefined)) {
|
|
85
85
|
return undefined;
|
|
86
86
|
}
|
|
87
87
|
args.push(parts);
|
|
@@ -114,7 +114,7 @@ function resolveAsStringFn(args) {
|
|
|
114
114
|
if (node.type !== type_1.RType.FunctionCall || !node.named) {
|
|
115
115
|
return r_value_1.Top;
|
|
116
116
|
}
|
|
117
|
-
const folded = foldStringCall(node, arg =>
|
|
117
|
+
const folded = foldStringCall(node, arg => resolve_helper_1.Resolve.toSingleString(arg.info.id, args));
|
|
118
118
|
if (folded === undefined) {
|
|
119
119
|
return r_value_1.Top;
|
|
120
120
|
}
|
|
@@ -2,7 +2,7 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
|
|
|
2
2
|
import type { DataflowGraph } from '../../graph/graph';
|
|
3
3
|
import type { ControlFlowGraph } from '../../../control-flow/control-flow-graph';
|
|
4
4
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
5
|
-
import {
|
|
5
|
+
import { ControlDependency } from '../../info';
|
|
6
6
|
/** a resolved `setwd`-style call: its `dir` is `undefined` when it cannot be determined statically */
|
|
7
7
|
export interface WorkingDirectoryChange {
|
|
8
8
|
readonly id: NodeId;
|
|
@@ -18,11 +18,11 @@ const edge_1 = require("../../graph/edge");
|
|
|
18
18
|
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
19
19
|
const files_1 = require("../../../util/files");
|
|
20
20
|
const built_in_source_1 = require("../../internal/process/functions/call/built-in/built-in-source");
|
|
21
|
+
const graph_1 = require("../../graph/graph");
|
|
21
22
|
/** functions recognized as changing the working directory; a registry so more (e.g. `withr::with_dir`) can be added */
|
|
22
23
|
const ChangeFunctions = [
|
|
23
24
|
{ name: 'setwd', namespace: 'base', argIdx: 0, argName: 'dir' }
|
|
24
25
|
];
|
|
25
|
-
const LoopTypes = new Set([type_1.RType.ForLoop, type_1.RType.WhileLoop, type_1.RType.RepeatLoop]);
|
|
26
26
|
const CandidateCap = 64;
|
|
27
27
|
function matchSpec(name) {
|
|
28
28
|
if (name === undefined) {
|
|
@@ -80,7 +80,7 @@ function enclosingFunction(idMap, id) {
|
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
82
|
function isIterated(cds, idMap) {
|
|
83
|
-
return cds.some(cd =>
|
|
83
|
+
return cds.some(cd => info_1.ControlDependency.isIterated(cd, idMap));
|
|
84
84
|
}
|
|
85
85
|
function resolveAt(target, targetCds, baseWd, changes, cfg) {
|
|
86
86
|
const relevant = changes.filter(c => (0, happens_before_1.happensBefore)(cfg, c.id, target) !== logic_1.Ternary.Never);
|
|
@@ -145,7 +145,7 @@ function collect(graph, ctx) {
|
|
|
145
145
|
// a function's setwd is propagated to its call sites; only a lone unconditional setwd has a site-independent effect
|
|
146
146
|
for (const [fn, setwds] of byFn.entries()) {
|
|
147
147
|
const net = setwds.length === 1 && setwds[0].cds.length === 0 && !setwds[0].iterated ? setwds[0].dir : undefined;
|
|
148
|
-
for (const [site, edge] of graph.ingoingEdges(fn) ??
|
|
148
|
+
for (const [site, edge] of graph.ingoingEdges(fn) ?? graph_1.NoEdges) {
|
|
149
149
|
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
150
150
|
continue;
|
|
151
151
|
}
|