@@ -83,8 +83,8 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
8383// editCodeBaseURL - the base URL to visit when the user clicks 'Edit code' (if null, then 'Edit code' link hidden)
8484// allowEditAnnotations - allow user to edit per-step annotations (default: false)
8585// embeddedMode - shortcut for hideOutput=true, allowEditAnnotations=false
86- // disableHeapNesting - if true, then render all heap objects at the top level (i.e., no nested objects)
8786// codeDivWidth=350, codeDivHeight=400
87+ // disableHeapNesting - if true, then render all heap objects at the top level (i.e., no nested objects)
8888// drawParentPointers - if true, then draw environment diagram parent pointers for all frames
8989// WARNING: there are hard-to-debug MEMORY LEAKS associated with activating this option
9090// textualMemoryLabels - render references using textual memory labels rather than as jsPlumb arrows.
@@ -1740,8 +1740,8 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
17401740 // $.extend(true /* make a deep copy */ , [], curRow),
17411741 // $.extend(true /* make a deep copy */ , [], newRow));
17421742
1743- // heuristic for laying out 1-D linked data structures:
1744- // try to lay them out as " siblings" in the same row
1743+ // heuristic for laying out 1-D linked data structures: check for enclosing elements that are
1744+ // structurally identical and then lay them out as siblings in the same " row"
17451745 var heapObj = curEntry . heap [ id ] ;
17461746 assert ( heapObj ) ;
17471747
@@ -1751,12 +1751,12 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
17511751
17521752 if ( ! isPrimitiveType ( child ) ) {
17531753 var childID = getRefID ( child ) ;
1754- if ( myViz . disableHeapNesting ) {
1755- updateCurLayout ( childID , [ ] , [ ] ) ;
1756- }
1757- else {
1754+ if ( structurallyEquivalent ( heapObj , curEntry . heap [ childID ] ) ) {
17581755 updateCurLayout ( childID , curRow , newRow ) ;
17591756 }
1757+ else if ( myViz . disableHeapNesting ) {
1758+ updateCurLayout ( childID , [ ] , [ ] ) ;
1759+ }
17601760 }
17611761 } ) ;
17621762 }
@@ -1775,12 +1775,12 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
17751775 var dictVal = child [ 1 ] ;
17761776 if ( ! isPrimitiveType ( dictVal ) ) {
17771777 var childID = getRefID ( dictVal ) ;
1778- if ( myViz . disableHeapNesting ) {
1779- updateCurLayout ( childID , [ ] , [ ] ) ;
1780- }
1781- else {
1778+ if ( structurallyEquivalent ( heapObj , curEntry . heap [ childID ] ) ) {
17821779 updateCurLayout ( childID , curRow , newRow ) ;
17831780 }
1781+ else if ( myViz . disableHeapNesting ) {
1782+ updateCurLayout ( childID , [ ] , [ ] ) ;
1783+ }
17841784 }
17851785 } ) ;
17861786 }
@@ -1800,12 +1800,12 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
18001800 var instVal = child [ 1 ] ;
18011801 if ( ! isPrimitiveType ( instVal ) ) {
18021802 var childID = getRefID ( instVal ) ;
1803- if ( myViz . disableHeapNesting ) {
1804- updateCurLayout ( childID , [ ] , [ ] ) ;
1805- }
1806- else {
1803+ if ( structurallyEquivalent ( heapObj , curEntry . heap [ childID ] ) ) {
18071804 updateCurLayout ( childID , curRow , newRow ) ;
18081805 }
1806+ else if ( myViz . disableHeapNesting ) {
1807+ updateCurLayout ( childID , [ ] , [ ] ) ;
1808+ }
18091809 }
18101810 } ) ;
18111811 }
0 commit comments