@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.
Files changed (40) hide show
  1. package/README.md +21 -21
  2. package/abstract-interpretation/absint-visitor.d.ts +5 -4
  3. package/abstract-interpretation/absint-visitor.js +12 -11
  4. package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
  5. package/control-flow/basic-cfg-guided-visitor.js +7 -6
  6. package/control-flow/cfg-dead-code.js +12 -9
  7. package/control-flow/cfg-properties.d.ts +2 -2
  8. package/control-flow/cfg-properties.js +3 -2
  9. package/control-flow/cfg-to-basic-blocks.js +9 -12
  10. package/control-flow/control-flow-graph.d.ts +382 -78
  11. package/control-flow/control-flow-graph.js +591 -106
  12. package/control-flow/dfg-cfg-guided-visitor.d.ts +4 -4
  13. package/control-flow/dfg-cfg-guided-visitor.js +3 -3
  14. package/control-flow/diff-cfg.js +35 -29
  15. package/control-flow/extract-cfg.d.ts +3 -3
  16. package/control-flow/extract-cfg.js +145 -125
  17. package/control-flow/happens-before.js +2 -1
  18. package/control-flow/semantic-cfg-guided-visitor.js +2 -1
  19. package/control-flow/simple-visitor.js +8 -6
  20. package/control-flow/syntax-cfg-guided-visitor.js +2 -1
  21. package/control-flow/useless-loop.js +2 -1
  22. package/documentation/wiki-cfg.js +21 -9
  23. package/documentation/wiki-mk/doc-maker.js +1 -1
  24. package/package.json +1 -1
  25. package/project/context/flowr-file.d.ts +5 -0
  26. package/project/context/flowr-file.js +7 -0
  27. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -0
  28. package/project/plugins/file-plugins/files/flowr-description-file.js +5 -0
  29. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +4 -0
  30. package/project/plugins/file-plugins/files/flowr-namespace-file.js +8 -0
  31. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +4 -0
  32. package/project/plugins/file-plugins/files/flowr-news-file.js +8 -0
  33. package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -1
  34. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +2 -1
  35. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -19
  36. package/search/search-executor/search-generators.js +2 -2
  37. package/util/assert.d.ts +3 -3
  38. package/util/mermaid/cfg.d.ts +1 -7
  39. package/util/mermaid/cfg.js +37 -44
  40. package/util/version.js +1 -1
@@ -1,4 +1,4 @@
1
- import { type CfgBasicBlockVertex, type CfgEndMarkerVertex, type CfgExpressionVertex, type CfgSimpleVertex, type CfgStatementVertex, type ControlFlowInformation } from './control-flow-graph';
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: CfgEndMarkerVertex): void;
23
- protected visitDataflowNode(node: Exclude<CfgSimpleVertex, CfgBasicBlockVertex>): void;
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<CfgSimpleVertex, CfgBasicBlockVertex>): void;
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.end === undefined) {
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.end === undefined) {
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((0, control_flow_graph_1.getVertexRootId)(node));
39
+ const dfgVertex = this.getDataflowGraph(control_flow_graph_1.CfgVertex.getRootId(node));
40
40
  if (!dfgVertex) {
41
41
  this.visitUnknown(node);
42
42
  return;
@@ -31,8 +31,8 @@ function diffRootVertices(ctx) {
31
31
  });
32
32
  }
33
33
  function diffVertices(ctx) {
34
- const lVert = [...ctx.left.vertices(false)].map(([id, info]) => [id, info]);
35
- const rVert = [...ctx.right.vertices(false)].map(([id, info]) => [id, info]);
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
- if (lInfo.type !== rInfo.type) {
49
- ctx.report.addComment(`Vertex ${id} differs in tags. ${ctx.leftname}: ${lInfo.type} vs. ${ctx.rightname}: ${rInfo.type}`, {
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
- if (lInfo.kind !== undefined || rInfo.kind !== undefined) {
55
- if (lInfo.kind !== rInfo.kind) {
56
- ctx.report.addComment(`Vertex ${id} differs in kinds. ${ctx.leftname}: ${String(lInfo.kind)} vs ${ctx.rightname}: ${String(rInfo.kind)}`, {
57
- tag: 'vertex',
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
- if (lInfo.elems !== undefined || rInfo.elems !== undefined) {
69
- if (!(0, arrays_1.arrayEqual)((lInfo.elems ?? []), (rInfo.elems ?? []), control_flow_graph_1.equalVertex)) {
70
- ctx.report.addComment(`Vertex ${id} differs in elems.\n ${ctx.leftname}: ${JSON.stringify(lInfo.elems)}\n vs\n ${ctx.rightname}: ${JSON.stringify(rInfo.elems)}`, { tag: 'vertex', id });
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.mid ?? []), new Set(rInfo.mid ?? []), {
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.end ?? []), new Set(rInfo.end ?? []), {
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
- if (lInfo.root !== rInfo.root) {
82
- ctx.report.addComment(`Vertex ${id} differs in root. ${ctx.leftname}: ${JSON.stringify(lInfo.root)} vs ${ctx.rightname}: ${JSON.stringify(rInfo.root)}`, {
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.children), new Set(rInfo.children), {
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 chilren. `
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
- if (edge.label !== otherEdge.label) {
127
- ctx.report.addComment(`Edge ${id}->${target} differs in labels. ${ctx.leftname}: ${edge.label} vs ${ctx.rightname}: ${otherEdge.label}`, { tag: 'edge', from: id, to: target });
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
- if (edge.caused !== otherEdge.caused) {
130
- ctx.report.addComment(`Edge ${id}->${target} differs in caused. ${ctx.leftname}: ${JSON.stringify(edge.caused)} vs ${ctx.rightname}: ${JSON.stringify(otherEdge.caused)}`, { tag: 'edge', from: id, to: target });
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
- if (edge.when !== otherEdge.when) {
133
- ctx.report.addComment(`Edge ${id}->${target} differs in when. ${ctx.leftname}: ${JSON.stringify(edge.when)} vs ${ctx.rightname}: ${JSON.stringify(otherEdge.when)}`, { tag: 'edge', from: id, to: target });
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<import("./control-flow-graph").CfgSimpleVertex>;
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 = "-resolved-call-exit";
29
+ export declare const ResolvedCallSuffix: "-resolved-call-e";
30
30
  /**
31
31
  * Convert a cfg to RDF quads.
32
32
  * @see {@link df2quads}