diff --git a/src/Bytecode.hh b/src/Bytecode.hh index 2fb965ff5130472ea9d00eb9aa5fade6bd083689..4d8c7b1af5d41085ca46d0754973d01f1a5cec2e 100644 --- a/src/Bytecode.hh +++ b/src/Bytecode.hh @@ -467,39 +467,39 @@ public: }; }; -class FUNARY_ : public TagWithOneArgument<uint8_t> +class FUNARY_ : public TagWithOneArgument<UnaryOpcode> { public: - explicit FUNARY_(uint8_t op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{Tags::FUNARY, op_type_arg} + explicit FUNARY_(UnaryOpcode op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FUNARY, op_type_arg} { }; - uint8_t + UnaryOpcode get_op_type() { return arg1; }; }; -class FBINARY_ : public TagWithOneArgument<uint8_t> +class FBINARY_ : public TagWithOneArgument<BinaryOpcode> { public: - explicit FBINARY_(int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{Tags::FBINARY, static_cast<uint8_t>(op_type_arg)} + explicit FBINARY_(BinaryOpcode op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FBINARY, op_type_arg} { }; - uint8_t + BinaryOpcode get_op_type() { return arg1; }; }; -class FTRINARY_ : public TagWithOneArgument<uint8_t> +class FTRINARY_ : public TagWithOneArgument<TrinaryOpcode> { public: - explicit FTRINARY_(int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{Tags::FTRINARY, static_cast<uint8_t>(op_type_arg)} + explicit FTRINARY_(TrinaryOpcode op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FTRINARY, op_type_arg} { }; - uint8_t + TrinaryOpcode get_op_type() { return arg1; @@ -640,13 +640,13 @@ public: }; }; -class FLDVS_ : public TagWithTwoArguments<uint8_t, unsigned int> +class FLDVS_ : public TagWithTwoArguments<SymbolType, unsigned int> { public: - FLDVS_(uint8_t type_arg, unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{Tags::FLDVS, type_arg, pos_arg} + FLDVS_(SymbolType type_arg, unsigned int pos_arg) : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDVS, type_arg, pos_arg} { }; - uint8_t + SymbolType get_type() { return arg1; @@ -658,14 +658,13 @@ public: }; }; -class FLDSV_ : public TagWithTwoArguments<uint8_t, unsigned int> +class FLDSV_ : public TagWithTwoArguments<SymbolType, unsigned int> { public: - FLDSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{Tags::FLDSV, type_arg, pos_arg} + FLDSV_(SymbolType type_arg, unsigned int pos_arg) : TagWithTwoArguments::TagWithTwoArguments{Tags::FLDSV, type_arg, pos_arg} { }; - uint8_t + SymbolType get_type() { return arg1; @@ -677,14 +676,13 @@ public: }; }; -class FSTPSV_ : public TagWithTwoArguments<uint8_t, unsigned int> +class FSTPSV_ : public TagWithTwoArguments<SymbolType, unsigned int> { public: - FSTPSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{Tags::FSTPSV, type_arg, pos_arg} + FSTPSV_(SymbolType type_arg, unsigned int pos_arg) : TagWithTwoArguments::TagWithTwoArguments{Tags::FSTPSV, type_arg, pos_arg} { }; - uint8_t + SymbolType get_type() { return arg1; @@ -696,18 +694,17 @@ public: }; }; -class FLDV_ : public TagWithThreeArguments<uint8_t, unsigned int, int> +class FLDV_ : public TagWithThreeArguments<SymbolType, unsigned int, int> { public: - FLDV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{Tags::FLDV, static_cast<uint8_t>(type_arg), pos_arg, 0} + FLDV_(SymbolType type_arg, unsigned int pos_arg) : TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV, type_arg, pos_arg, 0} { }; - FLDV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) : - TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{Tags::FLDV, static_cast<uint8_t>(type_arg), pos_arg, lead_lag_arg} + FLDV_(SymbolType type_arg, unsigned int pos_arg, int lead_lag_arg) : + TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV, type_arg, pos_arg, lead_lag_arg} { }; - uint8_t + SymbolType get_type() { return arg1; @@ -724,18 +721,18 @@ public: }; }; -class FSTPV_ : public TagWithThreeArguments<uint8_t, unsigned int, int> +class FSTPV_ : public TagWithThreeArguments<SymbolType, unsigned int, int> { public: - FSTPV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{Tags::FSTPV, static_cast<uint8_t>(type_arg), pos_arg, 0} + FSTPV_(SymbolType type_arg, unsigned int pos_arg) : + TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV, type_arg, pos_arg, 0} { }; - FSTPV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) : - TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{Tags::FSTPV, static_cast<uint8_t>(type_arg), pos_arg, lead_lag_arg} + FSTPV_(SymbolType type_arg, unsigned int pos_arg, int lead_lag_arg) : + TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV, type_arg, pos_arg, lead_lag_arg} { }; - uint8_t + SymbolType get_type() { return arg1; @@ -958,7 +955,7 @@ class FBEGINBLOCK_ : public BytecodeInstruction { private: int size{0}; - uint8_t type; + BlockSimulationType type; vector<int> variable; vector<int> equation; vector<int> other_endogenous; @@ -975,7 +972,7 @@ private: unsigned int nb_col_det_exo_jacob, nb_col_exo_jacob, nb_col_other_endo_jacob; public: FBEGINBLOCK_() : BytecodeInstruction{Tags::FBEGINBLOCK}, - type{static_cast<uint8_t>(BlockSimulationType::unknown)} + type{BlockSimulationType::unknown} { } FBEGINBLOCK_(unsigned int size_arg, BlockSimulationType type_arg, int unsigned first_element, int unsigned block_size, @@ -985,7 +982,7 @@ public: vector<int> det_exogenous_arg, vector<int> exogenous_arg, vector<int> other_endogenous_arg) : BytecodeInstruction{Tags::FBEGINBLOCK}, size{static_cast<int>(size_arg)}, - type{static_cast<uint8_t>(type_arg)}, + type{type_arg}, variable{variable_arg.begin()+first_element, variable_arg.begin()+(first_element+block_size)}, equation{equation_arg.begin()+first_element, equation_arg.begin()+(first_element+block_size)}, other_endogenous{move(other_endogenous_arg)}, @@ -1010,7 +1007,7 @@ public: bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg) : BytecodeInstruction{Tags::FBEGINBLOCK}, size{static_cast<int>(size_arg)}, - type{static_cast<uint8_t>(type_arg)}, + type{type_arg}, variable{variable_arg.begin()+first_element, variable_arg.begin()+(first_element+block_size)}, equation{equation_arg.begin()+first_element, equation_arg.begin()+(first_element+block_size)}, is_linear{is_linear_arg}, @@ -1032,7 +1029,7 @@ public: { return size; }; - uint8_t + BlockSimulationType get_type() { return type; @@ -1123,10 +1120,10 @@ public: CompileCode.write(reinterpret_cast<char *>(&variable[i]), sizeof(variable[0])); CompileCode.write(reinterpret_cast<char *>(&equation[i]), sizeof(equation[0])); } - if (type == static_cast<uint8_t>(BlockSimulationType::solveTwoBoundariesSimple) - || type == static_cast<uint8_t>(BlockSimulationType::solveTwoBoundariesComplete) - || type == static_cast<uint8_t>(BlockSimulationType::solveBackwardComplete) - || type == static_cast<uint8_t>(BlockSimulationType::solveForwardComplete)) + if (type == BlockSimulationType::solveTwoBoundariesSimple + || type == BlockSimulationType::solveTwoBoundariesComplete + || type == BlockSimulationType::solveBackwardComplete + || type == BlockSimulationType::solveForwardComplete) { CompileCode.write(reinterpret_cast<char *>(&is_linear), sizeof(is_linear)); CompileCode.write(reinterpret_cast<char *>(&endo_nbr), sizeof(endo_nbr)); @@ -1165,10 +1162,10 @@ public: memcpy(&bc.Equation, code, sizeof(bc.Equation)); code += sizeof(bc.Equation); Block_Contain_.push_back(bc); } - if (type == static_cast<uint8_t>(BlockSimulationType::solveTwoBoundariesSimple) - || type == static_cast<uint8_t>(BlockSimulationType::solveTwoBoundariesComplete) - || type == static_cast<uint8_t>(BlockSimulationType::solveBackwardComplete) - || type == static_cast<uint8_t>(BlockSimulationType::solveForwardComplete)) + if (type == BlockSimulationType::solveTwoBoundariesSimple + || type == BlockSimulationType::solveTwoBoundariesComplete + || type == BlockSimulationType::solveBackwardComplete + || type == BlockSimulationType::solveForwardComplete) { memcpy(&is_linear, code, sizeof(is_linear)); code += sizeof(is_linear); memcpy(&endo_nbr, code, sizeof(endo_nbr)); code += sizeof(endo_nbr); diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 9a43499f9d37f7e93d0ecaff0046139e26074206..cf43e95bca4205f464c0df081bca41ad6646d8d5 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -935,17 +935,17 @@ DynamicModel::writeDynamicBytecode(const string &basename) const { FLDU_ fldu(get<2>(*it)); fldu.write(code_file, instruction_number); - FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(get<0>(*it)), get<1>(*it)}; + FLDV_ fldv{SymbolType::endogenous, static_cast<unsigned int>(get<0>(*it)), get<1>(*it)}; fldv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); if (it != my_derivatives[i].begin()) { - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)}; + FBINARY_ fbinary{BinaryOpcode::plus}; fbinary.write(code_file, instruction_number); } } - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); } FSTPU_ fstpu(i); @@ -1181,7 +1181,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const lhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false, tef_terms); rhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, true, false, tef_terms); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPR_ fstpr(i - block_recursive); fstpr.write(code_file, instruction_number); @@ -1277,10 +1277,10 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const { FLDU_ fldu(Uf[v].Ufl->u); fldu.write(code_file, instruction_number); - FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag}; + FLDV_ fldv{SymbolType::endogenous, static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag}; fldv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); FCUML_ fcuml; @@ -1293,7 +1293,7 @@ DynamicModel::writeDynamicBlockBytecode(const string &basename) const free(Uf[v].Ufl); Uf[v].Ufl = Uf[v].Ufl_First; } - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPU_ fstpu(i - block_recursive); diff --git a/src/ExprNode.cc b/src/ExprNode.cc index dfd5d069aea6038d362bcafa7e387a1d0b7f0a31..c660ed91b1bf0ba0d519c08c3c673460e7fdec75 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -1244,26 +1244,26 @@ VariableNode::compile(ostream &CompileCode, unsigned int &instruction_number, { if (steady_dynamic) // steady state values in a dynamic model { - FLDVS_ fldvs{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)}; + FLDVS_ fldvs{type, static_cast<unsigned int>(tsid)}; fldvs.write(CompileCode, instruction_number); } else { if (type == SymbolType::parameter) { - FLDV_ fldv{static_cast<int>(type), static_cast<unsigned int>(tsid)}; + FLDV_ fldv{type, static_cast<unsigned int>(tsid)}; fldv.write(CompileCode, instruction_number); } else { - FLDV_ fldv{static_cast<int>(type), static_cast<unsigned int>(tsid), lag}; + FLDV_ fldv{type, static_cast<unsigned int>(tsid), lag}; fldv.write(CompileCode, instruction_number); } } } else { - FLDSV_ fldsv{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)}; + FLDSV_ fldsv{type, static_cast<unsigned int>(tsid)}; fldsv.write(CompileCode, instruction_number); } } @@ -1280,19 +1280,19 @@ VariableNode::compile(ostream &CompileCode, unsigned int &instruction_number, { if (type == SymbolType::parameter) { - FSTPV_ fstpv{static_cast<int>(type), static_cast<unsigned int>(tsid)}; + FSTPV_ fstpv{type, static_cast<unsigned int>(tsid)}; fstpv.write(CompileCode, instruction_number); } else { - FSTPV_ fstpv{static_cast<int>(type), static_cast<unsigned int>(tsid), lag}; + FSTPV_ fstpv{type, static_cast<unsigned int>(tsid), lag}; fstpv.write(CompileCode, instruction_number); } } } else { - FSTPSV_ fstpsv{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)}; + FSTPSV_ fstpsv{type, static_cast<unsigned int>(tsid)}; fstpsv.write(CompileCode, instruction_number); } } @@ -3036,7 +3036,7 @@ UnaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number, else { arg->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); - FUNARY_ funary{static_cast<uint8_t>(op_code)}; + FUNARY_ funary{op_code}; funary.write(CompileCode, instruction_number); } } @@ -4299,7 +4299,7 @@ BinaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number, } arg1->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); arg2->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); - FBINARY_ fbinary{static_cast<int>(op_code)}; + FBINARY_ fbinary{op_code}; fbinary.write(CompileCode, instruction_number); } @@ -5995,7 +5995,7 @@ TrinaryOpNode::compile(ostream &CompileCode, unsigned int &instruction_number, arg1->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); arg2->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); arg3->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); - FTRINARY_ ftrinary{static_cast<int>(op_code)}; + FTRINARY_ ftrinary{op_code}; ftrinary.write(CompileCode, instruction_number); } diff --git a/src/ModelTree.cc b/src/ModelTree.cc index fef72b7fae179e58bc60793625f5de0d1353e9ad..8b2ff1cde97745960b6a5b2f1b4ebb17434336d9 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1416,7 +1416,7 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n lhs->compile(code_file, instruction_number, false, temporary_terms_union, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); rhs->compile(code_file, instruction_number, false, temporary_terms_union, temporary_terms_idxs, dynamic, steady_dynamic, tef_terms); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPR_ fstpr(eq); diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 652ef51d3fb01aee5c219ffab15c8d4f9147ab0c..417b5e3e5b4afdb0f2ace27e9eb0a0464533930e 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -469,17 +469,17 @@ StaticModel::writeStaticBytecode(const string &basename) const { FLDSU_ fldsu(it.second); fldsu.write(code_file, instruction_number); - FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it.first)}; + FLDSV_ fldsv{SymbolType::endogenous, static_cast<unsigned int>(it.first)}; fldsv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); if (exchange(printed_something, true)) { - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)}; + FBINARY_ fbinary{BinaryOpcode::plus}; fbinary.write(code_file, instruction_number); } } - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); } FSTPSU_ fstpsu(i); @@ -694,7 +694,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const lhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); rhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPR_ fstpr(i - block_recursive); @@ -771,10 +771,10 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const { FLDSU_ fldsu(Uf[v].Ufl->u); fldsu.write(code_file, instruction_number); - FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var)}; + FLDSV_ fldsv{SymbolType::endogenous, static_cast<unsigned int>(Uf[v].Ufl->var)}; fldsv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); FCUML_ fcuml; @@ -787,7 +787,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const free(Uf[v].Ufl); Uf[v].Ufl = Uf[v].Ufl_First; } - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPSU_ fstpsu(i - block_recursive); @@ -868,7 +868,7 @@ StaticModel::writeStaticBlockBytecode(const string &basename) const lhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); rhs->compile(code_file, instruction_number, false, temporary_terms_union, blocks_temporary_terms_idxs, false, false, tef_terms); - FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPR_ fstpr(i - block_recursive);