private void print(TryStatement node) throws IOException { writer.append("try "); print(node.getTryBlock()); for (CatchClause cc : node.getCatchClauses()) { writer.ws().append("catch").ws().append('('); print(cc.getVarName()); if (cc.getCatchCondition() != null) { writer.append(" if "); print(cc.getCatchCondition()); } writer.append(')'); print(cc.getBody()); } if (node.getFinallyBlock() != null) { writer.ws().append("finally "); print(node.getFinallyBlock()); } }
CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>();
decompiler.addToken(Token.LP); String varName = cc.getVarName().getIdentifier(); decompiler.addName(varName); AstNode ccc = cc.getCatchCondition(); if (ccc != null) { decompiler.addName(" "); decompiler.addEOL(Token.LC); Node body = transform(cc.getBody()); decompiler.addEOL(Token.RC); body, cc.getLineno()));
offset = clause.getAbsolutePosition() + clause.getLength(); CodeBlock catchBlock = block.getParent().addChildCodeBlock( clause.getAbsolutePosition()); catchBlock.setEndOffset(offset); AstNode target = clause.getVarName(); addCodeBlock(clause.getBody(), set, entered, catchBlock, offset);
public boolean isIf() { return node.getCatchCondition() != null; }
/** * Sets catch body, and sets its parent to this node. * @throws IllegalArgumentException if body is {@code null} */ public void setBody(Block body) { assertNotNull(body); this.body = body; body.setParent(this); }
@Override public CAstNode visitCatchClause(CatchClause node, WalkContext arg) { return visit(node.getBody(), arg); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("catch ("); sb.append(varName.toSource(0)); if (catchCondition != null) { sb.append(" if "); sb.append(catchCondition.toSource(0)); } sb.append(") "); sb.append(body.toSource(0)); return sb.toString(); }
CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>();
decompiler.addToken(Token.LP); String varName = cc.getVarName().getIdentifier(); decompiler.addName(varName); AstNode ccc = cc.getCatchCondition(); if (ccc != null) { decompiler.addName(" "); decompiler.addEOL(Token.LC); Node body = transform(cc.getBody()); decompiler.addEOL(Token.RC); body, cc.getLineno()));
/** * Sets catch body, and sets its parent to this node. * @throws IllegalArgumentException if body is {@code null} */ public void setBody(Block body) { assertNotNull(body); this.body = body; body.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("catch ("); sb.append(varName.toSource(0)); if (catchCondition != null) { sb.append(" if "); sb.append(catchCondition.toSource(0)); } sb.append(") "); sb.append(body.toSource(0)); return sb.toString(); }
CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>();
decompiler.addToken(Token.LP); String varName = cc.getVarName().getIdentifier(); decompiler.addName(varName); AstNode ccc = cc.getCatchCondition(); if (ccc != null) { decompiler.addName(" "); decompiler.addEOL(Token.LC); Node body = transform(cc.getBody()); decompiler.addEOL(Token.RC); body, cc.getLineno()));
private void print(TryStatement node) throws IOException { writer.append("try "); print(node.getTryBlock()); for (CatchClause cc : node.getCatchClauses()) { writer.ws().append("catch").ws().append('('); print(cc.getVarName()); if (cc.getCatchCondition() != null) { writer.append(" if "); print(cc.getCatchCondition()); } writer.append(')'); print(cc.getBody()); } if (node.getFinallyBlock() != null) { writer.ws().append("finally "); print(node.getFinallyBlock()); } }
/** * Sets catch body, and sets its parent to this node. * @throws IllegalArgumentException if body is {@code null} */ public void setBody(Block body) { assertNotNull(body); this.body = body; body.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("catch ("); sb.append(varName.toSource(0)); if (catchCondition != null) { sb.append(" if "); sb.append(catchCondition.toSource(0)); } sb.append(") "); sb.append(body.toSource(0)); return sb.toString(); }
CatchClause catchNode = new CatchClause(catchPos); catchNode.setVarName(varName); catchNode.setCatchCondition(catchCond); catchNode.setBody(catchBlock); if (guardPos != -1) { catchNode.setIfPosition(guardPos - catchPos); catchNode.setParens(lp, rp); catchNode.setLineno(catchLineNum); catchNode.setLength(tryEnd - catchPos); if (clauses == null) clauses = new ArrayList<CatchClause>();
decompiler.addToken(Token.LP); String varName = cc.getVarName().getIdentifier(); decompiler.addName(varName); AstNode ccc = cc.getCatchCondition(); if (ccc != null) { decompiler.addName(" "); decompiler.addEOL(Token.LC); Node body = transform(cc.getBody()); decompiler.addEOL(Token.RC); body, cc.getLineno()));
String catchVarName = catches.get(0).getVarName().getString(); CAstNode var = Ast.makeConstant(catchVarName); for(int i = catches.size()-1; i >= 0; i--) { CatchClause clause = catches.get(i); if (clause.getCatchCondition() != null) { code = Ast.makeNode(CAstNode.IF_STMT, visit(clause.getCatchCondition(), arg), visit(clause.getBody(), arg), code); } else { code = visit(clause, arg);