Skip to content

Commit 60f801c

Browse files
committed
Record class' instance methods against their type
This makes it much easier to find the type's methods without having to search the whole symbol table.
1 parent 4b3bc72 commit 60f801c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,15 @@ optionalt<symbolt> java_bytecode_convert_methodt::get_lambda_method_symbol(
324324
/// This creates a method symbol in the symtab, but doesn't actually perform
325325
/// method conversion just yet. The caller should call
326326
/// java_bytecode_convert_method later to give the symbol/method a body.
327-
/// \param class_symbol: The class this method belongs to
327+
/// \param class_symbol: The class this method belongs to. The method, if not
328+
/// static, will be added to the class' list of methods.
328329
/// \param method_identifier: The fully qualified method name, including type
329330
/// descriptor (e.g. "x.y.z.f:(I)")
330331
/// \param m: The parsed method object to convert.
331332
/// \param symbol_table: The global symbol table (will be modified).
332333
/// \param message_handler: A message handler to collect warnings.
333334
void java_bytecode_convert_method_lazy(
334-
const symbolt &class_symbol,
335+
symbolt &class_symbol,
335336
const irep_idt &method_identifier,
336337
const java_bytecode_parse_treet::methodt &m,
337338
symbol_tablet &symbol_table,
@@ -423,6 +424,19 @@ void java_bytecode_convert_method_lazy(
423424
}
424425

425426
symbol_table.add(method_symbol);
427+
428+
if(!m.is_static)
429+
{
430+
class_typet::methodt new_method;
431+
new_method.set_name(method_symbol.name);
432+
new_method.set_base_name(method_symbol.base_name);
433+
new_method.set_pretty_name(method_symbol.pretty_name);
434+
new_method.set_access(member_type.get_access());
435+
new_method.type() = method_symbol.type;
436+
437+
to_class_type(class_symbol.type).methods().emplace_back(
438+
std::move(new_method));
439+
}
426440
}
427441

428442
static irep_idt get_method_identifier(

jbmc/src/java_bytecode/java_bytecode_convert_method.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void create_method_stub_symbol(
4949
message_handlert &message_handler);
5050

5151
void java_bytecode_convert_method_lazy(
52-
const symbolt &class_symbol,
52+
symbolt &class_symbol,
5353
const irep_idt &method_identifier,
5454
const java_bytecode_parse_treet::methodt &,
5555
symbol_tablet &symbol_table,

0 commit comments

Comments
 (0)