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);
   }
 }
Example #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();
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public void eUnset(int featureID) {
   switch (featureID) {
     case AsmPackage.PROC_DECLARATION__NAME:
       setName(NAME_EDEFAULT);
       return;
     case AsmPackage.PROC_DECLARATION__ARGS:
       getArgs().clear();
       return;
     case AsmPackage.PROC_DECLARATION__PROC_CALL:
       getProcCall().clear();
       return;
     case AsmPackage.PROC_DECLARATION__INSTRUCTIONS:
       getInstructions().clear();
       return;
   }
   super.eUnset(featureID);
 }
 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);
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @SuppressWarnings("unchecked")
 @Override
 public void eSet(int featureID, Object newValue) {
   switch (featureID) {
     case AsmPackage.PROC_DECLARATION__NAME:
       setName((String) newValue);
       return;
     case AsmPackage.PROC_DECLARATION__ARGS:
       getArgs().clear();
       getArgs().addAll((Collection<? extends Parameter>) newValue);
       return;
     case AsmPackage.PROC_DECLARATION__PROC_CALL:
       getProcCall().clear();
       getProcCall().addAll((Collection<? extends ProcCall>) newValue);
       return;
     case AsmPackage.PROC_DECLARATION__INSTRUCTIONS:
       getInstructions().clear();
       getInstructions().addAll((Collection<? extends Instruction>) newValue);
       return;
   }
   super.eSet(featureID, newValue);
 }