Closed hsorby closed 1 year ago
No idea what you mean by this.
I'll write a test to show the problem.
Here is a test that will cause a segfault when trying to generate the implement code (implementationCode) :
TEST(Generator, modelOutOfScope)
{
auto analyser = libcellml::Analyser::create();
{
auto parser = libcellml::Parser::create();
auto model = parser->parseModel(fileContents("generator/ode_multiple_dependent_odes/model.cellml"));
EXPECT_EQ(size_t(0), parser->issueCount());
analyser->analyseModel(model);
}
EXPECT_EQ(size_t(0), analyser->errorCount());
auto analyserModel = analyser->model();
auto generator = libcellml::Generator::create();
generator->setModel(analyserModel);
auto profile = libcellml::GeneratorProfile::create(libcellml::GeneratorProfile::Profile::PYTHON);
generator->setProfile(profile);
EXPECT_EQ(fileContents("generator/ode_multiple_dependent_odes/model.py"), generator->implementationCode());
}
Thanks, I am looking into it.
When analysing a model the analyser does not hold onto object references that it later needs when generating code. This results in generated code that cannot be simulated.