Skip to content

Commit ddd1b7a

Browse files
Add remove_instanceof overload to remove from a particular instruction
1 parent e2cda1a commit ddd1b7a

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/goto-programs/remove_instanceof.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ class remove_instanceoft
2828
class_hierarchy(symbol_table);
2929
}
3030

31-
// Lower instanceof for a single functions
31+
// Lower instanceof for a single function
3232
bool lower_instanceof(goto_programt &);
3333

34+
// Lower instanceof for a single instruction
35+
bool lower_instanceof(goto_programt &, goto_programt::targett);
36+
3437
protected:
3538
symbol_tablet &symbol_table;
3639
namespacet ns;
3740
class_hierarchyt class_hierarchy;
3841

39-
bool lower_instanceof(goto_programt &, goto_programt::targett);
40-
4142
std::size_t lower_instanceof(
4243
exprt &, goto_programt &, goto_programt::targett);
4344
};
@@ -168,9 +169,24 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program)
168169
}
169170

170171

172+
/// Replace an instanceof in the expression or guard of the passed instruction
173+
/// of the given function body with an explicit class-identifier test.
174+
/// \remarks Extra auxiliary variables may be introduced into symbol_table.
175+
/// \param target: The instruction to work on.
176+
/// \param goto_program: The function body containing the instruction.
177+
/// \param symbol_table: The symbol table to add symbols to.
178+
void remove_instanceof(
179+
goto_programt::targett target,
180+
goto_programt &goto_program,
181+
symbol_tablet &symbol_table)
182+
{
183+
remove_instanceoft rem(symbol_table);
184+
rem.lower_instanceof(goto_program, target);
185+
}
186+
171187
/// Replace every instanceof in the passed function with an explicit
172188
/// class-identifier test.
173-
/// Extra auxiliary variables may be introduced into symbol_table.
189+
/// \remarks Extra auxiliary variables may be introduced into symbol_table.
174190
/// \param function: The function to work on.
175191
/// \param symbol_table: The symbol table to add symbols to.
176192
void remove_instanceof(
@@ -183,7 +199,7 @@ void remove_instanceof(
183199

184200
/// Replace every instanceof in every function with an explicit
185201
/// class-identifier test.
186-
/// Extra auxiliary variables may be introduced into symbol_table.
202+
/// \remarks Extra auxiliary variables may be introduced into symbol_table.
187203
/// \param goto_functions: The functions to work on.
188204
/// \param symbol_table: The symbol table to add symbols to.
189205
void remove_instanceof(
@@ -198,6 +214,11 @@ void remove_instanceof(
198214
goto_functions.compute_location_numbers();
199215
}
200216

217+
/// Replace every instanceof in every function with an explicit
218+
/// class-identifier test.
219+
/// \remarks Extra auxiliary variables may be introduced into symbol_table.
220+
/// \param goto_model: The functions to work on and the symbol table to add
221+
/// symbols to.
201222
void remove_instanceof(goto_modelt &goto_model)
202223
{
203224
remove_instanceof(goto_model.goto_functions, goto_model.symbol_table);

src/goto-programs/remove_instanceof.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Author: Chris Smowton, [email protected]
1616
#include "goto_functions.h"
1717
#include "goto_model.h"
1818

19+
void remove_instanceof(
20+
goto_programt::targett target,
21+
goto_programt &goto_program,
22+
symbol_tablet &symbol_table);
23+
1924
void remove_instanceof(
2025
goto_functionst::goto_functiont &function,
2126
symbol_tablet &symbol_table);

0 commit comments

Comments
 (0)