@eagleoutice/flowr 2.15.10 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- 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 +185 -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 +64 -42
- 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 +42 -4
- package/dataflow/internal/control-flow.js +76 -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 +441 -79
- 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 +290 -252
- 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 +120 -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 +60 -58
- 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 +44 -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/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- 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 +117 -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 +130 -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-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- 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 +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- 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-executor.js +2 -0
- package/r-bridge/shell.js +8 -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 +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- 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/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -9,6 +9,8 @@ exports.classDeclarationOfImpl = classDeclarationOfImpl;
|
|
|
9
9
|
exports.declaredClassesImpl = declaredClassesImpl;
|
|
10
10
|
exports.superClassesOfImpl = superClassesOfImpl;
|
|
11
11
|
exports.toSigClassesImpl = toSigClassesImpl;
|
|
12
|
+
exports.s3DispatchClassesOf = s3DispatchClassesOf;
|
|
13
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
14
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
15
|
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
14
16
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
@@ -18,6 +20,11 @@ const edge_1 = require("../graph/edge");
|
|
|
18
20
|
const assert_1 = require("../../util/assert");
|
|
19
21
|
const objects_1 = require("../../util/objects");
|
|
20
22
|
const vertex_1 = require("../graph/vertex");
|
|
23
|
+
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
24
|
+
const node_value_1 = require("../eval/resolve/node-value");
|
|
25
|
+
const string_constants_1 = require("../eval/values/string/string-constants");
|
|
26
|
+
const r_value_1 = require("../eval/values/r-value");
|
|
27
|
+
const frame_reflection_1 = require("./frame-reflection");
|
|
21
28
|
/** the class name R uses to mark a class as non-instantiable */
|
|
22
29
|
const VirtualClass = 'VIRTUAL';
|
|
23
30
|
/** The argument `ref` names, by name when the call gives one and by position among the unnamed ones otherwise. */
|
|
@@ -25,37 +32,24 @@ function argForImpl(args, ref) {
|
|
|
25
32
|
if (ref === undefined) {
|
|
26
33
|
return undefined;
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return named.value;
|
|
32
|
-
}
|
|
35
|
+
const named = ref.name === undefined ? undefined : args.find(a => !r_argument_1.RArgument.isEmpty(a) && a.name?.content === ref.name);
|
|
36
|
+
if (named !== undefined) {
|
|
37
|
+
return r_argument_1.RArgument.valueOf(named);
|
|
33
38
|
}
|
|
34
39
|
if (ref.idx === undefined) {
|
|
35
40
|
return undefined;
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (r_argument_1.RArgument.isEmpty(a) || a.name !== undefined) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (pos++ === ref.idx) {
|
|
43
|
-
return a.value;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
42
|
+
const unnamed = args.filter(a => !r_argument_1.RArgument.isEmpty(a) && a.name === undefined);
|
|
43
|
+
return r_argument_1.RArgument.valueOf(unnamed[ref.idx]);
|
|
47
44
|
}
|
|
48
45
|
/** The string a node states literally, `undefined` for anything that is not a literal (a variable, a call, ...). */
|
|
49
46
|
function literal(node) {
|
|
50
|
-
return
|
|
47
|
+
return r_string_1.RString.is(node) ? node.content.str : undefined;
|
|
51
48
|
}
|
|
52
49
|
/** The character vector a node states: a literal, or the literals of a `c(...)`/`list(...)` around them. */
|
|
53
50
|
function literalVector(node) {
|
|
54
51
|
const values = [];
|
|
55
52
|
const byVariable = [];
|
|
56
|
-
if (node === undefined) {
|
|
57
|
-
return { values, byVariable };
|
|
58
|
-
}
|
|
59
53
|
const collect = (n) => {
|
|
60
54
|
const str = literal(n);
|
|
61
55
|
if (str !== undefined) {
|
|
@@ -66,11 +60,7 @@ function literalVector(node) {
|
|
|
66
60
|
byVariable.push(n.lexeme);
|
|
67
61
|
}
|
|
68
62
|
else if (r_function_call_1.RFunctionCall.isNamed(n)) {
|
|
69
|
-
|
|
70
|
-
if (!r_argument_1.RArgument.isEmpty(arg) && arg.value !== undefined) {
|
|
71
|
-
collect(arg.value);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
63
|
+
n.arguments.forEach(a => collect(r_argument_1.RArgument.valueOf(a)));
|
|
74
64
|
}
|
|
75
65
|
};
|
|
76
66
|
collect(node);
|
|
@@ -81,14 +71,11 @@ function literalVector(node) {
|
|
|
81
71
|
* element, plus the bare strings such a call may carry (an RC `fields = c("x", "y")`, or a `"VIRTUAL"` marker).
|
|
82
72
|
*/
|
|
83
73
|
function membersOf(node, ref) {
|
|
84
|
-
const members = [];
|
|
85
|
-
let virtual = false;
|
|
86
|
-
if (node === undefined) {
|
|
87
|
-
return { members, virtual };
|
|
88
|
-
}
|
|
89
74
|
if (!r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
90
|
-
return { members, virtual: literal(node) === VirtualClass };
|
|
75
|
+
return { members: [], virtual: literal(node) === VirtualClass };
|
|
91
76
|
}
|
|
77
|
+
const members = [];
|
|
78
|
+
let virtual = false;
|
|
92
79
|
for (const arg of node.arguments) {
|
|
93
80
|
if (r_argument_1.RArgument.isEmpty(arg) || arg.value === undefined) {
|
|
94
81
|
continue;
|
|
@@ -121,15 +108,10 @@ function isTrue(node) {
|
|
|
121
108
|
* An argument that resolves to no literal contributes a {@link ClassDeclaration.byVariable|by-variable} name, or nothing.
|
|
122
109
|
*/
|
|
123
110
|
function classDeclarationOfImpl(config, args) {
|
|
124
|
-
const byVariable = [];
|
|
125
111
|
const nameNode = argForImpl(args, config.nameArg);
|
|
126
112
|
const name = literal(nameNode);
|
|
127
|
-
if (name === undefined && nameNode !== undefined && r_symbol_1.RSymbol.is(nameNode)) {
|
|
128
|
-
byVariable.push(nameNode.lexeme);
|
|
129
|
-
}
|
|
130
113
|
const parents = literalVector(argForImpl(args, config.containsArg));
|
|
131
|
-
byVariable.
|
|
132
|
-
const contains = parents.values.filter(c => c !== VirtualClass);
|
|
114
|
+
const byVariable = name === undefined && r_symbol_1.RSymbol.is(nameNode) ? [nameNode.lexeme, ...parents.byVariable] : parents.byVariable;
|
|
133
115
|
let virtual = parents.values.includes(VirtualClass) || isTrue(argForImpl(args, config.virtualArg));
|
|
134
116
|
const members = [];
|
|
135
117
|
for (const ref of config.memberArgs ?? []) {
|
|
@@ -137,15 +119,14 @@ function classDeclarationOfImpl(config, args) {
|
|
|
137
119
|
members.push(...found.members);
|
|
138
120
|
virtual ||= found.virtual;
|
|
139
121
|
}
|
|
140
|
-
const union =
|
|
141
|
-
const prototype = config.prototypeArg
|
|
142
|
-
: membersOf(argForImpl(args, config.prototypeArg), config.prototypeArg).members.map(m => m.name);
|
|
122
|
+
const union = literalVector(argForImpl(args, config.unionArg)).values;
|
|
123
|
+
const prototype = membersOf(argForImpl(args, config.prototypeArg), config.prototypeArg ?? {}).members.map(m => m.name);
|
|
143
124
|
/* a class union is virtual by construction: it exists to be extended, never to be instantiated */
|
|
144
|
-
const isUnion = union
|
|
125
|
+
const isUnion = union.length > 0;
|
|
145
126
|
return (0, objects_1.compactRecord)({
|
|
146
127
|
system: config.system,
|
|
147
128
|
name,
|
|
148
|
-
contains,
|
|
129
|
+
contains: parents.values.filter(c => c !== VirtualClass),
|
|
149
130
|
members,
|
|
150
131
|
virtual: virtual || isUnion ? true : undefined,
|
|
151
132
|
union: isUnion ? union : undefined,
|
|
@@ -157,61 +138,54 @@ function classDeclarationOfImpl(config, args) {
|
|
|
157
138
|
/** Every class the graph declares, keyed by name. A later declaration of the same name wins, as it would in R. */
|
|
158
139
|
function declaredClassesImpl(graph) {
|
|
159
140
|
const classes = new Map();
|
|
160
|
-
for (const [id,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
continue;
|
|
141
|
+
for (const [id, { classDecl }] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
142
|
+
if (classDecl?.name !== undefined && classDecl.relation === undefined) {
|
|
143
|
+
classes.set(classDecl.name, { ...classDecl, id, name: classDecl.name });
|
|
164
144
|
}
|
|
165
|
-
classes.set(decl.name, { ...decl, id, name: decl.name });
|
|
166
145
|
}
|
|
146
|
+
const addSuper = (sub, sup) => {
|
|
147
|
+
const existing = classes.get(sub);
|
|
148
|
+
if (existing !== undefined && sup !== undefined && !existing.contains.includes(sup)) {
|
|
149
|
+
classes.set(sub, { ...existing, contains: [...existing.contains, sup] });
|
|
150
|
+
}
|
|
151
|
+
};
|
|
167
152
|
/* R6 and S7 name their parent by the generator *variable*, so `Employee <- R6Class(inherit = Person)`
|
|
168
153
|
only says "Person"; the assignment that bound the generator says which class that is */
|
|
169
154
|
const byGenerator = generatorVariables(graph, classes);
|
|
170
155
|
for (const [name, declared] of classes) {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
156
|
+
for (const sup of declared.byVariable.map(v => byGenerator.get(v))) {
|
|
157
|
+
if (sup !== name) {
|
|
158
|
+
addSuper(name, sup);
|
|
159
|
+
}
|
|
175
160
|
}
|
|
176
161
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const decl = vertex.classDecl;
|
|
180
|
-
if (decl?.name === undefined) {
|
|
162
|
+
for (const [, { classDecl }] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
163
|
+
if (classDecl?.name === undefined) {
|
|
181
164
|
continue;
|
|
182
165
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
classes.set(member, { ...existing, contains: [...existing.contains, decl.name] });
|
|
187
|
-
}
|
|
166
|
+
/* a `setClassUnion` states its members as subclasses, which is the same fact written the other way round */
|
|
167
|
+
for (const member of classDecl.union ?? []) {
|
|
168
|
+
addSuper(member, classDecl.name);
|
|
188
169
|
}
|
|
189
170
|
/* `setIs(class1, class2)` states the same is-a relation `contains` does */
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
const existing = classes.get(sub);
|
|
193
|
-
if (existing !== undefined && sup !== undefined && !existing.contains.includes(sup)) {
|
|
194
|
-
classes.set(sub, { ...existing, contains: [...existing.contains, sup] });
|
|
195
|
-
}
|
|
171
|
+
if (classDecl.relation === 'is') {
|
|
172
|
+
addSuper(classDecl.name, classDecl.contains[0]);
|
|
196
173
|
}
|
|
197
174
|
}
|
|
198
175
|
return classes;
|
|
199
176
|
}
|
|
200
177
|
/** Variable name to the class its generator declares, for the `Cls <- R6Class(...)`/`Cls <- new_class(...)` bindings. */
|
|
201
178
|
function generatorVariables(graph, classes) {
|
|
202
|
-
const
|
|
203
|
-
for (const declared of classes.values()) {
|
|
204
|
-
byName.set(declared.id, declared.name);
|
|
205
|
-
}
|
|
179
|
+
const classOfId = new Map(classes.values().map(d => [d.id, d.name]));
|
|
206
180
|
const generators = new Map();
|
|
207
181
|
for (const [id] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
|
|
208
182
|
const lexeme = graph.idMap?.get(id)?.lexeme;
|
|
209
183
|
if (lexeme === undefined) {
|
|
210
184
|
continue;
|
|
211
185
|
}
|
|
212
|
-
for (const
|
|
213
|
-
const cls =
|
|
214
|
-
if (cls !== undefined
|
|
186
|
+
for (const target of (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.DefinedBy)) {
|
|
187
|
+
const cls = classOfId.get(target);
|
|
188
|
+
if (cls !== undefined) {
|
|
215
189
|
generators.set(lexeme, cls);
|
|
216
190
|
}
|
|
217
191
|
}
|
|
@@ -223,50 +197,75 @@ function generatorVariables(graph, classes) {
|
|
|
223
197
|
* analysis never saw declared ends the chain, so what another package contributes is simply not in the answer.
|
|
224
198
|
*/
|
|
225
199
|
function superClassesOfImpl(name, classes) {
|
|
226
|
-
const chain = [];
|
|
227
200
|
const seen = new Set([name]);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
continue;
|
|
201
|
+
/* a set iteration also visits what is added during it, so this walks the hierarchy breadth first */
|
|
202
|
+
for (const next of seen) {
|
|
203
|
+
for (const sup of classes.get(next)?.contains ?? []) {
|
|
204
|
+
seen.add(sup);
|
|
233
205
|
}
|
|
234
|
-
seen.add(next);
|
|
235
|
-
chain.push(next);
|
|
236
|
-
queue.push(...(classes.get(next)?.contains ?? []));
|
|
237
206
|
}
|
|
238
|
-
|
|
207
|
+
seen.delete(name);
|
|
208
|
+
return [...seen];
|
|
239
209
|
}
|
|
240
210
|
/**
|
|
241
211
|
* The {@link SigClassInfo} records the signature database stores for the classes an analysis found. A class
|
|
242
212
|
* the analysis declared carries no `package`; a referenced class `ownerOf` can place becomes a `foreign` record.
|
|
243
213
|
*/
|
|
244
214
|
function toSigClassesImpl(classes, ownerOf) {
|
|
245
|
-
const records =
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
union: declared.union !== undefined ? true : undefined
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
215
|
+
const records = classes.values().map(declared => (0, objects_1.compactRecord)({
|
|
216
|
+
name: declared.name,
|
|
217
|
+
system: declared.system,
|
|
218
|
+
supers: declared.union ?? declared.contains,
|
|
219
|
+
slots: declared.members.filter(m => !m.method).map(m => (0, objects_1.compactRecord)({ name: m.name, type: m.type })),
|
|
220
|
+
virtual: declared.virtual ? true : undefined,
|
|
221
|
+
union: declared.union !== undefined ? true : undefined
|
|
222
|
+
})).toArray();
|
|
256
223
|
if (ownerOf === undefined) {
|
|
257
224
|
return records;
|
|
258
225
|
}
|
|
259
226
|
/* a superclass the analysis never declared belongs to whoever does define it, which is what makes an
|
|
260
227
|
inherited class distinguishable from one the package owns */
|
|
261
228
|
for (const referenced of new Set(records.flatMap(r => r.supers))) {
|
|
262
|
-
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
const owner = ownerOf(referenced);
|
|
229
|
+
const owner = classes.has(referenced) ? undefined : ownerOf(referenced);
|
|
266
230
|
if (owner !== undefined) {
|
|
267
231
|
records.push({ name: referenced, system: 's4', supers: [], slots: [], package: owner });
|
|
268
232
|
}
|
|
269
233
|
}
|
|
270
234
|
return records;
|
|
271
235
|
}
|
|
236
|
+
/** The class vector S3 dispatch sees for the value at `id`: a `structure(..., class = )` or a constant, `undefined` if not statically known. */
|
|
237
|
+
function s3ClassOfValue(id, info) {
|
|
238
|
+
const node = info.idMap.get(id);
|
|
239
|
+
if (r_function_call_1.RFunctionCall.is(node) && (0, frame_reflection_1.hasEdgeOfType)(info.graph, id, node_id_1.NodeId.toBuiltIn('structure'), edge_1.EdgeType.Calls)) {
|
|
240
|
+
const cls = node_value_1.NodeValue.soleOf(argForImpl(node.arguments, { name: 'class' }), info);
|
|
241
|
+
const strings = cls?.type === 'string' ? (0, string_constants_1.collectStrings)([cls]) : cls?.type === 'vector' && (0, r_value_1.isValue)(cls.elements) ? (0, string_constants_1.collectStrings)(cls.elements) : undefined;
|
|
242
|
+
return strings?.length ? strings : undefined;
|
|
243
|
+
}
|
|
244
|
+
const value = node_value_1.NodeValue.soleOf(id, info);
|
|
245
|
+
if (value?.type === 'string') {
|
|
246
|
+
return ['character'];
|
|
247
|
+
}
|
|
248
|
+
else if (value?.type === 'logical') {
|
|
249
|
+
return ['logical'];
|
|
250
|
+
}
|
|
251
|
+
else if (value?.type === 'number' && (0, r_value_1.isValue)(value.value)) {
|
|
252
|
+
return value.value.complexNumber ? ['complex'] : value.value.markedAsInt ? ['integer', 'numeric'] : ['double', 'numeric'];
|
|
253
|
+
}
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
/** The value a plain assignment binds to the definition `def`, `undefined` for any other kind of definition (`class(x) <- `, `assign`, a parameter, ...). */
|
|
257
|
+
function assignedValueOf(def, graph) {
|
|
258
|
+
const vertex = graph.getVertex(def);
|
|
259
|
+
const byAssignment = (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.DefinedBy).some(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Assignment));
|
|
260
|
+
return vertex_1.DfgVertex.isVariableDefinition(vertex) && byAssignment && vertex.source?.length === 1 ? vertex.source[0] : undefined;
|
|
261
|
+
}
|
|
262
|
+
/** The class vectors S3 dispatch may see for the argument at `id`, one per reaching definition, `undefined` unless all are known. */
|
|
263
|
+
function s3DispatchClassesOf(id, info) {
|
|
264
|
+
const { graph } = info;
|
|
265
|
+
const value = r_argument_1.RArgument.valueOf(info.idMap.get(id))?.info.id;
|
|
266
|
+
const isRead = value !== undefined && vertex_1.DfgVertex.isUse(graph.getVertex(value));
|
|
267
|
+
const values = isRead ? (0, frame_reflection_1.edgeTargets)(graph, value, edge_1.EdgeType.Reads).map(def => assignedValueOf(def, graph)) : [value];
|
|
268
|
+
const classes = values.map(v => v === undefined ? undefined : s3ClassOfValue(v, info));
|
|
269
|
+
return classes.length > 0 && classes.every(assert_1.isNotUndefined) ? classes : undefined;
|
|
270
|
+
}
|
|
272
271
|
//# sourceMappingURL=class-declaration.js.map
|
|
@@ -11,15 +11,14 @@ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes
|
|
|
11
11
|
const built_in_props_1 = require("../environments/built-in-props");
|
|
12
12
|
const query_fn_props_1 = require("../environments/query-fn-props");
|
|
13
13
|
const condition_handlers_1 = require("./condition-handlers");
|
|
14
|
-
const
|
|
15
|
-
const CatchHandlers = new Set([built_in_proc_name_1.BuiltInProcName.Try]);
|
|
14
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
16
15
|
/**
|
|
17
16
|
* Whether the vertex catches an error raised below it, which ends the walk. A construct declaring no condition
|
|
18
17
|
* handler of its own (`try`) catches whatever arrives; one that matches handlers by condition class
|
|
19
18
|
* (`tryCatch`) catches only what the names written for it say.
|
|
20
19
|
*/
|
|
21
20
|
function catches(vertex, graph, info) {
|
|
22
|
-
if (!vertex_1.DfgVertex.isFunctionCall(vertex) ||
|
|
21
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Try)) {
|
|
23
22
|
return false;
|
|
24
23
|
}
|
|
25
24
|
const sig = info(vertex.name)?.sig;
|
|
@@ -37,8 +36,8 @@ function catches(vertex, graph, info) {
|
|
|
37
36
|
*/
|
|
38
37
|
function guarded(id, graph, info) {
|
|
39
38
|
const idMap = graph.idMap;
|
|
40
|
-
let node = idMap
|
|
41
|
-
while (node !== undefined && !r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
39
|
+
let node = idMap?.get(id);
|
|
40
|
+
while (idMap !== undefined && node !== undefined && !r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
42
41
|
const parent = model_1.RNode.directParent(node, idMap);
|
|
43
42
|
if (r_argument_1.RArgument.isUnnamed(node) && r_function_call_1.RFunctionCall.is(parent) && catches(graph.getVertex(parent.info.id), graph, info)) {
|
|
44
43
|
return true;
|
|
@@ -49,7 +48,7 @@ function guarded(id, graph, info) {
|
|
|
49
48
|
}
|
|
50
49
|
function reach(id, graph, knownThrower) {
|
|
51
50
|
const info = (0, query_fn_props_1.builtInLookup)();
|
|
52
|
-
const isGuarded =
|
|
51
|
+
const isGuarded = (0, defaultmap_1.memoize)((n) => guarded(n, graph, info));
|
|
53
52
|
const calls = new Map();
|
|
54
53
|
const own = new Map();
|
|
55
54
|
const defs = new Set();
|
|
@@ -75,22 +74,72 @@ function reach(id, graph, knownThrower) {
|
|
|
75
74
|
own.set(current, vertex.exitPoints.filter(e => e.type === 4 /* ExitPointType.Error */).map(e => ({ id: e.nodeId, cds: e.cds })));
|
|
76
75
|
}
|
|
77
76
|
/* a guarded call is only ever reached through the construct guarding it, which ends the walk of its own */
|
|
78
|
-
const next = [...
|
|
79
|
-
let known = isGuarded.get(n);
|
|
80
|
-
if (known === undefined) {
|
|
81
|
-
known = guarded(n, graph, info);
|
|
82
|
-
isGuarded.set(n, known);
|
|
83
|
-
}
|
|
84
|
-
return !known;
|
|
85
|
-
});
|
|
77
|
+
const next = [...graph.edgesFrom(current).keys()].filter(n => !isGuarded(n));
|
|
86
78
|
calls.set(current, next);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
toVisit.push(...next);
|
|
80
|
+
}
|
|
81
|
+
return { calls, own, defs };
|
|
82
|
+
}
|
|
83
|
+
/** What each node may raise, its callees included; Tarjan yields the call cycles callees first, so each is settled once. */
|
|
84
|
+
function raisedPerNode(calls, own) {
|
|
85
|
+
const raised = new Map();
|
|
86
|
+
const index = new Map();
|
|
87
|
+
const low = new Map();
|
|
88
|
+
const stack = [];
|
|
89
|
+
const onStack = new Set();
|
|
90
|
+
const lower = (node, to) => low.set(node, Math.min(low.get(node), to));
|
|
91
|
+
for (const root of calls.keys()) {
|
|
92
|
+
if (index.has(root)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
/* each frame is a node and how many of its callees have been looked at */
|
|
96
|
+
const frames = [[root, 0]];
|
|
97
|
+
while (frames.length > 0) {
|
|
98
|
+
const frame = frames[frames.length - 1];
|
|
99
|
+
const [node, at] = frame;
|
|
100
|
+
if (at === 0) {
|
|
101
|
+
low.set(node, index.size);
|
|
102
|
+
index.set(node, index.size);
|
|
103
|
+
stack.push(node);
|
|
104
|
+
onStack.add(node);
|
|
105
|
+
}
|
|
106
|
+
const callee = calls.get(node)?.[at];
|
|
107
|
+
if (callee !== undefined) {
|
|
108
|
+
frame[1]++;
|
|
109
|
+
if (!index.has(callee)) {
|
|
110
|
+
frames.push([callee, 0]);
|
|
111
|
+
}
|
|
112
|
+
else if (onStack.has(callee)) {
|
|
113
|
+
lower(node, index.get(callee));
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
frames.pop();
|
|
118
|
+
if (frames.length > 0) {
|
|
119
|
+
lower(frames[frames.length - 1][0], low.get(node));
|
|
120
|
+
}
|
|
121
|
+
if (low.get(node) === index.get(node)) {
|
|
122
|
+
/* the node roots a component: its members are what lies on the stack above it, taken off top first */
|
|
123
|
+
const members = stack.splice(stack.lastIndexOf(node)).reverse();
|
|
124
|
+
const points = new Map();
|
|
125
|
+
for (const m of members) {
|
|
126
|
+
for (const e of own.get(m) ?? []) {
|
|
127
|
+
points.set(e.id, e);
|
|
128
|
+
}
|
|
129
|
+
for (const callee of calls.get(m) ?? []) {
|
|
130
|
+
for (const [at, point] of raised.get(callee) ?? []) {
|
|
131
|
+
points.set(at, point);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const m of members) {
|
|
136
|
+
onStack.delete(m);
|
|
137
|
+
raised.set(m, points);
|
|
138
|
+
}
|
|
90
139
|
}
|
|
91
140
|
}
|
|
92
141
|
}
|
|
93
|
-
return
|
|
142
|
+
return raised;
|
|
94
143
|
}
|
|
95
144
|
/**
|
|
96
145
|
* The `NodeId`s of functions that may throw exceptions when called by `id`, restricted to functions known by
|
|
@@ -99,30 +148,12 @@ function reach(id, graph, knownThrower) {
|
|
|
99
148
|
*/
|
|
100
149
|
function exceptionsOfFunction(id, graph, { knownThrower = {} } = {}) {
|
|
101
150
|
const { calls, own, defs } = reach(id, graph, knownThrower);
|
|
102
|
-
const raised = new Map();
|
|
103
|
-
for (const node of calls.keys()) {
|
|
104
|
-
raised.set(node, new Map((own.get(node) ?? []).map(e => [e.id, e])));
|
|
105
|
-
}
|
|
106
|
-
(0, function_props_1.propagateToFixpoint)(calls.keys(), calls, node => {
|
|
107
|
-
const into = raised.get(node);
|
|
108
|
-
let grew = false;
|
|
109
|
-
for (const call of calls.get(node) ?? []) {
|
|
110
|
-
for (const [at, point] of raised.get(call) ?? NoPoints) {
|
|
111
|
-
if (!into.has(at)) {
|
|
112
|
-
into.set(at, point);
|
|
113
|
-
grew = true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return grew;
|
|
118
|
-
});
|
|
119
151
|
const result = {};
|
|
120
|
-
for (const [node, points] of
|
|
152
|
+
for (const [node, points] of raisedPerNode(calls, own)) {
|
|
121
153
|
if (defs.has(node) || node === id) {
|
|
122
154
|
result[node] = [...points.values()];
|
|
123
155
|
}
|
|
124
156
|
}
|
|
125
157
|
return result;
|
|
126
158
|
}
|
|
127
|
-
const NoPoints = new Map();
|
|
128
159
|
//# sourceMappingURL=exceptions-of-function.js.map
|
|
@@ -3,19 +3,27 @@ import { EdgeType } from '../graph/edge';
|
|
|
3
3
|
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition } from '../graph/vertex';
|
|
4
4
|
import type { ArgProps, BuiltInFnInfo } from '../environments/built-in-props';
|
|
5
5
|
import type { Identifier } from '../environments/identifier';
|
|
6
|
-
import type
|
|
6
|
+
import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
7
8
|
/** What flowR states about the built-in a call names, see {@link BuiltInFnInfo}. */
|
|
8
9
|
export type BuiltInLookup = (name: Identifier) => BuiltInFnInfo | undefined;
|
|
9
10
|
/** The nodes at the far end of `node`'s outgoing edges of any of `types`, shared by every walk here and in the sibling analyses that follow specific edge kinds. */
|
|
10
11
|
export declare function edgeTargets(this: void, graph: DataflowGraph, node: NodeId, types: EdgeType): NodeId[];
|
|
12
|
+
/** The function-definition vertices a `call` resolves to (via {@link EdgeType.Calls}). */
|
|
13
|
+
export declare function calledDefinitions(this: void, graph: DataflowGraph, call: NodeId): NodeId[];
|
|
14
|
+
/** The nodes at the near end of `node`'s incoming edges of any of `types`, see {@link edgeTargets}. */
|
|
15
|
+
export declare function edgeSources(this: void, graph: DataflowGraph, node: NodeId, types: EdgeType): NodeId[];
|
|
16
|
+
/** Every variable definition by its unquoted name, in a single pass. */
|
|
17
|
+
export declare function definitionsByName(this: void, graph: DataflowGraph): DefaultMap<string, NodeId[]>;
|
|
18
|
+
/** Whether an edge from `from` to `to` carries any of `types`. */
|
|
19
|
+
export declare function hasEdgeOfType(this: void, graph: DataflowGraph, from: NodeId, to: NodeId, types: EdgeType): boolean;
|
|
11
20
|
/** The calls a definition's body reaches, id and vertex paired; shared by every walk here and in the sibling analyses that visit them all. */
|
|
12
21
|
export declare function callsIn(definition: DataflowGraphVertexFunctionDefinition, graph: DataflowGraph): Generator<[NodeId, DataflowGraphVertexFunctionCall]>;
|
|
13
22
|
/**
|
|
14
23
|
* Recomputes `recompute(id)` for every node reachable from `seed` along the reverse of `successors`, so a
|
|
15
24
|
* change at a node is carried on to whatever points at it, until nothing grows anymore. `recompute` updates
|
|
16
|
-
* its node's value itself and reports whether it grew; shared by {@link propagateOverCalls} and
|
|
17
|
-
* {@link
|
|
18
|
-
* by {@link carriersOf} below, which grows a set rather than a bitfield.
|
|
25
|
+
* its node's value itself and reports whether it grew; shared by {@link propagateOverCalls} and by
|
|
26
|
+
* {@link carriersOf} below, which grows a set rather than a bitfield.
|
|
19
27
|
*/
|
|
20
28
|
export declare function propagateToFixpoint(seed: Iterable<NodeId>, successors: ReadonlyMap<NodeId, readonly NodeId[]>, recompute: (id: NodeId) => boolean): void;
|
|
21
29
|
/** What to ask for beyond the definition itself, see {@link reflectiveRolesOf}. */
|