@eagleoutice/flowr 2.9.7 → 2.9.9
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 +21 -21
- package/abstract-interpretation/absint-visitor.d.ts +5 -4
- package/abstract-interpretation/absint-visitor.js +12 -11
- package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
- package/control-flow/basic-cfg-guided-visitor.js +7 -6
- package/control-flow/cfg-dead-code.js +12 -9
- package/control-flow/cfg-properties.d.ts +2 -2
- package/control-flow/cfg-properties.js +3 -2
- package/control-flow/cfg-to-basic-blocks.js +9 -12
- package/control-flow/control-flow-graph.d.ts +382 -78
- package/control-flow/control-flow-graph.js +591 -106
- package/control-flow/dfg-cfg-guided-visitor.d.ts +4 -4
- package/control-flow/dfg-cfg-guided-visitor.js +3 -3
- package/control-flow/diff-cfg.js +35 -29
- package/control-flow/extract-cfg.d.ts +3 -3
- package/control-flow/extract-cfg.js +145 -125
- package/control-flow/happens-before.js +2 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -1
- package/control-flow/simple-visitor.js +8 -6
- package/control-flow/syntax-cfg-guided-visitor.js +2 -1
- package/control-flow/useless-loop.js +2 -1
- package/documentation/wiki-cfg.js +21 -9
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/package.json +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +7 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +5 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +8 -0
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-news-file.js +8 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -19
- package/search/search-executor/search-generators.js +2 -2
- package/util/assert.d.ts +3 -3
- package/util/mermaid/cfg.d.ts +1 -7
- package/util/mermaid/cfg.js +37 -44
- package/util/version.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CfgBasicBlockVertex, type
|
|
1
|
+
import { type CfgBasicBlockVertex, type CfgMarkerVertex, type CfgExpressionVertex, CfgVertex, type CfgStatementVertex, type ControlFlowInformation } from './control-flow-graph';
|
|
2
2
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexUse, type DataflowGraphVertexValue, type DataflowGraphVertexVariableDefinition } from '../dataflow/graph/vertex';
|
|
4
4
|
import { type BasicCfgGuidedVisitorConfiguration, BasicCfgGuidedVisitor } from './basic-cfg-guided-visitor';
|
|
@@ -19,12 +19,12 @@ export declare class DataflowAwareCfgGuidedVisitor<ControlFlow extends ControlFl
|
|
|
19
19
|
protected getDataflowGraph(id: NodeId): DataflowGraphVertexArgument | undefined;
|
|
20
20
|
protected onStatementNode(node: CfgStatementVertex): void;
|
|
21
21
|
protected onExpressionNode(node: CfgExpressionVertex): void;
|
|
22
|
-
protected onEndMarkerNode(node:
|
|
23
|
-
protected visitDataflowNode(node: Exclude<
|
|
22
|
+
protected onEndMarkerNode(node: CfgMarkerVertex): void;
|
|
23
|
+
protected visitDataflowNode(node: Exclude<CfgVertex, CfgBasicBlockVertex>): void;
|
|
24
24
|
/**
|
|
25
25
|
* called for every cfg vertex that has no corresponding dataflow vertex.
|
|
26
26
|
*/
|
|
27
|
-
protected visitUnknown(_vertex: Exclude<
|
|
27
|
+
protected visitUnknown(_vertex: Exclude<CfgVertex, CfgBasicBlockVertex>): void;
|
|
28
28
|
protected visitValue(_val: DataflowGraphVertexValue): void;
|
|
29
29
|
protected visitVariableUse(_use: DataflowGraphVertexUse): void;
|
|
30
30
|
protected visitVariableDefinition(_def: DataflowGraphVertexVariableDefinition): void;
|
|
@@ -19,13 +19,13 @@ class DataflowAwareCfgGuidedVisitor extends basic_cfg_guided_visitor_1.BasicCfgG
|
|
|
19
19
|
}
|
|
20
20
|
onStatementNode(node) {
|
|
21
21
|
super.onStatementNode(node);
|
|
22
|
-
if (this.config.defaultVisitingType !== 'exit' || node
|
|
22
|
+
if (this.config.defaultVisitingType !== 'exit' || control_flow_graph_1.CfgVertex.getEnd(node) === undefined) {
|
|
23
23
|
this.visitDataflowNode(node);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
onExpressionNode(node) {
|
|
27
27
|
super.onExpressionNode(node);
|
|
28
|
-
if (this.config.defaultVisitingType !== 'exit' || node
|
|
28
|
+
if (this.config.defaultVisitingType !== 'exit' || control_flow_graph_1.CfgVertex.getEnd(node) === undefined) {
|
|
29
29
|
this.visitDataflowNode(node);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -36,7 +36,7 @@ class DataflowAwareCfgGuidedVisitor extends basic_cfg_guided_visitor_1.BasicCfgG
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
visitDataflowNode(node) {
|
|
39
|
-
const dfgVertex = this.getDataflowGraph(
|
|
39
|
+
const dfgVertex = this.getDataflowGraph(control_flow_graph_1.CfgVertex.getRootId(node));
|
|
40
40
|
if (!dfgVertex) {
|
|
41
41
|
this.visitUnknown(node);
|
|
42
42
|
return;
|
package/control-flow/diff-cfg.js
CHANGED
|
@@ -31,8 +31,8 @@ function diffRootVertices(ctx) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function diffVertices(ctx) {
|
|
34
|
-
const lVert =
|
|
35
|
-
const rVert =
|
|
34
|
+
const lVert = ctx.left.vertices(false).entries().map(([id, info]) => [id, info]).toArray();
|
|
35
|
+
const rVert = ctx.right.vertices(false).entries().map(([id, info]) => [id, info]).toArray();
|
|
36
36
|
if (lVert.length < rVert.length && !ctx.config.leftIsSubgraph
|
|
37
37
|
|| lVert.length > rVert.length && !ctx.config.rightIsSubgraph) {
|
|
38
38
|
ctx.report.addComment(`Detected different number of vertices! ${ctx.leftname} has ${lVert.length}, ${ctx.rightname} has ${rVert.length}`);
|
|
@@ -45,48 +45,48 @@ function diffVertices(ctx) {
|
|
|
45
45
|
}
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const lType = control_flow_graph_1.CfgVertex.getType(lInfo);
|
|
49
|
+
const rType = control_flow_graph_1.CfgVertex.getType(rInfo);
|
|
50
|
+
if (lType !== rType) {
|
|
51
|
+
ctx.report.addComment(`Vertex ${id} differs in tags. ${ctx.leftname}: ${control_flow_graph_1.CfgVertex.typeToString(lType)} vs. ${ctx.rightname}: ${control_flow_graph_1.CfgVertex.typeToString(rType)}`, {
|
|
50
52
|
tag: 'vertex',
|
|
51
53
|
id
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
id
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (lInfo.callTargets !== undefined || rInfo.callTargets !== undefined) {
|
|
63
|
-
(0, diff_1.setDifference)(new Set(lInfo.callTargets ?? []), new Set(rInfo.callTargets ?? []), {
|
|
56
|
+
const lCt = control_flow_graph_1.CfgVertex.getCallTargets(lInfo);
|
|
57
|
+
const rCt = control_flow_graph_1.CfgVertex.getCallTargets(rInfo);
|
|
58
|
+
if (lCt !== undefined || rCt !== undefined) {
|
|
59
|
+
(0, diff_1.setDifference)(new Set(lCt ?? []), new Set(rCt ?? []), {
|
|
64
60
|
...ctx,
|
|
65
61
|
position: `${ctx.position}Vertex ${id} differs in call targets. `
|
|
66
62
|
});
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
const lElems = control_flow_graph_1.CfgVertex.isBlock(lInfo) ? control_flow_graph_1.CfgVertex.getBasicBlockElements(lInfo) : undefined;
|
|
65
|
+
const rElems = control_flow_graph_1.CfgVertex.isBlock(rInfo) ? control_flow_graph_1.CfgVertex.getBasicBlockElements(rInfo) : undefined;
|
|
66
|
+
if (lElems !== undefined || rElems !== undefined) {
|
|
67
|
+
if (!(0, arrays_1.arrayEqual)((lElems ?? []), (rElems ?? []), control_flow_graph_1.CfgVertex.equal)) {
|
|
68
|
+
ctx.report.addComment(`Vertex ${id} differs in elems.\n ${ctx.leftname}: ${JSON.stringify(lElems)}\n vs\n ${ctx.rightname}: ${JSON.stringify(rElems)}`, { tag: 'vertex', id });
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
(0, diff_1.setDifference)(new Set(lInfo
|
|
71
|
+
(0, diff_1.setDifference)(new Set(control_flow_graph_1.CfgVertex.getMid(lInfo) ?? []), new Set(control_flow_graph_1.CfgVertex.getMid(rInfo) ?? []), {
|
|
74
72
|
...ctx,
|
|
75
73
|
position: `${ctx.position}Vertex ${id} differs in attached mid markers. `
|
|
76
74
|
});
|
|
77
|
-
(0, diff_1.setDifference)(new Set(lInfo
|
|
75
|
+
(0, diff_1.setDifference)(new Set(control_flow_graph_1.CfgVertex.getEnd(lInfo) ?? []), new Set(control_flow_graph_1.CfgVertex.getEnd(rInfo) ?? []), {
|
|
78
76
|
...ctx,
|
|
79
77
|
position: `${ctx.position}Vertex ${id} differs in attached end markers. `
|
|
80
78
|
});
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const lRoot = control_flow_graph_1.CfgVertex.getRootId(lInfo);
|
|
80
|
+
const rRoot = control_flow_graph_1.CfgVertex.getRootId(rInfo);
|
|
81
|
+
if (lRoot !== rRoot) {
|
|
82
|
+
ctx.report.addComment(`Vertex ${id} differs in root. ${ctx.leftname}: ${JSON.stringify(lRoot)} vs ${ctx.rightname}: ${JSON.stringify(rRoot)}`, {
|
|
83
83
|
tag: 'vertex',
|
|
84
84
|
id
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
(0, diff_1.setDifference)(new Set(lInfo
|
|
87
|
+
(0, diff_1.setDifference)(new Set(control_flow_graph_1.CfgVertex.getChildren(lInfo)), new Set(control_flow_graph_1.CfgVertex.getChildren(rInfo)), {
|
|
88
88
|
...ctx,
|
|
89
|
-
position: `${ctx.position}Vertex ${id} differs in
|
|
89
|
+
position: `${ctx.position}Vertex ${id} differs in children. `
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -123,14 +123,20 @@ function diffOutgoingEdges(ctx) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
function diffEdge(edge, otherEdge, ctx, id, target) {
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const el = control_flow_graph_1.CfgEdge.getType(edge);
|
|
127
|
+
const ol = control_flow_graph_1.CfgEdge.getType(otherEdge);
|
|
128
|
+
if (el !== ol) {
|
|
129
|
+
ctx.report.addComment(`Edge ${id}->${target} differs in labels. ${ctx.leftname}: ${el} vs ${ctx.rightname}: ${ol}`, { tag: 'edge', from: id, to: target });
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
const ec = control_flow_graph_1.CfgEdge.getCause(edge);
|
|
132
|
+
const oc = control_flow_graph_1.CfgEdge.getCause(otherEdge);
|
|
133
|
+
if (ec !== oc) {
|
|
134
|
+
ctx.report.addComment(`Edge ${id}->${target} differs in caused. ${ctx.leftname}: ${JSON.stringify(ec)} vs ${ctx.rightname}: ${JSON.stringify(oc)}`, { tag: 'edge', from: id, to: target });
|
|
131
135
|
}
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
const ew = control_flow_graph_1.CfgEdge.getWhen(edge);
|
|
137
|
+
const ow = control_flow_graph_1.CfgEdge.getWhen(otherEdge);
|
|
138
|
+
if (ew !== ow) {
|
|
139
|
+
ctx.report.addComment(`Edge ${id}->${target} differs in when. ${ctx.leftname}: ${JSON.stringify(ew)} vs ${ctx.rightname}: ${JSON.stringify(ow)}`, { tag: 'edge', from: id, to: target });
|
|
134
140
|
}
|
|
135
141
|
}
|
|
136
142
|
function diffEdges(ctx, id, lEdges, rEdges) {
|
|
@@ -3,7 +3,7 @@ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
|
3
3
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { DataflowGraph } from '../dataflow/graph/graph';
|
|
5
5
|
import type { DataflowGraphVertexFunctionCall } from '../dataflow/graph/vertex';
|
|
6
|
-
import { type ControlFlowInformation } from './control-flow-graph';
|
|
6
|
+
import { CfgVertex, type ControlFlowInformation } from './control-flow-graph';
|
|
7
7
|
import { type CfgSimplificationPassName } from './cfg-simplification';
|
|
8
8
|
import type { ReadOnlyFlowrAnalyzerContext } from '../project/context/flowr-analyzer-context';
|
|
9
9
|
/**
|
|
@@ -21,12 +21,12 @@ export declare function extractCfg<Info = ParentInformation>(ast: NormalizedAst<
|
|
|
21
21
|
/**
|
|
22
22
|
* A version of {@link extractCfg} that is much quicker and does not apply any simplifications or dataflow information.
|
|
23
23
|
*/
|
|
24
|
-
export declare function extractCfgQuick<Info = ParentInformation>(ast: NormalizedAst<Info>): ControlFlowInformation<
|
|
24
|
+
export declare function extractCfgQuick<Info = ParentInformation>(ast: NormalizedAst<Info>): ControlFlowInformation<CfgVertex>;
|
|
25
25
|
/**
|
|
26
26
|
* Extracts all function call vertices from the given control flow information and dataflow graph.
|
|
27
27
|
*/
|
|
28
28
|
export declare function getCallsInCfg(cfg: ControlFlowInformation, graph: DataflowGraph): Map<NodeId, Required<DataflowGraphVertexFunctionCall>>;
|
|
29
|
-
export declare const ResolvedCallSuffix
|
|
29
|
+
export declare const ResolvedCallSuffix: "-resolved-call-e";
|
|
30
30
|
/**
|
|
31
31
|
* Convert a cfg to RDF quads.
|
|
32
32
|
* @see {@link df2quads}
|