@@ -33,10 +33,14 @@ class remove_instanceoft
33
33
}
34
34
35
35
// Lower instanceof for a single function
36
- bool lower_instanceof (goto_programt &);
36
+ bool lower_instanceof (
37
+ const irep_idt &function_identifier,
38
+ goto_programt &);
37
39
38
40
// Lower instanceof for a single instruction
39
- bool lower_instanceof (goto_programt &, goto_programt::targett);
41
+ bool lower_instanceof (
42
+ const irep_idt &function_identifier,
43
+ goto_programt &, goto_programt::targett);
40
44
41
45
protected:
42
46
symbol_table_baset &symbol_table;
@@ -45,6 +49,7 @@ class remove_instanceoft
45
49
message_handlert &message_handler;
46
50
47
51
bool lower_instanceof (
52
+ const irep_idt &function_identifier,
48
53
exprt &, goto_programt &, goto_programt::targett);
49
54
};
50
55
@@ -56,6 +61,7 @@ class remove_instanceoft
56
61
// / \param this_inst: instruction the expression is found at
57
62
// / \return true if any instanceof instructionw was replaced
58
63
bool remove_instanceoft::lower_instanceof (
64
+ const irep_idt &function_identifier,
59
65
exprt &expr,
60
66
goto_programt &goto_program,
61
67
goto_programt::targett this_inst)
@@ -64,7 +70,7 @@ bool remove_instanceoft::lower_instanceof(
64
70
{
65
71
bool changed = false ;
66
72
Forall_operands (it, expr)
67
- changed |= lower_instanceof (*it, goto_program, this_inst);
73
+ changed |= lower_instanceof (function_identifier, *it, goto_program, this_inst);
68
74
return changed;
69
75
}
70
76
@@ -107,15 +113,15 @@ bool remove_instanceoft::lower_instanceof(
107
113
108
114
symbolt &clsid_tmp_sym = get_fresh_aux_symbol (
109
115
object_clsid.type (),
110
- id2string (this_inst-> function ),
116
+ id2string (function_identifier ),
111
117
" class_identifier_tmp" ,
112
118
source_locationt (),
113
119
ID_java,
114
120
symbol_table);
115
121
116
122
symbolt &instanceof_result_sym = get_fresh_aux_symbol (
117
123
bool_typet (),
118
- id2string (this_inst-> function ),
124
+ id2string (function_identifier ),
119
125
" instanceof_result_tmp" ,
120
126
source_locationt (),
121
127
ID_java,
@@ -193,6 +199,7 @@ static bool contains_instanceof(const exprt &e)
193
199
// / \param target: instruction to check for instanceof expressions
194
200
// / \return true if an instanceof has been replaced
195
201
bool remove_instanceoft::lower_instanceof (
202
+ const irep_idt &function_identifier,
196
203
goto_programt &goto_program,
197
204
goto_programt::targett target)
198
205
{
@@ -208,24 +215,26 @@ bool remove_instanceoft::lower_instanceof(
208
215
++target;
209
216
}
210
217
211
- return lower_instanceof (target->code , goto_program, target) |
212
- lower_instanceof (target->guard , goto_program, target);
218
+ return lower_instanceof (function_identifier, target->code , goto_program, target) |
219
+ lower_instanceof (function_identifier, target->guard , goto_program, target);
213
220
}
214
221
215
222
// / Replace every instanceof in the passed function body with an explicit
216
223
// / class-identifier test.
217
224
// / Extra auxiliary variables may be introduced into symbol_table.
218
225
// / \param goto_program: The function body to work on.
219
226
// / \return true if one or more instanceof expressions have been replaced
220
- bool remove_instanceoft::lower_instanceof (goto_programt &goto_program)
227
+ bool remove_instanceoft::lower_instanceof (
228
+ const irep_idt &function_identifier,
229
+ goto_programt &goto_program)
221
230
{
222
231
bool changed=false ;
223
232
for (goto_programt::instructionst::iterator target=
224
233
goto_program.instructions .begin ();
225
234
target!=goto_program.instructions .end ();
226
235
++target)
227
236
{
228
- changed=lower_instanceof (goto_program, target) || changed;
237
+ changed=lower_instanceof (function_identifier, goto_program, target) || changed;
229
238
}
230
239
if (!changed)
231
240
return false ;
@@ -242,13 +251,14 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program)
242
251
// / \param symbol_table: The symbol table to add symbols to.
243
252
// / \param message_handler: logging output
244
253
void remove_instanceof (
254
+ const irep_idt &function_identifier,
245
255
goto_programt::targett target,
246
256
goto_programt &goto_program,
247
257
symbol_table_baset &symbol_table,
248
258
message_handlert &message_handler)
249
259
{
250
260
remove_instanceoft rem (symbol_table, message_handler);
251
- rem.lower_instanceof (goto_program, target);
261
+ rem.lower_instanceof (function_identifier, goto_program, target);
252
262
}
253
263
254
264
// / Replace every instanceof in the passed function with an explicit
@@ -258,12 +268,13 @@ void remove_instanceof(
258
268
// / \param symbol_table: The symbol table to add symbols to.
259
269
// / \param message_handler: logging output
260
270
void remove_instanceof (
271
+ const irep_idt &function_identifier,
261
272
goto_functionst::goto_functiont &function,
262
273
symbol_table_baset &symbol_table,
263
274
message_handlert &message_handler)
264
275
{
265
276
remove_instanceoft rem (symbol_table, message_handler);
266
- rem.lower_instanceof (function.body );
277
+ rem.lower_instanceof (function_identifier, function.body );
267
278
}
268
279
269
280
// / Replace every instanceof in every function with an explicit
@@ -280,7 +291,7 @@ void remove_instanceof(
280
291
remove_instanceoft rem (symbol_table, message_handler);
281
292
bool changed=false ;
282
293
for (auto &f : goto_functions.function_map )
283
- changed=rem.lower_instanceof (f.second .body ) || changed;
294
+ changed=rem.lower_instanceof (f.first , f. second .body ) || changed;
284
295
if (changed)
285
296
goto_functions.compute_location_numbers ();
286
297
}
0 commit comments