@@ -63,12 +63,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6363
6464*/
6565
66- // include hooks.js after you include pytutor.js, if you want to use hooks
67- // see hooks.js for more instructions. (hooking code created by David Pritchard)
68- var try_hook = function ( hook_name , args ) {
69- return [ false ] ; // just a stub
70- }
71-
7266var SVG_ARROW_POLYGON = '0,3 12,3 12,0 18,5 12,10 12,7 0,7' ;
7367var SVG_ARROW_HEIGHT = 10 ; // must match height of SVG_ARROW_POLYGON
7468
@@ -252,7 +246,7 @@ function ExecutionVisualizer(domRootID, dat, params) {
252246 // API for adding a hook, created by David Pritchard
253247 this . pytutor_hooks = { } ; // keys, hook names; values, list of functions
254248
255- try_hook ( "end_constructor" , { myViz :this } ) ;
249+ this . try_hook ( "end_constructor" , { myViz :this } ) ;
256250
257251 this . hasRendered = false ;
258252
@@ -724,7 +718,7 @@ ExecutionVisualizer.prototype.render = function() {
724718 this . domRoot . find ( '#vizLayoutTdFirst' ) . hide ( ) ; // gigantic hack!
725719 }
726720
727- try_hook ( "end_render" , { myViz :this } ) ;
721+ this . try_hook ( "end_render" , { myViz :this } ) ;
728722
729723 this . precomputeCurTraceLayouts ( ) ;
730724
@@ -1404,7 +1398,7 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
14041398 else {
14051399 this . updateOutputFull ( smoothTransition ) ;
14061400 }
1407- try_hook ( "end_updateOutput" , { myViz :this } ) ;
1401+ this . try_hook ( "end_updateOutput" , { myViz :this } ) ;
14081402}
14091403
14101404ExecutionVisualizer . prototype . updateOutputFull = function ( smoothTransition ) {
@@ -2005,7 +1999,7 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
20051999 }
20062000
20072001 function isLinearObj ( heapObj ) {
2008- var hook_result = try_hook ( "isLinearObj" , { heapObj :heapObj } ) ;
2002+ var hook_result = myViz . try_hook ( "isLinearObj" , { heapObj :heapObj } ) ;
20092003 if ( hook_result [ 0 ] ) return hook_result [ 1 ] ;
20102004
20112005 return heapObj [ 0 ] == 'LIST' || heapObj [ 0 ] == 'TUPLE' || heapObj [ 0 ] == 'SET' ;
@@ -3005,8 +2999,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function(curEntry, curTople
30052999 highlight_frame ( myViz . generateID ( 'globals' ) ) ;
30063000 }
30073001
3008- try_hook ( "end_renderDataStructures" , { myViz :myViz } ) ;
3009-
3002+ myViz . try_hook ( "end_renderDataStructures" , { myViz :myViz } ) ;
30103003}
30113004
30123005
@@ -3185,7 +3178,7 @@ ExecutionVisualizer.prototype.renderTabularView = function() {
31853178// rendering functions, which all take a d3 dom element to anchor the
31863179// new element to render
31873180ExecutionVisualizer . prototype . renderPrimitiveObject = function ( obj , d3DomElement ) {
3188- if ( try_hook ( "renderPrimitiveObject" , { obj :obj , d3DomElement :d3DomElement } ) [ 0 ] )
3181+ if ( this . try_hook ( "renderPrimitiveObject" , { obj :obj , d3DomElement :d3DomElement } ) [ 0 ] )
31893182 return ;
31903183
31913184 var typ = typeof obj ;
@@ -3300,7 +3293,7 @@ function(objID, stepNum, d3DomElement, isTopLevel) {
33003293 typeLabelPrefix = 'id' + objID + ':' ;
33013294 }
33023295
3303- var hook_result = try_hook ( "renderCompoundObject" ,
3296+ var hook_result = myViz . try_hook ( "renderCompoundObject" ,
33043297 { objID :objID , d3DomElement :d3DomElement ,
33053298 isTopLevel :isTopLevel , obj :obj ,
33063299 typeLabelPrefix :typeLabelPrefix ,
@@ -3745,7 +3738,7 @@ ExecutionVisualizer.prototype.structurallyEquivalent = function(obj1, obj2) {
37453738
37463739
37473740ExecutionVisualizer . prototype . isPrimitiveType = function ( obj ) {
3748- var hook_result = try_hook ( "isPrimitiveType" , { obj :obj } ) ;
3741+ var hook_result = this . try_hook ( "isPrimitiveType" , { obj :obj } ) ;
37493742 if ( hook_result [ 0 ] ) return hook_result [ 1 ] ;
37503743
37513744 // null is a primitive
0 commit comments