Skip to content

Commit

Permalink
- dump class annotations in SCodeDumpTpl.tpl
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17305 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 19, 2013
1 parent 57740a6 commit 135c8dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
55 changes: 28 additions & 27 deletions Compiler/Template/SCodeDumpTpl.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ match classDef
case PARTS(__) then '<%\n%>'
end dumpClassDefSpacing;

template dumpCommentSpacing(Option<SCode.Comment> comment)
::=
match comment
case SOME(COMMENT(annotation_ = NONE())) then ""
else '<%\n%>'
end dumpCommentSpacing;

template dumpElement(SCode.Element element, String each)
::=
match element
Expand Down Expand Up @@ -133,24 +126,21 @@ match class
let res_str = dumpRestriction(restriction)
let prefixes_str = '<%prefix_str%><%enc_str%><%partial_str%><%res_str%>'
let cdef_str = dumpClassDef(classDef)
let header_str = dumpClassHeader(classDef, name)
let footer_str = dumpClassFooter(classDef, cdef_str, name)
//let cmt_str = dumpClassComment(classDef)
//let cmt2_str = if cdef_str then
// if cmt_str then
// '<%\n%> <%cmt_str%>'
// else ""
// else cmt_str
let cmt_str = dumpClassComment(cmt)
let ann_str = dumpClassAnnotation(cmt)
let header_str = dumpClassHeader(classDef, name, cmt_str)
let footer_str = dumpClassFooter(classDef, cdef_str, name, cmt_str, ann_str)
<<
<%prefixes_str%> <%header_str%> <%footer_str%>
>>
end dumpClass;

template dumpClassHeader(SCode.ClassDef classDef, String name)
template dumpClassHeader(SCode.ClassDef classDef, String name, String cmt)
::=
match classDef
case CLASS_EXTENDS(__) then 'extends <%name%>'
else name
case CLASS_EXTENDS(__) then 'extends <%name%> <%cmt%>'
case PARTS(__) then '<%name%> <%cmt%>'
else '<%name%>'
end dumpClassHeader;

template dumpClassDef(SCode.ClassDef classDef)
Expand All @@ -163,7 +153,6 @@ match classDef
let nal_str = dumpAlgorithmSections(normalAlgorithmLst, "algorithm")
let ial_str = dumpAlgorithmSections(initialAlgorithmLst, "initial algorithm")
let extdecl_str = dumpExternalDeclOpt(externalDecl)
//let cmt_str = dumpClassComment(comment)
let cdef_str =
<<
<%el_str%>
Expand Down Expand Up @@ -199,31 +188,41 @@ match classDef
else errorMsg("SCodeDump.dumpClassDef: Unknown class definition.")
end dumpClassDef;

template dumpClassFooter(SCode.ClassDef classDef, String cdefStr, String name)
template dumpClassFooter(SCode.ClassDef classDef, String cdefStr, String name, String cmt, String ann)
::=
match classDef
case DERIVED(__) then cdefStr
case ENUMERATION(__) then cdefStr
case DERIVED(__) then '<%cdefStr%><%cmt%><%ann%>'
case ENUMERATION(__) then '<%cdefStr%><%cmt%><%ann%>'
case PDER(__) then cdefStr
else
case _ then
let annstr = if ann then '<%ann%>; ' else ''
if cdefStr then
<<

<%cdefStr%>
<%annstr%>
end <%name%>
>>
else
<<
end <%name%>
<%annstr%>end <%name%>
>>
end dumpClassFooter;

template dumpClassComment(Option<SCode.Comment> comment)
template dumpClassComment(SCode.Comment comment)
::=
if Config.showAnnotations() then
match comment
case SOME(cmt as COMMENT(__)) then dumpComment(cmt)
case COMMENT(__) then dumpCommentStr(comment)
end dumpClassComment;

template dumpClassAnnotation(SCode.Comment comment)
::=
if Config.showAnnotations() then
match comment
case COMMENT(__) then dumpAnnotationOpt(annotation_)
end dumpClassAnnotation;

template dumpComponent(SCode.Element component, String each)
::=
match component
Expand Down Expand Up @@ -773,7 +772,9 @@ if Config.showAnnotations() then
end dumpComment;

template dumpCommentStr(Option<String> comment)
::= match comment case SOME(cmt) then ' "<%cmt%>"'
::= match comment
case SOME(cmt) then ' "<%cmt%>"'
else ''
end dumpCommentStr;

template errorMsg(String errMessage)
Expand Down
1 change: 1 addition & 0 deletions Compiler/Template/SCodeTV.mo
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ package SCode
Partial partialPrefix;
Restriction restriction;
ClassDef classDef;
Comment cmt;
Absyn.Info info;
end CLASS;

Expand Down

0 comments on commit 135c8dd

Please sign in to comment.