Skip to content

Commit e138d7b

Browse files
jgardn3rcirras
authored andcommitted
Add Block type to ControlFlowGraph debug logging
1 parent 82c9e8a commit e138d7b

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

delphi-frontend/src/main/java/au/com/integradev/delphi/cfg/ControlFlowGraphDebug.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private static void appendElement(StringBuilder buffer, int index, DelphiNode no
8383
}
8484

8585
private static String getBlockString(Block block) {
86-
return "B" + ((BlockImpl) block).getId();
86+
return "B" + ((BlockImpl) block).getId() + " - " + ((BlockImpl) block).getBlockType();
8787
}
8888

8989
private static <T> Optional<T> getAs(Block block, Class<T> clazz) {

delphi-frontend/src/main/java/au/com/integradev/delphi/cfg/block/BlockImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@ protected static Block getNewTarget(Block subject, Block inactiveBlock, Block ta
6767
}
6868

6969
public abstract String getDescription();
70+
71+
public abstract String getBlockType();
7072
}

delphi-frontend/src/main/java/au/com/integradev/delphi/cfg/block/ProtoBlockFactory.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public String getDescription() {
143143
"%n\tjumps to: %s%n\texceptions to: %s",
144144
getBlockString(successor), getBlocksString(exceptions));
145145
}
146+
147+
@Override
148+
public String getBlockType() {
149+
return "UnknownException";
150+
}
146151
}
147152

148153
static class CasesImpl extends BlockImpl implements Cases {
@@ -194,6 +199,11 @@ public String getDescription() {
194199
"%n\tcases to: %s%n\tfallthrough to: %s",
195200
getBlocksString(cases), getBlockString(fallthrough));
196201
}
202+
203+
@Override
204+
public String getBlockType() {
205+
return "Cases";
206+
}
197207
}
198208

199209
static class UnconditionalJumpImpl extends BlockImpl implements UnconditionalJump {
@@ -243,6 +253,11 @@ public String getDescription() {
243253
"%n\tjumps to: %s%n\twithout jump to: %s",
244254
getBlockString(target), getBlockString(withoutJump));
245255
}
256+
257+
@Override
258+
public String getBlockType() {
259+
return "UnconditionalJump";
260+
}
246261
}
247262

248263
static class LinearImpl extends BlockImpl implements Linear {
@@ -270,6 +285,11 @@ public void replaceInactiveSuccessor(Block inactiveBlock, Block target) {
270285
public String getDescription() {
271286
return String.format("%n\tjumps to: %s", getBlockString(successor));
272287
}
288+
289+
@Override
290+
public String getBlockType() {
291+
return "Linear";
292+
}
273293
}
274294

275295
static class FinallyImpl extends BlockImpl implements Finally {
@@ -307,6 +327,11 @@ public String getDescription() {
307327
"%n\tjumps to: %s%n\texits to: %s",
308328
getBlockString(successor), getBlockString(exceptionSuccessor));
309329
}
330+
331+
@Override
332+
public String getBlockType() {
333+
return "Finally";
334+
}
310335
}
311336

312337
static class HaltImpl extends BlockImpl implements Halt {
@@ -339,6 +364,11 @@ public void replaceInactiveSuccessor(Block inactiveBlock, Block target) {
339364
public String getDescription() {
340365
return String.format("%n\tno successors");
341366
}
367+
368+
@Override
369+
public String getBlockType() {
370+
return "Halt";
371+
}
342372
}
343373

344374
private static class TerminusImpl extends BlockImpl implements Terminus {
@@ -356,6 +386,11 @@ public void replaceInactiveSuccessor(Block inactiveBlock, Block target) {
356386
public String getDescription() {
357387
return String.format("%n\t(Exit)");
358388
}
389+
390+
@Override
391+
public String getBlockType() {
392+
return "Terminus";
393+
}
359394
}
360395

361396
static class BranchImpl extends BlockImpl implements Branch {
@@ -405,5 +440,10 @@ public String getDescription() {
405440
"%n\tjumps to: %s(true) %s(false)",
406441
getBlockString(trueBlock), getBlockString(falseBlock));
407442
}
443+
444+
@Override
445+
public String getBlockType() {
446+
return "Branch";
447+
}
408448
}
409449
}

0 commit comments

Comments
 (0)