Skip to content

Commit 5162304

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
Read the __Dymola_state annotation.
1 parent 52f0eb7 commit 5162304

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

Compiler/FrontEnd/ModelicaBuiltin.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,6 +3692,7 @@ function getClassInformation
36923692
output Boolean isDocumentationClass;
36933693
output String version;
36943694
output String preferredView;
3695+
output Boolean state;
36953696
external "builtin";
36963697
annotation(
36973698
Documentation(info="<html>

Compiler/Script/CevalScriptBackend.mo

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ algorithm
851851
case (cache,_,"getClassInformation",_,st,_)
852852
then (cache,Values.TUPLE({Values.STRING(""),Values.STRING(""),Values.BOOL(false),Values.BOOL(false),Values.BOOL(false),Values.STRING(""),
853853
Values.BOOL(false),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.ARRAY({},{0}),
854-
Values.BOOL(false),Values.BOOL(false),Values.STRING(""),Values.STRING("")}),st);
854+
Values.BOOL(false),Values.BOOL(false),Values.STRING(""),Values.STRING(""),Values.BOOL(false)}),st);
855855

856856
case (cache,_,"diffModelicaFileListings",{Values.STRING(s1),Values.STRING(s2),Values.ENUM_LITERAL(name=path)},(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
857857
algorithm
@@ -6526,6 +6526,44 @@ algorithm
65266526
System.writeFile(filename, str + str1);
65276527
end saveTotalModel;
65286528

6529+
protected function getDymolaStateAnnotation
6530+
"Returns the __Dymola_state annotation of a class.
6531+
This is annotated with the annotation:
6532+
annotation (__Dymola_state=true); in the class definition"
6533+
input Absyn.Path className;
6534+
input Absyn.Program p;
6535+
output Boolean isState;
6536+
algorithm
6537+
isState := match(className,p)
6538+
local
6539+
String stateStr;
6540+
case(_,_)
6541+
equation
6542+
stateStr = Interactive.getNamedAnnotation(className, p, Absyn.IDENT("__Dymola_state"), SOME("false"), getDymolaStateAnnotationModStr);
6543+
then
6544+
stringEq(stateStr, "true");
6545+
end match;
6546+
end getDymolaStateAnnotation;
6547+
6548+
protected function getDymolaStateAnnotationModStr
6549+
"Extractor function for getDocumentationClassAnnotation"
6550+
input Option<Absyn.Modification> mod;
6551+
output String stateStr;
6552+
algorithm
6553+
stateStr := matchcontinue(mod)
6554+
local Absyn.Exp e;
6555+
6556+
case(SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=e))))
6557+
equation
6558+
stateStr = Dump.printExpStr(e);
6559+
then
6560+
stateStr;
6561+
6562+
else "false";
6563+
6564+
end matchcontinue;
6565+
end getDymolaStateAnnotationModStr;
6566+
65296567
protected function getClassInformation
65306568
"author: PA
65316569
Returns all the possible class information.
@@ -6540,7 +6578,7 @@ protected function getClassInformation
65406578
protected
65416579
String name,file,strPartial,strFinal,strEncapsulated,res,cmt,str_readonly,str_sline,str_scol,str_eline,str_ecol,version,preferredView;
65426580
String dim_str,lastIdent;
6543-
Boolean partialPrefix,finalPrefix,encapsulatedPrefix,isReadOnly,isProtectedClass,isDocClass;
6581+
Boolean partialPrefix,finalPrefix,encapsulatedPrefix,isReadOnly,isProtectedClass,isDocClass,isState;
65446582
Absyn.Restriction restr;
65456583
Absyn.ClassDef cdef;
65466584
Integer sl,sc,el,ec;
@@ -6560,6 +6598,7 @@ algorithm
65606598
isDocClass := Interactive.getDocumentationClassAnnotation(path, p);
65616599
version := CevalScript.getPackageVersion(path, p);
65626600
Absyn.STRING(preferredView) := Interactive.getNamedAnnotation(path, p, Absyn.IDENT("preferredView"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp);
6601+
isState := getDymolaStateAnnotation(path, p);
65636602
res_1 := Values.TUPLE({
65646603
Values.STRING(res),
65656604
Values.STRING(cmt),
@@ -6576,7 +6615,8 @@ algorithm
65766615
Values.BOOL(isProtectedClass),
65776616
Values.BOOL(isDocClass),
65786617
Values.STRING(version),
6579-
Values.STRING(preferredView)
6618+
Values.STRING(preferredView),
6619+
Values.BOOL(isState)
65806620
});
65816621
end getClassInformation;
65826622

0 commit comments

Comments
 (0)