summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r--generic/tclCompCmds.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 3046841..3d6abcf 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -493,36 +493,42 @@ TclCompileBreakCmd(
rangePtr = TclGetInnermostExceptionRange(envPtr, TCL_BREAK, &auxPtr);
if (rangePtr && rangePtr->type == LOOP_EXCEPTION_RANGE) {
- int toPop = envPtr->currStackDepth - auxPtr->stackDepth;
+ int toPop;
+
+ /*
+ * Ditch the extra elements from the auxiliary stack.
+ */
+
+ toPop = envPtr->expandCount - auxPtr->expandTarget;
+ while (toPop > 0) {
+ TclEmitOpcode(INST_EXPAND_DROP, envPtr);
+ toPop--;
+ }
/*
* Pop off the extra stack frames.
*/
+ toPop = envPtr->currStackDepth - auxPtr->stackDepth;
while (toPop > 0) {
TclEmitOpcode(INST_POP, envPtr);
TclAdjustStackDepth(1, envPtr);
toPop--;
}
- if (envPtr->expandCount == auxPtr->expandTarget) {
- /*
- * Found the target! Also, no built-up expansion stack. No need
- * for a nasty INST_BREAK here.
- */
-
- TclAddLoopBreakFixup(envPtr, auxPtr);
- goto done;
- }
- }
+ /*
+ * Found the target! No need for a nasty INST_BREAK here.
+ */
- /*
- * Emit a break instruction.
- */
+ TclAddLoopBreakFixup(envPtr, auxPtr);
+ } else {
+ /*
+ * Emit a break instruction.
+ */
- TclEmitOpcode(INST_BREAK, envPtr);
+ TclEmitOpcode(INST_BREAK, envPtr);
+ }
- done:
/*
* Instructions that raise exceptions don't really have to follow the
* usual stack management rules, but the cleanup code does.
@@ -840,36 +846,42 @@ TclCompileContinueCmd(
rangePtr = TclGetInnermostExceptionRange(envPtr, TCL_CONTINUE, &auxPtr);
if (rangePtr && rangePtr->type == LOOP_EXCEPTION_RANGE) {
- int toPop = envPtr->currStackDepth - auxPtr->stackDepth;
+ int toPop;
+
+ /*
+ * Ditch the extra elements from the auxiliary stack.
+ */
+
+ toPop = envPtr->expandCount - auxPtr->expandTarget;
+ while (toPop > 0) {
+ TclEmitOpcode(INST_EXPAND_DROP, envPtr);
+ toPop--;
+ }
/*
* Pop off the extra stack frames.
*/
+ toPop = envPtr->currStackDepth - auxPtr->stackDepth;
while (toPop > 0) {
TclEmitOpcode(INST_POP, envPtr);
TclAdjustStackDepth(1, envPtr);
toPop--;
}
- if (envPtr->expandCount == auxPtr->expandTarget) {
- /*
- * Found the target! Also, no built-up expansion stack. No need
- * for a nasty INST_CONTINUE here.
- */
-
- TclAddLoopContinueFixup(envPtr, auxPtr);
- goto done;
- }
- }
+ /*
+ * Found the target! No need for a nasty INST_CONTINUE here.
+ */
- /*
- * Emit a continue instruction.
- */
+ TclAddLoopContinueFixup(envPtr, auxPtr);
+ } else {
+ /*
+ * Emit a continue instruction.
+ */
- TclEmitOpcode(INST_CONTINUE, envPtr);
+ TclEmitOpcode(INST_CONTINUE, envPtr);
+ }
- done:
/*
* Instructions that raise exceptions don't really have to follow the
* usual stack management rules, but the cleanup code does.