diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh index f9e2489d5..49e9b4a66 100644 --- a/mex/sources/bytecode/ErrorHandling.hh +++ b/mex/sources/bytecode/ErrorHandling.hh @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2020 Dynare Team + * Copyright © 2007-2021 Dynare Team * * This file is part of Dynare. * @@ -490,43 +490,43 @@ public: if (!steady_state) switch (EQN_type) { - case TemporaryTerm: + case ExpressionType::TemporaryTerm: if (EQN_block_number > 1) Error_loc << "temporary term " << EQN_equation+1 << " in block " << EQN_block+1 << " at time " << it_; else Error_loc << "temporary term " << EQN_equation+1 << " at time " << it_; break; - case ModelEquation: + case ExpressionType::ModelEquation: if (EQN_block_number > 1) Error_loc << "equation " << EQN_equation+1 << " in block " << EQN_block+1 << " at time " << it_; else Error_loc << "equation " << EQN_equation+1 << " at time " << it_; break; - case FirstEndoDerivative: + case ExpressionType::FirstEndoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; break; - case FirstOtherEndoDerivative: + case ExpressionType::FirstOtherEndoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to other endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to other endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; break; - case FirstExoDerivative: + case ExpressionType::FirstExoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; break; - case FirstExodetDerivative: + case ExpressionType::FirstExodetDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to deterministic exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to deterministic exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; break; - case FirstParamDerivative: + case ExpressionType::FirstParamDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to parameter " << get_variable(SymbolType::endogenous, EQN_dvar1) << " at time " << it_; else @@ -538,43 +538,43 @@ public: else switch (EQN_type) { - case TemporaryTerm: + case ExpressionType::TemporaryTerm: if (EQN_block_number > 1) Error_loc << "temporary term " << EQN_equation+1 << " in block " << EQN_block+1; else Error_loc << "temporary term " << EQN_equation+1; break; - case ModelEquation: + case ExpressionType::ModelEquation: if (EQN_block_number > 1) Error_loc << "equation " << EQN_equation+1 << " in block " << EQN_block+1; else Error_loc << "equation " << EQN_equation+1; break; - case FirstEndoDerivative: + case ExpressionType::FirstEndoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); break; - case FirstOtherEndoDerivative: + case ExpressionType::FirstOtherEndoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to other endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to other endogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); break; - case FirstExoDerivative: + case ExpressionType::FirstExoDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); break; - case FirstExodetDerivative: + case ExpressionType::FirstExodetDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to deterministic exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); else Error_loc << "first order derivative of equation " << EQN_equation+1 << " with respect to deterministic exogenous variable " << get_variable(SymbolType::endogenous, EQN_dvar1); break; - case FirstParamDerivative: + case ExpressionType::FirstParamDerivative: if (EQN_block_number > 1) Error_loc << "first order derivative of equation " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to parameter " << get_variable(SymbolType::endogenous, EQN_dvar1); else @@ -599,7 +599,7 @@ public: double v1f, v2f, v3f = 0.0; bool go_on = true; double ll; - ExpressionType equation_type = TemporaryTerm; + ExpressionType equation_type = ExpressionType::TemporaryTerm; size_t found; double *jacob = NULL, *jacob_other_endo = NULL, *jacob_exo = NULL, *jacob_exo_det = NULL; ExternalFunctionType function_type = ExternalFunctionType::withoutDerivative; @@ -623,61 +623,61 @@ public: #endif switch (it_code->first) { - case FNUMEXPR: + case Tags::FNUMEXPR: switch (static_cast(it_code->second)->get_expression_type()) { - case TemporaryTerm: - equation_type = TemporaryTerm; + case ExpressionType::TemporaryTerm: + equation_type = ExpressionType::TemporaryTerm; break; - case ModelEquation: - equation_type = ModelEquation; + case ExpressionType::ModelEquation: + equation_type = ExpressionType::ModelEquation; break; - case FirstEndoDerivative: - equation_type = FirstEndoDerivative; + case ExpressionType::FirstEndoDerivative: + equation_type = ExpressionType::FirstEndoDerivative; break; - case FirstOtherEndoDerivative: - equation_type = FirstOtherEndoDerivative; + case ExpressionType::FirstOtherEndoDerivative: + equation_type = ExpressionType::FirstOtherEndoDerivative; break; - case FirstExoDerivative: - equation_type = FirstExoDerivative; + case ExpressionType::FirstExoDerivative: + equation_type = ExpressionType::FirstExoDerivative; break; - case FirstExodetDerivative: - equation_type = FirstExodetDerivative; + case ExpressionType::FirstExodetDerivative: + equation_type = ExpressionType::FirstExodetDerivative; break; - case FirstParamDerivative: - equation_type = FirstParamDerivative; + case ExpressionType::FirstParamDerivative: + equation_type = ExpressionType::FirstParamDerivative; break; - case SecondEndoDerivative: - equation_type = SecondEndoDerivative; + case ExpressionType::SecondEndoDerivative: + equation_type = ExpressionType::SecondEndoDerivative; break; - case SecondExoDerivative: - equation_type = SecondExoDerivative; + case ExpressionType::SecondExoDerivative: + equation_type = ExpressionType::SecondExoDerivative; break; - case SecondExodetDerivative: - equation_type = SecondExodetDerivative; + case ExpressionType::SecondExodetDerivative: + equation_type = ExpressionType::SecondExodetDerivative; break; - case SecondParamDerivative: - equation_type = SecondExodetDerivative; + case ExpressionType::SecondParamDerivative: + equation_type = ExpressionType::SecondExodetDerivative; break; - case ThirdEndoDerivative: - equation_type = ThirdEndoDerivative; + case ExpressionType::ThirdEndoDerivative: + equation_type = ExpressionType::ThirdEndoDerivative; break; - case ThirdExoDerivative: - equation_type = ThirdExoDerivative; + case ExpressionType::ThirdExoDerivative: + equation_type = ExpressionType::ThirdExoDerivative; break; - case ThirdExodetDerivative: - equation_type = ThirdExodetDerivative; + case ExpressionType::ThirdExodetDerivative: + equation_type = ExpressionType::ThirdExodetDerivative; break; - case ThirdParamDerivative: - equation_type = ThirdExodetDerivative; + case ExpressionType::ThirdParamDerivative: + equation_type = ExpressionType::ThirdExodetDerivative; break; default: ostringstream tmp; - tmp << " in print_expression, expression type " << static_cast(it_code->second)->get_expression_type() << " not implemented yet\n"; + tmp << " in print_expression, expression type " << static_cast(static_cast(it_code->second)->get_expression_type()) << " not implemented yet\n"; throw FatalExceptionHandling(tmp.str()); } break; - case FLDV: + case Tags::FLDV: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -753,8 +753,8 @@ public: mexPrintf("FLDV: Unknown variable type\n"); } break; - case FLDSV: - case FLDVS: + case Tags::FLDSV: + case Tags::FLDVS: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -775,7 +775,7 @@ public: Stack.push(get_variable(SymbolType::endogenous, var)); if (compute) { - if (it_code->first == FLDSV) + if (it_code->first == Tags::FLDSV) { if (evaluate) Stackf.push(ya[var]); @@ -813,7 +813,7 @@ public: mexPrintf("FLDSV: Unknown variable type\n"); } break; - case FLDT: + case Tags::FLDT: //load a temporary variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -825,7 +825,7 @@ public: if (compute) Stackf.push(T[var*(periods+y_kmin+y_kmax)+it_]); break; - case FLDST: + case Tags::FLDST: //load a temporary variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -837,7 +837,7 @@ public: if (compute) Stackf.push(T[var]); break; - case FLDU: + case Tags::FLDU: //load u variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -850,7 +850,7 @@ public: if (compute) Stackf.push(u[var]); break; - case FLDSU: + case Tags::FLDSU: //load u variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -862,7 +862,7 @@ public: if (compute) Stackf.push(u[var]); break; - case FLDR: + case Tags::FLDR: var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG mexPrintf("FLDSR_ var=%d", var); @@ -873,7 +873,7 @@ public: if (compute) Stackf.push(r[var]); break; - case FLDZ: + case Tags::FLDZ: //load 0 in the processor #ifdef DEBUG mexPrintf("FLDZ_"); @@ -884,7 +884,7 @@ public: if (compute) Stackf.push(0.0); break; - case FLDC: + case Tags::FLDC: //load a numerical constant in the processor ll = static_cast(it_code->second)->get_value(); tmp_out.str(""); @@ -896,7 +896,7 @@ public: if (compute) Stackf.push(ll); break; - case FSTPV: + case Tags::FSTPV: //load a variable in the processor go_on = false; switch (static_cast(static_cast(it_code->second)->get_type())) @@ -983,7 +983,7 @@ public: mexPrintf("FSTPV: Unknown variable type\n"); } break; - case FSTPSV: + case Tags::FSTPSV: go_on = false; //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) @@ -1044,7 +1044,7 @@ public: mexPrintf("FSTPSV: Unknown variable type\n"); } break; - case FSTPT: + case Tags::FSTPT: go_on = false; //store in a temporary variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1060,7 +1060,7 @@ public: Stackf.pop(); } break; - case FSTPST: + case Tags::FSTPST: go_on = false; //store in a temporary variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1076,7 +1076,7 @@ public: Stackf.pop(); } break; - case FSTPU: + case Tags::FSTPU: go_on = false; //store in u variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1093,7 +1093,7 @@ public: Stackf.pop(); } break; - case FSTPSU: + case Tags::FSTPSU: go_on = false; //store in u variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1109,7 +1109,7 @@ public: Stackf.pop(); } break; - case FSTPR: + case Tags::FSTPR: go_on = false; //store in residual variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1125,7 +1125,7 @@ public: Stackf.pop(); } break; - case FSTPG: + case Tags::FSTPG: go_on = false; //store in derivative (g) variable from the processor var = static_cast(it_code->second)->get_pos(); @@ -1141,7 +1141,7 @@ public: Stackf.pop(); } break; - case FSTPG2: + case Tags::FSTPG2: go_on = false; //store in derivative (g) variable from the processor eq = static_cast(it_code->second)->get_row(); @@ -1158,7 +1158,7 @@ public: Stackf.pop(); } break; - case FSTPG3: + case Tags::FSTPG3: //store in derivative (g) variable from the processor #ifdef DEBUG mexPrintf("FSTPG3\n"); @@ -1178,7 +1178,7 @@ public: pos_col = static_cast(it_code->second)->get_col_pos(); switch (equation_type) { - case FirstEndoDerivative: + case ExpressionType::FirstEndoDerivative: #ifdef DEBUG mexPrintf("Endo eq=%d, pos_col=%d, size=%d\n", eq, pos_col, size); #endif @@ -1188,14 +1188,14 @@ public: tmp_out << "/*jacob(" << eq << ", " << pos_col << " var= " << var << ")*/ jacob(" << eq+size*pos_col+1 << ") = " << Stack.top(); Stack.pop(); break; - case FirstOtherEndoDerivative: + case ExpressionType::FirstOtherEndoDerivative: if (compute) jacob_other_endo[eq + size*pos_col] = r; tmp_out.str(""); tmp_out << "jacob_other_endo(" << eq+size*pos_col+1 << ") = " << Stack.top(); Stack.pop(); break; - case FirstExoDerivative: + case ExpressionType::FirstExoDerivative: #ifdef DEBUG mexPrintf("Exo eq=%d, pos_col=%d, size=%d\n", eq, pos_col, size); #endif @@ -1205,7 +1205,7 @@ public: tmp_out << "/*jacob_exo(" << eq << ", " << pos_col << " var=" << var << ")*/ jacob_exo(" << eq+size*pos_col+1 << ") = " << Stack.top(); Stack.pop(); break; - case FirstExodetDerivative: + case ExpressionType::FirstExodetDerivative: if (compute) jacob_exo_det[eq + size*pos_col] = r; tmp_out.str(""); @@ -1214,7 +1214,7 @@ public: break; default: ostringstream tmp; - tmp << " in compute_block_time, variable " << EQN_type << " not used yet\n"; + tmp << " in compute_block_time, variable " << static_cast(EQN_type) << " not used yet\n"; //throw FatalExceptionHandling(tmp.str()); mexPrintf("%s", tmp.str().c_str()); } @@ -1224,7 +1224,7 @@ public: tmp_out.str(""); #endif break; - case FBINARY: + case Tags::FBINARY: op = static_cast(it_code->second)->get_op_type(); v2 = Stack.top(); Stack.pop(); @@ -1559,7 +1559,7 @@ public: ; } break; - case FUNARY: + case Tags::FUNARY: op = static_cast(it_code->second)->get_op_type(); v1 = Stack.top(); Stack.pop(); @@ -1723,7 +1723,7 @@ public: ; } break; - case FTRINARY: + case Tags::FTRINARY: op = static_cast(it_code->second)->get_op_type(); v3 = Stack.top(); Stack.pop(); @@ -1760,7 +1760,7 @@ public: mexPrintf("Error unknown Trinary operator=%d\n", op); mexEvalString("drawnow;"); } break; - case FCALL: + case Tags::FCALL: { #ifdef DEBUG mexPrintf("------------------------------\n"); @@ -2010,7 +2010,7 @@ public: #endif break; } - case FSTPTEF: + case Tags::FSTPTEF: go_on = false; var = static_cast(it_code->second)->get_number(); #ifdef DEBUG @@ -2047,7 +2047,7 @@ public: mexEvalString("drawnow;"); #endif break; - case FLDTEF: + case Tags::FLDTEF: var = static_cast(it_code->second)->get_number(); #ifdef DEBUG mexPrintf("FLDTEF\n"); @@ -2072,7 +2072,7 @@ public: #endif break; - case FSTPTEFD: + case Tags::FSTPTEFD: { go_on = false; unsigned int indx = static_cast(it_code->second)->get_indx(); @@ -2098,7 +2098,7 @@ public: Stack.pop(); } break; - case FLDTEFD: + case Tags::FLDTEFD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -2119,7 +2119,7 @@ public: Stack.push(tmp_out.str()); } break; - case FSTPTEFDD: + case Tags::FSTPTEFDD: { go_on = false; unsigned int indx = static_cast(it_code->second)->get_indx(); @@ -2149,7 +2149,7 @@ public: } break; - case FLDTEFDD: + case Tags::FLDTEFDD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -2171,17 +2171,17 @@ public: Stack.push(tmp_out.str()); } break; - case FJMPIFEVAL: + case Tags::FJMPIFEVAL: tmp_out.str(""); tmp_out << "if (~evaluate)"; go_on = false; break; - case FJMP: + case Tags::FJMP: tmp_out.str(""); tmp_out << "else"; go_on = false; break; - case FCUML: + case Tags::FCUML: if (compute) { v1f = Stackf.top(); @@ -2198,16 +2198,16 @@ public: tmp_out << v1 << " + " << v2; Stack.push(tmp_out.str()); break; - case FENDBLOCK: - case FENDEQU: + case Tags::FENDBLOCK: + case Tags::FENDEQU: go_on = false; break; - case FOK: + case Tags::FOK: break; default: ostringstream tmp; mexPrintf("Error it_code->first=%d unknown\n", it_code->first); mexEvalString("drawnow;"); - tmp << " in print_expression, unknown opcode " << it_code->first << "!! FENDEQU=" << FENDEQU << "\n"; + tmp << " in print_expression, unknown opcode " << static_cast(it_code->first) << "!! FENDEQU=" << static_cast(Tags::FENDEQU) << "\n"; throw FatalExceptionHandling(tmp.str()); } it_code++; diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index 841d9365b..c9c5e39a8 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2013-2020 Dynare Team + * Copyright © 2013-2021 Dynare Team * * This file is part of Dynare. * @@ -147,121 +147,121 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif switch (it_code->first) { - case FNUMEXPR: + case Tags::FNUMEXPR: #ifdef DEBUG mexPrintf("FNUMEXPR\n"); #endif it_code_expr = it_code; switch (static_cast(it_code->second)->get_expression_type()) { - case TemporaryTerm: + case ExpressionType::TemporaryTerm: #ifdef DEBUG mexPrintf("TemporaryTerm\n"); #endif - EQN_type = TemporaryTerm; + EQN_type = ExpressionType::TemporaryTerm; EQN_equation = static_cast(it_code->second)->get_equation(); #ifdef DEBUG mexPrintf("EQN_equation=%d\n", EQN_equation); mexEvalString("drawnow;"); #endif break; - case ModelEquation: + case ExpressionType::ModelEquation: #ifdef DEBUG mexPrintf("ModelEquation\n"); #endif - EQN_type = ModelEquation; + EQN_type = ExpressionType::ModelEquation; EQN_equation = static_cast(it_code->second)->get_equation(); break; - case FirstEndoDerivative: + case ExpressionType::FirstEndoDerivative: #ifdef DEBUG mexPrintf("FirstEndoDerivative\n"); #endif - EQN_type = FirstEndoDerivative; + EQN_type = ExpressionType::FirstEndoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); break; - case FirstOtherEndoDerivative: + case ExpressionType::FirstOtherEndoDerivative: #ifdef DEBUG mexPrintf("FirstOtherEndoDerivative\n"); #endif - EQN_type = FirstOtherEndoDerivative; + EQN_type = ExpressionType::FirstOtherEndoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); break; - case FirstExoDerivative: + case ExpressionType::FirstExoDerivative: #ifdef DEBUG mexPrintf("FirstExoDerivative\n"); #endif - EQN_type = FirstExoDerivative; + EQN_type = ExpressionType::FirstExoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); break; - case FirstExodetDerivative: + case ExpressionType::FirstExodetDerivative: #ifdef DEBUG mexPrintf("FirstExodetDerivative\n"); #endif - EQN_type = FirstExodetDerivative; + EQN_type = ExpressionType::FirstExodetDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); break; - case FirstParamDerivative: + case ExpressionType::FirstParamDerivative: #ifdef DEBUG mexPrintf("FirstParamDerivative\n"); #endif - EQN_type = FirstParamDerivative; + EQN_type = ExpressionType::FirstParamDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); break; - case SecondEndoDerivative: + case ExpressionType::SecondEndoDerivative: #ifdef DEBUG mexPrintf("SecondEndoDerivative\n"); #endif - EQN_type = SecondEndoDerivative; + EQN_type = ExpressionType::SecondEndoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); EQN_dvar2 = static_cast(it_code->second)->get_dvariable2(); EQN_lag2 = static_cast(it_code->second)->get_lag2(); break; - case SecondExoDerivative: + case ExpressionType::SecondExoDerivative: #ifdef DEBUG mexPrintf("SecondExoDerivative\n"); #endif - EQN_type = SecondExoDerivative; + EQN_type = ExpressionType::SecondExoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); EQN_dvar2 = static_cast(it_code->second)->get_dvariable2(); EQN_lag2 = static_cast(it_code->second)->get_lag2(); break; - case SecondExodetDerivative: + case ExpressionType::SecondExodetDerivative: #ifdef DEBUG mexPrintf("SecondExodetDerivative\n"); #endif - EQN_type = SecondExodetDerivative; + EQN_type = ExpressionType::SecondExodetDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); EQN_dvar2 = static_cast(it_code->second)->get_dvariable2(); EQN_lag2 = static_cast(it_code->second)->get_lag2(); break; - case SecondParamDerivative: + case ExpressionType::SecondParamDerivative: #ifdef DEBUG mexPrintf("SecondParamDerivative\n"); #endif - EQN_type = SecondParamDerivative; + EQN_type = ExpressionType::SecondParamDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_dvar2 = static_cast(it_code->second)->get_dvariable2(); break; - case ThirdEndoDerivative: + case ExpressionType::ThirdEndoDerivative: #ifdef DEBUG mexPrintf("ThirdEndoDerivative\n"); #endif - EQN_type = ThirdEndoDerivative; + EQN_type = ExpressionType::ThirdEndoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); @@ -270,11 +270,11 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int EQN_dvar3 = static_cast(it_code->second)->get_dvariable3(); EQN_lag3 = static_cast(it_code->second)->get_lag3(); break; - case ThirdExoDerivative: + case ExpressionType::ThirdExoDerivative: #ifdef DEBUG mexPrintf("ThirdExoDerivative\n"); #endif - EQN_type = ThirdExoDerivative; + EQN_type = ExpressionType::ThirdExoDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); @@ -283,11 +283,11 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int EQN_dvar3 = static_cast(it_code->second)->get_dvariable3(); EQN_lag3 = static_cast(it_code->second)->get_lag3(); break; - case ThirdExodetDerivative: + case ExpressionType::ThirdExodetDerivative: #ifdef DEBUG mexPrintf("ThirdExodetDerivative\n"); #endif - EQN_type = ThirdExodetDerivative; + EQN_type = ExpressionType::ThirdExodetDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_lag1 = static_cast(it_code->second)->get_lag1(); @@ -296,11 +296,11 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int EQN_dvar3 = static_cast(it_code->second)->get_dvariable3(); EQN_lag3 = static_cast(it_code->second)->get_lag3(); break; - case ThirdParamDerivative: + case ExpressionType::ThirdParamDerivative: #ifdef DEBUG mexPrintf("ThirdParamDerivative\n"); #endif - EQN_type = ThirdParamDerivative; + EQN_type = ExpressionType::ThirdParamDerivative; EQN_equation = static_cast(it_code->second)->get_equation(); EQN_dvar1 = static_cast(it_code->second)->get_dvariable1(); EQN_dvar2 = static_cast(it_code->second)->get_dvariable2(); @@ -308,7 +308,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int break; } break; - case FLDV: + case Tags::FLDV: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -361,7 +361,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("FLDV: Unknown variable type\n"); } break; - case FLDSV: + case Tags::FLDSV: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -409,7 +409,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("FLDSV: Unknown variable type\n"); } break; - case FLDVS: + case Tags::FLDVS: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -451,7 +451,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("FLDVS: Unknown variable type\n"); } break; - case FLDT: + case Tags::FLDT: //load a temporary variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -460,7 +460,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.push(T[var*(periods+y_kmin+y_kmax)+it_]); break; - case FLDST: + case Tags::FLDST: //load a temporary variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -472,7 +472,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int tmp_out << " T[" << var << "](" << T[var] << ")"; #endif break; - case FLDU: + case Tags::FLDU: //load u variable in the processor var = static_cast(it_code->second)->get_pos(); var += Per_u_; @@ -482,7 +482,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.push(u[var]); break; - case FLDSU: + case Tags::FLDSU: //load u variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -491,7 +491,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.push(u[var]); break; - case FLDR: + case Tags::FLDR: //load u variable in the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -499,7 +499,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.push(r[var]); break; - case FLDZ: + case Tags::FLDZ: //load 0 in the processor #ifdef DEBUG mexPrintf("FLDZ\n"); @@ -509,7 +509,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int tmp_out << " 0"; #endif break; - case FLDC: + case Tags::FLDC: //load a numerical constant in the processor ll = static_cast(it_code->second)->get_value(); #ifdef DEBUG @@ -519,7 +519,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.push(ll); break; - case FSTPV: + case Tags::FSTPV: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -569,7 +569,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("FSTPV: Unknown variable type\n"); } break; - case FSTPSV: + case Tags::FSTPSV: //load a variable in the processor switch (static_cast(static_cast(it_code->second)->get_type())) { @@ -603,7 +603,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int mexPrintf("FSTPSV: Unknown variable type\n"); } break; - case FSTPT: + case Tags::FSTPT: //store in a temporary variable from the processor #ifdef DEBUG mexPrintf("FSTPT\n"); @@ -618,7 +618,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.pop(); break; - case FSTPST: + case Tags::FSTPST: //store in a temporary variable from the processor #ifdef DEBUG mexPrintf("FSTPST\n"); @@ -635,7 +635,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.pop(); break; - case FSTPU: + case Tags::FSTPU: //store in u variable from the processor var = static_cast(it_code->second)->get_pos(); var += Per_u_; @@ -651,7 +651,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.pop(); break; - case FSTPSU: + case Tags::FSTPSU: //store in u variable from the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -666,7 +666,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.pop(); break; - case FSTPR: + case Tags::FSTPR: //store in residual variable from the processor var = static_cast(it_code->second)->get_pos(); #ifdef DEBUG @@ -682,7 +682,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.pop(); break; - case FSTPG: + case Tags::FSTPG: //store in derivative (g) variable from the processor #ifdef DEBUG mexPrintf("FSTPG\n"); @@ -698,13 +698,13 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.pop(); break; - case FSTPG2: + case Tags::FSTPG2: //store in the jacobian matrix rr = Stack.top(); - if (EQN_type != FirstEndoDerivative) + if (EQN_type != ExpressionType::FirstEndoDerivative) { ostringstream tmp; - tmp << " in compute_block_time, impossible case " << EQN_type << " not implement in static jacobian\n"; + tmp << " in compute_block_time, impossible case " << static_cast(EQN_type) << " not implement in static jacobian\n"; throw FatalExceptionHandling(tmp.str()); } eq = static_cast(it_code->second)->get_row(); @@ -715,7 +715,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif jacob[eq + size*var] = rr; break; - case FSTPG3: + case Tags::FSTPG3: //store in derivative (g) variable from the processor #ifdef DEBUG mexPrintf("FSTPG3 Evaluate=%d\n", evaluate); @@ -730,7 +730,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int rr = Stack.top(); switch (EQN_type) { - case FirstEndoDerivative: + case ExpressionType::FirstEndoDerivative: eq = static_cast(it_code->second)->get_row(); var = static_cast(it_code->second)->get_col(); lag = static_cast(it_code->second)->get_lag(); @@ -741,7 +741,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif jacob[eq + size*pos_col] = rr; break; - case FirstOtherEndoDerivative: + case ExpressionType::FirstOtherEndoDerivative: //eq = static_cast(it_code->second)->get_row(); eq = EQN_equation; var = static_cast(it_code->second)->get_col(); @@ -753,7 +753,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif jacob_other_endo[eq + size*pos_col] = rr; break; - case FirstExoDerivative: + case ExpressionType::FirstExoDerivative: //eq = static_cast(it_code->second)->get_row(); eq = EQN_equation; var = static_cast(it_code->second)->get_col(); @@ -765,7 +765,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif jacob_exo[eq + size*pos_col] = rr; break; - case FirstExodetDerivative: + case ExpressionType::FirstExodetDerivative: //eq = static_cast(it_code->second)->get_row(); eq = EQN_equation; var = static_cast(it_code->second)->get_col(); @@ -780,7 +780,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int break; default: ostringstream tmp; - tmp << " in compute_block_time, variable " << EQN_type << " not used yet\n"; + tmp << " in compute_block_time, variable " << static_cast(EQN_type) << " not used yet\n"; throw FatalExceptionHandling(tmp.str()); } // #ifdef DEBUG @@ -791,7 +791,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.pop(); break; - case FBINARY: + case Tags::FBINARY: op = static_cast(it_code->second)->get_op_type(); #ifdef DEBUG mexPrintf("FBINARY, op=%d\n", op); @@ -947,7 +947,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } } break; - case FUNARY: + case Tags::FUNARY: op = static_cast(it_code->second)->get_op_type(); v1 = Stack.top(); Stack.pop(); @@ -1096,7 +1096,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } } break; - case FTRINARY: + case Tags::FTRINARY: op = static_cast(it_code->second)->get_op_type(); v3 = Stack.top(); Stack.pop(); @@ -1128,10 +1128,10 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } break; - case FPUSH: + case Tags::FPUSH: break; - case FCALL: + case Tags::FCALL: { #ifdef DEBUG mexPrintf("------------------------------\n"); @@ -1344,7 +1344,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } } break; - case FSTPTEF: + case Tags::FSTPTEF: var = static_cast(it_code->second)->get_number(); #ifdef DEBUG mexPrintf("FSTPTEF\n"); @@ -1357,7 +1357,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.pop(); break; - case FLDTEF: + case Tags::FLDTEF: var = static_cast(it_code->second)->get_number(); #ifdef DEBUG mexPrintf("FLDTEF\n"); @@ -1367,7 +1367,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int #endif Stack.push(TEF[var-1]); break; - case FSTPTEFD: + case Tags::FSTPTEFD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -1387,7 +1387,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } break; - case FLDTEFD: + case Tags::FLDTEFD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -1400,7 +1400,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.push(TEFD[make_pair(indx, row-1)]); } break; - case FSTPTEFDD: + case Tags::FSTPTEFDD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -1421,7 +1421,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int } break; - case FLDTEFDD: + case Tags::FLDTEFDD: { unsigned int indx = static_cast(it_code->second)->get_indx(); unsigned int row = static_cast(it_code->second)->get_row(); @@ -1435,28 +1435,28 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int Stack.push(TEFDD[make_pair(indx, make_pair(row-1, col-1))]); } break; - case FCUML: + case Tags::FCUML: v1 = Stack.top(); Stack.pop(); v2 = Stack.top(); Stack.pop(); Stack.push(v1+v2); break; - case FENDBLOCK: + case Tags::FENDBLOCK: //it's the block end #ifdef DEBUG mexPrintf("FENDBLOCK\n"); #endif go_on = false; break; - case FBEGINBLOCK: + case Tags::FBEGINBLOCK: mexPrintf("Impossible case in Bytecode\n"); break; - case FENDEQU: + case Tags::FENDEQU: if (no_derivative) go_on = false; break; - case FJMPIFEVAL: + case Tags::FJMPIFEVAL: if (evaluate) { #ifdef DEBUG @@ -1466,14 +1466,14 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int it_code += static_cast(it_code->second)->get_pos() /* - 1*/; } break; - case FJMP: + case Tags::FJMP: #ifdef DEBUG mexPrintf("FJMP length=%d\n", static_cast(it_code->second)->get_pos()); mexEvalString("drawnow;"); #endif it_code += static_cast(it_code->second)->get_pos() /*- 1 */; break; - case FOK: + case Tags::FOK: op = static_cast(it_code->second)->get_arg(); if (Stack.size() > 0) { @@ -1484,7 +1484,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int break; default: ostringstream tmp; - tmp << " in compute_block_time, unknown opcode " << it_code->first << "\n"; + tmp << " in compute_block_time, unknown opcode " << static_cast(it_code->first) << "\n"; throw FatalExceptionHandling(tmp.str()); } #ifdef DEBUG diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 65d275d68..bdafa8e2e 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2020 Dynare Team + * Copyright © 2007-2021 Dynare Team * * This file is part of Dynare. * @@ -551,7 +551,7 @@ Interpreter::print_a_block() bool space = false; while (go_on) { - if (it_code->first == FENDBLOCK) + if (it_code->first == Tags::FENDBLOCK) { go_on = false; it_code++; @@ -652,7 +652,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo { switch (it_code->first) { - case FBEGINBLOCK: + case Tags::FBEGINBLOCK: Block_Count++; #ifdef DEBUG mexPrintf("---------------------------------------------------------\n"); @@ -745,14 +745,14 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo } break; - case FEND: + case Tags::FEND: #ifdef DEBUG mexPrintf("FEND\n"); #endif go_on = false; it_code++; break; - case FDIMT: + case Tags::FDIMT: #ifdef DEBUG mexPrintf("FDIMT size=%d\n", static_cast(it_code->second)->get_size()); #endif @@ -768,7 +768,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo else it_code++; break; - case FDIMST: + case Tags::FDIMST: #ifdef DEBUG mexPrintf("FDIMST size=%d\n", static_cast(it_code->second)->get_size()); #endif @@ -798,7 +798,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo break; default: ostringstream tmp; - tmp << " in compute_blocks, unknown command " << it_code->first << " (block=" << Block_Count << ")\n"; + tmp << " in compute_blocks, unknown command " << static_cast(it_code->first) << " (block=" << Block_Count << ")\n"; throw FatalExceptionHandling(tmp.str()); } } diff --git a/preprocessor b/preprocessor index ce09f6620..07391e0f9 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit ce09f6620a260af855d310d664da5e85cd5f759e +Subproject commit 07391e0f9fdc8e697131cd3e292d6c9f23afd63b