diff --git a/src/CodeInterpreter.hh b/src/CodeInterpreter.hh index fdd93d26..70a87ff0 100644 --- a/src/CodeInterpreter.hh +++ b/src/CodeInterpreter.hh @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2020 Dynare Team + * Copyright © 2007-2021 Dynare Team * * This file is part of Dynare. * @@ -19,7 +19,6 @@ #ifndef _CODEINTERPRETER_HH #define _CODEINTERPRETER_HH -//#define DEBUGL #include #include @@ -44,7 +43,7 @@ const double near_zero{1e-12}; * \enum Tags * \brief The differents flags of the bytecode */ -enum Tags +enum class Tags { FLDZ, //!< Stores zero in the stack - 0 (0) FLDC, //!< Stores a constant term in the stack - 1 (1) @@ -146,7 +145,7 @@ enum class SymbolType excludedVariable = 19 //!< Type to use when an equation is excluded via include/exclude_eqs and the LHS variable is not used elsewhere in the model }; -enum ExpressionType +enum class ExpressionType { TemporaryTerm, ModelEquation, @@ -258,7 +257,7 @@ protected: uint8_t op_code; public: inline explicit - TagWithoutArgument(uint8_t op_code_arg) : op_code{op_code_arg} + TagWithoutArgument(Tags op_code_arg) : op_code{static_cast(op_code_arg)} { }; inline void @@ -277,11 +276,12 @@ protected: T1 arg1; public: inline explicit - TagWithOneArgument(uint8_t op_code_arg) : op_code{op_code_arg} + TagWithOneArgument(Tags op_code_arg) : op_code{static_cast(op_code_arg)} { }; inline - TagWithOneArgument(uint8_t op_code_arg, T1 arg_arg1) : op_code{op_code_arg}, arg1{arg_arg1} + TagWithOneArgument(Tags op_code_arg, T1 arg_arg1) : op_code{static_cast(op_code_arg)}, + arg1{arg_arg1} { }; inline void @@ -301,11 +301,12 @@ protected: T2 arg2; public: inline explicit - TagWithTwoArguments(uint8_t op_code_arg) : op_code{op_code_arg} + TagWithTwoArguments(Tags op_code_arg) : op_code{static_cast(op_code_arg)} { }; inline - TagWithTwoArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2) : op_code{op_code_arg}, arg1{arg_arg1}, arg2{arg_arg2} + TagWithTwoArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2) : + op_code{static_cast(op_code_arg)}, arg1{arg_arg1}, arg2{arg_arg2} { }; inline void @@ -326,11 +327,12 @@ protected: T3 arg3; public: inline explicit - TagWithThreeArguments(uint8_t op_code_arg) : op_code{op_code_arg} + TagWithThreeArguments(Tags op_code_arg) : op_code{static_cast(op_code_arg)} { }; inline - TagWithThreeArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) : op_code{op_code_arg}, arg1{arg_arg1}, arg2{arg_arg2}, arg3{arg_arg3} + TagWithThreeArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) : + op_code{static_cast(op_code_arg)}, arg1{arg_arg1}, arg2{arg_arg2}, arg3{arg_arg3} { }; inline void @@ -352,11 +354,13 @@ protected: T4 arg4; public: inline explicit - TagWithFourArguments(uint8_t op_code_arg) : op_code{op_code_arg} + TagWithFourArguments(Tags op_code_arg) : op_code{static_cast(op_code_arg)} { }; inline - TagWithFourArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) : op_code{op_code_arg}, arg1{arg_arg1}, arg2{arg_arg2}, arg3{move(arg_arg3)}, arg4{arg_arg4} + TagWithFourArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) : + op_code{static_cast(op_code_arg)}, arg1{arg_arg1}, arg2{arg_arg2}, + arg3{move(arg_arg3)}, arg4{arg_arg4} { }; inline void @@ -371,7 +375,7 @@ class FLDZ_ : public TagWithoutArgument { public: inline - FLDZ_() : TagWithoutArgument{FLDZ} + FLDZ_() : TagWithoutArgument{Tags::FLDZ} { }; }; @@ -380,7 +384,7 @@ class FEND_ : public TagWithoutArgument { public: inline - FEND_() : TagWithoutArgument{FEND} + FEND_() : TagWithoutArgument{Tags::FEND} { }; }; @@ -389,7 +393,7 @@ class FENDBLOCK_ : public TagWithoutArgument { public: inline - FENDBLOCK_() : TagWithoutArgument{FENDBLOCK} + FENDBLOCK_() : TagWithoutArgument{Tags::FENDBLOCK} { }; }; @@ -398,7 +402,7 @@ class FENDEQU_ : public TagWithoutArgument { public: inline - FENDEQU_() : TagWithoutArgument{FENDEQU} + FENDEQU_() : TagWithoutArgument{Tags::FENDEQU} { }; }; @@ -407,7 +411,7 @@ class FCUML_ : public TagWithoutArgument { public: inline - FCUML_() : TagWithoutArgument{FCUML} + FCUML_() : TagWithoutArgument{Tags::FCUML} { }; }; @@ -416,7 +420,7 @@ class FPUSH_ : public TagWithoutArgument { public: inline - FPUSH_() : TagWithoutArgument{FPUSH} + FPUSH_() : TagWithoutArgument{Tags::FPUSH} { }; }; @@ -425,7 +429,7 @@ class FPOP_ : public TagWithoutArgument { public: inline - FPOP_() : TagWithoutArgument{FPOP} + FPOP_() : TagWithoutArgument{Tags::FPOP} { }; }; @@ -434,11 +438,11 @@ class FDIMT_ : public TagWithOneArgument { public: inline - FDIMT_() : TagWithOneArgument::TagWithOneArgument{FDIMT} + FDIMT_() : TagWithOneArgument::TagWithOneArgument{Tags::FDIMT} { }; inline explicit - FDIMT_(unsigned int size_arg) : TagWithOneArgument::TagWithOneArgument{FDIMT, size_arg} + FDIMT_(unsigned int size_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FDIMT, size_arg} { }; inline unsigned int @@ -452,11 +456,11 @@ class FDIMST_ : public TagWithOneArgument { public: inline - FDIMST_() : TagWithOneArgument::TagWithOneArgument{FDIMST} + FDIMST_() : TagWithOneArgument::TagWithOneArgument{Tags::FDIMST} { }; inline explicit - FDIMST_(const unsigned int size_arg) : TagWithOneArgument::TagWithOneArgument{FDIMST, size_arg} + FDIMST_(const unsigned int size_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FDIMST, size_arg} { }; inline unsigned int @@ -470,11 +474,11 @@ class FLDC_ : public TagWithOneArgument { public: inline - FLDC_() : TagWithOneArgument::TagWithOneArgument{FLDC} + FLDC_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDC} { }; inline explicit - FLDC_(double value_arg) : TagWithOneArgument::TagWithOneArgument{FLDC, value_arg} + FLDC_(double value_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDC, value_arg} { }; inline double @@ -488,11 +492,11 @@ class FLDU_ : public TagWithOneArgument { public: inline - FLDU_() : TagWithOneArgument::TagWithOneArgument{FLDU} + FLDU_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDU} { }; inline explicit - FLDU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FLDU, pos_arg} + FLDU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDU, pos_arg} { }; inline unsigned int @@ -506,11 +510,11 @@ class FLDSU_ : public TagWithOneArgument { public: inline - FLDSU_() : TagWithOneArgument::TagWithOneArgument{FLDSU} + FLDSU_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDSU} { }; inline explicit - FLDSU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FLDSU, pos_arg} + FLDSU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDSU, pos_arg} { }; inline unsigned int @@ -524,11 +528,11 @@ class FLDR_ : public TagWithOneArgument { public: inline - FLDR_() : TagWithOneArgument::TagWithOneArgument{FLDR} + FLDR_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDR} { }; inline explicit - FLDR_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FLDR, pos_arg} + FLDR_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDR, pos_arg} { }; inline unsigned int @@ -542,11 +546,11 @@ class FLDT_ : public TagWithOneArgument { public: inline - FLDT_() : TagWithOneArgument::TagWithOneArgument{FLDT} + FLDT_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDT} { }; inline explicit - FLDT_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FLDT, pos_arg} + FLDT_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDT, pos_arg} { }; inline unsigned int @@ -560,11 +564,11 @@ class FLDST_ : public TagWithOneArgument { public: inline - FLDST_() : TagWithOneArgument::TagWithOneArgument{FLDST} + FLDST_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDST} { }; inline explicit - FLDST_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FLDST, pos_arg} + FLDST_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FLDST, pos_arg} { }; inline unsigned int @@ -578,11 +582,11 @@ class FSTPT_ : public TagWithOneArgument { public: inline - FSTPT_() : TagWithOneArgument::TagWithOneArgument{FSTPT} + FSTPT_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPT} { }; inline explicit - FSTPT_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPT, pos_arg} + FSTPT_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPT, pos_arg} { }; inline unsigned int @@ -596,11 +600,11 @@ class FSTPST_ : public TagWithOneArgument { public: inline - FSTPST_() : TagWithOneArgument::TagWithOneArgument{FSTPST} + FSTPST_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPST} { }; inline explicit - FSTPST_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPST, pos_arg} + FSTPST_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPST, pos_arg} { }; inline unsigned int @@ -614,11 +618,11 @@ class FSTPR_ : public TagWithOneArgument { public: inline - FSTPR_() : TagWithOneArgument::TagWithOneArgument{FSTPR} + FSTPR_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPR} { }; inline explicit - FSTPR_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPR, pos_arg} + FSTPR_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPR, pos_arg} { }; inline unsigned int @@ -632,11 +636,11 @@ class FSTPU_ : public TagWithOneArgument { public: inline - FSTPU_() : TagWithOneArgument::TagWithOneArgument{FSTPU} + FSTPU_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPU} { }; inline explicit - FSTPU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPU, pos_arg} + FSTPU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPU, pos_arg} { }; inline unsigned int @@ -650,11 +654,11 @@ class FSTPSU_ : public TagWithOneArgument { public: inline - FSTPSU_() : TagWithOneArgument::TagWithOneArgument{FSTPSU} + FSTPSU_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPSU} { }; inline explicit - FSTPSU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPSU, pos_arg} + FSTPSU_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPSU, pos_arg} { }; inline unsigned int @@ -668,11 +672,11 @@ class FSTPG_ : public TagWithOneArgument { public: inline - FSTPG_() : TagWithOneArgument::TagWithOneArgument{FSTPG, 0} + FSTPG_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPG, 0} { }; inline explicit - FSTPG_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{FSTPG, pos_arg} + FSTPG_(unsigned int pos_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPG, pos_arg} { }; inline unsigned int @@ -686,11 +690,11 @@ class FSTPG2_ : public TagWithTwoArguments { public: inline - FSTPG2_() : TagWithTwoArguments::TagWithTwoArguments{FSTPG2, 0, 0} + FSTPG2_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPG2, 0, 0} { }; inline - FSTPG2_(unsigned int pos_arg1, unsigned int pos_arg2) : TagWithTwoArguments::TagWithTwoArguments{FSTPG2, pos_arg1, pos_arg2} + FSTPG2_(unsigned int pos_arg1, unsigned int pos_arg2) : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPG2, pos_arg1, pos_arg2} { }; inline unsigned int @@ -709,11 +713,11 @@ class FSTPG3_ : public TagWithFourArguments::TagWithFourArguments{FSTPG3, 0, 0, 0, 0} + FSTPG3_() : TagWithFourArguments::TagWithFourArguments{Tags::FSTPG3, 0, 0, 0, 0} { }; inline - FSTPG3_(unsigned int pos_arg1, unsigned int pos_arg2, int pos_arg3, unsigned int pos_arg4) : TagWithFourArguments::TagWithFourArguments{FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4} + FSTPG3_(unsigned int pos_arg1, unsigned int pos_arg2, int pos_arg3, unsigned int pos_arg4) : TagWithFourArguments::TagWithFourArguments{Tags::FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4} { }; inline unsigned int @@ -742,11 +746,11 @@ class FUNARY_ : public TagWithOneArgument { public: inline - FUNARY_() : TagWithOneArgument::TagWithOneArgument{FUNARY} + FUNARY_() : TagWithOneArgument::TagWithOneArgument{Tags::FUNARY} { }; inline explicit - FUNARY_(uint8_t op_type_arg) : TagWithOneArgument::TagWithOneArgument{FUNARY, op_type_arg} + FUNARY_(uint8_t op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FUNARY, op_type_arg} { }; inline uint8_t @@ -760,11 +764,11 @@ class FBINARY_ : public TagWithOneArgument { public: inline - FBINARY_() : TagWithOneArgument::TagWithOneArgument{FBINARY} + FBINARY_() : TagWithOneArgument::TagWithOneArgument{Tags::FBINARY} { }; inline explicit - FBINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{FBINARY, static_cast(op_type_arg)} + FBINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FBINARY, static_cast(op_type_arg)} { }; inline uint8_t @@ -778,11 +782,11 @@ class FTRINARY_ : public TagWithOneArgument { public: inline - FTRINARY_() : TagWithOneArgument::TagWithOneArgument{FTRINARY} + FTRINARY_() : TagWithOneArgument::TagWithOneArgument{Tags::FTRINARY} { }; inline explicit - FTRINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{FTRINARY, static_cast(op_type_arg)} + FTRINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FTRINARY, static_cast(op_type_arg)} { }; inline uint8_t @@ -796,11 +800,11 @@ class FOK_ : public TagWithOneArgument { public: inline - FOK_() : TagWithOneArgument::TagWithOneArgument{FOK} + FOK_() : TagWithOneArgument::TagWithOneArgument{Tags::FOK} { }; inline explicit - FOK_(int arg_arg) : TagWithOneArgument::TagWithOneArgument{FOK, arg_arg} + FOK_(int arg_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FOK, arg_arg} { }; inline int @@ -814,11 +818,11 @@ class FJMPIFEVAL_ : public TagWithOneArgument { public: inline - FJMPIFEVAL_() : TagWithOneArgument::TagWithOneArgument{FJMPIFEVAL} + FJMPIFEVAL_() : TagWithOneArgument::TagWithOneArgument{Tags::FJMPIFEVAL} { }; inline explicit - FJMPIFEVAL_(unsigned int arg_pos) : TagWithOneArgument::TagWithOneArgument{FJMPIFEVAL, arg_pos} + FJMPIFEVAL_(unsigned int arg_pos) : TagWithOneArgument::TagWithOneArgument{Tags::FJMPIFEVAL, arg_pos} { }; inline unsigned int @@ -832,11 +836,11 @@ class FJMP_ : public TagWithOneArgument { public: inline - FJMP_() : TagWithOneArgument::TagWithOneArgument{FJMP} + FJMP_() : TagWithOneArgument::TagWithOneArgument{Tags::FJMP} { }; inline explicit - FJMP_(unsigned int arg_pos) : TagWithOneArgument::TagWithOneArgument{FJMP, arg_pos} + FJMP_(unsigned int arg_pos) : TagWithOneArgument::TagWithOneArgument{Tags::FJMP, arg_pos} { }; inline unsigned int @@ -850,11 +854,11 @@ class FLDTEF_ : public TagWithOneArgument { public: inline - FLDTEF_() : TagWithOneArgument::TagWithOneArgument{FLDTEF} + FLDTEF_() : TagWithOneArgument::TagWithOneArgument{Tags::FLDTEF} { }; inline explicit - FLDTEF_(unsigned int number) : TagWithOneArgument::TagWithOneArgument{FLDTEF, number} + FLDTEF_(unsigned int number) : TagWithOneArgument::TagWithOneArgument{Tags::FLDTEF, number} { }; inline unsigned int @@ -868,11 +872,11 @@ class FSTPTEF_ : public TagWithOneArgument { public: inline - FSTPTEF_() : TagWithOneArgument::TagWithOneArgument{FSTPTEF} + FSTPTEF_() : TagWithOneArgument::TagWithOneArgument{Tags::FSTPTEF} { }; inline explicit - FSTPTEF_(unsigned int number) : TagWithOneArgument::TagWithOneArgument{FSTPTEF, number} + FSTPTEF_(unsigned int number) : TagWithOneArgument::TagWithOneArgument{Tags::FSTPTEF, number} { }; inline unsigned int @@ -886,11 +890,11 @@ class FLDTEFD_ : public TagWithTwoArguments { public: inline - FLDTEFD_() : TagWithTwoArguments::TagWithTwoArguments{FLDTEFD} + FLDTEFD_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDTEFD} { }; inline - FLDTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments::TagWithTwoArguments{FLDTEFD, indx, row} + FLDTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDTEFD, indx, row} { }; inline unsigned int @@ -909,11 +913,11 @@ class FSTPTEFD_ : public TagWithTwoArguments { public: inline - FSTPTEFD_() : TagWithTwoArguments::TagWithTwoArguments{FSTPTEFD} + FSTPTEFD_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPTEFD} { }; inline - FSTPTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments::TagWithTwoArguments{FSTPTEFD, indx, row} + FSTPTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPTEFD, indx, row} { }; inline unsigned int @@ -932,11 +936,11 @@ class FLDTEFDD_ : public TagWithThreeArguments::TagWithThreeArguments{FLDTEFDD} + FLDTEFDD_() : TagWithThreeArguments::TagWithThreeArguments{Tags::FLDTEFDD} { }; inline - FLDTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments::TagWithThreeArguments{FLDTEFDD, indx, row, col} + FLDTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments::TagWithThreeArguments{Tags::FLDTEFDD, indx, row, col} { }; inline unsigned int @@ -960,11 +964,11 @@ class FSTPTEFDD_ : public TagWithThreeArguments::TagWithThreeArguments{FSTPTEFDD} + FSTPTEFDD_() : TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPTEFDD} { }; inline - FSTPTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments::TagWithThreeArguments{FSTPTEF, indx, row, col} + FSTPTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPTEF, indx, row, col} { }; inline unsigned int @@ -988,11 +992,11 @@ class FLDVS_ : public TagWithTwoArguments { public: inline - FLDVS_() : TagWithTwoArguments::TagWithTwoArguments{FLDVS} + FLDVS_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDVS} { }; inline - FLDVS_(uint8_t type_arg, unsigned int pos_arg) : TagWithTwoArguments::TagWithTwoArguments{FLDVS, type_arg, pos_arg} + FLDVS_(uint8_t type_arg, unsigned int pos_arg) : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDVS, type_arg, pos_arg} { }; inline uint8_t @@ -1011,12 +1015,12 @@ class FLDSV_ : public TagWithTwoArguments { public: inline - FLDSV_() : TagWithTwoArguments::TagWithTwoArguments{FLDSV} + FLDSV_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDSV} { }; inline FLDSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments::TagWithTwoArguments{FLDSV, type_arg, pos_arg} + TagWithTwoArguments::TagWithTwoArguments{Tags::FLDSV, type_arg, pos_arg} { }; inline uint8_t @@ -1035,12 +1039,12 @@ class FSTPSV_ : public TagWithTwoArguments { public: inline - FSTPSV_() : TagWithTwoArguments::TagWithTwoArguments{FSTPSV} + FSTPSV_() : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPSV} { }; inline FSTPSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments::TagWithTwoArguments{FSTPSV, type_arg, pos_arg} + TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPSV, type_arg, pos_arg} { }; inline uint8_t @@ -1059,17 +1063,17 @@ class FLDV_ : public TagWithThreeArguments { public: inline - FLDV_() : TagWithThreeArguments::TagWithThreeArguments{FLDV} + FLDV_() : TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV} { }; inline FLDV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments::TagWithThreeArguments{FLDV, static_cast(type_arg), pos_arg, 0} + TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV, static_cast(type_arg), pos_arg, 0} { }; inline FLDV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) : - TagWithThreeArguments::TagWithThreeArguments{FLDV, static_cast(type_arg), pos_arg, lead_lag_arg} + TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV, static_cast(type_arg), pos_arg, lead_lag_arg} { }; inline uint8_t @@ -1093,17 +1097,17 @@ class FSTPV_ : public TagWithThreeArguments { public: inline - FSTPV_() : TagWithThreeArguments::TagWithThreeArguments{FSTPV} + FSTPV_() : TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV} { }; inline FSTPV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments::TagWithThreeArguments{FSTPV, static_cast(type_arg), pos_arg, 0} + TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV, static_cast(type_arg), pos_arg, 0} { }; inline FSTPV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) : - TagWithThreeArguments::TagWithThreeArguments{FSTPV, static_cast(type_arg), pos_arg, lead_lag_arg} + TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV, static_cast(type_arg), pos_arg, lead_lag_arg} { }; inline uint8_t @@ -1131,7 +1135,7 @@ class FCALL_ : public TagWithFourArguments::TagWithFourArguments{FCALL}, + FCALL_() : TagWithFourArguments::TagWithFourArguments{Tags::FCALL}, add_input_arguments{0}, row{0}, col{0}, @@ -1140,7 +1144,7 @@ public: }; inline FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) : - TagWithFourArguments::TagWithFourArguments{FCALL, nb_output_arguments, nb_input_arguments, f_name, indx}, + TagWithFourArguments::TagWithFourArguments{Tags::FCALL, nb_output_arguments, nb_input_arguments, f_name, indx}, func_name{f_name}, add_input_arguments{0}, row{0}, @@ -1245,7 +1249,7 @@ public: inline uint8_t * load(uint8_t *code) { - op_code = FCALL; code += sizeof(op_code); + op_code = static_cast(Tags::FCALL); code += sizeof(op_code); memcpy(&arg1, code, sizeof(arg1)); code += sizeof(arg1); memcpy(&arg2, code, sizeof(arg2)); code += sizeof(arg2); memcpy(&arg4, code, sizeof(arg4)); code += sizeof(arg4); @@ -1279,12 +1283,12 @@ private: int8_t lag1, lag2, lag3; public: inline - FNUMEXPR_() : TagWithOneArgument::TagWithOneArgument{FNUMEXPR} + FNUMEXPR_() : TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR} { }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{0}, dvariable2{0}, dvariable3{0}, lag1{0}, lag2{0}, lag3{0} @@ -1292,7 +1296,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{0}, dvariable3{0}, lag1{0}, lag2{0}, lag3{0} @@ -1300,7 +1304,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{0}, dvariable3{0}, lag1{static_cast(lag1_arg)}, lag2{0}, lag3{0} @@ -1308,7 +1312,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{static_cast(dvariable2_arg)}, @@ -1318,7 +1322,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{static_cast(dvariable2_arg)}, @@ -1330,7 +1334,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg, unsigned int dvariable3_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{static_cast(dvariable2_arg)}, @@ -1340,7 +1344,7 @@ public: }; inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg, unsigned int dvariable3_arg, int lag3_arg) : - TagWithOneArgument::TagWithOneArgument{FNUMEXPR, expression_type}, + TagWithOneArgument::TagWithOneArgument{Tags::FNUMEXPR, expression_type}, equation{equation_arg}, dvariable1{static_cast(dvariable1_arg)}, dvariable2{static_cast(dvariable2_arg)}, @@ -1401,7 +1405,7 @@ public: class FBEGINBLOCK_ { private: - uint8_t op_code{FBEGINBLOCK}; + uint8_t op_code{static_cast(Tags::FBEGINBLOCK)}; int size; uint8_t type; vector variable; @@ -1601,7 +1605,7 @@ public: inline uint8_t * load(uint8_t *code) { - op_code = FBEGINBLOCK; code += sizeof(op_code); + op_code = static_cast(Tags::FBEGINBLOCK); code += sizeof(op_code); memcpy(&size, code, sizeof(size)); code += sizeof(size); memcpy(&type, code, sizeof(type)); code += sizeof(type); for (int i = 0; i < size; i++) @@ -1701,227 +1705,227 @@ public: int instruction = 0; while (!done) { - switch (*code) + switch (static_cast(*code)) { - case FLDZ: + case Tags::FLDZ: # ifdef DEBUGL - mexPrintf("FLDZ = %d size = %d\n", FLDZ, sizeof(FLDZ_)); + mexPrintf("FLDZ = %d size = %d\n", Tags::FLDZ, sizeof(FLDZ_)); # endif - tags_liste.emplace_back(FLDZ, code); + tags_liste.emplace_back(Tags::FLDZ, code); code += sizeof(FLDZ_); break; - case FEND: + case Tags::FEND: # ifdef DEBUGL mexPrintf("FEND\n"); # endif - tags_liste.emplace_back(FEND, code); + tags_liste.emplace_back(Tags::FEND, code); code += sizeof(FEND_); done = true; break; - case FENDBLOCK: + case Tags::FENDBLOCK: # ifdef DEBUGL mexPrintf("FENDBLOCK\n"); # endif - tags_liste.emplace_back(FENDBLOCK, code); + tags_liste.emplace_back(Tags::FENDBLOCK, code); code += sizeof(FENDBLOCK_); break; - case FENDEQU: + case Tags::FENDEQU: # ifdef DEBUGL mexPrintf("FENDEQU\n"); # endif - tags_liste.emplace_back(FENDEQU, code); + tags_liste.emplace_back(Tags::FENDEQU, code); code += sizeof(FENDEQU_); break; - case FCUML: + case Tags::FCUML: # ifdef DEBUGL mexPrintf("FCUML\n"); # endif - tags_liste.emplace_back(FCUML, code); + tags_liste.emplace_back(Tags::FCUML, code); code += sizeof(FCUML_); break; - case FDIMT: + case Tags::FDIMT: # ifdef DEBUGL - mexPrintf("FDIMT = %d size = %d\n", FDIMT, sizeof(FDIMT_)); + mexPrintf("FDIMT = %d size = %d\n", Tags::FDIMT, sizeof(FDIMT_)); # endif - tags_liste.emplace_back(FDIMT, code); + tags_liste.emplace_back(Tags::FDIMT, code); code += sizeof(FDIMT_); break; - case FDIMST: + case Tags::FDIMST: # ifdef DEBUGL mexPrintf("FDIMST\n"); # endif - tags_liste.emplace_back(FDIMST, code); + tags_liste.emplace_back(Tags::FDIMST, code); code += sizeof(FDIMST_); break; - case FNUMEXPR: + case Tags::FNUMEXPR: # ifdef DEBUGL mexPrintf("FNUMEXPR\n"); # endif - tags_liste.emplace_back(FNUMEXPR, code); + tags_liste.emplace_back(Tags::FNUMEXPR, code); code += sizeof(FNUMEXPR_); break; - case FLDC: + case Tags::FLDC: # ifdef DEBUGL mexPrintf("FLDC\n"); # endif - tags_liste.emplace_back(FLDC, code); + tags_liste.emplace_back(Tags::FLDC, code); code += sizeof(FLDC_); break; - case FLDU: + case Tags::FLDU: # ifdef DEBUGL mexPrintf("FLDU\n"); # endif - tags_liste.emplace_back(FLDU, code); + tags_liste.emplace_back(Tags::FLDU, code); code += sizeof(FLDU_); break; - case FLDSU: + case Tags::FLDSU: # ifdef DEBUGL mexPrintf("FLDSU\n"); # endif - tags_liste.emplace_back(FLDSU, code); + tags_liste.emplace_back(Tags::FLDSU, code); code += sizeof(FLDSU_); break; - case FLDR: + case Tags::FLDR: # ifdef DEBUGL mexPrintf("FLDR\n"); # endif - tags_liste.emplace_back(FLDR, code); + tags_liste.emplace_back(Tags::FLDR, code); code += sizeof(FLDR_); break; - case FLDT: + case Tags::FLDT: # ifdef DEBUGL mexPrintf("FLDT\n"); # endif - tags_liste.emplace_back(FLDT, code); + tags_liste.emplace_back(Tags::FLDT, code); code += sizeof(FLDT_); break; - case FLDST: + case Tags::FLDST: # ifdef DEBUGL mexPrintf("FLDST\n"); # endif - tags_liste.emplace_back(FLDST, code); + tags_liste.emplace_back(Tags::FLDST, code); code += sizeof(FLDST_); break; - case FSTPT: + case Tags::FSTPT: # ifdef DEBUGL - mexPrintf("FSTPT = %d size = %d\n", FSTPT, sizeof(FSTPT_)); + mexPrintf("FSTPT = %d size = %d\n", Tags::FSTPT, sizeof(FSTPT_)); # endif - tags_liste.emplace_back(FSTPT, code); + tags_liste.emplace_back(Tags::FSTPT, code); code += sizeof(FSTPT_); break; - case FSTPST: + case Tags::FSTPST: # ifdef DEBUGL mexPrintf("FSTPST\n"); # endif - tags_liste.emplace_back(FSTPST, code); + tags_liste.emplace_back(Tags::FSTPST, code); code += sizeof(FSTPST_); break; - case FSTPR: + case Tags::FSTPR: # ifdef DEBUGL mexPrintf("FSTPR\n"); # endif - tags_liste.emplace_back(FSTPR, code); + tags_liste.emplace_back(Tags::FSTPR, code); code += sizeof(FSTPR_); break; - case FSTPU: + case Tags::FSTPU: # ifdef DEBUGL mexPrintf("FSTPU\n"); # endif - tags_liste.emplace_back(FSTPU, code); + tags_liste.emplace_back(Tags::FSTPU, code); code += sizeof(FSTPU_); break; - case FSTPSU: + case Tags::FSTPSU: # ifdef DEBUGL mexPrintf("FSTPSU\n"); # endif - tags_liste.emplace_back(FSTPSU, code); + tags_liste.emplace_back(Tags::FSTPSU, code); code += sizeof(FSTPSU_); break; - case FSTPG: + case Tags::FSTPG: # ifdef DEBUGL mexPrintf("FSTPG\n"); # endif - tags_liste.emplace_back(FSTPG, code); + tags_liste.emplace_back(Tags::FSTPG, code); code += sizeof(FSTPG_); break; - case FSTPG2: + case Tags::FSTPG2: # ifdef DEBUGL mexPrintf("FSTPG2\n"); # endif - tags_liste.emplace_back(FSTPG2, code); + tags_liste.emplace_back(Tags::FSTPG2, code); code += sizeof(FSTPG2_); break; - case FSTPG3: + case Tags::FSTPG3: # ifdef DEBUGL mexPrintf("FSTPG3\n"); # endif - tags_liste.emplace_back(FSTPG3, code); + tags_liste.emplace_back(Tags::FSTPG3, code); code += sizeof(FSTPG3_); break; - case FUNARY: + case Tags::FUNARY: # ifdef DEBUGL mexPrintf("FUNARY\n"); # endif - tags_liste.emplace_back(FUNARY, code); + tags_liste.emplace_back(Tags::FUNARY, code); code += sizeof(FUNARY_); break; - case FBINARY: + case Tags::FBINARY: # ifdef DEBUGL mexPrintf("FBINARY\n"); # endif - tags_liste.emplace_back(FBINARY, code); + tags_liste.emplace_back(Tags::FBINARY, code); code += sizeof(FBINARY_); break; - case FTRINARY: + case Tags::FTRINARY: # ifdef DEBUGL mexPrintf("FTRINARY\n"); # endif - tags_liste.emplace_back(FTRINARY, code); + tags_liste.emplace_back(Tags::FTRINARY, code); code += sizeof(FTRINARY_); break; - case FOK: + case Tags::FOK: # ifdef DEBUGL mexPrintf("FOK\n"); # endif - tags_liste.emplace_back(FOK, code); + tags_liste.emplace_back(Tags::FOK, code); code += sizeof(FOK_); break; - case FLDVS: + case Tags::FLDVS: # ifdef DEBUGL mexPrintf("FLDVS\n"); # endif - tags_liste.emplace_back(FLDVS, code); + tags_liste.emplace_back(Tags::FLDVS, code); code += sizeof(FLDVS_); break; - case FLDSV: + case Tags::FLDSV: # ifdef DEBUGL mexPrintf("FLDSV\n"); # endif - tags_liste.emplace_back(FLDSV, code); + tags_liste.emplace_back(Tags::FLDSV, code); code += sizeof(FLDSV_); break; - case FSTPSV: + case Tags::FSTPSV: # ifdef DEBUGL mexPrintf("FSTPSV\n"); # endif - tags_liste.emplace_back(FSTPSV, code); + tags_liste.emplace_back(Tags::FSTPSV, code); code += sizeof(FSTPSV_); break; - case FLDV: + case Tags::FLDV: # ifdef DEBUGL mexPrintf("FLDV\n"); # endif - tags_liste.emplace_back(FLDV, code); + tags_liste.emplace_back(Tags::FLDV, code); code += sizeof(FLDV_); break; - case FSTPV: + case Tags::FSTPV: # ifdef DEBUGL mexPrintf("FSTPV\n"); # endif - tags_liste.emplace_back(FSTPV, code); + tags_liste.emplace_back(Tags::FSTPV, code); code += sizeof(FSTPV_); break; - case FBEGINBLOCK: + case Tags::FBEGINBLOCK: # ifdef DEBUGL mexPrintf("FBEGINBLOCK\n"); # endif @@ -1931,25 +1935,25 @@ public: code = fbegin_block->load(code); begin_block.push_back(tags_liste.size()); - tags_liste.emplace_back(FBEGINBLOCK, fbegin_block); + tags_liste.emplace_back(Tags::FBEGINBLOCK, fbegin_block); nb_blocks++; } break; - case FJMPIFEVAL: + case Tags::FJMPIFEVAL: # ifdef DEBUGL mexPrintf("FJMPIFEVAL\n"); # endif - tags_liste.emplace_back(FJMPIFEVAL, code); + tags_liste.emplace_back(Tags::FJMPIFEVAL, code); code += sizeof(FJMPIFEVAL_); break; - case FJMP: + case Tags::FJMP: # ifdef DEBUGL mexPrintf("FJMP\n"); # endif - tags_liste.emplace_back(FJMP, code); + tags_liste.emplace_back(Tags::FJMP, code); code += sizeof(FJMP_); break; - case FCALL: + case Tags::FCALL: { # ifdef DEBUGL mexPrintf("FCALL\n"); @@ -1958,67 +1962,67 @@ public: code = fcall->load(code); - tags_liste.emplace_back(FCALL, fcall); + tags_liste.emplace_back(Tags::FCALL, fcall); # ifdef DEBUGL mexPrintf("FCALL finish\n"); mexEvalString("drawnow;"); mexPrintf("-- *code=%d\n", *code); mexEvalString("drawnow;"); # endif } break; - case FPUSH: + case Tags::FPUSH: # ifdef DEBUGL mexPrintf("FPUSH\n"); # endif - tags_liste.emplace_back(FPUSH, code); + tags_liste.emplace_back(Tags::FPUSH, code); code += sizeof(FPUSH_); break; - case FPOP: + case Tags::FPOP: # ifdef DEBUGL mexPrintf("FPOP\n"); # endif - tags_liste.emplace_back(FPOP, code); + tags_liste.emplace_back(Tags::FPOP, code); code += sizeof(FPOP_); break; - case FLDTEF: + case Tags::FLDTEF: # ifdef DEBUGL mexPrintf("FLDTEF\n"); # endif - tags_liste.emplace_back(FLDTEF, code); + tags_liste.emplace_back(Tags::FLDTEF, code); code += sizeof(FLDTEF_); break; - case FSTPTEF: + case Tags::FSTPTEF: # ifdef DEBUGL mexPrintf("FSTPTEF\n"); # endif - tags_liste.emplace_back(FSTPTEF, code); + tags_liste.emplace_back(Tags::FSTPTEF, code); code += sizeof(FSTPTEF_); break; - case FLDTEFD: + case Tags::FLDTEFD: # ifdef DEBUGL mexPrintf("FLDTEFD\n"); # endif - tags_liste.emplace_back(FLDTEFD, code); + tags_liste.emplace_back(Tags::FLDTEFD, code); code += sizeof(FLDTEFD_); break; - case FSTPTEFD: + case Tags::FSTPTEFD: # ifdef DEBUGL mexPrintf("FSTPTEFD\n"); # endif - tags_liste.emplace_back(FSTPTEFD, code); + tags_liste.emplace_back(Tags::FSTPTEFD, code); code += sizeof(FSTPTEFD_); break; - case FLDTEFDD: + case Tags::FLDTEFDD: # ifdef DEBUGL mexPrintf("FLDTEFDD\n"); # endif - tags_liste.emplace_back(FLDTEFDD, code); + tags_liste.emplace_back(Tags::FLDTEFDD, code); code += sizeof(FLDTEFDD_); break; - case FSTPTEFDD: + case Tags::FSTPTEFDD: # ifdef DEBUGL mexPrintf("FSTPTEFDD\n"); # endif - tags_liste.emplace_back(FSTPTEFDD, code); + tags_liste.emplace_back(Tags::FSTPTEFDD, code); code += sizeof(FSTPTEFDD_); break; default: diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 3582a97a..39e7935e 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -927,7 +927,7 @@ DynamicModel::writeDynamicBytecode(const string &basename) const int symb = getSymbIDByDerivID(deriv_id); int var = symbol_table.getTypeSpecificID(symb); int lag = getLagByDerivID(deriv_id); - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eq, var, lag); fnumexpr.write(code_file, instruction_number); if (!my_derivatives[eq].size()) my_derivatives[eq].clear(); @@ -986,7 +986,7 @@ DynamicModel::writeDynamicBytecode(const string &basename) const { auto [lag, var, eq] = it.first; expr_t d1 = it.second; - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eq, var, lag); fnumexpr.write(code_file, instruction_number); if (prev_var != var || prev_lag != lag) { @@ -1005,7 +1005,7 @@ DynamicModel::writeDynamicBytecode(const string &basename) const { auto [lag, ignore, var, eq] = it.first; expr_t d1 = it.second; - FNUMEXPR_ fnumexpr(FirstExoDerivative, eq, var, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstExoDerivative, eq, var, lag); fnumexpr.write(code_file, instruction_number); if (prev_var != var || prev_lag != lag) { @@ -1130,7 +1130,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const if (dynamic_cast(it)) it->compileExternalFunctionOutput(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false, tef_terms); - FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast(blocks_temporary_terms_idxs.at(it))); + FNUMEXPR_ fnumexpr(ExpressionType::TemporaryTerm, static_cast(blocks_temporary_terms_idxs.at(it))); fnumexpr.write(code_file, instruction_number); it->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false, tef_terms); FSTPT_ fstpt(static_cast(blocks_temporary_terms_idxs.at(it))); @@ -1161,7 +1161,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const case BlockSimulationType::evaluateForward: equ_type = getBlockEquationType(block, i); { - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); } if (equ_type == EquationType::evaluate) @@ -1194,7 +1194,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const goto end; default: end: - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); eq_node = getBlockEquationExpr(block, i); lhs = eq_node->arg1; @@ -1228,7 +1228,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const case BlockSimulationType::solveBackwardSimple: case BlockSimulationType::solveForwardSimple: { - FNUMEXPR_ fnumexpr(FirstEndoDerivative, getBlockEquationID(block, 0), getBlockVariableID(block, 0), 0); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, getBlockEquationID(block, 0), getBlockVariableID(block, 0), 0); fnumexpr.write(code_file, instruction_number); } compileDerivative(code_file, instruction_number, getBlockEquationID(block, 0), getBlockVariableID(block, 0), 0, temporary_terms_union, blocks_temporary_terms_idxs); @@ -1268,7 +1268,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const Uf[eqr].Ufl->u = count_u; Uf[eqr].Ufl->var = varr; Uf[eqr].Ufl->lag = lag; - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eqr, varr, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); compileChainRuleDerivative(code_file, instruction_number, block, eq, var, lag, temporary_terms_union, blocks_temporary_terms_idxs); FSTPU_ fstpu(count_u); @@ -1337,7 +1337,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const auto [eq, var, lag] = indices; int eqr = getBlockEquationID(block, eq); int varr = getBlockVariableID(block, var); - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eqr, varr, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); compileDerivative(code_file, instruction_number, eqr, varr, lag, temporary_terms_union, blocks_temporary_terms_idxs); FSTPG3_ fstpg3(eq, var, lag, blocks_jacob_cols_endo[block].at({ var, lag })); @@ -1348,7 +1348,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const auto [eqr, var, lag] = indices; int eq = getBlockEquationID(block, eqr); int varr = 0; // Dummy value, actually unused by the bytecode MEX - FNUMEXPR_ fnumexpr(FirstExoDerivative, eqr, varr, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstExoDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); d->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false); FSTPG3_ fstpg3(eq, var, lag, blocks_jacob_cols_exo[block].at({ var, lag })); @@ -1359,7 +1359,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const auto [eqr, var, lag] = indices; int eq = getBlockEquationID(block, eqr); int varr = 0; // Dummy value, actually unused by the bytecode MEX - FNUMEXPR_ fnumexpr(FirstExodetDerivative, eqr, varr, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstExodetDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); d->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false); FSTPG3_ fstpg3(eq, var, lag, blocks_jacob_cols_exo_det[block].at({ var, lag })); @@ -1370,7 +1370,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const auto [eqr, var, lag] = indices; int eq = getBlockEquationID(block, eqr); int varr = 0; // Dummy value, actually unused by the bytecode MEX - FNUMEXPR_ fnumexpr(FirstOtherEndoDerivative, eqr, varr, lag); + FNUMEXPR_ fnumexpr(ExpressionType::FirstOtherEndoDerivative, eqr, varr, lag); fnumexpr.write(code_file, instruction_number); d->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false); FSTPG3_ fstpg3(eq, var, lag, blocks_jacob_cols_other_endo[block].at({ var, lag })); diff --git a/src/ModelTree.cc b/src/ModelTree.cc index 487d871c..4bcbcb24 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1263,7 +1263,7 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n if (dynamic_cast(tt)) tt->compileExternalFunctionOutput(code_file, instruction_number, false, temporary_terms_union, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); - FNUMEXPR_ fnumexpr(TemporaryTerm, idx); + FNUMEXPR_ fnumexpr(ExpressionType::TemporaryTerm, idx); fnumexpr.write(code_file, instruction_number); tt->compile(code_file, instruction_number, false, temporary_terms_union, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); if (dynamic) @@ -1399,7 +1399,7 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n BinaryOpNode *eq_node = equations[eq]; expr_t lhs = eq_node->arg1; expr_t rhs = eq_node->arg2; - FNUMEXPR_ fnumexpr(ModelEquation, eq); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, eq); fnumexpr.write(code_file, instruction_number); // Test if the right hand side of the equation is empty. double vrhs = 1.0; diff --git a/src/StaticModel.cc b/src/StaticModel.cc index b21bbff5..10649466 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2003-2020 Dynare Team + * Copyright © 2003-2021 Dynare Team * * This file is part of Dynare. * @@ -442,7 +442,7 @@ StaticModel::writeStaticBytecode(const string &basename) const int eq = indices[0]; int symb = getSymbIDByDerivID(deriv_id); int var = symbol_table.getTypeSpecificID(symb); - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eq, var); fnumexpr.write(code_file, instruction_number); if (!my_derivatives[eq].size()) my_derivatives[eq].clear(); @@ -504,7 +504,7 @@ StaticModel::writeStaticBytecode(const string &basename) const int eq = indices[0]; int symb = getSymbIDByDerivID(deriv_id); int var = symbol_table.getTypeSpecificID(symb); - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eq, var); fnumexpr.write(code_file, instruction_number); if (!my_derivatives[eq].size()) my_derivatives[eq].clear(); @@ -628,7 +628,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const if (dynamic_cast(it)) it->compileExternalFunctionOutput(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); - FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast(blocks_temporary_terms_idxs.at(it))); + FNUMEXPR_ fnumexpr(ExpressionType::TemporaryTerm, static_cast(blocks_temporary_terms_idxs.at(it))); fnumexpr.write(code_file, instruction_number); it->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); FSTPST_ fstpst(static_cast(blocks_temporary_terms_idxs.at(it))); @@ -651,7 +651,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const case BlockSimulationType::evaluateForward: equ_type = getBlockEquationType(block, i); { - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); } if (equ_type == EquationType::evaluate) @@ -682,7 +682,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const goto end; default: end: - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); eq_node = getBlockEquationExpr(block, i); lhs = eq_node->arg1; @@ -712,7 +712,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const case BlockSimulationType::solveBackwardSimple: case BlockSimulationType::solveForwardSimple: { - FNUMEXPR_ fnumexpr(FirstEndoDerivative, 0, 0); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, 0, 0); fnumexpr.write(code_file, instruction_number); } compileDerivative(code_file, instruction_number, getBlockEquationID(block, 0), getBlockVariableID(block, 0), temporary_terms_union, blocks_temporary_terms_idxs); @@ -745,7 +745,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const Uf[eqr].Ufl->pNext = nullptr; Uf[eqr].Ufl->u = count_u; Uf[eqr].Ufl->var = varr; - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eqr, varr); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eqr, varr); fnumexpr.write(code_file, instruction_number); compileChainRuleDerivative(code_file, instruction_number, block, eq, var, 0, temporary_terms_union, blocks_temporary_terms_idxs); FSTPSU_ fstpsu(count_u); @@ -827,7 +827,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const case BlockSimulationType::evaluateForward: equ_type = getBlockEquationType(block, i); { - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); } if (equ_type == EquationType::evaluate) @@ -858,7 +858,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const goto end_l; default: end_l: - FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i)); + FNUMEXPR_ fnumexpr(ExpressionType::ModelEquation, getBlockEquationID(block, i)); fnumexpr.write(code_file, instruction_number); eq_node = getBlockEquationExpr(block, i); lhs = eq_node->arg1; @@ -886,7 +886,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const case BlockSimulationType::solveBackwardSimple: case BlockSimulationType::solveForwardSimple: { - FNUMEXPR_ fnumexpr(FirstEndoDerivative, 0, 0); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, 0, 0); fnumexpr.write(code_file, instruction_number); } compileDerivative(code_file, instruction_number, getBlockEquationID(block, 0), getBlockVariableID(block, 0), temporary_terms_union, blocks_temporary_terms_idxs); @@ -905,7 +905,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const auto &[eq, var, ignore] = indices; int eqr = getBlockEquationID(block, eq); int varr = getBlockVariableID(block, var); - FNUMEXPR_ fnumexpr(FirstEndoDerivative, eqr, varr, 0); + FNUMEXPR_ fnumexpr(ExpressionType::FirstEndoDerivative, eqr, varr, 0); fnumexpr.write(code_file, instruction_number); compileChainRuleDerivative(code_file, instruction_number, block, eq, var, 0, temporary_terms_union, blocks_temporary_terms_idxs);