From 47d0516d4fb76767b61711d940c2249e23687677 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 3 Apr 2015 17:15:01 +0200 Subject: [PATCH] preprocessor: take care of extra exos in dynatype --- ComputingTasks.cc | 23 +++++++++++++++++++++++ ComputingTasks.hh | 1 + 2 files changed, 24 insertions(+) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index d32157f3..1d86564e 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -1462,6 +1462,29 @@ DynaTypeStatement::DynaTypeStatement(const SymbolList &symbol_list_arg, { } +Statement * +DynaTypeStatement::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 dynatype 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 DynaTypeStatement(new_symbol_list, filename); +} + void DynaTypeStatement::writeOutput(ostream &output, const string &basename) const { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index dc9a873b..4eedddb4 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -258,6 +258,7 @@ public: DynaTypeStatement(const SymbolList &symbol_list_arg, const string &filename_arg); virtual void writeOutput(ostream &output, const string &basename) const; + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DynaSaveStatement : public Statement