@@ -149,6 +149,42 @@ typet verilog_typecheck_exprt::convert_packed_array_type(
149149
150150/* ******************************************************************\
151151
152+ Function: verilog_typecheck_exprt::elaborate_package_scope_typedef
153+
154+ Inputs:
155+
156+ Outputs:
157+
158+ Purpose:
159+
160+ \*******************************************************************/
161+
162+ typet verilog_typecheck_exprt::elaborate_package_scope_typedef (
163+ const type_with_subtypest &src)
164+ {
165+ auto location = src.source_location ();
166+
167+ if (src.subtypes ()[1 ].id () != ID_typedef_type)
168+ throw errort ().with_location (location)
169+ << " verilog_package_scope expects typedef_type on the rhs" ;
170+
171+ auto package_base_name = src.subtypes ()[0 ].id ();
172+ auto typedef_base_name = src.subtypes ()[1 ].get (ID_base_name);
173+
174+ // stitch together
175+ irep_idt full_identifier =
176+ id2string (verilog_package_identifier (package_base_name)) + ' .' +
177+ id2string (typedef_base_name);
178+
179+ // recursive call
180+ verilog_typedef_typet full_typedef_type (full_identifier);
181+ full_typedef_type.set (ID_identifier, full_identifier);
182+
183+ return elaborate_type (full_typedef_type);
184+ }
185+
186+ /* ******************************************************************\
187+
152188Function: verilog_typecheck_exprt::elaborate_type
153189
154190 Inputs:
@@ -283,7 +319,7 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
283319 // Look it up!
284320 const symbolt *symbol_ptr;
285321
286- auto identifier = src. get (ID_identifier );
322+ auto identifier = to_verilog_typedef_type ( src). identifier ( );
287323
288324 if (ns.lookup (identifier, symbol_ptr))
289325 throw errort ().with_location (source_location)
@@ -402,6 +438,11 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
402438 {
403439 return src;
404440 }
441+ else if (src.id () == ID_verilog_package_scope)
442+ {
443+ // package::typedef
444+ return elaborate_package_scope_typedef (to_type_with_subtypes (src));
445+ }
405446 else
406447 {
407448 throw errort ().with_location (source_location)
0 commit comments