@@ -1430,13 +1430,16 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
14301430
14311431
14321432 function recurseIntoObject ( id , curRow , newRow ) {
1433+ //console.log('recurseIntoObject', id,
1434+ // $.extend(true /* make a deep copy */ , [], curRow),
1435+ // $.extend(true /* make a deep copy */ , [], newRow));
14331436
14341437 // heuristic for laying out 1-D linked data structures: check for enclosing elements that are
14351438 // structurally identical and then lay them out as siblings in the same "row"
14361439 var heapObj = curEntry . heap [ id ] ;
14371440 assert ( heapObj ) ;
14381441
1439- if ( heapObj [ 0 ] == 'LIST' || heapObj [ 0 ] == 'TUPLE' ) {
1442+ if ( heapObj [ 0 ] == 'LIST' || heapObj [ 0 ] == 'TUPLE' || heapObj [ 0 ] == 'SET' ) {
14401443 $ . each ( heapObj , function ( ind , child ) {
14411444 if ( ind < 1 ) return ; // skip type tag
14421445
@@ -1445,28 +1448,48 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
14451448 if ( structurallyEquivalent ( heapObj , curEntry . heap [ childID ] ) ) {
14461449 updateCurLayout ( childID , curRow , newRow ) ;
14471450 }
1451+ else if ( myViz . disableHeapNesting ) {
1452+ updateCurLayout ( childID , curRow , [ ] ) ;
1453+ }
14481454 }
14491455 } ) ;
14501456 }
14511457 else if ( heapObj [ 0 ] == 'DICT' ) {
14521458 $ . each ( heapObj , function ( ind , child ) {
14531459 if ( ind < 1 ) return ; // skip type tag
14541460
1461+ if ( myViz . disableHeapNesting ) {
1462+ var dictKey = child [ 0 ] ;
1463+ if ( ! isPrimitiveType ( dictKey ) ) {
1464+ var keyChildID = getRefID ( dictKey ) ;
1465+ updateCurLayout ( keyChildID , curRow , [ ] ) ;
1466+ }
1467+ }
1468+
14551469 var dictVal = child [ 1 ] ;
14561470 if ( ! isPrimitiveType ( dictVal ) ) {
14571471 var childID = getRefID ( dictVal ) ;
14581472 if ( structurallyEquivalent ( heapObj , curEntry . heap [ childID ] ) ) {
14591473 updateCurLayout ( childID , curRow , newRow ) ;
14601474 }
1475+ else if ( myViz . disableHeapNesting ) {
1476+ updateCurLayout ( childID , curRow , [ ] ) ;
1477+ }
14611478 }
14621479 } ) ;
14631480 }
1464- else if ( heapObj [ 0 ] == 'INSTANCE' ) {
1481+ else if ( heapObj [ 0 ] == 'INSTANCE' || heapObj [ 0 ] == 'CLASS' ) {
14651482 jQuery . each ( heapObj , function ( ind , child ) {
1466- if ( ind < 2 ) return ; // skip type tag and class name
1467-
1468- // instance keys are always strings, so no need to recurse
1469- assert ( typeof child [ 0 ] == "string" ) ;
1483+ var headerLength = ( heapObj [ 0 ] == 'INSTANCE' ) ? 2 : 3 ;
1484+ if ( ind < headerLength ) return ;
1485+
1486+ if ( myViz . disableHeapNesting ) {
1487+ var instKey = child [ 0 ] ;
1488+ if ( ! isPrimitiveType ( instKey ) ) {
1489+ var keyChildID = getRefID ( instKey ) ;
1490+ updateCurLayout ( keyChildID , curRow , [ ] ) ;
1491+ }
1492+ }
14701493
14711494 var instVal = child [ 1 ] ;
14721495 if ( ! isPrimitiveType ( instVal ) ) {
@@ -2010,9 +2033,16 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
20102033 var valTd = newRow . find ( 'td:last' ) ;
20112034
20122035 // the keys should always be strings, so render them directly (and without quotes):
2013- assert ( typeof kvPair [ 0 ] == "string" ) ;
2014- var attrnameStr = htmlspecialchars ( kvPair [ 0 ] ) ;
2015- keyTd . append ( '<span class="keyObj">' + attrnameStr + '</span>' ) ;
2036+ // (actually this isn't the case when strings are rendered on the heap)
2037+ if ( typeof kvPair [ 0 ] == "string" ) {
2038+ // common case ...
2039+ var attrnameStr = htmlspecialchars ( kvPair [ 0 ] ) ;
2040+ keyTd . append ( '<span class="keyObj">' + attrnameStr + '</span>' ) ;
2041+ }
2042+ else {
2043+ // when strings are rendered as heap objects ...
2044+ renderNestedObject ( kvPair [ 0 ] , keyTd ) ;
2045+ }
20162046
20172047 // values can be arbitrary objects, so recurse:
20182048 renderNestedObject ( kvPair [ 1 ] , valTd ) ;
@@ -2567,7 +2597,7 @@ function structurallyEquivalent(obj1, obj2) {
25672597 startingInd = 3 ;
25682598 }
25692599 else {
2570- return false ;
2600+ return false ; // punt on all other types
25712601 }
25722602
25732603 var obj1fields = d3 . map ( ) ;
0 commit comments