Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 6219713

Browse files
committed
Fix for DAE.RSUB with Expression.factorsWork
1 parent 1d668ee commit 6219713

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

Compiler/BackEnd/ExpressionSolve.mo

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ algorithm
129129
varexp := Expression.expDer(varexp);
130130
cr := ComponentReference.crefPrefixDer(cr);
131131
end if;
132-
133132
if (Types.isIntegerOrRealOrSubTypeOfEither(Expression.typeof(e1)) and Types.isIntegerOrRealOrSubTypeOfEither(Expression.typeof(e2))) then
134133
(e1, e2) := preprocessingSolve(e1, e2, varexp, SOME(shared.functionTree), NONE(), 0, false);
135134
end if;
@@ -915,7 +914,6 @@ algorithm
915914
(factorWithX1, factorWithoutX1) := List.split1OnTrue(f1, expHasCref, inExp3);
916915
pWithX1 := makeProductLstSort(factorWithX1);
917916
pWithoutX1 := makeProductLstSort(factorWithoutX1);
918-
919917
f2 := Expression.expandFactors(inExp2);
920918
(factorWithX2, factorWithoutX2) := List.split1OnTrue(f2, expHasCref, inExp3);
921919
(pWithX2,_) := ExpressionSimplify.simplify1(makeProductLstSort(factorWithX2));
@@ -989,7 +987,7 @@ algorithm
989987
if expand then
990988
(cr, b) := Expression.expOrDerCref(inExp3);
991989
if b then
992-
(lhs, rhs) := Expression.allTermsForCref(inExp1, cr, Expression.Expression.expHasDerCref);
990+
(lhs, rhs) := Expression.allTermsForCref(inExp1, cr, Expression.expHasDerCref);
993991
else
994992
(lhs, rhs) := Expression.allTermsForCref(inExp1, cr, Expression.expHasCrefNoPreOrStart);
995993
end if;
@@ -1748,7 +1746,7 @@ algorithm
17481746
false = hasOnlyFactors(inExp1,inExp2);
17491747
e = Expression.makeDiff(inExp1,inExp2);
17501748
(e,_) = ExpressionSimplify.simplify1(e);
1751-
//print("\n\ne: ");print(ExpressionDump.printExpStr(e));
1749+
//print("\ne: ");print(ExpressionDump.printExpStr(e));
17521750
dere = Differentiate.differentiateExpSolve(e, cr, functions);
17531751
//print("\nder(e): ");print(ExpressionDump.printExpStr(dere));
17541752
(dere,_) = ExpressionSimplify.simplify(dere);

Compiler/FrontEnd/Expression.mo

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,12 +3046,14 @@ algorithm
30463046
equation
30473047
e = if doInverseFactors then inverseFactors(inExp) else inExp;
30483048
then e::acc;
3049-
case (e,acc,true,_)
3049+
case (DAE.RSUB(),acc,_,_)
30503050
equation
3051-
e = if doInverseFactors then inverseFactors(e) else e;
3051+
e = if doInverseFactors then inverseFactors(inExp) else inExp;
30523052
then e::acc;
3053-
case (_,acc,false,_)
3054-
then acc;
3053+
else
3054+
algorithm
3055+
Error.addInternalError(getInstanceName() + " failed for " + ExpressionDump.printExpStr(inExp), sourceInfo());
3056+
then fail();
30553057
end match;
30563058
end factorsWork;
30573059

@@ -7119,6 +7121,13 @@ algorithm
71197121
then
71207122
(DAE.ASUB(e1, expl), arg);
71217123

7124+
case e1 as DAE.RSUB()
7125+
equation
7126+
(e2, arg) = traverseExpBidir(e1.exp, inEnterFunc, inExitFunc, inArg);
7127+
e1.exp = e2;
7128+
then
7129+
(e1, arg);
7130+
71227131
case DAE.TSUB(e1, i, ty)
71237132
equation
71247133
(e1, arg) = traverseExpBidir(e1, inEnterFunc, inExitFunc, inArg);

0 commit comments

Comments
 (0)