Skip to content

Commit 901d152

Browse files
ptaeuberOpenModelica-Hudson
authored andcommitted
Use qualified component names in hideResult attribute
Fix for ticket:4089
1 parent 350333d commit 901d152

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

Compiler/BackEnd/BackendDAECreate.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ algorithm
766766
dae_var_attr = DAEUtil.setProtectedAttr(dae_var_attr, b);
767767
dae_var_attr = setMinMaxFromEnumeration(t, dae_var_attr);
768768
ts = BackendDAEUtil.setTearingSelectAttribute(comment);
769-
hideResult = BackendDAEUtil.setHideResultAttribute(comment, b);
769+
hideResult = BackendDAEUtil.setHideResultAttribute(comment, b, name);
770770
then
771771
(BackendDAE.VAR(name, kind_1, dir, prl, tp, NONE(), NONE(), dims, source, dae_var_attr, ts, hideResult, comment, ct, DAEUtil.toDAEInnerOuter(io), false));
772772
end match;
@@ -831,7 +831,7 @@ algorithm
831831
eqLst = buildAssertAlgorithms({},source,assrtEqIn);
832832
// building an algorithm of the assert
833833
ts = NONE();
834-
hideResult = BackendDAEUtil.setHideResultAttribute(comment, b);
834+
hideResult = BackendDAEUtil.setHideResultAttribute(comment, b, name);
835835
then
836836
(BackendDAE.VAR(name, kind_1, dir, prl, tp, bind, NONE(), dims, source, dae_var_attr, ts, hideResult, comment, ct, DAEUtil.toDAEInnerOuter(io), false), iInlineHT, eqLst);
837837

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,16 +1240,27 @@ public function setHideResultAttribute
12401240
See Modelica Spec 3.3, section 18.3"
12411241
input Option<SCode.Comment> comment;
12421242
input Boolean isProtected;
1243+
input DAE.ComponentRef inCref;
12431244
output DAE.Exp hideResult;
12441245
protected
12451246
SCode.Annotation ann;
12461247
Absyn.Exp val;
1247-
String ts_str;
1248+
DAE.ComponentRef crefRoot;
12481249
algorithm
12491250
try
12501251
SOME(SCode.COMMENT(annotation_=SOME(ann))) := comment;
12511252
val := SCode.getNamedAnnotation(ann, "HideResult");
12521253
hideResult := Expression.fromAbsynExp(val);
1254+
1255+
hideResult := match(inCref)
1256+
case(DAE.CREF_QUAL())
1257+
equation
1258+
(crefRoot,_) = ComponentReference.splitCrefLast(inCref);
1259+
hideResult = Expression.traverseExpBottomUp(hideResult, ComponentReference.joinCrefsExp, crefRoot);
1260+
then hideResult;
1261+
else hideResult;
1262+
end match;
1263+
12531264
else
12541265
hideResult := DAE.BCONST(isProtected);
12551266
end try;

Compiler/FrontEnd/ComponentReference.mo

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,10 +2236,8 @@ algorithm
22362236
end appendStringLastIdent;
22372237

22382238
public function joinCrefs
2239-
"Join two component references by concatenating them.
2240-
2239+
"Joins two component references by concatenating them.
22412240
alternative names: crefAppend
2242-
22432241
"
22442242
input DAE.ComponentRef inComponentRef1 " first part of the new componentref";
22452243
input DAE.ComponentRef inComponentRef2 " last part of the new componentref";
@@ -2289,6 +2287,24 @@ algorithm
22892287
end match;
22902288
end joinCrefsR;
22912289

2290+
public function joinCrefsExp
2291+
"Like joinCrefs but first argument is an expression"
2292+
input output DAE.Exp exp;
2293+
input output DAE.ComponentRef cref;
2294+
algorithm
2295+
exp := match (exp)
2296+
local
2297+
DAE.ComponentRef cr;
2298+
DAE.Type tp;
2299+
case (DAE.CREF(cr, tp))
2300+
equation
2301+
cr = joinCrefs(cref, cr);
2302+
then
2303+
DAE.CREF(cr,tp);
2304+
else exp;
2305+
end match;
2306+
end joinCrefsExp;
2307+
22922308
public function subscriptCref
22932309
"The subscriptCref function adds a subscript to the ComponentRef
22942310
For instance a.b with subscript 10 becomes a.b[10] and c.d[1,2]

0 commit comments

Comments
 (0)