Doxygen
Loading...
Searching...
No Matches
FlowChart Class Reference

#include <src/vhdldocgen.h>

Collaboration diagram for FlowChart:

Public Types

enum  nodeTypes {
  IF_NO = 1<<1 , ELSIF_NO = 1<<2 , ELSE_NO = 1<<3 , CASE_NO = 1<<4 ,
  WHEN_NO = 1<<5 , EXIT_NO = 1<<6 , END_NO = 1<<7 , TEXT_NO = 1<<8 ,
  START_NO = 1<<9 , ENDIF_NO = 1<<10 , FOR_NO = 1<<11 , WHILE_NO = 1<<12 ,
  END_LOOP = 1<<13 , END_CASE = 1<<14 , VARIABLE_NO = 1<<15 , RETURN_NO = 1<<16 ,
  LOOP_NO = 1<<17 , NEXT_NO = 1<<18 , EMPTY_NO = 1<<19 , COMMENT_NO = 1<<20 ,
  BEGIN_NO = 1<<21
}

Public Member Functions

 FlowChart (int typ, const QCString &t, const QCString &ex, const QCString &label=QCString())

Static Public Member Functions

static void createSVG ()
static void startDot (TextStream &t)
static void endDot (TextStream &t)
static void codify (TextStream &t, const QCString &str)
static void writeShape (TextStream &t, const FlowChart &fl)
static void writeEdge (TextStream &t, int fl_from, int fl_to, int i, bool bFrom=FALSE, bool bTo=FALSE)
static void writeEdge (TextStream &t, const FlowChart &fl_from, const FlowChart &fl_to, int i)
static void writeFlowLinks (TextStream &t)
static QCString getNodeName (int n)
static void colTextNodes ()
static size_t getNextIfLink (const FlowChart &, size_t)
static size_t getNextNode (size_t index, int stamp)
static size_t findNode (size_t index, int stamp, int type)
static size_t findNode (size_t index, int type)
static size_t findNextLoop (size_t j, int stamp)
static size_t findPrevLoop (size_t j, int stamp, bool endif=FALSE)
static size_t findLabel (size_t j, const QCString &)
static void delFlowList ()
static const char * getNodeType (int c)
static void addFlowChart (int type, const QCString &text, const QCString &exp, const QCString &label=QCString())
static void moveToPrevLevel ()
static int getTimeStamp ()
static void writeFlowChart ()
static void alignFuncProc (QCString &q, const ArgumentList &al, bool isFunc)
static QCString convertNameToFileName ()
static void printNode (const FlowChart &n)
static void printFlowTree ()
static void buildCommentNodes (TextStream &t)
static void alignCommentNode (TextStream &t, QCString com)
static void printUmlTree ()
static QCString printPlantUmlNode (const FlowChart &flo, bool, bool)

Private Attributes

int id = 0
int stamp = 0
int type = 0
int line = 0
QCString label
QCString text
QCString exp

Detailed Description

Definition at line 238 of file vhdldocgen.h.

Member Enumeration Documentation

◆ nodeTypes

Enumerator
IF_NO 
ELSIF_NO 
ELSE_NO 
CASE_NO 
WHEN_NO 
EXIT_NO 
END_NO 
TEXT_NO 
START_NO 
ENDIF_NO 
FOR_NO 
WHILE_NO 
END_LOOP 
END_CASE 
VARIABLE_NO 
RETURN_NO 
LOOP_NO 
NEXT_NO 
EMPTY_NO 
COMMENT_NO 
BEGIN_NO 

Definition at line 241 of file vhdldocgen.h.

241 {
242 IF_NO = 1<<1,
243 ELSIF_NO = 1<<2,
244 ELSE_NO = 1<<3,
245 CASE_NO = 1<<4,
246 WHEN_NO = 1<<5,
247 EXIT_NO = 1<<6,
248 END_NO = 1<<7,
249 TEXT_NO = 1<<8,
250 START_NO = 1<<9,
251 ENDIF_NO = 1<<10,
252 FOR_NO = 1<<11,
253 WHILE_NO = 1<<12,
254 END_LOOP = 1<<13,
255 END_CASE = 1<<14,
256 VARIABLE_NO = 1<<15,
257 RETURN_NO = 1<<16,
258 LOOP_NO = 1<<17,
259 NEXT_NO = 1<<18,
260 EMPTY_NO = 1<<19,
261 COMMENT_NO = 1<<20,
262 BEGIN_NO = 1<<21
263 };

Constructor & Destructor Documentation

◆ FlowChart()

FlowChart::FlowChart ( int typ,
const QCString & t,
const QCString & ex,
const QCString & label = QCString() )

Definition at line 2876 of file vhdldocgen.cpp.

2877{
2879
2880 if (typ & STARTL)
2881 {
2882 ifcounter++;
2883 }
2884
2885 text=t;
2886 exp=ex;
2887 type=typ;
2888 label=lab;
2889
2890 if (typ & (ELSE_NO | ELSIF_NO))
2891 {
2892 stamp--;
2893 }
2894
2895 if (typ & (START_NO | END_NO | VARIABLE_NO))
2896 {
2897 stamp=0;
2898 }
2899
2900 id=nodeCounter++;
2901}
QCString label
Definition vhdldocgen.h:311
QCString text
Definition vhdldocgen.h:312
QCString exp
Definition vhdldocgen.h:313
static int nodeCounter
static int ifcounter
#define STARTL

References ELSE_NO, ELSIF_NO, END_NO, exp, ifcounter, label, nodeCounter, stamp, START_NO, STARTL, text, type, and VARIABLE_NO.

Referenced by addFlowChart(), buildCommentNodes(), colTextNodes(), findLabel(), findNextLoop(), findNode(), findPrevLoop(), getNextIfLink(), getNextNode(), getTimeStamp(), printNode(), printPlantUmlNode(), printUmlTree(), writeEdge(), writeFlowLinks(), and writeShape().

Member Function Documentation

◆ addFlowChart()

void FlowChart::addFlowChart ( int type,
const QCString & text,
const QCString & exp,
const QCString & label = QCString() )
static

Definition at line 2903 of file vhdldocgen.cpp.

2904{
2905 if (!VhdlDocGen::getFlowMember()) return;
2906
2907 QCString typeString(text);
2908 QCString expression(exp);
2909
2910
2911 if (!text.isEmpty())
2912 {
2913 typeString=substitute(typeString,";","\n");
2914 }
2915
2916 if (!exp.isEmpty())
2917 {
2918 expression=substitute(expression,"\"","\\\"");
2919 }
2920
2921 if (type & VARIABLE_NO)
2922 {
2923 // Ignore the empty section of the VHDL variable definition.
2924 // This is section between `process` and `begin` keywords, where any source text is missing, probably a bug in the VHDL source parser.
2925 if(text.isEmpty()) return;
2926
2927 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2928 flowList.front().line=1; // TODO: use getLine(); of the parser
2929 }
2930 else if (type & START_NO)
2931 {
2932 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2933 flowList.front().line=1; // TODO: use getLine(); of the parser
2934 }
2935 else
2936 {
2937 flowList.emplace_back(type,typeString,expression,label);
2938 flowList.back().line=1; // TODO: use getLine(); of the parser
2939 }
2940}
FlowChart(int typ, const QCString &t, const QCString &ex, const QCString &label=QCString())
static const MemberDef * getFlowMember()
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:482
std::vector< FlowChart > flowList

References exp, FlowChart(), flowList, VhdlDocGen::getFlowMember(), label, START_NO, substitute(), text, type, and VARIABLE_NO.

Referenced by VHDLOutlineParser::createFlow(), and VHDLOutlineParser::handleFlowComment().

◆ alignCommentNode()

void FlowChart::alignCommentNode ( TextStream & t,
QCString com )
static

Definition at line 2733 of file vhdldocgen.cpp.

2734{
2735 size_t max=0;
2736 QCString s;
2737 StringVector ql=split(com.str(),"\n");
2738 for (size_t j=0;j<ql.size();j++)
2739 {
2740 s=ql[j];
2741 if (max<s.length()) max=s.length();
2742 }
2743
2744 s=ql.back();
2745 int diff=static_cast<int>(max-s.length());
2746
2747 QCString n;
2748 if (diff>0)
2749 {
2750 n.fill(' ',2*diff);
2751 n.append(".");
2752 s+=n;
2753 ql.pop_back();
2754 ql.push_back(s.str());
2755 }
2756
2757 for (size_t j=0;j<ql.size();j++)
2758 {
2759 s=ql[j];
2760 if (j<ql.size()-1)
2761 {
2762 s+="\n";
2763 }
2764 FlowChart::codify(t,s);
2765 }
2766}
static void codify(TextStream &t, const QCString &str)
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString fill(char c, int len=-1)
Fills a string with a predefined character.
Definition qcstring.h:193
const std::string & str() const
Definition qcstring.h:552
QCString & append(char c)
Definition qcstring.h:396
std::vector< std::string > StringVector
Definition containers.h:33
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition util.cpp:6555

References QCString::append(), codify(), QCString::fill(), QCString::length(), split(), and QCString::str().

Referenced by buildCommentNodes(), and writeShape().

◆ alignFuncProc()

void FlowChart::alignFuncProc ( QCString & q,
const ArgumentList & al,
bool isFunc )
static

Definition at line 3294 of file vhdldocgen.cpp.

3295{
3296 size_t index=al.size();
3297 if (index==0) return;
3298
3299 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3300 QCString prev,temp;
3301 prev.fill(' ',static_cast<int>(len)+1);
3302
3303 q+="\n";
3304 for (const Argument &arg : al)
3305 {
3306 QCString attl=arg.defval+" ";
3307 attl+=arg.name+" ";
3308
3309 if (!isFunc)
3310 {
3311 attl+=arg.attrib+" ";
3312 }
3313 else
3314 {
3315 attl+=" in ";
3316 }
3317 attl+=arg.type;
3318 if (--index) attl+=",\n"; else attl+="\n";
3319
3320 attl.prepend(prev);
3321 temp+=attl;
3322 }
3323
3324 q+=temp;
3325}
size_t size() const
Definition arguments.h:100
virtual const QCString & name() const =0
QCString & prepend(const char *s)
Definition qcstring.h:422

References QCString::fill(), VhdlDocGen::getFlowMember(), QCString::length(), Definition::name(), QCString::prepend(), and ArgumentList::size().

Referenced by VHDLOutlineParser::createFlow().

◆ buildCommentNodes()

void FlowChart::buildCommentNodes ( TextStream & t)
static

Definition at line 2769 of file vhdldocgen.cpp.

2770{
2771 size_t size=flowList.size();
2772 bool begin=false;
2773
2774 if (size>0)
2775 {
2776 for (uint32_t j=0;j < size-1 ;j++)
2777 {
2778 FlowChart &fll = flowList[j];
2779 if (fll.type & COMMENT_NO)
2780 {
2781 FlowChart &to=flowList[j+1];
2782 if (to.type & COMMENT_NO)
2783 {
2784 to.label = fll.label+"\n"+to.label;
2785 flowList.erase(flowList.begin()+j);
2786 if (size>0) size--;
2787 if (j>0) j--;
2788 }
2789 }
2790 }// for
2791 }
2792
2793 for (size_t j=0;j <flowList.size() ;j++)
2794 {
2795 const FlowChart &fll=flowList[j];
2796
2797 if (fll.type & BEGIN_NO)
2798 {
2799 begin = true;
2800 continue;
2801 }
2802
2803 if (fll.type & COMMENT_NO)
2804 {
2805 const FlowChart *to = nullptr;
2806 if (!begin)
2807 {
2808 // comment between function/process .. begin is linked to start node
2809 to = &flowList[0];
2810 }
2811 else if (j>0 && flowList[j-1].line==fll.line)
2812 {
2813 to = &flowList[j-1];
2814 }
2815 else
2816 {
2817 to = &flowList[j+1];
2818 }
2819 t << getNodeName(fll.id);
2820 t << "[shape=none, label=<\n";
2821 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
2822 t << "<TR><TD BGCOLOR=\"";
2823 t << flowCol.comment;
2824 t << "\" > ";
2825
2827 t << " </TD></TR></TABLE>>];";
2828 writeEdge(t,fll.id,to->id,2);
2829 }
2830 }// for
2831
2832 // delete comment nodes;
2833 size=flowList.size();
2834 for (size_t j=0; j<size; j++)
2835 {
2836 FlowChart &fll=flowList[j];
2837 if (fll.type & (COMMENT_NO | BEGIN_NO))
2838 {
2839 size_t diff=FLOWLEN-(j+1);
2840
2841 if ((fll.type & COMMENT_NO) && diff > 1)
2842 {
2843 flowList[j+1].label = fll.label;
2844 }
2845
2846 flowList.erase(flowList.begin()+j);
2847
2848 if (size>0) size--;
2849 if (j>0) j--;
2850 }
2851 }// for;
2852}
static void writeEdge(TextStream &t, int fl_from, int fl_to, int i, bool bFrom=FALSE, bool bTo=FALSE)
static QCString getNodeName(int n)
static void alignCommentNode(TextStream &t, QCString com)
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:170
#define FLOWLEN
static struct @262143045100337216022015277174266365223104043217 flowCol

References alignCommentNode(), begin(), BEGIN_NO, COMMENT_NO, FlowChart(), flowCol, FLOWLEN, flowList, getNodeName(), id, label, line, type, and writeEdge().

Referenced by writeFlowChart().

◆ codify()

void FlowChart::codify ( TextStream & t,
const QCString & str )
static

Definition at line 2854 of file vhdldocgen.cpp.

2855{
2856 if (!str.isEmpty())
2857 {
2858 const char *p=str.data();
2859 while (*p)
2860 {
2861 char c=*p++;
2862 switch(c)
2863 {
2864 case '<': t << "&lt;"; break;
2865 case '>': t << "&gt;"; break;
2866 case '&': t << "&amp;"; break;
2867 case '\'': t << "&#39;"; break;
2868 case '"': t << "&quot;"; break;
2869 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2870 default: t << c; break;
2871 }
2872 }
2873 }
2874}//codify
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172

References QCString::data(), and QCString::isEmpty().

Referenced by alignCommentNode().

◆ colTextNodes()

void FlowChart::colTextNodes ( )
static

Definition at line 2669 of file vhdldocgen.cpp.

2670{
2671 FlowChart *flno = nullptr;
2672 bool found=FALSE;
2673 for (size_t j=0;j<flowList.size();j++)
2674 {
2675 FlowChart &flo = flowList[j];
2676 if (flo.type&TEXT_NO)
2677 {
2678 if (!found)
2679 {
2680 flno=&flo;
2681 }
2682 else
2683 {
2684 flno->text+=flo.text;
2685 flowList.erase(flowList.begin()+j);
2686 if (j>0) j=j-1;
2687 }
2688 found=TRUE;
2689 }
2690 else
2691 {
2692 found=FALSE;
2693 }
2694 }
2695
2696 // find if..endif without text
2697 // if..elseif without text
2698 if (!flowList.empty())
2699 {
2700 for (size_t j=0;j<flowList.size()-1;j++)
2701 {
2702 const FlowChart &flo = flowList[j];
2703 int kind = flo.type;
2704 if ( (kind & IFF) || (flo.type & ELSE_NO))
2705 {
2706 const FlowChart &ftemp = flowList[j+1];
2707 if (ftemp.type & EMPTY)
2708 {
2709 FlowChart fc(TEXT_NO,"empty ",QCString());
2710 fc.stamp = flo.stamp;
2711 flowList.insert(flowList.begin()+j+1,fc);
2712 }
2713 }
2714 }
2715 }
2716
2717}// colTextNode
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
#define IFF
#define EMPTY

References ELSE_NO, EMPTY, FALSE, FlowChart(), flowList, IFF, stamp, text, TEXT_NO, TRUE, and type.

Referenced by writeFlowChart().

◆ convertNameToFileName()

QCString FlowChart::convertNameToFileName ( )
static

Definition at line 3031 of file vhdldocgen.cpp.

3032{
3033 return VhdlDocGen::getFlowMember()->name();
3034}

References VhdlDocGen::getFlowMember(), and Definition::name().

Referenced by createSVG(), HtmlDocVisitor::operator()(), and printUmlTree().

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3065 of file vhdldocgen.cpp.

3066{
3067 QCString qcs("/");
3068 QCString ov = Config_getString(HTML_OUTPUT);
3069
3071
3072 //const MemberDef *m=VhdlDocGen::getFlowMember();
3073 //if (m)
3074 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),TRUE),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3075
3076 QCString dir=" -o \""+ov+qcs+"\"";
3077 ov+="/flow_design.dot";
3078
3079 QCString vlargs="-Tsvg \""+ov+"\" "+dir ;
3080
3082 {
3083 err("could not create dot file\n");
3084 }
3085}
static QCString verifiedDotPath
Definition doxygen.h:139
static QCString convertNameToFileName()
#define Config_getString(name)
Definition config.h:32
#define err(fmt,...)
Definition message.h:127
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106

References Config_getString, convertNameToFileName(), err, Portable::system(), and Doxygen::verifiedDotPath.

Referenced by writeFlowChart().

◆ delFlowList()

void FlowChart::delFlowList ( )
static

Definition at line 2726 of file vhdldocgen.cpp.

2727{
2728 ifcounter=0;
2729 nodeCounter=0;
2730 flowList.clear();
2731}

References flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3095 of file vhdldocgen.cpp.

3096{
3097 t << " } \n";
3098}

Referenced by writeFlowChart().

◆ findLabel()

size_t FlowChart::findLabel ( size_t j,
const QCString & label )
static

Definition at line 3367 of file vhdldocgen.cpp.

3368{
3369 for (size_t j=index;j>0;j--)
3370 {
3371 const FlowChart &flo = flowList[j];
3372 if ((flo.type & LOOP) && !flo.label.isEmpty() && qstricmp(flo.label,label)==0)
3373 {
3374 return j;
3375 }
3376 }
3377 err("could not find label: '{}'\n",label);
3378 return 0;
3379}
int qstricmp(const char *s1, const char *s2)
Definition qcstring.cpp:447
#define LOOP

References err, FlowChart(), flowList, QCString::isEmpty(), label, LOOP, qstricmp(), and type.

Referenced by writeFlowLinks().

◆ findNextLoop()

size_t FlowChart::findNextLoop ( size_t j,
int stamp )
static

Definition at line 3327 of file vhdldocgen.cpp.

3328{
3329 for (size_t j=index+1; j<flowList.size(); j++)
3330 {
3331 const FlowChart &flo = flowList[j];
3332 if (flo.stamp==stamp)
3333 {
3334 continue;
3335 }
3336 if (flo.type&END_LOOP)
3337 {
3338 return j;
3339 }
3340 }
3341 return flowList.size()-1;
3342}

References END_LOOP, FlowChart(), flowList, stamp, and type.

Referenced by writeFlowLinks().

◆ findNode() [1/2]

size_t FlowChart::findNode ( size_t index,
int stamp,
int type )
static

Definition at line 3381 of file vhdldocgen.cpp.

3382{
3383 for (size_t j=index+1; j<flowList.size(); j++)
3384 {
3385 const FlowChart &flo = flowList[j];
3386 if (flo.type==type && flo.stamp==stamp)
3387 {
3388 return j;
3389 }
3390 }
3391 return 0;
3392}// findNode

References FlowChart(), flowList, stamp, and type.

Referenced by getNextIfLink(), getNextNode(), and writeFlowLinks().

◆ findNode() [2/2]

size_t FlowChart::findNode ( size_t index,
int type )
static

References exp, FALSE, label, stamp, text, and type.

◆ findPrevLoop()

size_t FlowChart::findPrevLoop ( size_t j,
int stamp,
bool endif = FALSE )
static

Definition at line 3344 of file vhdldocgen.cpp.

3345{
3346 for (size_t j=index;j>0;j--)
3347 {
3348 const FlowChart &flo = flowList[j];
3349 if (flo.type & LOOP)
3350 {
3351 if (flo.stamp==stamp && endif)
3352 {
3353 return j;
3354 }
3355 else
3356 {
3357 if (flo.stamp<stamp)
3358 {
3359 return j;
3360 }
3361 }
3362 }
3363 }
3364 return flowList.size()-1;
3365}

References FlowChart(), flowList, LOOP, stamp, and type.

Referenced by writeFlowLinks().

◆ getNextIfLink()

size_t FlowChart::getNextIfLink ( const FlowChart & fl,
size_t index )
static

Definition at line 3435 of file vhdldocgen.cpp.

3436{
3437 int stamp=fl.stamp;
3438 size_t start = index+1;
3439 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3440 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3441 size_t elseNode = findNode(start,stamp,ELSE_NO);
3442
3443 if (elseifNode>0 && elseifNode<endifNode)
3444 {
3445 return elseifNode;
3446 }
3447
3448 if (elseNode>0 && elseNode<endifNode)
3449 {
3450 return elseNode+1;
3451 }
3452
3453 stamp=flowList[endifNode].stamp;
3454 return getNextNode(endifNode,stamp);
3455}
static size_t getNextNode(size_t index, int stamp)
static size_t findNode(size_t index, int stamp, int type)

References ELSE_NO, ELSIF_NO, ENDIF_NO, findNode(), FlowChart(), flowList, getNextNode(), and stamp.

Referenced by writeFlowLinks().

◆ getNextNode()

size_t FlowChart::getNextNode ( size_t index,
int stamp )
static

Definition at line 3394 of file vhdldocgen.cpp.

3395{
3396 for (size_t j=index+1; j<flowList.size(); j++)
3397 {
3398 const FlowChart &flo = flowList[j];
3399 int kind = flo.type;
3400 int s = flo.stamp;
3401 if (s>stamp)
3402 {
3403 continue;
3404 }
3405 if (kind & ENDIF_NO)
3406 {
3407 if (s<stamp && stamp>0)
3408 {
3409 stamp--;
3410 continue;
3411 }
3412 }
3413 if (kind & (ELSE_NO | ELSIF_NO))
3414 {
3415 if (s<stamp && stamp>0)
3416 {
3417 stamp--;
3418 }
3419 j=findNode(j,stamp,ENDIF_NO);
3420 continue;
3421 }
3422 if (kind & WHEN_NO)
3423 {
3424 if (s<stamp && stamp>0)
3425 {
3426 stamp--;
3427 }
3428 return findNode(j,stamp-1,END_CASE);
3429 }
3430 return j;
3431 }
3432 return FLOWLEN;
3433}

References ELSE_NO, ELSIF_NO, END_CASE, ENDIF_NO, findNode(), FlowChart(), FLOWLEN, flowList, stamp, type, and WHEN_NO.

Referenced by getNextIfLink(), and writeFlowLinks().

◆ getNodeName()

QCString FlowChart::getNodeName ( int n)
static

Definition at line 2719 of file vhdldocgen.cpp.

2720{
2721 QCString node;
2722 node.setNum(n);
2723 return node.prepend("node");
2724}
QCString & setNum(short n)
Definition qcstring.h:459

References QCString::prepend(), and QCString::setNum().

Referenced by buildCommentNodes(), writeEdge(), writeEdge(), and writeShape().

◆ getNodeType()

const char * FlowChart::getNodeType ( int c)
static

Definition at line 3036 of file vhdldocgen.cpp.

3037{
3038 switch(c)
3039 {
3040 case IF_NO: return "if ";
3041 case ELSIF_NO: return "elsif ";
3042 case ELSE_NO: return "else ";
3043 case CASE_NO: return "case ";
3044 case WHEN_NO: return "when ";
3045 case EXIT_NO: return "exit ";
3046 case END_NO: return "end ";
3047 case TEXT_NO: return "text ";
3048 case START_NO: return "start ";
3049 case ENDIF_NO: return "endif ";
3050 case FOR_NO: return "for ";
3051 case WHILE_NO: return "while ";
3052 case END_LOOP: return "end_loop ";
3053 case END_CASE: return "end_case ";
3054 case VARIABLE_NO: return "variable_decl ";
3055 case RETURN_NO: return "return ";
3056 case LOOP_NO: return "infinite loop ";
3057 case NEXT_NO: return "next ";
3058 case COMMENT_NO: return "comment ";
3059 case EMPTY_NO: return "empty ";
3060 case BEGIN_NO: return "<begin> ";
3061 default: return "--failure--";
3062 }
3063}

References BEGIN_NO, CASE_NO, COMMENT_NO, ELSE_NO, ELSIF_NO, EMPTY_NO, END_CASE, END_LOOP, END_NO, ENDIF_NO, EXIT_NO, FOR_NO, IF_NO, LOOP_NO, NEXT_NO, RETURN_NO, START_NO, TEXT_NO, VARIABLE_NO, WHEN_NO, and WHILE_NO.

Referenced by printNode().

◆ getTimeStamp()

int FlowChart::getTimeStamp ( )
static

References FlowChart(), and label.

◆ moveToPrevLevel()

void FlowChart::moveToPrevLevel ( )
static

Definition at line 2942 of file vhdldocgen.cpp.

2943{
2944 if (!VhdlDocGen::getFlowMember()) return;
2945 ifcounter--;
2946}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2661 of file vhdldocgen.cpp.

2662{
2663 for (const auto &flowChart : flowList)
2664 {
2665 printNode(flowChart);
2666 }
2667}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

void FlowChart::printNode ( const FlowChart & n)
static

Definition at line 2601 of file vhdldocgen.cpp.

2602{
2603 QCString ui="-";
2604 std::string q;
2605 std::string t;
2606
2607 ui.fill('-',255);
2608
2609 if (flo.type & STARTL)
2610 {
2611 if (flo.stamp>0)
2612 {
2613 q=ui.left(2*flo.stamp).str();
2614 }
2615 else
2616 {
2617 q=" ";
2618 }
2619 QCString nn=flo.exp.stripWhiteSpace();
2620 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2621 }
2622 else
2623 {
2624 if (flo.type & COMMENT_NO)
2625 {
2626 t=flo.label.str();
2627 }
2628 else
2629 {
2630 t=flo.text.str();
2631 }
2632 static const reg::Ex ep(R"(\s)");
2633 t = reg::replace(t,ep,std::string());
2634 if (t.empty())
2635 {
2636 t=" ";
2637 }
2638 if (flo.stamp>0)
2639 {
2640 q=ui.left(2*flo.stamp).str();
2641 }
2642 else
2643 {
2644 q=" ";
2645 }
2646 if (flo.type & EMPTNODE)
2647 {
2648 printf("\n NO: %s%s[%d,%d]",qPrint(q),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2649 }
2650 else if (flo.type & COMMENT_NO)
2651 {
2652 printf("\n NO: %s%s[%d,%d]",qPrint(t),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2653 }
2654 else
2655 {
2656 printf("\n NO: %s[%d,%d]",qPrint(t),flo.stamp,flo.id);
2657 }
2658 }
2659}
static const char * getNodeType(int c)
QCString left(size_t len) const
Definition qcstring.h:229
std::string replace(std::string_view str, const Ex &re, std::string_view replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
Definition regex.cpp:864
const char * qPrint(const char *s)
Definition qcstring.h:687
#define EMPTNODE

References COMMENT_NO, EMPTNODE, exp, QCString::fill(), FlowChart(), getNodeType(), id, label, QCString::left(), qPrint(), reg::replace(), stamp, STARTL, QCString::str(), QCString::stripWhiteSpace(), text, and type.

Referenced by printFlowTree().

◆ printPlantUmlNode()

QCString FlowChart::printPlantUmlNode ( const FlowChart & flo,
bool ca,
bool endL )
static

Definition at line 2948 of file vhdldocgen.cpp.

2949{
2950 QCString t;
2951 QCString exp=flo.exp.stripWhiteSpace();
2952 QCString text=flo.text.stripWhiteSpace();
2953 switch (flo.type)
2954 {
2955 case START_NO: t=":"+text+"|"; break;
2956 case IF_NO : t="\nif ("+exp+") then (yes)"; break;
2957 case ELSIF_NO: t="\nelseif ("+exp+") then (yes)"; break;
2958 case ELSE_NO: t="\nelse"; break;
2959 case CASE_NO: t="\n:"+exp+";"; break;
2960 case WHEN_NO: t="\n";
2961 if (!ca) t+="else";
2962 t+="if ("+exp+") then (yes)";
2963 break;
2964 case EXIT_NO: break;
2965 case END_NO: if (text.contains(" function")==0) t="\n:"+text+";";
2966 break;
2967 case TEXT_NO: t="\n:"+text+"]"; break;
2968 case ENDIF_NO: t="\nendif"; break;
2969 case FOR_NO: t="\nwhile ("+exp+") is (yes)"; break;
2970 case WHILE_NO: t="\nwhile ("+exp+") is (yes)"; break;
2971 case END_LOOP: t="\nendwhile"; break;
2972 case END_CASE: t="\nendif\n:end case;"; break;
2973 case VARIABLE_NO:t="\n:"+text+";"; break;
2974 case RETURN_NO: t="\n:"+text+";";
2975 if (!endL) t+="\nstop";
2976 break;
2977 case LOOP_NO: t="\nwhile (infinite loop)"; break;
2978 case NEXT_NO: break;
2979 case EMPTY_NO: break;
2980 case COMMENT_NO: t="\n note left \n "+flo.label+"\nend note \n"; break;
2981 case BEGIN_NO: t="\n:begin;"; break;
2982 default: assert(false); break;
2983 }
2984 return t;
2985}
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260

References BEGIN_NO, CASE_NO, COMMENT_NO, ELSE_NO, ELSIF_NO, EMPTY_NO, END_CASE, END_LOOP, END_NO, ENDIF_NO, EXIT_NO, exp, FlowChart(), FOR_NO, IF_NO, label, LOOP_NO, NEXT_NO, RETURN_NO, START_NO, QCString::stripWhiteSpace(), text, TEXT_NO, type, VARIABLE_NO, WHEN_NO, and WHILE_NO.

Referenced by printUmlTree().

◆ printUmlTree()

void FlowChart::printUmlTree ( )
static

Definition at line 2987 of file vhdldocgen.cpp.

2988{
2989 int caseCounter = 0;
2990 int whenCounter = 0;
2991
2992 QCString qcs;
2993 size_t size=flowList.size();
2994 for (size_t j=0;j<size;j++)
2995 {
2996 bool endList = j==FLOWLEN;
2997 const FlowChart &flo = flowList[j];
2998 if (flo.type==CASE_NO)
2999 {
3000 caseCounter++;
3001 whenCounter=0;
3002 }
3003
3004 if (flo.type==END_CASE)
3005 {
3006 caseCounter--;
3007 }
3008
3009 bool ca = (caseCounter>0 && whenCounter==0);
3010
3011 qcs+=printPlantUmlNode(flo,ca,endList);
3012
3013 if (flo.type==WHEN_NO)
3014 {
3015 whenCounter++;
3016 }
3017
3018 }
3019 qcs+="\n";
3020
3021 QCString htmlOutDir = Config_getString(HTML_OUTPUT);
3022
3023 QCString n=convertNameToFileName();
3024 auto baseNameVector=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG,"uml",n,1,true);
3025 for (const auto &baseName: baseNameVector)
3026 {
3028 }
3029}
static QCString printPlantUmlNode(const FlowChart &flo, bool, bool)
StringVector writePlantUMLSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &engine, const QCString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
Definition plantuml.cpp:31
static PlantumlManager & instance()
Definition plantuml.cpp:231
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:202

References CASE_NO, Config_getString, convertNameToFileName(), END_CASE, FlowChart(), FLOWLEN, flowList, PlantumlManager::generatePlantUMLOutput(), PlantumlManager::instance(), printPlantUmlNode(), PlantumlManager::PUML_SVG, type, WHEN_NO, and PlantumlManager::writePlantUMLSource().

Referenced by writeFlowChart().

◆ startDot()

void FlowChart::startDot ( TextStream & t)
static

Definition at line 3087 of file vhdldocgen.cpp.

3088{
3089 t << " digraph G { \n";
3090 t << "rankdir=TB \n";
3091 t << "concentrate=true\n";
3092 t << "stylesheet=\"doxygen.css\"\n";
3093}

Referenced by writeFlowChart().

◆ writeEdge() [1/2]

void FlowChart::writeEdge ( TextStream & t,
const FlowChart & fl_from,
const FlowChart & fl_to,
int i )
static

Definition at line 3247 of file vhdldocgen.cpp.

3248{
3249 bool b=fl_from.type & STARTL;
3250 bool c=fl_to.type & STARTL;
3251
3252#ifdef DEBUGFLOW
3253 QCString s1(getNodeName(fl_from.id));
3254 QCString s2(getNodeName(fl_to.id));
3255 auto it = g_keyMap.find(s1.str());
3256 auto it1 = g_keyMap.find(s2.str());
3257 // checks if the link is connected to a valid node
3258 assert(it!=g_keyMap.end());
3259 assert(it1!=g_keyMap.end());
3260#endif
3261
3262 writeEdge(t,fl_from.id,fl_to.id,i,b,c);
3263}

References FlowChart(), getNodeName(), id, STARTL, QCString::str(), type, and writeEdge().

◆ writeEdge() [2/2]

void FlowChart::writeEdge ( TextStream & t,
int fl_from,
int fl_to,
int i,
bool bFrom = FALSE,
bool bTo = FALSE )
static

Definition at line 3265 of file vhdldocgen.cpp.

3266{
3267 QCString label,col;
3268
3269 if (i==0)
3270 {
3271 col=flowCol.yesNodeLink;
3272 label="yes";
3273 }
3274 else if (i==1)
3275 {
3276 col=flowCol.noNodeLink;
3277 label="no";
3278 }
3279 else
3280 {
3281 col=flowCol.textNodeLink;
3282 label="";
3283 }
3284
3285 t << "edge [color=\""+col+"\",label=\""+label+"\"]\n";
3286 t << getNodeName(fl_from);
3287 if (bFrom) t << ":s";
3288 t << "->";
3289 t << getNodeName(fl_to);
3290 if (bTo) t << ":n";
3291 t << "\n";
3292}

References flowCol, getNodeName(), and label.

Referenced by buildCommentNodes(), writeEdge(), and writeFlowLinks().

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3100 of file vhdldocgen.cpp.

3101{
3102 // assert(VhdlDocGen::flowMember);
3103
3104 QCString ov = Config_getString(HTML_OUTPUT);
3105 QCString fileName = ov+"/flow_design.dot";
3106 std::ofstream f = Portable::openOutputStream(fileName);
3107 if (!f.is_open())
3108 {
3109 err("Cannot open file {} for writing\n",fileName);
3110 return;
3111 }
3112 TextStream t(&f);
3113
3114 colTextNodes();
3115 // buildCommentNodes(t);
3116
3117#ifdef DEBUGFLOW
3118 printFlowTree();
3119#endif
3120
3121 if (!Config_getString(PLANTUML_JAR_PATH).isEmpty())
3122 {
3123 printUmlTree();
3124 delFlowList();
3125 t.flush();
3126 f.close();
3127 return;
3128 }
3129
3130 startDot(t);
3132 for (const auto &fll : flowList)
3133 {
3134 writeShape(t,fll);
3135 }
3136 writeFlowLinks(t);
3137
3139 delFlowList();
3140 t.flush();
3141 f.close();
3143}// writeFlowChart
static void printFlowTree()
static void startDot(TextStream &t)
static void delFlowList()
static void colTextNodes()
static void createSVG()
static void writeShape(TextStream &t, const FlowChart &fl)
static void buildCommentNodes(TextStream &t)
static void printUmlTree()
static void writeFlowLinks(TextStream &t)
static void endDot(TextStream &t)
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:649

References buildCommentNodes(), colTextNodes(), Config_getString, createSVG(), delFlowList(), endDot(), err, flowList, TextStream::flush(), Portable::openOutputStream(), printFlowTree(), printUmlTree(), startDot(), writeFlowLinks(), and writeShape().

Referenced by VHDLOutlineParser::createFlow().

◆ writeFlowLinks()

void FlowChart::writeFlowLinks ( TextStream & t)
static

Definition at line 3457 of file vhdldocgen.cpp.

3458{
3459 size_t size=flowList.size();
3460 if (size<2) return;
3461
3462 // write start link
3463 writeEdge(t,flowList[0],flowList[1],2);
3464
3465 for (size_t j=0;j<size;j++)
3466 {
3467 const FlowChart &fll = flowList[j];
3468 int kind = fll.type;
3469 int stamp = fll.stamp;
3470 if (kind & EEND)
3471 {
3472 continue;
3473 }
3474
3475 if (kind & IFF)
3476 {
3477 writeEdge(t,fll,flowList[j+1],0);
3478 size_t z=getNextIfLink(fll,j);
3479 // assert(z>-1);
3480 writeEdge(t,fll,flowList[z],1);
3481 }
3482 else if (kind & LOOP_NO)
3483 {
3484 writeEdge(t,fll,flowList[j+1],2);
3485 continue;
3486 }
3487 else if (kind & (CASE_NO | FOR_NO | WHILE_NO))
3488 {
3489 if (kind & CASE_NO)
3490 {
3491 writeEdge(t,fll,flowList[j+1],2);
3492 continue;
3493 }
3494 else
3495 {
3496 writeEdge(t,fll,flowList[j+1],0);
3497 }
3498
3499 kind=END_LOOP;
3500 size_t z=findNode(j+1,fll.stamp,kind);
3501 z=getNextNode(z,flowList[z].stamp);
3502
3503 // assert(z>-1);
3504 writeEdge(t,fll,flowList[z],1);
3505 continue;
3506 }
3507 else if (kind & (TEXT_NO | VARIABLE_NO))
3508 {
3509 size_t z=getNextNode(j,stamp);
3510 writeEdge(t,fll,flowList[z],2);
3511 }
3512 else if (kind & WHEN_NO)
3513 {
3514 // default value
3515 if (qstricmp(fll.text.simplifyWhiteSpace(),"others")==0)
3516 {
3517 writeEdge(t,fll,flowList[j+1],2);
3518 continue;
3519 }
3520
3521
3522 writeEdge(t,fll,flowList[j+1],0);
3523 size_t u=findNode(j,stamp,WHEN_NO);
3524 size_t v=findNode(j,stamp-1,END_CASE);
3525
3526 if (u>0 && u<v)
3527 {
3528 writeEdge(t,fll,flowList[u],1);
3529 }
3530 else
3531 {
3532 writeEdge(t,fll,flowList[v],1);
3533 }
3534 }
3535 else if (kind & END_CASE)
3536 {
3537 size_t z=FlowChart::getNextNode(j,fll.stamp);
3538 writeEdge(t,fll,flowList[z],2);
3539 }
3540 else if (kind & END_LOOP)
3541 {
3542 size_t z=findPrevLoop(j,fll.stamp,true);
3543 writeEdge(t,fll,flowList[z],2);
3544 }
3545 else if (kind & RETURN_NO)
3546 {
3547 writeEdge(t,fll,flowList[size-1],2);
3548 }
3549 else if (kind & (EXIT_NO | NEXT_NO))
3550 {
3551 size_t z = 0;
3552 bool b = kind==NEXT_NO;
3553 if (!fll.exp.isEmpty())
3554 {
3555 writeEdge(t,fll,flowList[j+1],1);
3556 }
3557 if (!fll.label.isEmpty())
3558 {
3559 z=findLabel(j,fll.label);
3560 if (b)
3561 {
3562 writeEdge(t,fll,flowList[z],0);
3563 }
3564 else
3565 {
3567 z=getNextNode(z,flowList[z].stamp);
3568 writeEdge(t,fll,flowList[z],0);
3569 }
3570 continue;
3571 }
3572 else
3573 {
3574 if (b)
3575 {
3576 z=findPrevLoop(j,fll.stamp);
3577 writeEdge(t,fll,flowList[z],0);
3578 continue;
3579 }
3580 else
3581 {
3582 z =findNextLoop(j,fll.stamp-1);
3583 }
3584 z=getNextNode(z,flowList[z].stamp);
3585 }
3586 writeEdge(t,fll,flowList[z],0);
3587 }
3588 } //for
3589} //writeFlowLinks
static size_t findPrevLoop(size_t j, int stamp, bool endif=FALSE)
static size_t findLabel(size_t j, const QCString &)
static size_t findNextLoop(size_t j, int stamp)
static size_t getNextIfLink(const FlowChart &, size_t)
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
Definition qcstring.cpp:190
#define EEND

References CASE_NO, EEND, END_CASE, END_LOOP, EXIT_NO, exp, findLabel(), findNextLoop(), findNode(), findPrevLoop(), FlowChart(), flowList, FOR_NO, getNextIfLink(), getNextNode(), IFF, QCString::isEmpty(), label, LOOP_NO, NEXT_NO, qstricmp(), RETURN_NO, QCString::simplifyWhiteSpace(), stamp, text, TEXT_NO, type, VARIABLE_NO, WHEN_NO, WHILE_NO, and writeEdge().

Referenced by writeFlowChart().

◆ writeShape()

void FlowChart::writeShape ( TextStream & t,
const FlowChart & fl )
static

Definition at line 3145 of file vhdldocgen.cpp.

3146{
3147 if (fl.type & EEND) return;
3148 QCString var;
3149 if (fl.type & LOOP)
3150 {
3151 var=" loop";
3152 }
3153 else if (fl.type & IFF)
3154 {
3155 var=" then";
3156 }
3157 else
3158 {
3159 var="";
3160 }
3161
3162 t << getNodeName(fl.id);
3163
3164#ifdef DEBUGFLOW
3165 QCString qq(getNodeName(fl.id));
3166 g_keyMap.emplace(qq.str(),fl.id);
3167#endif
3168
3169 bool dec=(fl.type & DECLN);
3170 bool exit=(fl.type & EXITNEXT);
3171 if (exit && !fl.exp.isEmpty())
3172 {
3173 dec=TRUE;
3174 }
3175 if (dec)
3176 {
3177 QCString exp=fl.exp;
3178 alignText(exp);
3179
3180 t << " [shape=diamond,style=filled,color=\"";
3181 t << flowCol.decisionNode;
3182 t << "\",label=\" ";
3183 QCString kl;
3184 if (exit) kl=fl.text+" ";
3185
3186 if (!fl.label.isEmpty())
3187 {
3188 kl+=fl.label+":"+exp+var;
3189 }
3190 else
3191 {
3192 kl+=exp+var;
3193 }
3194
3196 t << "\"]\n";
3197 }
3198 else if (fl.type & ENDCL)
3199 {
3200 QCString val=fl.text;
3201 t << " [shape=ellipse ,label=\""+val+"\"]\n";
3202 }
3203 else if (fl.type & STARTFIN)
3204 {
3205 QCString val=fl.text;
3206 t << "[shape=box , style=rounded label=<\n";
3207 t << "<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" >\n ";
3208 t << "<TR><TD BGCOLOR=\"";
3209 t<< flowCol.startEndNode;
3210 t<< "\"> ";
3212 t << " </TD></TR></TABLE>>];";
3213 }
3214 else
3215 {
3216 if (fl.text.isEmpty()) return;
3217 bool isVar=(fl.type & FlowChart::VARIABLE_NO);
3218 QCString q=fl.text;
3219
3220 if (exit)
3221 {
3222 q+=" "+fl.label;
3223 }
3224
3225 int z=q.findRev("\n");
3226
3227 if (z==static_cast<int>(q.length())-1)
3228 {
3229 q=q.remove(z,2);
3230 }
3231 t << "[shape=none margin=0.1, label=<\n";
3232 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
3233 if (isVar)
3234 {
3235 t << "<TR><TD BGCOLOR=\"" << flowCol.varNode << "\" > ";
3236 }
3237 else
3238 {
3239 t << "<TR><TD BGCOLOR=\"" << flowCol.textNode << "\" > ";
3240 }
3242 t << " </TD></TR></TABLE>>];";
3243 }
3244}
QCString & remove(size_t index, size_t len)
Definition qcstring.h:442
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
#define ENDCL
#define DECLN
void alignText(QCString &q)
#define STARTFIN
#define EXITNEXT

References alignCommentNode(), alignText(), DECLN, EEND, ENDCL, EXITNEXT, exp, QCString::findRev(), FlowChart(), flowCol, getNodeName(), id, IFF, QCString::isEmpty(), label, QCString::length(), LOOP, QCString::remove(), STARTFIN, QCString::str(), text, TRUE, type, and VARIABLE_NO.

Referenced by writeFlowChart().

Member Data Documentation

◆ exp

QCString FlowChart::exp
private

◆ id

int FlowChart::id = 0
private

Definition at line 305 of file vhdldocgen.h.

Referenced by buildCommentNodes(), printNode(), writeEdge(), and writeShape().

◆ label

◆ line

int FlowChart::line = 0
private

Definition at line 309 of file vhdldocgen.h.

Referenced by buildCommentNodes().

◆ stamp

int FlowChart::stamp = 0
private

◆ text

QCString FlowChart::text
private

◆ type


The documentation for this class was generated from the following files: