Skip to content

Commit 4ba183a

Browse files
committed
made isPrimitiveType and structurallyEquivalent into methods
1 parent 4483059 commit 4ba183a

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

‎v3/js/pytutor.js‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,13 +1942,13 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
19421942
$.each(heapObj, function(ind, child) {
19431943
if (ind < 1) return; // skip type tag
19441944

1945-
if (!isPrimitiveType(child)) {
1945+
if (!myViz.isPrimitiveType(child)) {
19461946
var childID = getRefID(child);
19471947

19481948
// comment this out to make "linked lists" that aren't
19491949
// structurally equivalent look good, e.g.,:
19501950
// x = (1, 2, (3, 4, 5, 6, (7, 8, 9, None)))
1951-
//if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
1951+
//if (myViz.structurallyEquivalent(heapObj, curEntry.heap[childID])) {
19521952
// updateCurLayout(childID, curRow, newRow);
19531953
//}
19541954
if (myViz.disableHeapNesting) {
@@ -1966,16 +1966,16 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
19661966

19671967
if (myViz.disableHeapNesting) {
19681968
var dictKey = child[0];
1969-
if (!isPrimitiveType(dictKey)) {
1969+
if (!myViz.isPrimitiveType(dictKey)) {
19701970
var keyChildID = getRefID(dictKey);
19711971
updateCurLayout(keyChildID, [], []);
19721972
}
19731973
}
19741974

19751975
var dictVal = child[1];
1976-
if (!isPrimitiveType(dictVal)) {
1976+
if (!myViz.isPrimitiveType(dictVal)) {
19771977
var childID = getRefID(dictVal);
1978-
if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
1978+
if (myViz.structurallyEquivalent(heapObj, curEntry.heap[childID])) {
19791979
updateCurLayout(childID, curRow, newRow);
19801980
}
19811981
else if (myViz.disableHeapNesting) {
@@ -1991,16 +1991,16 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
19911991

19921992
if (myViz.disableHeapNesting) {
19931993
var instKey = child[0];
1994-
if (!isPrimitiveType(instKey)) {
1994+
if (!myViz.isPrimitiveType(instKey)) {
19951995
var keyChildID = getRefID(instKey);
19961996
updateCurLayout(keyChildID, [], []);
19971997
}
19981998
}
19991999

20002000
var instVal = child[1];
2001-
if (!isPrimitiveType(instVal)) {
2001+
if (!myViz.isPrimitiveType(instVal)) {
20022002
var childID = getRefID(instVal);
2003-
if (structurallyEquivalent(heapObj, curEntry.heap[childID])) {
2003+
if (myViz.structurallyEquivalent(heapObj, curEntry.heap[childID])) {
20042004
updateCurLayout(childID, curRow, newRow);
20052005
}
20062006
else if (myViz.disableHeapNesting) {
@@ -2116,7 +2116,7 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
21162116
$.each(curEntry.ordered_globals, function(i, varname) {
21172117
var val = curEntry.globals[varname];
21182118
if (val !== undefined) { // might not be defined at this line, which is OKAY!
2119-
if (!isPrimitiveType(val)) {
2119+
if (!myViz.isPrimitiveType(val)) {
21202120
var id = getRefID(val);
21212121
updateCurLayout(id, null, []);
21222122
}
@@ -2127,7 +2127,7 @@ ExecutionVisualizer.prototype.precomputeCurTraceLayouts = function() {
21272127
$.each(frame.ordered_varnames, function(xxx, varname) {
21282128
var val = frame.encoded_locals[varname];
21292129

2130-
if (!isPrimitiveType(val)) {
2130+
if (!myViz.isPrimitiveType(val)) {
21312131
var id = getRefID(val);
21322132
updateCurLayout(id, null, []);
21332133
}
@@ -2416,7 +2416,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function(curEntry, curTople
24162416
existingConnectionEndpointIDs.remove(varDivID);
24172417

24182418
var val = curEntry.globals[varname];
2419-
if (isPrimitiveType(val)) {
2419+
if (myViz.isPrimitiveType(val)) {
24202420
myViz.renderPrimitiveObject(val, $(this));
24212421
}
24222422
else {
@@ -2640,7 +2640,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function(curEntry, curTople
26402640
existingConnectionEndpointIDs.remove(varDivID);
26412641

26422642
var val = frame.encoded_locals[varname];
2643-
if (isPrimitiveType(val)) {
2643+
if (myViz.isPrimitiveType(val)) {
26442644
myViz.renderPrimitiveObject(val, $(this));
26452645
}
26462646
else {
@@ -3148,7 +3148,7 @@ ExecutionVisualizer.prototype.renderPrimitiveObject = function(obj, d3DomElement
31483148

31493149

31503150
ExecutionVisualizer.prototype.renderNestedObject = function(obj, stepNum, d3DomElement) {
3151-
if (isPrimitiveType(obj)) {
3151+
if (this.isPrimitiveType(obj)) {
31523152
this.renderPrimitiveObject(obj, d3DomElement);
31533153
}
31543154
else {
@@ -3614,9 +3614,9 @@ function varnameToCssID(varname) {
36143614

36153615

36163616
// compare two JSON-encoded compound objects for structural equivalence:
3617-
function structurallyEquivalent(obj1, obj2) {
3617+
ExecutionVisualizer.prototype.structurallyEquivalent = function(obj1, obj2) {
36183618
// punt if either isn't a compound type
3619-
if (isPrimitiveType(obj1) || isPrimitiveType(obj2)) {
3619+
if (this.isPrimitiveType(obj1) || this.isPrimitiveType(obj2)) {
36203620
return false;
36213621
}
36223622

@@ -3665,7 +3665,7 @@ function structurallyEquivalent(obj1, obj2) {
36653665
}
36663666

36673667

3668-
function isPrimitiveType(obj) {
3668+
ExecutionVisualizer.prototype.isPrimitiveType = function(obj) {
36693669
var hook_result = try_hook("isPrimitiveType", {obj:obj});
36703670
if (hook_result[0]) return hook_result[1];
36713671

0 commit comments

Comments
 (0)