Skip to content

Commit d932cfd

Browse files
committed
Document lazy methods
1 parent 5be7106 commit d932cfd

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,25 @@ const exprt java_bytecode_convert_methodt::variable(
177177
}
178178
}
179179

180+
/*******************************************************************\
181+
182+
Function: java_bytecode_convert_method_lazy
183+
184+
Inputs: `class_symbol`: class this method belongs to
185+
`method_identifier`: fully qualified method name, including
186+
type signature (e.g. "x.y.z.f:(I)")
187+
`m`: parsed method object to convert
188+
`symbol_table`: global symbol table (will be modified)
189+
190+
Outputs:
191+
192+
Purpose: This creates a method symbol in the symtab, but doesn't
193+
actually perform method conversion just yet. The caller
194+
should call java_bytecode_convert_method later to give the
195+
symbol/method a body.
196+
197+
\*******************************************************************/
198+
180199
void java_bytecode_convert_method_lazy(
181200
const symbolt& class_symbol,
182201
const irep_idt method_identifier,

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,27 @@ bool java_bytecode_languaget::parse(
179179
return false;
180180
}
181181

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+
182203
static irep_idt get_virtual_method_target(
183204
const std::set<irep_idt>& needed_classes,
184205
const irep_idt& call_basename,
@@ -195,6 +216,27 @@ static irep_idt get_virtual_method_target(
195216
return irep_idt();
196217
}
197218

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+
198240
static void get_virtual_method_targets(
199241
const code_function_callt& c,
200242
const std::set<irep_idt>& needed_classes,
@@ -262,6 +304,19 @@ static void get_virtual_method_targets(
262304

263305
}
264306

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+
265320
static void gather_virtual_callsites(const exprt& e, std::vector<const code_function_callt*>& result)
266321
{
267322
if(e.id()!=ID_code)
@@ -275,6 +330,20 @@ static void gather_virtual_callsites(const exprt& e, std::vector<const code_func
275330
gather_virtual_callsites(*it,result);
276331
}
277332

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+
278347
static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_table, symbol_tablet& needed)
279348
{
280349
if(e.id()==ID_symbol)
@@ -288,6 +357,23 @@ static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_ta
288357
gather_needed_globals(*opit,symbol_table,needed);
289358
}
290359

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+
291377
static void gather_field_types(
292378
const typet& class_type,
293379
const namespacet& ns,
@@ -310,6 +396,23 @@ static void gather_field_types(
310396
}
311397
}
312398

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+
313416
static void initialise_needed_classes(
314417
const std::vector<irep_idt>& entry_points,
315418
const namespacet& ns,

0 commit comments

Comments
 (0)