Skip to content

Commit 8d3b756

Browse files
committed
added stepNum for more uniqueness
1 parent 2af1282 commit 8d3b756

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

‎v3/js/pytutor.js‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function(curEntry, curTople
21632163
// TODO: add a smoother transition in the future
21642164
// Right now, just delete the old element and render a new one in its place
21652165
$(this).empty();
2166-
myViz.renderCompoundObject(objID, $(this), true);
2166+
myViz.renderCompoundObject(objID, myViz.curInstr, $(this), true);
21672167
});
21682168

21692169
// delete a toplevelHeapObject
@@ -2835,18 +2835,19 @@ ExecutionVisualizer.prototype.renderPrimitiveObject = function(obj, d3DomElement
28352835
}
28362836

28372837

2838-
ExecutionVisualizer.prototype.renderNestedObject = function(obj, d3DomElement) {
2838+
ExecutionVisualizer.prototype.renderNestedObject = function(obj, stepNum, d3DomElement) {
28392839
if (isPrimitiveType(obj)) {
28402840
this.renderPrimitiveObject(obj, d3DomElement);
28412841
}
28422842
else {
2843-
this.renderCompoundObject(getRefID(obj), d3DomElement, false);
2843+
// obj is a ["REF", <int>] so dereference the 'pointer' to render that object
2844+
this.renderCompoundObject(getRefID(obj), stepNum, d3DomElement, false);
28442845
}
28452846
}
28462847

28472848

28482849
ExecutionVisualizer.prototype.renderCompoundObject =
2849-
function(objID, d3DomElement, isTopLevel) {
2850+
function(objID, stepNum, d3DomElement, isTopLevel) {
28502851
var myViz = this; // to prevent confusion of 'this' inside of nested functions
28512852

28522853
if (!isTopLevel && myViz.jsPlumbManager.renderedObjectIDs.has(objID)) {
@@ -2898,10 +2899,8 @@ function(objID, d3DomElement, isTopLevel) {
28982899

28992900
myViz.jsPlumbManager.renderedObjectIDs.set(objID, 1);
29002901

2901-
var curEntry = this.curTrace[this.curInstr]; // was originally a param
2902-
// in renderDataStructures
2903-
2904-
var obj = curEntry.heap[objID];
2902+
var curHeap = myViz.curTrace[stepNum].heap;
2903+
var obj = curHeap[objID];
29052904
assert($.isArray(obj));
29062905

29072906
// prepend the type label with a memory address label
@@ -2942,7 +2941,7 @@ function(objID, d3DomElement, isTopLevel) {
29422941
headerTr.find('td:last').append(ind - 1);
29432942

29442943
contentTr.append('<td class="'+ label + 'Elt"></td>');
2945-
myViz.renderNestedObject(val, contentTr.find('td:last'));
2944+
myViz.renderNestedObject(val, stepNum, contentTr.find('td:last'));
29462945
});
29472946
}
29482947
else if (obj[0] == 'SET') {
@@ -2971,7 +2970,7 @@ function(objID, d3DomElement, isTopLevel) {
29712970

29722971
var curTr = tbl.find('tr:last');
29732972
curTr.append('<td class="setElt"></td>');
2974-
myViz.renderNestedObject(val, curTr.find('td:last'));
2973+
myViz.renderNestedObject(val, stepNum, curTr.find('td:last'));
29752974
});
29762975
}
29772976
else if (obj[0] == 'DICT') {
@@ -2986,8 +2985,8 @@ function(objID, d3DomElement, isTopLevel) {
29862985
var key = kvPair[0];
29872986
var val = kvPair[1];
29882987

2989-
myViz.renderNestedObject(key, keyTd);
2990-
myViz.renderNestedObject(val, valTd);
2988+
myViz.renderNestedObject(key, stepNum, keyTd);
2989+
myViz.renderNestedObject(val, stepNum, valTd);
29912990
});
29922991
}
29932992
}
@@ -3040,11 +3039,11 @@ function(objID, d3DomElement, isTopLevel) {
30403039
}
30413040
else {
30423041
// when strings are rendered as heap objects ...
3043-
myViz.renderNestedObject(kvPair[0], keyTd);
3042+
myViz.renderNestedObject(kvPair[0], stepNum, keyTd);
30443043
}
30453044

30463045
// values can be arbitrary objects, so recurse:
3047-
myViz.renderNestedObject(kvPair[1], valTd);
3046+
myViz.renderNestedObject(kvPair[1], stepNum, valTd);
30483047
});
30493048
}
30503049

0 commit comments

Comments
 (0)