}
//find the element directly after this one...
SortedSet<AbstractIntermediate> elseBranchElements = igc.getOrderedIntermediate().subSet(maxGotoForBranch, false, line, false);
AbstractIntermediate ai = igc.getSinglePredecessor(elseBranchElements.first());
if(!(ai instanceof IfIntermediate || ai instanceof ElseIfIntermediate)) {
return;
}
//get the first element...
if(elseBranchElements.size() > 0) {
AbstractIntermediate firstElseBlockElement = elseBranchElements.first();
if(firstElseBlockElement instanceof StatementIntermediate) {
//we should add the ELSE right away...
addElseBlock(firstElseBlockElement, maxGotoForBranch);
return;
}
if(firstElseBlockElement instanceof BooleanBranchIntermediate) {
//only add ELSE if the child of conditional doesn't go to the target.
BooleanBranchIntermediate ci = (BooleanBranchIntermediate)firstElseBlockElement;
if(igc.getFalseTarget(ci) == line || igc.getTrueTarget(ci) == line) {
//do nothing.
return;
}
//else if this is an ElseIf, probably should be an IF.
if(firstElseBlockElement instanceof ElseIfIntermediate) {
IfIntermediate ifIntermediate = new IfIntermediate(firstElseBlockElement.getInstruction(), ((BooleanBranchIntermediate) firstElseBlockElement).getExpression());
igc.getGraph().addVertex(ifIntermediate);
igc.redirectPredecessors(firstElseBlockElement, ifIntermediate);
igc.redirectSuccessors(firstElseBlockElement, ifIntermediate);
igc.getGraph().removeVertex(firstElseBlockElement);