@@ -179,6 +179,27 @@ bool java_bytecode_languaget::parse(
179
179
return false ;
180
180
}
181
181
182
+ /* ******************************************************************\
183
+
184
+ Function: get_virtual_method_target
185
+
186
+ Inputs: `needed_classes`: set of classes that can be instantiated.
187
+ Any potential callee not in this set will be ignored.
188
+ `call_basename`: unqualified function name with type
189
+ signature (e.g. "f:(I)")
190
+ `classname`: class name that may define or override a
191
+ function named `call_basename`.
192
+ `symbol_table`: global symtab
193
+
194
+ Outputs: Returns the fully qualified name of `classname`'s definition
195
+ of `call_basename` if found and `classname` is present in
196
+ `needed_classes`, or irep_idt() otherwise.
197
+
198
+ Purpose: Find a virtual callee, if one is defined and the callee type
199
+ is known to exist.
200
+
201
+ \*******************************************************************/
202
+
182
203
static irep_idt get_virtual_method_target (
183
204
const std::set<irep_idt>& needed_classes,
184
205
const irep_idt& call_basename,
@@ -195,6 +216,27 @@ static irep_idt get_virtual_method_target(
195
216
return irep_idt ();
196
217
}
197
218
219
+ /* ******************************************************************\
220
+
221
+ Function: get_virtual_method_target
222
+
223
+ Inputs: `c`: function call whose potential target functions should
224
+ be determined.
225
+ `needed_classes`: set of classes that can be instantiated.
226
+ Any potential callee not in this set will be ignored.
227
+ `symbol_table`: global symtab
228
+ `class_hierarchy`: global class hierarchy
229
+
230
+ Outputs: Populates `needed_methods` with all possible `c` callees,
231
+ taking `needed_classes` into account (virtual function
232
+ overrides defined on classes that are not 'needed' are
233
+ ignored)
234
+
235
+ Purpose: Find possible callees, excluding types that are not known
236
+ to be instantiated.
237
+
238
+ \*******************************************************************/
239
+
198
240
static void get_virtual_method_targets (
199
241
const code_function_callt& c,
200
242
const std::set<irep_idt>& needed_classes,
@@ -262,6 +304,19 @@ static void get_virtual_method_targets(
262
304
263
305
}
264
306
307
+ /* ******************************************************************\
308
+
309
+ Function: gather_virtual_callsites
310
+
311
+ Inputs: `e`: expression tree to search
312
+
313
+ Outputs: Populates `result` with pointers to each function call
314
+ within e that calls a virtual function.
315
+
316
+ Purpose: See output
317
+
318
+ \*******************************************************************/
319
+
265
320
static void gather_virtual_callsites (const exprt& e, std::vector<const code_function_callt*>& result)
266
321
{
267
322
if (e.id ()!=ID_code)
@@ -275,6 +330,20 @@ static void gather_virtual_callsites(const exprt& e, std::vector<const code_func
275
330
gather_virtual_callsites (*it,result);
276
331
}
277
332
333
+ /* ******************************************************************\
334
+
335
+ Function: gather_needed_globals
336
+
337
+ Inputs: `e`: expression tree to search
338
+ `symbol_table`: global symtab
339
+
340
+ Outputs: Populates `needed` with global variable symbols referenced
341
+ from `e` or its children.
342
+
343
+ Purpose: See output
344
+
345
+ \*******************************************************************/
346
+
278
347
static void gather_needed_globals (const exprt& e, const symbol_tablet& symbol_table, symbol_tablet& needed)
279
348
{
280
349
if (e.id ()==ID_symbol)
@@ -288,6 +357,23 @@ static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_ta
288
357
gather_needed_globals (*opit,symbol_table,needed);
289
358
}
290
359
360
+ /* ******************************************************************\
361
+
362
+ Function: gather_field_types
363
+
364
+ Inputs: `class_type`: root of class tree to search
365
+ `ns`: global namespace
366
+
367
+ Outputs: Populates `needed_classes` with all Java reference types
368
+ reachable starting at `class_type`. For example if
369
+ `class_type` is `symbol_typet("java::A")` and A has a B
370
+ field, then `B` (but not `A`) will be added to
371
+ `needed_classes`.
372
+
373
+ Purpose: See output
374
+
375
+ \*******************************************************************/
376
+
291
377
static void gather_field_types (
292
378
const typet& class_type,
293
379
const namespacet& ns,
@@ -310,6 +396,23 @@ static void gather_field_types(
310
396
}
311
397
}
312
398
399
+ /* ******************************************************************\
400
+
401
+ Function: initialise_needed_classes
402
+
403
+ Inputs: `entry_points`: list of fully-qualified function names that
404
+ we should assume are reachable
405
+ `ns`: global namespace
406
+ `ch`: global class hierarchy
407
+
408
+ Outputs: Populates `needed_classes` with all Java reference types
409
+ whose references may be passed, directly or indirectly,
410
+ to any of the functions in `entry_points`.
411
+
412
+ Purpose: See output
413
+
414
+ \*******************************************************************/
415
+
313
416
static void initialise_needed_classes (
314
417
const std::vector<irep_idt>& entry_points,
315
418
const namespacet& ns,
0 commit comments