bitvector_expr_value.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  *\file bitvector_expr_value.h
00004  *\brief Subclasses of ExprValue for bit-vector expressions
00005  *
00006  * Author: Sergey Berezin, Vijay Ganesh
00007  *
00008  * Created: Wed Jun 23 14:36:59 2004
00009  *
00010  * <hr>
00011  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00012  * Junior University and by New York University. 
00013  *
00014  * License to use, copy, modify, sell and/or distribute this software
00015  * and its documentation for any purpose is hereby granted without
00016  * royalty, subject to the terms and conditions defined in the \ref
00017  * LICENSE file provided with this distribution.  In particular:
00018  *
00019  * - The above copyright notice and this permission notice must appear
00020  * in all copies of the software and related documentation.
00021  *
00022  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00023  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00024  * 
00025  * <hr>
00026  * 
00027  */
00028 /*****************************************************************************/
00029 
00030 #ifndef _cvcl__theory_bitvector__bitvector_expr_value_h_
00031 #define _cvcl__theory_bitvector__bitvector_expr_value_h_
00032 
00033 #include "theory_bitvector.h"
00034 
00035 namespace CVCL {
00036 
00037 ///////////////////////////////////////////////////////////////////////////////
00038 //class BVConstExpr
00039 ///////////////////////////////////////////////////////////////////////////////
00040 //! An expression subclass for bitvector constants.
00041 class BVConstExpr : public ExprValue {
00042 private:
00043   std::vector<bool> d_bvconst; //!< value of bitvector constant
00044   size_t d_MMIndex; //!< The registration index for ExprManager
00045  public:
00046   //! Constructor
00047   BVConstExpr(ExprManager* em, std::string bvconst,
00048               size_t mmIndex, ExprIndex idx = 0);
00049   
00050   //! Constructor
00051   BVConstExpr(ExprManager* em, std::vector<bool> bvconst,
00052               size_t mmIndex, ExprIndex idx = 0);
00053   
00054   ExprValue* copy(ExprManager* em, ExprIndex idx = 0) const {
00055     return new(em->getMM(getMMIndex()))
00056       BVConstExpr(em, d_bvconst, d_MMIndex, idx);
00057   }
00058 
00059   size_t computeHash() const;
00060   size_t getMMIndex() const { return d_MMIndex; }
00061 
00062   const ExprValue* getExprValue() const { return this; }
00063   
00064   //! Only compare the bitvector constant, not the integer attribute
00065   bool operator==(const ExprValue& ev2) const {
00066     if(ev2.getMMIndex() != d_MMIndex) return false;
00067     return (d_bvconst == ((const BVConstExpr&)ev2).d_bvconst);
00068   }
00069   
00070   void* operator new(size_t size, MemoryManager* mm) {
00071     return mm->newData(size);
00072   }
00073 
00074   void operator delete(void*) { }
00075 
00076   unsigned size() const { return d_bvconst.size(); }
00077   bool getValue(int i) const
00078     { DebugAssert(0 <= i && (unsigned)i < size(), "out of bounds");
00079       return d_bvconst[i]; }
00080 
00081 }; //end of BVConstExpr
00082 
00083 } // end of namespace CVCL
00084 #endif

Generated on Thu Apr 13 16:57:29 2006 for CVC Lite by  doxygen 1.4.4