Skip to content

Commit 6345c52

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Override protected with HideResult annotation, ticket:4089
This treats protected variables with annotation(HideResult=false) like public variables during model translation. In particular such parameters can be changed after model translation.
1 parent 1580918 commit 6345c52

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Compiler/BackEnd/BackendVariable.mo

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,15 +1301,23 @@ algorithm
13011301
end isOutput;
13021302

13031303
public function isProtectedVar
1304-
"author: Frenkel TUD 2013-01
1305-
Returns the DAE.Protected attribute."
1304+
"Returns the DAE.Protected attribute, overridden with HideResult annotation"
13061305
input BackendDAE.Var v;
1307-
output Boolean prot;
1306+
output Boolean hidden;
13081307
protected
1309-
Option<DAE.VariableAttributes> attr;
1308+
SCode.Annotation anno;
1309+
Absyn.Exp val;
13101310
algorithm
1311-
BackendDAE.VAR(values = attr) := v;
1312-
prot := DAEUtil.getProtectedAttr(attr);
1311+
try
1312+
BackendDAE.VAR(comment=SOME(SCode.COMMENT(annotation_ = SOME(anno)))) := v;
1313+
val := SCode.getNamedAnnotation(anno, "HideResult");
1314+
hidden := match(val)
1315+
case Absyn.BOOL(true) then true;
1316+
else false;
1317+
end match;
1318+
else
1319+
hidden := DAEUtil.getProtectedAttr(v.values);
1320+
end try;
13131321
end isProtectedVar;
13141322

13151323
public function hasVarEvaluateAnnotationOrFinal
@@ -1697,7 +1705,7 @@ end isFinalVar;
16971705

16981706
public function isFinalOrProtectedVar
16991707
input BackendDAE.Var inVar;
1700-
output Boolean b = DAEUtil.getFinalAttr(inVar.values) or DAEUtil.getProtectedAttr(inVar.values);
1708+
output Boolean b = DAEUtil.getFinalAttr(inVar.values) or isProtectedVar(inVar);
17011709
end isFinalOrProtectedVar;
17021710

17031711
public function getVariableAttributes "Returns the DAE.VariableAttributes of a variable."

0 commit comments

Comments
 (0)