Split methods
This commit is contained in:
parent
5ea988992a
commit
47bff81942
1 changed files with 15 additions and 16 deletions
|
@ -123,22 +123,21 @@ public class CFG {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String node2str(Node s) {
|
private String node2str(Node n) {
|
||||||
if (s == beginNode)
|
if (n == beginNode) return "Start";
|
||||||
return "Start";
|
if (n == endNode) return "Stop";
|
||||||
if (s == endNode)
|
return String.format("\"(%d, %d) %s\"", indexOfNode(n) + 1, n.getRange().get().begin.line, escape(n.toString()));
|
||||||
return "Stop";
|
}
|
||||||
int index = -1;
|
|
||||||
for (int i = 0; i < nodes.size(); i++) {
|
private int indexOfNode(Node n) {
|
||||||
if (nodes.get(i) == s) {
|
for (int i = 0; i < nodes.size(); i++)
|
||||||
index = i;
|
if (nodes.get(i) == n)
|
||||||
break;
|
return i;
|
||||||
}
|
throw new RuntimeException("Internal error, can't find node in list");
|
||||||
}
|
}
|
||||||
if (index == -1)
|
|
||||||
throw new RuntimeException("Internal error, can't find node");
|
private String escape(String s) {
|
||||||
return "\"(" + (index + 1) + ", " + s.getRange().get().begin.line + ") "
|
return s.replace("\"", "\\\"");
|
||||||
+ s.toString().replace("\"", "\\\"") + "\"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int clusterId = 0;
|
private static int clusterId = 0;
|
||||||
|
|
Loading…
Reference in a new issue