@@ -116,35 +116,6 @@ function getParents(cluster: Cluster) {
116116 return parents . toReversed ( ) ;
117117}
118118
119- function renderNode ( graph : CFGGraph , node : string , verbose : boolean ) : string {
120- let label = "" ;
121- if ( verbose ) {
122- label = `${ node } ${ graph . getNodeAttributes ( node ) . type } ${ graph . getNodeAttributes ( node ) . code } ` ;
123-
124- const clusterAttrs = graph . getNodeAttribute ( node , "cluster" ) ;
125- label = `${ clusterAttrs ?. id } ${ clusterAttrs ?. type } \n${ label } ` ;
126- }
127- let shape = "box" ;
128- let fillColor = "lightgray" ;
129- let minHeight = 0.2 ;
130- if ( graph . degree ( node ) === 0 ) {
131- minHeight = 0.5 ;
132- } else if ( graph . inDegree ( node ) === 0 ) {
133- shape = "invhouse" ;
134- fillColor = "#48AB30" ;
135- minHeight = 0.5 ;
136- } else if ( graph . outDegree ( node ) === 0 ) {
137- shape = "house" ;
138- fillColor = "#AB3030" ;
139- minHeight = 0.5 ;
140- }
141-
142- const height = Math . max (
143- graph . getNodeAttribute ( node , "lines" ) * 0.3 ,
144- minHeight ,
145- ) ;
146- return ` ${ node } [label="${ label } " shape="${ shape } " fillcolor="${ fillColor } " style="filled" height=${ height } ];\n` ;
147- }
148119
149120function renderHierarchy (
150121 cfg : CFG ,
@@ -335,3 +306,46 @@ function renderEdge(
335306 }
336307 return ` ${ source } -> ${ target } [${ formatStyle ( dotAttrs ) } ];\n` ;
337308}
309+
310+ function renderNode ( graph : CFGGraph , node : string , verbose : boolean ) : string {
311+ const dotAttrs : DotAttributes = { } ;
312+ dotAttrs . style = "filled"
313+ dotAttrs . label = "" ;
314+ const nodeAttrs = graph . getNodeAttributes ( node ) ;
315+ if ( verbose ) {
316+ dotAttrs . label = `${ node } ${ nodeAttrs . type } ${ graph . getNodeAttributes ( node ) . code } ` ;
317+
318+ const clusterAttrs = graph . getNodeAttribute ( node , "cluster" ) ;
319+ dotAttrs . label = `${ clusterAttrs ?. id } ${ clusterAttrs ?. type } \n${ dotAttrs . label } ` ;
320+ }
321+ dotAttrs . shape = "box" ;
322+ dotAttrs . fillcolor = "lightgray" ;
323+ let minHeight = 0.2 ;
324+ if ( graph . degree ( node ) === 0 ) {
325+ dotAttrs . minHeight = 0.5 ;
326+ } else if ( graph . inDegree ( node ) === 0 ) {
327+ dotAttrs . shape = "invhouse" ;
328+ dotAttrs . fillcolor = "#48AB30" ;
329+ minHeight = 0.5 ;
330+ } else if ( graph . outDegree ( node ) === 0 ) {
331+ dotAttrs . shape = "house" ;
332+ dotAttrs . fillcolor = "#AB3030" ;
333+ minHeight = 0.5 ;
334+ }
335+ switch ( nodeAttrs . type ) {
336+ case "RAISE" :
337+ dotAttrs . shape = "triangle" ;
338+ dotAttrs . fillcolor = "#fdd" ;
339+ break ;
340+ case "YIELD" :
341+ dotAttrs . shallow = "hexagon" ;
342+ dotAttrs . fillcolor = "aqua" ;
343+ break ;
344+ }
345+
346+ dotAttrs . height = Math . max (
347+ graph . getNodeAttribute ( node , "lines" ) * 0.3 ,
348+ minHeight ,
349+ ) ;
350+ return ` ${ node } [${ formatStyle ( dotAttrs ) } ];\n` ;
351+ }
0 commit comments