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

Commit 18e3271

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Split record crefs in binding equations.
Belonging to [master]: - #2727 - OpenModelica/OpenModelica-testsuite#1053
1 parent e14b054 commit 18e3271

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Compiler/NFFrontEnd/NFExpression.mo

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4400,34 +4400,34 @@ public
44004400
end match;
44014401
end recordElement;
44024402

4403-
function splitRecord
4404-
input Expression recordExp;
4405-
output list<Expression> recordFields;
4403+
function splitRecordCref
4404+
input Expression exp;
4405+
output Expression outExp;
44064406
algorithm
4407-
recordFields := match recordExp
4407+
outExp := match exp
44084408
local
44094409
InstNode cls;
44104410
array<InstNode> comps;
44114411
ComponentRef cr, field_cr;
44124412
Type ty;
4413-
4414-
case RECORD() then recordExp.elements;
4413+
list<Expression> fields;
44154414

44164415
case CREF(ty = Type.COMPLEX(cls = cls), cref = cr)
44174416
algorithm
44184417
comps := ClassTree.getComponents(Class.classTree(InstNode.getClass(cls)));
4419-
recordFields := {};
4418+
fields := {};
44204419

44214420
for i in arrayLength(comps):-1:1 loop
44224421
ty := InstNode.getType(comps[i]);
44234422
field_cr := ComponentRef.prefixCref(comps[i], ty, {}, cr);
4424-
recordFields := CREF(ty, field_cr) :: recordFields;
4423+
fields := CREF(ty, field_cr) :: fields;
44254424
end for;
44264425
then
4427-
recordFields;
4426+
RECORD(InstNode.scopePath(cls), exp.ty, fields);
44284427

4428+
else exp;
44294429
end match;
4430-
end splitRecord;
4430+
end splitRecordCref;
44314431

44324432
function retype
44334433
input output Expression exp;

Compiler/NFFrontEnd/NFFlatten.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ algorithm
527527
binding_exp := SimplifyExp.simplify(binding_exp);
528528
end if;
529529

530+
binding_exp := Expression.splitRecordCref(binding_exp);
531+
530532
// TODO: This will probably not work so well if the binding is an array that
531533
// contains record non-literals. In that case we should probably
532534
// create an equation for each non-literal in the array, and pass the

0 commit comments

Comments
 (0)