Skip to content

Commit 7473d64

Browse files
committed
Reverted commit 6a48c0f.
1 parent 71a3ab4 commit 7473d64

File tree

101 files changed

+2411
-2413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2411
-2413
lines changed

src/analyser.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -483,36 +483,34 @@ void Analyser::AnalyserImpl::analyseNode(const XmlNodePtr &node,
483483
// +-------------+
484484

485485
auto childCount = mathmlChildCount(node);
486+
AnalyserEquationAstPtr tempAst;
487+
AnalyserEquationAstPtr astRightChild;
486488

487-
analyseNode(mathmlChildNode(node, 0), ast, astParent, component, equation);
488-
489-
if (childCount >= 2) {
490-
analyseNode(mathmlChildNode(node, 1), ast->mPimpl->mOwnedLeftChild, ast, component, equation);
491-
492-
if (childCount >= 3) {
493-
AnalyserEquationAstPtr astRightChild;
494-
AnalyserEquationAstPtr tempAst;
495-
496-
analyseNode(mathmlChildNode(node, childCount - 1), astRightChild, nullptr, component, equation);
497-
498-
for (auto i = childCount - 2; i > 1; --i) {
499-
tempAst = AnalyserEquationAst::create();
500-
501-
analyseNode(mathmlChildNode(node, 0), tempAst, nullptr, component, equation);
502-
analyseNode(mathmlChildNode(node, i), tempAst->mPimpl->mOwnedLeftChild, tempAst, component, equation);
489+
for (size_t i = childCount - 1; i > 0; --i) {
490+
astRightChild = tempAst;
491+
tempAst = AnalyserEquationAst::create();
503492

493+
if (astRightChild != nullptr) {
494+
if (i == childCount - 2) {
495+
astRightChild->swapLeftAndRightChildren();
496+
tempAst = astRightChild;
497+
} else {
504498
astRightChild->mPimpl->mParent = tempAst;
505-
506499
tempAst->mPimpl->mOwnedRightChild = astRightChild;
507-
astRightChild = tempAst;
508500
}
501+
}
509502

510-
astRightChild->mPimpl->mParent = ast;
511-
512-
ast->mPimpl->mOwnedRightChild = astRightChild;
503+
if (i != childCount - 2) {
504+
analyseNode(mathmlChildNode(node, 0), tempAst, nullptr, component, equation);
513505
}
506+
507+
analyseNode(mathmlChildNode(node, i), tempAst->mPimpl->mOwnedLeftChild, tempAst, component, equation);
514508
}
515509

510+
analyseNode(mathmlChildNode(node, 0), tempAst, astParent, component, equation);
511+
512+
ast = tempAst;
513+
516514
// Relational and logical operators.
517515

518516
} else if (node->isMathmlElement("eq")) {

tests/analyser/analyser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,8 @@ TEST(Analyser, algebraicSystemWithThreeLinkedUnknownsWithOneExternalVariable)
921921
EXPECT_EQ(size_t(0), parser->issueCount());
922922

923923
const std::vector<std::string> expectedIssues = {
924-
"Variable 'y' in component 'my_algebraic_system' is computed more than once.",
925924
"Variable 'z' in component 'my_algebraic_system' is computed more than once.",
925+
"Variable 'y' in component 'my_algebraic_system' is computed more than once.",
926926
};
927927

928928
auto analyser = libcellml::Analyser::create();
@@ -977,8 +977,8 @@ TEST(Analyser, overconstrainedNlaSystem)
977977
EXPECT_EQ(size_t(0), parser->issueCount());
978978

979979
const std::vector<std::string> expectedIssues = {
980-
"Variable 'x' in component 'my_algebraic_system' is computed more than once.",
981980
"Variable 'y' in component 'my_algebraic_system' is computed more than once.",
981+
"Variable 'x' in component 'my_algebraic_system' is computed more than once.",
982982
};
983983

984984
auto analyser = libcellml::Analyser::create();

tests/analyser/analyserunits.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ TEST(AnalyserUnits, powerValues)
883883
"The units in 'eqnPi = pow(x, pi)' in component 'my_component' are not equivalent. 'eqnPi' is in 'second' while 'pow(x, pi)' is in 'second^3.14159'.",
884884
"The units in 'eqnInfinity = pow(x, infinity)' in component 'my_component' are not equivalent. 'eqnInfinity' is in 'second' while 'pow(x, infinity)' is in 'second^inf' (i.e. '10^nan x second^inf').",
885885
"The units in 'eqnNotanumber = pow(x, notanumber)' in component 'my_component' are not equivalent. 'eqnNotanumber' is in 'second' while 'pow(x, notanumber)' is in 'second^nan' (i.e. '10^nan x second^nan').",
886-
"The type of variable 'eqnCoverage' in component 'my_component' is unknown.",
887886
"The type of variable 'u' in component 'my_component' is unknown.",
887+
"The type of variable 'eqnCoverage' in component 'my_component' is unknown.",
888888
"The type of variable 'eqnCoverage2' in component 'my_component' is unknown.",
889889
"The type of variable 'eqnCoverage3' in component 'my_component' is unknown.",
890890
};

tests/resources/coverage/generator/model.c

Lines changed: 200 additions & 200 deletions
Large diffs are not rendered by default.

tests/resources/coverage/generator/model.implementation.out

Lines changed: 195 additions & 195 deletions
Large diffs are not rendered by default.

tests/resources/coverage/generator/model.modified.profile.c

Lines changed: 200 additions & 200 deletions
Large diffs are not rendered by default.

tests/resources/coverage/generator/model.modified.profile.py

Lines changed: 200 additions & 200 deletions
Large diffs are not rendered by default.

tests/resources/coverage/generator/model.no.tracking.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const VariableInfo COMPUTED_CONSTANT_INFO[] = {
2626
};
2727

2828
const VariableInfo ALGEBRAIC_INFO[] = {
29-
{"eqnNlaVariable1", "dimensionless", "my_component"},
30-
{"eqnNlaVariable2", "dimensionless", "my_component"}
29+
{"eqnNlaVariable2", "dimensionless", "my_component"},
30+
{"eqnNlaVariable1", "dimensionless", "my_component"}
3131
};
3232

3333
double xor(double x, double y)
@@ -184,8 +184,8 @@ void objectiveFunction0(double *u, double *f, void *data)
184184
algebraic[0] = u[0];
185185
algebraic[1] = u[1];
186186

187-
f[0] = algebraic[0]+algebraic[1]+states[0]-0.0;
188-
f[1] = algebraic[0]-algebraic[1]-(my_component_eqnComputedConstant1+my_component_eqnComputedConstant2);
187+
f[0] = algebraic[1]+algebraic[0]+states[0]-0.0;
188+
f[1] = algebraic[1]-algebraic[0]-(my_component_eqnComputedConstant1+my_component_eqnComputedConstant2);
189189
}
190190

191191
void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)
@@ -217,8 +217,8 @@ void initialiseVariables(double *states, double *rates, double *constants, doubl
217217
double my_component_eqnNotanumber = NAN;
218218
double my_component_eqnComputedConstant1 = 1.0;
219219
double my_component_eqnComputedConstant2 = 3.0;
220-
algebraic[0] = 1.0;
221-
algebraic[1] = 2.0;
220+
algebraic[0] = 2.0;
221+
algebraic[1] = 1.0;
222222
}
223223

224224
void computeComputedConstants(double *constants, double *computedConstants)

0 commit comments

Comments
 (0)