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

Commit 547468f

Browse files
perostOpenModelica-Hudson
authored andcommitted
Expand crefs when simplifying cat.
- Expand one-dimensional crefs before trying to simplify cat in ExpressionSimplify.simplifyCat. This is needed when using the new frontend, since it generally doesn't expand function arguments. Belonging to [master]: - #2896
1 parent 2128334 commit 547468f

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

3rdParty

Compiler/FrontEnd/Algorithm.mo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ algorithm
287287
case DAE.CALL(attr=DAE.CALL_ATTR(builtin=true), path=Absyn.IDENT("listAppend"), expLst=(e1 as DAE.CREF())::_)
288288
guard Expression.expEqual(lhs, e1)
289289
algorithm
290-
print(stringDelimitList(list(SCodeDump.printCommentAndAnnotationStr(comment) for comment in ElementSource.getCommentsFromSource(source)), "\n"));
291290
if Flags.isSet(Flags.LIST_REVERSE_WRONG_ORDER) and not max(SCode.commentHasBooleanNamedAnnotation(comment, "__OpenModelica_DisableListAppendWarning") for comment in ElementSource.getCommentsFromSource(source)) then
292291
Error.addSourceMessage(Error.LIST_REVERSE_WRONG_ORDER, {ExpressionDump.printExpStr(e1)}, ElementSource.getElementSourceFileInfo(source));
293292
fail();

Compiler/FrontEnd/ComponentReference.mo

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,7 +3271,8 @@ algorithm
32713271
// Pad the list of subscripts with : if necessary to fill out all dimensions.
32723272
missing_subs = listLength(dims) - listLength(subs);
32733273
if missing_subs > 0 then
3274-
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs));
3274+
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs))
3275+
annotation(__OpenModelica_DisableListAppendWarning=true);
32753276
end if;
32763277

32773278
// Use the subscripts to generate only the wanted elements.
@@ -3289,7 +3290,8 @@ algorithm
32893290
// Pad the list of subscripts with : if necessary to fill out all dimensions.
32903291
missing_subs = listLength(dims) - listLength(subs);
32913292
if missing_subs > 0 then
3292-
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs));
3293+
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs))
3294+
annotation(__OpenModelica_DisableListAppendWarning=true);
32933295
end if;
32943296
// Use the subscripts to generate only the wanted elements.
32953297
then

Compiler/FrontEnd/ExpressionSimplify.mo

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ algorithm
15561556

15571557
case (1, _)
15581558
equation
1559-
expl = List.map(inExpList, Expression.matrixToArray);
1559+
expl = List.map(inExpList, simplifyCatArg);
15601560
then
15611561
simplifyCat2(inDim, expl, {}, false);
15621562

@@ -1565,6 +1565,21 @@ algorithm
15651565
end match;
15661566
end simplifyCat;
15671567

1568+
function simplifyCatArg
1569+
input DAE.Exp arg;
1570+
output DAE.Exp outArg;
1571+
algorithm
1572+
outArg := match arg
1573+
local
1574+
DAE.Dimension dim;
1575+
1576+
case DAE.MATRIX() then Expression.matrixToArray(arg);
1577+
case DAE.CREF(ty = DAE.T_ARRAY(dims = {dim})) guard Expression.dimensionKnown(dim)
1578+
then DAE.ARRAY(arg.ty, true, Expression.expandExpression(arg, false));
1579+
else arg;
1580+
end match;
1581+
end simplifyCatArg;
1582+
15681583
protected function simplifyCat2
15691584
input Integer dim;
15701585
input list<DAE.Exp> ies;

0 commit comments

Comments
 (0)