@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
|
@@ -12,22 +12,26 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
12
12
|
const log_1 = require("../../../../../../util/log");
|
|
13
13
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
14
14
|
const make_argument_1 = require("../argument/make-argument");
|
|
15
|
+
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
15
16
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
16
17
|
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
17
18
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
18
19
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
19
20
|
const logger_1 = require("../../../../../logger");
|
|
20
21
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
22
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
21
23
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
22
24
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
23
25
|
const retriever_1 = require("../../../../../../r-bridge/retriever");
|
|
24
26
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
25
|
-
const linker_1 = require("../../../../linker");
|
|
26
27
|
const define_1 = require("../../../../../environments/define");
|
|
27
28
|
const edge_1 = require("../../../../../graph/edge");
|
|
28
29
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
29
30
|
const named_call_handling_1 = require("../named-call-handling");
|
|
30
31
|
const built_in_1 = require("../../../../../environments/built-in");
|
|
32
|
+
const built_in_props_1 = require("../../../../../environments/built-in-props");
|
|
33
|
+
const arg_matching_1 = require("../../../../../../util/arg-matching");
|
|
34
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
31
35
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
32
36
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
33
37
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
@@ -49,15 +53,8 @@ function toReplacementSymbol(target, prefix, superAssignment) {
|
|
|
49
53
|
function getEffectiveOrder(config, args) {
|
|
50
54
|
return config.swapSourceAndTarget ? [args[1], args[0]] : args;
|
|
51
55
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
while (r_access_1.RAccess.is(current)) {
|
|
55
|
-
current = current.accessed;
|
|
56
|
-
}
|
|
57
|
-
if (r_symbol_1.RSymbol.is(current)) {
|
|
58
|
-
return current;
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
56
|
+
function originOf(config) {
|
|
57
|
+
return config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment;
|
|
61
58
|
}
|
|
62
59
|
const EnvironmentProducers = [built_in_proc_name_1.BuiltInProcName.NewEnv, built_in_proc_name_1.BuiltInProcName.StackEnv, built_in_proc_name_1.BuiltInProcName.ListToEnv];
|
|
63
60
|
function yieldsEnvironment(node, graph, data) {
|
|
@@ -75,23 +72,12 @@ function tryReplacement(rootId, functionName, data, superAssignment, args, befor
|
|
|
75
72
|
/* every replacement function rebinds its target, no matter whether we ship a built-in for it or the user wrote
|
|
76
73
|
* it; a user-defined one is only ever bound under its `<-` name, the `<<-` form stays in the configuration */
|
|
77
74
|
const name = builtIn ? functionName.content : identifier_1.Identifier.mapName(functionName.content, n => superAssignment ? n.slice(0, -'<<-'.length) + '<-' : n);
|
|
78
|
-
const
|
|
79
|
-
type: type_1.RType.Symbol,
|
|
80
|
-
info: functionName.info,
|
|
81
|
-
content: name,
|
|
82
|
-
lexeme: functionName.lexeme,
|
|
83
|
-
location: functionName.location
|
|
84
|
-
}, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), functionName.info.id, data, builtIn ? {
|
|
85
|
-
...builtIn.config,
|
|
86
|
-
assignRootId: rootId,
|
|
87
|
-
beforeDefine
|
|
88
|
-
} : {
|
|
75
|
+
const replacementConfig = builtIn ? builtIn.config : {
|
|
89
76
|
readIndices: true,
|
|
90
77
|
makeMaybe: true,
|
|
91
|
-
assignmentOperator: superAssignment ? '<<-' : '<-'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
78
|
+
assignmentOperator: superAssignment ? '<<-' : '<-'
|
|
79
|
+
};
|
|
80
|
+
const info = built_in_1.BuiltInProcessorMapper[built_in_proc_name_1.BuiltInProcName.Replacement]({ ...functionName, content: name }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), functionName.info.id, data, { ...replacementConfig, assignRootId: rootId, beforeDefine });
|
|
95
81
|
if (builtIn) {
|
|
96
82
|
(0, named_call_handling_1.markAsOnlyBuiltIn)(info.graph, functionName.info.id);
|
|
97
83
|
return info;
|
|
@@ -120,27 +106,16 @@ args, rootId, data, config) {
|
|
|
120
106
|
}
|
|
121
107
|
const source = argsWithNames.get(config.source.name) ?? (config.source.idx === undefined ? undefined : argsWithoutNames[config.source.idx]);
|
|
122
108
|
const target = argsWithNames.get(config.target.name) ?? (config.target.idx === undefined ? undefined : argsWithoutNames[config.target.idx]);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
return processAssignment(name, args, rootId, data, { ...config, mayHaveMoreArgs: true });
|
|
109
|
+
const normalizedArgs = source && target ? [target, source] : args;
|
|
110
|
+
return processAssignment(name, normalizedArgs, rootId, data, { ...config, mayHaveMoreArgs: true });
|
|
127
111
|
}
|
|
128
112
|
/** Within a data-masking call `a := b` is rlang's name-value pair, not data.table's assignment. */
|
|
129
113
|
function isMaskedNamePair(name, rootId, data) {
|
|
130
114
|
if (identifier_1.Identifier.getName(name.content) !== ':=') {
|
|
131
115
|
return false;
|
|
132
116
|
}
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
while (parent !== undefined) {
|
|
136
|
-
const node = idMap.get(parent);
|
|
137
|
-
if (node === undefined) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
else if (r_argument_1.RArgument.is(node)) {
|
|
141
|
-
parent = node.info.parent;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
117
|
+
for (const node of model_1.RNode.iterateParents(data.completeAst.idMap.get(rootId), data.completeAst.idMap)) {
|
|
118
|
+
if (!r_argument_1.RArgument.is(node)) {
|
|
144
119
|
return r_function_call_1.RFunctionCall.isNamed(node) && data_masking_functions_1.DataMaskingFunctionNames.has(identifier_1.Identifier.getName(node.functionName.content));
|
|
145
120
|
}
|
|
146
121
|
}
|
|
@@ -164,20 +139,15 @@ function processAssignment(name,
|
|
|
164
139
|
/* we expect them to be ordered in the sense that we have (source, target): `<source> <- <target>` */
|
|
165
140
|
args, rootId, data, config) {
|
|
166
141
|
const information = processAssignmentTarget(name, args, rootId, data, config);
|
|
167
|
-
|
|
168
|
-
linkSourceAsCalled(args, rootId, data, config, information);
|
|
169
|
-
}
|
|
170
|
-
return information;
|
|
171
|
-
}
|
|
172
|
-
function linkSourceAsCalled(args, rootId, data, config, information) {
|
|
173
|
-
const source = (0, unpack_argument_1.unpackArg)(args[config.swapSourceAndTarget ? 0 : 1]);
|
|
142
|
+
const source = config.callsSource ? (0, unpack_argument_1.unpackArg)(args[config.swapSourceAndTarget ? 0 : 1]) : undefined;
|
|
174
143
|
const vertex = source ? information.graph.getVertex(source.info.id) : undefined;
|
|
175
|
-
|
|
176
|
-
|
|
144
|
+
/* the function runs when the name is read, so what it reads is resolved there and not where it is bound */
|
|
145
|
+
if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
177
146
|
for (const written of information.out) {
|
|
178
147
|
information.graph.addEdge(written.nodeId, vertex.id, edge_1.EdgeType.Calls);
|
|
179
148
|
}
|
|
180
149
|
}
|
|
150
|
+
return information;
|
|
181
151
|
}
|
|
182
152
|
function processAssignmentTarget(name, args, rootId, data, config) {
|
|
183
153
|
if (isMaskedNamePair(name, rootId, data)) {
|
|
@@ -202,27 +172,31 @@ function processAssignmentTarget(name, args, rootId, data, config) {
|
|
|
202
172
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
203
173
|
}
|
|
204
174
|
const { type, named } = target;
|
|
205
|
-
/** the
|
|
206
|
-
const
|
|
175
|
+
/** the call (with `callArgs`) defines the plain name at `targetId` (with `targetName` set whenever the name had to be resolved first) */
|
|
176
|
+
const toSymbol = (callArgs, targetId, targetName) => {
|
|
207
177
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
208
178
|
name,
|
|
209
|
-
args,
|
|
179
|
+
args: callArgs,
|
|
210
180
|
rootId,
|
|
211
181
|
data,
|
|
212
182
|
reverseOrder: !config.swapSourceAndTarget,
|
|
213
|
-
origin: config
|
|
183
|
+
origin: originOf(config)
|
|
214
184
|
});
|
|
215
|
-
|
|
185
|
+
return processAssignmentToSymbol({
|
|
216
186
|
...config,
|
|
217
187
|
nameOfAssignmentFunction: name.content,
|
|
218
188
|
source,
|
|
219
|
-
targetId
|
|
189
|
+
targetId,
|
|
220
190
|
targetName,
|
|
221
191
|
args: getEffectiveOrder(config, res.processedArguments),
|
|
222
192
|
rootId,
|
|
223
193
|
data,
|
|
224
194
|
information: res.information,
|
|
225
195
|
});
|
|
196
|
+
};
|
|
197
|
+
/** the target is a plain name, so the assignment defines it directly */
|
|
198
|
+
const assignToSymbol = (targetName) => {
|
|
199
|
+
const info = toSymbol(args, target.info.id, targetName);
|
|
226
200
|
if (config.readTarget && r_symbol_1.RSymbol.is(target)) {
|
|
227
201
|
/* just like a replacement function, the call works on the old value of its target */
|
|
228
202
|
info.graph.addEdge(target.info.id, rootId, edge_1.EdgeType.Reads);
|
|
@@ -234,7 +208,8 @@ function processAssignmentTarget(name, args, rootId, data, config) {
|
|
|
234
208
|
return assignToSymbol();
|
|
235
209
|
}
|
|
236
210
|
else if (config.targetVariable && (type === type_1.RType.Symbol || type === type_1.RType.FunctionCall)) {
|
|
237
|
-
|
|
211
|
+
/* the target expression (`assign(x, v)` / `assign(paste0("cfg_", k), v)`) resolving to a constant name defines that name, keeping
|
|
212
|
+
* the reads that produced it; a dynamic name falls through to the unknown-target handling below */
|
|
238
213
|
const resolvedName = (0, built_in_envir_utils_1.resolveConstantString)(target, data);
|
|
239
214
|
if (resolvedName !== undefined) {
|
|
240
215
|
return assignToSymbol(resolvedName);
|
|
@@ -260,88 +235,42 @@ function processAssignmentTarget(name, args, rootId, data, config) {
|
|
|
260
235
|
return replaced;
|
|
261
236
|
}
|
|
262
237
|
else if (type === type_1.RType.Access) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
data,
|
|
270
|
-
reverseOrder: !config.swapSourceAndTarget,
|
|
271
|
-
origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
|
|
272
|
-
});
|
|
273
|
-
return processAssignmentToSymbol({
|
|
274
|
-
...config,
|
|
275
|
-
nameOfAssignmentFunction: name.content,
|
|
276
|
-
source,
|
|
277
|
-
targetId: rootArg.info.id,
|
|
278
|
-
args: getEffectiveOrder(config, res.processedArguments),
|
|
279
|
-
rootId,
|
|
280
|
-
data,
|
|
281
|
-
information: res.information,
|
|
282
|
-
});
|
|
238
|
+
let rootArg = target;
|
|
239
|
+
while (r_access_1.RAccess.is(rootArg)) {
|
|
240
|
+
rootArg = rootArg.accessed;
|
|
241
|
+
}
|
|
242
|
+
if (r_symbol_1.RSymbol.is(rootArg)) {
|
|
243
|
+
return toSymbol([rootArg, source], rootArg.info.id);
|
|
283
244
|
}
|
|
284
245
|
}
|
|
285
246
|
else if (type === type_1.RType.String) {
|
|
286
|
-
|
|
247
|
+
const symbol = {
|
|
248
|
+
type: type_1.RType.Symbol,
|
|
249
|
+
info: target.info,
|
|
250
|
+
content: (0, retriever_1.removeRQuotes)(target.lexeme) + (config.targetSuffix ?? ''),
|
|
251
|
+
lexeme: target.lexeme,
|
|
252
|
+
location: target.location,
|
|
253
|
+
};
|
|
254
|
+
/* treat the target argument as a symbol; keep extra args (e.g. envir=) so they get graph vertices */
|
|
255
|
+
const targetIdx = config.swapSourceAndTarget ? 1 : 0;
|
|
256
|
+
const mappedArgs = args.map((a, i) => i === targetIdx ? { ...a, value: symbol } : a);
|
|
257
|
+
return toSymbol(mappedArgs, symbol.info.id);
|
|
287
258
|
}
|
|
288
259
|
logger_1.dataflowLogger.warn(`Assignment ${identifier_1.Identifier.toString(name.content)} has an unknown target type ${target.type} => unknown impact`);
|
|
289
|
-
const info = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
290
|
-
name, args: effectiveArgs, rootId, data,
|
|
291
|
-
origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
|
|
292
|
-
}).information;
|
|
260
|
+
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args: effectiveArgs, rootId, data, origin: originOf(config) }).information;
|
|
293
261
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
|
|
294
262
|
return info;
|
|
295
263
|
}
|
|
296
264
|
/** Promotes the ingoing/unknown references of target (an assignment) to definitions. */
|
|
297
265
|
function produceWrittenNodes(rootId, target, referenceType, data, makeMaybe, value) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
cds: data.cds ?? (makeMaybe ? [] : undefined),
|
|
307
|
-
value
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return written;
|
|
312
|
-
}
|
|
313
|
-
function processAssignmentToString(target, args, name, rootId, data, config, source) {
|
|
314
|
-
const symbol = {
|
|
315
|
-
type: type_1.RType.Symbol,
|
|
316
|
-
info: target.info,
|
|
317
|
-
content: (0, retriever_1.removeRQuotes)(target.lexeme) + (config.targetSuffix ?? ''),
|
|
318
|
-
lexeme: target.lexeme,
|
|
319
|
-
location: target.location,
|
|
320
|
-
};
|
|
321
|
-
// treat first argument to Symbol; include extra args (e.g. envir=) so they get graph vertices
|
|
322
|
-
const extraArgs = config.mayHaveMoreArgs ? Array.from(args).slice(2) : [];
|
|
323
|
-
const mappedArgs = config.swapSourceAndTarget ? [args[0], {
|
|
324
|
-
...args[1],
|
|
325
|
-
value: symbol
|
|
326
|
-
}, ...extraArgs] : [{ ...args[0], value: symbol }, args[1], ...extraArgs];
|
|
327
|
-
const res = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
328
|
-
name,
|
|
329
|
-
args: mappedArgs,
|
|
330
|
-
rootId,
|
|
331
|
-
data,
|
|
332
|
-
reverseOrder: !config.swapSourceAndTarget,
|
|
333
|
-
origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
|
|
334
|
-
});
|
|
335
|
-
return processAssignmentToSymbol({
|
|
336
|
-
...config,
|
|
337
|
-
nameOfAssignmentFunction: name.content,
|
|
338
|
-
source,
|
|
339
|
-
targetId: symbol.info.id,
|
|
340
|
-
args: getEffectiveOrder(config, res.processedArguments),
|
|
341
|
-
rootId,
|
|
342
|
-
data,
|
|
343
|
-
information: res.information
|
|
344
|
-
});
|
|
266
|
+
return [...target.in, ...target.unknownReferences].filter(ref => !built_in_ambient_state_1.AmbientStateName.is(ref.name)).map(ref => ({
|
|
267
|
+
nodeId: ref.nodeId,
|
|
268
|
+
name: ref.name,
|
|
269
|
+
type: referenceType,
|
|
270
|
+
definedAt: rootId,
|
|
271
|
+
cds: data.cds ?? (makeMaybe ? [] : undefined),
|
|
272
|
+
value
|
|
273
|
+
}));
|
|
345
274
|
}
|
|
346
275
|
function checkTargetReferenceType(sourceInfo, fnModes) {
|
|
347
276
|
const vert = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
|
|
@@ -410,9 +339,8 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
|
|
|
410
339
|
}
|
|
411
340
|
const fieldName = (r_string_1.RString.is(fieldNode) ? fieldNode.content.str : fieldNode.lexeme);
|
|
412
341
|
const normalResult = tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source], config.beforeDefine);
|
|
413
|
-
const isFunction = (0, built_in_list_1.holdsFunction)(source, data.environment);
|
|
414
342
|
const fieldDef = {
|
|
415
|
-
type:
|
|
343
|
+
type: (0, built_in_list_1.holdsFunction)(source, data.environment) ? identifier_1.ReferenceType.Function : identifier_1.ReferenceType.Variable,
|
|
416
344
|
name: fieldName,
|
|
417
345
|
nodeId: source.info.id,
|
|
418
346
|
definedAt: normalResult.entryPoint,
|
|
@@ -431,7 +359,10 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
|
|
|
431
359
|
};
|
|
432
360
|
normalResult.graph.addEdge(normalResult.entryPoint, target.accessed.info.id, edge_1.EdgeType.Reads);
|
|
433
361
|
const environment = (0, define_1.define)(updatedEnvDef, false, strippedEnv);
|
|
434
|
-
|
|
362
|
+
if (updatedEnvDef.envId === undefined) {
|
|
363
|
+
return { ...normalResult, environment };
|
|
364
|
+
}
|
|
365
|
+
return { ...normalResult, environment: (0, built_in_envir_utils_1.rebindHolders)(environment, updatedEnvDef, newEnvState, rootId) };
|
|
435
366
|
}
|
|
436
367
|
/**
|
|
437
368
|
* When `config.environmentArg` (e.g. `'envir'` for `assign`) resolves to a variable with a tracked
|
|
@@ -443,25 +374,25 @@ function tryRouteToCustomEnv(name, args, rootId, data, config) {
|
|
|
443
374
|
const envirRouting = (0, built_in_envir_utils_1.resolveEnvirArgOrAmbiguous)(args, data, config.sig, config.environmentArg)
|
|
444
375
|
?? (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, built_in_envir_utils_1.EnvirPositionFormals);
|
|
445
376
|
if (envirRouting === 'ambiguous' || (!envirRouting && (0, built_in_envir_utils_1.suppliesArg)(args, config.sig, built_in_envir_utils_1.EnvirPositionFormals))) {
|
|
446
|
-
const info = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
447
|
-
name, args, rootId, data,
|
|
448
|
-
origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
|
|
449
|
-
}).information;
|
|
377
|
+
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: originOf(config) }).information;
|
|
450
378
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
|
|
451
379
|
return info;
|
|
452
380
|
}
|
|
453
381
|
if (!envirRouting) {
|
|
454
|
-
|
|
382
|
+
if (!data.ctx.config.solver.trackEnvironments || config.environmentArg === undefined || !(0, built_in_envir_utils_1.suppliesArg)(args, config.sig, [config.environmentArg])) {
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
/* an environment we cannot name (`sys.frame(-1)`) may be any frame, so the write stays here and is kept as well */
|
|
386
|
+
const info = processAssignment(name, args, rootId, data, { ...config, environmentArg: undefined });
|
|
387
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
|
|
388
|
+
return info;
|
|
455
389
|
}
|
|
456
390
|
/* run the normal assignment path to get the correct graph structure, the call reads the environment it writes into */
|
|
457
391
|
const global = envirRouting.stack === 'global';
|
|
458
392
|
const normalResult = processAssignment(name, args, rootId, data, { ...config, environmentArg: undefined, superAssignment: global || config.superAssignment });
|
|
459
393
|
normalResult.graph.addEdge(rootId, envirRouting.envirNodeId, edge_1.EdgeType.Reads);
|
|
460
|
-
if (global) {
|
|
461
|
-
return normalResult;
|
|
462
|
-
}
|
|
463
394
|
/* pass rootId as definedAt so only defs made at this call site are routed */
|
|
464
|
-
return (0, built_in_envir_utils_1.routeWrittenToEnvir)(normalResult, envirRouting, rootId, data.environment, rootId);
|
|
395
|
+
return global ? normalResult : (0, built_in_envir_utils_1.routeWrittenToEnvir)(normalResult, envirRouting, rootId, data.environment, rootId);
|
|
465
396
|
}
|
|
466
397
|
/**
|
|
467
398
|
* Models a call like `Hmisc::getHdata(x)` that loads a dataset into the variable it is *given*: `x` is both
|
|
@@ -470,12 +401,34 @@ function tryRouteToCustomEnv(name, args, rootId, data, config) {
|
|
|
470
401
|
function processDefineArgument(name, args, rootId, data, config) {
|
|
471
402
|
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.DefineArgument });
|
|
472
403
|
const info = res.information;
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
404
|
+
const formals = config.sig ?? [];
|
|
405
|
+
const bound = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => r_argument_1.RArgument.isEmpty(a) ? undefined : a.name?.content), formals.map(([f]) => f));
|
|
406
|
+
const defineByCall = (node) => {
|
|
407
|
+
info.environment = (0, define_1.define)(node, config.superAssignment, info.environment);
|
|
408
|
+
/* defined by the call; the read edge is left intact */
|
|
409
|
+
if (node.nodeId !== rootId) {
|
|
477
410
|
info.graph.setDefinitionOfVertex(node, [rootId]);
|
|
478
|
-
info.graph.addEdge(node.nodeId, rootId, edge_1.EdgeType.DefinedBy);
|
|
411
|
+
info.graph.addEdge(node.nodeId, rootId, edge_1.EdgeType.DefinedBy);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
for (let i = 0; i < args.length; i++) {
|
|
415
|
+
const arg = args[i], targetArg = res.processedArguments[i], param = bound[i];
|
|
416
|
+
if (r_argument_1.RArgument.isEmpty(arg) || targetArg === undefined || param === undefined) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (param === 0 && r_symbol_1.RSymbol.is(arg.value)) {
|
|
420
|
+
for (const node of produceWrittenNodes(rootId, targetArg, identifier_1.ReferenceType.Variable, data, false, undefined)) {
|
|
421
|
+
defineByCall(node);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else if (param === 0 || (formals[param][1] & built_in_props_1.ArgProp.Value) !== 0) {
|
|
425
|
+
/* a name given as a string literal is defined at it, any other at the call */
|
|
426
|
+
const at = r_string_1.RString.is(arg.value) ? arg.value.info.id : rootId;
|
|
427
|
+
for (const named of node_value_1.NodeValue.knownStringsOf(arg.value, data)) {
|
|
428
|
+
const node = { nodeId: at, name: named, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: data.cds };
|
|
429
|
+
info.out = [...info.out, node];
|
|
430
|
+
defineByCall(node);
|
|
431
|
+
}
|
|
479
432
|
}
|
|
480
433
|
}
|
|
481
434
|
return info;
|
|
@@ -483,6 +436,7 @@ function processDefineArgument(name, args, rootId, data, config) {
|
|
|
483
436
|
/** Define `nodeToDefine` in the environment and wire the `DefinedBy` edges from it to its sources and the assignment root (dropping the child-added read edges). */
|
|
484
437
|
function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignment, data, assignmentConfig) {
|
|
485
438
|
information.environment = (0, define_1.define)(nodeToDefine, assignmentConfig?.superAssignment, information.environment);
|
|
439
|
+
information.environment = (0, built_in_ambient_state_1.ambientWritesOfAssignment)(information.environment, nodeToDefine.name, rootIdOfAssignment, data.cds ? [...data.cds] : undefined, assignmentConfig?.superAssignment === true || data.environment.level === 0);
|
|
486
440
|
information.graph.setDefinitionOfVertex(nodeToDefine, sourceIds);
|
|
487
441
|
const nid = nodeToDefine.nodeId;
|
|
488
442
|
if (!assignmentConfig?.quoteSource) {
|
|
@@ -492,8 +446,8 @@ function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignme
|
|
|
492
446
|
}
|
|
493
447
|
information.graph.addEdge(nid, rootIdOfAssignment, edge_1.EdgeType.DefinedBy);
|
|
494
448
|
// kinda dirty, but we have to remove existing read edges for the symbol, added by the child
|
|
495
|
-
for (const [id] of information.graph.edgesFrom(
|
|
496
|
-
information.graph.removeEdgeType(
|
|
449
|
+
for (const [id] of information.graph.edgesFrom(nid)) {
|
|
450
|
+
information.graph.removeEdgeType(nid, id, edge_1.EdgeType.Reads);
|
|
497
451
|
}
|
|
498
452
|
}
|
|
499
453
|
/** Helper for when the _target_ of an assignment is known to be a (single) symbol (i.e. `x <- ...`, not `names(x) <- ...`). */
|
|
@@ -503,7 +457,7 @@ function processAssignmentToSymbol(config) {
|
|
|
503
457
|
const referenceType = config.replacement && kindOfValue === identifier_1.ReferenceType.Variable ? identifier_1.ReferenceType.Unknown : kindOfValue;
|
|
504
458
|
const useSourceIds = [sourceArg.graph.hasVertex(source.info.id) ? source.info.id : sourceArg.entryPoint];
|
|
505
459
|
const aliases = (0, alias_tracking_1.getAliases)(useSourceIds, information.graph, information.environment);
|
|
506
|
-
const
|
|
460
|
+
const written = targetName ? [{
|
|
507
461
|
nodeId: targetId,
|
|
508
462
|
name: targetName,
|
|
509
463
|
type: referenceType,
|
|
@@ -513,10 +467,10 @@ function processAssignmentToSymbol(config) {
|
|
|
513
467
|
}]
|
|
514
468
|
: produceWrittenNodes(rootId, targetArg, referenceType, data, makeMaybe ?? false, aliases);
|
|
515
469
|
let copied;
|
|
470
|
+
let envState;
|
|
471
|
+
let envId;
|
|
472
|
+
let returnsEnvState;
|
|
516
473
|
if (data.ctx.config.solver.trackEnvironments) {
|
|
517
|
-
let envState;
|
|
518
|
-
let envId;
|
|
519
|
-
let returnsEnvState;
|
|
520
474
|
const valueEntry = valueEntryPointOf(sourceArg);
|
|
521
475
|
const stackEnv = (0, built_in_stack_env_1.stackEnvStateFromSource)(sourceArg, data, valueEntry);
|
|
522
476
|
if (isEnvCreatorSource(sourceArg, valueEntry)) {
|
|
@@ -549,44 +503,30 @@ function processAssignmentToSymbol(config) {
|
|
|
549
503
|
}
|
|
550
504
|
envState ??= (0, built_in_class_generator_1.resolveConstructorInstanceEnvState)(source, data);
|
|
551
505
|
}
|
|
552
|
-
if (envState) {
|
|
553
|
-
for (let i = 0; i < writeNodes.length; i++) {
|
|
554
|
-
writeNodes[i] = { ...writeNodes[i], envState, envId };
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
else if (returnsEnvState) {
|
|
558
|
-
for (let i = 0; i < writeNodes.length; i++) {
|
|
559
|
-
writeNodes[i] = { ...writeNodes[i], returnsEnvState };
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
506
|
}
|
|
507
|
+
const forces = quoteSource ? (0, built_in_ambient_state_1.ambientWritesBetween)(sourceArg.environment, data.environment) : [];
|
|
508
|
+
if (forces.length > 0) {
|
|
509
|
+
(0, built_in_ambient_state_1.markForcing)(data.environment);
|
|
510
|
+
}
|
|
511
|
+
const tracked = envState ? { envState, envId } : returnsEnvState ? { returnsEnvState } : {};
|
|
512
|
+
const writeNodes = written.map(w => ({ ...w, ...tracked, ...forces.length > 0 ? { forces } : {} }));
|
|
563
513
|
if (writeNodes.length !== 1 && log_1.log.settings.minLevel >= 4 /* LogLevel.Warn */) {
|
|
564
514
|
log_1.log.warn(`Unexpected write number in assignment: ${JSON.stringify(writeNodes)}`);
|
|
565
515
|
}
|
|
566
|
-
|
|
516
|
+
/* we drop the first arg which we use to pass along arguments */
|
|
567
517
|
const readFromSourceWritten = sourceArg.out.slice(1);
|
|
568
518
|
const readTargets = [
|
|
569
|
-
{ nodeId: rootId, name: nameOfAssignmentFunction, cds: data.cds, type: identifier_1.ReferenceType.Function }
|
|
519
|
+
{ nodeId: rootId, name: nameOfAssignmentFunction, cds: data.cds, type: identifier_1.ReferenceType.Function },
|
|
520
|
+
...sourceArg.unknownReferences,
|
|
521
|
+
...sourceArg.in,
|
|
522
|
+
...targetName ? targetArg.in : targetArg.in.filter(i => i.nodeId !== targetId),
|
|
523
|
+
...readFromSourceWritten
|
|
570
524
|
];
|
|
571
|
-
readTargets.push(...sourceArg.unknownReferences);
|
|
572
|
-
readTargets.push(...sourceArg.in);
|
|
573
|
-
if (targetName) {
|
|
574
|
-
readTargets.push(...targetArg.in);
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
for (const i of targetArg.in) {
|
|
578
|
-
if (i.nodeId !== targetId) {
|
|
579
|
-
readTargets.push(i);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
readTargets.push(...readFromSourceWritten);
|
|
584
525
|
/* a quoted source (`delayedAssign`) writes nothing yet, its writes happen where it is forced (see `Deferred`) */
|
|
585
526
|
information.environment = quoteSource ? data.environment : (0, overwrite_1.overwriteEnvironment)(sourceArg.environment, targetArg.environment);
|
|
586
527
|
if (config.beforeDefine) {
|
|
587
528
|
information.environment = config.beforeDefine(information);
|
|
588
529
|
}
|
|
589
|
-
// install assigned variables in environment
|
|
590
530
|
for (const write of writeNodes) {
|
|
591
531
|
markAsAssignment(information, write, useSourceIds, rootId, data, config);
|
|
592
532
|
}
|
|
@@ -594,13 +534,7 @@ function processAssignmentToSymbol(config) {
|
|
|
594
534
|
information.environment = (0, define_1.define)({ ...copied, name: copied.name, envId: copied.nodeId }, false, information.environment);
|
|
595
535
|
}
|
|
596
536
|
information.graph.addEdge(rootId, targetArg.entryPoint, edge_1.EdgeType.Returns);
|
|
597
|
-
|
|
598
|
-
information.graph.addEdge(rootId, source.info.id, edge_1.EdgeType.NonStandardEvaluation);
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
// we read the source
|
|
602
|
-
information.graph.addEdge(rootId, source.info.id, edge_1.EdgeType.Reads);
|
|
603
|
-
}
|
|
537
|
+
information.graph.addEdge(rootId, source.info.id, quoteSource ? edge_1.EdgeType.NonStandardEvaluation : edge_1.EdgeType.Reads);
|
|
604
538
|
return {
|
|
605
539
|
environment: information.environment,
|
|
606
540
|
graph: information.graph,
|
|
@@ -610,7 +544,7 @@ function processAssignmentToSymbol(config) {
|
|
|
610
544
|
entryPoint: rootId,
|
|
611
545
|
cfgEntry: information.cfgEntry,
|
|
612
546
|
in: readTargets,
|
|
613
|
-
out: writeNodes
|
|
547
|
+
out: [...writeNodes, ...readFromSourceWritten],
|
|
614
548
|
};
|
|
615
549
|
}
|
|
616
550
|
//# sourceMappingURL=built-in-assignment.js.map
|
|
@@ -16,6 +16,7 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
16
16
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
17
17
|
const r_function_call_2 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
18
|
const built_in_s_seven_new_generic_1 = require("./built-in-s-seven-new-generic");
|
|
19
|
+
const built_in_s_four_1 = require("./built-in-s-four");
|
|
19
20
|
/** R6's `public` / Reference Class's `methods` argument carrying the class generator's methods. */
|
|
20
21
|
const MethodListArguments = ['public', 'methods'];
|
|
21
22
|
const FieldListArguments = ['fields', 'private'];
|
|
@@ -23,6 +24,7 @@ const FieldListArguments = ['fields', 'private'];
|
|
|
23
24
|
function processClassGenerator(name, args, rootId, data, config) {
|
|
24
25
|
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.ClassGenerator }).information;
|
|
25
26
|
(0, built_in_s_seven_new_generic_1.attachClassDeclaration)(info, rootId, args, config?.classDecl);
|
|
27
|
+
(0, built_in_s_four_1.linkS4Declaration)(info, rootId, data);
|
|
26
28
|
return info;
|
|
27
29
|
}
|
|
28
30
|
/** The method env of a class generator's `public`/`methods` `list(...)` (via {@link resolveListToEnvState}); `undefined` if absent. */
|
|
@@ -32,10 +34,9 @@ function resolveClassMethodsToEnvState(source, data) {
|
|
|
32
34
|
}
|
|
33
35
|
let envState;
|
|
34
36
|
for (const [names, values] of [[MethodListArguments, false], [FieldListArguments, true]]) {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
: undefined;
|
|
37
|
+
const listArg = source.arguments.find(arg => arg !== r_function_call_2.EmptyArgument && arg.name !== undefined && names.includes(arg.name.content));
|
|
38
|
+
const list = r_argument_1.RArgument.valueOf(listArg);
|
|
39
|
+
const resolved = list === undefined ? undefined : (0, built_in_list_1.resolveListToEnvState)(list, envState ? { environment: envState } : data, values);
|
|
39
40
|
envState = resolved ?? envState;
|
|
40
41
|
}
|
|
41
42
|
return envState;
|
|
@@ -43,14 +44,11 @@ function resolveClassMethodsToEnvState(source, data) {
|
|
|
43
44
|
const ConstructorField = 'new';
|
|
44
45
|
/** The method env an instance from `<Cls>$new(...)`/`<Cls>[["new"]](...)` carries, from the generator's recorded `returnsEnvState`; `undefined` otherwise. */
|
|
45
46
|
function resolveConstructorInstanceEnvState(source, data) {
|
|
46
|
-
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
const callee = source.calledFunction;
|
|
47
|
+
const callee = r_function_call_1.RFunctionCall.isUnnamed(source) ? source.calledFunction : undefined;
|
|
50
48
|
if (!r_access_1.RAccess.is(callee) || (callee.operator !== '$' && callee.operator !== '[[') || !r_symbol_1.RSymbol.is(callee.accessed)) {
|
|
51
49
|
return undefined;
|
|
52
50
|
}
|
|
53
|
-
const field = r_argument_1.RArgument.
|
|
51
|
+
const field = r_argument_1.RArgument.valueOf(callee.access[0]);
|
|
54
52
|
const fieldName = r_string_1.RString.is(field) ? field.content.str : field?.lexeme;
|
|
55
53
|
if (fieldName !== ConstructorField) {
|
|
56
54
|
return undefined;
|
|
@@ -2,7 +2,7 @@ import type { DataflowInformation } from '../../../../../info';
|
|
|
2
2
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
3
3
|
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
import type
|
|
5
|
+
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
6
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
7
7
|
/**
|
|
8
8
|
* Processes a list of expressions joining their dataflow graphs accordingly.
|