예제 #1
0
 private static boolean canInsertContinue(
     BlockNode pred,
     List<BlockNode> predecessors,
     BlockNode loopEnd,
     Set<BlockNode> loopExitNodes) {
   if (!pred.contains(AFlag.SYNTHETIC) || BlockUtils.checkLastInsnType(pred, InsnType.CONTINUE)) {
     return false;
   }
   List<BlockNode> preds = pred.getPredecessors();
   if (preds.isEmpty()) {
     return false;
   }
   BlockNode codePred = preds.get(0);
   if (codePred.contains(AFlag.SKIP)) {
     return false;
   }
   if (loopEnd.isDominator(codePred) || loopExitNodes.contains(codePred)) {
     return false;
   }
   if (isDominatedOnBlocks(codePred, predecessors)) {
     return false;
   }
   boolean gotoExit = false;
   for (BlockNode exit : loopExitNodes) {
     if (BlockUtils.isPathExists(codePred, exit)) {
       gotoExit = true;
       break;
     }
   }
   return gotoExit;
 }
예제 #2
0
 private static boolean isDominatedOnBlocks(BlockNode dom, List<BlockNode> blocks) {
   for (BlockNode node : blocks) {
     if (!node.isDominator(dom)) {
       return false;
     }
   }
   return true;
 }