private void print(ForLoop node) throws IOException { writer.append("for").ws().append('('); print(node.getInitializer()); writer.append(';'); print(node.getCondition()); writer.append(';'); print(node.getIncrement()); writer.append(')').ws(); print(node.getBody()); }
pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl;
if (child instanceof ForLoop) { ForLoop loop = (ForLoop) child; offset = loop.getAbsolutePosition() + loop.getLength(); if (canProcessNode(loop)) { iterateNode(loop.getInitializer(), set, entered, block, offset); addCodeBlock(loop.getBody(), set, entered, block, offset);
/** * Sets loop condition, and sets its parent to this node. * @param condition loop condition. Pass an {@link EmptyExpression} * if the condition is missing. * @throws IllegalArgumentException} if condition is {@code null} */ public void setCondition(AstNode condition) { assertNotNull(condition); this.condition = condition; condition.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("for ("); sb.append(initializer.toSource(0)); sb.append("; "); sb.append(condition.toSource(0)); sb.append("; "); sb.append(increment.toSource(0)); sb.append(") "); if (body.getType() == Token.BLOCK) { sb.append(body.toSource(depth).trim()).append("\n"); } else { sb.append("\n").append(body.toSource(depth+1)); } return sb.toString(); }
pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl;
/** * Sets loop condition, and sets its parent to this node. * @param condition loop condition. Pass an {@link EmptyExpression} * if the condition is missing. * @throws IllegalArgumentException} if condition is {@code null} */ public void setCondition(AstNode condition) { assertNotNull(condition); this.condition = condition; condition.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("for ("); sb.append(initializer.toSource(0)); sb.append("; "); sb.append(condition.toSource(0)); sb.append("; "); sb.append(increment.toSource(0)); sb.append(") "); if (body.getType() == Token.BLOCK) { sb.append(body.toSource(depth).trim()).append("\n"); } else { sb.append("\n").append(body.toSource(depth+1)); } return sb.toString(); }
private void print(ForLoop node) throws IOException { writer.append("for").ws().append('('); print(node.getInitializer()); writer.append(';'); print(node.getCondition()); writer.append(';'); print(node.getIncrement()); writer.append(')').ws(); print(node.getBody()); }
pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl;
/** * Sets loop condition, and sets its parent to this node. * @param condition loop condition. Pass an {@link EmptyExpression} * if the condition is missing. * @throws IllegalArgumentException} if condition is {@code null} */ public void setCondition(AstNode condition) { assertNotNull(condition); this.condition = condition; condition.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("for ("); sb.append(initializer.toSource(0)); sb.append("; "); sb.append(condition.toSource(0)); sb.append("; "); sb.append(increment.toSource(0)); sb.append(") "); if (body.getType() == Token.BLOCK) { sb.append(body.toSource(depth).trim()).append("\n"); } else { sb.append("\n").append(body.toSource(depth+1)); } return sb.toString(); }
private Node transformForLoop(ForLoop loop) { decompiler.addToken(Token.FOR); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); // XXX: Can't use pushScope/popScope here since 'createFor' may split // the scope Scope savedScope = currentScope; currentScope = loop; try { Node init = transform(loop.getInitializer()); decompiler.addToken(Token.SEMI); Node test = transform(loop.getCondition()); decompiler.addToken(Token.SEMI); Node incr = transform(loop.getIncrement()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createFor(loop, init, test, incr, body); } finally { currentScope = savedScope; } }
pn = fis; } else { ForLoop fl = new ForLoop(forPos); fl.setInitializer(init); fl.setCondition(cond); fl.setIncrement(incr); pn = fl;
/** * Sets loop condition, and sets its parent to this node. * @param condition loop condition. Pass an {@link EmptyExpression} * if the condition is missing. * @throws IllegalArgumentException} if condition is {@code null} */ public void setCondition(AstNode condition) { assertNotNull(condition); this.condition = condition; condition.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("for ("); sb.append(initializer.toSource(0)); sb.append("; "); sb.append(condition.toSource(0)); sb.append("; "); sb.append(increment.toSource(0)); sb.append(") "); if (body.getType() == Token.BLOCK) { sb.append(body.toSource(depth).trim()).append("\n"); } else { sb.append("\n").append(body.toSource(depth+1)); } return sb.toString(); }
private Node transformForLoop(ForLoop loop) { decompiler.addToken(Token.FOR); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); // XXX: Can't use pushScope/popScope here since 'createFor' may split // the scope Scope savedScope = currentScope; currentScope = loop; try { Node init = transform(loop.getInitializer()); decompiler.addToken(Token.SEMI); Node test = transform(loop.getCondition()); decompiler.addToken(Token.SEMI); Node incr = transform(loop.getIncrement()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createFor(loop, init, test, incr, body); } finally { currentScope = savedScope; } }
/** * Sets loop increment expression, and sets its parent to * this node. * @param increment loop increment expression. Pass an * {@link EmptyExpression} if increment is {@code null}. * @throws IllegalArgumentException} if increment is {@code null} */ public void setIncrement(AstNode increment) { assertNotNull(increment); this.increment = increment; increment.setParent(this); }
private Node transformForLoop(ForLoop loop) { decompiler.addToken(Token.FOR); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); // XXX: Can't use pushScope/popScope here since 'createFor' may split // the scope Scope savedScope = currentScope; currentScope = loop; try { Node init = transform(loop.getInitializer()); decompiler.addToken(Token.SEMI); Node test = transform(loop.getCondition()); decompiler.addToken(Token.SEMI); Node incr = transform(loop.getIncrement()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createFor(loop, init, test, incr, body); } finally { currentScope = savedScope; } }
/** * Sets loop increment expression, and sets its parent to * this node. * @param increment loop increment expression. Pass an * {@link EmptyExpression} if increment is {@code null}. * @throws IllegalArgumentException} if increment is {@code null} */ public void setIncrement(AstNode increment) { assertNotNull(increment); this.increment = increment; increment.setParent(this); }