if(predecessors.size() >= 2) {
//check to see that 1 predecessor is a GOTO.
TreeSet<GoToIntermediate> incomingGotoNonNested = new TreeSet<GoToIntermediate>(new IntermediateComparator());
TreeSet<GoToIntermediate> incomingGotoNested = new TreeSet<GoToIntermediate>(new IntermediateComparator());
GoToIntermediate nestedLine = null;
AbstractIntermediate otherLine = null;
//classify.
for(AbstractIntermediate predecessor : predecessors) {
//check to see if 1 is GOTO.
if(predecessor instanceof GoToIntermediate) {
if(isNested(line, predecessor)) {
incomingGotoNested.add((GoToIntermediate)predecessor);
}
else {
incomingGotoNonNested.add((GoToIntermediate)predecessor);
}
continue;
}
else {
otherLine = predecessor;
}
}
//if there are more than one GOTO statements that are not-nested, return.
if(incomingGotoNonNested.size() > 1) {
return;
}
nestedLine = getCandidateGoto(incomingGotoNonNested, incomingGotoNested);
//stop if both conditions aren't met.
if(nestedLine == null || otherLine == null) {
return;
}
//check to validate that the GOTO instruction is less than the other incoming...
if(comparator.before(otherLine, line)) {
//take the lower condition...
BranchHandle refHandle = null;
if(comparator.before(nestedLine, line)) {
refHandle = (BranchHandle)nestedLine.getInstruction();
}
else {
refHandle = (BranchHandle)line.getInstruction();
}