@eagleoutice/flowr 2.13.16 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- 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 +12 -5
- package/benchmark/calibration.js +42 -14
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +5 -4
- 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/common/options.d.ts +0 -31
- package/cli/common/options.js +1 -8
- package/cli/common/scripts-info.d.ts +0 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- 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 +79 -0
- 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/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +18 -0
- 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 +442 -10
- package/dataflow/environments/default-builtin-config.js +188 -18
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/identifier.d.ts +7 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.js +2 -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 +30 -5
- 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 +4 -3
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
- 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.js +5 -4
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +10 -4
- 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 +11 -1
- package/dataflow/graph/graph.js +16 -5
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- 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.js +2 -2
- 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-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 +15 -12
- 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-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +17 -18
- 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-signature-database.js +3 -0
- 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/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- 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 +35 -45
- 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.js +1 -2
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
- 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.js +21 -21
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +13 -13
- 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 +2 -2
- 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/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/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 -2
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.js +3 -3
- 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/quads.js +19 -6
- package/util/schema.js +2 -2
- 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
|
@@ -6,12 +6,12 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
6
6
|
const linker_1 = require("../../../../linker");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
|
-
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
10
9
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
11
10
|
const general_1 = require("../../../../../eval/values/general");
|
|
12
11
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
13
12
|
const range_1 = require("../../../../../../util/range");
|
|
14
13
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
14
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
15
15
|
/**
|
|
16
16
|
* Process a hook such as `on.exit`
|
|
17
17
|
*/
|
|
@@ -64,10 +64,10 @@ function processRegisterHook(name, args, rootId, data, config) {
|
|
|
64
64
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args: transformed, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.RegisterHook });
|
|
65
65
|
const resolveArgs = node_value_1.NodeValue.infoOf(data, { graph: res.information.graph, environment: res.information.environment });
|
|
66
66
|
const shouldAdd = addIds.size === 0 ? config.args.add?.default :
|
|
67
|
-
Array.from(addIds).flatMap(id => (0, general_1.valueSetGuard)(
|
|
67
|
+
Array.from(addIds).flatMap(id => (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, resolveArgs))?.elements ?? [])
|
|
68
68
|
.some(v => v.type === 'logical' && v.value !== false);
|
|
69
69
|
const shouldBeAfter = afterIds.size === 0 ? config.args.after?.default :
|
|
70
|
-
Array.from(afterIds).flatMap(id => (0, general_1.valueSetGuard)(
|
|
70
|
+
Array.from(afterIds).flatMap(id => (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, resolveArgs))?.elements ?? [])
|
|
71
71
|
.some(v => v.type === 'logical' && v.value !== false);
|
|
72
72
|
const info = res.information;
|
|
73
73
|
const hooks = Array.from(wrappedFunctions, id => ({
|
|
@@ -8,7 +8,6 @@ const common_1 = require("../common");
|
|
|
8
8
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
9
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
10
|
const logger_1 = require("../../../../../logger");
|
|
11
|
-
const vertex_1 = require("../../../../../graph/vertex");
|
|
12
11
|
const edge_1 = require("../../../../../graph/edge");
|
|
13
12
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
14
13
|
const built_in_access_1 = require("./built-in-access");
|
|
@@ -22,6 +21,7 @@ const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/
|
|
|
22
21
|
const graph_1 = require("../../../../../graph/graph");
|
|
23
22
|
const range_1 = require("../../../../../../util/range");
|
|
24
23
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
24
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
25
25
|
/**
|
|
26
26
|
* Process a replacement function call like `<-`, `[[<-`, `$<-`, etc.
|
|
27
27
|
* These are automatically created when doing assignments like `x[y] <- value` or in general `fun(x) <- value` will call `fun<- (x, value)`.
|
|
@@ -57,11 +57,11 @@ args, rootId, data, config) {
|
|
|
57
57
|
canBeReplacement: true
|
|
58
58
|
});
|
|
59
59
|
const createdVert = res.graph.getVertex(rootId);
|
|
60
|
-
if (
|
|
60
|
+
if (vertex_1.FunctionCallVertex.is(createdVert)) {
|
|
61
61
|
createdVert.origin = [built_in_proc_name_1.BuiltInProcName.Replacement];
|
|
62
62
|
}
|
|
63
63
|
const targetVert = res.graph.getVertex((0, unpack_argument_1.unpackArg)(args[0])?.info.id);
|
|
64
|
-
if (
|
|
64
|
+
if (vertex_1.VariableDefinitionVertex.is(targetVert)) {
|
|
65
65
|
targetVert.par = true;
|
|
66
66
|
}
|
|
67
67
|
const convertedArgs = config.readIndices ? args.slice(1, -1) : (0, built_in_access_1.symbolArgumentsToStrings)(args.slice(1, -1), 0);
|
|
@@ -10,10 +10,10 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
10
10
|
const prefix_1 = require("../../../../../../util/prefix");
|
|
11
11
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
12
12
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
13
|
-
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
14
13
|
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
15
14
|
const define_1 = require("../../../../../environments/define");
|
|
16
15
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
16
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
17
17
|
/** whether `value` is a call to the *built-in* `ls`/`objects` that lists (and thus clears) the whole scope */
|
|
18
18
|
function isBuiltInLsCall(value, data) {
|
|
19
19
|
if (value.type !== type_1.RType.FunctionCall || !value.named) {
|
|
@@ -32,7 +32,7 @@ function isBuiltInLsCall(value, data) {
|
|
|
32
32
|
if (ns === 'base') {
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
|
-
const resolved =
|
|
35
|
+
const resolved = resolve_helper_1.Resolve.byNameAndType(fn, data.environment, identifier_1.ReferenceType.Function);
|
|
36
36
|
return resolved === undefined || resolved.every(d => (0, identifier_1.isReferenceType)(d.type, identifier_1.ReferenceType.BuiltInFunction));
|
|
37
37
|
}
|
|
38
38
|
/** formal parameters of `rm` that may be given by name; every other positional argument belongs to `...` */
|
|
@@ -68,7 +68,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
68
68
|
info.graph.addEdge(rootId, funArg, edge_1.EdgeType.Returns);
|
|
69
69
|
info.entryPoint = funArg;
|
|
70
70
|
const fArg = info.graph.getVertex(funArg);
|
|
71
|
-
if (
|
|
71
|
+
if (vertex_1.FunctionDefinitionVertex.is(fArg)) {
|
|
72
72
|
fArg.mode ??= ['s4', 's7'];
|
|
73
73
|
}
|
|
74
74
|
return info;
|
|
@@ -86,7 +86,7 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
86
86
|
info.graph.addEdge(rootId, funId, edge_1.EdgeType.Returns);
|
|
87
87
|
info.entryPoint = funId;
|
|
88
88
|
const fArg = info.graph.getVertex(funId);
|
|
89
|
-
if (
|
|
89
|
+
if (vertex_1.FunctionDefinitionVertex.is(fArg) && config?.mode) {
|
|
90
90
|
fArg.mode ??= config.mode.slice(); // copy: mode is mutated in place later, config.mode is shared
|
|
91
91
|
}
|
|
92
92
|
if (config?.wrapIndex !== undefined) {
|
|
@@ -121,7 +121,7 @@ function linkWrappedFunction(info, args, wrapIndex, wrapName, data) {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
const vertex = info.graph.getVertex(resolved.functionId);
|
|
124
|
-
if (
|
|
124
|
+
if (!vertex_1.UseVertex.is(vertex)) {
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
info.graph.updateToFunctionCall({
|
|
@@ -121,7 +121,7 @@ function promoteCallToFunction(call, arg, info, data) {
|
|
|
121
121
|
if (anonymous) {
|
|
122
122
|
info.graph.addEdge(arg, functionId, edge_1.EdgeType.Calls | edge_1.EdgeType.Reads);
|
|
123
123
|
const dfVert = info.graph.getVertex(call);
|
|
124
|
-
if (dfVert &&
|
|
124
|
+
if (dfVert && vertex_1.FunctionDefinitionVertex.is(dfVert)) {
|
|
125
125
|
linker_1.ClosureRefs.resolveOpenIngoing(info.graph, call, dfVert, data.environment);
|
|
126
126
|
}
|
|
127
127
|
// we did the linking
|
|
@@ -145,7 +145,7 @@ function getExitPoints(vertex, graph) {
|
|
|
145
145
|
if (!vertex) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
|
-
if (
|
|
148
|
+
if (vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
149
149
|
return vertex.exitPoints;
|
|
150
150
|
}
|
|
151
151
|
// we assumed named argument
|
|
@@ -155,7 +155,7 @@ function getExitPoints(vertex, graph) {
|
|
|
155
155
|
}
|
|
156
156
|
if (n.type === type_1.RType.Argument && n.value?.type === type_1.RType.FunctionDefinition) {
|
|
157
157
|
const fdefV = graph.getVertex(n.value.info.id);
|
|
158
|
-
if (
|
|
158
|
+
if (vertex_1.FunctionDefinitionVertex.is(fdefV)) {
|
|
159
159
|
return fdefV.exitPoints;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataflowGraph } from '../../../../../graph/graph';
|
|
2
|
-
import {
|
|
2
|
+
import type { DataflowGraphVertexFunctionDefinition } from '../../../../../graph/vertex';
|
|
3
3
|
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import { type REnvironmentInformation } from '../../../../../environments/environment';
|
|
5
5
|
import type { FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
@@ -9,6 +9,7 @@ import type { IdentifierReference } from '../../../../../environments/identifier
|
|
|
9
9
|
* @param graph - the fully linked dataflow graph
|
|
10
10
|
* @param own - the effects a single function definition produces itself (its contribution to the summary)
|
|
11
11
|
* @returns a map from each function-definition vertex to its transitive-effect summary
|
|
12
|
+
* @useInstead {@link Dataflow.sideEffects.callGraphSummaries}
|
|
12
13
|
*/
|
|
13
14
|
export declare function computeCallGraphSummaries<T>(this: void, graph: DataflowGraph, own: (id: NodeId, fdef: DataflowGraphVertexFunctionDefinition) => Iterable<T>): Map<NodeId, Set<T>>;
|
|
14
15
|
/**
|
|
@@ -22,6 +23,7 @@ export declare function reResolveOpenReferences(this: void, graph: DataflowGraph
|
|
|
22
23
|
/**
|
|
23
24
|
* Propagates every function's escaped side effects (attached packages and `<<-` definitions) to its transitive callers.
|
|
24
25
|
* @returns the enriched top-level environment and whether it grew (so the extractor can re-link and re-run to a fixpoint).
|
|
26
|
+
* @useInstead {@link Dataflow.sideEffects.propagateTransitive}
|
|
25
27
|
*/
|
|
26
28
|
export declare function propagateTransitiveSideEffects(this: void, graph: DataflowGraph, environment: REnvironmentInformation, ctx: FlowrAnalyzerContext): {
|
|
27
29
|
environment: REnvironmentInformation;
|
|
@@ -4,20 +4,21 @@ exports.computeCallGraphSummaries = computeCallGraphSummaries;
|
|
|
4
4
|
exports.linkMaterializedExportsToLoaders = linkMaterializedExportsToLoaders;
|
|
5
5
|
exports.reResolveOpenReferences = reResolveOpenReferences;
|
|
6
6
|
exports.propagateTransitiveSideEffects = propagateTransitiveSideEffects;
|
|
7
|
-
const vertex_1 = require("../../../../../graph/vertex");
|
|
8
7
|
const edge_1 = require("../../../../../graph/edge");
|
|
9
8
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
9
|
const environment_1 = require("../../../../../environments/environment");
|
|
11
10
|
const built_in_library_1 = require("./built-in-library");
|
|
12
11
|
const define_1 = require("../../../../../environments/define");
|
|
13
|
-
const
|
|
12
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
13
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
14
|
+
const graph_1 = require("../../../../../graph/graph");
|
|
14
15
|
/**
|
|
15
16
|
* The function-definition vertices a `call` resolves to (via {@link EdgeType.Calls}).
|
|
16
17
|
*/
|
|
17
18
|
function calledDefinitions(graph, call) {
|
|
18
19
|
const targets = [];
|
|
19
|
-
for (const [target, edge] of graph.outgoingEdges(call) ??
|
|
20
|
-
if ((edge
|
|
20
|
+
for (const [target, edge] of graph.outgoingEdges(call) ?? graph_1.NoEdges) {
|
|
21
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.FunctionDefinitionVertex.is(graph.getVertex(target))) {
|
|
21
22
|
targets.push(target);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -28,18 +29,19 @@ function calledDefinitions(graph, call) {
|
|
|
28
29
|
* @param graph - the fully linked dataflow graph
|
|
29
30
|
* @param own - the effects a single function definition produces itself (its contribution to the summary)
|
|
30
31
|
* @returns a map from each function-definition vertex to its transitive-effect summary
|
|
32
|
+
* @useInstead {@link Dataflow.sideEffects.callGraphSummaries}
|
|
31
33
|
*/
|
|
32
34
|
function computeCallGraphSummaries(graph, own) {
|
|
33
35
|
const summary = new Map();
|
|
34
36
|
const callees = new Map();
|
|
35
37
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
36
|
-
if (
|
|
38
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
37
39
|
continue;
|
|
38
40
|
}
|
|
39
41
|
summary.set(id, new Set(own(id, vertex)));
|
|
40
42
|
const targets = [];
|
|
41
43
|
for (const node of vertex.subflow.graph) {
|
|
42
|
-
if (graph.getVertex(node)
|
|
44
|
+
if (vertex_1.FunctionCallVertex.is(graph.getVertex(node))) {
|
|
43
45
|
targets.push(...calledDefinitions(graph, node));
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -168,7 +170,7 @@ function escapedDefinitions() {
|
|
|
168
170
|
function propagateTransitiveDefinitions(graph, environment, ctx) {
|
|
169
171
|
const summary = computeCallGraphSummaries(graph, escapedDefinitions());
|
|
170
172
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
171
|
-
if (
|
|
173
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
172
174
|
continue;
|
|
173
175
|
}
|
|
174
176
|
for (const target of calledDefinitions(graph, id)) {
|
|
@@ -191,7 +193,7 @@ function propagateTransitivePackages(graph, environment, ctx) {
|
|
|
191
193
|
const summary = computeCallGraphSummaries(graph, attachedPackages);
|
|
192
194
|
const reachable = new Map(); // package -> its loading `library()` call
|
|
193
195
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
194
|
-
if (
|
|
196
|
+
if (!vertex_1.FunctionCallVertex.is(vertex) || !graph.isRoot(id)) {
|
|
195
197
|
continue;
|
|
196
198
|
}
|
|
197
199
|
for (const target of calledDefinitions(graph, id)) {
|
|
@@ -221,7 +223,7 @@ function escapedDefinitionMap(graph) {
|
|
|
221
223
|
const map = new Map();
|
|
222
224
|
const seen = new Set();
|
|
223
225
|
for (const [, vertex] of graph.vertices(true)) {
|
|
224
|
-
if (
|
|
226
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
225
227
|
continue;
|
|
226
228
|
}
|
|
227
229
|
for (const e of escapeTargetFrames(vertex)) {
|
|
@@ -251,7 +253,7 @@ function propagateTransitiveEscapedDefinitions(graph, environment) {
|
|
|
251
253
|
const names = new Set();
|
|
252
254
|
let grew = false;
|
|
253
255
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
254
|
-
if (
|
|
256
|
+
if (!vertex_1.FunctionCallVertex.is(vertex) || !graph.isRoot(id)) {
|
|
255
257
|
continue;
|
|
256
258
|
}
|
|
257
259
|
for (const target of calledDefinitions(graph, id)) {
|
|
@@ -261,7 +263,7 @@ function propagateTransitiveEscapedDefinitions(graph, environment) {
|
|
|
261
263
|
continue;
|
|
262
264
|
}
|
|
263
265
|
names.add(def.name);
|
|
264
|
-
if (
|
|
266
|
+
if (resolve_helper_1.Resolve.byNameAndType(def.name, environment, def.type)?.some(d => d.nodeId === nodeId)) {
|
|
265
267
|
continue;
|
|
266
268
|
}
|
|
267
269
|
environment = (0, define_1.define)(def, false, environment);
|
|
@@ -277,7 +279,7 @@ function reResolveOpenReferences(graph, environment, references, escapedNames) {
|
|
|
277
279
|
if (ref.name === undefined || !escapedNames.has(String(ref.name))) {
|
|
278
280
|
continue;
|
|
279
281
|
}
|
|
280
|
-
for (const { nodeId } of
|
|
282
|
+
for (const { nodeId } of resolve_helper_1.Resolve.byNameAndType(ref.name, environment, ref.type) ?? []) {
|
|
281
283
|
if (!node_id_1.NodeId.isBuiltIn(nodeId) && nodeId !== ref.nodeId) {
|
|
282
284
|
graph.addEdge(ref.nodeId, nodeId, edge_1.EdgeType.Reads);
|
|
283
285
|
}
|
|
@@ -287,6 +289,7 @@ function reResolveOpenReferences(graph, environment, references, escapedNames) {
|
|
|
287
289
|
/**
|
|
288
290
|
* Propagates every function's escaped side effects (attached packages and `<<-` definitions) to its transitive callers.
|
|
289
291
|
* @returns the enriched top-level environment and whether it grew (so the extractor can re-link and re-run to a fixpoint).
|
|
292
|
+
* @useInstead {@link Dataflow.sideEffects.propagateTransitive}
|
|
290
293
|
*/
|
|
291
294
|
function propagateTransitiveSideEffects(graph, environment, ctx) {
|
|
292
295
|
propagateTransitiveDefinitions(graph, environment, ctx);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument processing shared by the call processors.
|
|
3
|
+
* Importing the `Resolve` helper here pulls the evaluator in before the built-in configuration is
|
|
4
|
+
* initialized, so this file keeps the direct import.
|
|
5
|
+
* @lintIgnore use-instead
|
|
6
|
+
*/
|
|
1
7
|
import { type DataflowInformation } from '../../../../info';
|
|
2
8
|
import { type DataflowProcessorInformation } from '../../../../processor';
|
|
3
9
|
import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
@@ -22,6 +28,8 @@ export interface ProcessAllArgumentInput<OtherInfo> extends ForceArguments {
|
|
|
22
28
|
readonly patchData?: (data: DataflowProcessorInformation<OtherInfo & ParentInformation>, i: number) => DataflowProcessorInformation<OtherInfo & ParentInformation>;
|
|
23
29
|
/** which arguments are to be marked as {@link EdgeType#NonStandardEvaluation|non-standard-evaluation}? */
|
|
24
30
|
readonly markAsNSE?: readonly number[];
|
|
31
|
+
/** symbols that name data rather than code, so they must not resolve to a function of the same name */
|
|
32
|
+
readonly nonFunction?: ReadonlySet<NodeId>;
|
|
25
33
|
}
|
|
26
34
|
export interface ProcessAllArgumentResult {
|
|
27
35
|
readonly finalEnv: REnvironmentInformation;
|
|
@@ -44,7 +52,7 @@ export declare function convertFnArgument<OtherInfo>(this: void, arg: typeof Emp
|
|
|
44
52
|
/**
|
|
45
53
|
* Processes all arguments for a function call, updating the given final graph and environment.
|
|
46
54
|
*/
|
|
47
|
-
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forceArgs, patchData }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
|
|
55
|
+
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forceArgs, patchData, nonFunction }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
|
|
48
56
|
export interface PatchFunctionCallInput<OtherInfo> {
|
|
49
57
|
readonly nextGraph: DataflowGraph;
|
|
50
58
|
readonly rootId: NodeId;
|
|
@@ -4,6 +4,12 @@ exports.convertFnArguments = convertFnArguments;
|
|
|
4
4
|
exports.convertFnArgument = convertFnArgument;
|
|
5
5
|
exports.processAllArguments = processAllArguments;
|
|
6
6
|
exports.patchFunctionCall = patchFunctionCall;
|
|
7
|
+
/**
|
|
8
|
+
* Argument processing shared by the call processors.
|
|
9
|
+
* Importing the `Resolve` helper here pulls the evaluator in before the built-in configuration is
|
|
10
|
+
* initialized, so this file keeps the direct import.
|
|
11
|
+
* @lintIgnore use-instead
|
|
12
|
+
*/
|
|
7
13
|
const info_1 = require("../../../../info");
|
|
8
14
|
const processor_1 = require("../../../../processor");
|
|
9
15
|
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
@@ -16,18 +22,19 @@ const process_argument_1 = require("../process-argument");
|
|
|
16
22
|
const vertex_1 = require("../../../../graph/vertex");
|
|
17
23
|
const edge_1 = require("../../../../graph/edge");
|
|
18
24
|
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
25
|
+
const vertex_2 = require("../../../../graph/vertex");
|
|
19
26
|
function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
20
27
|
const valueVertex = graph.getVertex(value.entryPoint);
|
|
21
28
|
if (!valueVertex) {
|
|
22
29
|
return;
|
|
23
30
|
}
|
|
24
31
|
// link read if it is function definition directly and reference the exit point
|
|
25
|
-
if (
|
|
32
|
+
if (vertex_2.FunctionDefinitionVertex.is(valueVertex)) {
|
|
26
33
|
for (const exit of valueVertex.exitPoints) {
|
|
27
34
|
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
else if (
|
|
37
|
+
else if (!vertex_2.ValueVertex.is(valueVertex)) {
|
|
31
38
|
for (const exit of value.exitPoints) {
|
|
32
39
|
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
33
40
|
}
|
|
@@ -80,7 +87,7 @@ function convertFnArgument(arg) {
|
|
|
80
87
|
/**
|
|
81
88
|
* Processes all arguments for a function call, updating the given final graph and environment.
|
|
82
89
|
*/
|
|
83
|
-
function processAllArguments({ functionName, args, data, finalGraph, functionRootId, forceArgs = [], patchData }) {
|
|
90
|
+
function processAllArguments({ functionName, args, data, finalGraph, functionRootId, forceArgs = [], patchData, nonFunction }) {
|
|
84
91
|
let finalEnv = functionName.environment;
|
|
85
92
|
// arg env contains the environments with other args defined
|
|
86
93
|
let argEnv = functionName.environment;
|
|
@@ -112,10 +119,14 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
112
119
|
finalGraph.mergeWith(processed.graph);
|
|
113
120
|
// resolve reads within argument, we resolve before adding the `processed.environment` to avoid cyclic dependencies
|
|
114
121
|
for (const l of [processed.in, processed.unknownReferences]) {
|
|
115
|
-
for (const
|
|
122
|
+
for (const original of l) {
|
|
116
123
|
// check if it is called directly
|
|
117
|
-
const inId =
|
|
118
|
-
|
|
124
|
+
const inId = original.nodeId;
|
|
125
|
+
/* a data argument holds a value, so a function of that name is not what it reads; the narrowed
|
|
126
|
+
type stays on the reference as it bubbles through the enclosing calls */
|
|
127
|
+
const ingoing = nonFunction?.has(inId) ? { ...original, type: identifier_1.ReferenceType.NonFunction } : original;
|
|
128
|
+
const refType = vertex_2.FunctionCallVertex.is(finalGraph.getVertex(inId)) ? identifier_1.ReferenceType.Function
|
|
129
|
+
: ingoing.type === identifier_1.ReferenceType.NonFunction ? identifier_1.ReferenceType.NonFunction : identifier_1.ReferenceType.Unknown;
|
|
119
130
|
const tryToResolve = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, data.environment, refType) : undefined;
|
|
120
131
|
if (tryToResolve === undefined) {
|
|
121
132
|
remainingReadInArgs.push(ingoing);
|
|
@@ -11,6 +11,7 @@ const edge_1 = require("../../../../graph/edge");
|
|
|
11
11
|
const vertex_1 = require("../../../../graph/vertex");
|
|
12
12
|
const happens_before_1 = require("../../../../../control-flow/happens-before");
|
|
13
13
|
const logic_1 = require("../../../../../util/logic");
|
|
14
|
+
const graph_1 = require("../../../../graph/graph");
|
|
14
15
|
/** Drops the read of `target` from `use`, for a binding another write has replaced. */
|
|
15
16
|
function dropRead(graph, use, target) {
|
|
16
17
|
graph.removeEdgeType(use, target, edge_1.EdgeType.Reads);
|
|
@@ -79,7 +80,7 @@ exports.Deferred = {
|
|
|
79
80
|
*/
|
|
80
81
|
forcedAt(graph, binding, cfg) {
|
|
81
82
|
const reads = [];
|
|
82
|
-
for (const [reader, edge] of graph.ingoingEdges(binding) ??
|
|
83
|
+
for (const [reader, edge] of graph.ingoingEdges(binding) ?? graph_1.NoEdges) {
|
|
83
84
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
|
|
84
85
|
reads.push(reader);
|
|
85
86
|
}
|
|
@@ -29,6 +29,8 @@ export interface ProcessKnownFunctionCallInput<OtherInfo> extends ForceArguments
|
|
|
29
29
|
readonly hasUnknownSideEffect?: boolean;
|
|
30
30
|
/** The origin to use for the function being called. */
|
|
31
31
|
readonly origin: FunctionOriginInformation | 'default';
|
|
32
|
+
/** see {@link ProcessAllArgumentInput#nonFunction} */
|
|
33
|
+
readonly nonFunction?: ReadonlySet<NodeId>;
|
|
32
34
|
}
|
|
33
35
|
/** The result of processing a known function call. */
|
|
34
36
|
export interface ProcessKnownFunctionCallResult {
|
|
@@ -84,4 +86,4 @@ export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGrap
|
|
|
84
86
|
* The main processor for function calls for which we know the target but need not
|
|
85
87
|
* add any specific handling.
|
|
86
88
|
*/
|
|
87
|
-
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
|
|
89
|
+
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin, nonFunction }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
|
|
@@ -78,7 +78,10 @@ function markArgument(graph, rootId, arg, kind, evaluated) {
|
|
|
78
78
|
if (evaluated?.has(vtx)) {
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
/* every name in a mask is a candidate column, even one the caller binds: R asks the data first.
|
|
82
|
+
{@link Nse.dropResolvedMask} takes the mark off the bound ones again, and keeps them as the
|
|
83
|
+
names that mean both */
|
|
84
|
+
if (kind === NseKind.Quoted || nse_1.Nse.maskCandidate(info)) {
|
|
82
85
|
graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
@@ -87,12 +90,12 @@ function markArgument(graph, rootId, arg, kind, evaluated) {
|
|
|
87
90
|
* The main processor for function calls for which we know the target but need not
|
|
88
91
|
* add any specific handling.
|
|
89
92
|
*/
|
|
90
|
-
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin }) {
|
|
93
|
+
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin, nonFunction }) {
|
|
91
94
|
const functionName = (0, processor_1.processDataflowFor)(name, data);
|
|
92
95
|
const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
93
96
|
const functionCallName = name.content;
|
|
94
97
|
const processArgs = reverseOrder ? args.toReversed() : args;
|
|
95
|
-
const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({ functionName, args: processArgs, data, finalGraph, functionRootId: rootId, patchData, forceArgs });
|
|
98
|
+
const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({ functionName, args: processArgs, data, finalGraph, functionRootId: rootId, patchData, forceArgs, nonFunction });
|
|
96
99
|
markArgumentsAsNonStandardEvaluation(finalGraph, rootId, processedArguments, markAsNSE, { kind: NseKind.Reevaluated });
|
|
97
100
|
const onlyBuiltin = data.builtInNoEnv === rootId;
|
|
98
101
|
finalGraph.addVertex({
|
|
@@ -6,12 +6,14 @@ const info_1 = require("../../../../info");
|
|
|
6
6
|
const known_call_handling_1 = require("./known-call-handling");
|
|
7
7
|
const append_1 = require("../../../../environments/append");
|
|
8
8
|
const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
9
|
-
const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
|
|
10
|
-
const vertex_1 = require("../../../../graph/vertex");
|
|
11
9
|
const identifier_1 = require("../../../../environments/identifier");
|
|
12
10
|
const r_base_packages_1 = require("../../../../../util/r-base-packages");
|
|
11
|
+
const built_in_1 = require("../../../../environments/built-in");
|
|
13
12
|
const edge_1 = require("../../../../graph/edge");
|
|
14
13
|
const built_in_library_1 = require("./built-in/built-in-library");
|
|
14
|
+
const vertex_1 = require("../../../../graph/vertex");
|
|
15
|
+
const resolve_helper_1 = require("../../../../environments/resolve-helper");
|
|
16
|
+
const assert_1 = require("../../../../../util/assert");
|
|
15
17
|
function mergeInformation(info, newInfo) {
|
|
16
18
|
if (info === undefined) {
|
|
17
19
|
return newInfo;
|
|
@@ -27,12 +29,28 @@ function mergeInformation(info, newInfo) {
|
|
|
27
29
|
hooks: info.hooks.concat(newInfo.hooks)
|
|
28
30
|
};
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The flowR definition of `pkg::fn` behind an export a signature database attached. Such an export binds the
|
|
34
|
+
* name in a layer below the global environment, which hides the built-in environment underneath, and with it
|
|
35
|
+
* how the call evaluates its arguments: without this lookup `library(dplyr); filter(df, id > 2)` loses the data
|
|
36
|
+
* mask of `dplyr::filter`. Only that is recovered here. What a definition merely states about a call (its
|
|
37
|
+
* properties, its signature) reaches every consumer through the export vertex already, so a definition saying
|
|
38
|
+
* nothing about evaluation is left to the default processor, which keeps the call to one target.
|
|
39
|
+
*/
|
|
40
|
+
function builtInBehindExport(data, definition) {
|
|
41
|
+
if (definition.type !== identifier_1.ReferenceType.Function || definition.name === undefined || !node_id_1.NodeId.isBuiltIn(definition.nodeId)
|
|
42
|
+
|| identifier_1.Identifier.getNamespace(definition.name) === undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const known = data.ctx.env.builtInFunctionOf(definition.name);
|
|
46
|
+
return (0, built_in_1.statesNonStandardEvaluation)(known) ? known : undefined;
|
|
47
|
+
}
|
|
30
48
|
/**
|
|
31
49
|
* Marks the given function call node as only calling built-in functions.
|
|
32
50
|
*/
|
|
33
51
|
function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
|
|
34
52
|
const v = graph.getVertex(rootId);
|
|
35
|
-
if (
|
|
53
|
+
if (vertex_1.FunctionCallVertex.is(v)) {
|
|
36
54
|
v.onlyBuiltin = true;
|
|
37
55
|
if (!keepEnvironment) {
|
|
38
56
|
v.environment = undefined;
|
|
@@ -44,7 +62,7 @@ function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
|
|
|
44
62
|
* For example, `myFunction(arg1, arg2)`, resolves against the environment.
|
|
45
63
|
*/
|
|
46
64
|
function processNamedCall(name, args, rootId, data) {
|
|
47
|
-
const resolved =
|
|
65
|
+
const resolved = resolve_helper_1.Resolve.byNameAndType(name.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
|
|
48
66
|
let defaultProcessor = resolved.length === 0;
|
|
49
67
|
/* a call whose meaning a later pass looks up in its environment has to keep it */
|
|
50
68
|
const keepEnvironment = resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.keepEnvironment === true);
|
|
@@ -56,14 +74,23 @@ function processNamedCall(name, args, rootId, data) {
|
|
|
56
74
|
}
|
|
57
75
|
let information = undefined;
|
|
58
76
|
let builtIn = false;
|
|
77
|
+
/* a set, because an export and the built-in behind it are two ways to the same definition */
|
|
78
|
+
const toRun = new Set();
|
|
59
79
|
for (const resolvedFunction of resolved) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
const own = resolvedFunction.type === identifier_1.ReferenceType.BuiltInFunction && typeof resolvedFunction.processor === 'function'
|
|
81
|
+
? resolvedFunction
|
|
82
|
+
/* the call goes through the attached export, so it is not built-in only, but flowR's own
|
|
83
|
+
definition of that export is what knows how to process it */
|
|
84
|
+
: builtInBehindExport(data, resolvedFunction);
|
|
85
|
+
if (own === undefined) {
|
|
65
86
|
defaultProcessor = true;
|
|
87
|
+
continue;
|
|
66
88
|
}
|
|
89
|
+
builtIn ||= own === resolvedFunction && own.config?.libFn !== true;
|
|
90
|
+
toRun.add(own);
|
|
91
|
+
}
|
|
92
|
+
for (const own of toRun) {
|
|
93
|
+
information = mergeInformation(information, own.processor(name, args, rootId, data));
|
|
67
94
|
}
|
|
68
95
|
if (defaultProcessor) {
|
|
69
96
|
/* if we do not know where we land, we force! reuse `resolved`, data.environment did not change above */
|
|
@@ -95,9 +122,14 @@ function processNamedCall(name, args, rootId, data) {
|
|
|
95
122
|
}
|
|
96
123
|
}
|
|
97
124
|
const ns = identifier_1.Identifier.getNamespace(name.content);
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
// a call links to a database-unresolved `library(pkg)` recorded below the global env: `pkg::fn` names
|
|
126
|
+
// its package, a bare call takes it from what flowR resolved it to, which is what ties
|
|
127
|
+
// `filter(df, id > 2)` to the `library(dplyr)` that made it dplyr's
|
|
128
|
+
const owners = ns !== undefined ? [ns] : resolved
|
|
129
|
+
.map(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.name !== undefined ? identifier_1.Identifier.getNamespace(r.name) : undefined)
|
|
130
|
+
.filter(assert_1.isNotUndefined);
|
|
131
|
+
for (const owner of owners) {
|
|
132
|
+
for (const loadNode of (0, built_in_library_1.loadNodesForNamespace)(data.environment, String(owner))) {
|
|
101
133
|
information.graph.addEdge(rootId, loadNode, edge_1.EdgeType.Reads);
|
|
102
134
|
}
|
|
103
135
|
}
|
|
@@ -2,7 +2,7 @@ import { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
|
2
2
|
import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import { Identifier } from '../../../../environments/identifier';
|
|
5
|
-
import type
|
|
5
|
+
import { type DataflowGraph } from '../../../../graph/graph';
|
|
6
6
|
import { type DataflowGraphVertexInfo } from '../../../../graph/vertex';
|
|
7
7
|
/** The escape a quoting function offers, a property of the function: `quote(!!x)` negates, `expr(!!x)` splices. */
|
|
8
8
|
export declare enum Unquote {
|
|
@@ -13,6 +13,14 @@ export declare enum Unquote {
|
|
|
13
13
|
/** `bquote`'s `.(x)` evaluates its operand */
|
|
14
14
|
Bquote = "bquote"
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* A call that hands its arguments a data mask, with the names in that mask the caller binds itself.
|
|
18
|
+
* Those mean the column as much as the binding, so {@link Nse.linkMasksToData} links them to the data too.
|
|
19
|
+
*/
|
|
20
|
+
export interface MaskingCall {
|
|
21
|
+
readonly id: NodeId;
|
|
22
|
+
readonly bound: readonly NodeId[];
|
|
23
|
+
}
|
|
16
24
|
/** The parts of a call R does not evaluate the standard way. */
|
|
17
25
|
export declare const Nse: {
|
|
18
26
|
readonly name: "Nse";
|
|
@@ -20,10 +28,30 @@ export declare const Nse: {
|
|
|
20
28
|
readonly unquoted: <Info extends ParentInformation>(this: void, root: RNode<Info> | undefined, style: Unquote) => ReadonlySet<NodeId> | undefined;
|
|
21
29
|
/** Whether everything below `node` is unquoted. */
|
|
22
30
|
readonly isUnquote: <Info>(this: void, node: RNode<Info>, style: Unquote) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Drops the mask mark from names the caller binds to a value: while `filter(d, k)` is processed `k` has no
|
|
33
|
+
* read yet. A name bound to a function keeps its mark, as `filter(d, id > 2)` next to `id <- function(...)`
|
|
34
|
+
* still means the column. Hands back the masking call and the names it just unmarked, `undefined` when
|
|
35
|
+
* `name` does not mask at all, so {@link linkMasksToData} need not ask a second time.
|
|
36
|
+
*/
|
|
37
|
+
readonly dropResolvedMask: (this: void, graph: DataflowGraph, id: NodeId, name: Identifier) => MaskingCall | undefined;
|
|
38
|
+
/** Drops the non-standard-evaluation mark from the outgoing edges of `id` that `which` accepts, and reports them. */
|
|
39
|
+
readonly unmark: (this: void, graph: DataflowGraph, id: NodeId, which?: (target: NodeId) => boolean) => NodeId[];
|
|
40
|
+
/** Whether the vertex is a name a data mask may supply, which is every name appearing in the mask. */
|
|
41
|
+
readonly maskCandidate: (this: void, vertex: DataflowGraphVertexInfo | undefined) => boolean;
|
|
27
42
|
/** Whether `id` is a name the data mask supplies, i.e. a use the caller does not bind itself. */
|
|
28
43
|
readonly suppliedByMask: (this: void, graph: DataflowGraph, id: NodeId, vertex?: DataflowGraphVertexInfo | undefined) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether `id` is a name a data mask supplied, which the mark the masking call carries is what records.
|
|
46
|
+
* Unlike {@link suppliedByMask} this survives {@link linkMasksToData}, so ask this one after the dataflow
|
|
47
|
+
* is complete and that one while a call is still being processed.
|
|
48
|
+
*/
|
|
49
|
+
readonly maskedName: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Links every name the data masks of `calls` supply to the data it comes from: `id` in `filter(df, id > 2)`
|
|
52
|
+
* is a column of `df`, so it reads `df`. Run once every mark has settled, as adding the read makes
|
|
53
|
+
* {@link suppliedByMask} false for the name; a call whose first argument is masked too has no data to link
|
|
54
|
+
* against.
|
|
55
|
+
*/
|
|
56
|
+
readonly linkMasksToData: (this: void, graph: DataflowGraph, calls: readonly MaskingCall[]) => void;
|
|
29
57
|
};
|