00001 //===-- Constraints.h -------------------------------------------*- C++ -*-===// 00002 // 00003 // The KLEE Symbolic Virtual Machine 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef KLEE_CONSTRAINTS_H 00011 #define KLEE_CONSTRAINTS_H 00012 00013 #include "klee/Expr.h" 00014 00015 // FIXME: Currently we use ConstraintManager for two things: to pass 00016 // sets of constraints around, and to optimize constraints. We should 00017 // move the first usage into a separate data structure 00018 // (ConstraintSet?) which ConstraintManager could embed if it likes. 00019 namespace klee { 00020 00021 class ExprVisitor; 00022 00023 class ConstraintManager { 00024 public: 00025 typedef std::vector< ref<Expr> > constraints_ty; 00026 typedef constraints_ty::iterator iterator; 00027 typedef constraints_ty::const_iterator const_iterator; 00028 00029 ConstraintManager() {} 00030 00031 // create from constraints with no optimization 00032 explicit 00033 ConstraintManager(const std::vector< ref<Expr> > &_constraints) : 00034 constraints(_constraints) {} 00035 00036 ConstraintManager(const ConstraintManager &cs) : constraints(cs.constraints) {} 00037 00038 typedef std::vector< ref<Expr> >::const_iterator constraint_iterator; 00039 00040 // given a constraint which is known to be valid, attempt to 00041 // simplify the existing constraint set 00042 void simplifyForValidConstraint(ref<Expr> e); 00043 00044 ref<Expr> simplifyExpr(ref<Expr> e) const; 00045 00046 void addConstraint(ref<Expr> e); 00047 00048 bool empty() const { 00049 return constraints.empty(); 00050 } 00051 ref<Expr> back() const { 00052 return constraints.back(); 00053 } 00054 constraint_iterator begin() const { 00055 return constraints.begin(); 00056 } 00057 constraint_iterator end() const { 00058 return constraints.end(); 00059 } 00060 size_t size() const { 00061 return constraints.size(); 00062 } 00063 00064 bool operator==(const ConstraintManager &other) const { 00065 return constraints == other.constraints; 00066 } 00067 00068 private: 00069 std::vector< ref<Expr> > constraints; 00070 00071 // returns true iff the constraints were modified 00072 bool rewriteConstraints(ExprVisitor &visitor); 00073 00074 void addConstraintInternal(ref<Expr> e); 00075 }; 00076 00077 } 00078 00079 #endif /* KLEE_CONSTRAINTS_H */
1.5.8