summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr/type_node.cpp13
-rw-r--r--src/expr/type_node.h6
2 files changed, 19 insertions, 0 deletions
diff --git a/src/expr/type_node.cpp b/src/expr/type_node.cpp
index 8cfb6387a..4ddb01974 100644
--- a/src/expr/type_node.cpp
+++ b/src/expr/type_node.cpp
@@ -102,6 +102,19 @@ bool TypeNode::isSubtypeOf(TypeNode t) const {
return false;
}
+bool TypeNode::isComparableTo(TypeNode t) const {
+ if(*this == t) {
+ return true;
+ }
+ if(isSubtypeOf(NodeManager::currentNM()->realType())) {
+ return t.isSubtypeOf(NodeManager::currentNM()->realType());
+ }
+ if(isPredicateSubtype()) {
+ return t.isComparableTo(getSubtypeBaseType());
+ }
+ return false;
+}
+
Node TypeNode::getSubtypePredicate() const {
Assert(isPredicateSubtype());
return Node::fromExpr(getConst<Predicate>());
diff --git a/src/expr/type_node.h b/src/expr/type_node.h
index f59ce2dfe..7fe3bc75e 100644
--- a/src/expr/type_node.h
+++ b/src/expr/type_node.h
@@ -450,6 +450,12 @@ public:
/** Is this type a subtype of the given type? */
bool isSubtypeOf(TypeNode t) const;
+ /**
+ * Is this type comparable to the given type (i.e., do they share
+ * a common ancestor in the subtype tree)?
+ */
+ bool isComparableTo(TypeNode t) const;
+
/** Is this the Boolean type? */
bool isBoolean() const;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback