@eagleoutice/flowr 2.15.9 → 2.15.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 +34 -25
- package/abstract-interpretation/absint-inference.d.ts +2 -2
- package/abstract-interpretation/absint-inference.js +32 -79
- package/benchmark/slicer.d.ts +0 -1
- package/benchmark/slicer.js +1 -2
- package/cli/repl/commands/repl-signature.js +12 -3
- package/config.d.ts +5 -1
- package/control-flow/cfg-properties.js +0 -22
- package/control-flow/happens-before.d.ts +2 -2
- package/control-flow/happens-before.js +29 -19
- package/dataflow/environments/apply-kill.js +6 -2
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-props.d.ts +7 -1
- package/dataflow/environments/built-in-props.js +8 -1
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +11 -5
- package/dataflow/environments/default-builtin-config.d.ts +386 -8
- package/dataflow/environments/default-builtin-config.js +84 -22
- package/dataflow/environments/define.d.ts +3 -2
- package/dataflow/environments/define.js +4 -3
- package/dataflow/environments/deprecation-info.d.ts +45 -0
- package/dataflow/environments/deprecation-info.js +13 -0
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/environment.js +5 -4
- package/dataflow/environments/identifier.d.ts +2 -0
- package/dataflow/extractor.js +6 -1
- package/dataflow/fn/class-declaration.d.ts +0 -11
- package/dataflow/fn/class-declaration.js +0 -20
- package/dataflow/fn/higher-order-function.d.ts +9 -1
- package/dataflow/fn/higher-order-function.js +14 -7
- package/dataflow/fn/strict-function.js +8 -3
- package/dataflow/graph/graph.d.ts +7 -0
- package/dataflow/graph/graph.js +17 -0
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/internal/linker.d.ts +3 -0
- package/dataflow/internal/linker.js +67 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +113 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +506 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +22 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -0
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +22 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -0
- package/dataflow/internal/process/functions/call/deferred.js +33 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +15 -0
- package/dataflow/internal/process/functions/call/quoted.js +137 -24
- package/dataflow/internal/process/process-symbol.js +6 -2
- package/documentation/data/faq/faqs.js +3 -3
- package/documentation/data/interface/doc-writing-code.js +1 -2
- package/documentation/data/server/doc-data-server-messages.js +7 -7
- package/documentation/doc-capabilities.js +80 -34
- package/documentation/doc-util/doc-query.d.ts +0 -3
- package/documentation/doc-util/doc-query.js +4 -3
- package/documentation/wiki-analyzer.js +1 -1
- package/documentation/wiki-cfg.js +5 -6
- package/documentation/wiki-core.js +8 -8
- package/documentation/wiki-dataflow-graph.js +10 -11
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linting-and-testing.js +3 -3
- package/documentation/wiki-overview.js +6 -6
- package/documentation/wiki-query.js +9 -101
- package/documentation/wiki-signature-database.js +1 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/deprecated-functions.d.ts +1 -45
- package/linter/rules/deprecated-functions.js +24 -33
- package/package.json +1 -1
- package/project/flowr-analyzer.d.ts +2 -0
- package/project/flowr-analyzer.js +24 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
- package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +6 -4
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.js +4 -0
- package/project/sigdb/manifest.d.ts +2 -0
- package/project/sigdb/manifest.js +10 -1
- package/project/sigdb/reader.js +23 -61
- package/project/sigdb/sigdb-download.d.ts +29 -6
- package/project/sigdb/sigdb-download.js +212 -64
- package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
- package/queries/catalog/call-context-query/cascade-action.js +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/data/data.d.ts +21 -14
- package/r-bridge/data/data.js +28 -20
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
- package/util/files.d.ts +2 -0
- package/util/files.js +3 -1
- package/util/mermaid/mermaid.js +6 -2
- package/util/version.js +2 -2
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.capabilitiesAsHtml = capabilitiesAsHtml;
|
|
7
7
|
const data_1 = require("../r-bridge/data/data");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const summary_def_1 = require("../../test/functionality/summary-def");
|
|
11
12
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
@@ -18,17 +19,34 @@ const maxSignatureTests = 3;
|
|
|
18
19
|
const preferredContext = 'dataflow';
|
|
19
20
|
const labelCallRegex = /\blabel\(\s*(['"`])((?:\\.|(?!\1)[^])*?)\1\s*,\s*\[((?:[^[\]]|\[[^[\]]*\])*)\]/g;
|
|
20
21
|
const quotedStringRegex = /(['"])((?:\\.|(?!\1)[^])*?)\1/g;
|
|
22
|
+
const literalRegex = /(['"`])((?:\\.|(?!\1)[^\\\n])*)\1/g;
|
|
23
|
+
/* suites about the tooling around the analysis, whose tests rarely show what a capability means */
|
|
24
|
+
const toolingSuiteRegex = /\/(project|plugins?|cli|server|repl)\//;
|
|
25
|
+
const genericWords = new Set(['empty', 'single', 'simple', 'basic', 'test', 'next', 'one', 'two', 'all', 'some', 'multiple', 'other', 'foo', 'bar']);
|
|
21
26
|
const operatorSpreadRegex = /\.{3}\s*OperatorDatabase\[\s*(['"])((?:\\.|(?!\1)[^])*?)\1\s*]\s*\.capabilities/g;
|
|
22
27
|
function claimedCapabilities(array) {
|
|
23
28
|
const ids = [...array.matchAll(quotedStringRegex)].map(([, , id]) => id).filter(id => capabilityNames.has(id));
|
|
24
29
|
for (const [, , operator] of array.matchAll(operatorSpreadRegex)) {
|
|
25
30
|
ids.push(...operators_1.OperatorDatabase[operator]?.capabilities ?? []);
|
|
26
31
|
}
|
|
27
|
-
return
|
|
32
|
+
return [...new Set(ids)];
|
|
33
|
+
}
|
|
34
|
+
/** a test name as the source spells it, with its escapes (`\\name`) resolved */
|
|
35
|
+
function unescapeSource(name) {
|
|
36
|
+
return name.replace(/\\([^])/g, (_, c) => /[ntr]/.test(c) ? ' ' : c);
|
|
37
|
+
}
|
|
38
|
+
/** the capabilities a `// \@signature <ids>` comment on the line of `index` or the line above names */
|
|
39
|
+
function pinnedCapabilities(content, index) {
|
|
40
|
+
const from = content.lastIndexOf('\n', content.lastIndexOf('\n', index - 1) - 1) + 1;
|
|
41
|
+
const marker = /@signature\b(.*)/.exec(content.slice(from, index));
|
|
42
|
+
return marker === null ? [] : marker[1].split(/[\s,]+/).filter(id => capabilityNames.has(id));
|
|
43
|
+
}
|
|
44
|
+
function lineAt(content, index) {
|
|
45
|
+
return content.slice(0, index).split('\n').length;
|
|
28
46
|
}
|
|
29
47
|
function indexTestSources() {
|
|
30
48
|
const byCapability = new defaultmap_1.DefaultMap(() => []);
|
|
31
|
-
const
|
|
49
|
+
const literals = new Map();
|
|
32
50
|
for (const { folder: testSourceFolder } of testSuites) {
|
|
33
51
|
if (!fs_1.default.existsSync(testSourceFolder)) {
|
|
34
52
|
continue;
|
|
@@ -36,37 +54,55 @@ function indexTestSources() {
|
|
|
36
54
|
const files = fs_1.default.readdirSync(testSourceFolder, { recursive: true, encoding: 'utf-8' }).filter(f => f.endsWith('.ts')).sort();
|
|
37
55
|
for (const file of files) {
|
|
38
56
|
const content = fs_1.default.readFileSync(path_1.default.join(testSourceFolder, file), 'utf-8');
|
|
57
|
+
const source = `${testSourceFolder}/${file.split(path_1.default.sep).join('/')}`;
|
|
58
|
+
let previousLine = 0;
|
|
59
|
+
for (const match of content.matchAll(literalRegex)) {
|
|
60
|
+
const name = unescapeSource(match[2]);
|
|
61
|
+
const line = lineAt(content, match.index);
|
|
62
|
+
if (!literals.has(name)) {
|
|
63
|
+
literals.set(name, { file: source, line });
|
|
64
|
+
}
|
|
65
|
+
/* a marker pins the name of the test, the first literal of its line, never the code after it */
|
|
66
|
+
if (line !== previousLine) {
|
|
67
|
+
for (const id of pinnedCapabilities(content, match.index)) {
|
|
68
|
+
byCapability.get(id).push({ name, file: source, line, claimed: 0, pinned: true });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
previousLine = line;
|
|
72
|
+
}
|
|
39
73
|
for (const match of content.matchAll(labelCallRegex)) {
|
|
40
|
-
const
|
|
41
|
-
const test = {
|
|
42
|
-
name: match[2],
|
|
43
|
-
file: `${testSourceFolder}/${file.split(path_1.default.sep).join('/')}`,
|
|
44
|
-
line: content.slice(0, match.index).split('\n').length,
|
|
45
|
-
claimed: ids.length,
|
|
46
|
-
opaque
|
|
47
|
-
};
|
|
48
|
-
byName.get(test.name.toLowerCase()).push(test);
|
|
74
|
+
const ids = claimedCapabilities(match[3]);
|
|
75
|
+
const test = { name: unescapeSource(match[2]), file: source, line: lineAt(content, match.index), claimed: ids.length };
|
|
49
76
|
for (const id of ids) {
|
|
50
77
|
byCapability.get(id).push(test);
|
|
51
78
|
}
|
|
52
79
|
}
|
|
53
80
|
}
|
|
54
81
|
}
|
|
55
|
-
return { byCapability,
|
|
82
|
+
return { byCapability, literals };
|
|
56
83
|
}
|
|
57
84
|
function displayName(name) {
|
|
58
|
-
return name.replace(/\$\{[^}]*}/g, '...').trim();
|
|
85
|
+
return name.replace(/\$\{[^}]*}/g, '...').replace(/\s+/g, ' ').trim();
|
|
86
|
+
}
|
|
87
|
+
/** the words of a test name that say something, so `simple x` says nothing and `a call reads its arguments` a lot */
|
|
88
|
+
function telling(name) {
|
|
89
|
+
return displayName(name).toLowerCase().split(/[^a-z0-9]+/).filter(w => w.length > 2 && !genericWords.has(w)).length;
|
|
90
|
+
}
|
|
91
|
+
/** lower is better: a pinned test wins, then a test that claims little and describes what it shows in words */
|
|
92
|
+
function signatureScore(test, preferred) {
|
|
93
|
+
return (test.pinned ? -1000 : 0) + test.claimed * 2
|
|
94
|
+
+ (preferred.has(test.name.toLowerCase()) ? 0 : 6)
|
|
95
|
+
+ (toolingSuiteRegex.test(test.file) ? 20 : 0)
|
|
96
|
+
+ Math.max(0, 4 - telling(test.name)) * 6;
|
|
59
97
|
}
|
|
60
98
|
function pickSignatureTests(tests, preferred) {
|
|
61
99
|
const unique = [...new Map(tests.map(t => [`${t.file}:${t.line}`, t])).values()];
|
|
62
|
-
const
|
|
63
|
-
const named = literal.length > 0 ? literal : unique.filter(t => /[A-Za-z0-9]/.test(displayName(t.name)));
|
|
100
|
+
const named = unique.filter(t => /[A-Za-z0-9]/.test(displayName(t.name)));
|
|
64
101
|
const picked = new Map();
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const key = displayName(test.name).toLowerCase();
|
|
102
|
+
for (const t of named.sort((a, b) => signatureScore(a, preferred) - signatureScore(b, preferred) || a.name.length - b.name.length || a.file.localeCompare(b.file) || a.line - b.line)) {
|
|
103
|
+
const key = displayName(t.name).toLowerCase();
|
|
68
104
|
if (!picked.has(key)) {
|
|
69
|
-
picked.set(key,
|
|
105
|
+
picked.set(key, t);
|
|
70
106
|
}
|
|
71
107
|
}
|
|
72
108
|
return [...picked.values()].slice(0, maxSignatureTests);
|
|
@@ -74,18 +110,12 @@ function pickSignatureTests(tests, preferred) {
|
|
|
74
110
|
function signatureTestsFor(info, capability) {
|
|
75
111
|
const recorded = info.info?.get(capability.id) ?? [];
|
|
76
112
|
const preferred = new Set(recorded.filter(l => l.context.has(preferredContext)).map(l => l.name));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const locations = info.tests.byName.get(name);
|
|
84
|
-
if (locations.length === 1 && !locations[0].opaque) {
|
|
85
|
-
byName.push(locations[0]);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return pickSignatureTests(byName, preferred);
|
|
113
|
+
/* a test a helper labels is found where its name is written */
|
|
114
|
+
const located = recorded.flatMap(({ name, capabilities }) => {
|
|
115
|
+
const at = info.tests.literals.get(name);
|
|
116
|
+
return at === undefined ? [] : [{ name, claimed: capabilities.size, ...at }];
|
|
117
|
+
});
|
|
118
|
+
return pickSignatureTests([...info.tests.byCapability.get(capability.id), ...located], preferred);
|
|
89
119
|
}
|
|
90
120
|
function capabilitySearchUrl(id) {
|
|
91
121
|
return `https://github.com/search?q=${encodeURIComponent(`repo:${doc_files_1.FlowrGithubGroupName}/flowr "'${id}'"`)}&type=code`;
|
|
@@ -295,6 +325,20 @@ function iconLabel(what) {
|
|
|
295
325
|
function foldHtml(cssClass, icon, tooltip, label, content, open = false) {
|
|
296
326
|
return `<details class="${cssClass}"${open ? ' open' : ''}><summary title="${(0, r_highlight_1.escapeHtml)(tooltip)}">${icon}<span>${label}</span></summary>${content}</details>`;
|
|
297
327
|
}
|
|
328
|
+
let revision;
|
|
329
|
+
/** the commit the page is generated from, so a link to a test line keeps pointing at that line */
|
|
330
|
+
function currentRevision() {
|
|
331
|
+
try {
|
|
332
|
+
revision ??= process.env.GITHUB_SHA ?? (0, child_process_1.execSync)('git rev-parse HEAD', { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
revision = 'main';
|
|
336
|
+
}
|
|
337
|
+
return revision;
|
|
338
|
+
}
|
|
339
|
+
function permalinkOf(file, line) {
|
|
340
|
+
return `${(0, doc_files_1.flowrSourceFileUrl)(file).replace('/tree/main/', `/blob/${currentRevision()}/`)}#L${line}`;
|
|
341
|
+
}
|
|
298
342
|
function signatureTestsHtml(info, capability) {
|
|
299
343
|
const tests = signatureTestsFor(info, capability);
|
|
300
344
|
if (tests.length === 0) {
|
|
@@ -302,7 +346,7 @@ function signatureTestsHtml(info, capability) {
|
|
|
302
346
|
}
|
|
303
347
|
const links = tests.map(t => {
|
|
304
348
|
const name = displayName(t.name);
|
|
305
|
-
return `<a href="${(
|
|
349
|
+
return `<a href="${permalinkOf(t.file, t.line)}">${(0, r_highlight_1.escapeHtml)(name.length > 72 ? name.slice(0, 69) + '...' : name)}</a>`;
|
|
306
350
|
});
|
|
307
351
|
return foldHtml('proof', icon('i-proof'), 'the tests that demonstrate this capability', 'signature tests', `<p>${links.join(', ')}</p>`);
|
|
308
352
|
}
|
|
@@ -394,9 +438,11 @@ async function capabilityHtml(info, capability, extra = false, depth = 0) {
|
|
|
394
438
|
const support = capability.supported;
|
|
395
439
|
const prose = proseOf(info, capability.id);
|
|
396
440
|
const parts = [
|
|
397
|
-
|
|
441
|
+
'<div class="head">',
|
|
398
442
|
support ? `<span class="badge ${support}" title="${support} supported"></span>` : '',
|
|
399
|
-
|
|
443
|
+
/* after the badge, so the permalink lies on top of the bullet it replaces on hover */
|
|
444
|
+
`<a class="hash" href="#${capability.id}"${iconLabel('link to this capability')}>#</a>`,
|
|
445
|
+
`<a class="name" id="${capability.id}" href="#${capability.id}" title="${(0, r_highlight_1.escapeHtml)(capability.id)}">${(0, r_highlight_1.escapeHtml)(capability.name)}</a>`,
|
|
400
446
|
versionHtml(capability),
|
|
401
447
|
testDetails(info, capability),
|
|
402
448
|
signatureTestsHtml(info, capability),
|
|
@@ -29,9 +29,6 @@ export interface QueryDocumentation {
|
|
|
29
29
|
readonly name?: string;
|
|
30
30
|
readonly type: 'virtual' | 'active';
|
|
31
31
|
readonly shortDescription: string;
|
|
32
|
-
readonly functionName: string;
|
|
33
|
-
/** Path to the file implementing the query function, the wiki generation will fail if this isn't found */
|
|
34
|
-
readonly functionFile: string;
|
|
35
32
|
readonly buildExplanation: (shell: RShell, ctx: GeneralDocContext) => Promise<string>;
|
|
36
33
|
}
|
|
37
34
|
export declare const RegisteredQueries: {
|
|
@@ -141,9 +141,10 @@ function tocForQueryType(type) {
|
|
|
141
141
|
}
|
|
142
142
|
return result.join('\n');
|
|
143
143
|
}
|
|
144
|
-
async function explainQuery(shell, ctx, id, { shortDescription,
|
|
144
|
+
async function explainQuery(shell, ctx, id, { shortDescription, buildExplanation }) {
|
|
145
145
|
const name = getQueryTitle(id);
|
|
146
|
-
const
|
|
146
|
+
const supported = query_1.SupportedQueries[id];
|
|
147
|
+
const syntax = supported?.syntax;
|
|
147
148
|
return `
|
|
148
149
|
${(0, doc_auto_gen_1.autoGenHeader)({ filename: QueryDocFile, purpose: 'query API' })}
|
|
149
150
|
${(0, doc_structure_1.section)(name + ` <sup>[<a href="${doc_files_1.FlowrWikiBaseRef}/Query-API">overview</a>]</sup>`, 2, name)}
|
|
@@ -157,7 +158,7 @@ ${await buildExplanation(shell, ctx)}
|
|
|
157
158
|
|
|
158
159
|
<summary style="color:gray">Implementation Details</summary>
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
The ${name} is executed by ${ctx.link((supported?.executor ?? virtual_queries_1.SupportedVirtualQueries[id]).name)}.
|
|
161
162
|
|
|
162
163
|
</details>
|
|
163
164
|
|
|
@@ -296,7 +296,7 @@ ${(0, doc_structure_1.section)('Project Discovery', 4)}
|
|
|
296
296
|
These plugins trigger when confronted with a project analysis request (see, ${ctx.link('RProjectAnalysisRequest')}).
|
|
297
297
|
Their job is to identify the files that belong to the project and add them to the analysis.
|
|
298
298
|
flowR provides the ${ctx.link(flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin)} with a
|
|
299
|
-
${ctx.link(flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin.name)} as the default implementation that
|
|
299
|
+
${ctx.link(flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin.name)} as the default implementation that collects all R source files in the given folder.
|
|
300
300
|
|
|
301
301
|
Please note that all project discovery plugins should conform to the ${ctx.link(flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin)} base class.
|
|
302
302
|
|
|
@@ -119,7 +119,7 @@ _flowR_ produces three main perspectives of the program: 1) a ${ctx.linkPag
|
|
|
119
119
|
2) a ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')}, and 3) a control flow graph (CFG).
|
|
120
120
|
flowR uses this CFG interweaved with its data flow analysis and for some of its queries (e.g., to link to the last call in a ${(0, doc_query_1.linkToQueryOfName)('call-context')}).
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
The control flow graph is a view on the ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')},
|
|
123
123
|
similar to the ${ctx.linkPage('wiki/Dataflow Graph', 'call graph', 'perspectives-cg')}.
|
|
124
124
|
|
|
125
125
|
${(0, doc_structure_1.block)({
|
|
@@ -251,7 +251,7 @@ There are two kinds, told apart by the ${ctx.link('CfgEdgeType')} enum.
|
|
|
251
251
|
|
|
252
252
|
${(0, doc_structure_1.section)('Flow Edges', 4, 'cfg-flow-edge')}
|
|
253
253
|
|
|
254
|
-
A flow edge says that the target
|
|
254
|
+
A flow edge says that the target runs next. In \`x; y\` there is one from \`x\` to \`y\`:
|
|
255
255
|
|
|
256
256
|
${await (0, doc_cfg_1.printCfgCode)(shell, 'x; y', { showCode: false, prefix: 'flowchart LR\n', ctx })}
|
|
257
257
|
|
|
@@ -278,7 +278,7 @@ ${await (async () => {
|
|
|
278
278
|
})()}
|
|
279
279
|
<br/>
|
|
280
280
|
|
|
281
|
-
|
|
281
|
+
Repeat loops have no control edges, as they repeat their body unconditionally.
|
|
282
282
|
Additionally, the control flow graph does not have to be connected. If you use a repeat without any exit condition,
|
|
283
283
|
the loop is never left, so its vertex is not reachable from the entry:
|
|
284
284
|
|
|
@@ -327,7 +327,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(shell, 'print(3)', { showCode: true,
|
|
|
327
327
|
|
|
328
328
|
${(0, doc_structure_1.section)('Adding Basic Blocks', 3, 'cfg-basic-blocks')}
|
|
329
329
|
|
|
330
|
-
As mentioned in the introduction, our control flow graph does not use basic blocks by default and hence
|
|
330
|
+
As mentioned in the introduction, our control flow graph does not use basic blocks by default and hence links all vertices independent of whether they have (un-)conditional jumps or not.
|
|
331
331
|
On the upside, this tells us the execution order (and, in case of promises, forcing order) of involved expressions and seamlessly handles cases like
|
|
332
332
|
\`x <- return(3)\`. On the downside, this makes it hard to apply classical control flow graph algorithms and, in general, makes the graph much harder to read.
|
|
333
333
|
Yet, we can request basic blocks or transform an existing CFG into basic blocks using the ${ctx.link(cfg_to_basic_blocks_1.convertCfgToBasicBlocks)} function.
|
|
@@ -409,8 +409,7 @@ In general, we check for a hammock graph (given that the program contains no def
|
|
|
409
409
|
|
|
410
410
|
${(0, doc_structure_1.section)('Sophisticated CFG Traversal', 3, 'cfg-traversal')}
|
|
411
411
|
|
|
412
|
-
The [simple traversal](#cfg-simple-traversal) functions are
|
|
413
|
-
that incorporates language semantics such as function calls. Hence, we provide a series of incrementally more sophisticated (but complex)
|
|
412
|
+
The [simple traversal](#cfg-simple-traversal) functions are unhandy once you need language semantics such as function calls. Hence, we provide a series of incrementally more sophisticated (but complex)
|
|
414
413
|
visitors that incorporate various alternative perspectives:
|
|
415
414
|
|
|
416
415
|
- [Basic CFG Visitor](#cfg-traversal-basic):\\
|
|
@@ -370,7 +370,7 @@ We can see that it relies on three steps:
|
|
|
370
370
|
3. **${ctx.link('STATIC_DATAFLOW', { codeFont: false })}** ([dataflow](#dataflow-graph-generation)): Produces the actual ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')} from the normalized AST.\\
|
|
371
371
|
_Its main function linked as the processor is the ${ctx.link(extractor_1.produceDataFlowGraph, { codeFont: false })} function._
|
|
372
372
|
|
|
373
|
-
To explore these steps, let's use the REPL with the (
|
|
373
|
+
To explore these steps, let's use the REPL with the (simple, contrived) R code: \`${sampleCode}\`.
|
|
374
374
|
|
|
375
375
|
${await (0, doc_repl_1.documentReplSession)(shell, [{
|
|
376
376
|
command: `:parse "${sampleCode}"`,
|
|
@@ -421,10 +421,10 @@ ${await (async () => {
|
|
|
421
421
|
|
|
422
422
|
### Parsing
|
|
423
423
|
|
|
424
|
-
The parsing step uses the ${ctx.link(shell_1.RShell)} to parse the input program (or
|
|
424
|
+
The parsing step uses the ${ctx.link(shell_1.RShell)} to parse the input program (or the ${ctx.link(tree_sitter_executor_1.TreeSitterExecutor)} when using the ${ctx.linkPage('wiki/Engines', '`tree-sitter` engine')}).
|
|
425
425
|
To speed up the process, we use the ${ctx.link(init_1.initCommand)} function to compile the parsing function and rely on a
|
|
426
426
|
custom serialization, which outputs the information in a CSV-like format.
|
|
427
|
-
|
|
427
|
+
The ${(0, doc_cli_option_1.getReplCommand)('parse')} command pretty-prints the serialized version, which looks more like the following (this uses the ${ctx.link(retriever_1.retrieveParseDataFromRCode.name)} function with the sample code \`${sampleCode}\`):
|
|
428
428
|
|
|
429
429
|
${(0, doc_structure_1.details)(`Raw parse output for <code>${sampleCode}</code>`, `For the code \`${sampleCode}\`:\n\n` + (0, doc_code_1.codeBlock)('csv', await (0, retriever_1.retrieveParseDataFromRCode)((0, retriever_1.requestFromInput)(sampleCode), shell)))}
|
|
430
430
|
|
|
@@ -526,11 +526,11 @@ While all of them are essentially empty when processing an “uninteresting leaf
|
|
|
526
526
|
|
|
527
527
|
${ctx.hierarchy(process_value_1.processValue, { maxDepth: 2, openTop: true })}
|
|
528
528
|
|
|
529
|
-
|
|
529
|
+
Note that we add the ${ctx.linkPage('wiki/Dataflow Graph', 'value vertex', 'value-vertex')} to the newly created dataflow graph,
|
|
530
530
|
which holds a reference to the constant. If you are confused with the use of the ${ctx.link('ParentInformation')} type,
|
|
531
531
|
this stems from the [AST decoration](#normalization) and signals that we have a decorated ${ctx.link(model_1.RNode)} (which may have additional information in \`OtherInfo\`).
|
|
532
532
|
|
|
533
|
-
|
|
533
|
+
When looking at the ${ctx.link('processors')} object you may be confused by
|
|
534
534
|
many lines just mapping the node to the ${ctx.link(process_named_call_1.processAsNamedCall)} function.
|
|
535
535
|
This is because during the dataflow analysis we actually "desugar" the AST, and treat syntax constructs like binary operators (e.g., \`x + y\`) as function calls (e.g. \`\` \`+\`(x, y) \`\`).
|
|
536
536
|
We do this, because R does it the same way, and allows to even overwrite these operators (including \`if\`, \`<-\`, etc.) by their name.
|
|
@@ -566,18 +566,18 @@ Afterward, we take the \`processedArguments\`, perform another round of sanity c
|
|
|
566
566
|
semantic effects of the repeat loop. We first use one of flowR's linkers to
|
|
567
567
|
${ctx.link(linker_1.linkCircularRedefinitionsWithinALoop.name)} and then retrieve the active exit points with ${ctx.link(info_1.filterOutLoopExitPoints.name)}.
|
|
568
568
|
|
|
569
|
-
|
|
569
|
+
Each of them uses the results of its children alongside the active backpack
|
|
570
570
|
to produce a new dataflow information.
|
|
571
571
|
|
|
572
572
|
## Beyond the Dataflow Graph
|
|
573
573
|
|
|
574
574
|
Given the ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')}, you can do a lot more!
|
|
575
575
|
You can issue ${ctx.linkPage('wiki/Query API', 'queries')} to explore the graph, ${ctx.linkPage('wiki/Search API', 'search')} for specific elements, or, for example, request a [static backward slice](#static-backward-slicing).
|
|
576
|
-
|
|
576
|
+
All of these work with both the ${ctx.link(shell_1.RShell)} and the ${ctx.linkPage('wiki/Engines', '`tree-sitter` engine')}.
|
|
577
577
|
|
|
578
578
|
### Static Backward Slicing
|
|
579
579
|
|
|
580
|
-
The slicing is available as an extra step
|
|
580
|
+
The slicing is available as an extra step, see the ${ctx.link('DEFAULT_SLICING_PIPELINE')}.
|
|
581
581
|
Besides ${ctx.link('STATIC_SLICE')} it contains a ${ctx.link('NAIVE_RECONSTRUCT')} to print the slice as (executable) R code.
|
|
582
582
|
|
|
583
583
|
Your main point of interesting here is the ${ctx.link(static_slicer_1.staticSlice.name)} function which relies on a modified
|
|
@@ -106,7 +106,7 @@ async function getVertexExplanations(parser, ctx) {
|
|
|
106
106
|
type: vertex_1.VertexType.Value,
|
|
107
107
|
description: `
|
|
108
108
|
Describes a constant value (numbers, booleans/logicals, strings, ...).
|
|
109
|
-
|
|
109
|
+
The respective vertex is more or less a dummy vertex.
|
|
110
110
|
|
|
111
111
|
${ctx.hierarchy('DataflowGraphVertexValue')}
|
|
112
112
|
|
|
@@ -228,8 +228,7 @@ In this case, we have a function call vertex with id \`${callId}\` and the follo
|
|
|
228
228
|
|
|
229
229
|
${(0, doc_code_1.codeBlock)('json', JSON.stringify(callVert.args, json_1.jsonReplacer, 2))}
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
as the \`type\` of these references is a bit-mask, encoding one of the following reference types:
|
|
231
|
+
This is hard to read in this form, as the \`type\` of these references is a bit-mask, encoding one of the following reference types:
|
|
233
232
|
|
|
234
233
|
| Value | Reference Type |
|
|
235
234
|
|------:|----------------|
|
|
@@ -338,7 +337,7 @@ Interesting program, right? Running this with \`u <- TRUE\` will cause the last
|
|
|
338
337
|
operator to mean multiplication, while with \`u <- FALSE\` causes \`x\` to be assigned to \`3\`.
|
|
339
338
|
In short: the last line may either refer to a definition or to a use of \`x\`, and we are not fully equipped to visualize this (this causes a warning).
|
|
340
339
|
First of all how can you spot that something weird is happening? Well, this definition has a ${linkEdgeName(edge_1.EdgeType.Reads)} and a ${linkEdgeName(edge_1.EdgeType.DefinedBy)} edge,
|
|
341
|
-
but this
|
|
340
|
+
but this does not apply to the general case.
|
|
342
341
|
|
|
343
342
|
For starters, let's have a look at the environment of the call to \`<-\` in the last line:
|
|
344
343
|
|
|
@@ -407,10 +406,10 @@ The implementation is relatively sparse and similar to the other marker vertices
|
|
|
407
406
|
${ctx.hierarchy('DataflowGraphVertexVariableDefinition')}
|
|
408
407
|
Of only interest is \`par\`, which signals that the definitions is partial (e.g., in the case of \`x[a] <- 1\`).
|
|
409
408
|
|
|
410
|
-
|
|
409
|
+
Functions can define variables too, like \`assign\`.
|
|
411
410
|
|
|
412
411
|
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]), ctx })
|
|
413
|
-
+ `\nThe example may be misleading as the visualization prints the lexeme of the variable. However, this actually defines the variable \`x\` (without the quotes) as
|
|
412
|
+
+ `\nThe example may be misleading as the visualization prints the lexeme of the variable. However, this actually defines the variable \`x\` (without the quotes), as the ${linkEdgeName(edge_1.EdgeType.Reads)} edge shows.`)}
|
|
414
413
|
|
|
415
414
|
Please be aware, that the name of the symbol defined may differ from what you read in the program as R allows the assignments to strings, escaped names, and more:
|
|
416
415
|
|
|
@@ -430,7 +429,7 @@ In this case, the definition of \`x\` is constrained by the conditional, which i
|
|
|
430
429
|
|
|
431
430
|
${finalEnvironment}
|
|
432
431
|
|
|
433
|
-
|
|
432
|
+
_flowR_ recognizes that the initial definition of \`x\` has no influence on the final value of the variable.
|
|
434
433
|
`;
|
|
435
434
|
})())}
|
|
436
435
|
|
|
@@ -471,7 +470,7 @@ ${(0, doc_structure_1.details)('Example: Nested Function Definitions', await (as
|
|
|
471
470
|
return `
|
|
472
471
|
${text}
|
|
473
472
|
|
|
474
|
-
|
|
473
|
+
The vertex ids of the subflow do not contain those of nested function definitions but again only those which are part of the respective scope (creating a tree-like structure):
|
|
475
474
|
|
|
476
475
|
| Id | Vertex Ids in Subflow |
|
|
477
476
|
|---:|-----------------------|
|
|
@@ -498,7 +497,7 @@ Let's first consider the following dataflow graph (of \`${code}\`):
|
|
|
498
497
|
${text}
|
|
499
498
|
|
|
500
499
|
The function definition we are interested in has the id \`${id}\`. Looking at the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} of the code,
|
|
501
|
-
we can get the parameters
|
|
500
|
+
we can get the parameters by requesting the \`parameters\` property of the function definition (yielding the names: [${normalized.parameters.map(p => `\`${p.name.content}\``).join(', ')}]):
|
|
502
501
|
|
|
503
502
|
${ast}
|
|
504
503
|
`;
|
|
@@ -607,7 +606,7 @@ However, nested definitions can carry it (in the nested case, \`x\` is defined b
|
|
|
607
606
|
name: 'Returns Edge',
|
|
608
607
|
type: edge_1.EdgeType.Returns,
|
|
609
608
|
description: `Link the [function call](#function-call-vertex) to the exit points of the target definition (this may incorporate the call-context).
|
|
610
|
-
|
|
609
|
+
This happens for user-defined functions (like \`foo\`) as well as for built-in functions (like \`<-\`).
|
|
611
610
|
However, these edges are specific to scenarios in which flowR knows that a specific element is returned.
|
|
612
611
|
For contrast, compare this to a use of, for example, \`+\`:
|
|
613
612
|
|
|
@@ -921,7 +920,7 @@ in the first line at the seventh character and ending in the first line at the n
|
|
|
921
920
|
${(0, doc_structure_1.section)('Arguments and Additional Information', 3, 'vtx-additional-info')}
|
|
922
921
|
|
|
923
922
|
Some vertices (e.g., [function calls](#function-call-vertex)) have additional information, like the arguments of the call.
|
|
924
|
-
As
|
|
923
|
+
As in the \`if\` example above, alongside the [vertex id](#vtx-id),
|
|
925
924
|
these vertices also have an additional line (prefixed with \`arg:\`) which lists the ids of the arguments in order to clear any ambiguity in case, for example,
|
|
926
925
|
the mermaid graph layouting fumbles the order.
|
|
927
926
|
|
|
@@ -27,7 +27,7 @@ const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
|
27
27
|
async function explainServer(parser, ctx) {
|
|
28
28
|
(0, doc_data_server_messages_1.documentAllServerMessages)(ctx);
|
|
29
29
|
return `
|
|
30
|
-
As explained in the ${ctx.linkPage('wiki/Overview', 'Overview')}, you can
|
|
30
|
+
As explained in the ${ctx.linkPage('wiki/Overview', 'Overview')}, you can run the [TCP](https://de.wikipedia.org/wiki/Transmission_Control_Protocol) server by adding the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', true)} flag (and, due to the interactive mode, exit with the conventional <kbd>CTRL</kbd>+<kbd>C</kbd>).
|
|
31
31
|
Currently, every connection is handled by the same underlying \`${shell_1.RShell.name}\` - so the server is not designed to handle many clients at a time.
|
|
32
32
|
Additionally, the server is not well guarded against attacks (e.g., you can theoretically spawn an arbitrary number of ${shell_1.RShell.name} sessions on the target machine).
|
|
33
33
|
|
|
@@ -103,7 +103,7 @@ async function explainRepl(parser, ctx) {
|
|
|
103
103
|
> Please be aware that this introduces a security risk and note that this relies on the ${ctx.linkPage('wiki/Engines', '`r-shell` engine')} .
|
|
104
104
|
|
|
105
105
|
Although primarily meant for users to explore,
|
|
106
|
-
there is nothing which forbids
|
|
106
|
+
there is nothing which forbids calling _flowR_ as a subprocess to use standard-in, -output, and -error
|
|
107
107
|
for communication (although you can access the REPL using the server as well,
|
|
108
108
|
with the [REPL Request](#message-request-repl-execution) message).
|
|
109
109
|
|
|
@@ -52,7 +52,7 @@ for the latest benchmark results, see the ${ctx.linkPage('flowr:benchmarks', 'be
|
|
|
52
52
|
## 🏨 Testing Suites
|
|
53
53
|
|
|
54
54
|
Currently, flowR contains four testing suites: one for [functionality](#functionality-tests),
|
|
55
|
-
one for [system tests](#system-tests), one for [mutation tests](#mutation-tests), and one for [performance](#performance-tests).
|
|
55
|
+
one for [system tests](#system-tests), one for [mutation tests](#mutation-tests), and one for [performance](#performance-tests).
|
|
56
56
|
In addition to running those tests, you can use the more generalized \`npm run checkup\`.
|
|
57
57
|
This command includes the construction of the docker image, the generation of the wiki and landing pages, and the linter.
|
|
58
58
|
It runs these jobs concurrently but caps the test workers so the combined run fits the machine (it splits the
|
|
@@ -124,7 +124,7 @@ The resulting labels are used in the test report that is generated as part of th
|
|
|
124
124
|
They group tests by the capabilities they test and allow the report to display how many tests ensure that any given capability is properly supported.
|
|
125
125
|
The report can be found on flowR's ${ctx.linkPage('flowr:capabilities', 'capabilities page')}.
|
|
126
126
|
|
|
127
|
-
To add new labels,
|
|
127
|
+
To add new labels, add them to the relevant section in ${(0, doc_files_1.getFilePathMd)('../r-bridge/data/data.ts')} as part of a pull request.
|
|
128
128
|
|
|
129
129
|
<a id='writing-a-test'></a>
|
|
130
130
|
#### 🖋️ Writing a Test
|
|
@@ -313,7 +313,7 @@ Otherwise, the tests will not be instantiated.
|
|
|
313
313
|
## 🪈 CI Pipeline
|
|
314
314
|
|
|
315
315
|
We have several workflows defined in ${(0, doc_files_1.linkFlowRSourceFile)('.github/workflows')}.
|
|
316
|
-
|
|
316
|
+
The most important ones:
|
|
317
317
|
|
|
318
318
|
- ${(0, doc_files_1.linkFlowRSourceFile)('.github/workflows/qa.yaml')} is the main workflow that will run different steps depending on several factors. It is responsible for:
|
|
319
319
|
- running the [functionality](#functionality-tests), [system](#system-tests), [mutation](#mutation-tests), and [performance tests](#performance-tests)
|
|
@@ -38,8 +38,8 @@ for instructions on how to install _flowR_.
|
|
|
38
38
|
|
|
39
39
|
Primarily, _flowR_ provides a dataflow analysis framework for the [*R*](https://www.r-project.org/) programming language.
|
|
40
40
|
Its subcomponents (like the custom ${ctx.link(shell_1.RShell)}) or the internals of the static ${ctx.link(graph_1.DataflowGraph)})
|
|
41
|
-
are not important if you
|
|
42
|
-
|
|
41
|
+
are not important if you only wish to use _flowR_.
|
|
42
|
+
Instead, check out one of its extensions (e.g., the ${ctx.linkPage('flowr:vscode', 'VS Code extension')}),
|
|
43
43
|
the [REPL and server interfaces](#using-flowr-from-the-outside) or its coding API with the
|
|
44
44
|
${ctx.link(flowr_analyzer_1.FlowrAnalyzer)}, which you build with the ${ctx.link(flowr_analyzer_builder_1.FlowrAnalyzerBuilder)}:
|
|
45
45
|
|
|
@@ -72,10 +72,10 @@ _flowR_ itself has two main ways to operate:
|
|
|
72
72
|
Besides these two ways, there is a ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')} that allows you to use _flowR_ directly from within the editor (it is available on ${ctx.linkPage('flowr:positron', 'open-vsx')} as well).
|
|
73
73
|
Similarly, we offer an ${ctx.linkPage('flowr:rstudio-addin', 'Addin for RStudio')}, as well as an ${ctx.linkPage('flowr:radapter', 'R package')}.
|
|
74
74
|
|
|
75
|
-
🐳️ If you use the docker-version,
|
|
75
|
+
🐳️ If you use the docker-version, starting the docker container in interactive mode drops you right into the REPL (\`docker run -it --rm eagleoutice/flowr:latest\`), while launching with the ${ctx.cliOption('flowr', 'server')} argument starts the server (\`docker run -it --rm eagleoutice/flowr:latest --server\`).\\
|
|
76
76
|
⚒️ If you compile the _flowR_ sources yourself, you can access _flowR_ by the main script \`npm run flowr\` or in the development mode \`npm run main-dev\`.
|
|
77
77
|
|
|
78
|
-
Independent of your way of launching *flowr*, we
|
|
78
|
+
Independent of your way of launching *flowr*, we write \`flowr\` for either (🐳️) \`docker run -it --rm eagleoutice/flowr:latest\` or (⚒️) \`npm run flowr\`.
|
|
79
79
|
See the ${ctx.linkPage('wiki/Setup')} wiki page for more information on how to get _flowR_ running.
|
|
80
80
|
|
|
81
81
|
### The Read-Eval-Print Loop (REPL)
|
|
@@ -166,7 +166,7 @@ The server allows accessing the REPL as well
|
|
|
166
166
|
## Calling the Scripts Directly
|
|
167
167
|
|
|
168
168
|
This describes the old way of using _flowR_ by creating and calling the respective scripts directly.
|
|
169
|
-
Although this is no longer necessary, the scripts still remain, fully integrated into the REPL of _flowR_ (you can access them
|
|
169
|
+
Although this is no longer necessary, the scripts still remain, fully integrated into the REPL of _flowR_ (you can access them by adding a colon \`:\` before the name).
|
|
170
170
|
|
|
171
171
|
### Generate Static Slices
|
|
172
172
|
|
|
@@ -227,7 +227,7 @@ For this, you can make use of the _summarizer_ script from within the \`cli\` di
|
|
|
227
227
|
npm run summarizer -- "<output.json>"
|
|
228
228
|
\`\`\`
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
The summarizer may require a long time as it parses, normalizes, and analyzes _each_ slice produced, to calculate the reduction numbers. Therefore, it actually executes two steps:
|
|
231
231
|
|
|
232
232
|
1. For each file, it calculates the reduction, required time, and other information, written to \`<output-summary.json>\`
|
|
233
233
|
2. Calculate the "ultimate" summary by aggregating the intermediate results for each file
|