summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-12-18 20:38:53 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-12-18 20:38:53 (GMT)
commit748fa3a11436f305210af6a3e39d41222c25d704 (patch)
treed77d3d81359e8390fda49e66bfe310508d49850f /generic
parent0495b7f2194bbfb5a1d05b091df455407e717021 (diff)
downloadtcl-748fa3a11436f305210af6a3e39d41222c25d704.zip
tcl-748fa3a11436f305210af6a3e39d41222c25d704.tar.gz
tcl-748fa3a11436f305210af6a3e39d41222c25d704.tar.bz2
Simplify creation and storage of temporaries
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompCmds.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 739bf21..d2d14f0 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -1539,10 +1539,6 @@ TclCompileForeachCmd(
ForeachInfo *infoPtr = NULL;/* Points to the structure describing this
* foreach command. Stored in a AuxData
* record in the ByteCode. */
- int firstValueTemp; /* Index of the first temp var in the frame
- * used to point to a value list. */
- int loopCtTemp; /* Index of temp var holding the loop's
- * iteration count. */
Tcl_Token *tokenPtr, *bodyTokenPtr;
unsigned char *jumpPc;
JumpFixup jumpFalseFixup;
@@ -1679,19 +1675,14 @@ TclCompileForeachCmd(
*/
code = TCL_OK;
- firstValueTemp = -1;
- for (loopIndex = 0; loopIndex < numLists; loopIndex++) {
- tempVar = TclFindCompiledLocal(NULL, /*nameChars*/ 0,
- /*create*/ 1, procPtr);
- if (loopIndex == 0) {
- firstValueTemp = tempVar;
- }
+
+ tempVar = TclFindCompiledLocal(NULL, 0, 1, procPtr);
+ infoPtr->firstValueTemp = tempVar;
+ for (loopIndex = 1; loopIndex < numLists; loopIndex++) {
+ TclFindCompiledLocal(NULL, 0, 1, procPtr);
}
- loopCtTemp = TclFindCompiledLocal(NULL, /*nameChars*/ 0,
- /*create*/ 1, procPtr);
+ infoPtr->loopCtTemp = TclFindCompiledLocal(NULL, 0, 1, procPtr);
- infoPtr->firstValueTemp = firstValueTemp;
- infoPtr->loopCtTemp = loopCtTemp;
for (loopIndex = 0; loopIndex < numLists; loopIndex++) {
ForeachVarList *varListPtr = infoPtr->varLists[loopIndex];
numVars = varListPtr->numVars;
@@ -1722,14 +1713,13 @@ TclCompileForeachCmd(
if ((i%2 == 0) && (i > 0)) {
SetLineInformation (i);
CompileTokens(envPtr, tokenPtr, interp);
- tempVar = (firstValueTemp + loopIndex);
if (tempVar <= 255) {
TclEmitInstInt1(INST_STORE_SCALAR1, tempVar, envPtr);
} else {
TclEmitInstInt4(INST_STORE_SCALAR4, tempVar, envPtr);
}
TclEmitOpcode(INST_POP, envPtr);
- loopIndex++;
+ loopIndex++; tempVar++;
}
}