From 04b6690d5a258a6e33097511f65256e468d05165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 18 Jul 2018 16:56:55 +0200 Subject: [PATCH] C++11: convert ExternalFunctionType to a class enum --- src/CodeInterpreter.hh | 26 +++++++++++++------------- src/ExprNode.cc | 10 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/CodeInterpreter.hh b/src/CodeInterpreter.hh index 28fec2d5..2f933be5 100644 --- a/src/CodeInterpreter.hh +++ b/src/CodeInterpreter.hh @@ -229,15 +229,15 @@ enum class TrinaryOpcode normpdf }; -enum external_function_type +enum class ExternalFunctionType { - ExternalFunctionWithoutDerivative, - ExternalFunctionWithFirstDerivative, - ExternalFunctionWithFirstandSecondDerivative, - ExternalFunctionNumericalFirstDerivative, - ExternalFunctionFirstDerivative, - ExternalFunctionNumericalSecondDerivative, - ExternalFunctionSecondDerivative + withoutDerivative, + withFirstDerivative, + withFirstAndSecondDerivative, + numericalFirstDerivative, + firstDerivative, + numericalSecondDerivative, + secondDerivative }; enum class PriorDistributions @@ -1176,7 +1176,7 @@ class FCALL_ : public TagWithFourArguments::TagWithFourArguments(FCALL) @@ -1185,7 +1185,7 @@ public: add_input_arguments = 0; row = 0; col = 0; - function_type = ExternalFunctionWithoutDerivative; + function_type = ExternalFunctionType::withoutDerivative; }; inline FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) : @@ -1195,7 +1195,7 @@ public: add_input_arguments = 0; row = 0; col = 0; - function_type = ExternalFunctionWithoutDerivative; + function_type = ExternalFunctionType::withoutDerivative; func_name = f_name; }; inline string @@ -1260,11 +1260,11 @@ public: return col; }; inline void - set_function_type(external_function_type arg_function_type) + set_function_type(ExternalFunctionType arg_function_type) { function_type = arg_function_type; }; - inline external_function_type + inline ExternalFunctionType get_function_type() { return (function_type); diff --git a/src/ExprNode.cc b/src/ExprNode.cc index fa884efa..f2a6f3e4 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -6631,13 +6631,13 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign switch (nb_output_arguments) { case 1: - fcall.set_function_type(ExternalFunctionWithoutDerivative); + fcall.set_function_type(ExternalFunctionType::withoutDerivative); break; case 2: - fcall.set_function_type(ExternalFunctionWithFirstDerivative); + fcall.set_function_type(ExternalFunctionType::withFirstDerivative); break; case 3: - fcall.set_function_type(ExternalFunctionWithFirstandSecondDerivative); + fcall.set_function_type(ExternalFunctionType::withFirstAndSecondDerivative); break; } fcall.write(CompileCode, instruction_number); @@ -7156,7 +7156,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo fcall.set_arg_func_name(datatree.symbol_table.getName(symb_id)); fcall.set_row(inputIndex); fcall.set_nb_add_input_arguments(nb_add_input_arguments); - fcall.set_function_type(ExternalFunctionNumericalFirstDerivative); + fcall.set_function_type(ExternalFunctionType::numericalFirstDerivative); fcall.write(CompileCode, instruction_number); FSTPTEFD_ fstptefd(indx, inputIndex); fstptefd.write(CompileCode, instruction_number); @@ -7171,7 +7171,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo unsigned int nb_output_arguments = 1; FCALL_ fcall(nb_output_arguments, nb_add_input_arguments, datatree.symbol_table.getName(first_deriv_symb_id), indx); - fcall.set_function_type(ExternalFunctionFirstDerivative); + fcall.set_function_type(ExternalFunctionType::firstDerivative); fcall.write(CompileCode, instruction_number); FSTPTEFD_ fstptefd(indx, inputIndex); fstptefd.write(CompileCode, instruction_number);