return d_typeNode->isComparableTo(*t.d_typeNode);
}
+Type Type::getBaseType() const {
+ NodeManagerScope nms(d_nodeManager);
+ return d_typeNode->getBaseType().toType();
+}
+
Type& Type::operator=(const Type& t) {
CheckArgument(d_typeNode != NULL, this, "Unexpected NULL typenode pointer!");
CheckArgument(t.d_typeNode != NULL, t, "Unexpected NULL typenode pointer!");
return d_typeNode->getSubtypePredicate().toExpr();
}
-Type PredicateSubtype::getBaseType() const {
+Type PredicateSubtype::getParentType() const {
NodeManagerScope nms(d_nodeManager);
- return d_typeNode->getSubtypeBaseType().toType();
+ return d_typeNode->getSubtypeParentType().toType();
}
SubrangeBounds SubrangeType::getSubrangeBounds() const {
*/
bool isComparableTo(Type t) const;
+ /**
+ * Get the most general base type of this type.
+ */
+ Type getBaseType() const;
+
/**
* Substitution of Types.
*/
/** Get the LAMBDA defining this predicate subtype */
Expr getPredicate() const;
- /** Get the base type of this predicate subtype */
- Type getBaseType() const;
+ /**
+ * Get the parent type of this predicate subtype; note that this
+ * could be another predicate subtype.
+ */
+ Type getParentType() const;
};/* class PredicateSubtype */
}
}
if(isPredicateSubtype()) {
- return getSubtypeBaseType().isSubtypeOf(t);
+ return getSubtypeParentType().isSubtypeOf(t);
}
return false;
}
return t.isSubtypeOf(NodeManager::currentNM()->realType());
}
if(isPredicateSubtype()) {
- return t.isComparableTo(getSubtypeBaseType());
+ return t.isComparableTo(getSubtypeParentType());
}
return false;
}
return Node::fromExpr(getConst<Predicate>());
}
-TypeNode TypeNode::getSubtypeBaseType() const {
+TypeNode TypeNode::getSubtypeParentType() const {
Assert(isPredicateSubtype());
return getSubtypePredicate().getType().getArgTypes()[0];
}
TypeNode realt = NodeManager::currentNM()->realType();
if (isSubtypeOf(realt)) {
return realt;
- }
- else if (isPredicateSubtype()) {
- return getSubtypeBaseType();
+ } else if (isPredicateSubtype()) {
+ return getSubtypeParentType().getBaseType();
}
return *this;
}
return TypeNode(); // null type
}
default:
- if(t1.isPredicateSubtype() && t1.getSubtypeBaseType().isSubtypeOf(t0)){
+ if(t1.isPredicateSubtype() && t1.getSubtypeParentType().isSubtypeOf(t0)){
return t0; // t0 is a constant type
}else{
return TypeNode(); // null type
case kind::CONSTRUCTOR_TYPE:
case kind::SELECTOR_TYPE:
case kind::TESTER_TYPE:
- if(t1.isPredicateSubtype() && t1.getSubtypeBaseType().isSubtypeOf(t0)){
+ if(t1.isPredicateSubtype() && t1.getSubtypeParentType().isSubtypeOf(t0)){
return t0;
}else{
return TypeNode();
std::vector<TypeNode> t0stack;
t0stack.push_back(t0);
while(t0stack.back().isPredicateSubtype()){
- t0stack.push_back(t0stack.back().getSubtypeBaseType());
+ t0stack.push_back(t0stack.back().getSubtypeParentType());
}
std::vector<TypeNode> t1stack;
t1stack.push_back(t1);
while(t1stack.back().isPredicateSubtype()){
- t1stack.push_back(t1stack.back().getSubtypeBaseType());
+ t1stack.push_back(t1stack.back().getSubtypeParentType());
}
Assert(!t0stack.empty());
/** Get the predicate defining this subtype */
Node getSubtypePredicate() const;
- /** Get the base type of this subtype */
- TypeNode getSubtypeBaseType() const;
+ /**
+ * Get the parent type of this subtype; note that it could be
+ * another subtype.
+ */
+ TypeNode getSubtypeParentType() const;
/** Get the most general base type of the type */
TypeNode getBaseType() const;
inline bool TypeNode::isBoolean() const {
return
( getKind() == kind::TYPE_CONSTANT && getConst<TypeConstant>() == BOOLEAN_TYPE ) ||
- ( isPredicateSubtype() && getSubtypeBaseType().isBoolean() );
+ ( isPredicateSubtype() && getSubtypeParentType().isBoolean() );
}
inline bool TypeNode::isInteger() const {
return
( getKind() == kind::TYPE_CONSTANT && getConst<TypeConstant>() == INTEGER_TYPE ) ||
isSubrange() ||
- ( isPredicateSubtype() && getSubtypeBaseType().isInteger() );
+ ( isPredicateSubtype() && getSubtypeParentType().isInteger() );
}
inline bool TypeNode::isReal() const {
return
( getKind() == kind::TYPE_CONSTANT && getConst<TypeConstant>() == REAL_TYPE ) ||
isInteger() ||
- ( isPredicateSubtype() && getSubtypeBaseType().isReal() );
+ ( isPredicateSubtype() && getSubtypeParentType().isReal() );
}
inline bool TypeNode::isString() const {
/** Is this a tuple type? */
inline bool TypeNode::isTuple() const {
return getKind() == kind::TUPLE_TYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isTuple() );
+ ( isPredicateSubtype() && getSubtypeParentType().isTuple() );
}
/** Is this a symbolic expression type? */
inline bool TypeNode::isSExpr() const {
return getKind() == kind::SEXPR_TYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isSExpr() );
+ ( isPredicateSubtype() && getSubtypeParentType().isSExpr() );
}
/** Is this a sort kind */
inline bool TypeNode::isSort() const {
return ( getKind() == kind::SORT_TYPE && !hasAttribute(expr::SortArityAttr()) ) ||
- ( isPredicateSubtype() && getSubtypeBaseType().isSort() );
+ ( isPredicateSubtype() && getSubtypeParentType().isSort() );
}
/** Is this a sort constructor kind */
/** Is this a subrange type */
inline bool TypeNode::isSubrange() const {
return getKind() == kind::SUBRANGE_TYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isSubrange() );
+ ( isPredicateSubtype() && getSubtypeParentType().isSubrange() );
}
/** Is this a bit-vector type */
inline bool TypeNode::isBitVector() const {
return getKind() == kind::BITVECTOR_TYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isBitVector() );
+ ( isPredicateSubtype() && getSubtypeParentType().isBitVector() );
}
/** Is this a datatype type */
inline bool TypeNode::isDatatype() const {
return getKind() == kind::DATATYPE_TYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isDatatype() );
+ ( isPredicateSubtype() && getSubtypeParentType().isDatatype() );
}
/** Is this a parametric datatype type */
inline bool TypeNode::isParametricDatatype() const {
return getKind() == kind::PARAMETRIC_DATATYPE ||
- ( isPredicateSubtype() && getSubtypeBaseType().isParametricDatatype() );
+ ( isPredicateSubtype() && getSubtypeParentType().isParametricDatatype() );
}
/** Is this a constructor type */
inline bool TypeNode::isBitVector(unsigned size) const {
return
( getKind() == kind::BITVECTOR_TYPE && getConst<BitVectorSize>() == size ) ||
- ( isPredicateSubtype() && getSubtypeBaseType().isBitVector(size) );
+ ( isPredicateSubtype() && getSubtypeParentType().isBitVector(size) );
}
/** Get the size of this bit-vector type */
return getConst<SubrangeBounds>();
}else{
Assert(isPredicateSubtype());
- return getSubtypeBaseType().getSubrangeBounds();
+ return getSubtypeParentType().getSubrangeBounds();
}
}
Trace("theory::internal") << "theoryOf(" << typeNode << ")" << std::endl;
TheoryId id;
while (typeNode.isPredicateSubtype()) {
- typeNode = typeNode.getSubtypeBaseType();
+ typeNode = typeNode.getSubtypeParentType();
}
if (typeNode.getKind() == kind::TYPE_CONSTANT) {
id = typeConstantToTheoryId(typeNode.getConst<TypeConstant>());
delete d_em;
}
- void testIsComparableTo() {
+ void testSubtypes() {
TypeNode realType = d_nm->realType();
TypeNode integerType = d_nm->realType();
TypeNode booleanType = d_nm->booleanType();
TS_ASSERT( not predicateSubtype.isComparableTo(bvType) );
TS_ASSERT( predicateSubtype.isComparableTo(subrangeType) );
TS_ASSERT( predicateSubtype.isComparableTo(predicateSubtype) );
+
+ TS_ASSERT(realType.getBaseType() == realType);
+ TS_ASSERT(integerType.getBaseType() == realType);
+ TS_ASSERT(booleanType.getBaseType() == booleanType);
+ TS_ASSERT(arrayType.getBaseType() == arrayType);
+ TS_ASSERT(bvType.getBaseType() == bvType);
+ TS_ASSERT(subrangeType.getBaseType() == realType);
+ TS_ASSERT(predicateSubtype.getBaseType() == realType);
+
+ TS_ASSERT(predicateSubtype.getSubtypeParentType() == integerType);
}
};/* TypeNodeWhite */