return i + p;
}
+std::ostream& operator<<(std::ostream& out, const NodeValue& nv)
+{
+ nv.toStream(out,
+ options::ioutils::getNodeDepth(out),
+ options::ioutils::getDagThresh(out),
+ options::ioutils::getOutputLang(out));
+ return out;
+}
+
+void NodeValue::markRefCountMaxedOut()
+{
+ Assert(NodeManager::currentNM() != nullptr)
+ << "No current NodeManager on incrementing of NodeValue: "
+ "maybe a public cvc5 interface function is missing a "
+ "NodeManagerScope ?";
+ NodeManager::currentNM()->markRefCountMaxedOut(this);
+}
+
+void NodeValue::markForDeletion()
+{
+ Assert(NodeManager::currentNM() != nullptr)
+ << "No current NodeManager on destruction of NodeValue: "
+ "maybe a public cvc5 interface function is missing a "
+ "NodeManagerScope ?";
+ NodeManager::currentNM()->markForDeletion(this);
+}
+
+bool NodeValue::isBeingDeleted() const
+{
+ return NodeManager::currentNM() != NULL
+ && NodeManager::currentNM()->isCurrentlyDeleting(this);
+}
+
} // namespace expr
} // namespace cvc5
return iterator<NodeTemplate<true> >(d_i);
}
- inline T operator*() const;
+ T operator*() const { return T(*d_i); }
bool operator==(const iterator& i) const { return d_i == i.d_i; }
/** Private constructor for the null value. */
NodeValue(int);
- void inc();
- void dec();
+ void inc()
+ {
+ Assert(!isBeingDeleted())
+ << "NodeValue is currently being deleted "
+ "and increment is being called on it. Don't Do That!";
+ // FIXME multithreading
+ if (__builtin_expect((d_rc < MAX_RC - 1), true))
+ {
+ ++d_rc;
+ }
+ else if (__builtin_expect((d_rc == MAX_RC - 1), false))
+ {
+ ++d_rc;
+ markRefCountMaxedOut();
+ }
+ }
+
+ void dec()
+ {
+ // FIXME multithreading
+ if (__builtin_expect((d_rc < MAX_RC), true))
+ {
+ --d_rc;
+ if (__builtin_expect((d_rc == 0), false))
+ {
+ markForDeletion();
+ }
+ }
+ }
+
+ void markRefCountMaxedOut();
+ void markForDeletion();
/** Decrement ref counts of children */
inline void decrRefCounts();
}
};
-
-inline std::ostream& operator<<(std::ostream& out, const NodeValue& nv);
-
-} // namespace expr
-} // namespace cvc5
-
-#include "expr/node_manager.h"
-
-namespace cvc5 {
-namespace expr {
+std::ostream& operator<<(std::ostream& out, const NodeValue& nv);
inline NodeValue::NodeValue(int) :
d_id(0),
}
}
-inline void NodeValue::inc() {
- Assert(!isBeingDeleted())
- << "NodeValue is currently being deleted "
- "and increment is being called on it. Don't Do That!";
- // FIXME multithreading
- if (__builtin_expect((d_rc < MAX_RC - 1), true)) {
- ++d_rc;
- } else if (__builtin_expect((d_rc == MAX_RC - 1), false)) {
- ++d_rc;
- Assert(NodeManager::currentNM() != NULL)
- << "No current NodeManager on incrementing of NodeValue: "
- "maybe a public cvc5 interface function is missing a "
- "NodeManagerScope ?";
- NodeManager::currentNM()->markRefCountMaxedOut(this);
- }
-}
-
-inline void NodeValue::dec() {
- // FIXME multithreading
- if(__builtin_expect( ( d_rc < MAX_RC ), true )) {
- --d_rc;
- if(__builtin_expect( ( d_rc == 0 ), false )) {
- Assert(NodeManager::currentNM() != NULL)
- << "No current NodeManager on destruction of NodeValue: "
- "maybe a public cvc5 interface function is missing a "
- "NodeManagerScope ?";
- NodeManager::currentNM()->markForDeletion(this);
- }
- }
-}
-
inline NodeValue::nv_iterator NodeValue::nv_begin() {
return d_children;
}
return iterator<T>(d_children + d_nchildren);
}
-inline bool NodeValue::isBeingDeleted() const {
- return NodeManager::currentNM() != NULL &&
- NodeManager::currentNM()->isCurrentlyDeleting(this);
-}
-
inline NodeValue* NodeValue::getOperator() const {
Assert(getMetaKind() == kind::metakind::PARAMETERIZED);
return d_children[0];
} // namespace expr
} // namespace cvc5
-#include "expr/node.h"
-
-namespace cvc5 {
-namespace expr {
-
-template <typename T>
-inline T NodeValue::iterator<T>::operator*() const {
- return T(*d_i);
-}
-
-inline std::ostream& operator<<(std::ostream& out, const NodeValue& nv) {
- nv.toStream(out,
- options::ioutils::getNodeDepth(out),
- options::ioutils::getDagThresh(out),
- options::ioutils::getOutputLang(out));
- return out;
-}
-
-} // namespace expr
-
-} // namespace cvc5
-
#endif /* CVC5__EXPR__NODE_VALUE_H */