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

2865{
2867
2868 if (typ & STARTL)
2869 {
2870 ifcounter++;
2871 }
2872
2873 text=t;
2874 exp=ex;
2875 type=typ;
2876 label=lab;
2877
2878 if (typ & (ELSE_NO | ELSIF_NO))
2879 {
2880 stamp--;
2881 }
2882
2883 if (typ & (START_NO | END_NO | VARIABLE_NO))
2884 {
2885 stamp=0;
2886 }
2887
2888 id=nodeCounter++;
2889}
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 2891 of file vhdldocgen.cpp.

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

2722{
2723 size_t max=0;
2724 QCString s;
2725 StringVector ql=split(com.str(),"\n");
2726 for (size_t j=0;j<ql.size();j++)
2727 {
2728 s=ql[j];
2729 if (max<s.length()) max=s.length();
2730 }
2731
2732 s=ql.back();
2733 int diff=static_cast<int>(max-s.length());
2734
2735 QCString n;
2736 if (diff>0)
2737 {
2738 n.fill(' ',2*diff);
2739 n.append(".");
2740 s+=n;
2741 ql.pop_back();
2742 ql.push_back(s.str());
2743 }
2744
2745 for (size_t j=0;j<ql.size();j++)
2746 {
2747 s=ql[j];
2748 if (j<ql.size()-1)
2749 {
2750 s+="\n";
2751 }
2752 FlowChart::codify(t,s);
2753 }
2754}
static void codify(TextStream &t, const QCString &str)
void fill(char c, int len=-1)
Fills a string with a predefined character.
Definition qcstring.h:180
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
const std::string & str() const
Definition qcstring.h:537
QCString & append(char c)
Definition qcstring.h:381
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:7129

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

3283{
3284 size_t index=al.size();
3285 if (index==0) return;
3286
3287 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3288 QCString prev,temp;
3289 prev.fill(' ',static_cast<int>(len)+1);
3290
3291 q+="\n";
3292 for (const Argument &arg : al)
3293 {
3294 QCString attl=arg.defval+" ";
3295 attl+=arg.name+" ";
3296
3297 if (!isFunc)
3298 {
3299 attl+=arg.attrib+" ";
3300 }
3301 else
3302 {
3303 attl+=" in ";
3304 }
3305 attl+=arg.type;
3306 if (--index) attl+=",\n"; else attl+="\n";
3307
3308 attl.prepend(prev);
3309 temp+=attl;
3310 }
3311
3312 q+=temp;
3313}
size_t size() const
Definition arguments.h:100
virtual const QCString & name() const =0
QCString & prepend(const char *s)
Definition qcstring.h:407

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

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

2843{
2844 if (!str.isEmpty())
2845 {
2846 const char *p=str.data();
2847 while (*p)
2848 {
2849 char c=*p++;
2850 switch(c)
2851 {
2852 case '<': t << "&lt;"; break;
2853 case '>': t << "&gt;"; break;
2854 case '&': t << "&amp;"; break;
2855 case '\'': t << "&#39;"; break;
2856 case '"': t << "&quot;"; break;
2857 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2858 default: t << c; break;
2859 }
2860 }
2861 }
2862}//codify
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
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:159

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

Referenced by alignCommentNode().

◆ colTextNodes()

void FlowChart::colTextNodes ( )
static

Definition at line 2657 of file vhdldocgen.cpp.

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

3020{
3021 return VhdlDocGen::getFlowMember()->name();
3022}

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

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

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3053 of file vhdldocgen.cpp.

3054{
3055 QCString qcs("/");
3056 QCString ov = Config_getString(HTML_OUTPUT);
3057
3059
3060 //const MemberDef *m=VhdlDocGen::getFlowMember();
3061 //if (m)
3062 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),TRUE),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3063
3064 QCString dir=" -o \""+ov+qcs+"\"";
3065 ov+="/flow_design.dot";
3066
3067 QCString vlargs="-Tsvg \""+ov+"\" "+dir ;
3068
3070 {
3071 err("could not create dot file\n");
3072 }
3073}
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 2714 of file vhdldocgen.cpp.

2715{
2716 ifcounter=0;
2717 nodeCounter=0;
2718 flowList.clear();
2719}

References flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3083 of file vhdldocgen.cpp.

3084{
3085 t << " } \n";
3086}

Referenced by writeFlowChart().

◆ findLabel()

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

Definition at line 3355 of file vhdldocgen.cpp.

3356{
3357 for (size_t j=index;j>0;j--)
3358 {
3359 const FlowChart &flo = flowList[j];
3360 if ((flo.type & LOOP) && !flo.label.isEmpty() && qstricmp(flo.label,label)==0)
3361 {
3362 return j;
3363 }
3364 }
3365 err("could not find label: '{}'\n",label);
3366 return 0;
3367}
int qstricmp(const char *s1, const char *s2)
Definition qcstring.cpp:442
#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 3315 of file vhdldocgen.cpp.

3316{
3317 for (size_t j=index+1; j<flowList.size(); j++)
3318 {
3319 const FlowChart &flo = flowList[j];
3320 if (flo.stamp==stamp)
3321 {
3322 continue;
3323 }
3324 if (flo.type&END_LOOP)
3325 {
3326 return j;
3327 }
3328 }
3329 return flowList.size()-1;
3330}

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

3370{
3371 for (size_t j=index+1; j<flowList.size(); j++)
3372 {
3373 const FlowChart &flo = flowList[j];
3374 if (flo.type==type && flo.stamp==stamp)
3375 {
3376 return j;
3377 }
3378 }
3379 return 0;
3380}// 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 3332 of file vhdldocgen.cpp.

3333{
3334 for (size_t j=index;j>0;j--)
3335 {
3336 const FlowChart &flo = flowList[j];
3337 if (flo.type & LOOP)
3338 {
3339 if (flo.stamp==stamp && endif)
3340 {
3341 return j;
3342 }
3343 else
3344 {
3345 if (flo.stamp<stamp)
3346 {
3347 return j;
3348 }
3349 }
3350 }
3351 }
3352 return flowList.size()-1;
3353}

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

3424{
3425 int stamp=fl.stamp;
3426 size_t start = index+1;
3427 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3428 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3429 size_t elseNode = findNode(start,stamp,ELSE_NO);
3430
3431 if (elseifNode>0 && elseifNode<endifNode)
3432 {
3433 return elseifNode;
3434 }
3435
3436 if (elseNode>0 && elseNode<endifNode)
3437 {
3438 return elseNode+1;
3439 }
3440
3441 stamp=flowList[endifNode].stamp;
3442 return getNextNode(endifNode,stamp);
3443}
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 3382 of file vhdldocgen.cpp.

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

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

2708{
2709 QCString node;
2710 node.setNum(n);
2711 return node.prepend("node");
2712}
QCString & setNum(short n)
Definition qcstring.h:444

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

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

◆ getNodeType()

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

Definition at line 3024 of file vhdldocgen.cpp.

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

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

2931{
2932 if (!VhdlDocGen::getFlowMember()) return;
2933 ifcounter--;
2934}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2649 of file vhdldocgen.cpp.

2650{
2651 for (const auto &flowChart : flowList)
2652 {
2653 printNode(flowChart);
2654 }
2655}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

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

Definition at line 2589 of file vhdldocgen.cpp.

2590{
2591 QCString ui="-";
2592 std::string q;
2593 std::string t;
2594
2595 ui.fill('-',255);
2596
2597 if (flo.type & STARTL)
2598 {
2599 if (flo.stamp>0)
2600 {
2601 q=ui.left(2*flo.stamp).str();
2602 }
2603 else
2604 {
2605 q=" ";
2606 }
2607 QCString nn=flo.exp.stripWhiteSpace();
2608 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2609 }
2610 else
2611 {
2612 if (flo.type & COMMENT_NO)
2613 {
2614 t=flo.label.str();
2615 }
2616 else
2617 {
2618 t=flo.text.str();
2619 }
2620 static const reg::Ex ep(R"(\s)");
2621 t = reg::replace(t,ep,std::string());
2622 if (t.empty())
2623 {
2624 t=" ";
2625 }
2626 if (flo.stamp>0)
2627 {
2628 q=ui.left(2*flo.stamp).str();
2629 }
2630 else
2631 {
2632 q=" ";
2633 }
2634 if (flo.type & EMPTNODE)
2635 {
2636 printf("\n NO: %s%s[%d,%d]",q.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2637 }
2638 else if (flo.type & COMMENT_NO)
2639 {
2640 printf("\n NO: %s%s[%d,%d]",t.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2641 }
2642 else
2643 {
2644 printf("\n NO: %s[%d,%d]",t.c_str(),flo.stamp,flo.id);
2645 }
2646 }
2647}
static const char * getNodeType(int c)
QCString left(size_t len) const
Definition qcstring.h:214
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:770
const char * qPrint(const char *s)
Definition qcstring.h:672
#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 2936 of file vhdldocgen.cpp.

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

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

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

3076{
3077 t << " digraph G { \n";
3078 t << "rankdir=TB \n";
3079 t << "concentrate=true\n";
3080 t << "stylesheet=\"doxygen.css\"\n";
3081}

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

3236{
3237 bool b=fl_from.type & STARTL;
3238 bool c=fl_to.type & STARTL;
3239
3240#ifdef DEBUGFLOW
3241 QCString s1(getNodeName(fl_from.id));
3242 QCString s2(getNodeName(fl_to.id));
3243 auto it = g_keyMap.find(s1.str());
3244 auto it1 = g_keyMap.find(s2.str());
3245 // checks if the link is connected to a valid node
3246 assert(it!=g_keyMap.end());
3247 assert(it1!=g_keyMap.end());
3248#endif
3249
3250 writeEdge(t,fl_from.id,fl_to.id,i,b,c);
3251}

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

3254{
3255 QCString label,col;
3256
3257 if (i==0)
3258 {
3259 col=flowCol.yesNodeLink;
3260 label="yes";
3261 }
3262 else if (i==1)
3263 {
3264 col=flowCol.noNodeLink;
3265 label="no";
3266 }
3267 else
3268 {
3269 col=flowCol.textNodeLink;
3270 label="";
3271 }
3272
3273 t << "edge [color=\""+col+"\",label=\""+label+"\"]\n";
3274 t << getNodeName(fl_from);
3275 if (bFrom) t << ":s";
3276 t << "->";
3277 t << getNodeName(fl_to);
3278 if (bTo) t << ":n";
3279 t << "\n";
3280}

References flowCol, getNodeName(), and label.

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

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3088 of file vhdldocgen.cpp.

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

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

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

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