@eagleoutice/flowr 2.13.13 → 2.13.15
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 +31 -28
- package/abstract-interpretation/data-frame/resolve-args.js +11 -12
- package/benchmark/calibration.d.ts +18 -0
- package/benchmark/calibration.js +63 -0
- package/benchmark/slicer.d.ts +19 -0
- package/benchmark/slicer.js +84 -1
- package/benchmark/stats/feature-counts.d.ts +6 -0
- package/benchmark/stats/feature-counts.js +61 -0
- package/benchmark/stats/print.js +20 -0
- package/benchmark/stats/sigdb-counts.d.ts +7 -0
- package/benchmark/stats/sigdb-counts.js +219 -0
- package/benchmark/stats/size-of.d.ts +6 -0
- package/benchmark/stats/size-of.js +8 -0
- package/benchmark/stats/stats.d.ts +79 -0
- package/benchmark/stats/stats.js +7 -1
- package/benchmark/stopwatch.d.ts +4 -0
- package/benchmark/stopwatch.js +12 -1
- package/benchmark/summarizer/data.d.ts +17 -1
- package/benchmark/summarizer/first-phase/input.js +5 -0
- package/benchmark/summarizer/first-phase/process.js +12 -2
- package/benchmark/summarizer/second-phase/graph.d.ts +24 -1
- package/benchmark/summarizer/second-phase/graph.js +249 -18
- package/benchmark/summarizer/second-phase/process.js +56 -0
- package/benchmark/summarizer/summarizer.js +1 -2
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +2 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +12 -2
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +3 -1
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/repl/commands/repl-cfg.js +2 -42
- package/cli/repl/commands/repl-clipboard.d.ts +7 -0
- package/cli/repl/commands/repl-clipboard.js +53 -0
- package/cli/repl/commands/repl-dataflow.js +5 -70
- package/cli/repl/commands/repl-normalize.js +3 -51
- package/control-flow/cfg-builder.d.ts +30 -0
- package/control-flow/cfg-builder.js +79 -0
- package/control-flow/cfg-dead-code.js +5 -29
- package/control-flow/diff-cfg.js +2 -56
- package/control-flow/extract-cfg.js +17 -10
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +14 -0
- package/control-flow/useless-loop.js +4 -26
- package/core/steps/all/core/10-normalize.d.ts +8 -0
- package/core/steps/all/core/10-normalize.js +10 -8
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
- package/data/r-base-packages.generated.d.ts +1 -0
- package/data/r-base-packages.generated.js +5 -3
- package/dataflow/environments/apply-kill.d.ts +3 -3
- package/dataflow/environments/apply-kill.js +60 -31
- package/dataflow/environments/built-in-config.d.ts +9 -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-props.d.ts +4 -0
- package/dataflow/environments/built-in-props.js +3 -3
- package/dataflow/environments/built-in.d.ts +4 -2
- package/dataflow/environments/built-in.js +53 -3
- package/dataflow/environments/data-masking-functions.d.ts +3 -4
- package/dataflow/environments/data-masking-functions.js +7 -8
- package/dataflow/environments/default-builtin-config.d.ts +92 -12
- package/dataflow/environments/default-builtin-config.js +86 -43
- package/dataflow/environments/environment.d.ts +5 -0
- package/dataflow/environments/environment.js +17 -12
- package/dataflow/environments/identifier.d.ts +3 -0
- package/dataflow/environments/reference-to-maybe.d.ts +5 -3
- package/dataflow/environments/reference-to-maybe.js +17 -52
- package/dataflow/environments/resolve-helper.d.ts +2 -1
- package/dataflow/environments/resolve-helper.js +2 -1
- package/dataflow/eval/resolve/alias-tracking.js +4 -7
- package/dataflow/eval/resolve/node-value.d.ts +51 -0
- package/dataflow/eval/resolve/node-value.js +71 -0
- package/dataflow/eval/resolve/resolve-argument.js +10 -7
- package/dataflow/eval/resolve/resolve-operators.js +1 -2
- package/dataflow/eval/values/general.d.ts +4 -0
- package/dataflow/eval/values/general.js +11 -0
- package/dataflow/eval/values/r-value.d.ts +15 -0
- package/dataflow/eval/values/r-value.js +27 -1
- package/dataflow/extractor.js +2 -0
- package/dataflow/fn/higher-order-function.js +2 -3
- package/dataflow/graph/df-helper.d.ts +2 -1
- package/dataflow/graph/diff-dataflow-graph.js +3 -55
- package/dataflow/graph/graph.d.ts +5 -0
- package/dataflow/graph/graph.js +27 -0
- package/dataflow/info.d.ts +7 -1
- package/dataflow/info.js +36 -7
- package/dataflow/internal/linker.d.ts +23 -0
- package/dataflow/internal/linker.js +70 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +33 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +23 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +9 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/deferred.d.ts +41 -0
- package/dataflow/internal/process/functions/call/deferred.js +127 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/nse.d.ts +28 -0
- package/dataflow/internal/process/functions/call/nse.js +87 -0
- package/dataflow/internal/process/functions/call/quoted.d.ts +29 -0
- package/dataflow/internal/process/functions/call/quoted.js +188 -0
- package/documentation/doc-readme.js +5 -2
- package/documentation/doc-util/doc-issue.d.ts +2 -0
- package/documentation/doc-util/doc-issue.js +3 -1
- package/documentation/doc-util/doc-types.js +15 -9
- package/documentation/wiki-dataflow-graph.js +4 -0
- package/documentation/wiki-faq.js +6 -2
- package/documentation/wiki-onboarding.js +11 -1
- package/documentation/wiki-setup.js +2 -1
- package/linter/rules/deprecated-functions.js +9 -3
- package/linter/rules/seeded-randomness.js +2 -3
- package/linter/rules/undefined-symbol.js +10 -1
- package/package.json +9 -4
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
- package/project/sigdb/reader.d.ts +9 -0
- package/project/sigdb/reader.js +30 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/query-function-filter.d.ts +21 -0
- package/queries/query-function-filter.js +48 -0
- package/r-bridge/data/data.d.ts +13 -3
- package/r-bridge/data/data.js +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -9
- package/search/flowr-search-filters.d.ts +5 -1
- package/search/flowr-search-filters.js +31 -21
- package/search/search-executor/search-enrichers.d.ts +24 -4
- package/search/search-executor/search-enrichers.js +22 -9
- package/search/search-executor/search-transformer.js +1 -1
- package/slicing/static/slice-call.js +4 -4
- package/util/diff-graph.d.ts +13 -0
- package/util/diff-graph.js +64 -1
- package/util/files.js +9 -8
- package/util/node-version.d.ts +4 -0
- package/util/node-version.js +29 -0
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -1
- package/util/version.js +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ReplClipboard = void 0;
|
|
37
|
+
/** Output that the user most likely wants on their clipboard as well. */
|
|
38
|
+
exports.ReplClipboard = {
|
|
39
|
+
name: 'ReplClipboard',
|
|
40
|
+
/** Prints `text` and, if the output allows it, copies it to the clipboard and reports `note` afterwards. */
|
|
41
|
+
async print(output, text, note) {
|
|
42
|
+
output.stdout(text);
|
|
43
|
+
if (output.allowClipboard !== false) {
|
|
44
|
+
try {
|
|
45
|
+
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
46
|
+
clipboard.default.writeSync(text);
|
|
47
|
+
output.stdout(note);
|
|
48
|
+
}
|
|
49
|
+
catch { /* do nothing this is a service thing */ }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=repl-clipboard.js.map
|
|
@@ -1,41 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.dataflowSimpleStarCommand = exports.dataflowSimplifiedCommand = exports.dataflowSilentCommand = exports.dataflowAsciiCommand = exports.dataflowStarCommand = exports.dataflowCommand = void 0;
|
|
37
4
|
const ansi_1 = require("../../../util/text/ansi");
|
|
38
5
|
const core_1 = require("../core");
|
|
6
|
+
const repl_clipboard_1 = require("./repl-clipboard");
|
|
39
7
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
40
8
|
const dfg_ascii_1 = require("../../../util/simple-df/dfg-ascii");
|
|
41
9
|
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
@@ -89,16 +57,7 @@ exports.dataflowCommand = {
|
|
|
89
57
|
fn: async ({ output, analyzer }) => {
|
|
90
58
|
const result = await analyzer.dataflow();
|
|
91
59
|
const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, qualifyBaseR: (0, config_1.isSigDbEnabled)(analyzer.flowrConfig) }).string;
|
|
92
|
-
|
|
93
|
-
if (output.allowClipboard !== false) {
|
|
94
|
-
try {
|
|
95
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
96
|
-
clipboard.default.writeSync(mermaid);
|
|
97
|
-
output.stdout(formatInfo(output, 'mermaid code', result));
|
|
98
|
-
}
|
|
99
|
-
catch { /* do nothing this is a service thing */
|
|
100
|
-
}
|
|
101
|
-
}
|
|
60
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid code', result));
|
|
102
61
|
}
|
|
103
62
|
};
|
|
104
63
|
exports.dataflowStarCommand = {
|
|
@@ -111,15 +70,7 @@ exports.dataflowStarCommand = {
|
|
|
111
70
|
fn: async ({ output, analyzer }) => {
|
|
112
71
|
const result = await analyzer.dataflow();
|
|
113
72
|
const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, false, (0, config_1.isSigDbEnabled)(analyzer.flowrConfig));
|
|
114
|
-
|
|
115
|
-
if (output.allowClipboard !== false) {
|
|
116
|
-
try {
|
|
117
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
118
|
-
clipboard.default.writeSync(mermaid);
|
|
119
|
-
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
120
|
-
}
|
|
121
|
-
catch { /* do nothing this is a service thing */ }
|
|
122
|
-
}
|
|
73
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid url', result));
|
|
123
74
|
}
|
|
124
75
|
};
|
|
125
76
|
exports.dataflowAsciiCommand = {
|
|
@@ -174,15 +125,7 @@ exports.dataflowSimplifiedCommand = {
|
|
|
174
125
|
fn: async ({ output, analyzer }) => {
|
|
175
126
|
const result = await analyzer.dataflow();
|
|
176
127
|
const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, simplified: true, qualifyBaseR: (0, config_1.isSigDbEnabled)(analyzer.flowrConfig) }).string;
|
|
177
|
-
|
|
178
|
-
if (output.allowClipboard !== false) {
|
|
179
|
-
try {
|
|
180
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
181
|
-
clipboard.default.writeSync(mermaid);
|
|
182
|
-
output.stdout(formatInfo(output, 'mermaid code', result));
|
|
183
|
-
}
|
|
184
|
-
catch { /* do nothing this is a service thing */ }
|
|
185
|
-
}
|
|
128
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid code', result));
|
|
186
129
|
}
|
|
187
130
|
};
|
|
188
131
|
exports.dataflowSimpleStarCommand = {
|
|
@@ -195,15 +138,7 @@ exports.dataflowSimpleStarCommand = {
|
|
|
195
138
|
fn: async ({ output, analyzer }) => {
|
|
196
139
|
const result = await analyzer.dataflow();
|
|
197
140
|
const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, true, (0, config_1.isSigDbEnabled)(analyzer.flowrConfig));
|
|
198
|
-
|
|
199
|
-
if (output.allowClipboard !== false) {
|
|
200
|
-
try {
|
|
201
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
202
|
-
clipboard.default.writeSync(mermaid);
|
|
203
|
-
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
204
|
-
}
|
|
205
|
-
catch { /* do nothing this is a service thing */ }
|
|
206
|
-
}
|
|
141
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid url', result));
|
|
207
142
|
}
|
|
208
143
|
};
|
|
209
144
|
//# sourceMappingURL=repl-dataflow.js.map
|
|
@@ -1,42 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.normalizeHashCommand = exports.normalizeStarCommand = exports.normalizeCommand = void 0;
|
|
37
4
|
const ast_1 = require("../../../util/mermaid/ast");
|
|
38
5
|
const ansi_1 = require("../../../util/text/ansi");
|
|
39
6
|
const core_1 = require("../core");
|
|
7
|
+
const repl_clipboard_1 = require("./repl-clipboard");
|
|
40
8
|
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
41
9
|
const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
42
10
|
function formatInfo(out, type, meta) {
|
|
@@ -52,15 +20,7 @@ exports.normalizeCommand = {
|
|
|
52
20
|
fn: async ({ output, analyzer }) => {
|
|
53
21
|
const result = await analyzer.normalize();
|
|
54
22
|
const mermaid = (0, ast_1.normalizedAstToMermaid)(result.ast);
|
|
55
|
-
|
|
56
|
-
if (output.allowClipboard !== false) {
|
|
57
|
-
try {
|
|
58
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
59
|
-
clipboard.default.writeSync(mermaid);
|
|
60
|
-
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
61
|
-
}
|
|
62
|
-
catch { /* do nothing this is a service thing */ }
|
|
63
|
-
}
|
|
23
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid url', result));
|
|
64
24
|
}
|
|
65
25
|
};
|
|
66
26
|
exports.normalizeStarCommand = {
|
|
@@ -73,15 +33,7 @@ exports.normalizeStarCommand = {
|
|
|
73
33
|
fn: async ({ output, analyzer }) => {
|
|
74
34
|
const result = await analyzer.normalize();
|
|
75
35
|
const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.ast);
|
|
76
|
-
|
|
77
|
-
if (output.allowClipboard !== false) {
|
|
78
|
-
try {
|
|
79
|
-
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
80
|
-
clipboard.default.writeSync(mermaid);
|
|
81
|
-
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
82
|
-
}
|
|
83
|
-
catch { /* do nothing this is a service thing */ }
|
|
84
|
-
}
|
|
36
|
+
await repl_clipboard_1.ReplClipboard.print(output, mermaid, formatInfo(output, 'mermaid url', result));
|
|
85
37
|
}
|
|
86
38
|
};
|
|
87
39
|
exports.normalizeHashCommand = {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An append-only builder for a {@link ControlFlowGraph}, used while folding the AST.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
import type { CfgEdge } from './control-flow-graph';
|
|
7
|
+
import { CfgVertex, ControlFlowGraph } from './control-flow-graph';
|
|
8
|
+
/**
|
|
9
|
+
* Records the vertices and edges of a control flow graph instead of building it, as the bottom-up fold would
|
|
10
|
+
* copy an eager graph once per nesting level. {@link CfgBuilder#mergeWith|mergeWith()} only references the other
|
|
11
|
+
* builder, {@link CfgBuilder#materialize|materialize()} replays everything once in recording order — the
|
|
12
|
+
* order an eager merge produced, which the vertex order of a function definition's children relies on.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CfgBuilder {
|
|
15
|
+
private readonly operations;
|
|
16
|
+
addVertex(vertex: CfgVertex, rootVertex?: boolean): this;
|
|
17
|
+
addEdge(from: NodeId, to: NodeId, edge: CfgEdge): this;
|
|
18
|
+
/**
|
|
19
|
+
* Record that the other builder is part of this one, it must not be modified afterwards.
|
|
20
|
+
* @param other - the builder to include
|
|
21
|
+
* @param forceNested - should its vertices count as nested (e.g., within a function definition)
|
|
22
|
+
*/
|
|
23
|
+
mergeWith(other: CfgBuilder, forceNested?: boolean): this;
|
|
24
|
+
/** The last vertex recorded for the given id, searching the merged builders only if we hold none. */
|
|
25
|
+
getVertex(id: NodeId): CfgVertex | undefined;
|
|
26
|
+
/** The ids of all vertices that are not nested, in insertion order. */
|
|
27
|
+
rootIds(collected?: Set<NodeId>): ReadonlySet<NodeId>;
|
|
28
|
+
/** Replays all recorded operations into a {@link ControlFlowGraph}. */
|
|
29
|
+
materialize(graph?: ControlFlowGraph, nested?: boolean): ControlFlowGraph;
|
|
30
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CfgBuilder = void 0;
|
|
4
|
+
const control_flow_graph_1 = require("./control-flow-graph");
|
|
5
|
+
/**
|
|
6
|
+
* Records the vertices and edges of a control flow graph instead of building it, as the bottom-up fold would
|
|
7
|
+
* copy an eager graph once per nesting level. {@link CfgBuilder#mergeWith|mergeWith()} only references the other
|
|
8
|
+
* builder, {@link CfgBuilder#materialize|materialize()} replays everything once in recording order — the
|
|
9
|
+
* order an eager merge produced, which the vertex order of a function definition's children relies on.
|
|
10
|
+
*/
|
|
11
|
+
class CfgBuilder {
|
|
12
|
+
operations = [];
|
|
13
|
+
addVertex(vertex, rootVertex = true) {
|
|
14
|
+
this.operations.push({ kind: 0 /* BuilderOperationType.Vertex */, vertex, root: rootVertex });
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
addEdge(from, to, edge) {
|
|
18
|
+
this.operations.push({ kind: 1 /* BuilderOperationType.Edge */, from, to, edge });
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Record that the other builder is part of this one, it must not be modified afterwards.
|
|
23
|
+
* @param other - the builder to include
|
|
24
|
+
* @param forceNested - should its vertices count as nested (e.g., within a function definition)
|
|
25
|
+
*/
|
|
26
|
+
mergeWith(other, forceNested = false) {
|
|
27
|
+
this.operations.push({ kind: 2 /* BuilderOperationType.Merge */, other, nested: forceNested });
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/** The last vertex recorded for the given id, searching the merged builders only if we hold none. */
|
|
31
|
+
getVertex(id) {
|
|
32
|
+
for (let i = this.operations.length - 1; i >= 0; i--) {
|
|
33
|
+
const operation = this.operations[i];
|
|
34
|
+
if (operation.kind === 0 /* BuilderOperationType.Vertex */) {
|
|
35
|
+
if (control_flow_graph_1.CfgVertex.getId(operation.vertex) === id) {
|
|
36
|
+
return operation.vertex;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (operation.kind === 2 /* BuilderOperationType.Merge */) {
|
|
40
|
+
const found = operation.other.getVertex(id);
|
|
41
|
+
if (found !== undefined) {
|
|
42
|
+
return found;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
/** The ids of all vertices that are not nested, in insertion order. */
|
|
49
|
+
rootIds(collected = new Set()) {
|
|
50
|
+
for (const operation of this.operations) {
|
|
51
|
+
if (operation.kind === 0 /* BuilderOperationType.Vertex */) {
|
|
52
|
+
if (operation.root) {
|
|
53
|
+
collected.add(control_flow_graph_1.CfgVertex.getId(operation.vertex));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (operation.kind === 2 /* BuilderOperationType.Merge */ && !operation.nested) {
|
|
57
|
+
operation.other.rootIds(collected);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return collected;
|
|
61
|
+
}
|
|
62
|
+
/** Replays all recorded operations into a {@link ControlFlowGraph}. */
|
|
63
|
+
materialize(graph = new control_flow_graph_1.ControlFlowGraph(), nested = false) {
|
|
64
|
+
for (const operation of this.operations) {
|
|
65
|
+
if (operation.kind === 0 /* BuilderOperationType.Vertex */) {
|
|
66
|
+
graph.addVertex(operation.vertex, operation.root && !nested);
|
|
67
|
+
}
|
|
68
|
+
else if (operation.kind === 1 /* BuilderOperationType.Edge */) {
|
|
69
|
+
graph.addEdge(operation.from, operation.to, operation.edge);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
operation.other.materialize(graph, nested || operation.nested);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return graph;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.CfgBuilder = CfgBuilder;
|
|
79
|
+
//# sourceMappingURL=cfg-builder.js.map
|
|
@@ -6,11 +6,10 @@ const logic_1 = require("../util/logic");
|
|
|
6
6
|
const semantic_cfg_guided_visitor_1 = require("./semantic-cfg-guided-visitor");
|
|
7
7
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
8
8
|
const graph_1 = require("../dataflow/graph/graph");
|
|
9
|
-
const
|
|
9
|
+
const node_value_1 = require("../dataflow/eval/resolve/node-value");
|
|
10
10
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
11
11
|
const log_1 = require("../util/log");
|
|
12
12
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
|
-
const general_1 = require("../dataflow/eval/values/general");
|
|
14
13
|
const r_value_1 = require("../dataflow/eval/values/r-value");
|
|
15
14
|
const simple_visitor_1 = require("./simple-visitor");
|
|
16
15
|
const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
|
|
@@ -95,19 +94,13 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
95
94
|
if (this.cachedConditions.has(id)) {
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
full: true,
|
|
101
|
-
idMap: this.config.normalizedAst.idMap,
|
|
102
|
-
resolve: this.config.ctx.config.solver.variables,
|
|
103
|
-
ctx: this.config.ctx,
|
|
104
|
-
}));
|
|
105
|
-
if (values === undefined || values.elements.length !== 1 || values.elements[0].type !== 'logical' || !(0, r_value_1.isValue)(values.elements[0].value)) {
|
|
97
|
+
const value = node_value_1.NodeValue.inGraph.soleOf(valueId, this.config.dfg, this.config.ctx, 'logical', { idMap: this.config.normalizedAst.idMap });
|
|
98
|
+
if (value === undefined || !(0, r_value_1.isValue)(value.value)) {
|
|
106
99
|
this.unableToCalculateValue(id);
|
|
107
100
|
return;
|
|
108
101
|
}
|
|
109
102
|
/* we should translate this to truthy later */
|
|
110
|
-
this.storeDefiniteValue(id, Boolean(
|
|
103
|
+
this.storeDefiniteValue(id, Boolean(value.value));
|
|
111
104
|
}
|
|
112
105
|
handleWithCondition(data) {
|
|
113
106
|
const id = data.call.id;
|
|
@@ -117,21 +110,6 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
117
110
|
}
|
|
118
111
|
this.handleValuesFor(id, typeof data.condition === 'object' ? data.condition.nodeId : data.condition);
|
|
119
112
|
}
|
|
120
|
-
getBoolArgValue(data) {
|
|
121
|
-
if (data.call.args.length !== 1 || data.call.args[0] === r_function_call_1.EmptyArgument) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
const values = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(data.call.args[0].nodeId, {
|
|
125
|
-
graph: this.config.dfg,
|
|
126
|
-
full: true,
|
|
127
|
-
idMap: this.config.normalizedAst.idMap,
|
|
128
|
-
ctx: this.config.ctx,
|
|
129
|
-
}));
|
|
130
|
-
if (values === undefined || values.elements.length !== 1 || values.elements[0].type !== 'logical' || !(0, r_value_1.isValue)(values.elements[0].value)) {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
return Boolean(values.elements[0].value);
|
|
134
|
-
}
|
|
135
113
|
onIfThenElseCall(data) {
|
|
136
114
|
this.handleWithCondition(data);
|
|
137
115
|
}
|
|
@@ -191,9 +169,7 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
191
169
|
return result;
|
|
192
170
|
}
|
|
193
171
|
computeSelectedSwitchArm(v) {
|
|
194
|
-
const target =
|
|
195
|
-
graph: this.config.dfg, full: true, idMap: this.config.normalizedAst.idMap, resolve: this.config.ctx.config.solver.variables, ctx: this.config.ctx
|
|
196
|
-
});
|
|
172
|
+
const target = node_value_1.NodeValue.inGraph.singleStringOf(graph_1.FunctionArgument.getReference(v.args[0]), this.config.dfg, this.config.ctx, { idMap: this.config.normalizedAst.idMap });
|
|
197
173
|
if (target === undefined) {
|
|
198
174
|
return 'unknown';
|
|
199
175
|
}
|
package/control-flow/diff-cfg.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.diffOfControlFlowGraphs = diffOfControlFlowGraphs;
|
|
4
|
-
const json_1 = require("../util/json");
|
|
5
4
|
const diff_graph_1 = require("../util/diff-graph");
|
|
6
5
|
const diff_1 = require("../util/diff");
|
|
7
6
|
const control_flow_graph_1 = require("./control-flow-graph");
|
|
@@ -22,7 +21,7 @@ function diffOfControlFlowGraphs(left, right, config) {
|
|
|
22
21
|
function diffDataflowGraphs(ctx) {
|
|
23
22
|
diffRootVertices(ctx);
|
|
24
23
|
diffVertices(ctx);
|
|
25
|
-
|
|
24
|
+
diff_graph_1.GraphDiff.outgoingEdges(ctx, diffEdges);
|
|
26
25
|
}
|
|
27
26
|
function diffRootVertices(ctx) {
|
|
28
27
|
(0, diff_1.setDifference)(ctx.left.rootIds(), ctx.right.rootIds(), {
|
|
@@ -90,38 +89,6 @@ function diffVertices(ctx) {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
|
-
function diffOutgoingEdges(ctx) {
|
|
94
|
-
const lEdges = new Map([...ctx.left.edges()]);
|
|
95
|
-
const rEdges = new Map([...ctx.right.edges()]);
|
|
96
|
-
if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph || lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
|
|
97
|
-
ctx.report.addComment(`Detected different number of edges! ${ctx.leftname} has ${lEdges.size} (${JSON.stringify(lEdges, json_1.jsonReplacer)}). ${ctx.rightname} has ${rEdges.size} ${JSON.stringify(rEdges, json_1.jsonReplacer)}`);
|
|
98
|
-
}
|
|
99
|
-
for (const [id, edge] of lEdges) {
|
|
100
|
-
/* This has nothing to do with the subset relation as we verify this in the same graph.
|
|
101
|
-
* Yet we still do the check as a subgraph may not have to have all source vertices for edges.
|
|
102
|
-
*/
|
|
103
|
-
if (!ctx.left.hasVertex(id)) {
|
|
104
|
-
if (!ctx.config.leftIsSubgraph) {
|
|
105
|
-
ctx.report.addComment(`The source ${id} of edges ${JSON.stringify(edge, json_1.jsonReplacer)} is not present in ${ctx.leftname}. This means that the graph contains an edge but not the corresponding vertex.`);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
diffEdges(ctx, id, edge, rEdges.get(id));
|
|
110
|
-
}
|
|
111
|
-
// just to make it both ways in case the length differs
|
|
112
|
-
for (const [id, edge] of rEdges) {
|
|
113
|
-
if (!ctx.right.hasVertex(id)) {
|
|
114
|
-
if (!ctx.config.rightIsSubgraph) {
|
|
115
|
-
ctx.report.addComment(`The source ${id} of edges ${JSON.stringify(edge, json_1.jsonReplacer)} is not present in ${ctx.rightname}. This means that the graph contains an edge but not the corresponding vertex.`);
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!ctx.config.leftIsSubgraph && !lEdges.has(id)) {
|
|
120
|
-
diffEdges(ctx, id, undefined, edge);
|
|
121
|
-
}
|
|
122
|
-
/* otherwise, we already cover the edge above */
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
92
|
function diffEdge(edge, otherEdge, ctx, id, target) {
|
|
126
93
|
const el = control_flow_graph_1.CfgEdge.getType(edge);
|
|
127
94
|
const ol = control_flow_graph_1.CfgEdge.getType(otherEdge);
|
|
@@ -140,27 +107,6 @@ function diffEdge(edge, otherEdge, ctx, id, target) {
|
|
|
140
107
|
}
|
|
141
108
|
}
|
|
142
109
|
function diffEdges(ctx, id, lEdges, rEdges) {
|
|
143
|
-
|
|
144
|
-
if ((lEdges === undefined && !ctx.config.leftIsSubgraph)
|
|
145
|
-
|| (rEdges === undefined && !ctx.config.rightIsSubgraph)) {
|
|
146
|
-
ctx.report.addComment(`Vertex ${id} has undefined outgoing edges. ${ctx.leftname}: ${JSON.stringify(lEdges, json_1.jsonReplacer)} vs ${ctx.rightname}: ${JSON.stringify(rEdges, json_1.jsonReplacer)}`, { tag: 'vertex', id });
|
|
147
|
-
}
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph
|
|
151
|
-
|| lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
|
|
152
|
-
ctx.report.addComment(`Vertex ${id} differs in number of outgoing edges. ${ctx.leftname}: [${[...lEdges.keys()].join(',')}] vs ${ctx.rightname}: [${[...rEdges.keys()].join(',')}] `, { tag: 'vertex', id });
|
|
153
|
-
}
|
|
154
|
-
// order independent compare
|
|
155
|
-
for (const [target, edge] of lEdges) {
|
|
156
|
-
const otherEdge = rEdges.get(target);
|
|
157
|
-
if (otherEdge === undefined) {
|
|
158
|
-
if (!ctx.config.rightIsSubgraph) {
|
|
159
|
-
ctx.report.addComment(`Target of ${id}->${target} in ${ctx.leftname} is not present in ${ctx.rightname}`, { tag: 'edge', from: id, to: target });
|
|
160
|
-
}
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
diffEdge(edge, otherEdge, ctx, id, target);
|
|
164
|
-
}
|
|
110
|
+
diff_graph_1.GraphDiff.edges(ctx, id, lEdges, rEdges, diffEdge);
|
|
165
111
|
}
|
|
166
112
|
//# sourceMappingURL=diff-cfg.js.map
|
|
@@ -12,12 +12,19 @@ const linker_1 = require("../dataflow/internal/linker");
|
|
|
12
12
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
13
13
|
const control_flow_graph_1 = require("./control-flow-graph");
|
|
14
14
|
const cfg_simplification_1 = require("./cfg-simplification");
|
|
15
|
+
const cfg_builder_1 = require("./cfg-builder");
|
|
15
16
|
const assert_1 = require("../util/assert");
|
|
16
17
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
17
18
|
const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
|
|
18
19
|
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
19
20
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
20
21
|
const identifier_1 = require("../dataflow/environments/identifier");
|
|
22
|
+
function emptyCfgFoldInformation() {
|
|
23
|
+
return { graph: new cfg_builder_1.CfgBuilder(), breaks: [], nexts: [], returns: [], exitPoints: [], entryPoints: [] };
|
|
24
|
+
}
|
|
25
|
+
function materializeCfg(info) {
|
|
26
|
+
return { ...info, graph: info.graph.materialize() };
|
|
27
|
+
}
|
|
21
28
|
const cfgFolds = {
|
|
22
29
|
down: (n, down) => {
|
|
23
30
|
if (r_function_definition_1.RFunctionDefinition.is(n)) {
|
|
@@ -112,7 +119,7 @@ function cfgFoldProject(proj, folds) {
|
|
|
112
119
|
return (0, control_flow_graph_1.emptyControlFlowInformation)();
|
|
113
120
|
}
|
|
114
121
|
else if (proj.files.length === 1) {
|
|
115
|
-
return (0, stateful_fold_1.foldAstStateful)(proj.files[0].root, [false, false], folds);
|
|
122
|
+
return materializeCfg((0, stateful_fold_1.foldAstStateful)(proj.files[0].root, [false, false], folds));
|
|
116
123
|
}
|
|
117
124
|
/* for many files, it is too expensive to keep all asts at once, hence we create and merge them incrementally */
|
|
118
125
|
let exitPoints;
|
|
@@ -149,14 +156,14 @@ function cfgFoldProject(proj, folds) {
|
|
|
149
156
|
returns,
|
|
150
157
|
exitPoints,
|
|
151
158
|
entryPoints: firstEntryPoints,
|
|
152
|
-
graph: finalGraph
|
|
159
|
+
graph: finalGraph.materialize()
|
|
153
160
|
};
|
|
154
161
|
}
|
|
155
162
|
function cfgLeaf(type) {
|
|
156
163
|
return type === control_flow_graph_1.CfgVertexType.Expression ? ({ info: { id } }) => {
|
|
157
|
-
return { graph: new
|
|
164
|
+
return { graph: new cfg_builder_1.CfgBuilder().addVertex(control_flow_graph_1.CfgVertex.makeExpression(id)), breaks: [], nexts: [], returns: [], exitPoints: [id], entryPoints: [id] };
|
|
158
165
|
} : ({ info: { id } }) => {
|
|
159
|
-
return { graph: new
|
|
166
|
+
return { graph: new cfg_builder_1.CfgBuilder().addVertex(control_flow_graph_1.CfgVertex.makeStatement(id)), breaks: [], nexts: [], returns: [], exitPoints: [id], entryPoints: [id] };
|
|
160
167
|
};
|
|
161
168
|
}
|
|
162
169
|
const cfgLeafStatement = cfgLeaf(control_flow_graph_1.CfgVertexType.Statement);
|
|
@@ -173,14 +180,14 @@ function cfgNext(leaf, down) {
|
|
|
173
180
|
return { ...cfgLeafStatement(leaf), nexts: [leaf.info.id], exitPoints: [] };
|
|
174
181
|
}
|
|
175
182
|
function cfgIgnore(_leaf) {
|
|
176
|
-
return { graph: new
|
|
183
|
+
return { graph: new cfg_builder_1.CfgBuilder(), breaks: [], nexts: [], returns: [], exitPoints: [], entryPoints: [] };
|
|
177
184
|
}
|
|
178
185
|
function identifyMayStatementType(node) {
|
|
179
186
|
return node.info.role === "el-c" /* RoleInParent.ExpressionListChild */ ? control_flow_graph_1.CfgVertexType.Statement : control_flow_graph_1.CfgVertexType.Expression;
|
|
180
187
|
}
|
|
181
188
|
function cfgIfThenElse(ifNode, condition, then, otherwise) {
|
|
182
189
|
const ifId = ifNode.info.id;
|
|
183
|
-
const graph = new
|
|
190
|
+
const graph = new cfg_builder_1.CfgBuilder();
|
|
184
191
|
graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(ifId, identifyMayStatementType(ifNode), { mid: condition.exitPoints, end: [control_flow_graph_1.CfgVertex.toExitId(ifId)] }));
|
|
185
192
|
graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(ifId));
|
|
186
193
|
graph.mergeWith(condition.graph);
|
|
@@ -302,7 +309,7 @@ function cfgFor(forLoop, variable, vector, body) {
|
|
|
302
309
|
}
|
|
303
310
|
function cfgFunctionDefinition(fn, params, body) {
|
|
304
311
|
const fnId = fn.info.id;
|
|
305
|
-
const graph = new
|
|
312
|
+
const graph = new cfg_builder_1.CfgBuilder();
|
|
306
313
|
let paramExits = params.flatMap(e => e.exitPoints);
|
|
307
314
|
const children = [...paramExits, control_flow_graph_1.CfgVertex.toExitId(fnId)];
|
|
308
315
|
graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(fnId), false);
|
|
@@ -456,7 +463,7 @@ const OriginToFoldTypeMap = {
|
|
|
456
463
|
[built_in_proc_name_1.BuiltInProcName.IfThenElse]: (folds, call, args, down) => {
|
|
457
464
|
// arguments are in order!
|
|
458
465
|
return folds.foldIfThenElse(call, // we will have to this more sophisticated if we rewrite the dfg based generation
|
|
459
|
-
args[0] === r_function_call_1.EmptyArgument ? (
|
|
466
|
+
args[0] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[0], args[1] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[1], args[2] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[2], down);
|
|
460
467
|
}
|
|
461
468
|
};
|
|
462
469
|
function cfgFunctionCallWithDataflow(graph, folds) {
|
|
@@ -513,7 +520,7 @@ function cfgFunctionCallWithDataflow(graph, folds) {
|
|
|
513
520
|
};
|
|
514
521
|
}
|
|
515
522
|
function cfgArgumentOrParameter(node, name, value) {
|
|
516
|
-
const graph = new
|
|
523
|
+
const graph = new cfg_builder_1.CfgBuilder();
|
|
517
524
|
const nodeId = node.info.id;
|
|
518
525
|
const info = { graph, breaks: [], nexts: [], returns: [], exitPoints: [control_flow_graph_1.CfgVertex.toExitId(nodeId)], entryPoints: [nodeId] };
|
|
519
526
|
let currentExitPoints = name?.exitPoints ?? [nodeId];
|
|
@@ -617,7 +624,7 @@ function cfgUnaryOp(unary, operand) {
|
|
|
617
624
|
function cfgExprList(node, _grouping, expressions) {
|
|
618
625
|
const nodeId = node.info.id;
|
|
619
626
|
const result = {
|
|
620
|
-
graph: new
|
|
627
|
+
graph: new cfg_builder_1.CfgBuilder(),
|
|
621
628
|
breaks: [],
|
|
622
629
|
nexts: [],
|
|
623
630
|
returns: [],
|
|
@@ -46,6 +46,13 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, ControlFlow ex
|
|
|
46
46
|
* A helper function to get the normalized AST node for the given id or fail if it does not exist.
|
|
47
47
|
*/
|
|
48
48
|
protected getNormalizedAst(id: NodeId | undefined): RNode<OtherInfo & ParentInformation> | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The logical the call's only argument resolves to, `undefined` if the call does not take exactly one
|
|
51
|
+
* argument or if that argument does not resolve to a single logical.
|
|
52
|
+
*/
|
|
53
|
+
protected getBoolArgValue(data: {
|
|
54
|
+
call: DataflowGraphVertexFunctionCall;
|
|
55
|
+
}): boolean | undefined;
|
|
49
56
|
/**
|
|
50
57
|
* See {@link DataflowAwareCfgGuidedVisitor#visitValue} for the base implementation.
|
|
51
58
|
* This now dispatches the value to the appropriate event handler based on its type.
|
|
@@ -10,6 +10,8 @@ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-functi
|
|
|
10
10
|
const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
|
|
11
11
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
12
12
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
13
|
+
const node_value_1 = require("../dataflow/eval/resolve/node-value");
|
|
14
|
+
const r_value_1 = require("../dataflow/eval/values/r-value");
|
|
13
15
|
/**
|
|
14
16
|
* This visitor extends on the {@link DataflowAwareCfgGuidedVisitor} by dispatching visitors for separate function calls as well,
|
|
15
17
|
* providing more information!
|
|
@@ -40,6 +42,17 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
40
42
|
getNormalizedAst(id) {
|
|
41
43
|
return id === undefined ? undefined : this.config.normalizedAst.idMap.get(id);
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The logical the call's only argument resolves to, `undefined` if the call does not take exactly one
|
|
47
|
+
* argument or if that argument does not resolve to a single logical.
|
|
48
|
+
*/
|
|
49
|
+
getBoolArgValue(data) {
|
|
50
|
+
if (data.call.args.length !== 1 || data.call.args[0] === r_function_call_1.EmptyArgument) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const value = node_value_1.NodeValue.inGraph.soleOf(data.call.args[0].nodeId, this.config.dfg, this.config.ctx, 'logical', { idMap: this.config.normalizedAst.idMap });
|
|
54
|
+
return value !== undefined && (0, r_value_1.isValue)(value.value) ? Boolean(value.value) : undefined;
|
|
55
|
+
}
|
|
43
56
|
/**
|
|
44
57
|
* See {@link DataflowAwareCfgGuidedVisitor#visitValue} for the base implementation.
|
|
45
58
|
* This now dispatches the value to the appropriate event handler based on its type.
|
|
@@ -262,6 +275,7 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
262
275
|
case built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs:
|
|
263
276
|
case built_in_proc_name_1.BuiltInProcName.Function:
|
|
264
277
|
case built_in_proc_name_1.BuiltInProcName.FunctionDefinition:
|
|
278
|
+
case built_in_proc_name_1.BuiltInProcName.StringTemplate:
|
|
265
279
|
case built_in_proc_name_1.BuiltInProcName.S7MakeConstructor:
|
|
266
280
|
case built_in_proc_name_1.BuiltInProcName.ClassGenerator:
|
|
267
281
|
case built_in_proc_name_1.BuiltInProcName.DefineArgument:
|