@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
|
@@ -4,7 +4,7 @@ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
4
4
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
5
|
import type { DataflowInformation } from '../../../../../info';
|
|
6
6
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
7
|
-
import { type ClassArgRef
|
|
7
|
+
import { type ClassArgRef } from '../../../../../fn/class-declaration';
|
|
8
8
|
import { type Identifier } from '../../../../../environments/identifier';
|
|
9
9
|
/** shorthand for the decorated-info generics every helper below carries through */
|
|
10
10
|
type Data<O> = DataflowProcessorInformation<O & ParentInformation>;
|
|
@@ -15,17 +15,19 @@ export declare function s4ClassName(cls: string): Identifier;
|
|
|
15
15
|
export interface S4UseConfig {
|
|
16
16
|
/** the argument naming the S4 generic the call answers or asks about (`f` in `setMethod`) */
|
|
17
17
|
readonly genericArg?: ClassArgRef;
|
|
18
|
+
/** appended to the generic named by {@link genericArg} (`setReplaceMethod("f", ...)` answers `f<-`) */
|
|
19
|
+
readonly genericSuffix?: string;
|
|
18
20
|
/** the arguments naming S4 classes the call uses (`Class` in `new`, `signature` in `setMethod`) */
|
|
19
21
|
readonly classArgs?: readonly ClassArgRef[];
|
|
20
22
|
/** the argument naming an S4 class the call adds to without declaring it (`to` in `setAs`): read and registered anew, so a later use depends on this call as well as on the declaration */
|
|
21
23
|
readonly registersArg?: ClassArgRef;
|
|
22
24
|
}
|
|
23
|
-
export { argFor };
|
|
24
25
|
/** wires the S4 registrations a call *uses* (the classes and generic its arguments name by string), read against the registry so the call depends on whatever `setClass`/`setGeneric` wrote them */
|
|
25
26
|
export declare function linkS4Uses<O>(info: DataflowInformation, args: Args<O>, rootId: NodeId, data: Data<O>, config: S4UseConfig): void;
|
|
26
|
-
/** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
|
|
27
|
+
/** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 and Reference Classes only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
|
|
27
28
|
export declare function linkS4Declaration<O>(info: DataflowInformation, rootId: NodeId, data: Data<O>): void;
|
|
28
29
|
/** Records that the call registers the S4 generics it names, which `setMethod` and a call of the name depend on. */
|
|
29
30
|
export declare function linkS4Generic<O>(info: DataflowInformation, rootId: NodeId, names: readonly string[], data: Data<O>): void;
|
|
30
31
|
/** Processes a call that consumes S4 registrations without declaring any, like `new("P")` or `getMethod("f", "P")`. */
|
|
31
32
|
export declare function processS4Use<O>(name: RSymbol<O & ParentInformation>, args: Args<O>, rootId: NodeId, data: Data<O>, config: S4UseConfig): DataflowInformation;
|
|
33
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.argFor = void 0;
|
|
4
3
|
exports.s4ClassName = s4ClassName;
|
|
5
4
|
exports.linkS4Uses = linkS4Uses;
|
|
6
5
|
exports.linkS4Declaration = linkS4Declaration;
|
|
@@ -9,7 +8,6 @@ exports.processS4Use = processS4Use;
|
|
|
9
8
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
9
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
11
10
|
const class_declaration_1 = require("../../../../../fn/class-declaration");
|
|
12
|
-
Object.defineProperty(exports, "argFor", { enumerable: true, get: function () { return class_declaration_1.argFor; } });
|
|
13
11
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
14
12
|
const define_1 = require("../../../../../environments/define");
|
|
15
13
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
@@ -24,29 +22,16 @@ function s4ClassName(cls) {
|
|
|
24
22
|
}
|
|
25
23
|
/** The names an argument states, looking through the `c(...)`/`signature(...)` wrappers a signature may use. */
|
|
26
24
|
function namesOf(node, data) {
|
|
27
|
-
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
const known = node_value_1.NodeValue.knownStringsOf(node.info.id, data);
|
|
25
|
+
const known = node === undefined ? [] : node_value_1.NodeValue.knownStringsOf(node.info.id, data);
|
|
31
26
|
if (known.length > 0 || !r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
32
27
|
return known;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
for (const arg of node.arguments) {
|
|
36
|
-
if (!r_argument_1.RArgument.isEmpty(arg) && arg.value !== undefined) {
|
|
37
|
-
collected.push(...namesOf(arg.value, data));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return collected;
|
|
29
|
+
return node.arguments.flatMap(arg => namesOf(r_argument_1.RArgument.valueOf(arg), data));
|
|
41
30
|
}
|
|
42
31
|
/** Adds a read of every given name to the call, so the call depends on whatever registered them. */
|
|
43
32
|
function readNames(info, rootId, names, type, data) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
added.push({ nodeId: rootId, name, type, cds: data.cds });
|
|
47
|
-
}
|
|
48
|
-
if (added.length > 0) {
|
|
49
|
-
info.in = [...info.in, ...added];
|
|
33
|
+
if (names.length > 0) {
|
|
34
|
+
info.in = [...info.in, ...names.map(name => ({ nodeId: rootId, name, type, cds: data.cds }))];
|
|
50
35
|
}
|
|
51
36
|
}
|
|
52
37
|
/** Defines `name` in the environment and records it as an out-reference of the call at `rootId`. */
|
|
@@ -57,24 +42,21 @@ function defineOut(info, rootId, name, type, data) {
|
|
|
57
42
|
/** wires the S4 registrations a call *uses* (the classes and generic its arguments name by string), read against the registry so the call depends on whatever `setClass`/`setGeneric` wrote them */
|
|
58
43
|
function linkS4Uses(info, args, rootId, data, config) {
|
|
59
44
|
for (const ref of config.classArgs ?? []) {
|
|
60
|
-
readNames(info, rootId, namesOf((0, class_declaration_1.
|
|
61
|
-
}
|
|
62
|
-
if (config.genericArg !== undefined) {
|
|
63
|
-
readNames(info, rootId, namesOf((0, class_declaration_1.argFor)(args, config.genericArg), data), identifier_1.ReferenceType.Function, data);
|
|
45
|
+
readNames(info, rootId, namesOf((0, class_declaration_1.argForImpl)(args, ref), data).map(s4ClassName), identifier_1.ReferenceType.Variable, data);
|
|
64
46
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
const generics = namesOf((0, class_declaration_1.argForImpl)(args, config.genericArg), data).map(n => n + (config.genericSuffix ?? ''));
|
|
48
|
+
readNames(info, rootId, generics, identifier_1.ReferenceType.Function, data);
|
|
49
|
+
const registered = namesOf((0, class_declaration_1.argForImpl)(args, config.registersArg), data).map(s4ClassName);
|
|
50
|
+
readNames(info, rootId, registered, identifier_1.ReferenceType.Variable, data);
|
|
51
|
+
for (const cls of registered) {
|
|
52
|
+
defineOut(info, rootId, cls, identifier_1.ReferenceType.Variable, data);
|
|
71
53
|
}
|
|
72
54
|
}
|
|
73
|
-
/** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
|
|
55
|
+
/** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 and Reference Classes only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
|
|
74
56
|
function linkS4Declaration(info, rootId, data) {
|
|
75
57
|
const vertex = info.graph.getVertex(rootId);
|
|
76
58
|
const decl = vertex_1.DfgVertex.isFunctionCall(vertex) ? vertex.classDecl : undefined;
|
|
77
|
-
if (decl === undefined || decl.system !== "s4" /* ClassSystem.S4 */) {
|
|
59
|
+
if (decl === undefined || (decl.system !== "s4" /* ClassSystem.S4 */ && decl.system !== "rc" /* ClassSystem.RefClass */)) {
|
|
78
60
|
return;
|
|
79
61
|
}
|
|
80
62
|
const used = [...decl.contains, ...(decl.union ?? []), ...decl.members.map(m => m.type).filter(t => t !== undefined)];
|
|
@@ -21,7 +21,7 @@ interface S7GenericDispatchConfig {
|
|
|
21
21
|
export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S7GenericDispatchConfig): DataflowInformation;
|
|
22
22
|
/**
|
|
23
23
|
* Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
|
|
24
|
-
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`,
|
|
24
|
+
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
|
|
25
25
|
* synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
|
|
26
26
|
* constant.
|
|
27
27
|
*/
|
|
@@ -14,11 +14,13 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
14
14
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
15
15
|
const assert_1 = require("../../../../../../util/assert");
|
|
16
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
17
18
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
18
19
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
19
20
|
const range_1 = require("../../../../../../util/range");
|
|
20
21
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
21
22
|
const built_in_s_four_1 = require("./built-in-s-four");
|
|
23
|
+
const class_declaration_1 = require("../../../../../fn/class-declaration");
|
|
22
24
|
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
23
25
|
/**
|
|
24
26
|
* Process an S7 new generic dispatch call like `new_generic` or `setGeneric`.
|
|
@@ -28,16 +30,15 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
28
30
|
logger_1.dataflowLogger.warn('empty s7 new_generic, skipping');
|
|
29
31
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
30
32
|
}
|
|
31
|
-
const
|
|
33
|
+
const { dispatchArg } = config.args;
|
|
34
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
|
|
32
35
|
[config.args.name]: 'name',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
|
|
40
|
-
const genName = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('name')?.[0]));
|
|
36
|
+
...dispatchArg ? { [dispatchArg]: 'dispatchArg' } : {},
|
|
37
|
+
[config.args.fun]: 'fun',
|
|
38
|
+
'...': '...'
|
|
39
|
+
});
|
|
40
|
+
const argNamed = (formal) => (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get(formal)?.[0]));
|
|
41
|
+
const genName = argNamed('name');
|
|
41
42
|
if (!genName) {
|
|
42
43
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
43
44
|
}
|
|
@@ -47,14 +48,12 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
47
48
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
48
49
|
}
|
|
49
50
|
data = { ...data, currentS7name: accessedIdentifiers };
|
|
50
|
-
let funArg = (
|
|
51
|
+
let funArg = argNamed('fun')?.info.id;
|
|
51
52
|
const effectiveArgs = args.slice();
|
|
52
53
|
if (!funArg) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
effectiveArgs.push(newFun[0]);
|
|
57
|
-
funArg = newFun[1];
|
|
54
|
+
const [fun, funId] = makeS7DispatchFDef(name, [argNamed('dispatchArg')?.lexeme], rootId, args.length, data.completeAst.idMap);
|
|
55
|
+
effectiveArgs.push(fun);
|
|
56
|
+
funArg = funId;
|
|
58
57
|
}
|
|
59
58
|
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, sig: function_semantics_1.FunctionSemantics.call.signature.every, args: effectiveArgs, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.S7NewGeneric }).information;
|
|
60
59
|
info.graph.addEdge(rootId, funArg, edge_1.EdgeType.Returns);
|
|
@@ -70,7 +69,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
|
|
|
70
69
|
}
|
|
71
70
|
/**
|
|
72
71
|
* Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
|
|
73
|
-
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`,
|
|
72
|
+
* `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
|
|
74
73
|
* synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
|
|
75
74
|
* constant.
|
|
76
75
|
*/
|
|
@@ -82,7 +81,8 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
82
81
|
info.entryPoint = funId;
|
|
83
82
|
const fArg = info.graph.getVertex(funId);
|
|
84
83
|
if (vertex_1.DfgVertex.isFunctionDefinition(fArg) && config?.mode) {
|
|
85
|
-
|
|
84
|
+
/* a copy, as the mode is mutated in place later and config.mode is shared */
|
|
85
|
+
fArg.mode ??= config.mode.slice();
|
|
86
86
|
}
|
|
87
87
|
if (config?.wrapIndex !== undefined) {
|
|
88
88
|
linkWrappedFunction(info, args, rootId, config.wrapIndex, config.wrapName, data);
|
|
@@ -93,25 +93,25 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
93
93
|
}
|
|
94
94
|
/** Records on the call vertex what a class-declaring call states, see {@link DataflowGraphVertexFunctionCall.classDecl}. */
|
|
95
95
|
function attachClassDeclaration(info, rootId, args, config) {
|
|
96
|
-
if (config === undefined) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
96
|
const vertex = info.graph.getVertex(rootId);
|
|
100
|
-
if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
97
|
+
if (config !== undefined && vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
101
98
|
vertex.classDecl = function_semantics_1.FunctionSemantics.classes.of(config, args);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
101
|
function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
105
|
-
const wrapped = (0,
|
|
106
|
-
|
|
102
|
+
const wrapped = (0, class_declaration_1.argForImpl)(args, { name: wrapName, idx: wrapIndex });
|
|
103
|
+
const resolved = wrapped === undefined ? undefined : (0, built_in_apply_1.resolveFunctionArgument)(wrapped, data, {});
|
|
104
|
+
if (resolved === undefined) {
|
|
107
105
|
return;
|
|
108
106
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const body = rootId + '-s7-new-generic-fun-body';
|
|
108
|
+
/* the wrapper runs what it wraps, so a call of it does what the wrapped function does */
|
|
109
|
+
const targets = resolved.anonymous ? [resolved.functionId] : (resolve_helper_1.Resolve.byNameAndType(resolved.functionName, data.environment, identifier_1.ReferenceType.Function) ?? [])
|
|
110
|
+
.flatMap(d => d.type === identifier_1.ReferenceType.BuiltInFunction ? [d.nodeId] : d.value ?? []);
|
|
111
|
+
for (const target of targets) {
|
|
112
|
+
info.graph.addEdge(body, target, edge_1.EdgeType.Calls);
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
if (!vertex_1.DfgVertex.isUse(vertex)) {
|
|
114
|
+
if (resolved.anonymous || !vertex_1.DfgVertex.isUse(info.graph.getVertex(resolved.functionId))) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
info.graph.updateToFunctionCall({
|
|
@@ -124,7 +124,7 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
|
124
124
|
cds: data.cds,
|
|
125
125
|
origin: [built_in_proc_name_1.BuiltInProcName.Function]
|
|
126
126
|
});
|
|
127
|
-
info.graph.addEdge(
|
|
127
|
+
info.graph.addEdge(body, resolved.functionId, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
@@ -132,41 +132,17 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
|
|
|
132
132
|
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
133
133
|
*/
|
|
134
134
|
exports.S7SyntheticFunArgSuffix = '-s7-new-generic-fun-arg';
|
|
135
|
-
|
|
135
|
+
/** Synthesizes the argument `fun = function([dispatch_args], ...) S7_dispatch()`, returning it and the id of its value. */
|
|
136
136
|
function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
137
|
-
const argNameId = rootId + '-s7-new-generic-fun-arg-name';
|
|
138
137
|
const r = name.location ?? range_1.SourceRange.invalid();
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
info: {
|
|
144
|
-
id: argNameId,
|
|
145
|
-
nest: name.info.nest,
|
|
146
|
-
role: "arg-n" /* RoleInParent.ArgumentName */,
|
|
147
|
-
fullRange: r,
|
|
148
|
-
adToks: undefined,
|
|
149
|
-
file: name.info.file,
|
|
150
|
-
parent: rootId,
|
|
151
|
-
index: 0
|
|
152
|
-
},
|
|
153
|
-
location: r,
|
|
154
|
-
};
|
|
155
|
-
idMap.set(argNameId, argName);
|
|
156
|
-
const funcNameId = rootId + '-s7-new-generic-fun-name';
|
|
138
|
+
const info = (id, role, parent, index = 0) => ({ id, nest: name.info.nest, role, fullRange: r, adToks: undefined, file: name.info.file, parent, index });
|
|
139
|
+
const symbol = (id, lexeme, role, parent, index = 0) => ({ type: type_1.RType.Symbol, lexeme, content: lexeme, info: info(id, role, parent, index), location: r });
|
|
140
|
+
const argName = symbol(rootId + '-s7-new-generic-fun-arg-name', 'fun', "arg-n" /* RoleInParent.ArgumentName */, rootId);
|
|
141
|
+
idMap.set(argName.info.id, argName);
|
|
157
142
|
const funcName = {
|
|
158
143
|
type: type_1.RType.Symbol,
|
|
159
144
|
lexeme: 'S7_dispatch',
|
|
160
|
-
info:
|
|
161
|
-
id: funcNameId,
|
|
162
|
-
nest: name.info.nest,
|
|
163
|
-
role: "call-name" /* RoleInParent.FunctionCallName */,
|
|
164
|
-
fullRange: r,
|
|
165
|
-
adToks: undefined,
|
|
166
|
-
file: name.info.file,
|
|
167
|
-
parent: rootId,
|
|
168
|
-
index: 0
|
|
169
|
-
},
|
|
145
|
+
info: info(rootId + '-s7-new-generic-fun-name', "call-name" /* RoleInParent.FunctionCallName */, rootId),
|
|
170
146
|
location: r,
|
|
171
147
|
content: identifier_1.Identifier.make('S7_dispatch', 'S7'),
|
|
172
148
|
};
|
|
@@ -177,51 +153,17 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
177
153
|
named: true,
|
|
178
154
|
functionName: funcName,
|
|
179
155
|
arguments: [],
|
|
180
|
-
info:
|
|
181
|
-
id: rootId + '-s7-new-generic-fun-body',
|
|
182
|
-
nest: name.info.nest,
|
|
183
|
-
role: "fun-b" /* RoleInParent.FunctionDefinitionBody */,
|
|
184
|
-
fullRange: r,
|
|
185
|
-
adToks: undefined,
|
|
186
|
-
file: name.info.file,
|
|
187
|
-
parent: rootId,
|
|
188
|
-
index: 0
|
|
189
|
-
}
|
|
156
|
+
info: info(rootId + '-s7-new-generic-fun-body', "fun-b" /* RoleInParent.FunctionDefinitionBody */, rootId)
|
|
190
157
|
};
|
|
191
158
|
const fdefId = rootId + '-s7-new-generic-fun-fdef';
|
|
192
159
|
const argValue = {
|
|
193
160
|
type: type_1.RType.FunctionDefinition,
|
|
194
|
-
info:
|
|
195
|
-
file: name.info.file,
|
|
196
|
-
id: fdefId,
|
|
197
|
-
nest: name.info.nest,
|
|
198
|
-
role: "arg-v" /* RoleInParent.ArgumentValue */,
|
|
199
|
-
parent: rootId,
|
|
200
|
-
index: args + 1,
|
|
201
|
-
adToks: undefined,
|
|
202
|
-
fullRange: r,
|
|
203
|
-
},
|
|
161
|
+
info: info(fdefId, "arg-v" /* RoleInParent.ArgumentValue */, rootId, args + 1),
|
|
204
162
|
lexeme: 'function',
|
|
205
163
|
location: r,
|
|
206
164
|
parameters: [...names.filter(assert_1.isNotUndefined), '...'].map((n, i) => {
|
|
207
165
|
const paramId = fdefId + `-param-${i}`;
|
|
208
|
-
const
|
|
209
|
-
const paramName = {
|
|
210
|
-
type: type_1.RType.Symbol,
|
|
211
|
-
lexeme: n,
|
|
212
|
-
content: n,
|
|
213
|
-
info: {
|
|
214
|
-
id: paramNameId,
|
|
215
|
-
nest: name.info.nest,
|
|
216
|
-
role: "param-n" /* RoleInParent.ParameterName */,
|
|
217
|
-
fullRange: r,
|
|
218
|
-
adToks: undefined,
|
|
219
|
-
file: name.info.file,
|
|
220
|
-
index: i,
|
|
221
|
-
parent: paramId
|
|
222
|
-
},
|
|
223
|
-
location: r,
|
|
224
|
-
};
|
|
166
|
+
const paramName = symbol(paramId + '-name', n, "param-n" /* RoleInParent.ParameterName */, paramId, i);
|
|
225
167
|
const param = {
|
|
226
168
|
type: type_1.RType.Parameter,
|
|
227
169
|
location: r,
|
|
@@ -229,41 +171,22 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
229
171
|
name: paramName,
|
|
230
172
|
defaultValue: undefined,
|
|
231
173
|
special: n === '...',
|
|
232
|
-
info:
|
|
233
|
-
id: paramId,
|
|
234
|
-
nest: name.info.nest,
|
|
235
|
-
role: "param" /* RoleInParent.FunctionDefinitionParameter */,
|
|
236
|
-
parent: fdefId,
|
|
237
|
-
index: i,
|
|
238
|
-
adToks: undefined,
|
|
239
|
-
file: name.info.file,
|
|
240
|
-
fullRange: r,
|
|
241
|
-
}
|
|
174
|
+
info: info(paramId, "param" /* RoleInParent.FunctionDefinitionParameter */, fdefId, i)
|
|
242
175
|
};
|
|
243
|
-
idMap.set(
|
|
176
|
+
idMap.set(paramName.info.id, paramName);
|
|
244
177
|
idMap.set(paramId, param);
|
|
245
178
|
return param;
|
|
246
179
|
}),
|
|
247
180
|
body: funcBody,
|
|
248
181
|
};
|
|
249
|
-
idMap.set(
|
|
182
|
+
idMap.set(funcName.info.id, funcName);
|
|
250
183
|
idMap.set(funcBody.info.id, funcBody);
|
|
251
184
|
idMap.set(fdefId, argValue);
|
|
252
|
-
const argId = rootId + exports.S7SyntheticFunArgSuffix;
|
|
253
185
|
const argument = {
|
|
254
186
|
type: type_1.RType.Argument,
|
|
255
187
|
lexeme: 'fun',
|
|
256
188
|
location: r,
|
|
257
|
-
info:
|
|
258
|
-
id: argId,
|
|
259
|
-
nest: name.info.nest,
|
|
260
|
-
role: "call-arg" /* RoleInParent.FunctionCallArgument */,
|
|
261
|
-
fullRange: r,
|
|
262
|
-
adToks: undefined,
|
|
263
|
-
file: name.info.file,
|
|
264
|
-
parent: rootId,
|
|
265
|
-
index: args + 1
|
|
266
|
-
},
|
|
189
|
+
info: info(rootId + exports.S7SyntheticFunArgSuffix, "call-arg" /* RoleInParent.FunctionCallArgument */, rootId, args + 1),
|
|
267
190
|
name: argName,
|
|
268
191
|
value: argValue
|
|
269
192
|
};
|
|
@@ -13,8 +13,6 @@ interface S3DispatchConfig {
|
|
|
13
13
|
/** For NextMethod/if `generic` is not given, try to infer from the closure? */
|
|
14
14
|
inferFromClosure?: boolean;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Process an S3 dispatch call like `UseMethod`.
|
|
18
|
-
*/
|
|
16
|
+
/** Process an S3 dispatch call like `UseMethod`. */
|
|
19
17
|
export declare function processS3Dispatch<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S3DispatchConfig): DataflowInformation;
|
|
20
18
|
export {};
|
|
@@ -9,33 +9,34 @@ const logger_1 = require("../../../../../logger");
|
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
11
11
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
12
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
12
13
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
14
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
14
15
|
const range_1 = require("../../../../../../util/range");
|
|
15
16
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
17
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
17
18
|
const control_flow_1 = require("../../../../control-flow");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
19
|
+
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
20
|
+
const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
21
|
+
/** Process an S3 dispatch call like `UseMethod`. */
|
|
21
22
|
function processS3Dispatch(name, args, rootId, data, config) {
|
|
22
23
|
if (args.length === 0 && !config.inferFromClosure) {
|
|
23
24
|
logger_1.dataflowLogger.warn('empty s3, skipping');
|
|
24
25
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
+
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
|
|
27
28
|
[config.args.generic]: 'generic',
|
|
28
29
|
[config.args.object]: 'object',
|
|
29
30
|
'...': '...'
|
|
30
|
-
};
|
|
31
|
-
const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
|
|
31
|
+
});
|
|
32
32
|
const generic = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('generic')?.[0]));
|
|
33
33
|
if (!generic && !config.inferFromClosure) {
|
|
34
34
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
35
35
|
}
|
|
36
36
|
const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
|
|
37
37
|
const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : info_1.DataflowInformation.initialize(rootId, data);
|
|
38
|
-
|
|
38
|
+
const fnRef = { nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function };
|
|
39
|
+
if (control_flow_1.ControlFlow.alwaysExits(dfObj, data.cds)) {
|
|
39
40
|
(0, common_1.patchFunctionCall)({
|
|
40
41
|
nextGraph: dfObj.graph,
|
|
41
42
|
rootId,
|
|
@@ -55,18 +56,20 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
55
56
|
argumentProcessResult: [dfObj],
|
|
56
57
|
origin: built_in_proc_name_1.BuiltInProcName.S3DispatchNext
|
|
57
58
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
59
|
+
/* the next method receives the current values of the formals of the method it is called from */
|
|
60
|
+
const idMap = data.completeAst.idMap;
|
|
61
|
+
const enclosing = idMap.get(model_1.RNode.findEnclosing(rootId, idMap, r_function_definition_1.RFunctionDefinition.is) ?? rootId);
|
|
62
|
+
const formals = r_function_definition_1.RFunctionDefinition.is(enclosing) ? enclosing.parameters : [];
|
|
63
|
+
const formalReads = formals.map(param => ({ nodeId: rootId, name: param.name.content, cds: data.cds, type: identifier_1.ReferenceType.Variable }));
|
|
61
64
|
return {
|
|
62
65
|
hooks: dfObj.hooks,
|
|
63
66
|
environment: dfObj.environment,
|
|
64
67
|
exitPoints: dfObj.exitPoints,
|
|
65
68
|
graph: dfObj.graph,
|
|
66
69
|
entryPoint: rootId,
|
|
67
|
-
cfgEntry,
|
|
70
|
+
cfgEntry: control_flow_1.ControlFlow.inSequence(dfObj.graph, [dfObj], rootId),
|
|
68
71
|
cfgExit: rootId,
|
|
69
|
-
in:
|
|
72
|
+
in: [...dfObj.in, ...dfObj.unknownReferences, fnRef, ...formalReads],
|
|
70
73
|
out: dfObj.out,
|
|
71
74
|
unknownReferences: []
|
|
72
75
|
};
|
|
@@ -100,22 +103,19 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
100
103
|
argumentProcessResult: [dfGeneric, dfObj],
|
|
101
104
|
origin: built_in_proc_name_1.BuiltInProcName.Function
|
|
102
105
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (const id of accessedIdentifiers) {
|
|
106
|
-
ingoing.push({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix });
|
|
107
|
-
}
|
|
106
|
+
/* the method runs only as the dispatch does */
|
|
107
|
+
dfGeneric.graph.addEdge(generic.info.id, rootId, edge_1.EdgeType.Reads);
|
|
108
108
|
const graph = dfObj.graph.mergeWith(dfGeneric.graph);
|
|
109
|
-
const
|
|
109
|
+
const methodPrefixes = accessedIdentifiers.map(id => ({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix }));
|
|
110
110
|
return {
|
|
111
|
-
hooks: dfGeneric.hooks.concat(dfObj
|
|
111
|
+
hooks: dfGeneric.hooks.concat(dfObj.hooks),
|
|
112
112
|
environment: dfGeneric.environment,
|
|
113
113
|
exitPoints: dfObj.exitPoints.concat(dfGeneric.exitPoints),
|
|
114
114
|
graph,
|
|
115
115
|
entryPoint: rootId,
|
|
116
|
-
cfgEntry,
|
|
116
|
+
cfgEntry: control_flow_1.ControlFlow.inSequence(graph, [dfGeneric, dfObj], rootId),
|
|
117
117
|
cfgExit: rootId,
|
|
118
|
-
in:
|
|
118
|
+
in: [...dfObj.in, ...dfGeneric.in, ...dfObj.unknownReferences, ...dfGeneric.unknownReferences, fnRef, ...methodPrefixes],
|
|
119
119
|
out: dfGeneric.out.concat(dfObj.out),
|
|
120
120
|
unknownReferences: []
|
|
121
121
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AmbientStateAccess } from './built-in-ambient-state';
|
|
1
2
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
2
3
|
import { DataflowInformation } from '../../../../../info';
|
|
3
4
|
import { type FlowrLaxSourcingOptions, InferWorkingDirectory } from '../../../../../../config';
|
|
@@ -40,6 +41,7 @@ export declare function processSourceCall<OtherInfo>(name: RSymbol<OtherInfo & P
|
|
|
40
41
|
includeFunctionCall?: boolean;
|
|
41
42
|
/** should this function call be followed, even when the configuration disables it? */
|
|
42
43
|
forceFollow?: boolean;
|
|
44
|
+
ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
43
45
|
}): DataflowInformation;
|
|
44
46
|
/**
|
|
45
47
|
* Processes a source request with the given dataflow processor information and existing dataflow information
|