/**
* Attributes are roughly speaking [almost] global hash tables from Nodes
* (TNodes) to data. Attributes can be thought of as additional fields used to
- * extend NodeValues. Attributes are mutable and come in both sat
- * context-dependent and non-context dependent varieties. Attributes live only
- * as long as the node itself does. If a Node is garbage-collected, Attributes
- * associated with it will automatically be garbage collected. (Being in the
- * domain of an Attribute does not increase a Node's reference count.) To
- * achieve this special relationship with Nodes, Attributes are mapped by hash
- * tables (AttrHash<> and CDAttrHash<>) that live in the AttributeManager. The
- * AttributeManager is owned by the NodeManager.
+ * extend NodeValues. Attributes are mutable. Attributes live only as long as
+ * the node itself does. If a Node is garbage-collected, Attributes associated
+ * with it will automatically be garbage collected. (Being in the domain of an
+ * Attribute does not increase a Node's reference count.) To achieve this
+ * special relationship with Nodes, Attributes are mapped by hash tables
+ * (AttrHash<>) that live in the AttributeManager. The AttributeManager is
+ * owned by the NodeManager.
*
* Example:
*
* ```
*
* To separate Attributes of the same type in the same table, each of the
- * structures `struct InstLevelAttributeId {};` is given a different unique value
- * at load time. An example is the empty struct InstLevelAttributeId. These
- * should be unique for each Attribute. Then via some template messiness when
- * InstLevelAttribute() is passed as the argument to getAttribute(...) the load
- * time id is instantiated.
+ * structures `struct InstLevelAttributeId {};` is given a different unique
+ * value at load time. An example is the empty struct InstLevelAttributeId.
+ * These should be unique for each Attribute. Then via some template messiness
+ * when InstLevelAttribute() is passed as the argument to getAttribute(...) the
+ * load time id is instantiated.
*/
// ATTRIBUTE MANAGER ===========================================================
* getTable<> is a helper template that gets the right table from an
* AttributeManager given its type.
*/
- template <class T, bool context_dep, class Enable>
+ template <class T, class Enable>
friend struct getTable;
bool d_inGarbageCollection;
* `std::enable_if` in the template parameter and the condition is false), the
* instantiation is ignored due to the SFINAE rule.
*/
-template <class T, bool context_dep, class Enable = void>
+template <class T, class Enable = void>
struct getTable;
/** Access the "d_bools" member of AttributeManager. */
template <>
-struct getTable<bool, false> {
+struct getTable<bool>
+{
static const AttrTableId id = AttrTableBool;
typedef AttrHash<bool> table_type;
static inline table_type& get(AttributeManager& am) {
/** Access the "d_ints" member of AttributeManager. */
template <class T>
struct getTable<T,
- false,
// Use this specialization only for unsigned integers
typename std::enable_if<std::is_unsigned<T>::value>::type>
{
/** Access the "d_tnodes" member of AttributeManager. */
template <>
-struct getTable<TNode, false> {
+struct getTable<TNode>
+{
static const AttrTableId id = AttrTableTNode;
typedef AttrHash<TNode> table_type;
static inline table_type& get(AttributeManager& am) {
/** Access the "d_nodes" member of AttributeManager. */
template <>
-struct getTable<Node, false> {
+struct getTable<Node>
+{
static const AttrTableId id = AttrTableNode;
typedef AttrHash<Node> table_type;
static inline table_type& get(AttributeManager& am) {
/** Access the "d_types" member of AttributeManager. */
template <>
-struct getTable<TypeNode, false> {
+struct getTable<TypeNode>
+{
static const AttrTableId id = AttrTableTypeNode;
typedef AttrHash<TypeNode> table_type;
static inline table_type& get(AttributeManager& am) {
/** Access the "d_strings" member of AttributeManager. */
template <>
-struct getTable<std::string, false> {
+struct getTable<std::string>
+{
static const AttrTableId id = AttrTableString;
typedef AttrHash<std::string> table_type;
static inline table_type& get(AttributeManager& am) {
AttributeManager::getAttribute(NodeValue* nv, const AttrKind&) const {
typedef typename AttrKind::value_type value_type;
typedef KindValueToTableValueMapping<value_type> mapping;
- typedef typename getTable<value_type, AttrKind::context_dependent>::
- table_type table_type;
+ typedef typename getTable<value_type>::table_type table_type;
- const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*this);
+ const table_type& ah = getTable<value_type>::get(*this);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
typename AttrKind::value_type& ret) {
typedef typename AttrKind::value_type value_type;
typedef KindValueToTableValueMapping<value_type> mapping;
- typedef typename getTable<value_type,
- AttrKind::context_dependent>::table_type
- table_type;
+ typedef typename getTable<value_type>::table_type table_type;
- const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ const table_type& ah = getTable<value_type>::get(*am);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
NodeValue* nv) {
typedef typename AttrKind::value_type value_type;
//typedef KindValueToTableValueMapping<value_type> mapping;
- typedef typename getTable<value_type, AttrKind::context_dependent>::
- table_type table_type;
+ typedef typename getTable<value_type>::table_type table_type;
- const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ const table_type& ah = getTable<value_type>::get(*am);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
typename AttrKind::value_type& ret) {
typedef typename AttrKind::value_type value_type;
typedef KindValueToTableValueMapping<value_type> mapping;
- typedef typename getTable<value_type, AttrKind::context_dependent>::
- table_type table_type;
+ typedef typename getTable<value_type>::table_type table_type;
- const table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*am);
+ const table_type& ah = getTable<value_type>::get(*am);
typename table_type::const_iterator i =
ah.find(std::make_pair(AttrKind::getId(), nv));
const typename AttrKind::value_type& value) {
typedef typename AttrKind::value_type value_type;
typedef KindValueToTableValueMapping<value_type> mapping;
- typedef typename getTable<value_type, AttrKind::context_dependent>::
- table_type table_type;
+ typedef typename getTable<value_type>::table_type table_type;
- table_type& ah =
- getTable<value_type, AttrKind::context_dependent>::get(*this);
+ table_type& ah = getTable<value_type>::get(*this);
ah[std::make_pair(AttrKind::getId(), nv)] = mapping::convert(value);
}
inline void AttributeManager::deleteFromTable(AttrHash<T>& table,
NodeValue* nv) {
// This cannot use nv as anything other than a pointer!
- const uint64_t last = attr::LastAttributeId<T, false>::getId();
+ const uint64_t last = attr::LastAttributeId<T>::getId();
for (uint64_t id = 0; id < last; ++id)
{
table.erase(std::make_pair(id, nv));
template <class AttrKind>
AttributeUniqueId AttributeManager::getAttributeId(const AttrKind& attr){
typedef typename AttrKind::value_type value_type;
- AttrTableId tableId = getTable<value_type,
- AttrKind::context_dependent>::id;
+ AttrTableId tableId = getTable<value_type>::id;
return AttributeUniqueId(tableId, attr.getId());
}
* This is the last-attribute-assigner. IDs are not globally
* unique; rather, they are unique for each table_value_type.
*/
-template <class T, bool context_dep>
-struct LastAttributeId {
+template <class T>
+struct LastAttributeId
+{
public:
static uint64_t getNextId() {
uint64_t* id = raw_id();
* @param T the tag for the attribute kind.
*
* @param value_t the underlying value_type for the attribute kind
- *
- * @param context_dep whether this attribute kind is
- * context-dependent
*/
-template <class T, class value_t, bool context_dep = false>
+template <class T, class value_t>
class Attribute
{
/**
*/
static const bool has_default_value = false;
- /**
- * Expose this setting to the users of this Attribute kind.
- */
- static const bool context_dependent = context_dep;
-
/**
* Register this attribute kind and check that the ID is a valid ID
* for bool-valued attributes. Fail an assert if not. Otherwise
static inline uint64_t registerAttribute() {
typedef typename attr::KindValueToTableValueMapping<value_t>::
table_value_type table_value_type;
- return attr::LastAttributeId<table_value_type, context_dep>::getNextId();
+ return attr::LastAttributeId<table_value_type>::getNextId();
}
};/* class Attribute<> */
/**
* An "attribute type" structure for boolean flags (special).
*/
-template <class T, bool context_dep>
-class Attribute<T, bool, context_dep>
+template <class T>
+class Attribute<T, bool>
{
/** IDs for bool-valued attributes are actually bit assignments. */
static const uint64_t s_id;
*/
static const bool default_value = false;
- /**
- * Expose this setting to the users of this Attribute kind.
- */
- static const bool context_dependent = context_dep;
-
/**
* Register this attribute kind and check that the ID is a valid ID
* for bool-valued attributes. Fail an assert if not. Otherwise
* return the id.
*/
static inline uint64_t registerAttribute() {
- const uint64_t id = attr::LastAttributeId<bool, context_dep>::getNextId();
+ const uint64_t id = attr::LastAttributeId<bool>::getNextId();
AlwaysAssert(id <= 63) << "Too many boolean node attributes registered "
"during initialization !";
return id;
// ATTRIBUTE IDENTIFIER ASSIGNMENT =============================================
/** Assign unique IDs to attributes at load time. */
-template <class T, class value_t, bool context_dep>
-const uint64_t Attribute<T, value_t, context_dep>::s_id =
- Attribute<T, value_t, context_dep>::registerAttribute();
-
+template <class T, class value_t>
+const uint64_t Attribute<T, value_t>::s_id =
+ Attribute<T, value_t>::registerAttribute();
/** Assign unique IDs to attributes at load time. */
-template <class T, bool context_dep>
-const uint64_t Attribute<T, bool, context_dep>::s_id =
- Attribute<T, bool, context_dep>::registerAttribute();
+template <class T>
+const uint64_t Attribute<T, bool>::s_id =
+ Attribute<T, bool>::registerAttribute();
} // namespace expr
} // namespace cvc5