/** * Creates a block statement from the given list of statements. * @param stmts Initial statements for the block * @param introducesNewScope Determines whether the block introduces a new lexical scope. This * should be false in the case of a function body, as this has the same * lexical scope as the function parameters. */ public BlockStmt(List<Stmt> stmts, boolean introducesNewScope) { setStmts(stmts); this.introducesNewScope = introducesNewScope; }
@Override public void visitBlockStmt(BlockStmt stmt) { List<Stmt> newStmts = new ArrayList<>(); for (Stmt s : stmt.getStmts()) { if (shouldRemove.test(s)) { Optional<Stmt> possibleReplacement = maybeReplaceWith.apply(s); if (possibleReplacement.isPresent()) { newStmts.add(possibleReplacement.get()); } continue; } newStmts.add(s); } stmt.setStmts(newStmts); super.visitBlockStmt(stmt); }
@Override public void visitBlockStmt(BlockStmt blockStmt) { super.visitBlockStmt(blockStmt); final List<List<Stmt>> regionStack = new ArrayList<>(); regionStack.add(new ArrayList<>()); for (Stmt stmt : blockStmt.getStmts()) { addToCurrentRegion(regionStack, stmt); if (containsReturn(stmt)) { regionStack.add(new ArrayList<>()); } } blockStmt.setStmts(regionStackToStmts(regionStack)); }
@Override void applyReductionImpl() { List<Stmt> newStmts = new ArrayList<>(); for (int i = 0; i < block.getNumStmts(); i++) { if (i == indexOfBackupDeclaration().get()) { continue; } if (i >= indexOfAssignmentToBackup().get() && i <= indexOfRestorationFromBackup().get()) { continue; } newStmts.add(block.getStmt(i)); } block.setStmts(newStmts); }
generator, generationParams)); block.setStmts(Arrays.asList(new SwitchStmt(new FunctionCallExpr(Constants.GLF_SWITCH, zero), new BlockStmt(switchBodyStmts, true))));