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 2872 of file vhdldocgen.cpp.

2873{
2875
2876 if (typ & STARTL)
2877 {
2878 ifcounter++;
2879 }
2880
2881 text=t;
2882 exp=ex;
2883 type=typ;
2884 label=lab;
2885
2886 if (typ & (ELSE_NO | ELSIF_NO))
2887 {
2888 stamp--;
2889 }
2890
2891 if (typ & (START_NO | END_NO | VARIABLE_NO))
2892 {
2893 stamp=0;
2894 }
2895
2896 id=nodeCounter++;
2897}
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 2899 of file vhdldocgen.cpp.

2900{
2901 if (!VhdlDocGen::getFlowMember()) return;
2902
2903 QCString typeString(text);
2904 QCString expression(exp);
2905
2906
2907 if (!text.isEmpty())
2908 {
2909 typeString=substitute(typeString,";","\n");
2910 }
2911
2912 if (!exp.isEmpty())
2913 {
2914 expression=substitute(expression,"\"","\\\"");
2915 }
2916
2917 if (type & VARIABLE_NO)
2918 {
2919 // Ignore the empty section of the VHDL variable definition.
2920 // This is section between `process` and `begin` keywords, where any source text is missing, probably a bug in the VHDL source parser.
2921 if(text.isEmpty()) return;
2922
2923 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2924 flowList.front().line=1; // TODO: use getLine(); of the parser
2925 }
2926 else if (type & START_NO)
2927 {
2928 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2929 flowList.front().line=1; // TODO: use getLine(); of the parser
2930 }
2931 else
2932 {
2933 flowList.emplace_back(type,typeString,expression,label);
2934 flowList.back().line=1; // TODO: use getLine(); of the parser
2935 }
2936}
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:571
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 2729 of file vhdldocgen.cpp.

2730{
2731 size_t max=0;
2732 QCString s;
2733 StringVector ql=split(com.str(),"\n");
2734 for (size_t j=0;j<ql.size();j++)
2735 {
2736 s=ql[j];
2737 if (max<s.length()) max=s.length();
2738 }
2739
2740 s=ql.back();
2741 int diff=static_cast<int>(max-s.length());
2742
2743 QCString n;
2744 if (diff>0)
2745 {
2746 n.fill(' ',2*diff);
2747 n.append(".");
2748 s+=n;
2749 ql.pop_back();
2750 ql.push_back(s.str());
2751 }
2752
2753 for (size_t j=0;j<ql.size();j++)
2754 {
2755 s=ql[j];
2756 if (j<ql.size()-1)
2757 {
2758 s+="\n";
2759 }
2760 FlowChart::codify(t,s);
2761 }
2762}
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:6641

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 3290 of file vhdldocgen.cpp.

3291{
3292 size_t index=al.size();
3293 if (index==0) return;
3294
3295 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3296 QCString prev,temp;
3297 prev.fill(' ',static_cast<int>(len)+1);
3298
3299 q+="\n";
3300 for (const Argument &arg : al)
3301 {
3302 QCString attl=arg.defval+" ";
3303 attl+=arg.name+" ";
3304
3305 if (!isFunc)
3306 {
3307 attl+=arg.attrib+" ";
3308 }
3309 else
3310 {
3311 attl+=" in ";
3312 }
3313 attl+=arg.type;
3314 if (--index) attl+=",\n"; else attl+="\n";
3315
3316 attl.prepend(prev);
3317 temp+=attl;
3318 }
3319
3320 q+=temp;
3321}
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 2765 of file vhdldocgen.cpp.

2766{
2767 size_t size=flowList.size();
2768 bool begin=false;
2769
2770 if (size>0)
2771 {
2772 for (uint32_t j=0;j < size-1 ;j++)
2773 {
2774 FlowChart &fll = flowList[j];
2775 if (fll.type & COMMENT_NO)
2776 {
2777 FlowChart &to=flowList[j+1];
2778 if (to.type & COMMENT_NO)
2779 {
2780 to.label = fll.label+"\n"+to.label;
2781 flowList.erase(flowList.begin()+j);
2782 if (size>0) size--;
2783 if (j>0) j--;
2784 }
2785 }
2786 }// for
2787 }
2788
2789 for (size_t j=0;j <flowList.size() ;j++)
2790 {
2791 const FlowChart &fll=flowList[j];
2792
2793 if (fll.type & BEGIN_NO)
2794 {
2795 begin = true;
2796 continue;
2797 }
2798
2799 if (fll.type & COMMENT_NO)
2800 {
2801 const FlowChart *to = nullptr;
2802 if (!begin)
2803 {
2804 // comment between function/process .. begin is linked to start node
2805 to = &flowList[0];
2806 }
2807 else if (j>0 && flowList[j-1].line==fll.line)
2808 {
2809 to = &flowList[j-1];
2810 }
2811 else
2812 {
2813 to = &flowList[j+1];
2814 }
2815 t << getNodeName(fll.id);
2816 t << "[shape=none, label=<\n";
2817 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
2818 t << "<TR><TD BGCOLOR=\"";
2819 t << flowCol.comment;
2820 t << "\" > ";
2821
2823 t << " </TD></TR></TABLE>>];";
2824 writeEdge(t,fll.id,to->id,2);
2825 }
2826 }// for
2827
2828 // delete comment nodes;
2829 size=flowList.size();
2830 for (size_t j=0; j<size; j++)
2831 {
2832 FlowChart &fll=flowList[j];
2833 if (fll.type & (COMMENT_NO | BEGIN_NO))
2834 {
2835 size_t diff=FLOWLEN-(j+1);
2836
2837 if ((fll.type & COMMENT_NO) && diff > 1)
2838 {
2839 flowList[j+1].label = fll.label;
2840 }
2841
2842 flowList.erase(flowList.begin()+j);
2843
2844 if (size>0) size--;
2845 if (j>0) j--;
2846 }
2847 }// for;
2848}
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 2850 of file vhdldocgen.cpp.

2851{
2852 if (!str.isEmpty())
2853 {
2854 const char *p=str.data();
2855 while (*p)
2856 {
2857 char c=*p++;
2858 switch(c)
2859 {
2860 case '<': t << "&lt;"; break;
2861 case '>': t << "&gt;"; break;
2862 case '&': t << "&amp;"; break;
2863 case '\'': t << "&#39;"; break;
2864 case '"': t << "&quot;"; break;
2865 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2866 default: t << c; break;
2867 }
2868 }
2869 }
2870}//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 2665 of file vhdldocgen.cpp.

2666{
2667 FlowChart *flno = nullptr;
2668 bool found=FALSE;
2669 for (size_t j=0;j<flowList.size();j++)
2670 {
2671 FlowChart &flo = flowList[j];
2672 if (flo.type&TEXT_NO)
2673 {
2674 if (!found)
2675 {
2676 flno=&flo;
2677 }
2678 else
2679 {
2680 flno->text+=flo.text;
2681 flowList.erase(flowList.begin()+j);
2682 if (j>0) j=j-1;
2683 }
2684 found=TRUE;
2685 }
2686 else
2687 {
2688 found=FALSE;
2689 }
2690 }
2691
2692 // find if..endif without text
2693 // if..elseif without text
2694 if (!flowList.empty())
2695 {
2696 for (size_t j=0;j<flowList.size()-1;j++)
2697 {
2698 const FlowChart &flo = flowList[j];
2699 int kind = flo.type;
2700 if ( (kind & IFF) || (flo.type & ELSE_NO))
2701 {
2702 const FlowChart &ftemp = flowList[j+1];
2703 if (ftemp.type & EMPTY)
2704 {
2705 FlowChart fc(TEXT_NO,"empty ",QCString());
2706 fc.stamp = flo.stamp;
2707 flowList.insert(flowList.begin()+j+1,fc);
2708 }
2709 }
2710 }
2711 }
2712
2713}// 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 3027 of file vhdldocgen.cpp.

3028{
3029 return VhdlDocGen::getFlowMember()->name();
3030}

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

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

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3061 of file vhdldocgen.cpp.

3062{
3063 QCString qcs("/");
3064 QCString ov = Config_getString(HTML_OUTPUT);
3065
3067
3068 //const MemberDef *m=VhdlDocGen::getFlowMember();
3069 //if (m)
3070 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),TRUE),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3071
3072 QCString dir=" -o \""+ov+qcs+"\"";
3073 ov+="/flow_design.dot";
3074
3075 QCString vlargs="-Tsvg \""+ov+"\" "+dir ;
3076
3078 {
3079 err("could not create dot file\n");
3080 }
3081}
static QCString verifiedDotPath
Definition doxygen.h:136
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:105

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

Referenced by writeFlowChart().

◆ delFlowList()

void FlowChart::delFlowList ( )
static

Definition at line 2722 of file vhdldocgen.cpp.

2723{
2724 ifcounter=0;
2725 nodeCounter=0;
2726 flowList.clear();
2727}

References flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3091 of file vhdldocgen.cpp.

3092{
3093 t << " } \n";
3094}

Referenced by writeFlowChart().

◆ findLabel()

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

Definition at line 3363 of file vhdldocgen.cpp.

3364{
3365 for (size_t j=index;j>0;j--)
3366 {
3367 const FlowChart &flo = flowList[j];
3368 if ((flo.type & LOOP) && !flo.label.isEmpty() && qstricmp(flo.label,label)==0)
3369 {
3370 return j;
3371 }
3372 }
3373 err("could not find label: '{}'\n",label);
3374 return 0;
3375}
int qstricmp(const char *s1, const char *s2)
Definition qcstring.cpp:530
#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 3323 of file vhdldocgen.cpp.

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

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 3377 of file vhdldocgen.cpp.

3378{
3379 for (size_t j=index+1; j<flowList.size(); j++)
3380 {
3381 const FlowChart &flo = flowList[j];
3382 if (flo.type==type && flo.stamp==stamp)
3383 {
3384 return j;
3385 }
3386 }
3387 return 0;
3388}// 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 3340 of file vhdldocgen.cpp.

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

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 3431 of file vhdldocgen.cpp.

3432{
3433 int stamp=fl.stamp;
3434 size_t start = index+1;
3435 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3436 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3437 size_t elseNode = findNode(start,stamp,ELSE_NO);
3438
3439 if (elseifNode>0 && elseifNode<endifNode)
3440 {
3441 return elseifNode;
3442 }
3443
3444 if (elseNode>0 && elseNode<endifNode)
3445 {
3446 return elseNode+1;
3447 }
3448
3449 stamp=flowList[endifNode].stamp;
3450 return getNextNode(endifNode,stamp);
3451}
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 3390 of file vhdldocgen.cpp.

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

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 2715 of file vhdldocgen.cpp.

2716{
2717 QCString node;
2718 node.setNum(n);
2719 return node.prepend("node");
2720}
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 3032 of file vhdldocgen.cpp.

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

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 2938 of file vhdldocgen.cpp.

2939{
2940 if (!VhdlDocGen::getFlowMember()) return;
2941 ifcounter--;
2942}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2657 of file vhdldocgen.cpp.

2658{
2659 for (const auto &flowChart : flowList)
2660 {
2661 printNode(flowChart);
2662 }
2663}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

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

Definition at line 2597 of file vhdldocgen.cpp.

2598{
2599 QCString ui="-";
2600 std::string q;
2601 std::string t;
2602
2603 ui.fill('-',255);
2604
2605 if (flo.type & STARTL)
2606 {
2607 if (flo.stamp>0)
2608 {
2609 q=ui.left(2*flo.stamp).str();
2610 }
2611 else
2612 {
2613 q=" ";
2614 }
2615 QCString nn=flo.exp.stripWhiteSpace();
2616 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2617 }
2618 else
2619 {
2620 if (flo.type & COMMENT_NO)
2621 {
2622 t=flo.label.str();
2623 }
2624 else
2625 {
2626 t=flo.text.str();
2627 }
2628 static const reg::Ex ep(R"(\s)");
2629 t = reg::replace(t,ep,std::string());
2630 if (t.empty())
2631 {
2632 t=" ";
2633 }
2634 if (flo.stamp>0)
2635 {
2636 q=ui.left(2*flo.stamp).str();
2637 }
2638 else
2639 {
2640 q=" ";
2641 }
2642 if (flo.type & EMPTNODE)
2643 {
2644 printf("\n NO: %s%s[%d,%d]",qPrint(q),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2645 }
2646 else if (flo.type & COMMENT_NO)
2647 {
2648 printf("\n NO: %s%s[%d,%d]",qPrint(t),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2649 }
2650 else
2651 {
2652 printf("\n NO: %s[%d,%d]",qPrint(t),flo.stamp,flo.id);
2653 }
2654 }
2655}
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:866
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 2944 of file vhdldocgen.cpp.

2945{
2946 QCString t;
2947 QCString exp=flo.exp.stripWhiteSpace();
2948 QCString text=flo.text.stripWhiteSpace();
2949 switch (flo.type)
2950 {
2951 case START_NO: t=":"+text+"|"; break;
2952 case IF_NO : t="\nif ("+exp+") then (yes)"; break;
2953 case ELSIF_NO: t="\nelseif ("+exp+") then (yes)"; break;
2954 case ELSE_NO: t="\nelse"; break;
2955 case CASE_NO: t="\n:"+exp+";"; break;
2956 case WHEN_NO: t="\n";
2957 if (!ca) t+="else";
2958 t+="if ("+exp+") then (yes)";
2959 break;
2960 case EXIT_NO: break;
2961 case END_NO: if (text.contains(" function")==0) t="\n:"+text+";";
2962 break;
2963 case TEXT_NO: t="\n:"+text+"]"; break;
2964 case ENDIF_NO: t="\nendif"; break;
2965 case FOR_NO: t="\nwhile ("+exp+") is (yes)"; break;
2966 case WHILE_NO: t="\nwhile ("+exp+") is (yes)"; break;
2967 case END_LOOP: t="\nendwhile"; break;
2968 case END_CASE: t="\nendif\n:end case;"; break;
2969 case VARIABLE_NO:t="\n:"+text+";"; break;
2970 case RETURN_NO: t="\n:"+text+";";
2971 if (!endL) t+="\nstop";
2972 break;
2973 case LOOP_NO: t="\nwhile (infinite loop)"; break;
2974 case NEXT_NO: break;
2975 case EMPTY_NO: break;
2976 case COMMENT_NO: t="\n note left \n "+flo.label+"\nend note \n"; break;
2977 case BEGIN_NO: t="\n:begin;"; break;
2978 default: assert(false); break;
2979 }
2980 return t;
2981}
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 2983 of file vhdldocgen.cpp.

2984{
2985 int caseCounter = 0;
2986 int whenCounter = 0;
2987
2988 QCString qcs;
2989 size_t size=flowList.size();
2990 for (size_t j=0;j<size;j++)
2991 {
2992 bool endList = j==FLOWLEN;
2993 const FlowChart &flo = flowList[j];
2994 if (flo.type==CASE_NO)
2995 {
2996 caseCounter++;
2997 whenCounter=0;
2998 }
2999
3000 if (flo.type==END_CASE)
3001 {
3002 caseCounter--;
3003 }
3004
3005 bool ca = (caseCounter>0 && whenCounter==0);
3006
3007 qcs+=printPlantUmlNode(flo,ca,endList);
3008
3009 if (flo.type==WHEN_NO)
3010 {
3011 whenCounter++;
3012 }
3013
3014 }
3015 qcs+="\n";
3016
3017 QCString htmlOutDir = Config_getString(HTML_OUTPUT);
3018
3019 QCString n=convertNameToFileName();
3020 auto baseNameVector=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG,"uml",n,1,true);
3021 for (const auto &baseName: baseNameVector)
3022 {
3024 }
3025}
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 3083 of file vhdldocgen.cpp.

3084{
3085 t << " digraph G { \n";
3086 t << "rankdir=TB \n";
3087 t << "concentrate=true\n";
3088 t << "stylesheet=\"doxygen.css\"\n";
3089}

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 3243 of file vhdldocgen.cpp.

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

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 3261 of file vhdldocgen.cpp.

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

References flowCol, getNodeName(), and label.

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

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3096 of file vhdldocgen.cpp.

3097{
3098 // assert(VhdlDocGen::flowMember);
3099
3100 QCString ov = Config_getString(HTML_OUTPUT);
3101 QCString fileName = ov+"/flow_design.dot";
3102 std::ofstream f = Portable::openOutputStream(fileName);
3103 if (!f.is_open())
3104 {
3105 err("Cannot open file {} for writing\n",fileName);
3106 return;
3107 }
3108 TextStream t(&f);
3109
3110 colTextNodes();
3111 // buildCommentNodes(t);
3112
3113#ifdef DEBUGFLOW
3114 printFlowTree();
3115#endif
3116
3117 if (!Config_getString(PLANTUML_JAR_PATH).isEmpty())
3118 {
3119 printUmlTree();
3120 delFlowList();
3121 t.flush();
3122 f.close();
3123 return;
3124 }
3125
3126 startDot(t);
3128 for (const auto &fll : flowList)
3129 {
3130 writeShape(t,fll);
3131 }
3132 writeFlowLinks(t);
3133
3135 delFlowList();
3136 t.flush();
3137 f.close();
3139}// 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:648

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 3453 of file vhdldocgen.cpp.

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

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