From cc64a40ac74e20f37bc7806b095d081498142935 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 17 Oct 2008 10:20:19 +0000 Subject: [PATCH] trunk preprocessor: renamed "Type" to "SymbolType" for the sake of clarity git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2166 ac1d8469-bf42-47a9-8791-bf33cf982152 --- preprocessor/ComputingTasks.cc | 2 +- preprocessor/DataTree.cc | 2 +- preprocessor/ExprNode.cc | 2 +- preprocessor/NumericalInitialization.cc | 6 +++--- preprocessor/ParsingDriver.cc | 12 ++++++------ preprocessor/SymbolTable.cc | 4 ++-- preprocessor/VariableTable.cc | 2 +- preprocessor/include/CodeInterpreter.hh | 2 +- preprocessor/include/DataTree.hh | 2 +- preprocessor/include/ExprNode.hh | 6 +++--- preprocessor/include/ParsingDriver.hh | 2 +- preprocessor/include/SymbolTable.hh | 24 ++++++++++++------------ preprocessor/include/VariableTable.hh | 16 ++++++++-------- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 61edad6ab..b755a3ade 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -559,7 +559,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) for(it = trend_elements.begin(); it != trend_elements.end(); it++) { - Type type = symbol_table.getType(it->first); + SymbolType type = symbol_table.getType(it->first); if (type == eEndogenous) { output << "tmp1 = strmatch('" << it->first << "',options_.varobs,'exact');\n"; diff --git a/preprocessor/DataTree.cc b/preprocessor/DataTree.cc index e2b31be23..4579db474 100644 --- a/preprocessor/DataTree.cc +++ b/preprocessor/DataTree.cc @@ -56,7 +56,7 @@ NodeID DataTree::AddVariable(const string &name, int lag) { int symb_id = symbol_table.getID(name); - Type type = symbol_table.getType(name); + SymbolType type = symbol_table.getType(name); variable_node_map_type::iterator it = variable_node_map.find(make_pair(make_pair(symb_id, type), lag)); if (it != variable_node_map.end()) diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc index 964dd6534..98ed29252 100644 --- a/preprocessor/ExprNode.cc +++ b/preprocessor/ExprNode.cc @@ -164,7 +164,7 @@ NumConstNode::collectEndogenous(set > &result) const { } -VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, Type type_arg, int lag_arg) : +VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType type_arg, int lag_arg) : ExprNode(datatree_arg), symb_id(symb_id_arg), type(type_arg), diff --git a/preprocessor/NumericalInitialization.cc b/preprocessor/NumericalInitialization.cc index 020e4cbeb..d92a4912a 100644 --- a/preprocessor/NumericalInitialization.cc +++ b/preprocessor/NumericalInitialization.cc @@ -54,7 +54,7 @@ InitOrEndValStatement::writeInitValues(ostream &output) const const string &name = it->first; const NodeID expression = it->second; - Type type = symbol_table.getType(name); + SymbolType type = symbol_table.getType(name); int id = symbol_table.getID(name) + 1; if (type == eEndogenous) @@ -144,7 +144,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const const int &lag = it->first.second; const NodeID expression = it->second; - Type type = symbol_table.getType(name); + SymbolType type = symbol_table.getType(name); int id = symbol_table.getID(name) + 1; if (type == eEndogenous) @@ -196,7 +196,7 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename) const const NodeID expression1 = it->second.first; const NodeID expression2 = it->second.second; - const Type type = symbol_table.getType(name); + const SymbolType type = symbol_table.getType(name); const int id = symbol_table.getID(name) + 1; output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << type << ", " << id << ", "; diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 341b9b303..26bb0eda7 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -102,7 +102,7 @@ ParsingDriver::warning(const string &m) } void -ParsingDriver::declare_symbol(string *name, Type type, string *tex_name) +ParsingDriver::declare_symbol(string *name, SymbolType type, string *tex_name) { try { @@ -162,7 +162,7 @@ NodeID ParsingDriver::add_model_variable(string *name, string *olag) { check_symbol_existence(*name); - Type type = mod_file->symbol_table.getType(*name); + SymbolType type = mod_file->symbol_table.getType(*name); int lag = atoi(olag->c_str()); if (type == eModFileLocalVariable) @@ -271,7 +271,7 @@ void ParsingDriver::init_val(string *name, NodeID rhs) { check_symbol_existence(*name); - Type type = mod_file->symbol_table.getType(*name); + SymbolType type = mod_file->symbol_table.getType(*name); if (type != eEndogenous && type != eExogenous @@ -305,7 +305,7 @@ void ParsingDriver::hist_val(string *name, string *lag, NodeID rhs) { check_symbol_existence(*name); - Type type = mod_file->symbol_table.getType(*name); + SymbolType type = mod_file->symbol_table.getType(*name); if (type != eEndogenous && type != eExogenous @@ -328,7 +328,7 @@ void ParsingDriver::homotopy_val(string *name, NodeID val1, NodeID val2) { check_symbol_existence(*name); - Type type = mod_file->symbol_table.getType(*name); + SymbolType type = mod_file->symbol_table.getType(*name); if (type != eParameter && type != eExogenous @@ -430,7 +430,7 @@ void ParsingDriver::add_det_shock(string *var) { check_symbol_existence(*var); - Type type = mod_file->symbol_table.getType(*var); + SymbolType type = mod_file->symbol_table.getType(*var); if (type != eExogenous && type != eExogenousDet) error("shocks: shocks can only be applied to exogenous variables"); diff --git a/preprocessor/SymbolTable.cc b/preprocessor/SymbolTable.cc index bd3190c06..23d411db6 100644 --- a/preprocessor/SymbolTable.cc +++ b/preprocessor/SymbolTable.cc @@ -29,7 +29,7 @@ SymbolTable::SymbolTable() : endo_nbr(0), exo_nbr(0), exo_det_nbr(0), recur_nbr( } void -SymbolTable::addSymbol(const string &name, Type type, const string &tex_name) throw (AlreadyDeclaredException) +SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name) throw (AlreadyDeclaredException) { if (exists(name)) { @@ -69,7 +69,7 @@ SymbolTable::addSymbol(const string &name, Type type, const string &tex_name) th break; } - symbol_type symbol(type, id); + named_symbol_type symbol(type, id); symbol_table[name] = symbol; name_table[symbol] = name; tex_name_table[symbol] = tex_name; diff --git a/preprocessor/VariableTable.cc b/preprocessor/VariableTable.cc index e05b33558..b439dfe83 100644 --- a/preprocessor/VariableTable.cc +++ b/preprocessor/VariableTable.cc @@ -33,7 +33,7 @@ VariableTable::VariableTable(const SymbolTable &symbol_table_arg) : } int -VariableTable::addVariable(Type type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException) +VariableTable::addVariable(SymbolType type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException) { if (dyn_jacobian_cols_table.size() != 0) throw DynJacobianColsAlreadyComputedException(); diff --git a/preprocessor/include/CodeInterpreter.hh b/preprocessor/include/CodeInterpreter.hh index b6d0e528f..d698bb2d7 100644 --- a/preprocessor/include/CodeInterpreter.hh +++ b/preprocessor/include/CodeInterpreter.hh @@ -66,7 +66,7 @@ enum BlockSimulationType //! Enumeration of possible symbol types /*! Warning: do not to change existing values: the order matters for VariableTable (at least for endogenous and exogenous types), and the values matter for homotopy_setup command */ -enum Type +enum SymbolType { eEndogenous = 0, //!< Endogenous eExogenous = 1, //!< Exogenous diff --git a/preprocessor/include/DataTree.hh b/preprocessor/include/DataTree.hh index d14eccae7..3ee186794 100644 --- a/preprocessor/include/DataTree.hh +++ b/preprocessor/include/DataTree.hh @@ -62,7 +62,7 @@ protected: typedef map num_const_node_map_type; num_const_node_map_type num_const_node_map; //! Type (symbol_id, type, lag) used as key - typedef map, int>, NodeID> variable_node_map_type; + typedef map, int>, NodeID> variable_node_map_type; variable_node_map_type variable_node_map; typedef map, NodeID> unary_op_node_map_type; unary_op_node_map_type unary_op_node_map; diff --git a/preprocessor/include/ExprNode.hh b/preprocessor/include/ExprNode.hh index 2f8778219..55a2f9e12 100644 --- a/preprocessor/include/ExprNode.hh +++ b/preprocessor/include/ExprNode.hh @@ -61,7 +61,7 @@ enum ExprNodeOutputType //! Type for evaluation contexts /*! The key is a pair (symbol id, symbol type) Lags are assumed to be null */ -typedef map, double> eval_context_type; +typedef map, double> eval_context_type; /* Equal to 1 for Matlab langage, or to 0 for C language In Matlab, array indexes begin at 1, while they begin at 0 in C */ @@ -189,13 +189,13 @@ class VariableNode : public ExprNode private: //! Id from the symbol table const int symb_id; - const Type type; + const SymbolType type; const int lag; //! Id from the variable table (-1 if not a endogenous/exogenous/recursive) int var_id; virtual NodeID computeDerivative(int varID); public: - VariableNode(DataTree &datatree_arg, int symb_id_arg, Type type_arg, int lag_arg); + VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType type_arg, int lag_arg); virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms = temporary_terms_type()) const; virtual void collectEndogenous(set > &result) const; virtual double eval(const eval_context_type &eval_context) const throw (EvalException); diff --git a/preprocessor/include/ParsingDriver.hh b/preprocessor/include/ParsingDriver.hh index a4000579b..3ce2065fa 100644 --- a/preprocessor/include/ParsingDriver.hh +++ b/preprocessor/include/ParsingDriver.hh @@ -71,7 +71,7 @@ private: void check_symbol_existence(const string &name); //! Helper to add a symbol declaration - void declare_symbol(string *name, Type type, string *tex_name); + void declare_symbol(string *name, SymbolType type, string *tex_name); //! Creates option "optim_opt" in OptionsList if it doesn't exist, else add a comma, and adds the option name void optim_options_helper(const string &name); diff --git a/preprocessor/include/SymbolTable.hh b/preprocessor/include/SymbolTable.hh index 746a69419..a7e4257ac 100644 --- a/preprocessor/include/SymbolTable.hh +++ b/preprocessor/include/SymbolTable.hh @@ -41,13 +41,13 @@ class SymbolTable { private: //! A symbol is represented by a pair (type, id) - typedef pair symbol_type; + typedef pair named_symbol_type; - typedef map symbol_table_type; + typedef map symbol_table_type; //! Maps strings to pairs (type,id) symbol_table_type symbol_table; - typedef map inv_symbol_table_type; + typedef map inv_symbol_table_type; //! Maps pairs (type, id) to names inv_symbol_table_type name_table; //! Maps pairs (type, id) to TeX names @@ -67,10 +67,10 @@ public: { public: //! Symbol type - Type type; + SymbolType type; //! Symbol ID int id; - UnknownSymbolIDException(Type type_arg, int id_arg) : type(type_arg), id(id_arg) {} + UnknownSymbolIDException(SymbolType type_arg, int id_arg) : type(type_arg), id(id_arg) {} }; //! Thrown when trying to declare a symbol twice class AlreadyDeclaredException @@ -99,15 +99,15 @@ public: //! Number of unknown functions int unknown_function_nbr; //! Add a symbol - void addSymbol(const string &name, Type type, const string &tex_name = "") throw (AlreadyDeclaredException); + void addSymbol(const string &name, SymbolType type, const string &tex_name = "") throw (AlreadyDeclaredException); //! Tests if symbol already exists inline bool exists(const string &name) const; //! Get symbol name by type and ID - inline string getNameByID(Type type, int id) const throw (UnknownSymbolIDException); + inline string getNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException); //! Get TeX name by type and ID - inline string getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDException); + inline string getTeXNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException); //! Get type by name - inline Type getType(const string &name) const throw (UnknownSymbolNameException); + inline SymbolType getType(const string &name) const throw (UnknownSymbolNameException); //! Get ID by name inline int getID(const string &name) const throw (UnknownSymbolNameException); //! Write output of this class @@ -122,7 +122,7 @@ SymbolTable::exists(const string &name) const } inline string -SymbolTable::getNameByID(Type type, int id) const throw (UnknownSymbolIDException) +SymbolTable::getNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException) { inv_symbol_table_type::const_iterator iter = name_table.find(make_pair(type, id)); if (iter != name_table.end()) @@ -132,7 +132,7 @@ SymbolTable::getNameByID(Type type, int id) const throw (UnknownSymbolIDExceptio } inline string -SymbolTable::getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDException) +SymbolTable::getTeXNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException) { inv_symbol_table_type::const_iterator iter = tex_name_table.find(make_pair(type, id)); if (iter != tex_name_table.end()) @@ -141,7 +141,7 @@ SymbolTable::getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDExcep throw UnknownSymbolIDException(type, id); } -inline Type +inline SymbolType SymbolTable::getType(const string &name) const throw (UnknownSymbolNameException) { symbol_table_type::const_iterator iter = symbol_table.find(name); diff --git a/preprocessor/include/VariableTable.hh b/preprocessor/include/VariableTable.hh index 9ffb39900..50faa8038 100644 --- a/preprocessor/include/VariableTable.hh +++ b/preprocessor/include/VariableTable.hh @@ -36,7 +36,7 @@ private: const SymbolTable &symbol_table; //! A variable is a tuple (type, lag, symbol_id) /*! Warning: don't change the order of elements in the tuple, since this determines the lexicographic ordering in computeDynJacobianCols() */ - typedef pair, int> var_key_type; + typedef pair, int> var_key_type; typedef map variable_table_type; //! Maps a tuple (type, lag, symbol_id) to a variable ID @@ -81,9 +81,9 @@ public: class UnknownVariableKeyException { public: - Type type; + SymbolType type; int symb_id, lag; - UnknownVariableKeyException(Type type_arg, int symb_id_arg, int lag_arg) : type(type_arg), symb_id(symb_id_arg), lag(lag_arg) {} + UnknownVariableKeyException(SymbolType type_arg, int symb_id_arg, int lag_arg) : type(type_arg), symb_id(symb_id_arg), lag(lag_arg) {} }; //! Thrown when trying to access an unknown variable by var_id class UnknownVariableIDException @@ -103,15 +103,15 @@ public: }; //! Adds a variable in the table, and returns its (newly allocated) variable ID /*! Also works if the variable already exists */ - int addVariable(Type type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException); + int addVariable(SymbolType type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException); //! Return variable ID - inline int getID(Type type, int symb_id, int lag) const throw (UnknownVariableKeyException); + inline int getID(SymbolType type, int symb_id, int lag) const throw (UnknownVariableKeyException); //! Return lag of variable inline int getLag(int var_id) const throw (UnknownVariableIDException); //! Return symbol ID of variable inline int getSymbolID(int var_id) const throw (UnknownVariableIDException); //! Get variable type - inline Type getType(int var_id) const throw (UnknownVariableIDException); + inline SymbolType getType(int var_id) const throw (UnknownVariableIDException); //! Get number of variables inline int size() const; //! Get column index in dynamic jacobian @@ -135,7 +135,7 @@ VariableTable::getDynJacobianCol(int var_id) const throw (DynJacobianColsNotYetC } inline int -VariableTable::getID(Type type, int symb_id, int lag) const throw (UnknownVariableKeyException) +VariableTable::getID(SymbolType type, int symb_id, int lag) const throw (UnknownVariableKeyException) { variable_table_type::const_iterator it = variable_table.find(make_pair(make_pair(type, lag), symb_id)); if (it == variable_table.end()) @@ -144,7 +144,7 @@ VariableTable::getID(Type type, int symb_id, int lag) const throw (UnknownVariab return it->second; } -inline Type +inline SymbolType VariableTable::getType(int var_id) const throw (UnknownVariableIDException) { inv_variable_table_type::const_iterator it = inv_variable_table.find(var_id);