Beispiel #1
0
 /**
  * Eliminate the given type from the union type. (Performs a set complement operation.) Note that
  * this operation is not robust and only works if this is a union of the given type with some
  * other types that don't involve the given type.
  */
 public ProducedType minus(ClassOrInterface ci) {
   if (getDeclaration().equals(ci)) {
     return new BottomType(getDeclaration().getUnit()).getType();
   } else if (getDeclaration() instanceof UnionType) {
     List<ProducedType> types = new ArrayList<ProducedType>();
     for (ProducedType ct : getCaseTypes()) {
       if (ct.getSupertype(ci) == null) {
         addToUnion(types, ct.minus(ci));
       }
     }
     UnionType ut = new UnionType(getDeclaration().getUnit());
     ut.setCaseTypes(types);
     return ut.getType();
   } else {
     return this;
   }
 }
Beispiel #2
0
 public ProducedType getNonemptySequenceType(ProducedType pt) {
   return pt.minus(getEmptyDeclaration()).getSupertype(getSequenceDeclaration());
 }
Beispiel #3
0
 public ProducedType getNonemptyIterableType(ProducedType pt) {
   return pt.minus(getEmptyDeclaration()).getSupertype(getIterableDeclaration());
 }
Beispiel #4
0
 public ProducedType getNonemptyDefiniteType(ProducedType pt) {
   return pt.minus(getNothingDeclaration()).minus(getEmptyDeclaration());
 }