@@ -702,7 +702,7 @@ algorithm
702
702
Option < list< tuple< Integer , Integer , BackendDAE . Equation >>> jac;
703
703
Values . Value ret_val,simValue,value,v,cvar,cvar2,v1,v2,v3;
704
704
Absyn . ComponentRef cr,cr_1;
705
- Integer size,resI,i,i1,i2,i3,n,curveStyle,numberOfIntervals, status;
705
+ Integer size,resI,i,i1,i2,i3,n,curveStyle,numberOfIntervals, status, access ;
706
706
Option < Integer > fmiContext, fmiInstance, fmiModelVariablesInstance; /* void* implementation: DO NOT UNBOX THE POINTER AS THAT MIGHT CHANGE IT. Just treat this as an opaque type. */
707
707
Integer fmiLogLevel, direction;
708
708
list< Integer > is;
@@ -1858,24 +1858,37 @@ algorithm
1858
1858
case (cache,_,"saveModel" ,{Values . STRING (filename),Values . CODE (Absyn . C_TYPENAME (classpath))},_)
1859
1859
algorithm
1860
1860
b := false ;
1861
- absynClass := Interactive . getPathedClassInProgram(classpath, SymbolTable . getAbsyn());
1862
- str := Dump . unparseStr(Absyn . PROGRAM ({absynClass},Absyn . TOP ()),true );
1863
- try
1864
- System . writeFile(filename, str);
1865
- b := true ;
1861
+ Values . ENUM_LITERAL (index= access) := Interactive . checkAccessAnnotationAndEncryption(classpath, SymbolTable . getAbsyn());
1862
+ if (access >= 9 ) then // i.e., The class is not encrypted.
1863
+ absynClass := Interactive . getPathedClassInProgram(classpath, SymbolTable . getAbsyn());
1864
+ str := Dump . unparseStr(Absyn . PROGRAM ({absynClass},Absyn . TOP ()),true );
1865
+ try
1866
+ System . writeFile(filename, str);
1867
+ b := true ;
1868
+ else
1869
+ Error . addMessage(Error . WRITING_FILE_ERROR , {filename});
1870
+ end try ;
1866
1871
else
1867
- Error . addMessage(Error . WRITING_FILE_ERROR , {filename});
1868
- end try ;
1872
+ Error . addMessage(Error . SAVE_ENCRYPTED_CLASS_ERROR , {});
1873
+ b := false ;
1874
+ end if ;
1869
1875
then
1870
- (cache,Values . BOOL (true ));
1876
+ (cache,Values . BOOL (b ));
1871
1877
1872
1878
case (cache,_,"save" ,{Values . CODE (Absyn . C_TYPENAME (className))},_)
1873
1879
equation
1874
- (newp,filename) = Interactive . getContainedClassAndFile(className, SymbolTable . getAbsyn());
1875
- str = Dump . unparseStr(newp);
1876
- System . writeFile(filename, str);
1880
+ Values . ENUM_LITERAL (index= access) = Interactive . checkAccessAnnotationAndEncryption(className, SymbolTable . getAbsyn());
1881
+ if (access >= 9 ) then // i.e., The class is not encrypted.
1882
+ (newp,filename) = Interactive . getContainedClassAndFile(className, SymbolTable . getAbsyn());
1883
+ str = Dump . unparseStr(newp);
1884
+ System . writeFile(filename, str);
1885
+ b = true ;
1886
+ else
1887
+ Error . addMessage(Error . SAVE_ENCRYPTED_CLASS_ERROR , {});
1888
+ b = false ;
1889
+ end if ;
1877
1890
then
1878
- (cache,Values . BOOL (true ));
1891
+ (cache,Values . BOOL (b ));
1879
1892
1880
1893
case (cache,_,"save" ,{Values . CODE (Absyn . C_TYPENAME (_))},_)
1881
1894
then (cache,Values . BOOL (false ));
@@ -1897,17 +1910,30 @@ algorithm
1897
1910
case (cache,_,"saveTotalModel" ,{Values . STRING (filename),Values . CODE (Absyn . C_TYPENAME (classpath)),
1898
1911
Values . BOOL (b1), Values . BOOL (b2)},_)
1899
1912
equation
1900
- saveTotalModel(filename, classpath, b1, b2);
1913
+ Values . ENUM_LITERAL (index= access) = Interactive . checkAccessAnnotationAndEncryption(classpath, SymbolTable . getAbsyn());
1914
+ if (access >= 9 ) then // i.e., Access.documentation
1915
+ saveTotalModel(filename, classpath, b1, b2);
1916
+ b = true ;
1917
+ else
1918
+ Error . addMessage(Error . SAVE_ENCRYPTED_CLASS_ERROR , {});
1919
+ b = false ;
1920
+ end if ;
1901
1921
then
1902
- (cache, Values . BOOL (true ));
1922
+ (cache, Values . BOOL (b ));
1903
1923
1904
1924
case (cache,_,"saveTotalModel" ,{Values . STRING (_),Values . CODE (Absyn . C_TYPENAME (_)),
1905
1925
Values . BOOL (_), Values . BOOL (_)},_)
1906
1926
then (cache, Values . BOOL (false ));
1907
1927
1908
1928
case (cache,_,"getDocumentationAnnotation" ,{Values . CODE (Absyn . C_TYPENAME (classpath))},_)
1909
1929
equation
1910
- ((str1,str2,str3)) = Interactive . getNamedAnnotation(classpath, SymbolTable . getAbsyn(), Absyn . IDENT ("Documentation" ), SOME (("" ,"" ,"" )),Interactive . getDocumentationAnnotationString);
1930
+ Values . ENUM_LITERAL (index= access) = Interactive . checkAccessAnnotationAndEncryption(classpath, SymbolTable . getAbsyn());
1931
+ if (access >= 3 ) then // i.e., Access.documentation
1932
+ ((str1,str2,str3)) = Interactive . getNamedAnnotation(classpath, SymbolTable . getAbsyn(), Absyn . IDENT ("Documentation" ), SOME (("" ,"" ,"" )),Interactive . getDocumentationAnnotationString);
1933
+ else
1934
+ Error . addMessage(Error . ACCESS_ENCRYPTED_PROTECTED_CONTENTS , {});
1935
+ ((str1,str2,str3)) = ("" , "" , "" );
1936
+ end if ;
1911
1937
then
1912
1938
(cache,ValuesUtil . makeArray({Values . STRING (str1),Values . STRING (str2),Values . STRING (str3)}));
1913
1939
@@ -2578,15 +2604,27 @@ algorithm
2578
2604
case (cache,_,"getConnectionCount" ,{Values . CODE (Absyn . C_TYPENAME (path))},_)
2579
2605
equation
2580
2606
absynClass = Interactive . getPathedClassInProgram(path, SymbolTable . getAbsyn());
2581
- n = listLength(Interactive . getConnections(absynClass));
2607
+ Values . ENUM_LITERAL (index= access) = Interactive . checkAccessAnnotationAndEncryption(path, SymbolTable . getAbsyn());
2608
+ if (access >= 4 ) then // i.e., Access.diagram
2609
+ n = listLength(Interactive . getConnections(absynClass));
2610
+ else
2611
+ Error . addMessage(Error . ACCESS_ENCRYPTED_PROTECTED_CONTENTS , {});
2612
+ n = 0 ;
2613
+ end if ;
2582
2614
then
2583
2615
(cache,Values . INTEGER (n));
2584
2616
2585
2617
case (cache,_,"getConnectionCount" ,_,_) then (cache,Values . INTEGER (0 ));
2586
2618
2587
2619
case (cache,_,"getNthConnection" ,{Values . CODE (Absyn . C_TYPENAME (path)),Values . INTEGER (n)},_)
2588
2620
equation
2589
- vals = Interactive . getNthConnection(Absyn . pathToCref(path), SymbolTable . getAbsyn(), n);
2621
+ Values . ENUM_LITERAL (index= access) = Interactive . checkAccessAnnotationAndEncryption(path, SymbolTable . getAbsyn());
2622
+ if (access >= 4 ) then // i.e., Access.diagram
2623
+ vals = Interactive . getNthConnection(Absyn . pathToCref(path), SymbolTable . getAbsyn(), n);
2624
+ else
2625
+ Error . addMessage(Error . ACCESS_ENCRYPTED_PROTECTED_CONTENTS , {});
2626
+ vals = {};
2627
+ end if ;
2590
2628
then
2591
2629
(cache,ValuesUtil . makeArray(vals));
2592
2630
@@ -7063,69 +7101,6 @@ algorithm
7063
7101
end matchcontinue;
7064
7102
end getDymolaStateAnnotationModStr;
7065
7103
7066
- protected function getAccessAnnotation
7067
- "Returns the Protection(access=) annotation of a class.
7068
- This is annotated with the annotation:
7069
- annotation(Protection(access = Access.documentation)); in the class definition"
7070
- input Absyn . Path className;
7071
- input Absyn . Program p;
7072
- output String access;
7073
- algorithm
7074
- access := match(className,p)
7075
- local
7076
- String accessStr;
7077
- case (_,_)
7078
- equation
7079
- accessStr = Interactive . getNamedAnnotation(className, p, Absyn . IDENT ("Protection" ), SOME ("" ), getAccessAnnotationString);
7080
- then
7081
- accessStr;
7082
- else "" ;
7083
- end match;
7084
- end getAccessAnnotation;
7085
-
7086
- protected function getAccessAnnotationString
7087
- "Extractor function for getAccessAnnotation"
7088
- input Option < Absyn . Modification > mod;
7089
- output String access;
7090
- algorithm
7091
- access := match (mod)
7092
- local
7093
- list< Absyn . ElementArg > arglst;
7094
-
7095
- case (SOME (Absyn . CLASSMOD (elementArgLst = arglst)))
7096
- then getAccessAnnotationString2(arglst);
7097
-
7098
- end match;
7099
- end getAccessAnnotationString;
7100
-
7101
- protected function getAccessAnnotationString2
7102
- "Extractor function for getAccessAnnotation"
7103
- input list< Absyn . ElementArg > eltArgs;
7104
- output String access;
7105
- algorithm
7106
- access := match eltArgs
7107
- local
7108
- list< Absyn . ElementArg > xs;
7109
- Absyn . ComponentRef cref;
7110
- String name;
7111
- Absyn . Info info;
7112
-
7113
- case ({}) then "" ;
7114
-
7115
- case (Absyn . MODIFICATION (path = Absyn . IDENT (name= "access" ),
7116
- modification = SOME (Absyn . CLASSMOD (eqMod= Absyn . EQMOD (exp= Absyn . CREF (cref)))))::_)
7117
- equation
7118
- name = Dump . printComponentRefStr(cref);
7119
- then name;
7120
-
7121
- case (_::xs)
7122
- equation
7123
- name = getAccessAnnotationString2(xs);
7124
- then name;
7125
-
7126
- end match;
7127
- end getAccessAnnotationString2;
7128
-
7129
7104
protected function getClassInformation
7130
7105
"author: PA
7131
7106
Returns all the possible class information.
@@ -7161,7 +7136,7 @@ algorithm
7161
7136
version := CevalScript . getPackageVersion(path, p);
7162
7137
Absyn . STRING (preferredView) := Interactive . getNamedAnnotation(path, p, Absyn . IDENT ("preferredView" ), SOME (Absyn . STRING ("" )), Interactive . getAnnotationExp);
7163
7138
isState := getDymolaStateAnnotation(path, p);
7164
- access := getAccessAnnotation(path, p);
7139
+ access := Interactive . getAccessAnnotation(path, p);
7165
7140
res_1 := Values . TUPLE ({
7166
7141
Values . STRING (res),
7167
7142
Values . STRING (cmt),
0 commit comments