| 26 | import static com.google.common.base.Preconditions.checkState; |
| 27 | |
| 28 | public class ForLoop |
| 29 | implements FlowControl |
| 30 | { |
| 31 | private final String comment; |
| 32 | private final BytecodeBlock initialize = new BytecodeBlock(); |
| 33 | private final BytecodeBlock condition = new BytecodeBlock(); |
| 34 | private final BytecodeBlock update = new BytecodeBlock(); |
| 35 | private final BytecodeBlock body = new BytecodeBlock(); |
| 36 | |
| 37 | private final LabelNode beginLabel = new LabelNode("beginLabel"); |
| 38 | private final LabelNode continueLabel = new LabelNode("continue"); |
| 39 | private final LabelNode endLabel = new LabelNode("end"); |
| 40 | |
| 41 | public ForLoop() |
| 42 | { |
| 43 | this.comment = null; |
| 44 | } |
| 45 | |
| 46 | public ForLoop(String format, Object... args) |
| 47 | { |
| 48 | this.comment = String.format(format, args); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public String getComment() |
| 53 | { |
| 54 | return comment; |
| 55 | } |
| 56 | |
| 57 | public LabelNode getContinueLabel() |
| 58 | { |
| 59 | return continueLabel; |
| 60 | } |
| 61 | |
| 62 | public LabelNode getEndLabel() |
| 63 | { |
| 64 | return endLabel; |
| 65 | } |
| 66 | |
| 67 | public BytecodeBlock initialize() |
| 68 | { |
| 69 | return initialize; |
| 70 | } |
| 71 | |
| 72 | public ForLoop initialize(BytecodeNode node) |
| 73 | { |
| 74 | checkState(initialize.isEmpty(), "initialize already set"); |
| 75 | initialize.append(node); |
| 76 | return this; |
| 77 | } |
| 78 | |
| 79 | public BytecodeBlock condition() |
| 80 | { |
| 81 | return condition; |
| 82 | } |
| 83 | |
| 84 | public ForLoop condition(BytecodeNode node) |
| 85 | { |
nothing calls this directly
no outgoing calls
no test coverage detected