cprover
replace_expr.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #include "replace_expr.h"
11 
12 bool replace_expr(const exprt &what, const exprt &by, exprt &dest)
13 {
14  if(dest==what)
15  {
16  dest=by;
17  return false;
18  }
19 
20  bool result=true;
21 
22  Forall_operands(it, dest)
23  result=replace_expr(what, by, *it) && result;
24 
25  return result;
26 }
27 
28 bool replace_expr(const replace_mapt &what, exprt &dest)
29 {
30  {
31  replace_mapt::const_iterator it=what.find(dest);
32 
33  if(it!=what.end())
34  {
35  dest=it->second;
36  return false;
37  }
38  }
39 
40  bool result=true;
41 
42  Forall_operands(it, dest)
43  result=replace_expr(what, *it) && result;
44 
45  return result;
46 }
bool replace_expr(const exprt &what, const exprt &by, exprt &dest)
Base class for all expressions.
Definition: expr.h:46
std::unordered_map< exprt, exprt, irep_hash > replace_mapt
Definition: replace_expr.h:20
#define Forall_operands(it, expr)
Definition: expr.h:23