ASTNode::ASTNodeHasher,
ASTNode::ASTNodeEqual> ASTNodeCountMap;
-// typedef hash_map<int32_t,
-// ASTVec,
-// hash(int32_t)> IntToASTVecMap;
-
// Function to dump contents of ASTNodeMap
ostream &operator<<(ostream &os, const ASTNodeMap &nmap);
* INLINE METHODS from various classed, declared here because of
* dependencies on classes that are declared later.
*****************************************************************/
- // ASTNode accessor function.
- inline Kind ASTNode::GetKind() const
- {
- //cout << "GetKind: " << _int_node_ptr;
- return _int_node_ptr->GetKind();
- }
-
- // FIXME: should be const ASTVec const?
- // Declared here because of same ordering problem as GetKind.
- inline const ASTVec &ASTNode::GetChildren() const
- {
- return _int_node_ptr->GetChildren();
- }
-
- // Access node number
- inline int ASTNode::GetNodeNum() const
- {
- return _int_node_ptr->_node_num;
- }
-
- inline unsigned int ASTNode::GetIndexWidth() const
- {
- return _int_node_ptr->_index_width;
- }
-
- inline void ASTNode::SetIndexWidth(unsigned int iw) const
- {
- _int_node_ptr->_index_width = iw;
- }
-
- inline unsigned int ASTNode::GetValueWidth() const
- {
- return _int_node_ptr->_value_width;
- }
-
- inline void ASTNode::SetValueWidth(unsigned int vw) const
- {
- _int_node_ptr->_value_width = vw;
- }
-
- //return the type of the ASTNode: 0 iff BOOLEAN; 1 iff BITVECTOR; 2
- //iff ARRAY; 3 iff UNKNOWN;
- inline types ASTNode::GetType() const
- {
- if ((GetIndexWidth() == 0) && (GetValueWidth() == 0)) //BOOLEAN
- return BOOLEAN_TYPE;
- if ((GetIndexWidth() == 0) && (GetValueWidth() > 0)) //BITVECTOR
- return BITVECTOR_TYPE;
- if ((GetIndexWidth() > 0) && (GetValueWidth() > 0)) //ARRAY
- return ARRAY_TYPE;
- return UNKNOWN_TYPE;
- }
-
- // Constructor; creates a new pointer, increments refcount of
- // pointed-to object.
- inline ASTNode::ASTNode(ASTInternal *in) :
- _int_node_ptr(in)
- {
- if (in)
- in->IncRef();
- }
-
- // Assignment. Increment refcount of new value, decrement refcount of
- // old value and destroy if this was the last pointer. FIXME:
- // accelerate this by creating an intnode with a ref counter instead
- // of pointing to NULL. Need a special check in CleanUp to make sure
- // the null node never gets freed.
-
- inline ASTNode& ASTNode::operator=(const ASTNode& n)
- {
- if (n._int_node_ptr)
- {
- n._int_node_ptr->IncRef();
- }
- if (_int_node_ptr)
- {
- _int_node_ptr->DecRef();
- }
- _int_node_ptr = n._int_node_ptr;
- return *this;
- }
-
- inline void ASTInternal::DecRef()
- {
- if (--_ref_count == 0)
- {
- // Delete node from unique table and kill it.
- CleanUp();
- }
- }
-
- // Destructor
- inline ASTNode::~ASTNode()
- {
- if (_int_node_ptr)
- {
- _int_node_ptr->DecRef();
- }
- }
-
- inline BeevMgr* ASTNode::GetBeevMgr() const
- {
- return GlobalBeevMgr;
- }
//Return the unsigned constant value of the input 'n'
inline unsigned int GetUnsignedConst(const ASTNode n)
{
return _bvconst;
} //End of GetBVConst()
+
+ /****************************************************************
+ * Class ASTBVConstHasher and ASTBVConstEqual Functions *
+ ****************************************************************/
+
+ size_t ASTBVConst::ASTBVConstHasher::operator()(const ASTBVConst * bvc) const
+ {
+ return CONSTANTBV::BitVector_Hash(bvc->_bvconst);
+ } //End of ASTBVConstHasher operator
+
+
+ bool ASTBVConst::ASTBVConstEqual::operator()(const ASTBVConst * bvc1,
+ const ASTBVConst * bvc2) const
+ {
+ if (bvc1->_value_width != bvc2->_value_width)
+ {
+ return false;
+ }
+ return (0 ==
+ CONSTANTBV::BitVector_Compare(bvc1->_bvconst,
+ bvc2->_bvconst));
+ } //End of ASTBVConstEqual operator
};//End of namespace
class ASTBVConstHasher
{
public:
- size_t operator()(const ASTBVConst * bvc) const
- {
- return CONSTANTBV::BitVector_Hash(bvc->_bvconst);
- }
- ;
+ size_t operator()(const ASTBVConst * bvc) const;
}; //End of class ASTBVConstHahser
/****************************************************************
{
public:
bool operator()(const ASTBVConst * bvc1,
- const ASTBVConst * bvc2) const
- {
- if (bvc1->_value_width != bvc2->_value_width)
- {
- return false;
- }
- return (0 ==
- CONSTANTBV::BitVector_Compare(bvc1->_bvconst,
- bvc2->_bvconst));
- }
+ const ASTBVConst * bvc2) const;
}; //End of class ASTBVConstEqual
-
/****************************************************************
* Private Functions (virtual defs and friends) *
****************************************************************/
void IncRef()
{
++_ref_count;
- }
+ } //End of IncRef()
// Decrement Reference Count
- void DecRef();
+ void DecRef()
+ {
+ if (--_ref_count == 0)
+ {
+ // Delete node from unique table and kill it.
+ CleanUp();
+ }
+ }//End of DecRef()
int GetNodeNum() const
{
return _node_num;
- }
+ } //End of GetNodeNum()
void SetNodeNum(int nn)
{
_node_num = nn;
- }
- ;
- }; //End of Class ASTInternal
+ } //End of SetNodeNum()
+ }; //End of Class ASTInternal
}; //end of namespace
#endif
********************************************************************/
namespace BEEV
{
+ // Constructor;
+ //
+ // creates a new pointer, increments refcount of pointed-to object.
+ inline ASTNode::ASTNode(ASTInternal *in) :
+ _int_node_ptr(in)
+ {
+ if (in)
+ in->IncRef();
+ } //End of Constructor
+
// Copy constructor. Maintain _ref_count
ASTNode::ASTNode(const ASTNode &n) :
_int_node_ptr(n._int_node_ptr)
}
} //End of Copy Constructor for ASTNode
+ // ASTNode accessor function.
+ inline Kind ASTNode::GetKind() const
+ {
+ //cout << "GetKind: " << _int_node_ptr;
+ return _int_node_ptr->GetKind();
+ } //End of GetKind()
+
+ // Declared here because of same ordering problem as GetKind.
+ inline const ASTVec &ASTNode::GetChildren() const
+ {
+ return _int_node_ptr->GetChildren();
+ } //End of GetChildren()
+
+ // Access node number
+ inline int ASTNode::GetNodeNum() const
+ {
+ return _int_node_ptr->_node_num;
+ } //End of GetNodeNum()
+
+ inline unsigned int ASTNode::GetIndexWidth() const
+ {
+ return _int_node_ptr->_index_width;
+ } //End of GetIndexWidth()
+
+ inline void ASTNode::SetIndexWidth(unsigned int iw) const
+ {
+ _int_node_ptr->_index_width = iw;
+ } //End of SetIndexWidth()
+
+ inline unsigned int ASTNode::GetValueWidth() const
+ {
+ return _int_node_ptr->_value_width;
+ } //End of GetValueWidth()
+
+ inline void ASTNode::SetValueWidth(unsigned int vw) const
+ {
+ _int_node_ptr->_value_width = vw;
+ } //End of SetValueWidth()
+
+ //return the type of the ASTNode:
+ //
+ // 0 iff BOOLEAN; 1 iff BITVECTOR; 2 iff ARRAY; 3 iff UNKNOWN;
+ inline types ASTNode::GetType() const
+ {
+ if ((GetIndexWidth() == 0) && (GetValueWidth() == 0)) //BOOLEAN
+ return BOOLEAN_TYPE;
+ if ((GetIndexWidth() == 0) && (GetValueWidth() > 0)) //BITVECTOR
+ return BITVECTOR_TYPE;
+ if ((GetIndexWidth() > 0) && (GetValueWidth() > 0)) //ARRAY
+ return ARRAY_TYPE;
+ return UNKNOWN_TYPE;
+ } //End of GetType()
+
+ // Assignment
+ inline ASTNode& ASTNode::operator=(const ASTNode& n)
+ {
+ if (n._int_node_ptr)
+ {
+ n._int_node_ptr->IncRef();
+ }
+ if (_int_node_ptr)
+ {
+ _int_node_ptr->DecRef();
+ }
+ _int_node_ptr = n._int_node_ptr;
+ return *this;
+ } //End of operator=
+
+ // Destructor
+ inline ASTNode::~ASTNode()
+ {
+ if (_int_node_ptr)
+ {
+ _int_node_ptr->DecRef();
+ }
+ } //End of Destructor()
+
+ inline BeevMgr* ASTNode::GetBeevMgr() const
+ {
+ return GlobalBeevMgr;
+ } //End of GetBeevMgr()
+
// Checks if the node has alreadybeen printed or not
bool ASTNode::IsAlreadyPrinted() const
{
free((char*) this->_name);
delete this;
}//End of cleanup()
+
+
+ /****************************************************************
+ * ASTSymbolHasher and ASTSymbolEqual functions *
+ * *
+ ****************************************************************/
+ size_t
+ ASTSymbol::ASTSymbolHasher::operator()(const ASTSymbol *sym_ptr) const
+ {
+#ifdef TR1_UNORDERED_MAP
+ tr1::hash<string> h;
+#else
+ hash<char*> h;
+#endif
+ return h(sym_ptr->_name);
+ } //End of ASTSymbolHasher operator
+
+ bool ASTSymbol::ASTSymbolEqual::operator()(const ASTSymbol *sym_ptr1,
+ const ASTSymbol *sym_ptr2) const
+ {
+ return (*sym_ptr1 == *sym_ptr2);
+ } //End of ASTSymbolEqual operator
};//end of namespace
class ASTSymbolHasher
{
public:
- size_t operator()(const ASTSymbol *sym_ptr) const
- {
-#ifdef TR1_UNORDERED_MAP
- tr1::hash<string> h;
-#else
- hash<char*> h;
-#endif
- return h(sym_ptr->_name);
- }
- ;
+ size_t operator()(const ASTSymbol *sym_ptr) const;
}; // End of class ASTSymbolHasher
/****************************************************************
{
public:
bool operator()(const ASTSymbol *sym_ptr1,
- const ASTSymbol *sym_ptr2) const
- {
- return (*sym_ptr1 == *sym_ptr2);
- }
+ const ASTSymbol *sym_ptr2) const;
}; //End of class ASTSymbolEqual
friend bool operator==(const ASTSymbol &sym1,