@@ -106,6 +106,7 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
106106// compactFuncLabels - render functions with a 'func' prefix and no type label
107107// pyCrazyMode - run with Py2crazy, which provides expression-level
108108// granularity instead of line-level granularity (HIGHLY EXPERIMENTAL!)
109+ // hideCode - hide the code display and show only the data structure viz
109110function ExecutionVisualizer ( domRootID , dat , params ) {
110111 this . curInputCode = dat . code . rtrim ( ) ; // kill trailing spaces
111112 this . curTrace = dat . trace ;
@@ -487,13 +488,11 @@ ExecutionVisualizer.prototype.render = function() {
487488 }
488489
489490 this . domRoot . find ( "#jmpFirstInstr" ) . click ( function ( ) {
490- myViz . curInstr = 0 ;
491- myViz . updateOutput ( ) ;
491+ myViz . renderStep ( 0 ) ;
492492 } ) ;
493493
494494 this . domRoot . find ( "#jmpLastInstr" ) . click ( function ( ) {
495- myViz . curInstr = myViz . curTrace . length - 1 ;
496- myViz . updateOutput ( ) ;
495+ myViz . renderStep ( myViz . curTrace . length - 1 ) ;
497496 } ) ;
498497
499498 this . domRoot . find ( "#jmpStepBack" ) . click ( function ( ) {
@@ -541,8 +540,7 @@ ExecutionVisualizer.prototype.render = function() {
541540 // was changed by a user-initiated event, then this code should be
542541 // executed ...
543542 if ( evt . originalEvent ) {
544- myViz . curInstr = ui . value ;
545- myViz . updateOutput ( ) ;
543+ myViz . renderStep ( ui . value ) ;
546544 }
547545 } ) ;
548546
@@ -557,10 +555,16 @@ ExecutionVisualizer.prototype.render = function() {
557555 this . curInstr = this . curTrace . length - 1 ;
558556 }
559557
558+ if ( this . params . hideCode ) {
559+ this . domRoot . find ( '#vizLayoutTdFirst' ) . hide ( ) ; // gigantic hack!
560+ }
561+
560562
561563 this . precomputeCurTraceLayouts ( ) ;
562564
563- this . renderPyCodeOutput ( ) ;
565+ if ( ! this . params . hideCode ) {
566+ this . renderPyCodeOutput ( ) ;
567+ }
564568
565569 this . updateOutput ( ) ;
566570
@@ -1193,7 +1197,17 @@ function htmlWithHighlight(inputStr, highlightInd, extent, highlightCssClass) {
11931197// This function is called every time the display needs to be updated
11941198// smoothTransition is OPTIONAL!
11951199ExecutionVisualizer . prototype . updateOutput = function ( smoothTransition ) {
1200+ if ( this . params . hideCode ) {
1201+ this . updateOutputMini ( ) ;
1202+ }
1203+ else {
1204+ this . updateOutputFull ( smoothTransition ) ;
1205+ }
1206+ }
1207+
1208+ ExecutionVisualizer . prototype . updateOutputFull = function ( smoothTransition ) {
11961209 assert ( this . curTrace ) ;
1210+ assert ( ! this . params . hideCode ) ;
11971211
11981212 var myViz = this ; // to prevent confusion of 'this' inside of nested functions
11991213
@@ -1624,7 +1638,9 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
16241638
16251639
16261640 // finally, render all of the data structures
1627- this . renderDataStructures ( ) ;
1641+ var curEntry = this . curTrace [ this . curInstr ] ;
1642+ var curToplevelLayout = this . curTraceLayouts [ this . curInstr ] ;
1643+ this . renderDataStructures ( curEntry , curToplevelLayout ) ;
16281644
16291645 this . enterViewAnnotationsMode ( ) ; // ... and render optional annotations (if any exist)
16301646
@@ -1652,7 +1668,26 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
16521668 }
16531669 }
16541670
1655- } // end of updateOutput
1671+ } // end of updateOutputFull
1672+
1673+
1674+ ExecutionVisualizer . prototype . updateOutputMini = function ( ) {
1675+ assert ( this . params . hideCode ) ;
1676+ var curEntry = this . curTrace [ this . curInstr ] ;
1677+ var curToplevelLayout = this . curTraceLayouts [ this . curInstr ] ;
1678+ this . renderDataStructures ( curEntry , curToplevelLayout ) ;
1679+
1680+ this . enterViewAnnotationsMode ( ) ; // ... and render optional annotations (if any exist)
1681+ }
1682+
1683+
1684+ ExecutionVisualizer . prototype . renderStep = function ( step ) {
1685+ assert ( 0 <= step ) ;
1686+ assert ( step < this . curTrace . length ) ;
1687+
1688+ this . curInstr = step ;
1689+ this . updateOutput ( ) ;
1690+ }
16561691
16571692
16581693// Pre-compute the layout of top-level heap objects for ALL execution
@@ -1973,13 +2008,10 @@ var heapPtrSrcRE = /__heap_pointer_src_/;
19732008// INLINE within each stack frame without any explicit representation
19742009// of data structure aliasing. That is, aliased objects were rendered
19752010// multiple times, and a unique ID label was used to identify aliases.
1976- ExecutionVisualizer . prototype . renderDataStructures = function ( ) {
2011+ ExecutionVisualizer . prototype . renderDataStructures = function ( curEntry , curToplevelLayout ) {
19772012
19782013 var myViz = this ; // to prevent confusion of 'this' inside of nested functions
19792014
1980- var curEntry = this . curTrace [ this . curInstr ] ;
1981- var curToplevelLayout = this . curTraceLayouts [ this . curInstr ] ;
1982-
19832015 // for simplicity (but sacrificing some performance), delete all
19842016 // connectors and redraw them from scratch. doing so avoids mysterious
19852017 // jsPlumb connector alignment issues when the visualizer's enclosing
0 commit comments