#include "../STPManager/STP.h"
namespace BEEV
{
+ const ASTVec ASTBVConst::astbv_empty_children;
+
/****************************************************************
* ASTBVConst Member Function definitions *
****************************************************************/
// Copy constructor.
ASTBVConst::ASTBVConst(const ASTBVConst &sym) :
- ASTInternal(sym._kind, sym._children)
+ ASTInternal(sym._kind)
{
_bvconst = CONSTANTBV::BitVector_Clone(sym._bvconst);
_value_width = sym._value_width;
// compilers will accept)
virtual void nodeprint(ostream& os, bool c_friendly = false);
+ const static ASTVec astbv_empty_children;
+
public:
+ virtual ASTVec const &
+ GetChildren() const
+ {
+ return astbv_empty_children;
+ }
+
/****************************************************************
* Public Member Functions *
****************************************************************/
#define ASTINTERIOR_H
#include "UsefulDefs.h"
+#include "ASTInternalWithChildren.h"
namespace BEEV
{
class ASTNode;
* Internal representation of an interior ASTNode.Generally, these*
* nodes should have at least one child *
******************************************************************/
- class ASTInterior: public ASTInternal
+ class ASTInterior: public ASTInternalWithChildren
{
friend class STPMgr;
******************************************************************/
// Basic constructors
- ASTInterior(Kind kind) : ASTInternal(kind)
+ ASTInterior(Kind kind) : ASTInternalWithChildren(kind)
{
}
- ASTInterior(Kind kind, ASTVec &children) : ASTInternal(kind, children)
+ ASTInterior(Kind kind, ASTVec &children) : ASTInternalWithChildren(kind, children)
{
}
//Copy constructor. This copies the contents of the child nodes
//array, along with everything else. Assigning the smart pointer,
//ASTNode, does NOT invoke this.
- ASTInterior(const ASTInterior &int_node) : ASTInternal(int_node)
+ ASTInterior(const ASTInterior &int_node) : ASTInternalWithChildren(int_node)
{
}
// Kind. It's a type tag and the operator.
enumeration<Kind,unsigned char> _kind;
- // The vector of children
- ASTVec _children;
-
//Nodenum is a unique positive integer for the node. The nodenum
//of a node should always be greater than its descendents (which
//is easily achieved by incrementing the number each time a new
//node is created).
- //FIXME: Get rid of this
unsigned int _node_num;
/*******************************************************************
* *
* Width of the index of an array. Positive for array, 0 otherwise *
*******************************************************************/
-#ifdef LESSBYTES_PERNODE
- unsigned char _index_width;
-#else
unsigned int _index_width;
-#endif
+
/*******************************************************************
* ASTNode is of type BV <==> ((indexwidth=0)&&(valuewidth>0))*
* *
* Number of bits of bitvector. +ve for array/bitvector,0 otherwise*
*******************************************************************/
-#ifdef LESSBYTES_PERNODE
- unsigned char _value_width;
-#else
unsigned int _value_width;
-#endif
/****************************************************************
* Protected Member Functions *
}
// Get the child nodes of this node
- virtual ASTVec const &GetChildren() const
- {
- return _children;
- }
+ virtual ASTVec const &GetChildren() const = 0;
public:
{
}
- // Constructor (kind and children).
- ASTInternal(Kind kind, const ASTVec &children, int nodenum = 0) :
- _ref_count(0), _kind(kind), _children(children),
- _node_num(nodenum),
- _index_width(0), _value_width(0)
- {
- }
-
// Copy constructor. This copies the contents of the child nodes
// array, along with everything else. Assigning the smart pointer,
// ASTNode, does NOT invoke this; This should only be used for
// FIXME: I don't think children need to be copied.
ASTInternal(const ASTInternal &int_node, int nodenum = 0) :
_ref_count(0), _kind(int_node._kind),
- _children(int_node._children),
+ //_children(int_node._children),
_node_num(int_node._node_num),
- _index_width(int_node._index_width),
+ _index_width(int_node._index_width),
_value_width(int_node._value_width)
{
}
--- /dev/null
+#ifndef ASTINTERNALWithChildren_H
+#define ASTINTERNALWithChildren_H
+
+/*
+ * Leaf objects like Symbols and BVConsts don't need a vector of
+ * children. On a 64-bit machine, a vector object is 24 bytes. So
+ * splitting the two objects apart saves 24 bytes for those objects.
+ */
+
+namespace BEEV
+{
+ class ASTInternalWithChildren : public ASTInternal
+ {
+
+ protected:
+ // The vector of children
+ ASTVec _children;
+
+ public:
+
+ virtual ASTVec const &GetChildren() const
+ {
+ return _children;
+ }
+
+ // Constructor (kind and children).
+ ASTInternalWithChildren(Kind kind, const ASTVec &children, int nodenum = 0) :
+ ASTInternal(kind,nodenum), _children(children)
+ {
+ }
+
+ // Constructor (kind only, empty children, int nodenum)
+ ASTInternalWithChildren(Kind kind, int nodenum = 0) :
+ ASTInternal(kind,nodenum)
+ {
+ }
+ }; //End of Class ASTInternalBase
+}; //end of namespace
+#endif
#include "../STPManager/STP.h"
namespace BEEV
{
+ const ASTVec ASTSymbol::empty_children;
+
+
/****************************************************************
* ASTSymbol Member Function definitions *
****************************************************************/
friend class ASTNodeHasher;
friend class ASTNodeEqual;
+ const static ASTVec empty_children;
+
private:
/****************************************************************
* Private Data *
public:
+ virtual ASTVec const &GetChildren() const
+ {
+ return empty_children;
+ }
+
+
/****************************************************************
* Public Member Functions *
****************************************************************/
ASTSymbol(const char * const name) :
ASTInternal(SYMBOL), _name(name)
{
- //printf("inside ASTSymbol constructor %s\n", _name);
}
// Destructor (does nothing, but is declared virtual here.
// Copy constructor
ASTSymbol(const ASTSymbol &sym) :
- ASTInternal(sym._kind, sym._children), _name(sym._name)
+ ASTInternal(sym._kind), _name(sym._name)
{
//printf("inside ASTSymbol constructor %s\n", _name);
}