@@ -273,9 +273,11 @@ void verilog_typecheckt::convert_function_or_task(verilog_declt &decl)
273
273
{
274
274
irep_idt decl_class=decl.get_class ();
275
275
276
- const std::string identifier=
277
- id2string (module_identifier)+" ." +
278
- id2string (decl.get_identifier ());
276
+ // the base name of the function/task
277
+ auto base_name = decl.get_identifier ();
278
+
279
+ const std::string identifier =
280
+ id2string (module_identifier) + " ." + id2string (base_name);
279
281
280
282
auto result=symbol_table.get_writeable (identifier);
281
283
@@ -292,11 +294,18 @@ void verilog_typecheckt::convert_function_or_task(verilog_declt &decl)
292
294
293
295
function_or_task_name = symbol.name ;
294
296
297
+ // function/tasks have an implicit named block with the name
298
+ // of the function
299
+
300
+ named_blocks.push_back (id2string (base_name) + " ." );
301
+
295
302
for (auto &inner_decl : decl.declarations ())
296
303
convert_decl (inner_decl);
297
304
298
305
convert_statement (decl.body ());
299
306
307
+ named_blocks.pop_back ();
308
+
300
309
function_or_task_name=" " ;
301
310
302
311
symbol.value =decl.body ();
@@ -336,6 +345,11 @@ exprt verilog_typecheckt::elaborate_constant_function_call(
336
345
337
346
function_or_task_name = function_symbol.name ;
338
347
348
+ // function/tasks have an implicit named block with the name
349
+ // of the function
350
+
351
+ named_blocks.push_back (id2string (function_symbol.base_name ) + " ." );
352
+
339
353
for (auto &inner_decl : decl.declarations ())
340
354
convert_decl (inner_decl);
341
355
@@ -380,6 +394,8 @@ exprt verilog_typecheckt::elaborate_constant_function_call(
380
394
// interpret it
381
395
verilog_interpreter (decl.body ());
382
396
397
+ named_blocks.pop_back ();
398
+
383
399
function_or_task_name=" " ;
384
400
385
401
// get return value
@@ -429,16 +445,9 @@ void verilog_typecheckt::convert_decl(verilog_declt &decl)
429
445
named_block = named_blocks.back ();
430
446
431
447
// fix the type and identifier
432
- irep_idt full_identifier;
433
-
434
- if (!function_or_task_name.empty ())
435
- full_identifier = id2string (function_or_task_name) + " ." +
436
- id2string (named_block) +
437
- id2string (declarator.base_name ());
438
- else
439
- full_identifier = id2string (module_identifier) + " ." +
440
- id2string (named_block) +
441
- id2string (declarator.base_name ());
448
+ auto full_identifier = id2string (module_identifier) + " ." +
449
+ id2string (named_block) +
450
+ id2string (declarator.base_name ());
442
451
443
452
symbolt &symbol = symbol_table_lookup (full_identifier);
444
453
declarator.type () = symbol.type ;
0 commit comments