@eagleoutice/flowr 2.15.9 → 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 +47 -41
- package/abstract-interpretation/absint-inference.d.ts +2 -2
- package/abstract-interpretation/absint-inference.js +32 -79
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/benchmark/slicer.d.ts +0 -1
- package/benchmark/slicer.js +1 -2
- package/cli/repl/commands/repl-signature.js +12 -3
- package/config.d.ts +5 -1
- package/control-flow/cfg-properties.js +0 -22
- package/control-flow/happens-before.d.ts +7 -2
- package/control-flow/happens-before.js +55 -31
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/apply-kill.js +6 -2
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-props.d.ts +16 -1
- package/dataflow/environments/built-in-props.js +33 -20
- package/dataflow/environments/built-in.d.ts +8 -3
- package/dataflow/environments/built-in.js +52 -82
- package/dataflow/environments/default-builtin-config.d.ts +551 -21
- package/dataflow/environments/default-builtin-config.js +121 -45
- package/dataflow/environments/define.d.ts +3 -2
- package/dataflow/environments/define.js +4 -3
- package/dataflow/environments/deprecation-info.d.ts +45 -0
- package/dataflow/environments/deprecation-info.js +13 -0
- package/dataflow/environments/environment.d.ts +7 -5
- package/dataflow/environments/environment.js +55 -121
- package/dataflow/environments/identifier.d.ts +6 -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 +180 -58
- package/dataflow/fn/class-declaration.d.ts +8 -13
- package/dataflow/fn/class-declaration.js +95 -116
- 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.d.ts +9 -1
- package/dataflow/fn/higher-order-function.js +27 -24
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +291 -123
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +13 -1
- package/dataflow/graph/graph.js +74 -66
- package/dataflow/graph/vertex.d.ts +1 -1
- 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 +17 -8
- package/dataflow/internal/linker.js +286 -213
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
- 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 +60 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
- 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-envir-utils.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- 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 +141 -146
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
- 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 +91 -129
- 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 +16 -12
- 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-repeat-loop.js +2 -0
- 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 +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
- 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 +42 -119
- 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 +21 -21
- 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 +23 -26
- 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 +4 -4
- package/dataflow/internal/process/functions/call/common.js +49 -71
- package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
- package/dataflow/internal/process/functions/call/deferred.js +81 -63
- 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 +48 -19
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +257 -154
- 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 +4 -3
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/data/faq/faqs.js +3 -3
- package/documentation/data/interface/doc-writing-code.js +1 -2
- package/documentation/data/server/doc-data-server-messages.js +7 -7
- package/documentation/doc-capabilities.js +80 -34
- package/documentation/doc-util/doc-query.d.ts +0 -3
- package/documentation/doc-util/doc-query.js +4 -3
- package/documentation/wiki-analyzer.js +1 -1
- package/documentation/wiki-cfg.js +5 -6
- package/documentation/wiki-core.js +8 -8
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linting-and-testing.js +3 -3
- package/documentation/wiki-overview.js +6 -6
- package/documentation/wiki-query.js +9 -101
- package/documentation/wiki-setup.js +23 -0
- package/documentation/wiki-signature-database.js +1 -1
- package/linter/linter-rules.d.ts +18 -9
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/deprecated-functions.d.ts +1 -45
- package/linter/rules/deprecated-functions.js +24 -33
- 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.d.ts +2 -0
- package/project/flowr-analyzer.js +28 -1
- 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 +0 -2
- package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
- 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/file-plugins/flowr-analyzer-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +4 -0
- package/project/sigdb/manifest.d.ts +2 -0
- package/project/sigdb/manifest.js +10 -1
- package/project/sigdb/reader.js +23 -61
- package/project/sigdb/sigdb-download.d.ts +29 -6
- package/project/sigdb/sigdb-download.js +212 -64
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
- package/queries/catalog/call-context-query/cascade-action.js +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
- 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/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/data/data.d.ts +21 -14
- package/r-bridge/data/data.js +28 -20
- 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/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
- 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/files.d.ts +2 -0
- package/util/files.js +3 -1
- package/util/mermaid/mermaid.js +6 -2
- 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
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onlyLiterals = onlyLiterals;
|
|
3
4
|
exports.resolveNode = resolveNode;
|
|
4
5
|
exports.resolveAsVector = resolveAsVector;
|
|
5
6
|
exports.resolveAsSeq = resolveAsSeq;
|
|
6
7
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
8
|
const r_value_1 = require("../values/r-value");
|
|
8
9
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
10
|
+
const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
11
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
12
|
+
const r_logical_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
|
|
9
13
|
const r_value_2 = require("../../../util/r-value");
|
|
10
14
|
const logical_constants_1 = require("../values/logical/logical-constants");
|
|
11
15
|
const r_value_3 = require("../values/r-value");
|
|
@@ -17,6 +21,7 @@ const df_helper_1 = require("../../graph/df-helper");
|
|
|
17
21
|
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
18
22
|
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
19
23
|
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
24
|
+
const r_unary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
20
25
|
const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
21
26
|
/**
|
|
22
27
|
* The {@link BuiltInEvalHandler} the given name resolves to in the current environment, just like the
|
|
@@ -24,21 +29,27 @@ const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/
|
|
|
24
29
|
* by a user definition or its built-in declares no handler.
|
|
25
30
|
*/
|
|
26
31
|
function evalHandlerOf(name, environment, ctx) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/* without an environment the search path is unknown, so what a package states about the name has its say */
|
|
30
|
-
: ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name))
|
|
31
|
-
?? ctx.env.statedDefinitionsOf(name);
|
|
32
|
+
/* without an environment the search path is unknown, so what a package states about the name has its say */
|
|
33
|
+
const defs = environment ? resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.BuiltInFunction) : builtInDefinitionsOf(name, ctx);
|
|
32
34
|
const def = defs?.length === 1 ? defs[0] : undefined;
|
|
33
35
|
return def?.type === identifier_1.ReferenceType.BuiltInFunction ? def.evalHandler : undefined;
|
|
34
36
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
+
function builtInDefinitionsOf(name, ctx) {
|
|
38
|
+
return ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name))
|
|
37
39
|
?? ctx.env.statedDefinitionsOf(name);
|
|
38
|
-
|
|
40
|
+
}
|
|
41
|
+
function foldsThroughBuiltIn(name, ctx) {
|
|
42
|
+
return builtInDefinitionsOf(name, ctx)?.some(d => d.type === identifier_1.ReferenceType.BuiltInFunction && d.evalHandler !== undefined) ?? false;
|
|
39
43
|
}
|
|
40
44
|
/** the node types that may fold through a built-in: calls, operators, and the `(`/`{` groupings */
|
|
41
45
|
const EvalNodeTypes = [type_1.RType.FunctionCall, type_1.RType.BinaryOp, type_1.RType.UnaryOp, type_1.RType.ExpressionList];
|
|
46
|
+
/** Whether the operator only combines literals (`1 + 2`), which alone fold while the analysis runs, as a name may still change its value. */
|
|
47
|
+
function onlyLiterals(node) {
|
|
48
|
+
return r_binary_op_1.RBinaryOp.is(node) ? onlyLiterals(node.lhs) && onlyLiterals(node.rhs)
|
|
49
|
+
: r_unary_op_1.RUnaryOp.is(node) ? onlyLiterals(node.operand)
|
|
50
|
+
: r_expression_list_1.RExpressionList.is(node) && node.grouping !== undefined && node.children.length === 1 ? onlyLiterals(node.children[0])
|
|
51
|
+
: r_number_1.RNumber.is(node) || r_string_1.RString.is(node) || r_logical_1.RLogical.is(node);
|
|
52
|
+
}
|
|
42
53
|
/**
|
|
43
54
|
* The name of the built-in the given node folds through, `undefined` if it is no call to one or if it may just
|
|
44
55
|
* as well resolve to something else (a user redefinition, a conditional one, ...), which must not be folded.
|
|
@@ -49,7 +60,8 @@ function evalNameOf({ node, graph, environment, ctx }) {
|
|
|
49
60
|
}
|
|
50
61
|
else if (graph === undefined) {
|
|
51
62
|
const named = r_expression_list_1.RExpressionList.is(node) ? r_expression_list_1.RExpressionList.groupStart(node)?.content
|
|
52
|
-
: r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.content
|
|
63
|
+
: r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.content
|
|
64
|
+
: (r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node)) && onlyLiterals(node) ? identifier_1.Identifier.make(node.operator) : undefined;
|
|
53
65
|
return named !== undefined && environment !== undefined && foldsThroughBuiltIn(named, ctx)
|
|
54
66
|
&& resolve_helper_1.Resolve.isBuiltIn(named, environment, identifier_1.ReferenceType.Function) ? named : undefined;
|
|
55
67
|
}
|
|
@@ -114,11 +126,8 @@ function resolveAsSeq(args) {
|
|
|
114
126
|
}
|
|
115
127
|
const leftValue = (0, r_value_2.unliftRValue)(resolve_helper_1.Resolve.toValue(operator.lhs, args));
|
|
116
128
|
const rightValue = (0, r_value_2.unliftRValue)(resolve_helper_1.Resolve.toValue(operator.rhs, args));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return sequence === undefined ? r_value_3.Top : (0, vector_constants_1.vectorFrom)(sequence.map(scalar_constants_1.liftScalar));
|
|
120
|
-
}
|
|
121
|
-
return r_value_3.Top;
|
|
129
|
+
const sequence = (0, r_value_2.isRNumberValue)(leftValue) && (0, r_value_2.isRNumberValue)(rightValue) ? createNumberSequence(leftValue, rightValue) : undefined;
|
|
130
|
+
return sequence === undefined ? r_value_3.Top : (0, vector_constants_1.vectorFrom)(sequence.map(scalar_constants_1.liftScalar));
|
|
122
131
|
}
|
|
123
132
|
/**
|
|
124
133
|
* How many elements of a sequence are worth naming one by one. `1:148066` is a loop bound rather than a set of
|
package/dataflow/extractor.js
CHANGED
|
@@ -23,16 +23,22 @@ const edge_1 = require("./graph/edge");
|
|
|
23
23
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
24
24
|
const built_in_function_definition_1 = require("./internal/process/functions/call/built-in/built-in-function-definition");
|
|
25
25
|
const transitive_side_effects_1 = require("./internal/process/functions/call/built-in/transitive-side-effects");
|
|
26
|
+
const built_in_try_catch_1 = require("./internal/process/functions/call/built-in/built-in-try-catch");
|
|
27
|
+
const linker_1 = require("./internal/linker");
|
|
26
28
|
const flowr_file_1 = require("../project/context/flowr-file");
|
|
29
|
+
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
27
30
|
const vertex_1 = require("./graph/vertex");
|
|
28
31
|
const identifier_1 = require("./environments/identifier");
|
|
29
32
|
const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
30
|
-
const
|
|
33
|
+
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
34
|
+
const r_function_definition_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
31
35
|
const range_1 = require("../util/range");
|
|
32
36
|
const logger_1 = require("./logger");
|
|
33
37
|
const gas_1 = require("../gas");
|
|
34
38
|
const config_1 = require("../config");
|
|
35
39
|
const df_helper_1 = require("./graph/df-helper");
|
|
40
|
+
const built_in_ambient_state_1 = require("./internal/process/functions/call/built-in/built-in-ambient-state");
|
|
41
|
+
const unnamed_call_handling_1 = require("./internal/process/functions/call/unnamed-call-handling");
|
|
36
42
|
const built_in_proc_name_1 = require("./environments/built-in-proc-name");
|
|
37
43
|
const arrays_1 = require("../util/collections/arrays");
|
|
38
44
|
const defaultmap_1 = require("../util/collections/defaultmap");
|
|
@@ -42,6 +48,7 @@ const query_fn_props_1 = require("./environments/query-fn-props");
|
|
|
42
48
|
const resolve_helper_1 = require("./environments/resolve-helper");
|
|
43
49
|
const happens_before_1 = require("../control-flow/happens-before");
|
|
44
50
|
const assert_1 = require("../util/assert");
|
|
51
|
+
const frame_reflection_1 = require("./fn/frame-reflection");
|
|
45
52
|
/**
|
|
46
53
|
* The best friend of {@link produceDataFlowGraph} and {@link processDataflowFor}.
|
|
47
54
|
* Maps every {@link RType} in the normalized AST to a processor.
|
|
@@ -95,10 +102,7 @@ function linkEnvironmentArgumentsWrittenByCallee(graph, environment) {
|
|
|
95
102
|
if (!holdsEnvironment(graph, argument, environment)) {
|
|
96
103
|
continue;
|
|
97
104
|
}
|
|
98
|
-
for (const
|
|
99
|
-
if (!edge_1.DfEdge.includesType(handed, edge_1.EdgeType.Argument) || !vertex_1.DfgVertex.isFunctionCall(graph.getVertex(call))) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
105
|
+
for (const call of (0, frame_reflection_1.edgeSources)(graph, argument, edge_1.EdgeType.Argument).filter(c => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(c)))) {
|
|
102
106
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, call);
|
|
103
107
|
for (const write of writes) {
|
|
104
108
|
graph.addEdge(call, write, edge_1.EdgeType.Reads);
|
|
@@ -110,76 +114,151 @@ function linkEnvironmentArgumentsWrittenByCallee(graph, environment) {
|
|
|
110
114
|
}
|
|
111
115
|
function tracksAnyEnvironment(environment) {
|
|
112
116
|
for (let e = environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if ((0, identifier_1.hasEnvState)(def)) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
117
|
+
if (e.memory.values().some(defs => defs.some(identifier_1.hasEnvState))) {
|
|
118
|
+
return true;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
return false;
|
|
122
122
|
}
|
|
123
|
+
/** Collects, per parameter of `definition`, the replacements (`x$f <- v`) and the side-effecting calls in its body that write into it. */
|
|
123
124
|
function writesOfParameters(graph, definition, parameters, written, environment) {
|
|
124
125
|
for (const node of definition.subflow.graph) {
|
|
125
126
|
const vertex = graph.getVertex(node);
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
if (vertex_1.DfgVertex.isVariableDefinition(vertex) && vertex.par) {
|
|
128
|
+
const replacements = (0, frame_reflection_1.edgeTargets)(graph, node, edge_1.EdgeType.DefinedBy).filter(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Replacement));
|
|
129
|
+
for (const parameter of (0, frame_reflection_1.edgeTargets)(graph, node, edge_1.EdgeType.Reads).filter(t => parameters.has(t))) {
|
|
130
|
+
written.get(parameter).push(...replacements);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (vertex_1.DfgVertex.isFunctionCall(vertex) && graph.unknownSideEffects.has(node_id_1.NodeId.normalize(node))) {
|
|
134
|
+
for (const target of argsWithProp(vertex, (0, query_fn_props_1.callFnProps)(node, { graph, environment }), built_in_props_1.ArgProp.Written)) {
|
|
135
|
+
for (const reached of definitionsReachedBy(target, graph)) {
|
|
136
|
+
if (parameters.has(reached)) {
|
|
137
|
+
written.get(reached).push(node);
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function holdsEnvironment(graph, argument, environment) {
|
|
145
|
+
const node = graph.idMap?.get(argument);
|
|
146
|
+
return r_symbol_1.RSymbol.is(node) && (resolve_helper_1.Resolve.byName(node.content, environment)?.some(identifier_1.hasEnvState) ?? false);
|
|
147
|
+
}
|
|
148
|
+
function openReadsOfCalledFunctions(graph) {
|
|
149
|
+
const reads = new Map();
|
|
150
|
+
for (const [id, definition] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
151
|
+
if ((0, frame_reflection_1.edgeSources)(graph, id, edge_1.EdgeType.Calls).length > 0) {
|
|
152
|
+
for (const read of definition.subflow.in) {
|
|
153
|
+
if (read.name !== undefined && !built_in_ambient_state_1.AmbientStateName.is(read.name) && !identifier_1.Identifier.getName(read.name).startsWith(unnamed_call_handling_1.UnnamedFunctionCallPrefix)) {
|
|
154
|
+
reads.set(read.nodeId, read);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return [...reads.values()];
|
|
160
|
+
}
|
|
161
|
+
/** An active binding (`makeActiveBinding`) runs its function on every assignment to and read of the name, so each becomes a call of it. */
|
|
162
|
+
function callActiveBindings(graph) {
|
|
163
|
+
const bindings = new Map();
|
|
164
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
|
|
165
|
+
const fns = (0, frame_reflection_1.calledDefinitions)(graph, id);
|
|
166
|
+
if (fns.length > 0) {
|
|
167
|
+
bindings.set(id, fns);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (const [, ids] of bindings.size === 0 ? [] : (0, frame_reflection_1.definitionsByName)(graph).entries()) {
|
|
171
|
+
const fns = ids.flatMap(id => bindings.get(id) ?? []);
|
|
172
|
+
for (const id of fns.length === 0 ? [] : ids.filter(id => !bindings.has(id))) {
|
|
173
|
+
for (const assignment of (0, frame_reflection_1.edgeSources)(graph, id, edge_1.EdgeType.Returns).filter(a => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(a)))) {
|
|
174
|
+
for (const fn of fns) {
|
|
175
|
+
graph.addEdge(assignment, fn, edge_1.EdgeType.Calls);
|
|
176
|
+
graph.addEdge(id, fn, edge_1.EdgeType.Calls);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const isActiveBinding = (def) => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(def)) && (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.Calls).length > 0;
|
|
182
|
+
for (const id of graph.vertexIdsOfType(vertex_1.VertexType.Use)) {
|
|
183
|
+
const node = graph.idMap?.get(id);
|
|
184
|
+
if (r_symbol_1.RSymbol.is(node) && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).some(isActiveBinding)) {
|
|
185
|
+
graph.updateToFunctionCall({ tag: vertex_1.VertexType.FunctionCall, id, name: node.content, args: [], environment: undefined, onlyBuiltin: false, cds: graph.getVertex(id)?.cds, origin: [built_in_proc_name_1.BuiltInProcName.Function] });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** A call of what a closure returned that we could not link (`h2 <- h()` with `h` returning `sys.function()`) may run anything. */
|
|
190
|
+
function markCallsOfUnknownValues(graph, environment) {
|
|
191
|
+
const fromClosure = (def) => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(def))
|
|
192
|
+
&& (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.DefinedBy).some(c => (0, frame_reflection_1.calledDefinitions)(graph, c).length > 0);
|
|
193
|
+
for (const [id, call] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
194
|
+
if (!call.onlyBuiltin && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Calls).length === 0 && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).some(fromClosure)) {
|
|
195
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, id);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** `environment()` hands out the function's frame by reference, so the call reads every definition of the frame, a closure's `<<-` included. */
|
|
200
|
+
function readFramesThroughEnvironment(graph) {
|
|
201
|
+
const idMap = graph.idMap;
|
|
202
|
+
if (idMap === undefined) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const environmentCall = node_id_1.NodeId.toBuiltIn('environment');
|
|
206
|
+
const callsEnvironment = (id) => (0, frame_reflection_1.hasEdgeOfType)(graph, id, environmentCall, edge_1.EdgeType.Calls);
|
|
207
|
+
/* `environment(fn)` hands out the frame `fn` was created in */
|
|
208
|
+
const ofClosures = new defaultmap_1.DefaultMap(() => []);
|
|
209
|
+
for (const [id, call] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
210
|
+
const fn = call.args.length === 1 && callsEnvironment(id) ? graph_1.FunctionArgument.getReference(call.args[0]) : undefined;
|
|
211
|
+
for (const closure of fn === undefined ? [] : (0, linker_1.getAllLinkedFunctionDefinitions)(new Set([fn]), graph)[0]) {
|
|
212
|
+
const creator = model_1.RNode.strictlyEnclosingFunction(closure.id, idMap);
|
|
213
|
+
if (creator !== undefined) {
|
|
214
|
+
ofClosures.get(creator).push(id);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const [, definition] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
219
|
+
const frameCalls = ofClosures.get(definition.id);
|
|
220
|
+
if (frameCalls.length === 0 && !definition.subflow.graph.values().some(callsEnvironment)) {
|
|
136
221
|
continue;
|
|
137
222
|
}
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
for (const
|
|
141
|
-
|
|
142
|
-
|
|
223
|
+
/* the nested functions' bodies, too, where a closure may write the frame */
|
|
224
|
+
const within = [...definition.subflow.graph];
|
|
225
|
+
for (const id of within) {
|
|
226
|
+
const vertex = graph.getVertex(id);
|
|
227
|
+
if (vertex_1.DfgVertex.isFunctionDefinition(vertex) && vertex.id !== definition.id) {
|
|
228
|
+
within.push(...vertex.subflow.graph);
|
|
143
229
|
}
|
|
144
|
-
|
|
145
|
-
|
|
230
|
+
}
|
|
231
|
+
const definitions = [];
|
|
232
|
+
for (const id of new Set(within)) {
|
|
233
|
+
const vertex = graph.getVertex(id);
|
|
234
|
+
const own = model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is) === definition.id;
|
|
235
|
+
if (own && vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.args.length === 0 && callsEnvironment(id)) {
|
|
236
|
+
frameCalls.push(id);
|
|
237
|
+
}
|
|
238
|
+
else if (vertex_1.DfgVertex.isVariableDefinition(vertex) && !(id in definition.params)) {
|
|
239
|
+
/* a parameter is what the call binds, which reflecting on the frame already accounts for */
|
|
240
|
+
definitions.push({ id, own, name: node_id_1.NodeId.recoverName(id, idMap) });
|
|
146
241
|
}
|
|
147
242
|
}
|
|
148
|
-
|
|
149
|
-
|
|
243
|
+
const local = new Set(definitions.filter(d => d.own && d.name !== undefined).map(d => d.name));
|
|
244
|
+
/* a nested definition writes this frame only by `<<-` to a name it binds */
|
|
245
|
+
const bySuperAssignment = (id) => vertex_1.DfgVertex.hasOrigin(graph.getVertex(idMap.get(id)?.info.parent ?? ''), built_in_proc_name_1.BuiltInProcName.SuperAssignment);
|
|
246
|
+
for (const d of definitions.filter(d => local.has(d.name ?? '') && (d.own || bySuperAssignment(d.id)))) {
|
|
247
|
+
for (const call of frameCalls) {
|
|
248
|
+
graph.addEdge(call, d.id, edge_1.EdgeType.Reads);
|
|
249
|
+
}
|
|
150
250
|
}
|
|
151
251
|
}
|
|
152
252
|
}
|
|
153
253
|
function argsWithProp(vertex, info, prop) {
|
|
154
254
|
return info?.sig === undefined ? [] : match_args_1.MatchArgs.findWithProps(vertex.args, info.sig, prop);
|
|
155
255
|
}
|
|
156
|
-
function holdsEnvironment(graph, argument, environment) {
|
|
157
|
-
const node = graph.idMap?.get(argument);
|
|
158
|
-
if (!r_symbol_1.RSymbol.is(node)) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
return (resolve_helper_1.Resolve.byName(node.content, environment) ?? [])
|
|
162
|
-
.some(identifier_1.hasEnvState);
|
|
163
|
-
}
|
|
164
256
|
function definitionsReachedBy(node, graph) {
|
|
165
257
|
return df_helper_1.Dataflow.reachable(graph, node, {
|
|
166
258
|
follow: edge_1.EdgeType.Reads,
|
|
167
259
|
stopAt: id => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(id))
|
|
168
260
|
});
|
|
169
261
|
}
|
|
170
|
-
function sameResource(a, b, reachedBy, pathOf) {
|
|
171
|
-
if (a === b) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
const reachedByA = reachedBy(a);
|
|
175
|
-
for (const t of reachedBy(b)) {
|
|
176
|
-
if (reachedByA.has(t)) {
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const path = pathOf(a);
|
|
181
|
-
return path !== undefined && path === pathOf(b);
|
|
182
|
-
}
|
|
183
262
|
function fileCallNames(index) {
|
|
184
263
|
return new Set(index.with(built_in_props_1.SemanticCallTag.File).map(identifier_1.Identifier.getName));
|
|
185
264
|
}
|
|
@@ -211,10 +290,10 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
|
|
|
211
290
|
continue;
|
|
212
291
|
}
|
|
213
292
|
const resource = argsWithProp(vertex, info, built_in_props_1.ArgProp.Resource)[0];
|
|
214
|
-
|
|
215
|
-
|
|
293
|
+
/* writing to the console names no file, and neither does a reader we cannot pin down */
|
|
294
|
+
if (resource !== undefined) {
|
|
295
|
+
(reads ? readers : writers).push({ id, resource });
|
|
216
296
|
}
|
|
217
|
-
(reads ? readers : writers).push({ id, resource });
|
|
218
297
|
}
|
|
219
298
|
if (readers.length === 0 || writers.length === 0) {
|
|
220
299
|
return;
|
|
@@ -222,16 +301,49 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
|
|
|
222
301
|
const reachedBy = (0, defaultmap_1.memoize)((id) => definitionsReachedBy(id, graph));
|
|
223
302
|
const where = { graph, idMap: graph.idMap, resolve: ctx.config.solver.variables, ctx, environment };
|
|
224
303
|
const pathOf = (0, defaultmap_1.memoize)((id) => resolve_helper_1.Resolve.toSingleString(id, where));
|
|
304
|
+
const sameResource = (a, b) => {
|
|
305
|
+
if (a === b || reachedBy(b).values().some(t => reachedBy(a).has(t))) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const path = pathOf(a);
|
|
309
|
+
return path !== undefined && path === pathOf(b);
|
|
310
|
+
};
|
|
225
311
|
let cfg;
|
|
226
312
|
for (const reader of readers) {
|
|
227
313
|
let before;
|
|
228
314
|
for (const writer of writers) {
|
|
229
|
-
if (reader.id === writer.id || !sameResource(reader.resource, writer.resource
|
|
315
|
+
if (reader.id === writer.id || !sameResource(reader.resource, writer.resource)) {
|
|
230
316
|
continue;
|
|
231
317
|
}
|
|
232
318
|
before ??= (0, happens_before_1.reachableTo)(cfg ??= new control_flow_graph_1.ControlFlowGraph(graph), [reader.id]);
|
|
233
319
|
if (before.has(writer.id)) {
|
|
234
320
|
graph.addEdge(reader.id, writer.id, edge_1.EdgeType.Reads);
|
|
321
|
+
/* whatever is linked to a diverting writer (`print` after `sink(file)`) writes to the resource as well */
|
|
322
|
+
for (const id of (0, frame_reflection_1.edgeSources)(graph, writer.id, edge_1.EdgeType.Reads)) {
|
|
323
|
+
graph.addEdge(reader.id, id, edge_1.EdgeType.Reads);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** A variable read linked to a call diverting the output (`sink(con)`, see `AmbientStateName.textConnection`) also reads what that call diverts. */
|
|
330
|
+
function linkReadsOfDivertedOutput(graph, environment) {
|
|
331
|
+
if (!(0, built_in_ambient_state_1.mayForce)(environment)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const printsOf = (0, defaultmap_1.memoize)((id) => function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(id, { graph, environment }), [built_in_props_1.SemanticCallTag.Prints]));
|
|
335
|
+
const printingCall = (writer) => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(writer)) && printsOf(writer);
|
|
336
|
+
const writersOf = (0, defaultmap_1.memoize)((target) => (0, frame_reflection_1.edgeSources)(graph, target, edge_1.EdgeType.Reads).filter(printingCall));
|
|
337
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.Use)) {
|
|
338
|
+
for (const target of (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads)) {
|
|
339
|
+
const diverting = graph.getVertex(target);
|
|
340
|
+
if (!vertex_1.DfgVertex.isFunctionCall(diverting) || diverting.args.length === 0) {
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
for (const writer of writersOf(target)) {
|
|
344
|
+
if (writer !== id) {
|
|
345
|
+
graph.addEdge(id, writer, edge_1.EdgeType.Reads);
|
|
346
|
+
}
|
|
235
347
|
}
|
|
236
348
|
}
|
|
237
349
|
}
|
|
@@ -240,12 +352,12 @@ function resolveLinkToSideEffects(graph, ctx) {
|
|
|
240
352
|
const gasLevel = ctx.gas.checkGas(gas_1.GasFeatureKey.SideEffectLinking);
|
|
241
353
|
if (gasLevel >= 2 /* GasLevel.Critical */) {
|
|
242
354
|
logger_1.dataflowLogger.warn('Skipping side-effect link resolution due to resource pressure (gas: critical). See ' + gas_1.GasWikiRef);
|
|
243
|
-
return
|
|
355
|
+
return;
|
|
244
356
|
}
|
|
245
357
|
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
246
358
|
logger_1.dataflowLogger.warn('Approaching resource limits during side-effect link resolution (gas: problematic). See ' + gas_1.GasWikiRef);
|
|
247
359
|
}
|
|
248
|
-
let cf
|
|
360
|
+
let cf;
|
|
249
361
|
let knownCalls;
|
|
250
362
|
let allCallNames = [];
|
|
251
363
|
const killedRegexes = new Set();
|
|
@@ -268,11 +380,10 @@ function resolveLinkToSideEffects(graph, ctx) {
|
|
|
268
380
|
handled.add(s.id);
|
|
269
381
|
const regexKey = s.linkTo.callName.source + '//' + s.linkTo.callName.flags;
|
|
270
382
|
if (killedRegexes.has(regexKey)) {
|
|
271
|
-
// we already know we will not find it!
|
|
272
383
|
continue;
|
|
273
384
|
}
|
|
274
385
|
else if (allCallNames.length > 0 && !allCallNames.some(name => s.linkTo.callName.test(name))) {
|
|
275
|
-
|
|
386
|
+
/* we know no call matches the regex */
|
|
276
387
|
killedRegexes.add(regexKey);
|
|
277
388
|
continue;
|
|
278
389
|
}
|
|
@@ -326,13 +437,17 @@ function extractDataFlowGraph(parser, completeAst, ctx) {
|
|
|
326
437
|
df = (0, built_in_source_1.standaloneSourceFile)(i, files[i], dfData, df);
|
|
327
438
|
}
|
|
328
439
|
// resolve linkages and propagate transitive side effects across calls to a fixpoint
|
|
440
|
+
callActiveBindings(df.graph);
|
|
441
|
+
readFramesThroughEnvironment(df.graph);
|
|
329
442
|
(0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment, ctx);
|
|
330
443
|
const escapedNames = new Set();
|
|
331
444
|
/* carried across the rounds, so a definition already folded in does not read as growth again */
|
|
332
445
|
const foldedIn = new Set();
|
|
333
446
|
const rounds = ctx.config.solver.transitiveSideEffectRounds ?? config_1.DefaultTransitiveSideEffectRounds;
|
|
447
|
+
/* a read of the options or graphics state nothing set reads the state R starts with, unless a write escaping a call replaces it */
|
|
448
|
+
const [initialState, open] = (0, arrays_1.partitionArray)(df.in, r => built_in_ambient_state_1.AmbientStateName.is(r.name));
|
|
334
449
|
for (let round = 0; round < rounds; round++) {
|
|
335
|
-
const { environment, grew, escapedNames: roundNames } = df_helper_1.Dataflow.sideEffects.propagateTransitive(df.graph, df.environment, ctx, foldedIn);
|
|
450
|
+
const { environment, grew, escapedNames: roundNames } = df_helper_1.Dataflow.sideEffects.propagateTransitive(df.graph, df.environment, ctx, foldedIn, initialState);
|
|
336
451
|
df.environment = environment;
|
|
337
452
|
for (const n of roundNames) {
|
|
338
453
|
escapedNames.add(n);
|
|
@@ -342,16 +457,23 @@ function extractDataFlowGraph(parser, completeAst, ctx) {
|
|
|
342
457
|
}
|
|
343
458
|
(0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment, ctx);
|
|
344
459
|
}
|
|
460
|
+
markCallsOfUnknownValues(df.graph, df.environment);
|
|
461
|
+
df.in = open.concat(openReadsOfCalledFunctions(df.graph));
|
|
345
462
|
// resolve top-level reads that now see the escaped `<<-` definitions folded in above
|
|
346
463
|
if (escapedNames.size > 0) {
|
|
347
464
|
(0, transitive_side_effects_1.reResolveOpenReferences)(df.graph, df.environment, [...df.in, ...df.unknownReferences], escapedNames);
|
|
348
465
|
}
|
|
349
466
|
// link on-demand-materialized package exports back to their `library()` loaders
|
|
350
467
|
(0, transitive_side_effects_1.linkMaterializedExportsToLoaders)(df.graph, df.environment);
|
|
468
|
+
const cleanEnvironment = ctx.env.makeCleanEnv();
|
|
469
|
+
(0, linker_1.separateClosureInstances)(df.graph, name => (0, query_fn_props_1.queryFnProps)(name, { environment: cleanEnvironment }));
|
|
351
470
|
function_semantics_1.FunctionSemantics.call.quoted.finalize(df.graph, df.environment, completeAst.idMap, () => new control_flow_graph_1.ControlFlowGraph(df.graph));
|
|
471
|
+
(0, built_in_try_catch_1.orderRaisingBodies)(df.graph, completeAst.idMap, ctx);
|
|
472
|
+
function_semantics_1.FunctionSemantics.settleJumpsInPromises(df.graph, df.exitPoints, { ctx });
|
|
352
473
|
linkEnvironmentArgumentsWrittenByCallee(df.graph, df.environment);
|
|
353
|
-
linkResourceReadersToWriters(df.graph, df.environment, ctx);
|
|
354
474
|
resolveLinkToSideEffects(df.graph, ctx);
|
|
475
|
+
linkResourceReadersToWriters(df.graph, df.environment, ctx);
|
|
476
|
+
linkReadsOfDivertedOutput(df.graph, df.environment);
|
|
355
477
|
return df;
|
|
356
478
|
}
|
|
357
479
|
//# sourceMappingURL=extractor.js.map
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* which argument means what is configured per built-in in {@link ClassDeclarationConfig}, not guessed.
|
|
4
4
|
*/
|
|
5
5
|
import type { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
6
|
-
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
|
-
import
|
|
6
|
+
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import { type PotentiallyEmptyRArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
9
9
|
import type { DataflowGraph } from '../graph/graph';
|
|
10
10
|
import type { SigClassInfo } from '../../project/sigdb/schema';
|
|
11
|
+
import type { ResolveInfo } from '../eval/resolve/alias-tracking';
|
|
11
12
|
/** The object system a declaration belongs to. */
|
|
12
13
|
export declare const enum ClassSystem {
|
|
13
14
|
/** `setClass`, `setClassUnion`, `setIs`, `setValidity` */
|
|
@@ -89,13 +90,6 @@ export interface ClassDeclarationConfig {
|
|
|
89
90
|
}
|
|
90
91
|
/** The argument `ref` names, by name when the call gives one and by position among the unnamed ones otherwise. */
|
|
91
92
|
export declare function argForImpl<Info>(args: readonly PotentiallyEmptyRArgument<Info & ParentInformation>[], ref: ClassArgRef | undefined): RNode<Info & ParentInformation> | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* The argument `ref` names, by name when the call gives one and by position among the unnamed ones otherwise.
|
|
94
|
-
* Exported so `built-in-s-four.ts` can drop its own copy of this instead of hand-rolling it again; that file
|
|
95
|
-
* already imports {@link ClassArgRef} from here, so the reverse import would cycle.
|
|
96
|
-
* @deprecated use {@link argForImpl} instead
|
|
97
|
-
*/
|
|
98
|
-
export declare function argFor<Info>(args: readonly PotentiallyEmptyRArgument<Info & ParentInformation>[], ref: ClassArgRef | undefined): RNode<Info & ParentInformation> | undefined;
|
|
99
93
|
/**
|
|
100
94
|
* Reads the {@link ClassDeclaration} a call states, following the argument mapping its built-in declares.
|
|
101
95
|
* An argument that resolves to no literal contributes a {@link ClassDeclaration.byVariable|by-variable} name, or nothing.
|
|
@@ -110,8 +104,6 @@ export interface DeclaredClass extends ClassDeclaration {
|
|
|
110
104
|
}
|
|
111
105
|
/** Every class the graph declares, keyed by name. A later declaration of the same name wins, as it would in R. */
|
|
112
106
|
export declare function declaredClassesImpl(graph: DataflowGraph): Map<string, DeclaredClass>;
|
|
113
|
-
/** @deprecated use {@link declaredClassesImpl} instead */
|
|
114
|
-
export declare function declaredClasses(graph: DataflowGraph): Map<string, DeclaredClass>;
|
|
115
107
|
/**
|
|
116
108
|
* The transitive superclasses of `name` among `classes`, nearest first and each named once. A class the
|
|
117
109
|
* analysis never saw declared ends the chain, so what another package contributes is simply not in the answer.
|
|
@@ -122,5 +114,8 @@ export declare function superClassesOfImpl(name: string, classes: ReadonlyMap<st
|
|
|
122
114
|
* the analysis declared carries no `package`; a referenced class `ownerOf` can place becomes a `foreign` record.
|
|
123
115
|
*/
|
|
124
116
|
export declare function toSigClassesImpl(classes: ReadonlyMap<string, DeclaredClass>, ownerOf?: (name: string) => string | undefined): SigClassInfo[];
|
|
125
|
-
/**
|
|
126
|
-
export declare function
|
|
117
|
+
/** The class vectors S3 dispatch may see for the argument at `id`, one per reaching definition, `undefined` unless all are known. */
|
|
118
|
+
export declare function s3DispatchClassesOf(id: NodeId, info: ResolveInfo & {
|
|
119
|
+
readonly graph: DataflowGraph;
|
|
120
|
+
readonly idMap: AstIdMap;
|
|
121
|
+
}): readonly (readonly string[])[] | undefined;
|