@eagleoutice/flowr 2.15.10 → 2.16.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 +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +176 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +54 -57
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/wiki-setup.js +23 -0
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -21,7 +21,7 @@ interface S7GenericDispatchConfig {
|
|
|
21
21
|
export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S7GenericDispatchConfig): DataflowInformation;
|
|
22
22
|
/**
|
|
23
23
|
* Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
|
|
24
|
-
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`,
|
|
24
|
+
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
|
|
25
25
|
* synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
|
|
26
26
|
* constant.
|
|
27
27
|
*/
|
|
@@ -14,6 +14,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
14
14
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
15
15
|
const assert_1 = require("../../../../../../util/assert");
|
|
16
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
17
18
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
18
19
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
19
20
|
const range_1 = require("../../../../../../util/range");
|
|
@@ -29,16 +30,15 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
29
30
|
logger_1.dataflowLogger.warn('empty s7 new_generic, skipping');
|
|
30
31
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
31
32
|
}
|
|
32
|
-
const
|
|
33
|
+
const { dispatchArg } = config.args;
|
|
34
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
|
|
33
35
|
[config.args.name]: 'name',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
|
|
41
|
-
const genName = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('name')?.[0]));
|
|
36
|
+
...dispatchArg ? { [dispatchArg]: 'dispatchArg' } : {},
|
|
37
|
+
[config.args.fun]: 'fun',
|
|
38
|
+
'...': '...'
|
|
39
|
+
});
|
|
40
|
+
const argNamed = (formal) => (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get(formal)?.[0]));
|
|
41
|
+
const genName = argNamed('name');
|
|
42
42
|
if (!genName) {
|
|
43
43
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
44
44
|
}
|
|
@@ -48,14 +48,12 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
48
48
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
49
49
|
}
|
|
50
50
|
data = { ...data, currentS7name: accessedIdentifiers };
|
|
51
|
-
let funArg = (
|
|
51
|
+
let funArg = argNamed('fun')?.info.id;
|
|
52
52
|
const effectiveArgs = args.slice();
|
|
53
53
|
if (!funArg) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
effectiveArgs.push(newFun[0]);
|
|
58
|
-
funArg = newFun[1];
|
|
54
|
+
const [fun, funId] = makeS7DispatchFDef(name, [argNamed('dispatchArg')?.lexeme], rootId, args.length, data.completeAst.idMap);
|
|
55
|
+
effectiveArgs.push(fun);
|
|
56
|
+
funArg = funId;
|
|
59
57
|
}
|
|
60
58
|
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, sig: function_semantics_1.FunctionSemantics.call.signature.every, args: effectiveArgs, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.S7NewGeneric }).information;
|
|
61
59
|
info.graph.addEdge(rootId, funArg, edge_1.EdgeType.Returns);
|
|
@@ -71,7 +69,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
71
69
|
}
|
|
72
70
|
/**
|
|
73
71
|
* Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
|
|
74
|
-
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`,
|
|
72
|
+
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
|
|
75
73
|
* synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
|
|
76
74
|
* constant.
|
|
77
75
|
*/
|
|
@@ -83,7 +81,8 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
83
81
|
info.entryPoint = funId;
|
|
84
82
|
const fArg = info.graph.getVertex(funId);
|
|
85
83
|
if (vertex_1.DfgVertex.isFunctionDefinition(fArg) && config?.mode) {
|
|
86
|
-
|
|
84
|
+
/* a copy, as the mode is mutated in place later and config.mode is shared */
|
|
85
|
+
fArg.mode ??= config.mode.slice();
|
|
87
86
|
}
|
|
88
87
|
if (config?.wrapIndex !== undefined) {
|
|
89
88
|
linkWrappedFunction(info, args, rootId, config.wrapIndex, config.wrapName, data);
|
|
@@ -94,25 +93,25 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
94
93
|
}
|
|
95
94
|
/** Records on the call vertex what a class-declaring call states, see {@link DataflowGraphVertexFunctionCall.classDecl}. */
|
|
96
95
|
function attachClassDeclaration(info, rootId, args, config) {
|
|
97
|
-
if (config === undefined) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
96
|
const vertex = info.graph.getVertex(rootId);
|
|
101
|
-
if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
97
|
+
if (config !== undefined && vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
102
98
|
vertex.classDecl = function_semantics_1.FunctionSemantics.classes.of(config, args);
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
106
102
|
const wrapped = (0, class_declaration_1.argForImpl)(args, { name: wrapName, idx: wrapIndex });
|
|
107
|
-
|
|
103
|
+
const resolved = wrapped === undefined ? undefined : (0, built_in_apply_1.resolveFunctionArgument)(wrapped, data, {});
|
|
104
|
+
if (resolved === undefined) {
|
|
108
105
|
return;
|
|
109
106
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
const body = rootId + '-s7-new-generic-fun-body';
|
|
108
|
+
/* the wrapper runs what it wraps, so a call of it does what the wrapped function does */
|
|
109
|
+
const targets = resolved.anonymous ? [resolved.functionId] : (resolve_helper_1.Resolve.byNameAndType(resolved.functionName, data.environment, identifier_1.ReferenceType.Function) ?? [])
|
|
110
|
+
.flatMap(d => d.type === identifier_1.ReferenceType.BuiltInFunction ? [d.nodeId] : d.value ?? []);
|
|
111
|
+
for (const target of targets) {
|
|
112
|
+
info.graph.addEdge(body, target, edge_1.EdgeType.Calls);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
if (!vertex_1.DfgVertex.isUse(vertex)) {
|
|
114
|
+
if (resolved.anonymous || !vertex_1.DfgVertex.isUse(info.graph.getVertex(resolved.functionId))) {
|
|
116
115
|
return;
|
|
117
116
|
}
|
|
118
117
|
info.graph.updateToFunctionCall({
|
|
@@ -125,7 +124,7 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
|
125
124
|
cds: data.cds,
|
|
126
125
|
origin: [built_in_proc_name_1.BuiltInProcName.Function]
|
|
127
126
|
});
|
|
128
|
-
info.graph.addEdge(
|
|
127
|
+
info.graph.addEdge(body, resolved.functionId, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
129
128
|
}
|
|
130
129
|
/**
|
|
131
130
|
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
@@ -133,41 +132,17 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
|
133
132
|
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
134
133
|
*/
|
|
135
134
|
exports.S7SyntheticFunArgSuffix = '-s7-new-generic-fun-arg';
|
|
136
|
-
|
|
135
|
+
/** Synthesizes the argument `fun = function([dispatch_args], ...) S7_dispatch()`, returning it and the id of its value. */
|
|
137
136
|
function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
138
|
-
const argNameId = rootId + '-s7-new-generic-fun-arg-name';
|
|
139
137
|
const r = name.location ?? range_1.SourceRange.invalid();
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
info: {
|
|
145
|
-
id: argNameId,
|
|
146
|
-
nest: name.info.nest,
|
|
147
|
-
role: "arg-n" /* RoleInParent.ArgumentName */,
|
|
148
|
-
fullRange: r,
|
|
149
|
-
adToks: undefined,
|
|
150
|
-
file: name.info.file,
|
|
151
|
-
parent: rootId,
|
|
152
|
-
index: 0
|
|
153
|
-
},
|
|
154
|
-
location: r,
|
|
155
|
-
};
|
|
156
|
-
idMap.set(argNameId, argName);
|
|
157
|
-
const funcNameId = rootId + '-s7-new-generic-fun-name';
|
|
138
|
+
const info = (id, role, parent, index = 0) => ({ id, nest: name.info.nest, role, fullRange: r, adToks: undefined, file: name.info.file, parent, index });
|
|
139
|
+
const symbol = (id, lexeme, role, parent, index = 0) => ({ type: type_1.RType.Symbol, lexeme, content: lexeme, info: info(id, role, parent, index), location: r });
|
|
140
|
+
const argName = symbol(rootId + '-s7-new-generic-fun-arg-name', 'fun', "arg-n" /* RoleInParent.ArgumentName */, rootId);
|
|
141
|
+
idMap.set(argName.info.id, argName);
|
|
158
142
|
const funcName = {
|
|
159
143
|
type: type_1.RType.Symbol,
|
|
160
144
|
lexeme: 'S7_dispatch',
|
|
161
|
-
info:
|
|
162
|
-
id: funcNameId,
|
|
163
|
-
nest: name.info.nest,
|
|
164
|
-
role: "call-name" /* RoleInParent.FunctionCallName */,
|
|
165
|
-
fullRange: r,
|
|
166
|
-
adToks: undefined,
|
|
167
|
-
file: name.info.file,
|
|
168
|
-
parent: rootId,
|
|
169
|
-
index: 0
|
|
170
|
-
},
|
|
145
|
+
info: info(rootId + '-s7-new-generic-fun-name', "call-name" /* RoleInParent.FunctionCallName */, rootId),
|
|
171
146
|
location: r,
|
|
172
147
|
content: identifier_1.Identifier.make('S7_dispatch', 'S7'),
|
|
173
148
|
};
|
|
@@ -178,51 +153,17 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
178
153
|
named: true,
|
|
179
154
|
functionName: funcName,
|
|
180
155
|
arguments: [],
|
|
181
|
-
info:
|
|
182
|
-
id: rootId + '-s7-new-generic-fun-body',
|
|
183
|
-
nest: name.info.nest,
|
|
184
|
-
role: "fun-b" /* RoleInParent.FunctionDefinitionBody */,
|
|
185
|
-
fullRange: r,
|
|
186
|
-
adToks: undefined,
|
|
187
|
-
file: name.info.file,
|
|
188
|
-
parent: rootId,
|
|
189
|
-
index: 0
|
|
190
|
-
}
|
|
156
|
+
info: info(rootId + '-s7-new-generic-fun-body', "fun-b" /* RoleInParent.FunctionDefinitionBody */, rootId)
|
|
191
157
|
};
|
|
192
158
|
const fdefId = rootId + '-s7-new-generic-fun-fdef';
|
|
193
159
|
const argValue = {
|
|
194
160
|
type: type_1.RType.FunctionDefinition,
|
|
195
|
-
info:
|
|
196
|
-
file: name.info.file,
|
|
197
|
-
id: fdefId,
|
|
198
|
-
nest: name.info.nest,
|
|
199
|
-
role: "arg-v" /* RoleInParent.ArgumentValue */,
|
|
200
|
-
parent: rootId,
|
|
201
|
-
index: args + 1,
|
|
202
|
-
adToks: undefined,
|
|
203
|
-
fullRange: r,
|
|
204
|
-
},
|
|
161
|
+
info: info(fdefId, "arg-v" /* RoleInParent.ArgumentValue */, rootId, args + 1),
|
|
205
162
|
lexeme: 'function',
|
|
206
163
|
location: r,
|
|
207
164
|
parameters: [...names.filter(assert_1.isNotUndefined), '...'].map((n, i) => {
|
|
208
165
|
const paramId = fdefId + `-param-${i}`;
|
|
209
|
-
const
|
|
210
|
-
const paramName = {
|
|
211
|
-
type: type_1.RType.Symbol,
|
|
212
|
-
lexeme: n,
|
|
213
|
-
content: n,
|
|
214
|
-
info: {
|
|
215
|
-
id: paramNameId,
|
|
216
|
-
nest: name.info.nest,
|
|
217
|
-
role: "param-n" /* RoleInParent.ParameterName */,
|
|
218
|
-
fullRange: r,
|
|
219
|
-
adToks: undefined,
|
|
220
|
-
file: name.info.file,
|
|
221
|
-
index: i,
|
|
222
|
-
parent: paramId
|
|
223
|
-
},
|
|
224
|
-
location: r,
|
|
225
|
-
};
|
|
166
|
+
const paramName = symbol(paramId + '-name', n, "param-n" /* RoleInParent.ParameterName */, paramId, i);
|
|
226
167
|
const param = {
|
|
227
168
|
type: type_1.RType.Parameter,
|
|
228
169
|
location: r,
|
|
@@ -230,41 +171,22 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
230
171
|
name: paramName,
|
|
231
172
|
defaultValue: undefined,
|
|
232
173
|
special: n === '...',
|
|
233
|
-
info:
|
|
234
|
-
id: paramId,
|
|
235
|
-
nest: name.info.nest,
|
|
236
|
-
role: "param" /* RoleInParent.FunctionDefinitionParameter */,
|
|
237
|
-
parent: fdefId,
|
|
238
|
-
index: i,
|
|
239
|
-
adToks: undefined,
|
|
240
|
-
file: name.info.file,
|
|
241
|
-
fullRange: r,
|
|
242
|
-
}
|
|
174
|
+
info: info(paramId, "param" /* RoleInParent.FunctionDefinitionParameter */, fdefId, i)
|
|
243
175
|
};
|
|
244
|
-
idMap.set(
|
|
176
|
+
idMap.set(paramName.info.id, paramName);
|
|
245
177
|
idMap.set(paramId, param);
|
|
246
178
|
return param;
|
|
247
179
|
}),
|
|
248
180
|
body: funcBody,
|
|
249
181
|
};
|
|
250
|
-
idMap.set(
|
|
182
|
+
idMap.set(funcName.info.id, funcName);
|
|
251
183
|
idMap.set(funcBody.info.id, funcBody);
|
|
252
184
|
idMap.set(fdefId, argValue);
|
|
253
|
-
const argId = rootId + exports.S7SyntheticFunArgSuffix;
|
|
254
185
|
const argument = {
|
|
255
186
|
type: type_1.RType.Argument,
|
|
256
187
|
lexeme: 'fun',
|
|
257
188
|
location: r,
|
|
258
|
-
info:
|
|
259
|
-
id: argId,
|
|
260
|
-
nest: name.info.nest,
|
|
261
|
-
role: "call-arg" /* RoleInParent.FunctionCallArgument */,
|
|
262
|
-
fullRange: r,
|
|
263
|
-
adToks: undefined,
|
|
264
|
-
file: name.info.file,
|
|
265
|
-
parent: rootId,
|
|
266
|
-
index: args + 1
|
|
267
|
-
},
|
|
189
|
+
info: info(rootId + exports.S7SyntheticFunArgSuffix, "call-arg" /* RoleInParent.FunctionCallArgument */, rootId, args + 1),
|
|
268
190
|
name: argName,
|
|
269
191
|
value: argValue
|
|
270
192
|
};
|
|
@@ -13,8 +13,6 @@ interface S3DispatchConfig {
|
|
|
13
13
|
/** For NextMethod/if `generic` is not given, try to infer from the closure? */
|
|
14
14
|
inferFromClosure?: boolean;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Process an S3 dispatch call like `UseMethod`.
|
|
18
|
-
*/
|
|
16
|
+
/** Process an S3 dispatch call like `UseMethod`. */
|
|
19
17
|
export declare function processS3Dispatch<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S3DispatchConfig): DataflowInformation;
|
|
20
18
|
export {};
|
|
@@ -9,6 +9,7 @@ const logger_1 = require("../../../../../logger");
|
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
11
11
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
12
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
12
13
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
14
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
14
15
|
const range_1 = require("../../../../../../util/range");
|
|
@@ -17,27 +18,25 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
17
18
|
const control_flow_1 = require("../../../../control-flow");
|
|
18
19
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
19
20
|
const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
20
|
-
/**
|
|
21
|
-
* Process an S3 dispatch call like `UseMethod`.
|
|
22
|
-
*/
|
|
21
|
+
/** Process an S3 dispatch call like `UseMethod`. */
|
|
23
22
|
function processS3Dispatch(name, args, rootId, data, config) {
|
|
24
23
|
if (args.length === 0 && !config.inferFromClosure) {
|
|
25
24
|
logger_1.dataflowLogger.warn('empty s3, skipping');
|
|
26
25
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
27
26
|
}
|
|
28
|
-
const
|
|
27
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
|
|
29
28
|
[config.args.generic]: 'generic',
|
|
30
29
|
[config.args.object]: 'object',
|
|
31
30
|
'...': '...'
|
|
32
|
-
};
|
|
33
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
|
|
31
|
+
});
|
|
34
32
|
const generic = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('generic')?.[0]));
|
|
35
33
|
if (!generic && !config.inferFromClosure) {
|
|
36
34
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
37
35
|
}
|
|
38
36
|
const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
|
|
39
37
|
const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : info_1.DataflowInformation.initialize(rootId, data);
|
|
40
|
-
|
|
38
|
+
const fnRef = { nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function };
|
|
39
|
+
if (control_flow_1.ControlFlow.alwaysExits(dfObj, data.cds)) {
|
|
41
40
|
(0, common_1.patchFunctionCall)({
|
|
42
41
|
nextGraph: dfObj.graph,
|
|
43
42
|
rootId,
|
|
@@ -57,24 +56,20 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
57
56
|
argumentProcessResult: [dfObj],
|
|
58
57
|
origin: built_in_proc_name_1.BuiltInProcName.S3DispatchNext
|
|
59
58
|
});
|
|
60
|
-
const ingoing = dfObj.in.concat(dfObj.unknownReferences);
|
|
61
|
-
ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
|
|
62
59
|
/* the next method receives the current values of the formals of the method it is called from */
|
|
63
60
|
const idMap = data.completeAst.idMap;
|
|
64
61
|
const enclosing = idMap.get(model_1.RNode.findEnclosing(rootId, idMap, r_function_definition_1.RFunctionDefinition.is) ?? rootId);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
const cfgEntry = control_flow_1.ControlFlow.inSequence(dfObj.graph, [dfObj], rootId);
|
|
62
|
+
const formals = r_function_definition_1.RFunctionDefinition.is(enclosing) ? enclosing.parameters : [];
|
|
63
|
+
const formalReads = formals.map(param => ({ nodeId: rootId, name: param.name.content, cds: data.cds, type: identifier_1.ReferenceType.Variable }));
|
|
69
64
|
return {
|
|
70
65
|
hooks: dfObj.hooks,
|
|
71
66
|
environment: dfObj.environment,
|
|
72
67
|
exitPoints: dfObj.exitPoints,
|
|
73
68
|
graph: dfObj.graph,
|
|
74
69
|
entryPoint: rootId,
|
|
75
|
-
cfgEntry,
|
|
70
|
+
cfgEntry: control_flow_1.ControlFlow.inSequence(dfObj.graph, [dfObj], rootId),
|
|
76
71
|
cfgExit: rootId,
|
|
77
|
-
in:
|
|
72
|
+
in: [...dfObj.in, ...dfObj.unknownReferences, fnRef, ...formalReads],
|
|
78
73
|
out: dfObj.out,
|
|
79
74
|
unknownReferences: []
|
|
80
75
|
};
|
|
@@ -108,22 +103,19 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
108
103
|
argumentProcessResult: [dfGeneric, dfObj],
|
|
109
104
|
origin: built_in_proc_name_1.BuiltInProcName.Function
|
|
110
105
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
for (const id of accessedIdentifiers) {
|
|
114
|
-
ingoing.push({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix });
|
|
115
|
-
}
|
|
106
|
+
/* the method runs only as the dispatch does */
|
|
107
|
+
dfGeneric.graph.addEdge(generic.info.id, rootId, edge_1.EdgeType.Reads);
|
|
116
108
|
const graph = dfObj.graph.mergeWith(dfGeneric.graph);
|
|
117
|
-
const
|
|
109
|
+
const methodPrefixes = accessedIdentifiers.map(id => ({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix }));
|
|
118
110
|
return {
|
|
119
|
-
hooks: dfGeneric.hooks.concat(dfObj
|
|
111
|
+
hooks: dfGeneric.hooks.concat(dfObj.hooks),
|
|
120
112
|
environment: dfGeneric.environment,
|
|
121
113
|
exitPoints: dfObj.exitPoints.concat(dfGeneric.exitPoints),
|
|
122
114
|
graph,
|
|
123
115
|
entryPoint: rootId,
|
|
124
|
-
cfgEntry,
|
|
116
|
+
cfgEntry: control_flow_1.ControlFlow.inSequence(graph, [dfGeneric, dfObj], rootId),
|
|
125
117
|
cfgExit: rootId,
|
|
126
|
-
in:
|
|
118
|
+
in: [...dfObj.in, ...dfGeneric.in, ...dfObj.unknownReferences, ...dfGeneric.unknownReferences, fnRef, ...methodPrefixes],
|
|
127
119
|
out: dfGeneric.out.concat(dfObj.out),
|
|
128
120
|
unknownReferences: []
|
|
129
121
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AmbientStateAccess } from './built-in-ambient-state';
|
|
1
2
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
2
3
|
import { DataflowInformation } from '../../../../../info';
|
|
3
4
|
import { type FlowrLaxSourcingOptions, InferWorkingDirectory } from '../../../../../../config';
|
|
@@ -40,6 +41,7 @@ export declare function processSourceCall<OtherInfo>(name: RSymbol<OtherInfo & P
|
|
|
40
41
|
includeFunctionCall?: boolean;
|
|
41
42
|
/** should this function call be followed, even when the configuration disables it? */
|
|
42
43
|
forceFollow?: boolean;
|
|
44
|
+
ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
43
45
|
}): DataflowInformation;
|
|
44
46
|
/**
|
|
45
47
|
* Processes a source request with the given dataflow processor information and existing dataflow information
|