Exemplo n.º 1
0
 @Override
 public void visit(WhileStatement statement) {
   if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) {
     WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0);
     BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement);
     replacer.visitSequence(innerLoop.getBody());
     statement.getBody().clear();
     statement.getBody().addAll(innerLoop.getBody());
   }
   List<Statement> statements = processSequence(statement.getBody());
   for (int i = 0; i < statements.size(); ++i) {
     if (statements.get(i) instanceof ContinueStatement) {
       ContinueStatement continueStmt = (ContinueStatement) statements.get(i);
       if (continueStmt.getTarget() == statement) {
         statements.subList(i, statements.size()).clear();
         break;
       }
     }
   }
   statement.getBody().clear();
   statement.getBody().addAll(statements);
   if (statement.getCondition() != null) {
     List<Statement> sequenceBackup = resultSequence;
     resultSequence = new ArrayList<>();
     statement.getCondition().acceptVisitor(this);
     statement.setCondition(resultExpr);
     resultSequence = sequenceBackup;
   }
   while (true) {
     if (!statement.getBody().isEmpty()
         && statement.getBody().get(0) instanceof ConditionalStatement) {
       ConditionalStatement cond = (ConditionalStatement) statement.getBody().get(0);
       if (cond.getConsequent().size() == 1
           && cond.getConsequent().get(0) instanceof BreakStatement) {
         BreakStatement breakStmt = (BreakStatement) cond.getConsequent().get(0);
         if (breakStmt.getTarget() == statement) {
           statement.getBody().remove(0);
           if (statement.getCondition() != null) {
             Expr newCondition =
                 Expr.binary(
                     BinaryOperation.AND,
                     statement.getCondition(),
                     ExprOptimizer.invert(cond.getCondition()));
             newCondition.setLocation(statement.getCondition().getLocation());
             statement.setCondition(newCondition);
           } else {
             statement.setCondition(ExprOptimizer.invert(cond.getCondition()));
           }
           continue;
         }
       }
     }
     break;
   }
   resultStmt = statement;
 }
 /*
  * @see ASTVisitor#visit(ContinueStatement)
  */
 @Override
 public boolean visit(ContinueStatement node) {
   this.fBuffer.append("continue"); // $NON-NLS-1$
   if (node.getLabel() != null) {
     this.fBuffer.append(" "); // $NON-NLS-1$
     node.getLabel().accept(this);
   }
   this.fBuffer.append(";"); // $NON-NLS-1$
   return false;
 }
Exemplo n.º 3
0
 @Override
 public Void visitContinueStatement(ContinueStatement node) {
   writer.print("continue");
   visit(" ", node.getLabel());
   writer.print(";");
   return null;
 }
Exemplo n.º 4
0
 Statement generateJumpStatement(BasicBlock target) {
   if (nextBlock == target && blockMap[target.getIndex()] == null) {
     return null;
   }
   Decompiler.Block block = blockMap[target.getIndex()];
   if (block == null) {
     throw new IllegalStateException("Could not find block for basic block $" + target.getIndex());
   }
   if (target.getIndex() == indexer.nodeAt(block.end)) {
     BreakStatement breakStmt = new BreakStatement();
     breakStmt.setLocation(currentLocation);
     breakStmt.setTarget(block.statement);
     return breakStmt;
   } else {
     ContinueStatement contStmt = new ContinueStatement();
     contStmt.setLocation(currentLocation);
     contStmt.setTarget(block.statement);
     return contStmt;
   }
 }