File tree Expand file tree Collapse file tree 1 file changed +26
-21
lines changed Expand file tree Collapse file tree 1 file changed +26
-21
lines changed Original file line number Diff line number Diff line change 6
6
7
7
\*******************************************************************/
8
8
9
-
10
9
#include " replace_expr.h"
10
+ #include " expr_iterator.h"
11
11
12
12
bool replace_expr (const exprt &what, const exprt &by, exprt &dest)
13
13
{
14
- if (dest==what)
14
+ bool no_change = true ;
15
+
16
+ for (auto it = dest.depth_begin (), itend = dest.depth_end ();
17
+ it != itend;) // no ++it
15
18
{
16
- dest=by;
17
- return false ;
19
+ if (*it == what)
20
+ {
21
+ it.mutate () = by;
22
+ no_change = false ;
23
+ it.next_sibling_or_parent ();
24
+ }
25
+ else
26
+ ++it;
18
27
}
19
28
20
- bool result=true ;
21
-
22
- Forall_operands (it, dest)
23
- result=replace_expr (what, by, *it) && result;
24
-
25
- return result;
29
+ return no_change;
26
30
}
27
31
28
32
bool replace_expr (const replace_mapt &what, exprt &dest)
29
33
{
30
- {
31
- replace_mapt::const_iterator it=what.find (dest);
34
+ bool no_change = true ;
32
35
33
- if (it!=what.end ())
36
+ for (auto it = dest.depth_begin (), itend = dest.depth_end ();
37
+ it != itend;) // No ++it
38
+ {
39
+ replace_mapt::const_iterator findit = what.find (*it);
40
+ if (findit != what.end ())
34
41
{
35
- dest=it->second ;
36
- return false ;
42
+ it.mutate () = findit->second ;
43
+ no_change = false ;
44
+ it.next_sibling_or_parent ();
37
45
}
46
+ else
47
+ ++it;
38
48
}
39
49
40
- bool result=true ;
41
-
42
- Forall_operands (it, dest)
43
- result=replace_expr (what, *it) && result;
44
-
45
- return result;
50
+ return no_change;
46
51
}
You can’t perform that action at this time.
0 commit comments