2008-02-03 11:28:36 +01:00
|
|
|
/*
|
2010-02-22 17:33:38 +01:00
|
|
|
* Copyright (C) 2006-2010 Dynare Team
|
2008-02-03 11:28:36 +01:00
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MOD_FILE_HH
|
|
|
|
#define _MOD_FILE_HH
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <ostream>
|
2009-01-20 23:04:37 +01:00
|
|
|
#include <ctime>
|
|
|
|
|
2008-02-03 11:28:36 +01:00
|
|
|
#include "SymbolTable.hh"
|
|
|
|
#include "NumericalConstants.hh"
|
2008-12-19 11:24:31 +01:00
|
|
|
#include "NumericalInitialization.hh"
|
2009-04-14 16:39:53 +02:00
|
|
|
#include "StaticModel.hh"
|
|
|
|
#include "DynamicModel.hh"
|
2010-04-23 18:39:07 +02:00
|
|
|
#include "SteadyStateModel.hh"
|
2008-02-03 11:28:36 +01:00
|
|
|
#include "Statement.hh"
|
2010-02-22 17:33:38 +01:00
|
|
|
#include "ExternalFunctionsTable.hh"
|
2008-02-03 11:28:36 +01:00
|
|
|
|
|
|
|
//! The abstract representation of a "mod" file
|
|
|
|
class ModFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ModFile();
|
|
|
|
~ModFile();
|
|
|
|
//! Symbol table
|
|
|
|
SymbolTable symbol_table;
|
2010-02-22 17:33:38 +01:00
|
|
|
//! External Functions table
|
|
|
|
ExternalFunctionsTable external_functions_table;
|
2008-02-03 11:28:36 +01:00
|
|
|
//! Numerical constants table
|
|
|
|
NumericalConstants num_constants;
|
|
|
|
//! Expressions outside model block
|
|
|
|
DataTree expressions_tree;
|
2010-04-23 18:39:07 +02:00
|
|
|
//! Dynamic model, as declared in the "model" block
|
2009-04-14 16:39:53 +02:00
|
|
|
DynamicModel dynamic_model;
|
2010-04-23 18:39:07 +02:00
|
|
|
//! Static model, as derived from the "model" block when leads and lags have been removed
|
|
|
|
StaticModel static_model;
|
2010-04-27 17:04:52 +02:00
|
|
|
//! Static model, as declared in the "steady_state_model" block if present
|
|
|
|
SteadyStateModel steady_state_model;
|
2008-02-03 11:28:36 +01:00
|
|
|
//! Option linear
|
|
|
|
bool linear;
|
2009-08-29 17:04:11 +02:00
|
|
|
|
|
|
|
//! Is the model block decomposed?
|
|
|
|
bool block;
|
|
|
|
|
2009-12-09 12:50:58 +01:00
|
|
|
//! Is the model stored in bytecode format (byte_code=true) or in a M-file (byte_code=false)
|
2009-08-29 17:04:11 +02:00
|
|
|
bool byte_code;
|
|
|
|
|
2009-12-09 12:50:58 +01:00
|
|
|
//! Is the model stored in a MEX file ? (option "use_dll" of "model")
|
2009-09-02 15:36:56 +02:00
|
|
|
bool use_dll;
|
2009-08-29 17:04:11 +02:00
|
|
|
|
2010-01-08 12:06:25 +01:00
|
|
|
//! Is the static model have to computed (no_static=false) or not (no_static=true). Option of 'model'
|
|
|
|
bool no_static;
|
|
|
|
|
2008-02-03 11:28:36 +01:00
|
|
|
//! Global evaluation context
|
|
|
|
/*! Filled using initval blocks and parameters initializations */
|
|
|
|
eval_context_type global_eval_context;
|
|
|
|
|
|
|
|
private:
|
|
|
|
//! List of statements
|
|
|
|
vector<Statement *> statements;
|
|
|
|
//! Structure of the mod file
|
|
|
|
ModFileStructure mod_file_struct;
|
|
|
|
|
|
|
|
public:
|
|
|
|
//! Add a statement
|
|
|
|
void addStatement(Statement *st);
|
2008-12-19 11:24:31 +01:00
|
|
|
//! Evaluate all the statements
|
2009-11-06 19:31:03 +01:00
|
|
|
/*! \param warn_uninit Should a warning be displayed for uninitialized endogenous/exogenous/parameters ? */
|
|
|
|
void evalAllExpressions(bool warn_uninit);
|
2008-02-03 11:28:36 +01:00
|
|
|
//! Do some checking and fills mod_file_struct
|
2008-09-29 12:16:13 +02:00
|
|
|
/*! \todo add check for number of equations and endogenous if ramsey_policy is present */
|
2008-02-03 11:28:36 +01:00
|
|
|
void checkPass();
|
2009-09-30 17:10:31 +02:00
|
|
|
//! Perform some transformations on the model (creation of auxiliary vars and equations)
|
|
|
|
void transformPass();
|
2008-02-03 11:28:36 +01:00
|
|
|
//! Execute computations
|
2008-10-29 16:10:51 +01:00
|
|
|
/*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
|
|
|
void computingPass(bool no_tmp_terms);
|
2009-04-14 16:39:53 +02:00
|
|
|
//! Writes Matlab/Octave output files
|
2008-02-03 11:28:36 +01:00
|
|
|
/*!
|
|
|
|
\param basename The base name used for writing output files. Should be the name of the mod file without its extension
|
|
|
|
\param clear_all Should a "clear all" instruction be written to output ?
|
2009-12-11 15:46:21 +01:00
|
|
|
\param msvc Should the MEX command of use_dll be adapted for MSVC?
|
2008-02-03 11:28:36 +01:00
|
|
|
*/
|
2009-12-11 15:46:21 +01:00
|
|
|
void writeOutputFiles(const string &basename, bool clear_all
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN32__)
|
2009-12-16 18:13:23 +01:00
|
|
|
, bool cygwin, bool msvc
|
2009-12-11 15:46:21 +01:00
|
|
|
#endif
|
2009-12-16 18:13:23 +01:00
|
|
|
) const;
|
2008-02-03 11:28:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! MOD_FILE_HH
|