@@ -1541,7 +1541,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
15411541 connectionEndpointIDs . set ( varDivID , heapObjID ) ;
15421542 }
15431543
1544- console . log ( 'CHANGED' , varname , prevValStringRepr , valStringRepr ) ;
1544+ // console.log('CHANGED', varname, prevValStringRepr, valStringRepr);
15451545 }
15461546
15471547 // SUPER HACK - set current value as a hidden string attribute
@@ -1583,58 +1583,44 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
15831583 // TODO: perhaps this table keeps on getting cleared out since it's done on enter()?!?
15841584 . append ( 'table' )
15851585 . attr ( 'class' , 'stackFrameVarTable' )
1586+ . each ( function ( d , i ) { console . log ( 'stackFrameDiv.enter()' , d . unique_hash ) ; } )
15861587
1587-
1588- /*
1589- stackFrameDiv.select('div.stackFrameHeader')
1590- .html(function(frame, i) {
1591- var funcName = htmlspecialchars(frame.func_name); // might contain '<' or '>' for weird names like <genexpr>
1592- var headerLabel = funcName + '()';
1593-
1594- var frameID = frame.frame_id; // optional (btw, this isn't a CSS id)
1595- if (frameID) {
1596- headerLabel = 'f' + frameID + ': ' + headerLabel;
1597- }
15981588
1599- // optional (btw, this isn't a CSS id)
1600- if (frame.parent_frame_id_list.length > 0) {
1601- var parentFrameID = frame.parent_frame_id_list[0];
1602- headerLabel = headerLabel + ' [parent=f' + parentFrameID + ']';
1603- }
1604-
1605- return headerLabel;
1606- });
1607- */
1608-
16091589 var stackVarTable = stackFrameDiv
16101590 . order ( ) // VERY IMPORTANT to put in the order corresponding to data elements
1591+ . each ( function ( d , i ) { console . log ( 'stackFrameDiv.order() POST' , d . unique_hash ) ; } )
16111592 . select ( 'table' ) . selectAll ( 'tr' )
16121593 . data ( function ( frame ) {
1613- // each list element contains a reference to the entire frame object as well as the variable name
1614- // TODO: look into whether we can use d3 parent nodes to avoid this hack ... http://bost.ocks.org/mike/nest/
1615- return frame . ordered_varnames . map ( function ( varname ) { return [ varname , frame ] ; } ) ;
1594+ // each list element contains a reference to the entire frame
1595+ // object as well as the variable name
1596+ // TODO: look into whether we can use d3 parent nodes to avoid
1597+ // this hack ... http://bost.ocks.org/mike/nest/
1598+ return frame . ordered_varnames . map ( function ( varname ) { return { varname :varname , frame :frame } ; } ) ;
16161599 } ,
1617- function ( d ) { return d [ 0 ] ; } // use variable name as key
1600+ function ( d ) { return d . varname ; } // use variable name as key
16181601 ) ;
16191602
16201603 stackVarTable
16211604 . enter ( )
16221605 . append ( 'tr' )
1606+ . each ( function ( d , i ) { console . log ( 'stackVarTable.enter()' , d ) ; } )
16231607
16241608
16251609 var stackVarTableCells = stackVarTable
16261610 . selectAll ( 'td' )
1611+ . each ( function ( d , i ) { console . log ( 'stackVarTable UPDATE' , d , i ) ; } )
16271612 . data ( function ( d , i ) { return [ d , d ] /* map identical data down both columns */ ; } )
16281613
16291614 stackVarTableCells . enter ( )
16301615 . append ( 'td' )
1616+ . each ( function ( d , i ) { console . log ( 'stackVarTableCells.enter()' , d , i ) ; } )
16311617
16321618 stackVarTableCells
16331619 . order ( ) // VERY IMPORTANT to put in the order corresponding to data elements
16341620 . attr ( 'class' , function ( d , i ) { return ( i == 0 ) ? 'stackFrameVar' : 'stackFrameValue' ; } )
16351621 . html ( function ( d , i ) {
1636- var varname = d [ 0 ] ;
1637- var frame = d [ 1 ] ;
1622+ var varname = d . varname ;
1623+ var frame = d . frame ;
16381624 if ( i == 0 ) {
16391625 if ( varname == '__return__' && ! frame . is_zombie ) {
16401626 return '<span class="retval">Return value</span>'
@@ -1648,8 +1634,10 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
16481634 }
16491635 } )
16501636 . each ( function ( d , i ) {
1651- var varname = d [ 0 ] ;
1652- var frame = d [ 1 ] ;
1637+ var varname = d . varname ;
1638+ var frame = d . frame ;
1639+
1640+ console . log ( 'stackVarTableCells.each()' , varname , i ) ;
16531641
16541642 if ( i == 1 ) {
16551643 var val = frame . encoded_locals [ varname ] ;
@@ -1687,7 +1675,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
16871675 connectionEndpointIDs . set ( varDivID , heapObjID ) ;
16881676 }
16891677
1690- console . log ( 'CHANGED' , varname , prevValStringRepr , valStringRepr ) ;
1678+ // console.log('CHANGED', varname, prevValStringRepr, valStringRepr);
16911679 }
16921680
16931681 // SUPER HACK - set current value as a hidden string attribute
@@ -1702,98 +1690,29 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
17021690
17031691 stackFrameDiv . exit ( ) . remove ( ) ;
17041692
1693+ // TODO: sometimes mistakenly renders TWICE on, say, closures :(
1694+ stackFrameDiv
1695+ . insert ( 'div' , ':first-child' ) // prepend header after the dust settles
1696+ . attr ( 'class' , 'stackFrameHeader' )
1697+ . html ( function ( frame , i ) {
1698+ var funcName = htmlspecialchars ( frame . func_name ) ; // might contain '<' or '>' for weird names like <genexpr>
1699+ var headerLabel = funcName + '()' ;
17051700
1701+ var frameID = frame . frame_id ; // optional (btw, this isn't a CSS id)
1702+ if ( frameID ) {
1703+ headerLabel = 'f' + frameID + ': ' + headerLabel ;
1704+ }
17061705
1707- function renderStackFrame ( frame , ind , is_zombie ) {
1708- var funcName = htmlspecialchars ( frame . func_name ) ; // might contain '<' or '>' for weird names like <genexpr>
1709- var frameID = frame . frame_id ; // optional (btw, this isn't a CSS id)
1710-
1711- // optional (btw, this isn't a CSS id)
1712- var parentFrameID = null ;
1713- if ( frame . parent_frame_id_list . length > 0 ) {
1714- parentFrameID = frame . parent_frame_id_list [ 0 ] ;
1715- }
1716-
1717- var localVars = frame . encoded_locals
1718-
1719- // the stackFrame div's id is simply its index ("stack<index>")
1720-
1721- var divClass , divID , headerDivID ;
1722- if ( is_zombie ) {
1723- divClass = 'zombieStackFrame' ;
1724- divID = myViz . generateID ( "zombie_stack" + ind ) ;
1725- headerDivID = myViz . generateID ( "zombie_stack_header" + ind ) ;
1726- }
1727- else {
1728- divClass = 'stackFrame' ;
1729- divID = myViz . generateID ( "stack" + ind ) ;
1730- headerDivID = myViz . generateID ( "stack_header" + ind ) ;
1731- }
1732-
1733- myViz . domRoot . find ( "#stack" ) . append ( '<div class="' + divClass + '" id="' + divID + '"></div>' ) ;
1734-
1735- var headerLabel = funcName + '()' ;
1736- if ( frameID ) {
1737- headerLabel = 'f' + frameID + ': ' + headerLabel ;
1738- }
1739- if ( parentFrameID ) {
1740- headerLabel = headerLabel + ' [parent=f' + parentFrameID + ']' ;
1741- }
1742- myViz . domRoot . find ( "#stack #" + divID ) . append ( '<div id="' + headerDivID + '" class="stackFrameHeader">' + headerLabel + '</div>' ) ;
1743-
1744- if ( frame . ordered_varnames . length > 0 ) {
1745- var tableID = divID + '_table' ;
1746- myViz . domRoot . find ( "#stack #" + divID ) . append ( '<table class="stackFrameVarTable" id="' + tableID + '"></table>' ) ;
1747-
1748- var tbl = myViz . domRoot . find ( "#" + tableID ) ;
1749-
1750- $ . each ( frame . ordered_varnames , function ( xxx , varname ) {
1751- var val = localVars [ varname ] ;
1752-
1753- // special treatment for displaying return value and indicating
1754- // that the function is about to return to its caller
1755- //
1756- // DON'T do this for zombie frames
1757- if ( varname == '__return__' && ! is_zombie ) {
1758- assert ( curEntry . event == 'return' ) ; // sanity check
1759-
1760- tbl . append ( '<tr><td colspan="2" class="returnWarning">About to return</td></tr>' ) ;
1761- tbl . append ( '<tr><td class="stackFrameVar"><span class="retval">Return value:</span></td><td class="stackFrameValue"></td></tr>' ) ;
1762- }
1763- else {
1764- tbl . append ( '<tr><td class="stackFrameVar">' + varname + '</td><td class="stackFrameValue"></td></tr>' ) ;
1765- }
1766-
1767- var curTr = tbl . find ( 'tr:last' ) ;
1768-
1769- if ( isPrimitiveType ( val ) ) {
1770- renderPrimitiveObject ( val , curTr . find ( "td.stackFrameValue" ) ) ;
1771- }
1772- else {
1773- // add a stub so that we can connect it with a connector later.
1774- // IE needs this div to be NON-EMPTY in order to properly
1775- // render jsPlumb endpoints, so that's why we add an " "!
1776-
1777- // make sure varname doesn't contain any weird
1778- // characters that are illegal for CSS ID's ...
1779- var varDivID = divID + '__' + varnameToCssID ( varname ) ;
1780- curTr . find ( "td.stackFrameValue" ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
1781-
1782- assert ( ! connectionEndpointIDs . has ( varDivID ) ) ;
1783-
1784- var heapObjID = myViz . generateID ( 'heap_object_' + getRefID ( val ) ) ;
1785- connectionEndpointIDs . set ( varDivID , heapObjID ) ;
1786- }
1787- } ) ;
1788- }
1789- }
1790-
1791- /*
1792- $.each(curEntry.stack_to_render, function(i, e) {
1793- renderStackFrame(e, i, e.is_zombie);
1794- });
1795- */
1706+ // optional (btw, this isn't a CSS id)
1707+ if ( frame . parent_frame_id_list . length > 0 ) {
1708+ var parentFrameID = frame . parent_frame_id_list [ 0 ] ;
1709+ headerLabel = headerLabel + ' [parent=f' + parentFrameID + ']' ;
1710+ }
17961711
1712+ console . log ( 'HEADER:' , i , headerLabel ) ;
1713+ return headerLabel ;
1714+ } ) ;
1715+
17971716
17981717
17991718 // finally add all the connectors!
0 commit comments