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

Commit a185205

Browse files
perostOpenModelica-Hudson
authored andcommitted
Improve inlining to handle Complex constructor.
- Make a binding from the record field bindings for record outputs with no explicit binding. Belonging to [master]: - #2471
1 parent e8395d7 commit a185205

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Compiler/FrontEnd/Inline.mo

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ algorithm
11331133

11341134
case DAE.VAR(componentRef=cr,direction=DAE.OUTPUT(), binding=binding)
11351135
equation
1136+
binding = makeComplexBinding(binding, elt.ty);
11361137
oRepl = addOptBindingReplacements(cr,binding,oRepl);
11371138
oOutputs = cr :: oOutputs;
11381139
then ();
@@ -1168,6 +1169,46 @@ algorithm
11681169

11691170
end getFunctionInputsOutputBody;
11701171

1172+
function makeComplexBinding
1173+
"Creates a record binding from the given type if the given binding is empty."
1174+
input output Option<DAE.Exp> binding;
1175+
input DAE.Type ty;
1176+
algorithm
1177+
binding := match (binding, ty)
1178+
local
1179+
list<DAE.Exp> expl;
1180+
list<String> strl;
1181+
DAE.Exp exp;
1182+
1183+
case (NONE(), DAE.Type.T_COMPLEX())
1184+
algorithm
1185+
expl := {};
1186+
strl := {};
1187+
1188+
for var in listReverse(ty.varLst) loop
1189+
() := match var
1190+
case DAE.Var.TYPES_VAR(binding = DAE.Binding.EQBOUND(exp = exp))
1191+
algorithm
1192+
expl := exp :: expl;
1193+
strl := var.name :: strl;
1194+
then
1195+
();
1196+
1197+
else
1198+
algorithm
1199+
return;
1200+
then
1201+
();
1202+
end match;
1203+
end for;
1204+
1205+
then
1206+
SOME(DAE.Exp.RECORD(ClassInf.getStateName(ty.complexClassType), expl, strl, ty));
1207+
1208+
else binding;
1209+
end match;
1210+
end makeComplexBinding;
1211+
11711212
protected function addOptBindingReplacements
11721213
input DAE.ComponentRef cr;
11731214
input Option<DAE.Exp> binding;

0 commit comments

Comments
 (0)