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 DString &t, const DString &ex, const DString &label=DString())

Static Public Member Functions

static void createSVG ()
static void startDot (TextStream &t)
static void endDot (TextStream &t)
static void codify (TextStream &t, const DString &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 DString 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 DString &)
static void delFlowList ()
static const char * getNodeType (int c)
static void addFlowChart (int type, const DString &text, const DString &exp, const DString &label=DString())
static void moveToPrevLevel ()
static int getTimeStamp ()
static void writeFlowChart ()
static void alignFuncProc (DString &q, const ArgumentList &al, bool isFunc)
static DString convertNameToFileName ()
static void printNode (const FlowChart &n)
static void printFlowTree ()
static void buildCommentNodes (TextStream &t)
static void alignCommentNode (TextStream &t, DString com)
static void printUmlTree ()
static DString printPlantUmlNode (const FlowChart &flo, bool, bool)

Private Attributes

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

Detailed Description

Definition at line 235 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 238 of file vhdldocgen.h.

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

Constructor & Destructor Documentation

◆ FlowChart()

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

Definition at line 2852 of file vhdldocgen.cpp.

2853{
2855
2856 if (typ & STARTL)
2857 {
2858 ifcounter++;
2859 }
2860
2861 text=t;
2862 exp=ex;
2863 type=typ;
2864 label=lab;
2865
2866 if (typ & (ELSE_NO | ELSIF_NO))
2867 {
2868 stamp--;
2869 }
2870
2871 if (typ & (START_NO | END_NO | VARIABLE_NO))
2872 {
2873 stamp=0;
2874 }
2875
2876 id=nodeCounter++;
2877}
DString text
Definition vhdldocgen.h:309
DString exp
Definition vhdldocgen.h:310
DString label
Definition vhdldocgen.h:308
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 DString & text,
const DString & exp,
const DString & label = DString() )
static

Definition at line 2879 of file vhdldocgen.cpp.

2880{
2881 if (!VhdlDocGen::getFlowMember()) return;
2882
2883 DString typeString(text);
2884 DString expression(exp);
2885
2886
2887 if (!text.empty())
2888 {
2889 typeString=substitute(typeString,";","\n");
2890 }
2891
2892 if (!exp.empty())
2893 {
2894 expression=substitute(expression,"\"","\\\"");
2895 }
2896
2897 if (type & VARIABLE_NO)
2898 {
2899 // Ignore the empty section of the VHDL variable definition.
2900 // This is section between `process` and `begin` keywords, where any source text is missing, probably a bug in the VHDL source parser.
2901 if(text.empty()) return;
2902
2903 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2904 flowList.front().line=1; // TODO: use getLine(); of the parser
2905 }
2906 else if (type & START_NO)
2907 {
2908 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2909 flowList.front().line=1; // TODO: use getLine(); of the parser
2910 }
2911 else
2912 {
2913 flowList.emplace_back(type,typeString,expression,label);
2914 flowList.back().line=1; // TODO: use getLine(); of the parser
2915 }
2916}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
FlowChart(int typ, const DString &t, const DString &ex, const DString &label=DString())
static const MemberDef * getFlowMember()
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:485
std::vector< FlowChart > flowList

References DString::empty(), 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,
DString com )
static

Definition at line 2709 of file vhdldocgen.cpp.

2710{
2711 size_t max=0;
2712 DString s;
2713 StringVector ql=split(com.str(),"\n");
2714 for (size_t j=0;j<ql.size();j++)
2715 {
2716 s=ql[j];
2717 if (max<s.length()) max=s.length();
2718 }
2719
2720 s=ql.back();
2721 int diff=static_cast<int>(max-s.length());
2722
2723 DString n;
2724 if (diff>0)
2725 {
2726 n.fill(' ',2*diff);
2727 n.append(".");
2728 s+=n;
2729 ql.pop_back();
2730 ql.push_back(s.str());
2731 }
2732
2733 for (size_t j=0;j<ql.size();j++)
2734 {
2735 s=ql[j];
2736 if (j<ql.size()-1)
2737 {
2738 s+="\n";
2739 }
2740 FlowChart::codify(t,s);
2741 }
2742}
DString fill(char c, size_t len)
Fills a string with a predefined character.
Definition dstring.h:278
DString & append(char c)
Definition dstring.h:489
const std::string & str() const
Definition dstring.h:645
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
static void codify(TextStream &t, const DString &str)
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 stringutil.h:117

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

Referenced by buildCommentNodes(), and writeShape().

◆ alignFuncProc()

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

Definition at line 3270 of file vhdldocgen.cpp.

3271{
3272 size_t index=al.size();
3273 if (index==0) return;
3274
3275 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3276 DString prev,temp;
3277 prev.fill(' ',static_cast<int>(len)+1);
3278
3279 q+="\n";
3280 for (const Argument &arg : al)
3281 {
3282 DString attl=arg.defval+" ";
3283 attl+=arg.name+" ";
3284
3285 if (!isFunc)
3286 {
3287 attl+=arg.attrib+" ";
3288 }
3289 else
3290 {
3291 attl+=" in ";
3292 }
3293 attl+=arg.type;
3294 if (--index) attl+=",\n"; else attl+="\n";
3295
3296 attl.prepend(prev);
3297 temp+=attl;
3298 }
3299
3300 q+=temp;
3301}
size_t size() const
Definition arguments.h:101
DString & prepend(const char *s)
Definition dstring.h:515
virtual const DString & name() const =0

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

Referenced by VHDLOutlineParser::createFlow().

◆ buildCommentNodes()

void FlowChart::buildCommentNodes ( TextStream & t)
static

Definition at line 2745 of file vhdldocgen.cpp.

2746{
2747 size_t size=flowList.size();
2748 bool begin=false;
2749
2750 if (size>0)
2751 {
2752 for (uint32_t j=0;j < size-1 ;j++)
2753 {
2754 FlowChart &fll = flowList[j];
2755 if (fll.type & COMMENT_NO)
2756 {
2757 FlowChart &to=flowList[j+1];
2758 if (to.type & COMMENT_NO)
2759 {
2760 to.label = fll.label+"\n"+to.label;
2761 flowList.erase(flowList.begin()+j);
2762 if (size>0) size--;
2763 if (j>0) j--;
2764 }
2765 }
2766 }// for
2767 }
2768
2769 for (size_t j=0;j <flowList.size() ;j++)
2770 {
2771 const FlowChart &fll=flowList[j];
2772
2773 if (fll.type & BEGIN_NO)
2774 {
2775 begin = true;
2776 continue;
2777 }
2778
2779 if (fll.type & COMMENT_NO)
2780 {
2781 const FlowChart *to = nullptr;
2782 if (!begin)
2783 {
2784 // comment between function/process .. begin is linked to start node
2785 to = &flowList[0];
2786 }
2787 else if (j>0 && flowList[j-1].line==fll.line)
2788 {
2789 to = &flowList[j-1];
2790 }
2791 else
2792 {
2793 to = &flowList[j+1];
2794 }
2795 t << getNodeName(fll.id);
2796 t << "[shape=none, label=<\n";
2797 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
2798 t << "<TR><TD BGCOLOR=\"";
2799 t << flowCol.comment;
2800 t << "\" > ";
2801
2803 t << " </TD></TR></TABLE>>];";
2804 writeEdge(t,fll.id,to->id,2);
2805 }
2806 }// for
2807
2808 // delete comment nodes;
2809 size=flowList.size();
2810 for (size_t j=0; j<size; j++)
2811 {
2812 FlowChart &fll=flowList[j];
2813 if (fll.type & (COMMENT_NO | BEGIN_NO))
2814 {
2815 size_t diff=FLOWLEN-(j+1);
2816
2817 if ((fll.type & COMMENT_NO) && diff > 1)
2818 {
2819 flowList[j+1].label = fll.label;
2820 }
2821
2822 flowList.erase(flowList.begin()+j);
2823
2824 if (size>0) size--;
2825 if (j>0) j--;
2826 }
2827 }// for;
2828}
DString & erase(size_t index=0, size_t count=npos)
Definition dstring.h:232
static void alignCommentNode(TextStream &t, DString com)
static void writeEdge(TextStream &t, int fl_from, int fl_to, int i, bool bFrom=false, bool bTo=false)
static DString getNodeName(int n)
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:176
#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 DString & str )
static

Definition at line 2830 of file vhdldocgen.cpp.

2831{
2832 if (!str.empty())
2833 {
2834 const char *p=str.data();
2835 while (*p)
2836 {
2837 char c=*p++;
2838 switch(c)
2839 {
2840 case '<': t << "&lt;"; break;
2841 case '>': t << "&gt;"; break;
2842 case '&': t << "&amp;"; break;
2843 case '\'': t << "&#39;"; break;
2844 case '"': t << "&quot;"; break;
2845 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2846 default: t << c; break;
2847 }
2848 }
2849 }
2850}//codify
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157

References DString::data(), and DString::empty().

Referenced by alignCommentNode().

◆ colTextNodes()

void FlowChart::colTextNodes ( )
static

Definition at line 2645 of file vhdldocgen.cpp.

2646{
2647 FlowChart *flno = nullptr;
2648 bool found=false;
2649 for (size_t j=0;j<flowList.size();j++)
2650 {
2651 FlowChart &flo = flowList[j];
2652 if (flo.type&TEXT_NO)
2653 {
2654 if (!found)
2655 {
2656 flno=&flo;
2657 }
2658 else
2659 {
2660 flno->text+=flo.text;
2661 flowList.erase(flowList.begin()+j);
2662 if (j>0) j=j-1;
2663 }
2664 found=true;
2665 }
2666 else
2667 {
2668 found=false;
2669 }
2670 }
2671
2672 // find if..endif without text
2673 // if..elseif without text
2674 if (!flowList.empty())
2675 {
2676 for (size_t j=0;j<flowList.size()-1;j++)
2677 {
2678 const FlowChart &flo = flowList[j];
2679 int kind = flo.type;
2680 if ( (kind & IFF) || (flo.type & ELSE_NO))
2681 {
2682 const FlowChart &ftemp = flowList[j+1];
2683 if (ftemp.type & EMPTY)
2684 {
2685 FlowChart fc(TEXT_NO,"empty ",DString());
2686 fc.stamp = flo.stamp;
2687 flowList.insert(flowList.begin()+j+1,fc);
2688 }
2689 }
2690 }
2691 }
2692
2693}// colTextNode
#define IFF
#define EMPTY

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

Referenced by writeFlowChart().

◆ convertNameToFileName()

DString FlowChart::convertNameToFileName ( )
static

Definition at line 3007 of file vhdldocgen.cpp.

3008{
3009 return VhdlDocGen::getFlowMember()->name();
3010}

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

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

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3041 of file vhdldocgen.cpp.

3042{
3043 DString qcs("/");
3044 DString ov = Config_getString(HTML_OUTPUT);
3045
3047
3048 //const MemberDef *m=VhdlDocGen::getFlowMember();
3049 //if (m)
3050 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),true),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3051
3052 DString dir=" -o \""+ov+qcs+"\"";
3053 ov+="/flow_design.dot";
3054
3055 DString vlargs="-Tsvg \""+ov+"\" "+dir ;
3056
3058 {
3059 err("could not create dot file\n");
3060 }
3061}
static DString verifiedDotPath
Definition doxygen.h:130
static DString convertNameToFileName()
#define Config_getString(name)
Definition config.h:32
#define err(fmt,...)
Definition message.h:127
int system(const DString &command, const DString &args, bool commandHasConsole=true)
Definition portable.cpp:121

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

Referenced by writeFlowChart().

◆ delFlowList()

void FlowChart::delFlowList ( )
static

Definition at line 2702 of file vhdldocgen.cpp.

2703{
2704 ifcounter=0;
2705 nodeCounter=0;
2706 flowList.clear();
2707}

References flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3071 of file vhdldocgen.cpp.

3072{
3073 t << " } \n";
3074}

Referenced by writeFlowChart().

◆ findLabel()

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

Definition at line 3343 of file vhdldocgen.cpp.

3344{
3345 for (size_t j=index;j>0;j--)
3346 {
3347 const FlowChart &flo = flowList[j];
3348 if ((flo.type & LOOP) && !flo.label.empty() && dstricmp(flo.label,label)==0)
3349 {
3350 return j;
3351 }
3352 }
3353 err("could not find label: '{}'\n",label);
3354 return 0;
3355}
int dstricmp(const char *s1, const char *s2)
Definition dstring.cpp:444
#define LOOP

References dstricmp(), DString::empty(), err, FlowChart(), flowList, label, LOOP, and type.

Referenced by writeFlowLinks().

◆ findNextLoop()

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

Definition at line 3303 of file vhdldocgen.cpp.

3304{
3305 for (size_t j=index+1; j<flowList.size(); j++)
3306 {
3307 const FlowChart &flo = flowList[j];
3308 if (flo.stamp==stamp)
3309 {
3310 continue;
3311 }
3312 if (flo.type&END_LOOP)
3313 {
3314 return j;
3315 }
3316 }
3317 return flowList.size()-1;
3318}

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

3358{
3359 for (size_t j=index+1; j<flowList.size(); j++)
3360 {
3361 const FlowChart &flo = flowList[j];
3362 if (flo.type==type && flo.stamp==stamp)
3363 {
3364 return j;
3365 }
3366 }
3367 return 0;
3368}// 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, label, stamp, text, and type.

◆ findPrevLoop()

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

Definition at line 3320 of file vhdldocgen.cpp.

3321{
3322 for (size_t j=index;j>0;j--)
3323 {
3324 const FlowChart &flo = flowList[j];
3325 if (flo.type & LOOP)
3326 {
3327 if (flo.stamp==stamp && endif)
3328 {
3329 return j;
3330 }
3331 else
3332 {
3333 if (flo.stamp<stamp)
3334 {
3335 return j;
3336 }
3337 }
3338 }
3339 }
3340 return flowList.size()-1;
3341}

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

3412{
3413 int stamp=fl.stamp;
3414 size_t start = index+1;
3415 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3416 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3417 size_t elseNode = findNode(start,stamp,ELSE_NO);
3418
3419 if (elseifNode>0 && elseifNode<endifNode)
3420 {
3421 return elseifNode;
3422 }
3423
3424 if (elseNode>0 && elseNode<endifNode)
3425 {
3426 return elseNode+1;
3427 }
3428
3429 stamp=flowList[endifNode].stamp;
3430 return getNextNode(endifNode,stamp);
3431}
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 3370 of file vhdldocgen.cpp.

3371{
3372 for (size_t j=index+1; j<flowList.size(); j++)
3373 {
3374 const FlowChart &flo = flowList[j];
3375 int kind = flo.type;
3376 int s = flo.stamp;
3377 if (s>stamp)
3378 {
3379 continue;
3380 }
3381 if (kind & ENDIF_NO)
3382 {
3383 if (s<stamp && stamp>0)
3384 {
3385 stamp--;
3386 continue;
3387 }
3388 }
3389 if (kind & (ELSE_NO | ELSIF_NO))
3390 {
3391 if (s<stamp && stamp>0)
3392 {
3393 stamp--;
3394 }
3395 j=findNode(j,stamp,ENDIF_NO);
3396 continue;
3397 }
3398 if (kind & WHEN_NO)
3399 {
3400 if (s<stamp && stamp>0)
3401 {
3402 stamp--;
3403 }
3404 return findNode(j,stamp-1,END_CASE);
3405 }
3406 return j;
3407 }
3408 return FLOWLEN;
3409}

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

Referenced by getNextIfLink(), and writeFlowLinks().

◆ getNodeName()

DString FlowChart::getNodeName ( int n)
static

Definition at line 2695 of file vhdldocgen.cpp.

2696{
2697 DString node;
2698 node.setNum(n);
2699 return node.prepend("node");
2700}
DString & setNum(short n)
Definition dstring.h:552

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

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

◆ getNodeType()

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

Definition at line 3012 of file vhdldocgen.cpp.

3013{
3014 switch(c)
3015 {
3016 case IF_NO: return "if ";
3017 case ELSIF_NO: return "elsif ";
3018 case ELSE_NO: return "else ";
3019 case CASE_NO: return "case ";
3020 case WHEN_NO: return "when ";
3021 case EXIT_NO: return "exit ";
3022 case END_NO: return "end ";
3023 case TEXT_NO: return "text ";
3024 case START_NO: return "start ";
3025 case ENDIF_NO: return "endif ";
3026 case FOR_NO: return "for ";
3027 case WHILE_NO: return "while ";
3028 case END_LOOP: return "end_loop ";
3029 case END_CASE: return "end_case ";
3030 case VARIABLE_NO: return "variable_decl ";
3031 case RETURN_NO: return "return ";
3032 case LOOP_NO: return "infinite loop ";
3033 case NEXT_NO: return "next ";
3034 case COMMENT_NO: return "comment ";
3035 case EMPTY_NO: return "empty ";
3036 case BEGIN_NO: return "<begin> ";
3037 default: return "--failure--";
3038 }
3039}

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

2919{
2920 if (!VhdlDocGen::getFlowMember()) return;
2921 ifcounter--;
2922}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2637 of file vhdldocgen.cpp.

2638{
2639 for (const auto &flowChart : flowList)
2640 {
2641 printNode(flowChart);
2642 }
2643}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

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

Definition at line 2577 of file vhdldocgen.cpp.

2578{
2579 DString ui="-";
2580 std::string q;
2581 std::string t;
2582
2583 ui.fill('-',255);
2584
2585 if (flo.type & STARTL)
2586 {
2587 if (flo.stamp>0)
2588 {
2589 q=ui.left(2*flo.stamp).str();
2590 }
2591 else
2592 {
2593 q=" ";
2594 }
2595 DString nn=flo.exp.stripWhiteSpace();
2596 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2597 }
2598 else
2599 {
2600 if (flo.type & COMMENT_NO)
2601 {
2602 t=flo.label.str();
2603 }
2604 else
2605 {
2606 t=flo.text.str();
2607 }
2608 static const reg::Ex ep(R"(\s)");
2609 t = reg::replace(t,ep,std::string());
2610 if (t.empty())
2611 {
2612 t=" ";
2613 }
2614 if (flo.stamp>0)
2615 {
2616 q=ui.left(2*flo.stamp).str();
2617 }
2618 else
2619 {
2620 q=" ";
2621 }
2622 if (flo.type & EMPTNODE)
2623 {
2624 printf("\n NO: %s%s[%d,%d]",qPrint(q),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2625 }
2626 else if (flo.type & COMMENT_NO)
2627 {
2628 printf("\n NO: %s%s[%d,%d]",qPrint(t),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2629 }
2630 else
2631 {
2632 printf("\n NO: %s[%d,%d]",qPrint(t),flo.stamp,flo.id);
2633 }
2634 }
2635}
DString left(size_t len) const
Definition dstring.h:306
static const char * getNodeType(int c)
const char * qPrint(const char *s)
Definition dstring.h:783
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:872
#define EMPTNODE

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

Referenced by printFlowTree().

◆ printPlantUmlNode()

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

Definition at line 2924 of file vhdldocgen.cpp.

2925{
2926 DString t;
2927 DString exp=flo.exp.stripWhiteSpace();
2928 DString text=flo.text.stripWhiteSpace();
2929 switch (flo.type)
2930 {
2931 case START_NO: t=":"+text+"|"; break;
2932 case IF_NO : t="\nif ("+exp+") then (yes)"; break;
2933 case ELSIF_NO: t="\nelseif ("+exp+") then (yes)"; break;
2934 case ELSE_NO: t="\nelse"; break;
2935 case CASE_NO: t="\n:"+exp+";"; break;
2936 case WHEN_NO: t="\n";
2937 if (!ca) t+="else";
2938 t+="if ("+exp+") then (yes)";
2939 break;
2940 case EXIT_NO: break;
2941 case END_NO: if (text.contains(" function")==0) t="\n:"+text+";";
2942 break;
2943 case TEXT_NO: t="\n:"+text+"]"; break;
2944 case ENDIF_NO: t="\nendif"; break;
2945 case FOR_NO: t="\nwhile ("+exp+") is (yes)"; break;
2946 case WHILE_NO: t="\nwhile ("+exp+") is (yes)"; break;
2947 case END_LOOP: t="\nendwhile"; break;
2948 case END_CASE: t="\nendif\n:end case;"; break;
2949 case VARIABLE_NO:t="\n:"+text+";"; break;
2950 case RETURN_NO: t="\n:"+text+";";
2951 if (!endL) t+="\nstop";
2952 break;
2953 case LOOP_NO: t="\nwhile (infinite loop)"; break;
2954 case NEXT_NO: break;
2955 case EMPTY_NO: break;
2956 case COMMENT_NO: t="\n note left \n "+flo.label+"\nend note \n"; break;
2957 case BEGIN_NO: t="\n:begin;"; break;
2958 default: ASSERT(false); break;
2959 }
2960 return t;
2961}
int contains(char c, bool cs=true) const
Definition dstring.cpp:85
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition dstring.h:337
#define ASSERT(x)
Definition message.h:142

References ASSERT, BEGIN_NO, CASE_NO, COMMENT_NO, DString::contains(), 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, DString::stripWhiteSpace(), text, TEXT_NO, type, VARIABLE_NO, WHEN_NO, and WHILE_NO.

Referenced by printUmlTree().

◆ printUmlTree()

void FlowChart::printUmlTree ( )
static

Definition at line 2963 of file vhdldocgen.cpp.

2964{
2965 int caseCounter = 0;
2966 int whenCounter = 0;
2967
2968 DString qcs;
2969 size_t size=flowList.size();
2970 for (size_t j=0;j<size;j++)
2971 {
2972 bool endList = j==FLOWLEN;
2973 const FlowChart &flo = flowList[j];
2974 if (flo.type==CASE_NO)
2975 {
2976 caseCounter++;
2977 whenCounter=0;
2978 }
2979
2980 if (flo.type==END_CASE)
2981 {
2982 caseCounter--;
2983 }
2984
2985 bool ca = (caseCounter>0 && whenCounter==0);
2986
2987 qcs+=printPlantUmlNode(flo,ca,endList);
2988
2989 if (flo.type==WHEN_NO)
2990 {
2991 whenCounter++;
2992 }
2993
2994 }
2995 qcs+="\n";
2996
2997 DString htmlOutDir = Config_getString(HTML_OUTPUT);
2998
2999 DString n=convertNameToFileName();
3000 auto baseNameVector=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG,"uml",n,1,true);
3001 for (const auto &baseName: baseNameVector)
3002 {
3004 }
3005}
static DString printPlantUmlNode(const FlowChart &flo, bool, bool)
void generatePlantUMLOutput(const DString &baseName, const DString &outDir, OutputFormat format, bool toIndex)
Convert a PlantUML file to an image.
Definition plantuml.cpp:207
StringVector writePlantUMLSource(const DString &outDirArg, const DString &fileName, const DString &content, OutputFormat format, const DString &engine, const DString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
Definition plantuml.cpp:37
static PlantumlManager & instance()
Definition plantuml.cpp:236

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

3064{
3065 t << " digraph G { \n";
3066 t << "rankdir=TB \n";
3067 t << "concentrate=true\n";
3068 t << "stylesheet=\"doxygen.css\"\n";
3069}

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

3224{
3225 bool b=fl_from.type & STARTL;
3226 bool c=fl_to.type & STARTL;
3227
3228#ifdef DEBUGFLOW
3229 DString s1(getNodeName(fl_from.id));
3230 DString s2(getNodeName(fl_to.id));
3231 auto it = g_keyMap.find(s1.str());
3232 auto it1 = g_keyMap.find(s2.str());
3233 // checks if the link is connected to a valid node
3234 ASSERT(it!=g_keyMap.end());
3235 ASSERT(it1!=g_keyMap.end());
3236#endif
3237
3238 writeEdge(t,fl_from.id,fl_to.id,i,b,c);
3239}

References ASSERT, FlowChart(), getNodeName(), id, STARTL, DString::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 3241 of file vhdldocgen.cpp.

3242{
3243 DString label,col;
3244
3245 if (i==0)
3246 {
3247 col=flowCol.yesNodeLink;
3248 label="yes";
3249 }
3250 else if (i==1)
3251 {
3252 col=flowCol.noNodeLink;
3253 label="no";
3254 }
3255 else
3256 {
3257 col=flowCol.textNodeLink;
3258 label="";
3259 }
3260
3261 t << "edge [color=\""+col+"\",label=\""+label+"\"]\n";
3262 t << getNodeName(fl_from);
3263 if (bFrom) t << ":s";
3264 t << "->";
3265 t << getNodeName(fl_to);
3266 if (bTo) t << ":n";
3267 t << "\n";
3268}

References flowCol, getNodeName(), and label.

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

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3076 of file vhdldocgen.cpp.

3077{
3078 // ASSERT(VhdlDocGen::flowMember);
3079
3080 DString ov = Config_getString(HTML_OUTPUT);
3081 DString fileName = ov+"/flow_design.dot";
3082 std::ofstream f = Portable::openOutputStream(fileName);
3083 if (!f.is_open())
3084 {
3085 err("Cannot open file {} for writing\n",fileName);
3086 return;
3087 }
3088 TextStream t(&f);
3089
3090 colTextNodes();
3091 // buildCommentNodes(t);
3092
3093#ifdef DEBUGFLOW
3094 printFlowTree();
3095#endif
3096
3098 {
3099 printUmlTree();
3100 delFlowList();
3101 t.flush();
3102 f.close();
3103 return;
3104 }
3105
3106 startDot(t);
3108 for (const auto &fll : flowList)
3109 {
3110 writeShape(t,fll);
3111 }
3112 writeFlowLinks(t);
3113
3115 delFlowList();
3116 t.flush();
3117 f.close();
3119}// 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)
static bool isEnabled()
Returns true if doxygen has been configured to run PlantUML, i.e.
Definition plantuml.cpp:246
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:681

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

Referenced by VHDLOutlineParser::createFlow().

◆ writeFlowLinks()

void FlowChart::writeFlowLinks ( TextStream & t)
static

Definition at line 3433 of file vhdldocgen.cpp.

3434{
3435 size_t size=flowList.size();
3436 if (size<2) return;
3437
3438 // write start link
3439 writeEdge(t,flowList[0],flowList[1],2);
3440
3441 for (size_t j=0;j<size;j++)
3442 {
3443 const FlowChart &fll = flowList[j];
3444 int kind = fll.type;
3445 int stamp = fll.stamp;
3446 if (kind & EEND)
3447 {
3448 continue;
3449 }
3450
3451 if (kind & IFF)
3452 {
3453 writeEdge(t,fll,flowList[j+1],0);
3454 size_t z=getNextIfLink(fll,j);
3455 // ASSERT(z>-1);
3456 writeEdge(t,fll,flowList[z],1);
3457 }
3458 else if (kind & LOOP_NO)
3459 {
3460 writeEdge(t,fll,flowList[j+1],2);
3461 continue;
3462 }
3463 else if (kind & (CASE_NO | FOR_NO | WHILE_NO))
3464 {
3465 if (kind & CASE_NO)
3466 {
3467 writeEdge(t,fll,flowList[j+1],2);
3468 continue;
3469 }
3470 else
3471 {
3472 writeEdge(t,fll,flowList[j+1],0);
3473 }
3474
3475 kind=END_LOOP;
3476 size_t z=findNode(j+1,fll.stamp,kind);
3477 z=getNextNode(z,flowList[z].stamp);
3478
3479 // ASSERT(z>-1);
3480 writeEdge(t,fll,flowList[z],1);
3481 continue;
3482 }
3483 else if (kind & (TEXT_NO | VARIABLE_NO))
3484 {
3485 size_t z=getNextNode(j,stamp);
3486 writeEdge(t,fll,flowList[z],2);
3487 }
3488 else if (kind & WHEN_NO)
3489 {
3490 // default value
3491 if (dstricmp(fll.text.simplifyWhiteSpace(),"others")==0)
3492 {
3493 writeEdge(t,fll,flowList[j+1],2);
3494 continue;
3495 }
3496
3497
3498 writeEdge(t,fll,flowList[j+1],0);
3499 size_t u=findNode(j,stamp,WHEN_NO);
3500 size_t v=findNode(j,stamp-1,END_CASE);
3501
3502 if (u>0 && u<v)
3503 {
3504 writeEdge(t,fll,flowList[u],1);
3505 }
3506 else
3507 {
3508 writeEdge(t,fll,flowList[v],1);
3509 }
3510 }
3511 else if (kind & END_CASE)
3512 {
3513 size_t z=FlowChart::getNextNode(j,fll.stamp);
3514 writeEdge(t,fll,flowList[z],2);
3515 }
3516 else if (kind & END_LOOP)
3517 {
3518 size_t z=findPrevLoop(j,fll.stamp,true);
3519 writeEdge(t,fll,flowList[z],2);
3520 }
3521 else if (kind & RETURN_NO)
3522 {
3523 writeEdge(t,fll,flowList[size-1],2);
3524 }
3525 else if (kind & (EXIT_NO | NEXT_NO))
3526 {
3527 size_t z = 0;
3528 bool b = kind==NEXT_NO;
3529 if (!fll.exp.empty())
3530 {
3531 writeEdge(t,fll,flowList[j+1],1);
3532 }
3533 if (!fll.label.empty())
3534 {
3535 z=findLabel(j,fll.label);
3536 if (b)
3537 {
3538 writeEdge(t,fll,flowList[z],0);
3539 }
3540 else
3541 {
3543 z=getNextNode(z,flowList[z].stamp);
3544 writeEdge(t,fll,flowList[z],0);
3545 }
3546 continue;
3547 }
3548 else
3549 {
3550 if (b)
3551 {
3552 z=findPrevLoop(j,fll.stamp);
3553 writeEdge(t,fll,flowList[z],0);
3554 continue;
3555 }
3556 else
3557 {
3558 z =findNextLoop(j,fll.stamp-1);
3559 }
3560 z=getNextNode(z,flowList[z].stamp);
3561 }
3562 writeEdge(t,fll,flowList[z],0);
3563 }
3564 } //for
3565} //writeFlowLinks
DString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple internal white...
Definition dstring.cpp:127
static size_t findNextLoop(size_t j, int stamp)
static size_t findPrevLoop(size_t j, int stamp, bool endif=false)
static size_t getNextIfLink(const FlowChart &, size_t)
static size_t findLabel(size_t j, const DString &)
#define EEND

References CASE_NO, dstricmp(), EEND, DString::empty(), END_CASE, END_LOOP, EXIT_NO, exp, findLabel(), findNextLoop(), findNode(), findPrevLoop(), FlowChart(), flowList, FOR_NO, getNextIfLink(), getNextNode(), IFF, label, LOOP_NO, NEXT_NO, RETURN_NO, DString::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 3121 of file vhdldocgen.cpp.

3122{
3123 if (fl.type & EEND) return;
3124 DString var;
3125 if (fl.type & LOOP)
3126 {
3127 var=" loop";
3128 }
3129 else if (fl.type & IFF)
3130 {
3131 var=" then";
3132 }
3133 else
3134 {
3135 var="";
3136 }
3137
3138 t << getNodeName(fl.id);
3139
3140#ifdef DEBUGFLOW
3141 DString qq(getNodeName(fl.id));
3142 g_keyMap.emplace(qq.str(),fl.id);
3143#endif
3144
3145 bool dec=(fl.type & DECLN);
3146 bool exit=(fl.type & EXITNEXT);
3147 if (exit && !fl.exp.empty())
3148 {
3149 dec=true;
3150 }
3151 if (dec)
3152 {
3153 DString exp=fl.exp;
3154 alignText(exp);
3155
3156 t << " [shape=diamond,style=filled,color=\"";
3157 t << flowCol.decisionNode;
3158 t << "\",label=\" ";
3159 DString kl;
3160 if (exit) kl=fl.text+" ";
3161
3162 if (!fl.label.empty())
3163 {
3164 kl+=fl.label+":"+exp+var;
3165 }
3166 else
3167 {
3168 kl+=exp+var;
3169 }
3170
3172 t << "\"]\n";
3173 }
3174 else if (fl.type & ENDCL)
3175 {
3176 DString val=fl.text;
3177 t << " [shape=ellipse ,label=\""+val+"\"]\n";
3178 }
3179 else if (fl.type & STARTFIN)
3180 {
3181 DString val=fl.text;
3182 t << "[shape=box , style=rounded label=<\n";
3183 t << "<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" >\n ";
3184 t << "<TR><TD BGCOLOR=\"";
3185 t<< flowCol.startEndNode;
3186 t<< "\"> ";
3188 t << " </TD></TR></TABLE>>];";
3189 }
3190 else
3191 {
3192 if (fl.text.empty()) return;
3193 bool isVar=(fl.type & FlowChart::VARIABLE_NO);
3194 DString q=fl.text;
3195
3196 if (exit)
3197 {
3198 q+=" "+fl.label;
3199 }
3200
3201 size_t z=q.rfind('\n');
3202
3203 if (z!=DString::npos && z==q.length()-1)
3204 {
3205 q=q.remove(z,2);
3206 }
3207 t << "[shape=none margin=0.1, label=<\n";
3208 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
3209 if (isVar)
3210 {
3211 t << "<TR><TD BGCOLOR=\"" << flowCol.varNode << "\" > ";
3212 }
3213 else
3214 {
3215 t << "<TR><TD BGCOLOR=\"" << flowCol.textNode << "\" > ";
3216 }
3218 t << " </TD></TR></TABLE>>];";
3219 }
3220}
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:244
DString & remove(size_t index, size_t len)
Definition dstring.h:535
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
static void alignText(DString &q)
#define ENDCL
#define DECLN
#define STARTFIN
#define EXITNEXT

References alignCommentNode(), alignText(), DECLN, EEND, DString::empty(), ENDCL, EXITNEXT, exp, FlowChart(), flowCol, getNodeName(), id, IFF, label, DString::length(), LOOP, DString::npos, DString::remove(), DString::rfind(), STARTFIN, DString::str(), text, type, and VARIABLE_NO.

Referenced by writeFlowChart().

Member Data Documentation

◆ exp

DString FlowChart::exp
private

◆ id

int FlowChart::id = 0
private

Definition at line 302 of file vhdldocgen.h.

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

◆ label

◆ line

int FlowChart::line = 0
private

Definition at line 306 of file vhdldocgen.h.

Referenced by buildCommentNodes().

◆ stamp

int FlowChart::stamp = 0
private

◆ text

DString FlowChart::text
private

◆ type


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