Skip to content

Commit

Permalink
Make getAnnotationNamedModifiers not return bad data
Browse files Browse the repository at this point in the history
If the annotation does not exist, use the error buffer to return the
message instead of saying an annotation with a weird name exists.
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Oct 3, 2017
1 parent 702501a commit 29e8121
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Compiler/Script/CevalScriptBackend.mo
Expand Up @@ -756,6 +756,7 @@ algorithm
list<SimpleModelicaParser.ParseTree> parseTree1, parseTree2;
list<tuple<Diff, list<Token>>> diffs;
list<tuple<Diff, list<SimpleModelicaParser.ParseTree>>> treeDiffs;
SourceInfo info;

case (cache,_,"setClassComment",{Values.CODE(Absyn.C_TYPENAME(path)),Values.STRING(str)},st as GlobalScript.SYMBOLTABLE(ast=p),_)
equation
Expand Down Expand Up @@ -2039,9 +2040,9 @@ algorithm

case (cache,_,"getAnnotationNamedModifiers",{Values.CODE(Absyn.C_TYPENAME(classpath)),Values.STRING(annotationname)},st as GlobalScript.SYMBOLTABLE(ast=p),_)
equation
Absyn.CLASS(_,_,_,_,_,cdef,_) =Interactive.getPathedClassInProgram(classpath,p);
Absyn.CLASS(body=cdef,info=info) =Interactive.getPathedClassInProgram(classpath,p);
annlst= getAnnotationList(cdef);
modifiernamelst=getElementArgsModifiers(annlst,annotationname);
modifiernamelst=getElementArgsModifiers(annlst,annotationname,Absyn.pathString(classpath),info);
v1 = ValuesUtil.makeArray(List.map(modifiernamelst, ValuesUtil.makeString));
then
(cache,v1,st);
Expand Down Expand Up @@ -7854,6 +7855,8 @@ function getElementArgsModifiers
"@author arun Helper function which parses list of elementargs,annotationname returns the list of modifiers name in the annotation"
input list<Absyn.ElementArg> inargs;
input String instring;
input String inClass;
input SourceInfo info;
output list<String> outstring;
algorithm
outstring:=match(inargs,instring)
Expand All @@ -7873,9 +7876,12 @@ algorithm

case((_::eltarglst),name1)
then
getElementArgsModifiers(eltarglst,name1);
getElementArgsModifiers(eltarglst,name1,inClass,info);

case({},_) then {"The searched annotation name not found"};
case ({},_)
algorithm
Error.addSourceMessage(Error.CLASS_ANNOTATION_DOES_NOT_EXIST, {instring, inClass}, info);
then {};
end match;
end getElementArgsModifiers;

Expand Down

0 comments on commit 29e8121

Please sign in to comment.