@@ -37,6 +37,10 @@ var visitedLineColor = '#3D58A2';
3737var curTrace = null ;
3838var curInstr = 0 ;
3939
40+ // true iff trace ended prematurely since maximum instruction limit has
41+ // been reached
42+ var instrLimitReached = false ;
43+
4044function assert ( cond ) {
4145 if ( ! cond ) {
4246 alert ( "Error: ASSERTION FAILED" ) ;
@@ -72,6 +76,9 @@ function processTrace(traceData) {
7276 if ( curTrace . length > 0 ) {
7377 var lastEntry = curTrace [ curTrace . length - 1 ] ;
7478
79+ // GLOBAL!
80+ instrLimitReached = ( lastEntry . event == 'instruction_limit_reached' ) ;
81+
7582 // if there is some sort of error, then JUMP to it so that we can
7683 // immediately alert the user:
7784 // (cgi-bin/pg_logger.py ensures that if there is an uncaught
@@ -88,7 +95,7 @@ function processTrace(traceData) {
8895 curInstr = curTrace.length - 1;
8996 }
9097 */
91- if ( lastEntry . event == 'instruction_limit_reached' ) {
98+ if ( instrLimitReached ) {
9299 curTrace . pop ( ) // kill last entry
93100 var warningMsg = lastEntry . exception_msg ;
94101 $ ( "#warningOutput" ) . html ( htmlspecialchars ( warningMsg ) ) ;
@@ -145,7 +152,12 @@ function updateOutput() {
145152 // to be user-friendly, if we're on the LAST instruction, print "Program has terminated"
146153 // and DON'T highlight any lines of code in the code display
147154 if ( curInstr == ( totalInstrs - 1 ) ) {
148- $ ( "#vcrControls #curInstr" ) . html ( "Program has terminated" ) ;
155+ if ( instrLimitReached ) {
156+ $ ( "#vcrControls #curInstr" ) . html ( "Instruction limit reached" ) ;
157+ }
158+ else {
159+ $ ( "#vcrControls #curInstr" ) . html ( "Program has terminated" ) ;
160+ }
149161 }
150162 else {
151163 $ ( "#vcrControls #curInstr" ) . html ( "About to do step " + ( curInstr + 1 ) + " of " + ( totalInstrs - 1 ) ) ;
@@ -203,7 +215,9 @@ function updateOutput() {
203215 visitedLinesSet [ curTrace [ i ] . line ] = true ;
204216 }
205217 }
206- highlightCodeLine ( curEntry . line , visitedLinesSet , hasError , ( curInstr == ( totalInstrs - 1 ) ) ) ;
218+ highlightCodeLine ( curEntry . line , visitedLinesSet , hasError ,
219+ /* if instrLimitReached, then treat like a normal non-terminating line */
220+ ( ! instrLimitReached && ( curInstr == ( totalInstrs - 1 ) ) ) ) ;
207221 }
208222
209223
0 commit comments