예제 #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;
   }
 }
예제 #2
0
 public ProducedType getNonemptySequenceType(ProducedType pt) {
   return pt.minus(getEmptyDeclaration()).getSupertype(getSequenceDeclaration());
 }
예제 #3
0
 public ProducedType getNonemptyIterableType(ProducedType pt) {
   return pt.minus(getEmptyDeclaration()).getSupertype(getIterableDeclaration());
 }
예제 #4
0
 public ProducedType getNonemptyDefiniteType(ProducedType pt) {
   return pt.minus(getNothingDeclaration()).minus(getEmptyDeclaration());
 }