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