| 9 | import unluac.parse.LFunction; |
| 10 | |
| 11 | public class AlwaysLoop extends ContainerBlock { |
| 12 | |
| 13 | private final boolean repeat; |
| 14 | |
| 15 | private ConstantExpression condition; |
| 16 | |
| 17 | public AlwaysLoop(LFunction function, int begin, int end, CloseType closeType, int closeLine, boolean repeat) { |
| 18 | super(function, begin, end, closeType, closeLine, 0); |
| 19 | this.repeat = repeat; |
| 20 | condition = null; |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public int scopeEnd() { |
| 25 | return usingClose && closeType == CloseType.CLOSE ? closeLine - 1 : end - 2; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public boolean breakable() { |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public boolean isUnprotected() { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public int getUnprotectedTarget() { |
| 40 | return begin; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public int getUnprotectedLine() { |
| 45 | return end - 1; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public int getLoopback() { |
| 50 | return begin; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void print(Decompiler d, Output out) { |
| 55 | if(repeat) { |
| 56 | out.println("repeat"); |
| 57 | } else { |
| 58 | out.print("while "); |
| 59 | if(condition == null) { |
| 60 | out.print("true"); |
| 61 | } else { |
| 62 | condition.print(d, out); |
| 63 | } |
| 64 | out.println(" do"); |
| 65 | } |
| 66 | out.indent(); |
| 67 | Statement.printSequence(d, out, statements); |
| 68 | out.dedent(); |
nothing calls this directly
no outgoing calls
no test coverage detected