while (block != bookmark.block) { if (block.body.size() > 1) { TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); tryCatchStmt.getHandler().add(generator.generateJumpStatement( program.basicBlockAt(bookmark.exceptionHandler))); List<Statement> body = block.body.subList(0, block.body.size() - 1); tryCatchStmt.getProtectedBody().addAll(body); body.clear(); body.add(tryCatchStmt); TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); Statement jumpToHandler = generator.generateJumpStatement(program.basicBlockAt(bookmark.exceptionHandler)); if (jumpToHandler != null) { tryCatchStmt.getHandler().add(jumpToHandler); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); if (!tryCatchStmt.getProtectedBody().isEmpty()) { blockPart.add(tryCatchStmt);
private void wieldTryCatch(List<Statement> statements) { for (int i = 0; i < statements.size() - 1; ++i) { if (statements.get(i) instanceof TryCatchStatement && statements.get(i + 1) instanceof TryCatchStatement) { TryCatchStatement first = (TryCatchStatement) statements.get(i); TryCatchStatement second = (TryCatchStatement) statements.get(i + 1); if (Objects.equals(first.getExceptionType(), second.getExceptionType()) && Objects.equals(first.getExceptionVariable(), second.getExceptionVariable()) && briefStatementComparison(first.getHandler(), second.getHandler())) { first.getProtectedBody().addAll(second.getProtectedBody()); statements.remove(i + 1); wieldTryCatch(first.getProtectedBody()); --i; } } } }
@Override public void visit(TryCatchStatement statement) { super.visit(statement); if (statement.getExceptionVariable() != null) { if (variables[statement.getExceptionVariable()] < 0) { statement.setExceptionVariable(null); } else { statement.setExceptionVariable(renumber(statement.getExceptionVariable())); } } } }
@Override public void visit(TryCatchStatement statement) { List<Statement> statements = processSequence(statement.getProtectedBody()); statement.getProtectedBody().clear(); statement.getProtectedBody().addAll(statements); statements = processSequence(statement.getHandler()); statement.getHandler().clear(); statement.getHandler().addAll(statements); resultStmt = statement; }
@Override public void visit(TryCatchStatement statement) { WasmBlock block = new WasmBlock(false); for (Statement bodyPart : statement.getProtectedBody()) { accept(bodyPart); if (result != null) { block.getBody().add(result); } } result = block; }
@Override public void visit(TryCatchStatement statement) { super.visit(statement); if (statement.getExceptionType() != null) { consumer.consume(statement.getExceptionType()); } }
@Override public void visit(TryCatchStatement statement) { visit(statement.getProtectedBody()); visit(statement.getHandler()); }
@Override public void visit(TryCatchStatement statement) { super.visit(statement); if (statement.getExceptionVariable() != null) { if (variables[statement.getExceptionVariable()] < 0) { statement.setExceptionVariable(null); } else { statement.setExceptionVariable(renumber(statement.getExceptionVariable())); } } } }
@Override public void visit(TryCatchStatement statement) { WasmBlock block = new WasmBlock(false); for (Statement bodyPart : statement.getProtectedBody()) { accept(bodyPart); if (result != null) { block.getBody().add(result); } } result = block; }
@Override public void visit(TryCatchStatement statement) { super.visit(statement); if (statement.getExceptionType() != null) { consumer.consume(statement.getExceptionType()); } }
TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); tryCatchStmt.getHandler().add(generator.generateJumpStatement( program.basicBlockAt(bookmark.exceptionHandler))); List<Statement> blockPart = oldBlock.body.subList(bookmark.offset, oldBlock.body.size()); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); if (!tryCatchStmt.getProtectedBody().isEmpty()) { blockPart.add(tryCatchStmt);
@Override public void visit(TryCatchStatement statement) { try { output.writeByte(16); writeSequence(statement.getProtectedBody()); output.writeInt(statement.getExceptionType() != null ? symbolTable.lookup(statement.getExceptionType()) : -1); output.writeShort(statement.getExceptionVariable() != null ? statement.getExceptionVariable() : -1); writeSequence(statement.getHandler()); } catch (IOException e) { throw new IOExceptionWrapper(e); } }
@Override public void visit(TryCatchStatement statement) { visit(statement.getProtectedBody()); visit(statement.getHandler()); }
TryCatchStatement stmt = new TryCatchStatement(); readSequence(input, stmt.getProtectedBody()); int exceptionTypeIndex = input.readInt(); if (exceptionTypeIndex >= 0) { stmt.setExceptionType(symbolTable.at(exceptionTypeIndex)); stmt.setExceptionVariable(exceptionVarIndex); readSequence(input, stmt.getHandler()); return stmt;
List<TryCatchStatement> sequence = new ArrayList<>(); sequence.add(statement); List<Statement> protectedBody = statement.getProtectedBody(); while (protectedBody.size() == 1 && protectedBody.get(0) instanceof TryCatchStatement) { TryCatchStatement nextStatement = (TryCatchStatement) protectedBody.get(0); sequence.add(nextStatement); protectedBody = nextStatement.getProtectedBody(); if (catchClause.getExceptionType() != null) { if (!first) { writer.append(" "); writer.append("if").ws().append("($$je instanceof ").appendClass(catchClause.getExceptionType()); writer.append(")").ws(); } else { if (catchClause.getExceptionType() != null || !first) { writer.append("{").indent().softNewLine(); if (catchClause.getExceptionVariable() != null) { writer.append(variableName(catchClause.getExceptionVariable())).ws().append("=").ws() .append("$$je;").softNewLine(); visitStatements(catchClause.getHandler()); if (catchClause.getExceptionType() != null || !first) { writer.outdent().append("}");
@Override public void visit(TryCatchStatement statement) { handleList(statement.getProtectedBody()); handleList(statement.getHandler()); }
Block block = stack.peek(); while (block != bookmark.block) { TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); tryCatchStmt.getHandler().add(generator.generateJumpStatement( program.basicBlockAt(bookmark.exceptionHandler))); tryCatchStmt.getProtectedBody().addAll(block.body); block.body.clear(); if (!tryCatchStmt.getProtectedBody().isEmpty()) { block.body.add(tryCatchStmt); TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); if (node != bookmark.exceptionHandler) { tryCatchStmt.getHandler().add(generator.generateJumpStatement( program.basicBlockAt(bookmark.exceptionHandler))); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); if (!tryCatchStmt.getProtectedBody().isEmpty()) { blockPart.add(tryCatchStmt);
private void wieldTryCatch(List<Statement> statements) { for (int i = 0; i < statements.size() - 1; ++i) { if (statements.get(i) instanceof TryCatchStatement && statements.get(i + 1) instanceof TryCatchStatement) { TryCatchStatement first = (TryCatchStatement) statements.get(i); TryCatchStatement second = (TryCatchStatement) statements.get(i + 1); if (Objects.equals(first.getExceptionType(), second.getExceptionType()) && Objects.equals(first.getExceptionVariable(), second.getExceptionVariable()) && briefStatementComparison(first.getHandler(), second.getHandler())) { first.getProtectedBody().addAll(second.getProtectedBody()); statements.remove(i + 1); wieldTryCatch(first.getProtectedBody()); --i; } } } }
@Override public void visit(TryCatchStatement statement) { Map<BlockStatement, List<Statement>> oldBlockSuccessors = blockSuccessors; Set<IdentifiedStatement> oldOuterStatements = outerStatements; outerStatements = new LinkedHashSet<>(); blockSuccessors = new LinkedHashMap<>(); processSequence(statement.getProtectedBody()); outerStatements = oldOuterStatements; blockSuccessors = oldBlockSuccessors; processSequence(statement.getHandler()); }
TryCatchStatement tryCatchStmt = new TryCatchStatement(); tryCatchStmt.setExceptionType(bookmark.exceptionType); tryCatchStmt.setExceptionVariable(bookmark.exceptionVariable); tryCatchStmt.getHandler().add(generator.generateJumpStatement( program.basicBlockAt(bookmark.exceptionHandler))); List<Statement> blockPart = oldBlock.body.subList(bookmark.offset, oldBlock.body.size()); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); if (!tryCatchStmt.getProtectedBody().isEmpty()) { blockPart.add(tryCatchStmt);