Skip to content

Commit f394c50

Browse files
author
Daniel Kroening
committed
symbol_table API
1 parent 84e5518 commit f394c50

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/verilog/verilog_interfaces.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ void verilog_typecheckt::interface_ports(irept::subt &ports)
177177

178178
// check that all declared ports are also in the port list
179179

180-
forall_symbol_module_map(it, symbol_table.symbol_module_map, module_identifier)
180+
for(auto it=symbol_table.symbol_module_map.lower_bound(module_identifier);
181+
it!=symbol_table.symbol_module_map.upper_bound(module_identifier);
182+
it++)
181183
{
182184
const symbolt &symbol=ns.lookup(it->second);
183185

@@ -265,7 +267,7 @@ void verilog_typecheckt::interface_function_or_task(
265267

266268
return_symbol.pretty_name=strip_verilog_prefix(return_symbol.name);
267269

268-
symbol_table.move(return_symbol);
270+
symbol_table.add(return_symbol);
269271
}
270272

271273
// do the declarations within the task/function
@@ -419,10 +421,9 @@ void verilog_typecheckt::interface_function_or_task_decl(const verilog_declt &de
419421
// in Verilog terminology, but inputs and outputs.
420422
// We'll use the C terminology, and call them parameters.
421423
// Not to be confused with module parameters.
422-
symbol_tablet::symbolst::iterator s_it=
423-
symbol_table.symbols.find(function_or_task_name);
424-
assert(s_it!=symbol_table.symbols.end());
425-
symbolt &function_or_task_symbol=s_it->second;
424+
auto s_it=symbol_table.get_writeable(function_or_task_name);
425+
CHECK_RETURN(s_it!=nullptr);
426+
symbolt &function_or_task_symbol=*s_it;
426427
code_typet::parameterst &parameters=
427428
to_code_type(function_or_task_symbol.type).parameters();
428429
parameters.push_back(code_typet::parametert());
@@ -434,7 +435,7 @@ void verilog_typecheckt::interface_function_or_task_decl(const verilog_declt &de
434435
parameter.set(ID_input, input);
435436
}
436437

437-
symbol_tablet::symbolst::iterator result=
438+
symbol_tablet::symbolst::const_iterator result=
438439
symbol_table.symbols.find(symbol.name);
439440

440441
if(result!=symbol_table.symbols.end())
@@ -584,16 +585,15 @@ void verilog_typecheckt::interface_module_decl(
584585
symbol.pretty_name=
585586
strip_verilog_prefix(symbol.name);
586587

587-
symbol_tablet::symbolst::iterator result=
588-
symbol_table.symbols.find(symbol.name);
588+
auto result=symbol_table.get_writeable(symbol.name);
589589

590-
if(result==symbol_table.symbols.end())
590+
if(result==nullptr)
591591
{
592592
symbol_table.add(symbol);
593593
}
594594
else
595595
{
596-
symbolt &osymbol=result->second;
596+
symbolt &osymbol=*result;
597597

598598
if(osymbol.type.id()==ID_code)
599599
{

src/verilog/verilog_symbol_table.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Function: verilog_symbol_tablet::symbol_table_lookup
2222

2323
symbolt &verilog_symbol_tablet::symbol_table_lookup(const irep_idt &identifier)
2424
{
25-
symbol_tablet::symbolst::iterator it=symbol_table.symbols.find(identifier);
25+
auto it=symbol_table.get_writeable(identifier);
2626

27-
if(it==symbol_table.symbols.end())
27+
if(it==nullptr)
2828
throw "symbol "+id2string(identifier)+" not found";
2929

30-
return it->second;
30+
return *it;
3131
}

src/verilog/verilog_synthesis.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ void verilog_synthesist::replace_by_wire(
603603
assignment.next.value=what;
604604
new_wires.insert(new_symbol.name);
605605

606-
if(symbol_table.move(new_symbol))
606+
if(symbol_table.add(new_symbol))
607607
{
608608
error() << "failed to add replace_by_wire symbol" << eom;
609609
throw 0;
@@ -783,7 +783,7 @@ Function: verilog_synthesist::assignment_symbol
783783
784784
\*******************************************************************/
785785

786-
symbolt &verilog_synthesist::assignment_symbol(const exprt &lhs)
786+
const symbolt &verilog_synthesist::assignment_symbol(const exprt &lhs)
787787
{
788788
const exprt *e=&lhs;
789789

@@ -831,7 +831,7 @@ symbolt &verilog_synthesist::assignment_symbol(const exprt &lhs)
831831

832832
const irep_idt &identifier=e->get(ID_identifier);
833833

834-
symbol_tablet::symbolst::iterator it=
834+
symbol_tablet::symbolst::const_iterator it=
835835
symbol_table.symbols.find(identifier);
836836

837837
if(it==symbol_table.symbols.end())
@@ -1248,7 +1248,9 @@ void verilog_synthesist::expand_module_instance(
12481248

12491249
std::list<irep_idt> new_symbols;
12501250

1251-
forall_symbol_module_map(it, symbol_table.symbol_module_map, symbol.module)
1251+
for(auto it=symbol_table.symbol_module_map.lower_bound(symbol.module);
1252+
it!=symbol_table.symbol_module_map.upper_bound(symbol.module);
1253+
it++)
12521254
{
12531255
const symbolt &symbol=ns.lookup(it->second);
12541256

@@ -1619,7 +1621,7 @@ void verilog_synthesist::synth_force_rec(
16191621

16201622
// get symbol
16211623

1622-
symbolt &symbol=assignment_symbol(lhs);
1624+
const symbolt &symbol=assignment_symbol(lhs);
16231625

16241626
assignmentt &assignment=assignments[symbol.name];
16251627

@@ -2950,7 +2952,9 @@ void verilog_synthesist::convert_module_items(symbolt &symbol)
29502952

29512953
// find out about symbols of this module
29522954

2953-
forall_symbol_module_map(it, symbol_table.symbol_module_map, module)
2955+
for(auto it=symbol_table.symbol_module_map.lower_bound(module);
2956+
it!=symbol_table.symbol_module_map.upper_bound(module);
2957+
it++)
29542958
local_symbols.insert(it->second);
29552959

29562960
// now convert the module items

src/verilog/verilog_synthesis_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class verilog_synthesist:
185185
exprt &rhs,
186186
exprt &new_value);
187187

188-
symbolt &assignment_symbol(const exprt &lhs);
188+
const symbolt &assignment_symbol(const exprt &lhs);
189189

190190
void assignment_member_rec(
191191
const exprt &lhs,

0 commit comments

Comments
 (0)