Skip to content

Commit 5d097da

Browse files
author
Philip Guo
committed
works slightly better
1 parent 5d2e852 commit 5d097da

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

PyTutorGAE/js/pytutor.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,47 +1572,45 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
15721572
*/
15731573

15741574

1575-
var stackD3 = d3.select('#stack')
1576-
.selectAll('div')
1575+
var stackDiv = myViz.domRootD3.select('#stack');
1576+
1577+
var stackFrameDiv = stackDiv.selectAll('div')
15771578
.data(curEntry.stack_to_render, function(frame, i) {
15781579
// use a frankenstein combination of frame identifiers and also the INDEX (stack position)
15791580
// as the join key, to properly handle closures and recursive calls of the same function
15801581
return frame.func_name + '_' + String(frame.frame_id) + '_' + String(frame.parent_frame_id_list) + '_' + String(frame.is_zombie) + '_' + i;
15811582
});
1582-
1583-
// ENTER - create a new stack frame div for each entry in curEntry.stack_to_render
1584-
var stackEnter = stackD3.enter();
15851583

1586-
var stackFrame = stackEnter.append('div')
1587-
.each(function(frame, i) {
1588-
console.log('APPEND DIV', (frame.func_name + '_' + String(frame.frame_id) + '_' + String(frame.parent_frame_id_list) + '_' + i));
1589-
})
1584+
stackFrameDiv.enter().append('div')
15901585
.attr('class', function(d, i) {return d.is_zombie ? 'zombieStackFrame' : 'stackFrame';})
15911586
.attr('id', function(d, i) {return d.is_zombie ? myViz.generateID("zombie_stack" + i) : myViz.generateID("stack" + i);});
15921587

1593-
var stackVarsTable = stackFrame
1588+
1589+
var stackVarTable = stackFrameDiv
1590+
.each(function(frame, i) {
1591+
console.log('ENTER/UPDATE DIV', (frame.func_name + '_' + String(frame.frame_id) + '_' + String(frame.parent_frame_id_list) + '_' + i));
1592+
})
15941593
.selectAll('li')
1595-
.data(function(frame, i) {
1594+
.data(function(frame) {
15961595
// each list element contains a reference to the entire frame object as well as the variable name
15971596
// TODO: look into whether we can use d3 parent nodes to avoid this hack ... http://bost.ocks.org/mike/nest/
15981597
return frame.ordered_varnames.map(function(e) {return [e, frame];});
15991598
},
16001599
function(d) {return d[0];} // use variable name as key
16011600
);
16021601

1603-
stackVarsTable
1602+
stackVarTable
16041603
.enter()
1605-
.append('li');
1606-
1607-
stackVarsTable
1604+
.append('li')
16081605
.html(function(d, i) {
16091606
var varname = d[0];
16101607
var frame = d[1];
16111608
return varname + '_' + frame.func_name;
16121609
});
16131610

1614-
stackVarsTable.exit().remove();
1611+
stackVarTable.exit().remove();
16151612

1613+
stackFrameDiv.exit().remove();
16161614

16171615
/*
16181616
stackFrame.enter()
@@ -1696,10 +1694,6 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
16961694
.remove
16971695
*/
16981696

1699-
// EXIT - stack frame
1700-
stackD3.exit()
1701-
.remove()
1702-
17031697

17041698
function renderStackFrame(frame, ind, is_zombie) {
17051699
var funcName = htmlspecialchars(frame.func_name); // might contain '<' or '>' for weird names like <genexpr>

0 commit comments

Comments
 (0)