Skip to content

Commit

Permalink
[NF] Fix connection graph.
Browse files Browse the repository at this point in the history
- Emulate the old frontend better by not splitting array connectors when
  building the connection graph.

Belonging to [master]:
  - OpenModelica/OMCompiler#2860
  • Loading branch information
perost authored and OpenModelica-Hudson committed Jan 10, 2019
1 parent 82a256a commit 2f4f72e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
23 changes: 13 additions & 10 deletions Compiler/NFFrontEnd/NFConnector.mo
Expand Up @@ -177,9 +177,10 @@ public
function split
"Splits a connector into its primitive components."
input Connector conn;
input Boolean splitArrays = Flags.isSet(Flags.NF_SCALARIZE);
output list<Connector> connl;
algorithm
connl := splitImpl(conn.name, conn.ty, conn.face, conn.source, conn.cty);
connl := splitImpl(conn.name, conn.ty, conn.face, conn.source, conn.cty, splitArrays);
end split;

protected
Expand All @@ -205,8 +206,9 @@ protected
input Face face;
input DAE.ElementSource source;
input ConnectorType cty;
input Boolean splitArrays;
input output list<Connector> conns = {};
input list<Dimension> dims = {} "accumulated dimensions if not NF_SCALARIZE";
input list<Dimension> dims = {} "accumulated dimensions if splitArrays = false";
algorithm
conns := match ty
local
Expand All @@ -216,30 +218,30 @@ protected

case Type.COMPLEX(complexTy = ct as ComplexType.CONNECTOR())
algorithm
conns := splitImpl2(name, face, source, ct.potentials, conns, dims);
conns := splitImpl2(name, face, source, ct.flows, conns, dims);
conns := splitImpl2(name, face, source, ct.streams, conns, dims);
conns := splitImpl2(name, face, source, ct.potentials, splitArrays, conns, dims);
conns := splitImpl2(name, face, source, ct.flows, splitArrays, conns, dims);
conns := splitImpl2(name, face, source, ct.streams, splitArrays, conns, dims);
then
conns;

case Type.COMPLEX()
algorithm
tree := Class.classTree(InstNode.getClass(ty.cls));
conns := splitImpl2(name, face, source,
arrayList(ClassTree.getComponents(tree)), conns, dims);
arrayList(ClassTree.getComponents(tree)), splitArrays, conns, dims);
then
conns;

case Type.ARRAY()
algorithm
t := Type.arrayElementType(ty);
if Flags.isSet(Flags.NF_SCALARIZE) then
if splitArrays then
for c in ComponentRef.scalarize(name) loop
conns := splitImpl(c, t, face, source, cty, conns, dims);
conns := splitImpl(c, t, face, source, cty, splitArrays, conns, dims);
end for;
else
if not Type.isEmptyArray(ty) then
conns := splitImpl(name, t, face, source, cty, conns,
conns := splitImpl(name, t, face, source, cty, splitArrays, conns,
listAppend(dims, ty.dimensions));
end if;
end if;
Expand All @@ -255,6 +257,7 @@ protected
input Face face;
input DAE.ElementSource source;
input list<InstNode> comps;
input Boolean splitArrays;
input output list<Connector> conns;
input list<Dimension> dims;
protected
Expand All @@ -268,7 +271,7 @@ protected
ty := Component.getType(c);
cty := Component.connectorType(c);
cref := ComponentRef.append(ComponentRef.fromNode(comp, ty), name);
conns := splitImpl(cref, ty, face, source, cty, conns, dims);
conns := splitImpl(cref, ty, face, source, cty, splitArrays, conns, dims);
end for;
end splitImpl2;

Expand Down
7 changes: 3 additions & 4 deletions Compiler/NFFrontEnd/NFOCConnectionGraph.mo
Expand Up @@ -172,15 +172,14 @@ algorithm
rhs = Expression.CREF(ty = ty2, cref = rhs),
source = source)
algorithm
if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs))
then
if not (ComponentRef.isDeleted(lhs) or ComponentRef.isDeleted(rhs)) then
cl1 := NFConnections.makeConnectors(lhs, ty1, source);
cl2 := NFConnections.makeConnectors(rhs, ty2, source);
for c1 in cl1 loop
c2 :: cl2 := cl2;

lhsl := Connector.split(c1);
rhsl := Connector.split(c2);
lhsl := Connector.split(c1, splitArrays = false);
rhsl := Connector.split(c2, splitArrays = false);

for cc1 in lhsl loop
cc2 :: rhsl := rhsl;
Expand Down

0 comments on commit 2f4f72e

Please sign in to comment.