diff --git a/src/generator.cpp b/src/generator.cpp index daaab7743..b7ff781cc 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -21,7 +21,6 @@ limitations under the License. #include "libcellml/analyservariable.h" #include "libcellml/version.h" -#include "commonutils.h" #include "generator_p.h" #include "generatorinterpreter_p.h" #include "generatorprofilesha1values.h" diff --git a/src/generatorinterpreter.cpp b/src/generatorinterpreter.cpp index 4321c2fab..580737174 100644 --- a/src/generatorinterpreter.cpp +++ b/src/generatorinterpreter.cpp @@ -1590,8 +1590,7 @@ void GeneratorInterpreter::GeneratorInterpreterImpl::initialiseVariables(std::ve methodBody += generateInitialisationCode(state); } - // Use an initial guess of zero for rates computed using an NLA system - // (see the note below). + // Use an initial guess of zero for rates computed using an NLA system (see the note below). for (const auto &state : mModel->states()) { if (state->equation(0)->type() == AnalyserEquation::Type::NLA) { diff --git a/src/generatorinterpreter.h b/src/generatorinterpreter.h index c681c647d..09b0819ca 100644 --- a/src/generatorinterpreter.h +++ b/src/generatorinterpreter.h @@ -137,8 +137,7 @@ class GeneratorInterpreter std::vector computeVariablesStatements() const; private: - GeneratorInterpreter(const AnalyserModelPtr &model, const GeneratorProfilePtr &profile, - const std::string &code); /**< Constructor, @private. */ + GeneratorInterpreter(const AnalyserModelPtr &model, const GeneratorProfilePtr &profile, const std::string &code); /**< Constructor, @private. */ GeneratorInterpreter(const AnalyserModelPtr &model); /**< Constructor, @private. */ GeneratorInterpreter(const AnalyserEquationAstPtr &ast, const GeneratorProfilePtr &profile); /**< Constructor, @private. */ diff --git a/src/generatorinterpreter_p.h b/src/generatorinterpreter_p.h index 7a432e6a3..894c60c69 100644 --- a/src/generatorinterpreter_p.h +++ b/src/generatorinterpreter_p.h @@ -80,19 +80,14 @@ struct GeneratorInterpreter::GeneratorInterpreterImpl std::string generateVariableNameCode(const VariablePtr &variable, bool rate = false) const; - std::string generateOperatorCode(const std::string &op, - const AnalyserEquationAstPtr &ast, + std::string generateOperatorCode(const std::string &op, const AnalyserEquationAstPtr &ast, const InterpreterStatementPtr &statement = nullptr) const; - std::string generateMinusUnaryCode(const AnalyserEquationAstPtr &ast, - const InterpreterStatementPtr &statement) const; - std::string generateOneParameterFunctionCode(const std::string &function, - const AnalyserEquationAstPtr &ast, + std::string generateMinusUnaryCode(const AnalyserEquationAstPtr &ast, const InterpreterStatementPtr &statement) const; + std::string generateOneParameterFunctionCode(const std::string &function, const AnalyserEquationAstPtr &ast, const InterpreterStatementPtr &statement = nullptr) const; - std::string generateTwoParameterFunctionCode(const std::string &function, - const AnalyserEquationAstPtr &ast, + std::string generateTwoParameterFunctionCode(const std::string &function, const AnalyserEquationAstPtr &ast, const InterpreterStatementPtr &statement = nullptr) const; - std::string generatePiecewiseIfCode(const std::string &condition, - const std::string &value) const; + std::string generatePiecewiseIfCode(const std::string &condition, const std::string &value) const; std::string generatePiecewiseElseCode(const std::string &value) const; std::tuple generateCode(const AnalyserEquationAstPtr &ast) const; diff --git a/tests/coverage/coverage.cpp b/tests/coverage/coverage.cpp index a81181d1c..f76359171 100644 --- a/tests/coverage/coverage.cpp +++ b/tests/coverage/coverage.cpp @@ -632,53 +632,29 @@ TEST(Coverage, generator) EXPECT_EQ(size_t(1), analyserModel->equation(0)->states().size()); EXPECT_NE(nullptr, analyserModel->equation(0)->state(0)); EXPECT_EQ(nullptr, analyserModel->equation(0)->state(analyserModel->equation(0)->stateCount())); - /*---GRY--- STILL NEEDED? - EXPECT_NE(nullptr, analyserModel->equation(199)); - EXPECT_NE(size_t(0), analyserModel->equation(199)->dependencyCount()); - EXPECT_NE(size_t(0), analyserModel->equation(199)->dependencies().size()); - EXPECT_NE(nullptr, analyserModel->equation(199)->dependency(0)); - EXPECT_EQ(nullptr, analyserModel->equation(199)->dependency(analyserModel->equation(199)->dependencyCount())); - EXPECT_EQ(size_t(1), analyserModel->equation(199)->nlaSiblingCount()); - EXPECT_EQ(size_t(1), analyserModel->equation(199)->nlaSiblings().size()); - EXPECT_NE(nullptr, analyserModel->equation(199)->nlaSibling(0)); - EXPECT_EQ(nullptr, analyserModel->equation(199)->nlaSibling(analyserModel->equation(199)->nlaSiblingCount())); - EXPECT_EQ(size_t(0), analyserModel->equation(199)->computedConstantCount()); - EXPECT_EQ(size_t(0), analyserModel->equation(199)->computedConstants().size()); - EXPECT_EQ(nullptr, analyserModel->equation(199)->computedConstant(0)); - EXPECT_EQ(nullptr, analyserModel->equation(199)->computedConstant(analyserModel->equation(199)->computedConstantCount())); - EXPECT_NE(size_t(0), analyserModel->equation(199)->algebraicCount()); - EXPECT_NE(size_t(0), analyserModel->equation(199)->algebraic().size()); - EXPECT_NE(nullptr, analyserModel->equation(199)->algebraic(0)); - EXPECT_EQ(nullptr, analyserModel->equation(199)->algebraic(analyserModel->equation(199)->algebraicCount())); - EXPECT_EQ(size_t(0), analyserModel->equation(199)->externalCount()); - EXPECT_EQ(size_t(0), analyserModel->equation(199)->externals().size()); - EXPECT_EQ(nullptr, analyserModel->equation(199)->external(0)); - EXPECT_EQ(nullptr, analyserModel->equation(199)->external(analyserModel->equation(199)->externalCount())); - EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); - */ for (const auto &equation : analyserModel->equations()) { + equation->dependencyCount(); + equation->dependency(0); + equation->dependency(equation->dependencyCount()); + equation->nlaSiblingCount(); + equation->nlaSibling(0); + equation->nlaSibling(equation->nlaSiblingCount()); + equation->computedConstantCount(); + equation->computedConstant(0); + equation->computedConstant(equation->computedConstantCount()); + equation->algebraicCount(); + equation->algebraic(0); + equation->algebraic(equation->algebraicCount()); + equation->externalCount(); + equation->external(0); + equation->external(equation->externalCount()); + checkAstTypeAsString(equation->ast()); } auto generator = libcellml::Generator::create(); - EXPECT_EQ(nullptr, analyserModel->voi()->initialisingVariable()); - - for (size_t i = 0; i < analyserModel->stateCount(); ++i) { - EXPECT_NE(nullptr, analyserModel->state(i)->initialisingVariable()); - } - - for (size_t i = 0; i < analyserModel->constantCount(); ++i) { - EXPECT_NE(nullptr, analyserModel->constant(i)->initialisingVariable()); - } - - /*---GRY--- STILL NEEDED? - for (size_t i = 0; i < analyserModel->algebraicCount(); ++i) { - EXPECT_NE(nullptr, analyserModel->algebraic(i)->initialisingVariable()); - } - */ - EXPECT_EQ(nullptr, generator->model()); EXPECT_EQ(EMPTY_STRING, generator->interfaceCode()); EXPECT_EQ(EMPTY_STRING, generator->implementationCode());