diff --git a/ComputingTasks.cc b/ComputingTasks.cc index bc004ae0..9d1a93b7 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -2974,6 +2974,23 @@ PriorStatement::PriorStatement(const string &name_arg, { } +Statement * +PriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + try + { + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + new_symbol_table->getID(name); + } + catch (...) + { + cerr << "ERROR: A variable in the prior 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 PriorStatement(name, subsample_name, prior_shape, variance, options_list); +} + void PriorStatement::writeOutput(ostream &output, const string &basename) const { @@ -3011,6 +3028,23 @@ StdPriorStatement::StdPriorStatement(const string &name_arg, { } +Statement * +StdPriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + try + { + new_symbol_table->getID(name); + } + catch (...) + { + cerr << "ERROR: A variable in the std_prior 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 StdPriorStatement(name, subsample_name, prior_shape, variance, options_list, *new_symbol_table); +} + void StdPriorStatement::writeOutput(ostream &output, const string &basename) const { @@ -3074,6 +3108,24 @@ CorrPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolid } } +Statement * +CorrPriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + try + { + new_symbol_table->getID(name); + new_symbol_table->getID(name1); + } + catch (...) + { + cerr << "ERROR: A variable in the corr_prior 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 CorrPriorStatement(name, name1, subsample_name, prior_shape, variance, options_list, *new_symbol_table); +} + void CorrPriorStatement::writeOutput(ostream &output, const string &basename) const { @@ -3153,6 +3205,37 @@ PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli } } +Statement * +PriorEqualStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + try + { + new_symbol_table->getID(to_name1); + if (!to_name2.empty()) + new_symbol_table->getID(to_name2); + + new_symbol_table->getID(from_name1); + if (!from_name2.empty()) + new_symbol_table->getID(from_name2); + } + catch (...) + { + cerr << "ERROR: A variable in the prior equal 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 PriorEqualStatement(to_declaration_type, + to_name1, + to_name2, + to_subsample_name, + from_declaration_type, + from_name1, + from_name2, + from_subsample_name, + *new_symbol_table); +} + void PriorEqualStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index 4c761a08..b6625e81 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -756,6 +756,7 @@ public: const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeCOutput(ostream &output, const string &basename); + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class StdPriorStatement : public BasicPriorStatement @@ -771,6 +772,7 @@ public: const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeCOutput(ostream &output, const string &basename); + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class CorrPriorStatement : public BasicPriorStatement @@ -789,6 +791,7 @@ public: virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeCOutput(ostream &output, const string &basename); + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class PriorEqualStatement : public Statement @@ -816,6 +819,7 @@ public: void get_base_name(const SymbolType symb_type, string &lhs_field) const; 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 BasicOptionsStatement : public Statement