diff --git a/src/Bytecode.hh b/src/Bytecode.hh index 2fb965ff..4d8c7b1a 100644 --- a/src/Bytecode.hh +++ b/src/Bytecode.hh @@ -467,39 +467,39 @@ public: }; }; -class FUNARY_ : public TagWithOneArgument +class FUNARY_ : public TagWithOneArgument { public: - explicit FUNARY_(uint8_t op_type_arg) : TagWithOneArgument::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 +class FBINARY_ : public TagWithOneArgument { public: - explicit FBINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FBINARY, static_cast(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 +class FTRINARY_ : public TagWithOneArgument { public: - explicit FTRINARY_(int op_type_arg) : TagWithOneArgument::TagWithOneArgument{Tags::FTRINARY, static_cast(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 +class FLDVS_ : public TagWithTwoArguments { public: - FLDVS_(uint8_t type_arg, unsigned int pos_arg) : TagWithTwoArguments::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 +class FLDSV_ : public TagWithTwoArguments { public: - FLDSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments::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 +class FSTPSV_ : public TagWithTwoArguments { public: - FSTPSV_(uint8_t type_arg, unsigned int pos_arg) : - TagWithTwoArguments::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 +class FLDV_ : public TagWithThreeArguments { public: - FLDV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments::TagWithThreeArguments{Tags::FLDV, static_cast(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::TagWithThreeArguments{Tags::FLDV, static_cast(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 +class FSTPV_ : public TagWithThreeArguments { public: - FSTPV_(int type_arg, unsigned int pos_arg) : - TagWithThreeArguments::TagWithThreeArguments{Tags::FSTPV, static_cast(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::TagWithThreeArguments{Tags::FSTPV, static_cast(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 variable; vector equation; vector 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(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 det_exogenous_arg, vector exogenous_arg, vector other_endogenous_arg) : BytecodeInstruction{Tags::FBEGINBLOCK}, size{static_cast(size_arg)}, - type{static_cast(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(size_arg)}, - type{static_cast(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(&variable[i]), sizeof(variable[0])); CompileCode.write(reinterpret_cast(&equation[i]), sizeof(equation[0])); } - if (type == static_cast(BlockSimulationType::solveTwoBoundariesSimple) - || type == static_cast(BlockSimulationType::solveTwoBoundariesComplete) - || type == static_cast(BlockSimulationType::solveBackwardComplete) - || type == static_cast(BlockSimulationType::solveForwardComplete)) + if (type == BlockSimulationType::solveTwoBoundariesSimple + || type == BlockSimulationType::solveTwoBoundariesComplete + || type == BlockSimulationType::solveBackwardComplete + || type == BlockSimulationType::solveForwardComplete) { CompileCode.write(reinterpret_cast(&is_linear), sizeof(is_linear)); CompileCode.write(reinterpret_cast(&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(BlockSimulationType::solveTwoBoundariesSimple) - || type == static_cast(BlockSimulationType::solveTwoBoundariesComplete) - || type == static_cast(BlockSimulationType::solveBackwardComplete) - || type == static_cast(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 9a43499f..cf43e95b 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(SymbolType::endogenous), static_cast(get<0>(*it)), get<1>(*it)}; + FLDV_ fldv{SymbolType::endogenous, static_cast(get<0>(*it)), get<1>(*it)}; fldv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); if (it != my_derivatives[i].begin()) { - FBINARY_ fbinary{static_cast(BinaryOpcode::plus)}; + FBINARY_ fbinary{BinaryOpcode::plus}; fbinary.write(code_file, instruction_number); } } - FBINARY_ fbinary{static_cast(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(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(SymbolType::endogenous), static_cast(Uf[v].Ufl->var), Uf[v].Ufl->lag}; + FLDV_ fldv{SymbolType::endogenous, static_cast(Uf[v].Ufl->var), Uf[v].Ufl->lag}; fldv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast(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(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 dfd5d069..c660ed91 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(type), static_cast(tsid)}; + FLDVS_ fldvs{type, static_cast(tsid)}; fldvs.write(CompileCode, instruction_number); } else { if (type == SymbolType::parameter) { - FLDV_ fldv{static_cast(type), static_cast(tsid)}; + FLDV_ fldv{type, static_cast(tsid)}; fldv.write(CompileCode, instruction_number); } else { - FLDV_ fldv{static_cast(type), static_cast(tsid), lag}; + FLDV_ fldv{type, static_cast(tsid), lag}; fldv.write(CompileCode, instruction_number); } } } else { - FLDSV_ fldsv{static_cast(type), static_cast(tsid)}; + FLDSV_ fldsv{type, static_cast(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(type), static_cast(tsid)}; + FSTPV_ fstpv{type, static_cast(tsid)}; fstpv.write(CompileCode, instruction_number); } else { - FSTPV_ fstpv{static_cast(type), static_cast(tsid), lag}; + FSTPV_ fstpv{type, static_cast(tsid), lag}; fstpv.write(CompileCode, instruction_number); } } } else { - FSTPSV_ fstpsv{static_cast(type), static_cast(tsid)}; + FSTPSV_ fstpsv{type, static_cast(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(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(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(op_code)}; + FTRINARY_ ftrinary{op_code}; ftrinary.write(CompileCode, instruction_number); } diff --git a/src/ModelTree.cc b/src/ModelTree.cc index fef72b7f..8b2ff1cd 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(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 652ef51d..417b5e3e 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(SymbolType::endogenous), static_cast(it.first)}; + FLDSV_ fldsv{SymbolType::endogenous, static_cast(it.first)}; fldsv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast(BinaryOpcode::times)}; + FBINARY_ fbinary{BinaryOpcode::times}; fbinary.write(code_file, instruction_number); if (exchange(printed_something, true)) { - FBINARY_ fbinary{static_cast(BinaryOpcode::plus)}; + FBINARY_ fbinary{BinaryOpcode::plus}; fbinary.write(code_file, instruction_number); } } - FBINARY_ fbinary{static_cast(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(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(SymbolType::endogenous), static_cast(Uf[v].Ufl->var)}; + FLDSV_ fldsv{SymbolType::endogenous, static_cast(Uf[v].Ufl->var)}; fldsv.write(code_file, instruction_number); - FBINARY_ fbinary{static_cast(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(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(BinaryOpcode::minus)}; + FBINARY_ fbinary{BinaryOpcode::minus}; fbinary.write(code_file, instruction_number); FSTPR_ fstpr(i - block_recursive);