Skip to content

Commit f4dc20d

Browse files
author
Philip Guo
committed
on we march ...
1 parent cc78968 commit f4dc20d

2 files changed

Lines changed: 42 additions & 21 deletions

File tree

edu-python.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ div.globalFrame {
437437
margin-bottom: 15px;
438438
padding: 2px;
439439
padding-left: 8px;
440-
font-size: 12pt;
440+
font-size: 11pt;
441441
}
442442

443443
/* apply to the currently selected stack frame (e.g., on mouse hover) */
@@ -465,7 +465,7 @@ div.inactiveStackFrameHeader {
465465

466466
td.stackFrameVar {
467467
text-align: right;
468-
padding-right: 10px;
468+
padding-right: 8px;
469469
min-width: 120px; /* to prevent excess jittering as new variables are added*/
470470
}
471471

edu-python.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ function updateOutput() {
239239
// Renders the current trace entry (curEntry) into the div named by vizDiv
240240
function renderDataStructures(curEntry, vizDiv) {
241241
renderDataStructuresVersion1(curEntry, vizDiv);
242-
243242
//renderDataStructuresVersion2(curEntry, vizDiv);
244243
}
245244

@@ -392,12 +391,12 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
392391
var funcName = htmlspecialchars(frame[0]); // might contain '<' or '>' for weird names like <genexpr>
393392
var localVars = frame[1];
394393

395-
// the stackFrame div's id is simply its index ("stack_<index>")
394+
// the stackFrame div's id is simply its index ("stack<index>")
396395
var divClass = (i==0) ? "stackFrame topStackFrame" : "stackFrame";
397-
var divID = "stack_" + i;
396+
var divID = "stack" + i;
398397
$(vizDiv + " #stack").append('<div class="' + divClass + '" id="' + divID + '"></div>');
399398

400-
var headerDivID = "stack_header_" + i;
399+
var headerDivID = "stack_header" + i;
401400
$(vizDiv + " #stack #" + divID).append('<div id="' + headerDivID + '" class="stackFrameHeader inactiveStackFrameHeader">' + funcName + '</div>');
402401

403402
// render locals in alphabetical order for tidiness:
@@ -411,18 +410,6 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
411410
}
412411
orderedVarnames.sort();
413412

414-
415-
/*
416-
<table class="stackFrameVarTable" id="TowerOfHanoi1_table">
417-
<tr>
418-
<td class="stackFrameVar">a</td>
419-
<!-- IE needs the div to be NON-EMPTY in order to properly
420-
render the plumb endpoints!!! -->
421-
<td class="stackFrameValue"><div id="TowerOfHanoi1_a">&nbsp;</div></td>
422-
</tr>
423-
</table>
424-
*/
425-
426413
if (orderedVarnames.length > 0) {
427414
var tableID = divID + '_table';
428415
$(vizDiv + " #stack #" + divID).append('<table class="stackFrameVarTable" id="' + tableID + '"></table>');
@@ -438,15 +425,29 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
438425
else {
439426
curTr.find("td.stackFrameVar").html(varname);
440427
}
441-
renderData(val, curTr.find("td.stackFrameValue"));
428+
429+
// render primitives inline and compound types on the heap
430+
if (isPrimitiveType(val)) {
431+
renderData(val, curTr.find("td.stackFrameValue"));
432+
}
433+
else {
434+
// add a stub so that we can connect it with a connector later.
435+
// IE needs this div to be NON-EMPTY in order to properly
436+
// render jsPlumb endpoints, so that's why we add an "&nbsp;"!
437+
438+
// TODO: make sure varname doesn't contain any weird
439+
// characters that are illegal for CSS ID's ...
440+
var varDivID = divID + '__' + varname;
441+
curTr.find("td.stackFrameValue").append('<div id="' + varDivID + '">&nbsp;</div>');
442+
}
442443
});
443444
}
444445
});
445446
}
446447

447448

448449
// render globals LAST:
449-
$(vizDiv + " #stack").append('<div class="globalFrame" id="globals"><div class="stackFrameHeader inactiveStackFrameHeader">Global variables</div></div>');
450+
$(vizDiv + " #stack").append('<div class="globalFrame" id="globals"><div id="globals_header" class="stackFrameHeader inactiveStackFrameHeader">Global variables</div></div>');
450451

451452
var nonEmptyGlobals = false;
452453
var curGlobalFields = {};
@@ -508,7 +509,21 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
508509
tbl.append('<tr><td class="stackFrameVar"></td><td class="stackFrameValue"></td></tr>');
509510
var curTr = tbl.find('tr:last');
510511
curTr.find("td.stackFrameVar").html(varname);
511-
renderData(val, curTr.find("td.stackFrameValue"));
512+
513+
// render primitives inline
514+
if (isPrimitiveType(val)) {
515+
renderData(val, curTr.find("td.stackFrameValue"));
516+
}
517+
else {
518+
// add a stub so that we can connect it with a connector later.
519+
// IE needs this div to be NON-EMPTY in order to properly
520+
// render jsPlumb endpoints, so that's why we add an "&nbsp;"!
521+
522+
// TODO: make sure varname doesn't contain any weird
523+
// characters that are illegal for CSS ID's ...
524+
var varDivID = 'global__' + varname;
525+
curTr.find("td.stackFrameValue").append('<div id="' + varDivID + '">&nbsp;</div>');
526+
}
512527
}
513528
});
514529
}
@@ -520,6 +535,12 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
520535

521536
}
522537

538+
function isPrimitiveType(obj) {
539+
var typ = typeof obj;
540+
return ((obj == null) || (typ == "number") || (typ == "boolean") || (typ == "string"));
541+
}
542+
543+
523544
// render the JS data object obj inside of jDomElt,
524545
// which is a jQuery wrapped DOM object
525546
// (obj is in a format encoded by cgi-bin/pg_encoder.py)

0 commit comments

Comments
 (0)