private static void addEdge(InstructionImpl begin, InstructionImpl end) {
    begin.addSuccessor(end);
    end.addPredecessor(begin);

    if (!(begin instanceof ReadWriteVariableInstruction || begin instanceof MixinTypeInstruction)) {
      end.addNegationsFrom(begin);
    }
  }
 @Nullable
 private InstructionImpl findInstruction(PsiElement element) {
   final Iterator<InstructionImpl> iterator = myProcessingStack.descendingIterator();
   while (iterator.hasNext()) {
     final InstructionImpl instruction = iterator.next();
     if (element.equals(instruction.getElement())) return instruction;
   }
   return null;
 }
 private void checkPending(@NotNull InstructionImpl instruction) {
   final PsiElement element = instruction.getElement();
   List<Pair<InstructionImpl, GroovyPsiElement>> target =
       collectCorrespondingPendingEdges(element);
   for (Pair<InstructionImpl, GroovyPsiElement> pair : target) {
     addEdge(pair.getFirst(), instruction);
   }
 }
Beispiel #4
0
 private void markDeadInstructions() {
   Set<Instruction> instructionSet = Sets.newHashSet(instructions);
   for (Instruction instruction : mutableInstructionList) {
     if (!instructionSet.contains(instruction)) {
       ((InstructionImpl) instruction).setMarkedAsDead(true);
       for (Instruction nextInstruction : instruction.getNextInstructions()) {
         nextInstruction.getPreviousInstructions().remove(instruction);
       }
     }
   }
 }
  public void visitReturnStatement(GrReturnStatement returnStatement) {
    boolean isNodeNeeded = myHead == null || myHead.getElement() != returnStatement;
    final GrExpression value = returnStatement.getReturnValue();
    if (value != null) value.accept(this);

    if (isNodeNeeded) {
      InstructionImpl returnInstruction = startNode(returnStatement);
      addPendingEdge(null, myHead);
      finishNode(returnInstruction);
    } else {
      addPendingEdge(null, myHead);
    }
    interruptFlow();
  }
 private void finishNode(InstructionImpl instruction) {
   final InstructionImpl popped = myProcessingStack.pop();
   if (!instruction.equals(popped)) {
     String description =
         "popped: "
             + popped.toString()
             + " : "
             + popped.hashCode()
             + "   ,  expected: "
             + instruction.toString()
             + " : "
             + instruction.hashCode();
     error(description);
   }
 }