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

Commit e80e927

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Implemented expansion of cat and promote.
- Refactored expression expansion code into a new module NFExpandExp. - Implemented expansion of cat and promote to avoid them being subscripted and blowing up the flat model during scalarization. Belonging to [master]: - #2463 - OpenModelica/OpenModelica-testsuite#960
1 parent 2ea6748 commit e80e927

File tree

9 files changed

+670
-563
lines changed

9 files changed

+670
-563
lines changed

Compiler/NFFrontEnd/NFCeval.mo

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,48 +1312,6 @@ function evalNormalCall
13121312
output Expression result = EvalFunction.evaluate(fn, args);
13131313
end evalNormalCall;
13141314

1315-
protected
1316-
1317-
function printUnboundError
1318-
input EvalTarget target;
1319-
input Expression exp;
1320-
algorithm
1321-
() := match target
1322-
case EvalTarget.DIMENSION()
1323-
algorithm
1324-
Error.addSourceMessage(Error.STRUCTURAL_PARAMETER_OR_CONSTANT_WITH_NO_BINDING,
1325-
{Expression.toString(exp), InstNode.name(target.component)}, target.info);
1326-
then
1327-
fail();
1328-
1329-
case EvalTarget.CONDITION()
1330-
algorithm
1331-
Error.addSourceMessage(Error.CONDITIONAL_EXP_WITHOUT_VALUE,
1332-
{Expression.toString(exp)}, target.info);
1333-
then
1334-
fail();
1335-
1336-
case EvalTarget.GENERIC()
1337-
algorithm
1338-
Error.addMultiSourceMessage(Error.UNBOUND_CONSTANT,
1339-
{Expression.toString(exp)},
1340-
{InstNode.info(ComponentRef.node(Expression.toCref(exp))), target.info});
1341-
then
1342-
fail();
1343-
1344-
else ();
1345-
end match;
1346-
end printUnboundError;
1347-
1348-
function printWrongArgsError
1349-
input String evalFunc;
1350-
input list<Expression> args;
1351-
input SourceInfo info;
1352-
algorithm
1353-
Error.addInternalError(evalFunc + " got invalid arguments " +
1354-
List.toString(args, Expression.toString, "", "(", ", ", ")", true), info);
1355-
end printWrongArgsError;
1356-
13571315
function evalBuiltinAbs
13581316
input Expression arg;
13591317
output Expression result;
@@ -2362,5 +2320,47 @@ algorithm
23622320
end match;
23632321
end evalSubscript;
23642322

2323+
protected
2324+
2325+
function printUnboundError
2326+
input EvalTarget target;
2327+
input Expression exp;
2328+
algorithm
2329+
() := match target
2330+
case EvalTarget.DIMENSION()
2331+
algorithm
2332+
Error.addSourceMessage(Error.STRUCTURAL_PARAMETER_OR_CONSTANT_WITH_NO_BINDING,
2333+
{Expression.toString(exp), InstNode.name(target.component)}, target.info);
2334+
then
2335+
fail();
2336+
2337+
case EvalTarget.CONDITION()
2338+
algorithm
2339+
Error.addSourceMessage(Error.CONDITIONAL_EXP_WITHOUT_VALUE,
2340+
{Expression.toString(exp)}, target.info);
2341+
then
2342+
fail();
2343+
2344+
case EvalTarget.GENERIC()
2345+
algorithm
2346+
Error.addMultiSourceMessage(Error.UNBOUND_CONSTANT,
2347+
{Expression.toString(exp)},
2348+
{InstNode.info(ComponentRef.node(Expression.toCref(exp))), target.info});
2349+
then
2350+
fail();
2351+
2352+
else ();
2353+
end match;
2354+
end printUnboundError;
2355+
2356+
function printWrongArgsError
2357+
input String evalFunc;
2358+
input list<Expression> args;
2359+
input SourceInfo info;
2360+
algorithm
2361+
Error.addInternalError(evalFunc + " got invalid arguments " +
2362+
List.toString(args, Expression.toString, "", "(", ", ", ")", true), info);
2363+
end printWrongArgsError;
2364+
23652365
annotation(__OpenModelica_Interface="frontend");
23662366
end NFCeval;

Compiler/NFFrontEnd/NFConnections.mo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected
4444
import Type = NFType;
4545
import MetaModelica.Dangerous.listReverseInPlace;
4646
import ElementSource;
47+
import ExpandExp = NFExpandExp;
4748

4849
public
4950
record CONNECTIONS
@@ -98,8 +99,8 @@ public
9899
rhs = Expression.CREF(cref = rhs), source = source)
99100
algorithm
100101
if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs)) then
101-
cl1 := Connector.fromExp(Expression.expand(eq.lhs), source);
102-
cl2 := Connector.fromExp(Expression.expand(eq.rhs), source);
102+
cl1 := Connector.fromExp(ExpandExp.expand(eq.lhs), source);
103+
cl2 := Connector.fromExp(ExpandExp.expand(eq.rhs), source);
103104

104105
for c1 in cl1 loop
105106
c2 :: cl2 := cl2;

0 commit comments

Comments
 (0)