@@ -70,13 +70,20 @@ symbolt generate_java_generic_typet::operator()(
7070 pre_modification_size==after_modification_size,
7171 " All components in the original class should be in the new class" );
7272
73- const auto expected_symbol=" java::" +id2string (new_tag);
73+ const java_class_typet &new_java_class = construct_specialised_generic_type (
74+ generic_class_definition, new_tag, replacement_components);
75+ const type_symbolt &class_symbol =
76+ build_symbol_from_specialised_class (new_java_class);
77+
78+ std::pair<symbolt &, bool > res = symbol_table.insert (std::move (class_symbol));
79+ if (!res.second )
80+ {
81+ messaget message (message_handler);
82+ message.warning () << " stub class symbol " << class_symbol.name
83+ << " already exists" << messaget::eom;
84+ }
7485
75- generate_class_stub (
76- new_tag,
77- symbol_table,
78- message_handler,
79- replacement_components);
86+ const auto expected_symbol=" java::" +id2string (new_tag);
8087 auto symbol=symbol_table.lookup (expected_symbol);
8188 INVARIANT (symbol, " New class not created" );
8289 return *symbol;
@@ -216,3 +223,38 @@ irep_idt generate_java_generic_typet::build_generic_tag(
216223
217224 return new_tag_buffer.str ();
218225}
226+
227+ // / Build the specalised version of the specific class, with the specified
228+ // / parameters and name.
229+ // / \param generic_class_definition: The generic class we are specialising
230+ // / \param new_tag: The new name for the class (like Generic<java::Float>)
231+ // / \param new_components: The specialised components
232+ // / \return The newly constructed class.
233+ java_class_typet
234+ generate_java_generic_typet::construct_specialised_generic_type (
235+ const java_generic_class_typet &generic_class_definition,
236+ const irep_idt &new_tag,
237+ const struct_typet::componentst &new_components) const
238+ {
239+ java_class_typet specialised_class = generic_class_definition;
240+ // We are specialising the logic - so we don't want to be marked as generic
241+ specialised_class.set (ID_C_java_generics_class_type, false );
242+ specialised_class.set (ID_name, " java::" + id2string (new_tag));
243+ specialised_class.set (ID_base_name, new_tag);
244+ specialised_class.components () = new_components;
245+ return specialised_class;
246+ }
247+
248+ // / Construct the symbol to be moved into the symbol table
249+ // / \param specialised_class: The newly constructed specialised class
250+ // / \return The symbol to add to the symbol table
251+ type_symbolt generate_java_generic_typet::build_symbol_from_specialised_class (
252+ const java_class_typet &specialised_class) const
253+ {
254+ type_symbolt new_symbol (specialised_class);
255+ new_symbol.base_name = specialised_class.get (ID_base_name);
256+ new_symbol.pretty_name = specialised_class.get (ID_base_name);
257+ new_symbol.name = specialised_class.get (ID_name);
258+ new_symbol.mode = ID_java;
259+ return new_symbol;
260+ }
0 commit comments