boolean areAbstractSuccessors(
      AbstractState pElement,
      CFAEdge pCfaEdge,
      Collection<? extends AbstractState> pSuccessors,
      List<ConfigurableProgramAnalysis> cpas)
      throws CPATransferException, InterruptedException {
    Preconditions.checkNotNull(pCfaEdge);

    CompositeState compositeState = (CompositeState) pElement;

    int resultCount = 1;
    boolean result = true;
    for (int i = 0; i < size; ++i) {
      Set<AbstractState> componentSuccessors = new HashSet<>();
      for (AbstractState successor : pSuccessors) {
        CompositeState compositeSuccessor = (CompositeState) successor;
        if (compositeSuccessor.getNumberOfStates() != size) {
          return false;
        }
        componentSuccessors.add(compositeSuccessor.get(i));
      }
      resultCount *= componentSuccessors.size();
      ProofChecker componentProofChecker = (ProofChecker) cpas.get(i);
      if (!componentProofChecker.areAbstractSuccessors(
          compositeState.get(i), pCfaEdge, componentSuccessors)) {
        result =
            false; // if there are no successors it might be still ok if one of the other components
                   // is fine with the empty set
      } else {
        if (componentSuccessors.isEmpty()) {
          assert pSuccessors.isEmpty();
          return true; // another component is indeed fine with the empty set as set of successors;
                       // transition is ok
        }
      }
    }

    if (resultCount > pSuccessors.size()) {
      return false;
    }

    HashSet<List<AbstractState>> states = new HashSet<>();
    for (AbstractState successor : pSuccessors) {
      states.add(((CompositeState) successor).getWrappedStates());
    }
    if (resultCount != states.size()) {
      return false;
    }

    return result;
  }
  private Collection<List<AbstractState>> callTransferRelation(
      final CompositeState compositeState,
      final CompositePrecision compositePrecision,
      final CFAEdge cfaEdge)
      throws CPATransferException, InterruptedException {
    int resultCount = 1;
    List<AbstractState> componentElements = compositeState.getWrappedStates();
    checkArgument(
        componentElements.size() == size, "State with wrong number of component states given");
    List<Collection<? extends AbstractState>> allComponentsSuccessors = new ArrayList<>(size);

    for (int i = 0; i < size; i++) {
      TransferRelation lCurrentTransfer = transferRelations.get(i);
      AbstractState lCurrentElement = componentElements.get(i);
      Precision lCurrentPrecision = compositePrecision.get(i);

      Collection<? extends AbstractState> componentSuccessors;
      componentSuccessors =
          lCurrentTransfer.getAbstractSuccessorsForEdge(
              lCurrentElement, lCurrentPrecision, cfaEdge);
      resultCount *= componentSuccessors.size();

      if (resultCount == 0) {
        // shortcut
        break;
      }

      allComponentsSuccessors.add(componentSuccessors);
    }

    // create cartesian product of all elements we got
    return createCartesianProduct(allComponentsSuccessors, resultCount);
  }
Ejemplo n.º 3
0
 public void characters(char[] ch, int start, int length) throws SAXParseException {
   if (DEBUG) {
     trace("CHARS");
   }
   try {
     state = state.chars(ch, start, length);
   } catch (IOException exn) {
     die(exn);
   } catch (IllegalStateException exn) {
     die(exn);
   }
 }
Ejemplo n.º 4
0
 public void endDocument() throws SAXParseException {
   if (DEBUG) {
     trace("END document");
   }
   try {
     state = state.end(null);
   } catch (IOException exn) {
     die(exn);
   } catch (IllegalStateException exn) {
     die(exn);
   }
 }
Ejemplo n.º 5
0
 public void endElement(String ns, String lname, String qname) throws SAXParseException {
   if (DEBUG) {
     trace("END " + qname);
   }
   assert qname == elts.peek();
   atts.pop();
   try {
     state = state.end(atts.peek());
   } catch (IOException exn) {
     die(exn);
   } catch (IllegalStateException exn) {
     die(exn);
   }
   elts.pop();
 }
Ejemplo n.º 6
0
 public void startElement(String ns, String lname, String qname, Attributes attr)
     throws SAXParseException {
   if (DEBUG) {
     trace("START " + qname);
   }
   HashMap<Integer, String> attm = new HashMap<Integer, String>();
   for (int i = 0; i < attr.getLength(); i++) {
     attm.put(encodeName(attr.getURI(i), attr.getLocalName(i)), attr.getValue(i));
   }
   elts.push(qname);
   atts.push(attm);
   try {
     state = state.start(encodeName(ns, lname), attm);
   } catch (IOException exn) {
     die(exn);
   } catch (IllegalStateException exn) {
     die(exn);
   }
 }
Ejemplo n.º 7
0
 public void startDocument() {
   state.initialize(initialState());
   elts.clear();
   atts.clear();
   atts.push(null);
 }
Ejemplo n.º 8
0
 protected void trace(String msg) {
   state.show(dbg);
   dbg.print("  <> ");
   dbg.println(msg);
 }