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

Commit 2f4f72e

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix connection graph.
- Emulate the old frontend better by not splitting array connectors when building the connection graph. Belonging to [master]: - #2860
1 parent 82a256a commit 2f4f72e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Compiler/NFFrontEnd/NFConnector.mo

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ public
177177
function split
178178
"Splits a connector into its primitive components."
179179
input Connector conn;
180+
input Boolean splitArrays = Flags.isSet(Flags.NF_SCALARIZE);
180181
output list<Connector> connl;
181182
algorithm
182-
connl := splitImpl(conn.name, conn.ty, conn.face, conn.source, conn.cty);
183+
connl := splitImpl(conn.name, conn.ty, conn.face, conn.source, conn.cty, splitArrays);
183184
end split;
184185

185186
protected
@@ -205,8 +206,9 @@ protected
205206
input Face face;
206207
input DAE.ElementSource source;
207208
input ConnectorType cty;
209+
input Boolean splitArrays;
208210
input output list<Connector> conns = {};
209-
input list<Dimension> dims = {} "accumulated dimensions if not NF_SCALARIZE";
211+
input list<Dimension> dims = {} "accumulated dimensions if splitArrays = false";
210212
algorithm
211213
conns := match ty
212214
local
@@ -216,30 +218,30 @@ protected
216218

217219
case Type.COMPLEX(complexTy = ct as ComplexType.CONNECTOR())
218220
algorithm
219-
conns := splitImpl2(name, face, source, ct.potentials, conns, dims);
220-
conns := splitImpl2(name, face, source, ct.flows, conns, dims);
221-
conns := splitImpl2(name, face, source, ct.streams, conns, dims);
221+
conns := splitImpl2(name, face, source, ct.potentials, splitArrays, conns, dims);
222+
conns := splitImpl2(name, face, source, ct.flows, splitArrays, conns, dims);
223+
conns := splitImpl2(name, face, source, ct.streams, splitArrays, conns, dims);
222224
then
223225
conns;
224226

225227
case Type.COMPLEX()
226228
algorithm
227229
tree := Class.classTree(InstNode.getClass(ty.cls));
228230
conns := splitImpl2(name, face, source,
229-
arrayList(ClassTree.getComponents(tree)), conns, dims);
231+
arrayList(ClassTree.getComponents(tree)), splitArrays, conns, dims);
230232
then
231233
conns;
232234

233235
case Type.ARRAY()
234236
algorithm
235237
t := Type.arrayElementType(ty);
236-
if Flags.isSet(Flags.NF_SCALARIZE) then
238+
if splitArrays then
237239
for c in ComponentRef.scalarize(name) loop
238-
conns := splitImpl(c, t, face, source, cty, conns, dims);
240+
conns := splitImpl(c, t, face, source, cty, splitArrays, conns, dims);
239241
end for;
240242
else
241243
if not Type.isEmptyArray(ty) then
242-
conns := splitImpl(name, t, face, source, cty, conns,
244+
conns := splitImpl(name, t, face, source, cty, splitArrays, conns,
243245
listAppend(dims, ty.dimensions));
244246
end if;
245247
end if;
@@ -255,6 +257,7 @@ protected
255257
input Face face;
256258
input DAE.ElementSource source;
257259
input list<InstNode> comps;
260+
input Boolean splitArrays;
258261
input output list<Connector> conns;
259262
input list<Dimension> dims;
260263
protected
@@ -268,7 +271,7 @@ protected
268271
ty := Component.getType(c);
269272
cty := Component.connectorType(c);
270273
cref := ComponentRef.append(ComponentRef.fromNode(comp, ty), name);
271-
conns := splitImpl(cref, ty, face, source, cty, conns, dims);
274+
conns := splitImpl(cref, ty, face, source, cty, splitArrays, conns, dims);
272275
end for;
273276
end splitImpl2;
274277

Compiler/NFFrontEnd/NFOCConnectionGraph.mo

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ algorithm
172172
rhs = Expression.CREF(ty = ty2, cref = rhs),
173173
source = source)
174174
algorithm
175-
if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs))
176-
then
175+
if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs)) then
177176
cl1 := NFConnections.makeConnectors(lhs, ty1, source);
178177
cl2 := NFConnections.makeConnectors(rhs, ty2, source);
179178
for c1 in cl1 loop
180179
c2 :: cl2 := cl2;
181180

182-
lhsl := Connector.split(c1);
183-
rhsl := Connector.split(c2);
181+
lhsl := Connector.split(c1, splitArrays = false);
182+
rhsl := Connector.split(c2, splitArrays = false);
184183

185184
for cc1 in lhsl loop
186185
cc2 :: rhsl := rhsl;

0 commit comments

Comments
 (0)