| 26 | import static com.google.common.base.Preconditions.checkState; |
| 27 | |
| 28 | public class IfStatement |
| 29 | implements FlowControl |
| 30 | { |
| 31 | private final String comment; |
| 32 | private final BytecodeBlock condition = new BytecodeBlock(); |
| 33 | private final BytecodeBlock ifTrue = new BytecodeBlock(); |
| 34 | private final BytecodeBlock ifFalse = new BytecodeBlock(); |
| 35 | |
| 36 | private final LabelNode falseLabel = new LabelNode("false"); |
| 37 | private final LabelNode outLabel = new LabelNode("out"); |
| 38 | |
| 39 | public IfStatement() |
| 40 | { |
| 41 | this.comment = null; |
| 42 | } |
| 43 | |
| 44 | public IfStatement(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 BytecodeBlock condition() |
| 56 | { |
| 57 | return condition; |
| 58 | } |
| 59 | |
| 60 | public IfStatement condition(BytecodeNode node) |
| 61 | { |
| 62 | checkState(condition.isEmpty(), "condition already set"); |
| 63 | condition.append(node); |
| 64 | return this; |
| 65 | } |
| 66 | |
| 67 | public BytecodeBlock ifTrue() |
| 68 | { |
| 69 | return ifTrue; |
| 70 | } |
| 71 | |
| 72 | public IfStatement ifTrue(BytecodeNode node) |
| 73 | { |
| 74 | checkState(ifTrue.isEmpty(), "ifTrue already set"); |
| 75 | ifTrue.append(node); |
| 76 | return this; |
| 77 | } |
| 78 | |
| 79 | public BytecodeBlock ifFalse() |
| 80 | { |
| 81 | return ifFalse; |
| 82 | } |
| 83 | |
| 84 | public IfStatement ifFalse(BytecodeNode node) |
| 85 | { |
nothing calls this directly
no outgoing calls
no test coverage detected