@@ -115,6 +115,8 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
115115// granularity instead of line-level granularity (HIGHLY EXPERIMENTAL!)
116116// hideCode - hide the code display and show only the data structure viz
117117// tabularView - render a tabular view of ALL steps at once (EXPERIMENTAL)
118+ // lang - to render labels in a style appropriate for other languages.
119+ // e.g., 'js' for JavaScript, 'java' for Java [default is Python]
118120// debugMode - some extra debugging printouts
119121function ExecutionVisualizer ( domRootID , dat , params ) {
120122 this . curInputCode = dat . code . rtrim ( ) ; // kill trailing spaces
@@ -3215,10 +3217,10 @@ function(objID, stepNum, d3DomElement, isTopLevel) {
32153217
32163218 assert ( obj . length >= 1 ) ;
32173219 if ( obj . length == 1 ) {
3218- d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + 'empty ' + label + '</div>' ) ;
3220+ d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + 'empty ' + myViz . getRealLabel ( label ) + '</div>' ) ;
32193221 }
32203222 else {
3221- d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + label + '</div>' ) ;
3223+ d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + myViz . getRealLabel ( label ) + '</div>' ) ;
32223224 d3DomElement . append ( '<table class="' + label + 'Tbl"></table>' ) ;
32233225 var tbl = d3DomElement . children ( 'table' ) ;
32243226
@@ -3292,7 +3294,11 @@ function(objID, stepNum, d3DomElement, isTopLevel) {
32923294 assert ( obj . length >= headerLength ) ;
32933295
32943296 if ( isInstance ) {
3295- d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + ' instance</div>' ) ;
3297+ if ( obj . length === headerLength ) {
3298+ d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + 'empty ' + myViz . getRealLabel ( 'instance' ) + '</div>' ) ;
3299+ } else {
3300+ d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + ' ' + myViz . getRealLabel ( 'instance' ) + '</div>' ) ;
3301+ }
32963302 }
32973303 else {
32983304 var superclassStr = '' ;
@@ -3471,6 +3477,19 @@ ExecutionVisualizer.prototype.redrawConnectors = function() {
34713477}
34723478
34733479
3480+ ExecutionVisualizer . prototype . getRealLabel = function ( label ) {
3481+ if ( this . params . lang === 'js' ) {
3482+ if ( label === 'list' ) {
3483+ return 'array' ;
3484+ } else if ( label === 'instance' ) {
3485+ return 'object' ;
3486+ }
3487+ } else {
3488+ return label ;
3489+ }
3490+ } ;
3491+
3492+
34743493// Utilities
34753494
34763495
0 commit comments