Esempio n. 1
0
 @Override
 public void visit(SequentialStatement statement) {
   List<Statement> statements = processSequence(statement.getSequence());
   if (statements.size() == 1) {
     resultStmt = statements.get(0);
   } else {
     statement.getSequence().clear();
     statement.getSequence().addAll(statements);
     resultStmt = statement;
   }
 }
Esempio n. 2
0
 @Override
 public void visit(BlockStatement statement) {
   List<Statement> statements = processSequence(statement.getBody());
   eliminateRedundantBreaks(statements, statement);
   BlockCountVisitor usageCounter = new BlockCountVisitor(statement);
   usageCounter.visit(statements);
   if (usageCounter.getCount() == 0) {
     SequentialStatement result = new SequentialStatement();
     result.getSequence().addAll(statements);
     resultStmt = result;
   } else {
     statement.getBody().clear();
     statement.getBody().addAll(statements);
     resultStmt = statement;
   }
 }