예제 #1
0
 public void testContains3() {
   Expr right = factory_.createSetExpr();
   MemPred pred = factory_.createMemPred();
   pred.setLeftExpr(joker_);
   pred.setRightExpr(right);
   pred.setMixfix(Boolean.TRUE);
   assertTrue(occursCheck_.contains(pred, joker_));
 }
예제 #2
0
 /** Check that multiple instances of the same name joker are equal. */
 public void testContains5() {
   Expr left = factory_.createSetExpr();
   Expr samejoker = factory_.createJokerExpr("jokerName_", null);
   MemPred pred = factory_.createMemPred();
   pred.setLeftExpr(left);
   pred.setRightExpr(samejoker);
   pred.setMixfix(Boolean.TRUE);
   assertFalse(occursCheck_.contains(pred, joker_));
 }
예제 #3
0
 public void testContains4() {
   Expr left = factory_.createSetExpr();
   Expr joker2 = factory_.createJokerExpr("otherJoker", null);
   MemPred pred = factory_.createMemPred();
   pred.setLeftExpr(left);
   pred.setRightExpr(joker2);
   pred.setMixfix(Boolean.TRUE);
   assertFalse(occursCheck_.contains(pred, joker_));
 }
예제 #4
0
 /**
  * This function obtains from a predicate that is a conjunction of assignments the assignment
  * related to an identifier
  *
  * @param specID The identifier of a variable in the specification
  * @param pred A predicate
  * @return the equality
  */
 public static MemPred getRelatedEquality(Pred pred, String specID) {
   AbstractRepository<Pred> predRep = pred.accept(new AndPredClausesExtractor());
   AbstractIterator<Pred> predIt = predRep.createIterator();
   while (predIt.hasNext()) {
     Pred auxPred = predIt.next();
     if (auxPred instanceof MemPred) {
       MemPred memPred = ((MemPred) auxPred);
       if (memPred.getMixfix()) {
         String id = ((RefExpr) memPred.getLeftExpr()).getName().toString();
         if (id.equals(specID)) {
           return memPred;
         }
       } else return null;
     } else return null;
   }
   return null;
 }
 /* (non-Javadoc)
  * @see pea.util.z.TermToCDDVisitor#visitMemPred(net.sourceforge.czt.z.ast.MemPred)
  */
 @Override
 public CDD visitMemPred(MemPred pred) {
   if (pred.getRightExpr() instanceof RefExpr) {
     final RefExpr refExpr = (RefExpr) pred.getRightExpr();
     final ZName name = refExpr.getZName();
     // We replace expressions like a != b + c with NOT(a = b + c)
     if (name.getOperatorName().getWord().equals(Z_NEQ_OPERATOR)) {
       final ZName newRefName = factory.createZName(Z_EQUALS_OPERATOR, name.getStrokeList());
       final RefExpr newRefExpr =
           factory.createRefExpr(newRefName, refExpr.getZExprList(), refExpr.getMixfix());
       final Pred newMemPred =
           factory.createMemPred(pred.getLeftExpr(), newRefExpr, pred.getMixfix());
       return newMemPred.accept(this).negate();
     }
   }
   return visitTerm(pred);
 }