diff --git a/src/ModelTree.hh b/src/ModelTree.hh index ad67aa1a7564e834f3e40e448af1b3d07518558b..a195cf79093cfd790322aae67ebf3cd706d588c6 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -1023,7 +1023,6 @@ ModelTree::writeBytecodeTemporaryTerms(const temporary_terms_t &tt, BytecodeWriter &code_file, deriv_node_temp_terms_t &tef_terms) const { - // To store the functions that have already been written in the form TEF* = ext_fun(); for (auto it : tt) { if (dynamic_cast<AbstractExternalFunctionNode *>(it)) @@ -1032,22 +1031,15 @@ ModelTree::writeBytecodeTemporaryTerms(const temporary_terms_t &tt, int idx {temporary_terms_idxs.at(it)}; code_file << FNUMEXPR_{ExpressionType::TemporaryTerm, idx}; it->writeBytecodeOutput(code_file, output_type, temporary_terms_union, temporary_terms_idxs, tef_terms); - switch (output_type) - { - case ExprNodeBytecodeOutputType::dynamicModel: - code_file << FSTPT_{idx}; - break; - case ExprNodeBytecodeOutputType::staticModel: - code_file << FSTPST_{idx}; - break; - case ExprNodeBytecodeOutputType::dynamicSteadyStateOperator: - case ExprNodeBytecodeOutputType::dynamicAssignmentLHS: - case ExprNodeBytecodeOutputType::staticAssignmentLHS: - cerr << "ModelTree::writeBytecodeTemporaryTerms: impossible case" << endl; - exit(EXIT_FAILURE); - - temporary_terms_union.insert(it); - } + + static_assert(output_type == ExprNodeBytecodeOutputType::dynamicModel + || output_type == ExprNodeBytecodeOutputType::staticModel); + if constexpr(output_type == ExprNodeBytecodeOutputType::dynamicModel) + code_file << FSTPT_{idx}; + else + code_file << FSTPST_{idx}; + + temporary_terms_union.insert(it); } }