Skip to content

Commit e0d3a08

Browse files
committed
Separate the copying parameter identifers
So that the symbol table reading function does not need access to the goto functions.
1 parent 716f451 commit e0d3a08

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/goto-programs/read_bin_goto_object.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Date: June 2006
2323
static void read_bin_symbol_table_object(
2424
std::istream &in,
2525
symbol_table_baset &symbol_table,
26-
goto_functionst &functions,
2726
irep_serializationt &irepconverter)
2827
{
2928
const std::size_t count = irepconverter.read_gb_word(in); // # of symbols
@@ -66,17 +65,36 @@ static void read_bin_symbol_table_object(
6665
sym.is_extern = (flags &(1 << 1))!=0;
6766
sym.is_volatile = (flags &1)!=0;
6867

69-
if(!sym.is_type && sym.type.id()==ID_code)
70-
{
71-
// makes sure there is an empty function for every function symbol
72-
auto entry = functions.function_map.emplace(sym.name, goto_functiont());
73-
entry.first->second.set_parameter_identifiers(to_code_type(sym.type));
74-
}
75-
7668
symbol_table.add(sym);
7769
}
7870
}
7971

72+
/// The serialised form of the goto-model currently includes the parameter
73+
/// identifiers in the symbol table attached to the types of function symbols.
74+
/// However it is not included in the goto functions. Therefore this function is
75+
/// needed to copy the parameter identifiers from the symbol table to the
76+
/// functions.
77+
static void copy_parameter_identifiers(
78+
const symbol_table_baset &symbol_table,
79+
goto_functionst &functions)
80+
{
81+
for(const auto &name_symbol : symbol_table)
82+
{
83+
const auto &symbol = name_symbol.second;
84+
if(symbol.is_type)
85+
continue;
86+
87+
const auto code_type = type_try_dynamic_cast<code_typet>(symbol.type);
88+
if(!code_type)
89+
continue;
90+
91+
// Makes sure there is an empty function for every function symbol.
92+
auto emplaced =
93+
functions.function_map.emplace(symbol.name, goto_functiont());
94+
emplaced.first->second.set_parameter_identifiers(*code_type);
95+
}
96+
}
97+
8098
static void read_bin_functions_object(
8199
std::istream &in,
82100
goto_functionst &functions,
@@ -180,7 +198,8 @@ static bool read_bin_goto_object(
180198
goto_functionst &functions,
181199
irep_serializationt &irepconverter)
182200
{
183-
read_bin_symbol_table_object(in, symbol_table, functions, irepconverter);
201+
read_bin_symbol_table_object(in, symbol_table, irepconverter);
202+
copy_parameter_identifiers(symbol_table, functions);
184203
read_bin_functions_object(in, functions, irepconverter);
185204
return false;
186205
}

0 commit comments

Comments
 (0)