@@ -89,28 +89,8 @@ class renamedt
89
89
(void )::simplify (value, ns);
90
90
}
91
91
92
- typedef std::function<optionalt<renamedt<exprt, level>>(const exprt &)>
93
- expr_mutator_functiont;
94
-
95
- // / This permits replacing subexpressions of the renamed value, so long as
96
- // / each replacement is consistent with our current renaming level (for
97
- // / example, replacing subexpressions of L2 expressions with ones which are
98
- // / themselves L2 renamed).
99
- // / The passed function will be called with each expression node in preorder
100
- // / (i.e. parent expressions before children), and should return an empty
101
- // / optional to make no change or a renamed expression to make a change.
102
- void selectively_mutate (expr_mutator_functiont get_mutated_expr)
103
- {
104
- for (
105
- auto it = value.depth_begin (), itend = value.depth_end ();
106
- it != itend;
107
- ++it)
108
- {
109
- auto replacement = get_mutated_expr (*it);
110
- if (replacement)
111
- it.mutate () = replacement->get ();
112
- }
113
- }
92
+ using mutator_functiont =
93
+ std::function<optionalt<renamedt<underlyingt, level>>(const underlyingt &)>;
114
94
115
95
private:
116
96
underlyingt value;
@@ -119,8 +99,16 @@ class renamedt
119
99
friend struct symex_level1t ;
120
100
friend struct symex_level2t ;
121
101
friend class goto_symex_statet ;
102
+
122
103
template <levelt make_renamed_level>
123
- friend renamedt<exprt, make_renamed_level> make_renamed (constant_exprt constant);
104
+ friend renamedt<exprt, make_renamed_level>
105
+ make_renamed (constant_exprt constant);
106
+
107
+ template <levelt selectively_mutate_level>
108
+ friend void selectively_mutate (
109
+ renamedt<exprt, selectively_mutate_level> &renamed,
110
+ typename renamedt<exprt, selectively_mutate_level>::mutator_functiont
111
+ get_mutated_expr);
124
112
125
113
// / Only the friend classes can create renamedt objects
126
114
explicit renamedt (underlyingt value) : value(std::move(value))
@@ -133,6 +121,28 @@ renamedt<exprt, level> make_renamed(constant_exprt constant) {
133
121
return renamedt<exprt, level>(std::move (constant));
134
122
}
135
123
124
+ // / This permits replacing subexpressions of the renamed value, so long as
125
+ // / each replacement is consistent with our current renaming level (for
126
+ // / example, replacing subexpressions of L2 expressions with ones which are
127
+ // / themselves L2 renamed).
128
+ // / The passed function will be called with each expression node in preorder
129
+ // / (i.e. parent expressions before children), and should return an empty
130
+ // / optional to make no change or a renamed expression to make a change.
131
+ template <levelt level>
132
+ void selectively_mutate (renamedt<exprt, level> &renamed,
133
+ typename renamedt<exprt, level>::mutator_functiont get_mutated_expr)
134
+ {
135
+ for (
136
+ auto it = renamed.value .depth_begin (), itend = renamed.value .depth_end ();
137
+ it != itend;
138
+ ++it)
139
+ {
140
+ auto replacement = get_mutated_expr (*it);
141
+ if (replacement)
142
+ it.mutate () = replacement->get ();
143
+ }
144
+ }
145
+
136
146
// / Functor to set the level 0 renaming of SSA expressions.
137
147
// / Level 0 corresponds to threads.
138
148
// / The renaming is built for one particular interleaving.
0 commit comments