preprocessor: pointer to symbol_table unnecessary

issue#70
Houtan Bastani 2015-04-09 15:18:12 +02:00
parent f329a2686e
commit cb08675696
2 changed files with 14 additions and 20 deletions

View File

@ -1184,14 +1184,13 @@ ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_t &t
Statement * Statement *
ObservationTrendsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) ObservationTrendsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
map<string, expr_t> new_trend_elements; map<string, expr_t> new_trend_elements;
try try
{ {
for (map<string, expr_t>::const_iterator it = trend_elements.begin(); for (map<string, expr_t>::const_iterator it = trend_elements.begin();
it != trend_elements.end(); it++) it != trend_elements.end(); it++)
{ {
new_symbol_table->getID(it->first); symbol_table.getID(it->first);
new_trend_elements[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); new_trend_elements[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
} }
} }
@ -1201,7 +1200,7 @@ ObservationTrendsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, S
<< " This likely means that you have declared a varexo that is not used in the model" << endl; << " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return new ObservationTrendsStatement(new_trend_elements, *new_symbol_table); return new ObservationTrendsStatement(new_trend_elements, symbol_table);
} }
void void
@ -1351,7 +1350,6 @@ OptimWeightsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
Statement * Statement *
OptimWeightsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) OptimWeightsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
var_weights_t new_var_weights; var_weights_t new_var_weights;
covar_weights_t new_covar_weights; covar_weights_t new_covar_weights;
try try
@ -1359,15 +1357,15 @@ OptimWeightsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, Symbol
for (var_weights_t::const_iterator it = var_weights.begin(); for (var_weights_t::const_iterator it = var_weights.begin();
it != var_weights.end(); it++) it != var_weights.end(); it++)
{ {
new_symbol_table->getID(it->first); symbol_table.getID(it->first);
new_var_weights[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); new_var_weights[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
} }
for (covar_weights_t::const_iterator it = covar_weights.begin(); for (covar_weights_t::const_iterator it = covar_weights.begin();
it != covar_weights.end(); it++) it != covar_weights.end(); it++)
{ {
new_symbol_table->getID(it->first.first); symbol_table.getID(it->first.first);
new_symbol_table->getID(it->first.second); symbol_table.getID(it->first.second);
new_covar_weights[make_pair(it->first.first, it->first.second)] = new_covar_weights[make_pair(it->first.first, it->first.second)] =
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
} }
@ -1378,7 +1376,7 @@ OptimWeightsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, Symbol
<< " This likely means that you have declared a varexo that is not used in the model" << endl; << " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return new OptimWeightsStatement(new_var_weights, new_covar_weights, *new_symbol_table); return new OptimWeightsStatement(new_var_weights, new_covar_weights, symbol_table);
} }
void void

View File

@ -76,12 +76,11 @@ InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
Statement * Statement *
InitParamStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) InitParamStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
try try
{ {
return new InitParamStatement(new_symbol_table->getID(orig_symbol_table.getName(symb_id)), return new InitParamStatement(symbol_table.getID(orig_symbol_table.getName(symb_id)),
param_value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table), param_value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table),
*new_symbol_table); symbol_table);
} }
catch (SymbolTable::UnknownSymbolIDException &e) catch (SymbolTable::UnknownSymbolIDException &e)
{ {
@ -229,12 +228,11 @@ Statement *
InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
init_values_t new_init_values; init_values_t new_init_values;
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
try try
{ {
for (init_values_t::const_iterator it=init_values.begin(); for (init_values_t::const_iterator it=init_values.begin();
it != init_values.end(); it++) it != init_values.end(); it++)
new_init_values.push_back(make_pair(new_symbol_table->getID(orig_symbol_table.getName(it->first)), new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table))); it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
} }
catch (SymbolTable::UnknownSymbolIDException &e) catch (SymbolTable::UnknownSymbolIDException &e)
@ -243,7 +241,7 @@ InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable
<< " This likely means that you have declared a varexo that is not used in the model" << endl; << " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return new InitValStatement(new_init_values, *new_symbol_table, all_values_required); return new InitValStatement(new_init_values, symbol_table, all_values_required);
} }
EndValStatement::EndValStatement(const init_values_t &init_values_arg, EndValStatement::EndValStatement(const init_values_t &init_values_arg,
@ -296,12 +294,11 @@ Statement *
EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
init_values_t new_init_values; init_values_t new_init_values;
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
try try
{ {
for (init_values_t::const_iterator it=init_values.begin(); for (init_values_t::const_iterator it=init_values.begin();
it != init_values.end(); it++) it != init_values.end(); it++)
new_init_values.push_back(make_pair(new_symbol_table->getID(orig_symbol_table.getName(it->first)), new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table))); it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
} }
catch (SymbolTable::UnknownSymbolIDException &e) catch (SymbolTable::UnknownSymbolIDException &e)
@ -310,7 +307,7 @@ EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable
<< " This likely means that you have declared a varexo that is not used in the model" << endl; << " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return new EndValStatement(new_init_values, *new_symbol_table, all_values_required); return new EndValStatement(new_init_values, symbol_table, all_values_required);
} }
HistValStatement::HistValStatement(const hist_values_t &hist_values_arg, HistValStatement::HistValStatement(const hist_values_t &hist_values_arg,
@ -383,12 +380,11 @@ Statement *
HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{ {
hist_values_t new_hist_values; hist_values_t new_hist_values;
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
try try
{ {
for (hist_values_t::const_iterator it=hist_values.begin(); for (hist_values_t::const_iterator it=hist_values.begin();
it != hist_values.end(); it++) it != hist_values.end(); it++)
new_hist_values[make_pair(new_symbol_table->getID(orig_symbol_table.getName(it->first.first)), new_hist_values[make_pair(symbol_table.getID(orig_symbol_table.getName(it->first.first)),
it->first.second)] = it->first.second)] =
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
} }
@ -398,7 +394,7 @@ HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable
<< " This likely means that you have declared a varexo that is not used in the model" << endl; << " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return new HistValStatement(new_hist_values, *new_symbol_table); return new HistValStatement(new_hist_values, symbol_table);
} }
InitvalFileStatement::InitvalFileStatement(const string &filename_arg) : InitvalFileStatement::InitvalFileStatement(const string &filename_arg) :