Skip to content

Commit

Permalink
feat(irDump): Colorful return nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
byakuren-hijiri committed Jul 29, 2024
1 parent d3e11e6 commit 02380a7
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/internals/irDump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class GraphvizDumper {
output += ` color=lightgrey;\n`;
}
cfg.forEachNode(cu.ast, (stmt, node) => {
output += ` "${prefix}_${node.idx}" [label="${this.ppSummary(stmt)}"];\n`;
const color =
node.kind.kind === "return" ? ',style=filled,fillcolor="#66A7DB"' : "";
output += ` "${prefix}_${node.idx}" [label="${this.ppSummary(stmt)}"${color}];\n`;
});
cfg.forEachEdge((edge) => {
output += ` "${prefix}_${edge.src}" -> "${prefix}_${edge.dst}";\n`;
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/conditional-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ digraph "conditional-1" {
"test_142" [label="if (a > 42)"];
"test_144" [label="a = 23"];
"test_146" [label="let b: Int = a + 1"];
"test_148" [label="return b"];
"test_148" [label="return b",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/conditional-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ digraph "conditional-2" {
"test_142" [label="if (a > 42)"];
"test_144" [label="a = 23"];
"test_146" [label="a = 22"];
"test_148" [label="return a"];
"test_148" [label="return a",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_142" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/div-before-mul-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ digraph "div-before-mul-1" {
"test_142" [label="let b: Int = 3"];
"test_144" [label="let c: Int = 2"];
"test_146" [label="let result: Int = a / b * c"];
"test_148" [label="return result"];
"test_148" [label="return result",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/div-before-mul-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ digraph "div-before-mul-2" {
"test_142" [label="let b: Int = 3"];
"test_144" [label="let c: Int = 2"];
"test_146" [label="let result: Int = a * c / b"];
"test_148" [label="return result"];
"test_148" [label="return result",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/div-before-mul-3.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph "div-before-mul-3" {
"test_144" [label="let taintedWithA1: Int = 2 - a"];
"test_146" [label="let taintedWithA2: Int = 55 + taintedWithA1"];
"test_148" [label="let result: Int = taintedWithA2 * c"];
"test_150" [label="return result"];
"test_150" [label="return result",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/linear-flow-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ digraph "linear-flow-1" {
"test_141" [label="let a: Int = 20"];
"test_142" [label="let b: Int = 22"];
"test_144" [label="let c: Int = a + b"];
"test_146" [label="return c"];
"test_146" [label="return c",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/loops-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph "loops-1" {
"test_144" [label="while (i < 10)"];
"test_146" [label="i = i + 1"];
"test_148" [label="sum = sum + i"];
"test_151" [label="return sum"];
"test_151" [label="return sum",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/loops-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph "loops-2" {
"test_144" [label="until (i < 10)"];
"test_146" [label="i = i + 1"];
"test_148" [label="sum = sum + i"];
"test_151" [label="return sum"];
"test_151" [label="return sum",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/loops-3.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph "loops-3" {
"test_144" [label="repeat (10)"];
"test_146" [label="i = i + 1"];
"test_148" [label="sum = sum + i"];
"test_151" [label="return sum"];
"test_151" [label="return sum",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/never-accessed-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ digraph "never-accessed-1" {
"test_141" [label="let a: Int = 20"];
"test_142" [label="if (true)"];
"test_144" [label="a = 42"];
"test_146" [label="return 42"];
"test_146" [label="return 42",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/never-accessed-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ digraph "never-accessed-2" {
}
subgraph "cluster_FieldTest__use_f1" {
label="FieldTest__use_f1";
"FieldTest__use_f1_143" [label="return self.f1"];
"FieldTest__use_f1_143" [label="return self.f1",style=filled,fillcolor="#66A7DB"];
}
}
2 changes: 1 addition & 1 deletion test/contracts/readonly-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph "readonly-1" {
"test_144" [label="let c: Int = 24"];
"test_146" [label="if (true)"];
"test_148" [label="c = a + b"];
"test_150" [label="return c"];
"test_150" [label="return c",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_146";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/readonly-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ digraph "readonly-2" {
label="test1";
"test1_141" [label="let a: Int = 20"];
"test1_142" [label="let b: Int = 22"];
"test1_144" [label="return b"];
"test1_144" [label="return b",style=filled,fillcolor="#66A7DB"];
"test1_141" -> "test1_142";
"test1_142" -> "test1_144";
}
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/traits-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ digraph "traits-1" {
node [shape=box];
subgraph "cluster_TestContract__getter" {
label="TestContract__getter";
"TestContract__getter_141" [label="return 0"];
"TestContract__getter_141" [label="return 0",style=filled,fillcolor="#66A7DB"];
}
}
2 changes: 1 addition & 1 deletion test/contracts/unbound-loop-1.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ digraph "unbound-loop-1" {
label="test";
"test_141" [label="let a: Int = 20"];
"test_142" [label="while (a > 10)"];
"test_145" [label="return a"];
"test_145" [label="return a",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_142";
"test_142" -> "test_145";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/unbound-loop-2.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ digraph "unbound-loop-2" {
label="test";
"test_141" [label="let a: Int = 20"];
"test_142" [label="until (a > 10)"];
"test_145" [label="return a"];
"test_145" [label="return a",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_142";
"test_142" -> "test_145";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/unbound-loop-3.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ digraph "unbound-loop-3" {
"test_141" [label="let a: Int = 20"];
"test_142" [label="while (a > 10)"];
"test_144" [label="a += 1"];
"test_147" [label="return a"];
"test_147" [label="return a",style=filled,fillcolor="#66A7DB"];
"test_141" -> "test_142";
"test_142" -> "test_144";
"test_144" -> "test_142";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/unbound-loop-4.cfg.dot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ digraph "unbound-loop-4" {
"test_142" [label="let a: Int = 20"];
"test_143" [label="while (a > 10)"];
"test_145" [label="fn(a)"];
"test_148" [label="return a"];
"test_148" [label="return a",style=filled,fillcolor="#66A7DB"];
"test_142" -> "test_143";
"test_143" -> "test_145";
"test_145" -> "test_143";
Expand Down

0 comments on commit 02380a7

Please sign in to comment.