From 9dda8c40585b528f7e9664e9fcede9d7bf104f0f Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 3 Apr 2015 16:46:44 +0200 Subject: [PATCH] preprocessor: take care of extra exos in osr --- ComputingTasks.cc | 23 +++++++++++++++++++++++ ComputingTasks.hh | 1 + 2 files changed, 24 insertions(+) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 1274858b..1a9e4601 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -1295,6 +1295,29 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation mod_file_struct.k_order_solver = true; } +Statement * +OsrStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + SymbolList new_symbol_list; + try + { + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + vector symbols = symbol_list.get_symbols(); + for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) + { + new_symbol_table->getID(*it); + new_symbol_list.addSymbol(*it); + } + } + catch (SymbolTable::UnknownSymbolNameException &e) + { + cerr << "ERROR: A variable in the osr statement was not found in the symbol table" << endl + << " This likely means that you have declared a varexo that is not used in the model" << endl; + exit(EXIT_FAILURE); + } + return new OsrStatement(new_symbol_list, options_list); +} + void OsrStatement::writeOutput(ostream &output, const string &basename) const { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index 88d51c2c..3736d0de 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -246,6 +246,7 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename) const; + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DynaTypeStatement : public Statement