diff options
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 354 |
1 files changed, 89 insertions, 265 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 3c83a58..26c387b 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompCmds.c,v 1.39.2.7 2008/07/21 19:37:42 andreas_kupries Exp $ + * RCS: @(#) $Id: tclCompCmds.c,v 1.39.2.8 2009/08/25 20:59:10 andreas_kupries Exp $ */ #include "tclInt.h" @@ -27,11 +27,37 @@ static void FreeForeachInfo _ANSI_ARGS_((ClientData clientData)); static int TclPushVarName _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Token *varTokenPtr, CompileEnv *envPtr, int flags, int *localIndexPtr, int *simpleVarNamePtr, int *isScalarPtr)); + +#define TclPushVarNameWord(i,v,e,f,l,s,sc,word) \ + TclPushVarName (i,v,e,f,l,s,sc) /* ignoring word */ + +#define DefineLineInformation /**/ +#define SetLineInformation(word) /**/ #else static int TclPushVarName _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Token *varTokenPtr, CompileEnv *envPtr, int flags, int *localIndexPtr, int *simpleVarNamePtr, int *isScalarPtr, - int line)); + int line, int* clNext)); + +#define TclPushVarNameWord(i,v,e,f,l,s,sc,word) \ + TclPushVarName (i,v,e,f,l,s,sc, \ + mapPtr->loc [eclIndex].line [(word)], \ + mapPtr->loc [eclIndex].next [(word)]) + +/* TIP #280 : Remember the per-word line information of the current + * command. An index is used instead of a pointer as recursive compilation may + * reallocate, i.e. move, the array. This is also the reason to save the nuloc + * now, it may change during the course of the function. + * + * Macros to encapsulate the variable definition and setup, and their use. + */ +#define DefineLineInformation \ + ExtCmdLoc *mapPtr = envPtr->extCmdMapPtr; \ + int eclIndex = mapPtr->nuloc - 1 + +#define SetLineInformation(word) \ + envPtr->line = mapPtr->loc [eclIndex].line [(word)]; \ + envPtr->clNext = mapPtr->loc [eclIndex].next [(word)] #endif /* @@ -85,15 +111,7 @@ TclCompileAppendCmd(interp, parsePtr, envPtr) int simpleVarName, isScalar, localIndex, numWords; int code = TCL_OK; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; numWords = parsePtr->numWords; if (numWords == 1) { @@ -125,13 +143,8 @@ TclCompileAppendCmd(interp, parsePtr, envPtr) varTokenPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); - code = TclPushVarName(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, -#ifndef TCL_TIP280 - &localIndex, &simpleVarName, &isScalar); -#else - &localIndex, &simpleVarName, &isScalar, - mapPtr->loc [eclIndex].line [1]); -#endif + code = TclPushVarNameWord(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, + &localIndex, &simpleVarName, &isScalar, 1); if (code != TCL_OK) { goto done; } @@ -148,9 +161,7 @@ TclCompileAppendCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); code = TclCompileTokens(interp, valueTokenPtr+1, valueTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -271,15 +282,7 @@ TclCompileCatchCmd(interp, parsePtr, envPtr) int code; int savedStackDepth = envPtr->currStackDepth; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if ((parsePtr->numWords != 2) && (parsePtr->numWords != 3)) { Tcl_ResetResult(interp); @@ -343,9 +346,7 @@ TclCompileCatchCmd(interp, parsePtr, envPtr) * errors in the substitution are not catched [Bug 219184] */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [1]; -#endif + SetLineInformation (1); if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) { startOffset = (envPtr->codeNext - envPtr->codeStart); code = TclCompileCmdWord(interp, cmdTokenPtr+1, 1, envPtr); @@ -493,6 +494,8 @@ TclCompileExprCmd(interp, parsePtr, envPtr) { Tcl_Token *firstWordPtr; + DefineLineInformation; + if (parsePtr->numWords == 1) { Tcl_ResetResult(interp); Tcl_AppendToObj(Tcl_GetObjResult(interp), @@ -500,11 +503,7 @@ TclCompileExprCmd(interp, parsePtr, envPtr) return TCL_ERROR; } -#ifdef TCL_TIP280 - /* TIP #280 : Use the per-word line information of the current command. - */ - envPtr->line = envPtr->extCmdMapPtr->loc [envPtr->extCmdMapPtr->nuloc - 1].line [1]; -#endif + SetLineInformation (1); firstWordPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); return TclCompileExprWords(interp, firstWordPtr, (parsePtr->numWords-1), @@ -543,15 +542,7 @@ TclCompileForCmd(interp, parsePtr, envPtr) char buffer[32 + TCL_INTEGER_SPACE]; int savedStackDepth = envPtr->currStackDepth; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if (parsePtr->numWords != 5) { Tcl_ResetResult(interp); @@ -601,9 +592,7 @@ TclCompileForCmd(interp, parsePtr, envPtr) * Inline compile the initial command. */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [1]; -#endif + SetLineInformation (1); code = TclCompileCmdWord(interp, startTokenPtr+1, startTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -635,9 +624,7 @@ TclCompileForCmd(interp, parsePtr, envPtr) bodyCodeOffset = (envPtr->codeNext - envPtr->codeStart); -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [4]; -#endif + SetLineInformation (4); code = TclCompileCmdWord(interp, bodyTokenPtr+1, bodyTokenPtr->numComponents, envPtr); envPtr->currStackDepth = savedStackDepth + 1; @@ -660,9 +647,7 @@ TclCompileForCmd(interp, parsePtr, envPtr) nextCodeOffset = (envPtr->codeNext - envPtr->codeStart); -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [3]; -#endif + SetLineInformation (3); envPtr->currStackDepth = savedStackDepth; code = TclCompileCmdWord(interp, nextTokenPtr+1, nextTokenPtr->numComponents, envPtr); @@ -693,9 +678,7 @@ TclCompileForCmd(interp, parsePtr, envPtr) nextCodeOffset += 3; testCodeOffset += 3; } -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); envPtr->currStackDepth = savedStackDepth; code = TclCompileExprWords(interp, testTokenPtr, 1, envPtr); if (code != TCL_OK) { @@ -786,14 +769,8 @@ TclCompileForeachCmd(interp, parsePtr, envPtr) char buffer[32 + TCL_INTEGER_SPACE]; int savedStackDepth = envPtr->currStackDepth; + DefineLineInformation; #ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; int bodyIndex; #endif @@ -976,9 +953,7 @@ TclCompileForeachCmd(interp, parsePtr, envPtr) i < numWords-1; i++, tokenPtr += (tokenPtr->numComponents + 1)) { if ((i%2 == 0) && (i > 0)) { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -1016,9 +991,7 @@ TclCompileForeachCmd(interp, parsePtr, envPtr) * Inline compile the loop body. */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [bodyIndex]; -#endif + SetLineInformation (bodyIndex); envPtr->exceptArrayPtr[range].codeOffset = (envPtr->codeNext - envPtr->codeStart); code = TclCompileCmdWord(interp, bodyTokenPtr+1, @@ -1248,15 +1221,7 @@ TclCompileIfCmd(interp, parsePtr, envPtr) int boolVal; /* value of static condition */ int compileScripts = 1; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* * Only compile the "if" command if all arguments are simple @@ -1339,9 +1304,7 @@ TclCompileIfCmd(interp, parsePtr, envPtr) } } else { Tcl_ResetResult(interp); -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [wordIdx]; -#endif + SetLineInformation (wordIdx); code = TclCompileExprWords(interp, testTokenPtr, 1, envPtr); if (code != TCL_OK) { if (code == TCL_ERROR) { @@ -1398,9 +1361,7 @@ TclCompileIfCmd(interp, parsePtr, envPtr) */ if (compileScripts) { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [wordIdx]; -#endif + SetLineInformation (wordIdx); envPtr->currStackDepth = savedStackDepth; code = TclCompileCmdWord(interp, tokenPtr+1, tokenPtr->numComponents, envPtr); @@ -1503,9 +1464,7 @@ TclCompileIfCmd(interp, parsePtr, envPtr) /* * Compile the else command body. */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [wordIdx]; -#endif + SetLineInformation (wordIdx); code = TclCompileCmdWord(interp, tokenPtr+1, tokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -1617,15 +1576,7 @@ TclCompileIncrCmd(interp, parsePtr, envPtr) int simpleVarName, isScalar, localIndex, haveImmValue, immValue; int code = TCL_OK; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if ((parsePtr->numWords != 2) && (parsePtr->numWords != 3)) { Tcl_ResetResult(interp); @@ -1637,14 +1588,9 @@ TclCompileIncrCmd(interp, parsePtr, envPtr) varTokenPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); - code = TclPushVarName(interp, varTokenPtr, envPtr, + code = TclPushVarNameWord(interp, varTokenPtr, envPtr, (TCL_NO_LARGE_INDEX | TCL_CREATE_VAR), -#ifndef TCL_TIP280 - &localIndex, &simpleVarName, &isScalar); -#else - &localIndex, &simpleVarName, &isScalar, - mapPtr->loc [eclIndex].line [1]); -#endif + &localIndex, &simpleVarName, &isScalar, 1); if (code != TCL_OK) { goto done; } @@ -1684,9 +1630,7 @@ TclCompileIncrCmd(interp, parsePtr, envPtr) TclRegisterNewLiteral(envPtr, word, numBytes), envPtr); } } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); code = TclCompileTokens(interp, incrTokenPtr+1, incrTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -1779,15 +1723,7 @@ TclCompileLappendCmd(interp, parsePtr, envPtr) int simpleVarName, isScalar, localIndex, numWords; int code = TCL_OK; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* * If we're not in a procedure, don't compile. @@ -1821,13 +1757,8 @@ TclCompileLappendCmd(interp, parsePtr, envPtr) varTokenPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); - code = TclPushVarName(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, -#ifndef TCL_TIP280 - &localIndex, &simpleVarName, &isScalar); -#else - &localIndex, &simpleVarName, &isScalar, - mapPtr->loc [eclIndex].line [1]); -#endif + code = TclPushVarNameWord(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, + &localIndex, &simpleVarName, &isScalar, 1); if (code != TCL_OK) { goto done; } @@ -1843,9 +1774,7 @@ TclCompileLappendCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); code = TclCompileTokens(interp, valueTokenPtr+1, valueTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -1923,15 +1852,7 @@ TclCompileLindexCmd(interp, parsePtr, envPtr) Tcl_Token *varTokenPtr; int code, i; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; int numWords; numWords = parsePtr->numWords; @@ -1957,9 +1878,7 @@ TclCompileLindexCmd(interp, parsePtr, envPtr) TclRegisterNewLiteral( envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2013,15 +1932,7 @@ TclCompileListCmd(interp, parsePtr, envPtr) * command created by Tcl_ParseCommand. */ CompileEnv *envPtr; /* Holds resulting instructions. */ { -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* * If we're not in a procedure, don't compile. @@ -2052,9 +1963,7 @@ TclCompileListCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, valueTokenPtr+1, valueTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2100,15 +2009,7 @@ TclCompileLlengthCmd(interp, parsePtr, envPtr) Tcl_Token *varTokenPtr; int code; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if (parsePtr->numWords != 2) { Tcl_SetResult(interp, "wrong # args: should be \"llength list\"", @@ -2126,9 +2027,7 @@ TclCompileLlengthCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [1]; -#endif + SetLineInformation (1); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2204,15 +2103,7 @@ TclCompileLsetCmd( interp, parsePtr, envPtr ) int i; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* Check argument count */ @@ -2231,13 +2122,8 @@ TclCompileLsetCmd( interp, parsePtr, envPtr ) varTokenPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); - result = TclPushVarName( interp, varTokenPtr, envPtr, -#ifndef TCL_TIP280 - TCL_CREATE_VAR, &localIndex, &simpleVarName, &isScalar ); -#else - TCL_CREATE_VAR, &localIndex, &simpleVarName, &isScalar, - mapPtr->loc [eclIndex].line [1]); -#endif + result = TclPushVarNameWord( interp, varTokenPtr, envPtr, + TCL_CREATE_VAR, &localIndex, &simpleVarName, &isScalar, 1); if (result != TCL_OK) { return result; } @@ -2256,9 +2142,7 @@ TclCompileLsetCmd( interp, parsePtr, envPtr ) TclEmitPush(TclRegisterNewLiteral( envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); result = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if ( result != TCL_OK ) { @@ -2389,15 +2273,7 @@ TclCompileRegexpCmd(interp, parsePtr, envPtr) int i, len, code, nocase, anchorLeft, anchorRight, start; char *str; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* * We are only interested in compiling simple regexp cases. @@ -2546,9 +2422,7 @@ TclCompileRegexpCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [parsePtr->numWords-1]; -#endif + SetLineInformation (parsePtr->numWords-1); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2599,15 +2473,7 @@ TclCompileReturnCmd(interp, parsePtr, envPtr) int code; int index = envPtr->exceptArrayNext - 1; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; /* * If we're not in a procedure, don't compile. @@ -2666,9 +2532,7 @@ TclCompileReturnCmd(interp, parsePtr, envPtr) * "return" will be byte-compiled; otherwise it will be * out line compiled. */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [1]; -#endif + SetLineInformation (1); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2729,15 +2593,7 @@ TclCompileSetCmd(interp, parsePtr, envPtr) int isAssignment, isScalar, simpleVarName, localIndex, numWords; int code = TCL_OK; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; numWords = parsePtr->numWords; if ((numWords != 2) && (numWords != 3)) { @@ -2759,13 +2615,8 @@ TclCompileSetCmd(interp, parsePtr, envPtr) varTokenPtr = parsePtr->tokenPtr + (parsePtr->tokenPtr->numComponents + 1); - code = TclPushVarName(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, -#ifndef TCL_TIP280 - &localIndex, &simpleVarName, &isScalar); -#else - &localIndex, &simpleVarName, &isScalar, - mapPtr->loc [eclIndex].line [1]); -#endif + code = TclPushVarNameWord(interp, varTokenPtr, envPtr, TCL_CREATE_VAR, + &localIndex, &simpleVarName, &isScalar, 1); if (code != TCL_OK) { goto done; } @@ -2780,9 +2631,7 @@ TclCompileSetCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, valueTokenPtr[1].start, valueTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); code = TclCompileTokens(interp, valueTokenPtr+1, valueTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2885,15 +2734,7 @@ TclCompileStringCmd(interp, parsePtr, envPtr) STR_WORDEND, STR_WORDSTART }; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if (parsePtr->numWords < 2) { /* Fail at run time, not in compilation */ @@ -2956,9 +2797,7 @@ TclCompileStringCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -2989,9 +2828,7 @@ TclCompileStringCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, varTokenPtr[1].start, varTokenPtr[1].size), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -3022,9 +2859,7 @@ TclCompileStringCmd(interp, parsePtr, envPtr) TclEmitPush(TclRegisterNewLiteral(envPtr, buf, len), envPtr); return TCL_OK; } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -3082,9 +2917,7 @@ TclCompileStringCmd(interp, parsePtr, envPtr) TclEmitPush( TclRegisterNewLiteral(envPtr, str, length), envPtr); } else { -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [i]; -#endif + SetLineInformation (i); code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); if (code != TCL_OK) { @@ -3201,15 +3034,7 @@ TclCompileWhileCmd(interp, parsePtr, envPtr) Tcl_Obj *boolObj; int boolVal; -#ifdef TCL_TIP280 - /* TIP #280 : Remember the per-word line information of the current - * command. An index is used instead of a pointer as recursive compilation - * may reallocate, i.e. move, the array. This is also the reason to save - * the nuloc now, it may change during the course of the function. - */ - ExtCmdLoc* mapPtr = envPtr->extCmdMapPtr; - int eclIndex = mapPtr->nuloc - 1; -#endif + DefineLineInformation; if (parsePtr->numWords != 3) { Tcl_ResetResult(interp); @@ -3296,9 +3121,7 @@ TclCompileWhileCmd(interp, parsePtr, envPtr) * Compile the loop body. */ -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [2]; -#endif + SetLineInformation (2); bodyCodeOffset = (envPtr->codeNext - envPtr->codeStart); code = TclCompileCmdWord(interp, bodyTokenPtr+1, bodyTokenPtr->numComponents, envPtr); @@ -3328,9 +3151,7 @@ TclCompileWhileCmd(interp, parsePtr, envPtr) testCodeOffset += 3; } envPtr->currStackDepth = savedStackDepth; -#ifdef TCL_TIP280 - envPtr->line = mapPtr->loc [eclIndex].line [1]; -#endif + SetLineInformation (1); code = TclCompileExprWords(interp, testTokenPtr, 1, envPtr); if (code != TCL_OK) { if (code == TCL_ERROR) { @@ -3406,7 +3227,7 @@ TclPushVarName(interp, varTokenPtr, envPtr, flags, localIndexPtr, #ifndef TCL_TIP280 simpleVarNamePtr, isScalarPtr) #else - simpleVarNamePtr, isScalarPtr, line) + simpleVarNamePtr, isScalarPtr, line, clNext) #endif Tcl_Interp *interp; /* Used for error reporting. */ Tcl_Token *varTokenPtr; /* Points to a variable token. */ @@ -3418,6 +3239,7 @@ TclPushVarName(interp, varTokenPtr, envPtr, flags, localIndexPtr, int *isScalarPtr; /* must not be NULL */ #ifdef TCL_TIP280 int line; /* line the token starts on */ + int* clNext; #endif { register CONST char *p; @@ -3601,7 +3423,8 @@ TclPushVarName(interp, varTokenPtr, envPtr, flags, localIndexPtr, if (elName != NULL) { if (elNameChars) { #ifdef TCL_TIP280 - envPtr->line = line; + envPtr->line = line; + envPtr->clNext = clNext; #endif code = TclCompileTokens(interp, elemTokenPtr, elemTokenCount, envPtr); @@ -3618,7 +3441,8 @@ TclPushVarName(interp, varTokenPtr, envPtr, flags, localIndexPtr, */ #ifdef TCL_TIP280 - envPtr->line = line; + envPtr->line = line; + envPtr->clNext = clNext; #endif code = TclCompileTokens(interp, varTokenPtr+1, varTokenPtr->numComponents, envPtr); |