conditionAddress = 0;
condition = null;
}
// add jump
Jump jump = new Jump();
fInstructions.add(jump);
fCounter++;
if (hasCondition) {
// add conditional jump
ConditionalJump condJump = new ConditionalJump(false);
fInstructions.insert(condJump, conditionAddress + 1);
bodyAddress++;
bodyStartAddress++;
updatersAddress++;
fCounter++;
// set conditional jump offset
condJump.setOffset(body.getSize() + updaters.getSize() + 1);
}
// set jump offset
jump.setOffset(-((hasCondition && (condition != null) ? condition
.getSize() : 0) + body.getSize() + updaters.getSize() + 2));
// for each pending break or continue instruction which are related to
// this loop, set the offset of the corresponding jump.
for (Iterator<CompleteInstruction> iter = fCompleteInstructions.iterator(); iter.hasNext();) {
CompleteInstruction instruction = iter.next();
Jump jumpInstruction = instruction.fInstruction;
int instructionAddress = fInstructions.indexOf(jumpInstruction);
if (instructionAddress > bodyStartAddress
&& (instruction.fLabel == null || instruction.fLabel
.equals(label))) {
iter.remove();
if (instruction.fIsBreak) {
// jump to the instruction after the last jump
jumpInstruction
.setOffset((updatersAddress - instructionAddress) + 1);
} else {
// jump to the first instruction of the condition
jumpInstruction.setOffset(bodyAddress - instructionAddress);
}
}
}
storeInstruction();