コード例 #1
0
 @Nullable
 private InstructionImpl reduceAllNegationsIntoInstruction(
     GroovyPsiElement currentScope, List<? extends GotoInstruction> negations) {
   if (negations.size() > 1) {
     InstructionImpl instruction = addNode(new InstructionImpl(currentScope));
     for (GotoInstruction negation : negations) {
       addEdge(negation, instruction);
     }
     return instruction;
   } else if (negations.size() == 1) {
     GotoInstruction instruction = negations.get(0);
     myHead = instruction;
     return instruction;
   }
   return null;
 }
コード例 #2
0
  public Instruction[] buildControlFlow(GroovyPsiElement scope) {
    myInstructions = new ArrayList<InstructionImpl>();
    myProcessingStack = new ArrayDeque<InstructionImpl>();
    myCaughtExceptionInfos = new ArrayDeque<ExceptionInfo>();
    myConditions = new ArrayDeque<ConditionInstruction>();

    myFinallyCount = 0;
    myPending = new ArrayList<Pair<InstructionImpl, GroovyPsiElement>>();
    myInstructionNumber = 0;

    myScope = scope;

    startNode(null);
    if (scope instanceof GrClosableBlock) {
      buildFlowForClosure((GrClosableBlock) scope);
    } else {
      scope.accept(this);
    }

    final InstructionImpl end = startNode(null);
    checkPending(end); // collect return edges

    return assertValidPsi(myInstructions.toArray(new Instruction[myInstructions.size()]));
  }