Skip to content

Commit c7cd6a6

Browse files
authored
Merge pull request #323 from diffblue/verilog_blockt
Verilog: strengthen typing when using verilog_blockt
2 parents 37b871d + 53bba2d commit c7cd6a6

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/verilog/verilog_expr.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,25 @@ class verilog_blockt:public verilog_statementt
653653
verilog_blockt():verilog_statementt(ID_block)
654654
{
655655
}
656-
657-
inline irep_idt get_identifier() const
656+
657+
using statementst = std::vector<verilog_statementt>;
658+
659+
statementst &statements()
660+
{
661+
return (statementst &)operands();
662+
}
663+
664+
const statementst &statements() const
665+
{
666+
return (const statementst &)operands();
667+
}
668+
669+
irep_idt identifier() const
658670
{
659671
return get(ID_identifier);
660672
}
661-
662-
inline bool is_named() const
673+
674+
bool is_named() const
663675
{
664676
return !get(ID_identifier).empty();
665677
}

src/verilog/verilog_interfaces.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@ void verilog_typecheckt::interface_block(
857857

858858
if(is_named)
859859
{
860-
irep_idt identifier=statement.get_identifier();
861-
860+
irep_idt identifier = statement.identifier();
861+
862862
// need to add to symbol table
863863
symbolt symbol;
864864

@@ -892,9 +892,8 @@ void verilog_typecheckt::interface_block(
892892

893893
// do block itself
894894

895-
forall_operands(it, statement)
896-
interface_statement(
897-
static_cast<const verilog_statementt &>(*it));
895+
for(auto &block_statement : statement.statements())
896+
interface_statement(block_statement);
898897

899898
if(is_named)
900899
named_blocks.pop_back();

src/verilog/verilog_synthesis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ Function: verilog_synthesist::synth_block
15701570

15711571
void verilog_synthesist::synth_block(const verilog_blockt &statement)
15721572
{
1573-
forall_operands(it, statement)
1574-
synth_statement(static_cast<const verilog_statementt &>(*it));
1573+
for(auto &block_statement : statement.statements())
1574+
synth_statement(block_statement);
15751575
}
15761576

15771577
/*******************************************************************\

src/verilog/verilog_typecheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,11 @@ void verilog_typecheckt::convert_block(verilog_blockt &statement)
757757
bool is_named=statement.is_named();
758758

759759
if(is_named)
760-
enter_named_block(statement.get_identifier());
760+
enter_named_block(statement.identifier());
761+
762+
for(auto &block_statement : statement.statements())
763+
convert_statement(block_statement);
761764

762-
Forall_operands(it, statement)
763-
convert_statement(to_verilog_statement(*it));
764-
765765
if(is_named)
766766
named_blocks.pop_back();
767767
}

0 commit comments

Comments
 (0)