From fe133054cff196db9316e3989051950b7b0d90d3 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtanb@gmail.com> Date: Thu, 24 Jun 2010 15:07:15 +0200 Subject: [PATCH] DSGE-Var: bug fix. Add init param statement at the before the estimation statement --- ModFile.cc | 12 +++++++++--- ModFile.hh | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ModFile.cc b/ModFile.cc index 8044fa1b..71c539bd 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -86,6 +86,12 @@ ModFile::addStatement(Statement *st) statements.push_back(st); } +void +ModFile::addStatementAtFront(Statement *st) +{ + statements.insert(statements.begin(), st); +} + void ModFile::checkPass() { @@ -226,9 +232,9 @@ ModFile::transformPass() { int sid = symbol_table.addSymbol("dsge_prior_weight", eParameter); if (!mod_file_struct.dsge_var_calibrated.empty()) - addStatement(new InitParamStatement(sid, - expressions_tree.AddNumConstant(mod_file_struct.dsge_var_calibrated), - symbol_table)); + addStatementAtFront(new InitParamStatement(sid, + expressions_tree.AddNumConstant(mod_file_struct.dsge_var_calibrated), + symbol_table)); } catch (SymbolTable::AlreadyDeclaredException &e) { diff --git a/ModFile.hh b/ModFile.hh index bfa12f9d..f35957a9 100644 --- a/ModFile.hh +++ b/ModFile.hh @@ -82,6 +82,8 @@ private: public: //! Add a statement void addStatement(Statement *st); + //! Add a statement at the front of the statements vector + void addStatementAtFront(Statement *st); //! Evaluate all the statements /*! \param warn_uninit Should a warning be displayed for uninitialized endogenous/exogenous/parameters ? */ void evalAllExpressions(bool warn_uninit); -- GitLab