summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormig <mig>2013-12-11 14:51:15 (GMT)
committermig <mig>2013-12-11 14:51:15 (GMT)
commit13a7f30bb1ad0a3bb814f20efe88d5eb02d9e453 (patch)
tree77c60531f9a73924d7bb66e94e4cab150c9a0ee7
parent6af51247c19f071e11ea3f2b27724643bb7e0d70 (diff)
downloadtcl-13a7f30bb1ad0a3bb814f20efe88d5eb02d9e453.zip
tcl-13a7f30bb1ad0a3bb814f20efe88d5eb02d9e453.tar.gz
tcl-13a7f30bb1ad0a3bb814f20efe88d5eb02d9e453.tar.bz2
store options early: simplify compiler, reduce stack manipulations
-rw-r--r--generic/tclCompCmds.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 0a0aa8e..65c50eb 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -614,6 +614,7 @@ TclCompileCatchCmd(
TclEmitInstInt4( INST_REVERSE, 2, envPtr);
TclEmitOpcode( INST_POP, envPtr);
}
+ ExceptionRangeEnds(envPtr, range);
if (resultIndex == -1) {
/*
@@ -669,47 +670,26 @@ TclCompileCatchCmd(
if (optsIndex != -1) {
TclEmitOpcode( INST_PUSH_RETURN_OPTIONS, envPtr);
+ Emit14Inst( INST_STORE_SCALAR, optsIndex, envPtr);
+ TclEmitOpcode( INST_POP, envPtr);
}
/*
* End the catch
*/
- ExceptionRangeEnds(envPtr, range);
TclEmitOpcode( INST_END_CATCH, envPtr);
/*
* At this point, the top of the stack is inconveniently ordered:
- * result returnCode ?returnOptions?
- * Reverse the stack to bring the result to the top.
- */
-
- if (optsIndex != -1) {
- TclEmitInstInt4( INST_REVERSE, 3, envPtr);
- } else {
- TclEmitInstInt4( INST_REVERSE, 2, envPtr);
- }
-
- /*
- * Store the result and remove it from the stack.
+ * result returnCode
+ * Reverse the stack to store the result.
*/
+ TclEmitInstInt4( INST_REVERSE, 2, envPtr);
Emit14Inst( INST_STORE_SCALAR, resultIndex, envPtr);
TclEmitOpcode( INST_POP, envPtr);
- /*
- * Stack is now ?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);
- }
-
return TCL_OK;
}