*/
void assignNodeValue(expr::NodeValue* ev);
+ inline void assertTNodeNotExpired() const throw(AssertionException) {
+ if(!ref_count) {
+ Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
+ }
+ }
+
public:
/** Default constructor, makes a null expression. */
* @return true if null
*/
bool isNull() const {
+ assertTNodeNotExpired();
return d_nv == &expr::NodeValue::s_null;
}
*/
template <bool ref_count_1>
bool operator==(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv == node.d_nv;
}
*/
template <bool ref_count_1>
bool operator!=(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv != node.d_nv;
}
*/
template <bool ref_count_1>
inline bool operator<(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv->d_id < node.d_nv->d_id;
}
*/
template <bool ref_count_1>
inline bool operator>(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv->d_id > node.d_nv->d_id;
}
*/
template <bool ref_count_1>
inline bool operator<=(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv->d_id <= node.d_nv->d_id;
}
*/
template <bool ref_count_1>
inline bool operator>=(const NodeTemplate<ref_count_1>& node) const {
+ assertTNodeNotExpired();
+ node.assertTNodeNotExpired();
return d_nv->d_id >= node.d_nv->d_id;
}
* @return the node representing the i-th child
*/
NodeTemplate operator[](int i) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
return NodeTemplate(d_nv->getChild(i));
}
* @return true if const
*/
inline bool isConst() const {
+ assertTNodeNotExpired();
return getMetaKind() == kind::metakind::CONSTANT;
}
* @return the ud
*/
unsigned getId() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->getId();
}
* @return the kind
*/
inline Kind getKind() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return Kind(d_nv->d_kind);
}
* @return the metakind
*/
inline kind::MetaKind getMetaKind() const {
+ assertTNodeNotExpired();
return kind::metaKindOf(getKind());
}
* @return the iterator
*/
inline iterator begin() {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->begin< NodeTemplate<ref_count> >();
}
* @return the end of the children iterator.
*/
inline iterator end() {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->end< NodeTemplate<ref_count> >();
}
*/
template <Kind kind>
inline iterator begin() {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->begin< NodeTemplate<ref_count>, kind >();
}
*/
template <Kind kind>
inline iterator end() {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->end< NodeTemplate<ref_count>, kind >();
}
* @return the const_iterator
*/
inline const_iterator begin() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->begin< NodeTemplate<ref_count> >();
}
* @return the end of the children const_iterator.
*/
inline const_iterator end() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->end< NodeTemplate<ref_count> >();
}
*/
template <Kind kind>
inline const_iterator begin() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->begin< NodeTemplate<ref_count>, kind >();
}
*/
template <Kind kind>
inline const_iterator end() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->end< NodeTemplate<ref_count>, kind >();
}
* @return the string representation of this node.
*/
inline std::string toString() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return d_nv->toString();
}
*/
inline void toStream(std::ostream& out, int toDepth = -1,
bool types = false) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
d_nv->toStream(out, toDepth, types);
}
template <bool ref_count>
inline size_t NodeTemplate<ref_count>::getNumChildren() const {
+ assertTNodeNotExpired();
return d_nv->getNumChildren();
}
template <bool ref_count>
template <class T>
inline const T& NodeTemplate<ref_count>::getConst() const {
+ assertTNodeNotExpired();
return d_nv->getConst<T>();
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
return NodeManager::currentNM()->getAttribute(*this, AttrKind());
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
return NodeManager::currentNM()->hasAttribute(*this, AttrKind());
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
return NodeManager::currentNM()->getAttribute(*this, AttrKind(), ret);
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
NodeManager::currentNM()->setAttribute(*this, AttrKind(), value);
}
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value!");
d_nv = e.d_nv;
if(ref_count) {
+ Assert(d_nv->d_rc > 0, "Node constructed from TNode with rc == 0");
d_nv->inc();
} else {
- // shouldn't ever happen
- Assert(d_nv->d_rc > 0,
- "TNode constructed from Node with rc == 0");
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0, "TNode constructed from Node with rc == 0");
}
}
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value!");
d_nv = e.d_nv;
if(ref_count) {
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0, "Node constructed from Node with rc == 0");
d_nv->inc();
} else {
Assert(d_nv->d_rc > 0, "TNode constructed from TNode with rc == 0");
NodeTemplate<ref_count>::~NodeTemplate() throw(AssertionException) {
Assert(d_nv != NULL, "Expecting a non-NULL expression value!");
if(ref_count) {
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0, "Node reference count would be negative");
d_nv->dec();
- } else {
- Assert(d_nv->d_rc > 0 || d_nv->isBeingDeleted() || NodeManager::currentNM()->inDestruction(),
- "TNode pointing to an expired NodeValue at destruction time");
}
}
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!");
if(EXPECT_TRUE( d_nv != e.d_nv )) {
if(ref_count) {
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0,
+ "Node reference count would be negative");
d_nv->dec();
}
d_nv = e.d_nv;
if(ref_count) {
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0, "Node assigned from Node with rc == 0");
d_nv->inc();
} else {
Assert(d_nv->d_rc > 0, "TNode assigned from TNode with rc == 0");
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!");
if(EXPECT_TRUE( d_nv != e.d_nv )) {
if(ref_count) {
+ // shouldn't ever fail
+ Assert(d_nv->d_rc > 0, "Node reference count would be negative");
d_nv->dec();
}
d_nv = e.d_nv;
if(ref_count) {
+ Assert(d_nv->d_rc > 0, "Node assigned from TNode with rc == 0");
d_nv->inc();
} else {
// shouldn't ever happen
- Assert(d_nv->d_rc > 0,
- "TNode assigned from Node with rc == 0");
+ Assert(d_nv->d_rc > 0, "TNode assigned from Node with rc == 0");
}
}
return *this;
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::eqNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::EQUAL, *this, right);
}
template <bool ref_count>
NodeTemplate<true> NodeTemplate<ref_count>::notNode() const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::NOT, *this);
}
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::andNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::AND, *this, right);
}
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::orNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::OR, *this, right);
}
NodeTemplate<true>
NodeTemplate<ref_count>::iteNode(const NodeTemplate<ref_count>& thenpart,
const NodeTemplate<ref_count>& elsepart) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::ITE, *this, thenpart, elsepart);
}
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::iffNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::IFF, *this, right);
}
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::impNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::IMPLIES, *this, right);
}
template <bool ref_count>
NodeTemplate<true>
NodeTemplate<ref_count>::xorNode(const NodeTemplate<ref_count>& right) const {
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
-
+ assertTNodeNotExpired();
return NodeManager::currentNM()->mkNode(kind::XOR, *this, right);
}
template <bool ref_count>
inline void
NodeTemplate<ref_count>::printAst(std::ostream& out, int indent) const {
+ assertTNodeNotExpired();
d_nv->printAst(out, indent);
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
switch(kind::MetaKind mk = getMetaKind()) {
case kind::metakind::INVALID:
*/
template <bool ref_count>
inline bool NodeTemplate<ref_count>::hasOperator() const {
+ assertTNodeNotExpired();
return NodeManager::hasOperator(getKind());
}
"There is no current CVC4::NodeManager associated to this thread.\n"
"Perhaps a public-facing function is missing a NodeManagerScope ?" );
- if(!ref_count) {
- Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
- }
+ assertTNodeNotExpired();
return NodeManager::currentNM()->getType(*this, check);
}