@@ -239,7 +239,6 @@ function updateOutput() {
239239// Renders the current trace entry (curEntry) into the div named by vizDiv
240240function renderDataStructures ( curEntry , vizDiv ) {
241241 renderDataStructuresVersion1 ( curEntry , vizDiv ) ;
242-
243242 //renderDataStructuresVersion2(curEntry, vizDiv);
244243}
245244
@@ -392,12 +391,12 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
392391 var funcName = htmlspecialchars ( frame [ 0 ] ) ; // might contain '<' or '>' for weird names like <genexpr>
393392 var localVars = frame [ 1 ] ;
394393
395- // the stackFrame div's id is simply its index ("stack_ <index>")
394+ // the stackFrame div's id is simply its index ("stack <index>")
396395 var divClass = ( i == 0 ) ? "stackFrame topStackFrame" : "stackFrame" ;
397- var divID = "stack_ " + i ;
396+ var divID = "stack " + i ;
398397 $ ( vizDiv + " #stack" ) . append ( '<div class="' + divClass + '" id="' + divID + '"></div>' ) ;
399398
400- var headerDivID = "stack_header_ " + i ;
399+ var headerDivID = "stack_header " + i ;
401400 $ ( vizDiv + " #stack #" + divID ) . append ( '<div id="' + headerDivID + '" class="stackFrameHeader inactiveStackFrameHeader">' + funcName + '</div>' ) ;
402401
403402 // render locals in alphabetical order for tidiness:
@@ -411,18 +410,6 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
411410 }
412411 orderedVarnames . sort ( ) ;
413412
414-
415- /*
416- <table class="stackFrameVarTable" id="TowerOfHanoi1_table">
417- <tr>
418- <td class="stackFrameVar">a</td>
419- <!-- IE needs the div to be NON-EMPTY in order to properly
420- render the plumb endpoints!!! -->
421- <td class="stackFrameValue"><div id="TowerOfHanoi1_a"> </div></td>
422- </tr>
423- </table>
424- */
425-
426413 if ( orderedVarnames . length > 0 ) {
427414 var tableID = divID + '_table' ;
428415 $ ( vizDiv + " #stack #" + divID ) . append ( '<table class="stackFrameVarTable" id="' + tableID + '"></table>' ) ;
@@ -438,15 +425,29 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
438425 else {
439426 curTr . find ( "td.stackFrameVar" ) . html ( varname ) ;
440427 }
441- renderData ( val , curTr . find ( "td.stackFrameValue" ) ) ;
428+
429+ // render primitives inline and compound types on the heap
430+ if ( isPrimitiveType ( val ) ) {
431+ renderData ( val , curTr . find ( "td.stackFrameValue" ) ) ;
432+ }
433+ else {
434+ // add a stub so that we can connect it with a connector later.
435+ // IE needs this div to be NON-EMPTY in order to properly
436+ // render jsPlumb endpoints, so that's why we add an " "!
437+
438+ // TODO: make sure varname doesn't contain any weird
439+ // characters that are illegal for CSS ID's ...
440+ var varDivID = divID + '__' + varname ;
441+ curTr . find ( "td.stackFrameValue" ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
442+ }
442443 } ) ;
443444 }
444445 } ) ;
445446 }
446447
447448
448449 // render globals LAST:
449- $ ( vizDiv + " #stack" ) . append ( '<div class="globalFrame" id="globals"><div class="stackFrameHeader inactiveStackFrameHeader">Global variables</div></div>' ) ;
450+ $ ( vizDiv + " #stack" ) . append ( '<div class="globalFrame" id="globals"><div id="globals_header" class="stackFrameHeader inactiveStackFrameHeader">Global variables</div></div>' ) ;
450451
451452 var nonEmptyGlobals = false ;
452453 var curGlobalFields = { } ;
@@ -508,7 +509,21 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
508509 tbl . append ( '<tr><td class="stackFrameVar"></td><td class="stackFrameValue"></td></tr>' ) ;
509510 var curTr = tbl . find ( 'tr:last' ) ;
510511 curTr . find ( "td.stackFrameVar" ) . html ( varname ) ;
511- renderData ( val , curTr . find ( "td.stackFrameValue" ) ) ;
512+
513+ // render primitives inline
514+ if ( isPrimitiveType ( val ) ) {
515+ renderData ( val , curTr . find ( "td.stackFrameValue" ) ) ;
516+ }
517+ else {
518+ // add a stub so that we can connect it with a connector later.
519+ // IE needs this div to be NON-EMPTY in order to properly
520+ // render jsPlumb endpoints, so that's why we add an " "!
521+
522+ // TODO: make sure varname doesn't contain any weird
523+ // characters that are illegal for CSS ID's ...
524+ var varDivID = 'global__' + varname ;
525+ curTr . find ( "td.stackFrameValue" ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
526+ }
512527 }
513528 } ) ;
514529 }
@@ -520,6 +535,12 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
520535
521536}
522537
538+ function isPrimitiveType ( obj ) {
539+ var typ = typeof obj ;
540+ return ( ( obj == null ) || ( typ == "number" ) || ( typ == "boolean" ) || ( typ == "string" ) ) ;
541+ }
542+
543+
523544// render the JS data object obj inside of jDomElt,
524545// which is a jQuery wrapped DOM object
525546// (obj is in a format encoded by cgi-bin/pg_encoder.py)
0 commit comments