@eagleoutice/flowr 2.10.8 → 2.10.10
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 +106 -36
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/script.js +3 -2
- package/cli/flowr.js +47 -10
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +25 -0
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/statistics-core.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +4 -1
- package/config.d.ts +9 -0
- package/config.js +23 -1
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/extract-cfg.js +9 -3
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/dataflow/environments/append.d.ts +2 -1
- package/dataflow/environments/append.js +2 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +122 -66
- package/dataflow/environments/default-builtin-config.js +324 -145
- package/dataflow/environments/environment.d.ts +2 -1
- package/dataflow/environments/environment.js +13 -9
- package/dataflow/environments/identifier.d.ts +55 -2
- package/dataflow/environments/identifier.js +14 -2
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.js +13 -7
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +22 -3
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +33 -0
- package/dataflow/graph/graph.js +7 -3
- package/dataflow/info.d.ts +1 -1
- package/dataflow/info.js +3 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +75 -57
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +119 -31
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +77 -76
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +19 -6
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +14 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +3 -3
- package/documentation/wiki-query.js +85 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +88 -86
- package/linter/linter-rules.js +7 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +6 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +3 -2
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-files-context.d.ts +12 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +3 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +7 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +63 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +600 -0
- package/search/search-executor/search-enrichers.js +23 -2
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/objects.d.ts +9 -0
- package/util/objects.js +57 -1
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +1 -1
|
@@ -47,7 +47,8 @@ export declare class Environment implements IEnvironment {
|
|
|
47
47
|
*/
|
|
48
48
|
get closure(): NodeId | undefined;
|
|
49
49
|
/**
|
|
50
|
-
* Create a
|
|
50
|
+
* Create a clone of this environment. Definition arrays and objects are copy-on-write
|
|
51
|
+
* (never mutated in place) and hence shared with the clone.
|
|
51
52
|
* @param recurseParents - Whether to also clone parent environments
|
|
52
53
|
*/
|
|
53
54
|
clone(recurseParents: boolean): Environment;
|
|
@@ -54,7 +54,8 @@ class Environment {
|
|
|
54
54
|
return this.c;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Create a
|
|
57
|
+
* Create a clone of this environment. Definition arrays and objects are copy-on-write
|
|
58
|
+
* (never mutated in place) and hence shared with the clone.
|
|
58
59
|
* @param recurseParents - Whether to also clone parent environments
|
|
59
60
|
*/
|
|
60
61
|
clone(recurseParents) {
|
|
@@ -65,13 +66,7 @@ class Environment {
|
|
|
65
66
|
const clone = new Environment(parent, this.builtInEnv);
|
|
66
67
|
clone.c = this.c;
|
|
67
68
|
clone.n = this.n;
|
|
68
|
-
clone.memory = new Map(this.memory
|
|
69
|
-
.map(([k, v]) => [k,
|
|
70
|
-
v.map(s => ({
|
|
71
|
-
...s,
|
|
72
|
-
cds: s.cds?.slice()
|
|
73
|
-
}))
|
|
74
|
-
]));
|
|
69
|
+
clone.memory = new Map(this.memory);
|
|
75
70
|
return clone;
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
@@ -83,6 +78,10 @@ class Environment {
|
|
|
83
78
|
if (ns !== undefined && this.n !== ns) {
|
|
84
79
|
return this.defineInNamespace(definition, ns);
|
|
85
80
|
}
|
|
81
|
+
/* isolate the cds from the originating reference, which may still be updated in place */
|
|
82
|
+
if (definition.cds !== undefined) {
|
|
83
|
+
definition = { ...definition, cds: definition.cds.slice() };
|
|
84
|
+
}
|
|
86
85
|
const newEnvironment = this.clone(false);
|
|
87
86
|
// When there are defined indices, merge the definitions
|
|
88
87
|
if (definition.cds === undefined) {
|
|
@@ -99,7 +98,8 @@ class Environment {
|
|
|
99
98
|
newEnvironment.memory.set(name, [definition]);
|
|
100
99
|
}
|
|
101
100
|
else {
|
|
102
|
-
|
|
101
|
+
/* the array may be shared with clones, so replace instead of push */
|
|
102
|
+
newEnvironment.memory.set(name, [...existing, definition]);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
return newEnvironment;
|
|
@@ -134,6 +134,10 @@ class Environment {
|
|
|
134
134
|
}
|
|
135
135
|
defineSuper(definition) {
|
|
136
136
|
const [name, ns] = identifier_1.Identifier.toArray(definition.name);
|
|
137
|
+
/* isolate the cds from the originating reference, see {@link define} */
|
|
138
|
+
if (definition.cds !== undefined) {
|
|
139
|
+
definition = { ...definition, cds: definition.cds.slice() };
|
|
140
|
+
}
|
|
137
141
|
const newEnvironment = this.clone(false);
|
|
138
142
|
if (ns !== undefined && this.n !== ns) {
|
|
139
143
|
newEnvironment.parent = newEnvironment.parent.defineInNamespace(definition, ns);
|
|
@@ -36,10 +36,20 @@ export type Identifier = BrandedIdentifier | [id: BrandedIdentifier, namespace:
|
|
|
36
36
|
export declare const Identifier: {
|
|
37
37
|
readonly name: "Identifier";
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* Creates an identifier. Strips surrounding backticks from the name.
|
|
40
|
+
* Prefer {@link Identifier.from} for static config entries where namespace is always present and name has no backticks.
|
|
41
41
|
*/
|
|
42
42
|
readonly make: (this: void, name: BrandedIdentifier, namespace?: BrandedNamespace, internal?: boolean) => Identifier;
|
|
43
|
+
/**
|
|
44
|
+
* Fast-path factory: returns the tuple as-is with no allocation or runtime checks.
|
|
45
|
+
* Use for static built-in config entries where name is a compile-time constant with no backticks.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* Identifier.from(['map', 'purrr']) // ['map', 'purrr']
|
|
49
|
+
* Identifier.from(['map', 'purrr', true]) // ['map', 'purrr', true]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
readonly from: (this: void, arr: [BrandedIdentifier, BrandedNamespace] | [BrandedIdentifier, BrandedNamespace, boolean]) => Identifier;
|
|
43
53
|
/**
|
|
44
54
|
* Verify whether an unknown element has a valid identifier shape!
|
|
45
55
|
*/
|
|
@@ -101,6 +111,49 @@ export declare const Identifier: {
|
|
|
101
111
|
*/
|
|
102
112
|
readonly toArray: (this: void, id: Identifier) => [BrandedIdentifier, BrandedNamespace | undefined, boolean | undefined];
|
|
103
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Well-known R package names used in {@link DefaultBuiltinConfig}.
|
|
116
|
+
* Using a const enum keeps the string values inlined at compile time.
|
|
117
|
+
*/
|
|
118
|
+
export declare const enum PkgName {
|
|
119
|
+
Base = "base",
|
|
120
|
+
Compiler = "compiler",
|
|
121
|
+
Graphics = "graphics",
|
|
122
|
+
GrDevices = "grDevices",
|
|
123
|
+
Methods = "methods",
|
|
124
|
+
Stats = "stats",
|
|
125
|
+
Utils = "utils",
|
|
126
|
+
AssertThat = "assertthat",
|
|
127
|
+
Cli = "cli",
|
|
128
|
+
DataTable = "data.table",
|
|
129
|
+
Devtools = "devtools",
|
|
130
|
+
Dplyr = "dplyr",
|
|
131
|
+
Fs = "fs",
|
|
132
|
+
Functools = "functools",
|
|
133
|
+
GgPlot2 = "ggplot2",
|
|
134
|
+
Import = "import",
|
|
135
|
+
Inferference = "inferference",
|
|
136
|
+
Janitor = "janitor",
|
|
137
|
+
Lattice = "lattice",
|
|
138
|
+
Magick = "magick",
|
|
139
|
+
Magrittr = "magrittr",
|
|
140
|
+
Msgr = "msgr",
|
|
141
|
+
PkgLoad = "pkgload",
|
|
142
|
+
Plyr = "plyr",
|
|
143
|
+
Purrr = "purrr",
|
|
144
|
+
Ragg = "ragg",
|
|
145
|
+
RasterPdf = "rasterpdf",
|
|
146
|
+
Remotes = "remotes",
|
|
147
|
+
Rlang = "rlang",
|
|
148
|
+
RmethodsS3 = "R.methodsS3",
|
|
149
|
+
Roo = "R.oo",
|
|
150
|
+
Rutils = "R.utils",
|
|
151
|
+
S7 = "S7",
|
|
152
|
+
Soda = "SoDA",
|
|
153
|
+
Testthat = "testthat",
|
|
154
|
+
TinyPlot = "tinyplot",
|
|
155
|
+
TryCatchLog = "tryCatchLog"
|
|
156
|
+
}
|
|
104
157
|
/**
|
|
105
158
|
* Each reference has exactly one reference type, stored as the respective number.
|
|
106
159
|
* However, when checking, we may want to allow for one of several types,
|
|
@@ -19,8 +19,8 @@ const dotDotDotAccess = /^\.\.\d+$/;
|
|
|
19
19
|
exports.Identifier = {
|
|
20
20
|
name: 'Identifier',
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Creates an identifier. Strips surrounding backticks from the name.
|
|
23
|
+
* Prefer {@link Identifier.from} for static config entries where namespace is always present and name has no backticks.
|
|
24
24
|
*/
|
|
25
25
|
make(name, namespace, internal = false) {
|
|
26
26
|
if ((0, strings_1.startAndEndsWith)(name, '`')) {
|
|
@@ -33,6 +33,18 @@ exports.Identifier = {
|
|
|
33
33
|
return name;
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* Fast-path factory: returns the tuple as-is with no allocation or runtime checks.
|
|
38
|
+
* Use for static built-in config entries where name is a compile-time constant with no backticks.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* Identifier.from(['map', 'purrr']) // ['map', 'purrr']
|
|
42
|
+
* Identifier.from(['map', 'purrr', true]) // ['map', 'purrr', true]
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
from(arr) {
|
|
46
|
+
return arr;
|
|
47
|
+
},
|
|
36
48
|
/**
|
|
37
49
|
* Verify whether an unknown element has a valid identifier shape!
|
|
38
50
|
*/
|
|
@@ -4,6 +4,8 @@ import type { ControlDependency } from '../info';
|
|
|
4
4
|
import type { REnvironmentInformation } from './environment';
|
|
5
5
|
/**
|
|
6
6
|
* Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
|
|
7
|
+
* With `includeDefs`, the cds are also attached (copy-on-write) to the definitions the reference
|
|
8
|
+
* resolves to, see {@link applyCdsToDefinitions}.
|
|
7
9
|
*/
|
|
8
10
|
export declare function makeReferenceMaybe(ref: IdentifierReference, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency[] | undefined): IdentifierReference;
|
|
9
11
|
/**
|
|
@@ -7,6 +7,7 @@ exports.applyCdToReferences = applyCdToReferences;
|
|
|
7
7
|
const identifier_1 = require("./identifier");
|
|
8
8
|
const resolve_by_name_1 = require("./resolve-by-name");
|
|
9
9
|
const vertex_1 = require("../graph/vertex");
|
|
10
|
+
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
10
11
|
function appToCdsUnique(target, toAdd) {
|
|
11
12
|
if (!toAdd) {
|
|
12
13
|
return;
|
|
@@ -43,22 +44,66 @@ function concatCdsUnique(target, toAdd) {
|
|
|
43
44
|
}
|
|
44
45
|
return result;
|
|
45
46
|
}
|
|
47
|
+
/** copy of the definition with the given cds attached */
|
|
48
|
+
function withAppliedCds(definition, defaultCd) {
|
|
49
|
+
return {
|
|
50
|
+
...definition,
|
|
51
|
+
cds: definition.cds ? concatCdsUnique(definition.cds, defaultCd) : (defaultCd ? Array.from(defaultCd) : [])
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** replaces the definitions stored under the given key by copies carrying the additional cds */
|
|
55
|
+
function replaceDefinitions(env, key, toUpdate, defaultCd) {
|
|
56
|
+
const defs = env.memory.get(key);
|
|
57
|
+
if (defs?.some(d => toUpdate.has(d))) {
|
|
58
|
+
env.memory.set(key, defs.map(d => toUpdate.has(d) ? withAppliedCds(d, defaultCd) : d));
|
|
59
|
+
}
|
|
60
|
+
env.cache?.delete(key);
|
|
61
|
+
}
|
|
46
62
|
/**
|
|
47
|
-
*
|
|
63
|
+
* Attaches the given control dependencies to the given definitions within the environment chain.
|
|
64
|
+
* Copy-on-write: definitions are replaced, never mutated in place, so previously cloned
|
|
65
|
+
* environments (e.g., snapshots stored in the dataflow graph) keep their state.
|
|
48
66
|
*/
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
function applyCdsToDefinitions(environments, name, type, definitions, defaultCd) {
|
|
68
|
+
const toUpdate = new Set();
|
|
69
|
+
for (const definition of definitions) {
|
|
70
|
+
if (definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant
|
|
71
|
+
&& (defaultCd !== undefined || definition.cds === undefined)) {
|
|
72
|
+
toUpdate.add(definition);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (toUpdate.size === 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const [plainName] = identifier_1.Identifier.toArray(name);
|
|
79
|
+
const prefix = type === identifier_1.ReferenceType.S3MethodPrefix ? plainName + '.'
|
|
80
|
+
: type === identifier_1.ReferenceType.S7MethodPrefix ? plainName + built_in_s_seven_dispatch_1.S7DispatchSeparator : undefined;
|
|
81
|
+
let current = environments.current;
|
|
82
|
+
while (!current.builtInEnv) {
|
|
83
|
+
if (prefix === undefined) {
|
|
84
|
+
replaceDefinitions(current, plainName, toUpdate, defaultCd);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
for (const key of [...current.memory.keys()]) {
|
|
88
|
+
if (key.startsWith(prefix)) {
|
|
89
|
+
replaceDefinitions(current, key, toUpdate, defaultCd);
|
|
59
90
|
}
|
|
60
91
|
}
|
|
61
92
|
}
|
|
93
|
+
current = current.parent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
|
|
98
|
+
* With `includeDefs`, the cds are also attached (copy-on-write) to the definitions the reference
|
|
99
|
+
* resolves to, see {@link applyCdsToDefinitions}.
|
|
100
|
+
*/
|
|
101
|
+
function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
|
|
102
|
+
if (includeDefs && ref.name) {
|
|
103
|
+
const definitions = (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type);
|
|
104
|
+
if (definitions && definitions.length > 0) {
|
|
105
|
+
applyCdsToDefinitions(environments, ref.name, ref.type, definitions, defaultCd);
|
|
106
|
+
}
|
|
62
107
|
}
|
|
63
108
|
const node = graph.getVertex(ref.nodeId);
|
|
64
109
|
if (node) {
|
|
@@ -90,9 +90,13 @@ function resolveByName(id, environment, target) {
|
|
|
90
90
|
*/
|
|
91
91
|
function resolveByNameAnyType(id, environment) {
|
|
92
92
|
let current = environment.current;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
/* only cache plain names: namespaced ids are arrays (no stable map key) and must not answer plain lookups */
|
|
94
|
+
const cacheable = typeof id === 'string';
|
|
95
|
+
if (cacheable) {
|
|
96
|
+
const g = current.cache?.get(id);
|
|
97
|
+
if (g !== undefined) {
|
|
98
|
+
return g;
|
|
99
|
+
}
|
|
96
100
|
}
|
|
97
101
|
const [name, ns, internal] = identifier_1.Identifier.toArray(id);
|
|
98
102
|
let definitions = undefined;
|
|
@@ -107,8 +111,10 @@ function resolveByNameAnyType(id, environment) {
|
|
|
107
111
|
definition = definition.filter(({ name }) => name === undefined || !identifier_1.Identifier.accessesInternal(name));
|
|
108
112
|
}
|
|
109
113
|
if (definition.every(d => (0, info_1.happensInEveryBranch)(d.cds))) {
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
if (cacheable) {
|
|
115
|
+
environment.current.cache ??= new Map();
|
|
116
|
+
environment.current.cache.set(id, definition);
|
|
117
|
+
}
|
|
112
118
|
return definition;
|
|
113
119
|
}
|
|
114
120
|
else if (definition.length > 0) {
|
|
@@ -130,9 +136,9 @@ function resolveByNameAnyType(id, environment) {
|
|
|
130
136
|
else {
|
|
131
137
|
ret = builtIns;
|
|
132
138
|
}
|
|
133
|
-
if (ret) {
|
|
139
|
+
if (ret && cacheable) {
|
|
134
140
|
environment.current.cache ??= new Map();
|
|
135
|
-
environment.current.cache
|
|
141
|
+
environment.current.cache.set(id, ret);
|
|
136
142
|
}
|
|
137
143
|
return ret;
|
|
138
144
|
}
|
|
@@ -9,6 +9,7 @@ const interval_constants_1 = require("./intervals/interval-constants");
|
|
|
9
9
|
const logical_constants_1 = require("./logical/logical-constants");
|
|
10
10
|
const r_value_1 = require("./r-value");
|
|
11
11
|
const string_constants_1 = require("./string/string-constants");
|
|
12
|
+
const vector_constants_1 = require("./vectors/vector-constants");
|
|
12
13
|
/**
|
|
13
14
|
* Takes n potentially lifted ops and returns `Top` or `Bottom` if any is `Top` or `Bottom`.
|
|
14
15
|
*/
|
|
@@ -50,6 +51,9 @@ function valueFromTsValue(a) {
|
|
|
50
51
|
else if (typeof a === 'boolean') {
|
|
51
52
|
return a ? logical_constants_1.ValueLogicalTrue : logical_constants_1.ValueLogicalFalse;
|
|
52
53
|
}
|
|
54
|
+
else if (Array.isArray(a)) {
|
|
55
|
+
return (0, vector_constants_1.vectorFrom)(a.map(v => valueFromTsValue(v)));
|
|
56
|
+
}
|
|
53
57
|
return r_value_1.Top;
|
|
54
58
|
}
|
|
55
59
|
/**
|
package/dataflow/extractor.js
CHANGED
|
@@ -21,6 +21,8 @@ const built_in_function_definition_1 = require("./internal/process/functions/cal
|
|
|
21
21
|
const flowr_file_1 = require("../project/context/flowr-file");
|
|
22
22
|
const identifier_1 = require("./environments/identifier");
|
|
23
23
|
const range_1 = require("../util/range");
|
|
24
|
+
const logger_1 = require("./logger");
|
|
25
|
+
const gas_1 = require("../gas");
|
|
24
26
|
/**
|
|
25
27
|
* The best friend of {@link produceDataFlowGraph} and {@link processDataflowFor}.
|
|
26
28
|
* Maps every {@link RType} in the normalized AST to a processor.
|
|
@@ -58,7 +60,15 @@ exports.processors = {
|
|
|
58
60
|
}, (0, make_argument_1.wrapArgumentsUnnamed)(children, d.completeAst.idMap), info.id, d);
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
|
-
function resolveLinkToSideEffects(ast, graph) {
|
|
63
|
+
function resolveLinkToSideEffects(ast, graph, ctx) {
|
|
64
|
+
const gasLevel = ctx.gas.checkGas(gas_1.GasFeatureKey.SideEffectLinking);
|
|
65
|
+
if (gasLevel >= 2 /* GasLevel.Critical */) {
|
|
66
|
+
logger_1.dataflowLogger.warn('Skipping side-effect link resolution due to resource pressure (gas: critical). See ' + gas_1.GasWikiRef);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
70
|
+
logger_1.dataflowLogger.warn('Approaching resource limits during side-effect link resolution (gas: problematic). See ' + gas_1.GasWikiRef);
|
|
71
|
+
}
|
|
62
72
|
let cf = undefined;
|
|
63
73
|
let knownCalls;
|
|
64
74
|
let allCallNames = [];
|
|
@@ -121,14 +131,23 @@ function produceDataFlowGraph(parser, completeAst, ctx) {
|
|
|
121
131
|
referenceChain: [files[0].filePath],
|
|
122
132
|
ctx
|
|
123
133
|
};
|
|
124
|
-
let df
|
|
134
|
+
let df;
|
|
135
|
+
try {
|
|
136
|
+
df = (0, processor_1.processDataflowFor)(files[0].root, dfData);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
if (e instanceof RangeError) {
|
|
140
|
+
throw new Error(`Dataflow analysis exceeded the call stack for '${files[0].filePath ?? '<inline>'}' (code is too deeply nested). Consider --stack-size=65536 when invoking Node.js.`, { cause: e });
|
|
141
|
+
}
|
|
142
|
+
throw e;
|
|
143
|
+
}
|
|
125
144
|
for (let i = 1; i < files.length; i++) {
|
|
126
145
|
/* source requests register automatically */
|
|
127
146
|
df = (0, built_in_source_1.standaloneSourceFile)(i, files[i], dfData, df);
|
|
128
147
|
}
|
|
129
148
|
// finally, resolve linkages
|
|
130
149
|
(0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment);
|
|
131
|
-
df.cfgQuick = resolveLinkToSideEffects(completeAst, df.graph);
|
|
150
|
+
df.cfgQuick = resolveLinkToSideEffects(completeAst, df.graph, ctx);
|
|
132
151
|
// performance optimization: return cfgQuick as part of the result to avoid recomputation
|
|
133
152
|
return df;
|
|
134
153
|
}
|
|
@@ -89,6 +89,12 @@ export declare const Dataflow: {
|
|
|
89
89
|
* @param includeMissingTargets - if set to true, this will include edges which target vertices that are not selected!
|
|
90
90
|
*/
|
|
91
91
|
readonly reduceGraph: <G extends DataflowGraph>(this: void, graph: G, select: ReadonlySet<NodeId>, includeMissingTargets?: boolean) => G;
|
|
92
|
+
/**
|
|
93
|
+
* Equivalent to {@link Dataflow.reduceGraph|`reduceGraph`} followed by {@link Dataflow.invertGraph|`invertGraph`}
|
|
94
|
+
* but in a single pass over the graph, allocating only one intermediate object instead of two.
|
|
95
|
+
* Use this when you need the reduced-and-inverted graph for a forward traversal within a restriction set.
|
|
96
|
+
*/
|
|
97
|
+
readonly reduceAndInvertGraph: <G extends DataflowGraph>(this: void, graph: G, select: ReadonlySet<NodeId>, cleanEnv: REnvironmentInformation) => G;
|
|
92
98
|
/**
|
|
93
99
|
* Given the id of a vertex (usually a variable use),
|
|
94
100
|
* this returns a reachable provenance set by calculating a non-interprocedural and non-context sensitive backward slice, but stopping at the given ids!
|
|
@@ -90,6 +90,39 @@ exports.Dataflow = {
|
|
|
90
90
|
}
|
|
91
91
|
return df;
|
|
92
92
|
},
|
|
93
|
+
/**
|
|
94
|
+
* Equivalent to {@link Dataflow.reduceGraph|`reduceGraph`} followed by {@link Dataflow.invertGraph|`invertGraph`}
|
|
95
|
+
* but in a single pass over the graph, allocating only one intermediate object instead of two.
|
|
96
|
+
* Use this when you need the reduced-and-inverted graph for a forward traversal within a restriction set.
|
|
97
|
+
*/
|
|
98
|
+
reduceAndInvertGraph(graph, select, cleanEnv) {
|
|
99
|
+
const df = new graph_1.DataflowGraph(graph.idMap);
|
|
100
|
+
for (const [id, vtx] of graph.vertices(true)) {
|
|
101
|
+
if (select.has(id)) {
|
|
102
|
+
df.addVertex(vtx, cleanEnv);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const [from, targets] of graph.edges()) {
|
|
106
|
+
if (!select.has(from)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
for (const [to, { types }] of targets) {
|
|
110
|
+
if (!select.has(to)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
df.addEdge(to, from, types);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const u of graph.unknownSideEffects) {
|
|
117
|
+
if (typeof u === 'object' && select.has(u.id)) {
|
|
118
|
+
df.markIdForUnknownSideEffects(u.id, u.linkTo);
|
|
119
|
+
}
|
|
120
|
+
else if (select.has(u)) {
|
|
121
|
+
df.markIdForUnknownSideEffects(u);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return df;
|
|
125
|
+
},
|
|
93
126
|
/**
|
|
94
127
|
* Given the id of a vertex (usually a variable use),
|
|
95
128
|
* this returns a reachable provenance set by calculating a non-interprocedural and non-context sensitive backward slice, but stopping at the given ids!
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -307,7 +307,7 @@ class DataflowGraph {
|
|
|
307
307
|
return this;
|
|
308
308
|
}
|
|
309
309
|
const vtag = vertex.tag;
|
|
310
|
-
// keep a clone of the original environment
|
|
310
|
+
// keep a clone of the original environment, isolating the snapshot from later updates
|
|
311
311
|
vertex.environment = vertex.environment ? (0, clone_1.cloneEnvironmentInformation)(vertex.environment) : (vtag === vertex_1.VertexType.FunctionDefinition || (vtag === vertex_1.VertexType.FunctionCall && !vertex.onlyBuiltin) ? fallbackEnv : undefined);
|
|
312
312
|
this.vertexInformation.set(vid, vertex);
|
|
313
313
|
const typeIds = this.types.get(vtag);
|
|
@@ -349,14 +349,18 @@ class DataflowGraph {
|
|
|
349
349
|
* in the context of function definitions
|
|
350
350
|
*/
|
|
351
351
|
mergeWith(otherGraph, mergeRootVertices = true) {
|
|
352
|
-
if (otherGraph === undefined) {
|
|
352
|
+
if (otherGraph === undefined || otherGraph === this) {
|
|
353
353
|
return this;
|
|
354
354
|
}
|
|
355
355
|
this.mergeVertices(otherGraph, mergeRootVertices);
|
|
356
356
|
for (const [type, ids] of otherGraph.types) {
|
|
357
357
|
const existing = this.types.get(type);
|
|
358
358
|
if (existing) {
|
|
359
|
-
existing
|
|
359
|
+
if (existing !== ids) {
|
|
360
|
+
for (const id of ids) {
|
|
361
|
+
existing.push(id);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
360
364
|
}
|
|
361
365
|
else {
|
|
362
366
|
this.types.set(type, ids.slice());
|
package/dataflow/info.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface DataflowCfgInformation {
|
|
|
97
97
|
* Each processor during the dataflow analysis may use the information from its children
|
|
98
98
|
* to produce a new state of the dataflow information.
|
|
99
99
|
*
|
|
100
|
-
* You may initialize a new dataflow information with {@link
|
|
100
|
+
* You may initialize a new dataflow information with {@link DataflowInformation.initialize}.
|
|
101
101
|
* @see {@link DataflowCfgInformation} - the control flow aspects
|
|
102
102
|
*/
|
|
103
103
|
export interface DataflowInformation extends DataflowCfgInformation {
|
package/dataflow/info.js
CHANGED
|
@@ -38,7 +38,9 @@ function addNonDefaultExitPoints(existing, invertExitCds, activeCds, add) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const invertedCds = toAdd.flatMap(e => e.cds?.filter(icd => !activeCds?.some(e => e.id === icd.id && e.when === icd.when)).map(negateControlDependency)).filter(assert_1.isNotUndefined);
|
|
41
|
-
|
|
41
|
+
for (const ep of toAdd) {
|
|
42
|
+
existing.push(ep);
|
|
43
|
+
}
|
|
42
44
|
for (const icd of invertedCds) {
|
|
43
45
|
if (!invertExitCds.some(e => e.id === icd.id && e.when === icd.when)) {
|
|
44
46
|
invertExitCds.push(icd);
|
|
@@ -100,8 +100,12 @@ export declare function linkInputs(referencesToLinkAgainstEnvironment: readonly
|
|
|
100
100
|
* }
|
|
101
101
|
* ```
|
|
102
102
|
* `x_2` must get a read marker to `x_1` as `x_1` is the active redefinition in the second loop iteration.
|
|
103
|
+
*
|
|
104
|
+
* When `environment` is supplied the function uses it to discover ALL definitions that are still live at the
|
|
105
|
+
* loop exit, so sequential overwrites contribute a single candidate while if-else branches contribute one
|
|
106
|
+
* candidate per branch.
|
|
103
107
|
*/
|
|
104
|
-
export declare function linkCircularRedefinitionsWithinALoop(graph: DataflowGraph, openIns: NameIdMap, outgoing: readonly IdentifierReference[]): void;
|
|
108
|
+
export declare function linkCircularRedefinitionsWithinALoop(graph: DataflowGraph, openIns: NameIdMap, outgoing: readonly IdentifierReference[], environment?: REnvironmentInformation): void;
|
|
105
109
|
/**
|
|
106
110
|
* Reapplies the loop exit points' control dependencies to the given identifier references.
|
|
107
111
|
*/
|
|
@@ -401,8 +401,13 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
401
401
|
result.add(vertex);
|
|
402
402
|
continue;
|
|
403
403
|
}
|
|
404
|
+
const outgoing = dataflowGraph.outgoingEdges(cid);
|
|
405
|
+
if (!outgoing) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const isSkipType = vertex.tag === vertex_1.VertexType.FunctionCall || (vertex.tag === vertex_1.VertexType.VariableDefinition && vertex.par);
|
|
404
409
|
let hasReturnEdge = false;
|
|
405
|
-
|
|
410
|
+
let followTargets;
|
|
406
411
|
for (const [target, e] of outgoing) {
|
|
407
412
|
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)) {
|
|
408
413
|
hasReturnEdge = true;
|
|
@@ -410,12 +415,12 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
410
415
|
potential.push(target);
|
|
411
416
|
}
|
|
412
417
|
}
|
|
418
|
+
else if (!isSkipType && !hasReturnEdge && edge_1.DfEdge.includesType(e, LinkedFnFollowBits) && !visited.has(target)) {
|
|
419
|
+
(followTargets ??= []).push(target);
|
|
420
|
+
}
|
|
413
421
|
}
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
for (const [target, e] of outgoing) {
|
|
418
|
-
if (edge_1.DfEdge.includesType(e, LinkedFnFollowBits) && !visited.has(target)) {
|
|
422
|
+
if (!hasReturnEdge && followTargets) {
|
|
423
|
+
for (const target of followTargets) {
|
|
419
424
|
potential.push(target);
|
|
420
425
|
}
|
|
421
426
|
}
|
|
@@ -466,10 +471,30 @@ function linkInputs(referencesToLinkAgainstEnvironment, environmentInformation,
|
|
|
466
471
|
* }
|
|
467
472
|
* ```
|
|
468
473
|
* `x_2` must get a read marker to `x_1` as `x_1` is the active redefinition in the second loop iteration.
|
|
474
|
+
*
|
|
475
|
+
* When `environment` is supplied the function uses it to discover ALL definitions that are still live at the
|
|
476
|
+
* loop exit, so sequential overwrites contribute a single candidate while if-else branches contribute one
|
|
477
|
+
* candidate per branch.
|
|
469
478
|
*/
|
|
470
|
-
function linkCircularRedefinitionsWithinALoop(graph, openIns, outgoing) {
|
|
471
|
-
|
|
472
|
-
|
|
479
|
+
function linkCircularRedefinitionsWithinALoop(graph, openIns, outgoing, environment) {
|
|
480
|
+
if (environment !== undefined) {
|
|
481
|
+
const outgoingIds = new Set(outgoing.map(o => o.nodeId));
|
|
482
|
+
for (const [name, targets] of openIns.entries()) {
|
|
483
|
+
const liveDefs = environment.current.memory.get(identifier_1.Identifier.getName(name));
|
|
484
|
+
if (liveDefs === undefined) {
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
for (const def of liveDefs) {
|
|
488
|
+
if (outgoingIds.has(def.nodeId)) {
|
|
489
|
+
for (const target of targets) {
|
|
490
|
+
graph.addEdge(target.nodeId, def.nodeId, edge_1.EdgeType.Reads);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
// fallback: keep only the last definition per identifier (used when no environment is available)
|
|
473
498
|
const lastOutgoing = new Map();
|
|
474
499
|
for (const out of outgoing) {
|
|
475
500
|
const on = out.name;
|
|
@@ -180,7 +180,9 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
180
180
|
}
|
|
181
181
|
const ingoing = [];
|
|
182
182
|
for (const refs of remainingRead.values()) {
|
|
183
|
-
|
|
183
|
+
for (const ref of refs) {
|
|
184
|
+
ingoing.push(ref);
|
|
185
|
+
}
|
|
184
186
|
}
|
|
185
187
|
const rootNode = data.completeAst.idMap.get(rootId);
|
|
186
188
|
const withGroup = rootNode?.grouping;
|
|
@@ -64,7 +64,7 @@ function processForLoop(name, args, rootId, data) {
|
|
|
64
64
|
}
|
|
65
65
|
(0, reference_to_maybe_1.applyCdToReferences)(body.out, cd);
|
|
66
66
|
const outgoing = variable.out.concat(writtenVariable, body.out);
|
|
67
|
-
(0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out);
|
|
67
|
+
(0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out, body.environment);
|
|
68
68
|
(0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), nextGraph);
|
|
69
69
|
(0, common_1.patchFunctionCall)({
|
|
70
70
|
nextGraph,
|