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