@@ -29,7 +29,7 @@ function addDummy(sources, targets, obj, options, directionS, directionT){
29
29
30
30
let dummyId = "dummy_" + dummyCount , o , port ;
31
31
dummyCount ++ ;
32
- obj . children . push ( drawNodeNew ( dummyId , '' , 'Dummy' , sources , options ) ) ;
32
+ obj . children . push ( drawNodeNew ( dummyId , dummyId , 'Dummy' , sources , options ) ) ;
33
33
if ( sources && sources . length > 0 ) {
34
34
o = drawEdgeNew ( sources [ 0 ] , dummyId , obj ) , port = o . targetPort ;
35
35
obj . edges . push ( o ) ;
@@ -134,12 +134,13 @@ function drawNodeNew(id, label, type, properties, options){
134
134
}
135
135
else if ( o . type === 'function' ) {
136
136
o . fullFunctionCode = label ;
137
- const prettyCode = require ( 'js-beautify' ) ( o . fullFunctionCode )
138
-
139
- if ( options . renderFunctionsInView ) {
137
+ const prettyCode = require ( 'js-beautify' ) ( o . fullFunctionCode ) ,
138
+ { nLines, maxLineLength } = textualPropertiesOfCode ( prettyCode )
139
+
140
+ // uncomment the second clause if you want always to display 1-liner functions inline in the view
141
+ if ( options . renderFunctionsInView /*|| nLines === 1*/ ) {
140
142
// ok cool, then render this function body directly in the view
141
- const { nLines, maxLineLength } = textualPropertiesOfCode ( prettyCode ) ,
142
- charWidthForCode = defaultCharWidth * 0.63
143
+ const charWidthForCode = defaultCharWidth * 0.63
143
144
144
145
o . width = Math . min ( maxWidth , maxLineLength * charWidthForCode ) ;
145
146
o . height = Math . max ( 2.25 , nLines ) * defaultCharHeight ; // use at least two lines; makes one-line functions look better
@@ -202,12 +203,12 @@ function drawNodeNew(id, label, type, properties, options){
202
203
properties . forEach ( s => { // a source id
203
204
if ( visited [ s ] ) { // if the source is visited
204
205
visited [ s ] . forEach ( a => { // find out if any of its activation was success
205
- if ( activations [ a ] . response . success ) { // if so, dummy is visited
206
- if ( visited [ dummyId ] == undefined ) {
207
- visited [ dummyId ] = [ ] ;
206
+ if ( activations [ a ] . response . success ) { // if so, dummy is visited
207
+ if ( visited [ o . id ] == undefined ) {
208
+ visited [ o . id ] = [ ] ;
208
209
o . visited = [ ] ;
209
210
}
210
- visited [ dummyId ] . push ( a ) ;
211
+ visited [ o . id ] . push ( a ) ;
211
212
o . visited . push ( a ) ;
212
213
}
213
214
} )
@@ -331,11 +332,11 @@ function ir2graph(ir, gm, id, prevId, options={}){ // ir and graph model
331
332
}
332
333
else if ( ir . type === 'if' ) {
333
334
let firstTestId = gm . children . length ,
334
- lastTestId = ir2graph ( ir . test , gm , `${ id } -test` , undefined , options ) ,
335
+ lastTestId = ir2graph ( ir . test , gm , `${ id } -test` , undefined , options ) ,
335
336
firstConsId = gm . children . length ,
336
- lastConsId = ir2graph ( ir . consequent , gm , `${ id } -consequent` , undefined , options ) ,
337
+ lastConsId = ir2graph ( ir . consequent , gm , `${ id } -consequent` , undefined , options ) ,
337
338
firstAltId = gm . children . length ,
338
- lastAltId = ir2graph ( ir . alternate , gm , `${ id } -alternate` , undefined , options ) ;
339
+ lastAltId = ir2graph ( ir . alternate , gm , `${ id } -alternate` , undefined , options )
339
340
340
341
if ( prevId ) // connect prevId to the first node in test
341
342
prevId . forEach ( pid => gm . edges . push ( drawEdgeNew ( pid , gm . children [ firstTestId ] . id , gm ) ) ) ;
@@ -354,8 +355,9 @@ function ir2graph(ir, gm, id, prevId, options={}){ // ir and graph model
354
355
gm . edges . push ( drawEdgeNew ( ltid , gm . children [ firstAltId ] . id , gm , 'false' ) ) ;
355
356
else
356
357
lastAltId = [ ltid ] ;
357
-
358
- return lastAltId . concat ( lastConsId ) ;
358
+
359
+ const exitConcentrator = addDummy ( lastAltId . concat ( lastConsId ) , undefined , gm , options ) ;
360
+ return [ exitConcentrator ]
359
361
}
360
362
else if ( ir . type === 'try' ) {
361
363
// insert a compound node for try
0 commit comments