Skip to content

Commit e1c0637

Browse files
smowtonMatthias Güdemann
authored andcommitted
Add implied fields to classes
When dealing with opaque (unelaborated) classes, this infers that a particular class or superclass must have a particular field when the source program assumes their presence (i.e. when there is an ((A*)a)->x reference and we don't yet know that a field named 'x' exists). This feeds into opaque stub generation, which can use the inferred type descriptor to create appropriate object initialisers in stub functions.
1 parent f747a29 commit e1c0637

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/java_bytecode/java_bytecode_typecheck_expr.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ void java_bytecode_typecheckt::typecheck_expr_member(member_exprt &expr)
254254
{
255255
// member doesn't exist. In this case struct_type should be an opaque
256256
// stub, and we'll add the member to it.
257-
components
257+
symbolt &symbol_table_type=
258+
symbol_table.lookup("java::"+id2string(struct_type.get_tag()));
259+
auto &add_to_components=
260+
to_struct_type(symbol_table_type.type).components();
261+
add_to_components
258262
.push_back(struct_typet::componentt(component_name, expr.type()));
259-
components.back().set_base_name(component_name);
260-
components.back().set_pretty_name(component_name);
263+
add_to_components.back().set_base_name(component_name);
264+
add_to_components.back().set_pretty_name(component_name);
261265
return;
262266
}
263267

0 commit comments

Comments
 (0)