C++11: convert {Unary,Binary,Trinary}Opcode to class enums

issue#70
Sébastien Villemot 2018-07-18 16:18:26 +02:00
parent 11b1fdcffd
commit 4ad0e500d4
12 changed files with 684 additions and 684 deletions

View File

@ -174,59 +174,59 @@ enum ExpressionType
ThirdParamDerivative
};
enum UnaryOpcode
enum class UnaryOpcode
{
oUminus,
oExp,
oLog,
oLog10,
oCos,
oSin,
oTan,
oAcos,
oAsin,
oAtan,
oCosh,
oSinh,
oTanh,
oAcosh,
oAsinh,
oAtanh,
oSqrt,
oAbs,
oSign,
oSteadyState,
oSteadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
oSteadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter
oExpectation,
oErf,
oDiff,
oAdl
uminus,
exp,
log,
log10,
cos,
sin,
tan,
acos,
asin,
atan,
cosh,
sinh,
tanh,
acosh,
asinh,
atanh,
sqrt,
abs,
sign,
steadyState,
steadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
steadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter
expectation,
erf,
diff,
adl
};
enum BinaryOpcode
enum class BinaryOpcode
{
oPlus,
oMinus,
oTimes,
oDivide,
oPower,
oPowerDeriv, // for the derivative of the power function (see trac ticket #78)
oEqual,
oMax,
oMin,
oLess,
oGreater,
oLessEqual,
oGreaterEqual,
oEqualEqual,
oDifferent
plus,
minus,
times,
divide,
power,
powerDeriv, // for the derivative of the power function (see trac ticket #78)
equal,
max,
min,
less,
greater,
lessEqual,
greaterEqual,
equalEqual,
different
};
enum TrinaryOpcode
enum class TrinaryOpcode
{
oNormcdf,
oNormpdf
normcdf,
normpdf
};
enum external_function_type

View File

@ -946,16 +946,16 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
output << "{" << it->endo + 1 << ", '";
switch (it->code)
{
case oLess:
case BinaryOpcode::less:
output << '<';
break;
case oGreater:
case BinaryOpcode::greater:
output << '>';
break;
case oLessEqual:
case BinaryOpcode::lessEqual:
output << "<=";
break;
case oGreaterEqual:
case BinaryOpcode::greaterEqual:
output << ">=";
break;
default:
@ -981,16 +981,16 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
output << "{\"constraint\": \"" << symbol_table.getName(it->endo) << " ";
switch (it->code)
{
case oLess:
case BinaryOpcode::less:
output << '<';
break;
case oGreater:
case BinaryOpcode::greater:
output << '>';
break;
case oLessEqual:
case BinaryOpcode::lessEqual:
output << "<=";
break;
case oGreaterEqual:
case BinaryOpcode::greaterEqual:
output << ">=";
break;
default:

View File

@ -98,7 +98,7 @@ DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
{
// Simplify x+(-y) in x-y
auto *uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
if (uarg2 != nullptr && uarg2->get_op_code() == oUminus)
if (uarg2 != nullptr && uarg2->get_op_code() == UnaryOpcode::uminus)
return AddMinus(iArg1, uarg2->get_arg());
// To treat commutativity of "+"
@ -109,7 +109,7 @@ DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
iArg1 = iArg2;
iArg2 = tmp;
}
return AddBinaryOp(iArg1, oPlus, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::plus, iArg2);
}
else if (iArg1 != Zero)
return iArg1;
@ -131,7 +131,7 @@ DataTree::AddMinus(expr_t iArg1, expr_t iArg2)
if (iArg1 == iArg2)
return Zero;
return AddBinaryOp(iArg1, oMinus, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::minus, iArg2);
}
expr_t
@ -141,10 +141,10 @@ DataTree::AddUMinus(expr_t iArg1)
{
// Simplify -(-x) in x
auto *uarg = dynamic_cast<UnaryOpNode *>(iArg1);
if (uarg != nullptr && uarg->get_op_code() == oUminus)
if (uarg != nullptr && uarg->get_op_code() == UnaryOpcode::uminus)
return uarg->get_arg();
return AddUnaryOp(oUminus, iArg1);
return AddUnaryOp(UnaryOpcode::uminus, iArg1);
}
else
return Zero;
@ -167,7 +167,7 @@ DataTree::AddTimes(expr_t iArg1, expr_t iArg2)
iArg1 = iArg2;
iArg2 = tmp;
}
return AddBinaryOp(iArg1, oTimes, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::times, iArg2);
}
else if (iArg1 != Zero && iArg1 != One && iArg2 == One)
return iArg1;
@ -198,50 +198,50 @@ DataTree::AddDivide(expr_t iArg1, expr_t iArg2) noexcept(false)
if (iArg1 == iArg2)
return One;
return AddBinaryOp(iArg1, oDivide, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::divide, iArg2);
}
expr_t
DataTree::AddLess(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oLess, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::less, iArg2);
}
expr_t
DataTree::AddGreater(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oGreater, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::greater, iArg2);
}
expr_t
DataTree::AddLessEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oLessEqual, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::lessEqual, iArg2);
}
expr_t
DataTree::AddGreaterEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oGreaterEqual, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::greaterEqual, iArg2);
}
expr_t
DataTree::AddEqualEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oEqualEqual, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::equalEqual, iArg2);
}
expr_t
DataTree::AddDifferent(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oDifferent, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::different, iArg2);
}
expr_t
DataTree::AddPower(expr_t iArg1, expr_t iArg2)
{
if (iArg1 != Zero && iArg2 != Zero && iArg1 != One && iArg2 != One)
return AddBinaryOp(iArg1, oPower, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::power, iArg2);
else if (iArg1 == One)
return One;
else if (iArg2 == One)
@ -256,26 +256,26 @@ expr_t
DataTree::AddPowerDeriv(expr_t iArg1, expr_t iArg2, int powerDerivOrder)
{
assert(powerDerivOrder > 0);
return AddBinaryOp(iArg1, oPowerDeriv, iArg2, powerDerivOrder);
return AddBinaryOp(iArg1, BinaryOpcode::powerDeriv, iArg2, powerDerivOrder);
}
expr_t
DataTree::AddDiff(expr_t iArg1)
{
return AddUnaryOp(oDiff, iArg1);
return AddUnaryOp(UnaryOpcode::diff, iArg1);
}
expr_t
DataTree::AddAdl(expr_t iArg1, const string &name, const vector<int> &lags)
{
return AddUnaryOp(oAdl, iArg1, 0, 0, 0, string(name), lags);
return AddUnaryOp(UnaryOpcode::adl, iArg1, 0, 0, 0, string(name), lags);
}
expr_t
DataTree::AddExp(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oExp, iArg1);
return AddUnaryOp(UnaryOpcode::exp, iArg1);
else
return One;
}
@ -284,7 +284,7 @@ expr_t
DataTree::AddLog(expr_t iArg1)
{
if (iArg1 != Zero && iArg1 != One)
return AddUnaryOp(oLog, iArg1);
return AddUnaryOp(UnaryOpcode::log, iArg1);
else if (iArg1 == One)
return Zero;
else
@ -298,7 +298,7 @@ expr_t
DataTree::AddLog10(expr_t iArg1)
{
if (iArg1 != Zero && iArg1 != One)
return AddUnaryOp(oLog10, iArg1);
return AddUnaryOp(UnaryOpcode::log10, iArg1);
else if (iArg1 == One)
return Zero;
else
@ -312,7 +312,7 @@ expr_t
DataTree::AddCos(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oCos, iArg1);
return AddUnaryOp(UnaryOpcode::cos, iArg1);
else
return One;
}
@ -321,7 +321,7 @@ expr_t
DataTree::AddSin(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oSin, iArg1);
return AddUnaryOp(UnaryOpcode::sin, iArg1);
else
return Zero;
}
@ -330,7 +330,7 @@ expr_t
DataTree::AddTan(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oTan, iArg1);
return AddUnaryOp(UnaryOpcode::tan, iArg1);
else
return Zero;
}
@ -339,7 +339,7 @@ expr_t
DataTree::AddAcos(expr_t iArg1)
{
if (iArg1 != One)
return AddUnaryOp(oAcos, iArg1);
return AddUnaryOp(UnaryOpcode::acos, iArg1);
else
return Zero;
}
@ -348,7 +348,7 @@ expr_t
DataTree::AddAsin(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oAsin, iArg1);
return AddUnaryOp(UnaryOpcode::asin, iArg1);
else
return Zero;
}
@ -357,7 +357,7 @@ expr_t
DataTree::AddAtan(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oAtan, iArg1);
return AddUnaryOp(UnaryOpcode::atan, iArg1);
else
return Zero;
}
@ -366,7 +366,7 @@ expr_t
DataTree::AddCosh(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oCosh, iArg1);
return AddUnaryOp(UnaryOpcode::cosh, iArg1);
else
return One;
}
@ -375,7 +375,7 @@ expr_t
DataTree::AddSinh(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oSinh, iArg1);
return AddUnaryOp(UnaryOpcode::sinh, iArg1);
else
return Zero;
}
@ -384,7 +384,7 @@ expr_t
DataTree::AddTanh(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oTanh, iArg1);
return AddUnaryOp(UnaryOpcode::tanh, iArg1);
else
return Zero;
}
@ -393,7 +393,7 @@ expr_t
DataTree::AddAcosh(expr_t iArg1)
{
if (iArg1 != One)
return AddUnaryOp(oAcosh, iArg1);
return AddUnaryOp(UnaryOpcode::acosh, iArg1);
else
return Zero;
}
@ -402,7 +402,7 @@ expr_t
DataTree::AddAsinh(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oAsinh, iArg1);
return AddUnaryOp(UnaryOpcode::asinh, iArg1);
else
return Zero;
}
@ -411,7 +411,7 @@ expr_t
DataTree::AddAtanh(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oAtanh, iArg1);
return AddUnaryOp(UnaryOpcode::atanh, iArg1);
else
return Zero;
}
@ -420,7 +420,7 @@ expr_t
DataTree::AddSqrt(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oSqrt, iArg1);
return AddUnaryOp(UnaryOpcode::sqrt, iArg1);
else
return Zero;
}
@ -433,7 +433,7 @@ DataTree::AddAbs(expr_t iArg1)
if (iArg1 == One)
return One;
else
return AddUnaryOp(oAbs, iArg1);
return AddUnaryOp(UnaryOpcode::abs, iArg1);
}
expr_t
@ -444,14 +444,14 @@ DataTree::AddSign(expr_t iArg1)
if (iArg1 == One)
return One;
else
return AddUnaryOp(oSign, iArg1);
return AddUnaryOp(UnaryOpcode::sign, iArg1);
}
expr_t
DataTree::AddErf(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oErf, iArg1);
return AddUnaryOp(UnaryOpcode::erf, iArg1);
else
return Zero;
}
@ -459,49 +459,49 @@ DataTree::AddErf(expr_t iArg1)
expr_t
DataTree::AddMax(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oMax, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::max, iArg2);
}
expr_t
DataTree::AddMin(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oMin, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::min, iArg2);
}
expr_t
DataTree::AddNormcdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
{
return AddTrinaryOp(iArg1, oNormcdf, iArg2, iArg3);
return AddTrinaryOp(iArg1, TrinaryOpcode::normcdf, iArg2, iArg3);
}
expr_t
DataTree::AddNormpdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
{
return AddTrinaryOp(iArg1, oNormpdf, iArg2, iArg3);
return AddTrinaryOp(iArg1, TrinaryOpcode::normpdf, iArg2, iArg3);
}
expr_t
DataTree::AddSteadyState(expr_t iArg1)
{
return AddUnaryOp(oSteadyState, iArg1);
return AddUnaryOp(UnaryOpcode::steadyState, iArg1);
}
expr_t
DataTree::AddSteadyStateParamDeriv(expr_t iArg1, int param_symb_id)
{
return AddUnaryOp(oSteadyStateParamDeriv, iArg1, 0, param_symb_id);
return AddUnaryOp(UnaryOpcode::steadyStateParamDeriv, iArg1, 0, param_symb_id);
}
expr_t
DataTree::AddSteadyStateParam2ndDeriv(expr_t iArg1, int param1_symb_id, int param2_symb_id)
{
return AddUnaryOp(oSteadyStateParam2ndDeriv, iArg1, 0, param1_symb_id, param2_symb_id);
return AddUnaryOp(UnaryOpcode::steadyStateParam2ndDeriv, iArg1, 0, param1_symb_id, param2_symb_id);
}
expr_t
DataTree::AddExpectation(int iArg1, expr_t iArg2)
{
return AddUnaryOp(oExpectation, iArg2, iArg1);
return AddUnaryOp(UnaryOpcode::expectation, iArg2, iArg1);
}
expr_t
@ -529,7 +529,7 @@ DataTree::AddPacExpectation(const string &model_name)
expr_t
DataTree::AddEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oEqual, iArg2);
return AddBinaryOp(iArg1, BinaryOpcode::equal, iArg2);
}
void
@ -706,14 +706,14 @@ DataTree::minLagForSymbol(int symb_id) const
void
DataTree::writePowerDerivCHeader(ostream &output) const
{
if (isBinaryOpUsed(oPowerDeriv))
if (isBinaryOpUsed(BinaryOpcode::powerDeriv))
output << "double getPowerDeriv(double, double, int);" << endl;
}
void
DataTree::writePowerDeriv(ostream &output) const
{
if (isBinaryOpUsed(oPowerDeriv))
if (isBinaryOpUsed(BinaryOpcode::powerDeriv))
output << "/*" << endl
<< " * The k-th derivative of x^p" << endl
<< " */" << endl
@ -739,7 +739,7 @@ void
DataTree::writeNormcdfCHeader(ostream &output) const
{
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
if (isTrinaryOpUsed(oNormcdf))
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
output << "#ifdef _MSC_VER" << endl
<< "double normcdf(double);" << endl
<< "#endif" << endl;
@ -750,7 +750,7 @@ void
DataTree::writeNormcdf(ostream &output) const
{
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
if (isTrinaryOpUsed(oNormcdf))
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
output << endl
<< "#ifdef _MSC_VER" << endl
<< "/*" << endl

View File

@ -348,9 +348,9 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int
return it->second;
// Try to reduce to a constant
// Case where arg is a constant and op_code == oUminus (i.e. we're adding a negative constant) is skipped
// Case where arg is a constant and op_code == UnaryOpcode::uminus (i.e. we're adding a negative constant) is skipped
auto *carg = dynamic_cast<NumConstNode *>(arg);
if (op_code != oUminus || carg == nullptr)
if (op_code != UnaryOpcode::uminus || carg == nullptr)
{
try
{

View File

@ -953,15 +953,15 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
fldu.write(code_file, instruction_number);
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first.first), it->first.second};
fldv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
fbinary.write(code_file, instruction_number);
if (it != derivatives[i].begin())
{
FBINARY_ fbinary(oPlus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)};
fbinary.write(code_file, instruction_number);
}
}
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
}
FSTPU_ fstpu(i);
@ -1273,7 +1273,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPR_ fstpr(i - block_recursive);
fstpr.write(code_file, instruction_number);
@ -1362,7 +1362,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag};
fldv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
fbinary.write(code_file, instruction_number);
FCUML_ fcuml;
@ -1375,7 +1375,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
free(Uf[v].Ufl);
Uf[v].Ufl = Uf[v].Ufl_First;
}
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPU_ fstpu(i - block_recursive);
@ -1585,7 +1585,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
mDynamicModelFile << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
// Write function definition if oPowerDeriv is used
// Write function definition if BinaryOpcode::powerDeriv is used
writePowerDerivCHeader(mDynamicModelFile);
writeNormcdfCHeader(mDynamicModelFile);
@ -5567,7 +5567,7 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const
// First, auxiliary variables
for (auto aux_equation : aux_equations)
{
assert(aux_equation->get_op_code() == oEqual);
assert(aux_equation->get_op_code() == BinaryOpcode::equal);
auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->get_arg1());
assert(auxvar != nullptr);
try
@ -5620,7 +5620,7 @@ void
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string>> &eq_tags)
{
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
assert(beq != nullptr && beq->get_op_code() == oEqual);
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
vector<pair<string, string>> soe_eq_tags;
for (const auto & eq_tag : eq_tags)

View File

@ -411,7 +411,7 @@ public:
//! Transforms the model by removing all lags on exos
void substituteExoLag(bool deterministic_model);
//! Transforms the model by removing all oExpectation
//! Transforms the model by removing all UnaryOpcode::expectation
void substituteExpectation(bool partial_information_model);
//! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one

File diff suppressed because it is too large Load Diff

View File

@ -726,7 +726,7 @@ private:
const expr_t arg;
//! Stores the information set. Only used for expectation operator
const int expectation_information_set;
//! Only used for oSteadyStateParamDeriv and oSteadyStateParam2ndDeriv
//! Only used for UnaryOpcode::steadyStateParamDeriv and UnaryOpcode::steadyStateParam2ndDeriv
const int param1_symb_id, param2_symb_id;
const UnaryOpcode op_code;
const string adl_param_name;

View File

@ -273,29 +273,29 @@ ModFile::checkPass(bool nostrict, bool stochastic)
}
if (stochastic_statement_present
&& (dynamic_model.isUnaryOpUsed(oSign)
|| dynamic_model.isUnaryOpUsed(oAbs)
|| dynamic_model.isBinaryOpUsed(oMax)
|| dynamic_model.isBinaryOpUsed(oMin)
|| dynamic_model.isBinaryOpUsed(oGreater)
|| dynamic_model.isBinaryOpUsed(oLess)
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|| dynamic_model.isBinaryOpUsed(oDifferent)))
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
|| dynamic_model.isUnaryOpUsed(UnaryOpcode::abs)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::max)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::min)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greater)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::less)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greaterEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
if (linear
&& (dynamic_model.isUnaryOpUsed(oSign)
|| dynamic_model.isUnaryOpUsed(oAbs)
|| dynamic_model.isBinaryOpUsed(oMax)
|| dynamic_model.isBinaryOpUsed(oMin)
|| dynamic_model.isBinaryOpUsed(oGreater)
|| dynamic_model.isBinaryOpUsed(oLess)
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|| dynamic_model.isBinaryOpUsed(oDifferent)))
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
|| dynamic_model.isUnaryOpUsed(UnaryOpcode::abs)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::max)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::min)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greater)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::less)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greaterEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
warnings << "WARNING: you have declared your model 'linear' but you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which potentially makes it non-linear." << endl;
// Test if some estimated parameters are used within the values of shocks
@ -905,17 +905,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
// If using USE_DLL with MSVC 10.0 or earlier, check that the user didn't use a function not supported by the compiler (because MSVC <= 10.0 doesn't comply with C99 standard)
if (use_dll && msvc)
{
if (dynamic_model.isUnaryOpUsed(oAcosh))
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::acosh))
{
cerr << "ERROR: acosh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
exit(EXIT_FAILURE);
}
if (dynamic_model.isUnaryOpUsed(oAsinh))
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::asinh))
{
cerr << "ERROR: asinh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
exit(EXIT_FAILURE);
}
if (dynamic_model.isUnaryOpUsed(oAtanh))
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::atanh))
{
cerr << "ERROR: atanh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
exit(EXIT_FAILURE);

View File

@ -1587,7 +1587,7 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPR_ fstpr(eq);
@ -1729,7 +1729,7 @@ void
ModelTree::addEquation(expr_t eq, int lineno)
{
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
assert(beq != nullptr && beq->get_op_code() == oEqual);
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
equations.push_back(beq);
equations_lineno.push_back(lineno);
@ -1748,7 +1748,7 @@ void
ModelTree::addAuxEquation(expr_t eq)
{
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
assert(beq != nullptr && beq->get_op_code() == oEqual);
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
aux_equations.push_back(beq);
}

View File

@ -3156,7 +3156,7 @@ ParsingDriver::is_there_one_integer_argument() const
}
}
else
if (unaryNode->get_op_code() != oUminus)
if (unaryNode->get_op_code() != UnaryOpcode::uminus)
return { false, 0 };
else
{
@ -3516,25 +3516,25 @@ ParsingDriver::add_ramsey_constraints_statement()
void
ParsingDriver::ramsey_constraint_add_less(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name, oLess, rhs);
add_ramsey_constraint(name, BinaryOpcode::less, rhs);
}
void
ParsingDriver::ramsey_constraint_add_greater(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name, oGreater, rhs);
add_ramsey_constraint(name, BinaryOpcode::greater, rhs);
}
void
ParsingDriver::ramsey_constraint_add_less_equal(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name, oLessEqual, rhs);
add_ramsey_constraint(name, BinaryOpcode::lessEqual, rhs);
}
void
ParsingDriver::ramsey_constraint_add_greater_equal(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name, oGreaterEqual, rhs);
add_ramsey_constraint(name, BinaryOpcode::greaterEqual, rhs);
}
void

View File

@ -487,15 +487,15 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
fldsu.write(code_file, instruction_number);
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first)};
fldsv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
fbinary.write(code_file, instruction_number);
if (it != derivatives[i].begin())
{
FBINARY_ fbinary(oPlus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)};
fbinary.write(code_file, instruction_number);
}
}
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
}
FSTPSU_ fstpsu(i);
@ -710,7 +710,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPR_ fstpr(i - block_recursive);
@ -789,7 +789,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var)};
fldsv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
fbinary.write(code_file, instruction_number);
FCUML_ fcuml;
@ -802,7 +802,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
free(Uf[v].Ufl);
Uf[v].Ufl = Uf[v].Ufl_First;
}
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPSU_ fstpsu(i - block_recursive);
@ -906,7 +906,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
lhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
rhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
FBINARY_ fbinary(oMinus);
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
fbinary.write(code_file, instruction_number);
FSTPR_ fstpr(i - block_recursive);
@ -1899,7 +1899,7 @@ StaticModel::writeStaticCFile(const string &basename) const
output << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
// Write function definition if oPowerDeriv is used
// Write function definition if BinaryOpcode::powerDeriv is used
writePowerDerivCHeader(output);
writeNormcdfCHeader(output);