Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor: make comments accurate in [catch] compiler. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b95f569ee32fa109400d907e7c66c493 |
User & Date: | dkf 2012-01-30 23:34:28 |
Context
2012-02-01
| ||
13:00 | [Bug 3482614]: Documentation nit. check-in: 7f49ede254 user: dkf tags: trunk | |
2012-01-30
| ||
23:34 | Minor: make comments accurate in [catch] compiler. check-in: b95f569ee3 user: dkf tags: trunk | |
15:43 |
* generic/tclCompCmds.c (TclCompileCatchCmd): Added a more efficient bytecode generator for the ca...check-in: c7bbf49644 user: dkf tags: trunk | |
Changes
Changes to generic/tclCompCmds.c.
︙ | ︙ | |||
348 349 350 351 352 353 354 | if (optsIndex < 0) { return TCL_ERROR; } } } /* | | | | | | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | if (optsIndex < 0) { return TCL_ERROR; } } } /* * We will compile the catch command. Declare the exception range that it * uses. */ range = DeclareExceptionRange(envPtr, CATCH_EXCEPTION_RANGE); /* * If the body is a simple word, compile a BEGIN_CATCH instruction, * followed by the instructions to eval the body. * Otherwise, compile instructions to substitute the body text before * starting the catch, then BEGIN_CATCH, and then EVAL_STK to evaluate the * substituted body. * Care has to be taken to make sure that substitution happens outside the * catch range so that errors in the substitution are not caught. * [Bug 219184] * The reason for duplicating the script is that EVAL_STK would otherwise * begin by undeflowing the stack below the mark set by BEGIN_CATCH4. */ SetLineInformation(1); if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) { |
︙ | ︙ | |||
413 414 415 416 417 418 419 | * simple: <mark> returnCode */ goto dropScriptAtEnd; } /* | | | | | > | > | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | * simple: <mark> returnCode */ goto dropScriptAtEnd; } /* * Emit the "no errors" epilogue: push "0" (TCL_OK) as the catch result, * and jump around the "error case" code. */ PushLiteral(envPtr, "0", 1); TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpFixup); /* Stack at this point: ?script? <mark> result TCL_OK */ /* * Emit the "error case" epilogue. Push the interpreter result and the * return code. */ envPtr->currStackDepth = savedStackDepth; ExceptionRangeTarget(envPtr, range, catchOffset); /* Stack at this point: ?script? */ TclEmitOpcode( INST_PUSH_RESULT, envPtr); TclEmitOpcode( INST_PUSH_RETURN_CODE, envPtr); /* * Update the target of the jump after the "no errors" code. */ /* Stack at this point: ?script? result returnCode */ if (TclFixupForwardJumpToHere(envPtr, &jumpFixup, 127)) { Tcl_Panic("TclCompileCatchCmd: bad jump distance %d", (int)(CurrentOffset(envPtr) - jumpFixup.codeOffset)); } /* * Push the return options if the caller wants them. */ if (optsIndex != -1) { TclEmitOpcode( INST_PUSH_RETURN_OPTIONS, envPtr); } /* * End the catch |
︙ | ︙ | |||
468 469 470 471 472 473 474 | if (optsIndex != -1) { TclEmitInstInt4( INST_REVERSE, 3, envPtr); } else { TclEmitInstInt4( INST_REVERSE, 2, envPtr); } /* | | < | < | | | | | | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | if (optsIndex != -1) { TclEmitInstInt4( INST_REVERSE, 3, envPtr); } else { TclEmitInstInt4( INST_REVERSE, 2, envPtr); } /* * Store the result and remove it from the stack. */ Emit14Inst( INST_STORE_SCALAR, resultIndex, envPtr); TclEmitOpcode( INST_POP, envPtr); /* * Stack is now ?script? ?returnOptions? returnCode. * If the options dict has been requested, it is buried on the stack under * the return code. Reverse the stack to bring it to the top, store it and * remove it from the stack. */ if (optsIndex != -1) { TclEmitInstInt4( INST_REVERSE, 2, envPtr); Emit14Inst( INST_STORE_SCALAR, optsIndex, envPtr); TclEmitOpcode( INST_POP, envPtr); } dropScriptAtEnd: /* * Stack is now ?script? result. Get rid of the subst'ed script if it's * hanging arond. */ if (cmdTokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { TclEmitInstInt4( INST_REVERSE, 2, envPtr); TclEmitOpcode( INST_POP, envPtr); } /* * Result of all this, on either branch, should have been to leave one * operand -- the return code -- on the stack. */ if (envPtr->currStackDepth != initStackDepth + 1) { Tcl_Panic("in TclCompileCatchCmd, currStackDepth = %d should be %d", envPtr->currStackDepth, initStackDepth+1); } return TCL_OK; |
︙ | ︙ |