diff options
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 274 |
1 files changed, 84 insertions, 190 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index f6ca0e0..e5defd1 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -39,8 +39,7 @@ static int IndexTailVarIfKnown(Tcl_Interp *interp, static int PushVarName(Tcl_Interp *interp, Tcl_Token *varTokenPtr, CompileEnv *envPtr, int flags, int *localIndexPtr, - int *simpleVarNamePtr, int *isScalarPtr, - int line, int *clNext); + int *simpleVarNamePtr, int *isScalarPtr); static int CompileEachloopCmd(Tcl_Interp *interp, Tcl_Parse *parsePtr, Command *cmdPtr, CompileEnv *envPtr, int collect); @@ -54,43 +53,19 @@ static int CompileDictEachCmd(Tcl_Interp *interp, * the simplest of compiles. The ANSI C "prototype" for this macro is: * * static void CompileWord(CompileEnv *envPtr, Tcl_Token *tokenPtr, - * Tcl_Interp *interp, int word); + * Tcl_Interp *interp); */ -#define CompileWord(envPtr, tokenPtr, interp, word) \ +#define CompileWord(envPtr, tokenPtr, interp) \ if ((tokenPtr)->type == TCL_TOKEN_SIMPLE_WORD) { \ TclEmitPush(TclRegisterNewLiteral((envPtr), (tokenPtr)[1].start, \ (tokenPtr)[1].size), (envPtr)); \ } else { \ - envPtr->line = mapPtr->loc[eclIndex].line[word]; \ - envPtr->clNext = mapPtr->loc[eclIndex].next[word]; \ TclCompileTokens((interp), (tokenPtr)+1, (tokenPtr)->numComponents, \ (envPtr)); \ } /* - * 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. - * - * Macro to encapsulate the variable definition and setup. - */ - -#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)] - -#define PushVarNameWord(i,v,e,f,l,s,sc,word) \ - PushVarName(i,v,e,f,l,s,sc, \ - mapPtr->loc[eclIndex].line[(word)], \ - mapPtr->loc[eclIndex].next[(word)]) - -/* * Often want to issue one of two versions of an instruction based on whether * the argument will fit in a single byte or not. This makes it much clearer. */ @@ -156,7 +131,6 @@ TclCompileAppendCmd( { Tcl_Token *varTokenPtr, *valueTokenPtr; int simpleVarName, isScalar, localIndex, numWords; - DefineLineInformation; /* TIP #280 */ numWords = parsePtr->numWords; if (numWords == 1) { @@ -185,8 +159,8 @@ TclCompileAppendCmd( varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, 0, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, varTokenPtr, envPtr, 0, + &localIndex, &simpleVarName, &isScalar); /* * We are doing an assignment, otherwise TclCompileSetCmd was called, so @@ -196,7 +170,7 @@ TclCompileAppendCmd( if (numWords > 2) { valueTokenPtr = TokenAfter(varTokenPtr); - CompileWord(envPtr, valueTokenPtr, interp, 2); + CompileWord(envPtr, valueTokenPtr, interp); } /* @@ -251,7 +225,6 @@ TclCompileArrayExistsCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr; int simpleVarName, isScalar, localIndex; @@ -260,8 +233,8 @@ TclCompileArrayExistsCmd( } tokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, tokenPtr, envPtr, TCL_NO_ELEMENT, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, tokenPtr, envPtr, TCL_NO_ELEMENT, + &localIndex, &simpleVarName, &isScalar); if (!isScalar) { return TCL_ERROR; } @@ -283,7 +256,6 @@ TclCompileArraySetCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *varTokenPtr, *dataTokenPtr; int simpleVarName, isScalar, localIndex; int isDataLiteral, isDataValid, isDataEven, len; @@ -297,8 +269,8 @@ TclCompileArraySetCmd( } varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, TCL_NO_ELEMENT, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, varTokenPtr, envPtr, TCL_NO_ELEMENT, + &localIndex, &simpleVarName, &isScalar); if (!isScalar) { return TCL_ERROR; } @@ -376,11 +348,11 @@ TclCompileArraySetCmd( TclEmitPush(cmdLit, envPtr); TclDecrRefCount(objPtr); if (localIndex >= 0) { - CompileWord(envPtr, varTokenPtr, interp, 1); + CompileWord(envPtr, varTokenPtr, interp); } else { TclEmitInstInt4(INST_REVERSE, 2, envPtr); } - CompileWord(envPtr, dataTokenPtr, interp, 2); + CompileWord(envPtr, dataTokenPtr, interp); TclEmitInstInt1(INST_INVOKE_STK1, 3, envPtr); goto done; } @@ -399,7 +371,7 @@ TclCompileArraySetCmd( * Start issuing instructions to write to the array. */ - CompileWord(envPtr, dataTokenPtr, interp, 2); + CompileWord(envPtr, dataTokenPtr, interp); if (!isDataLiteral || !isDataValid) { /* * Only need this safety check if we're handling a non-literal or list @@ -490,7 +462,6 @@ TclCompileArrayUnsetCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); int simpleVarName, isScalar, localIndex, savedStackDepth; @@ -498,8 +469,8 @@ TclCompileArrayUnsetCmd( return TclCompileBasic2ArgCmd(interp, parsePtr, cmdPtr, envPtr); } - PushVarNameWord(interp, tokenPtr, envPtr, TCL_NO_ELEMENT, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, tokenPtr, envPtr, TCL_NO_ELEMENT, + &localIndex, &simpleVarName, &isScalar); if (!isScalar) { return TCL_ERROR; } @@ -596,7 +567,6 @@ TclCompileCatchCmd( int resultIndex, optsIndex, nameChars, range; int initStackDepth = envPtr->currStackDepth; int savedStackDepth; - DefineLineInformation; /* TIP #280 */ /* * If syntax does not match what we expect for [catch], do not compile. @@ -680,7 +650,6 @@ TclCompileCatchCmd( * begin by undeflowing the stack below the mark set by BEGIN_CATCH4. */ - SetLineInformation(1); if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) { savedStackDepth = envPtr->currStackDepth; TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr); @@ -899,7 +868,6 @@ TclCompileDictSetCmd( { Tcl_Token *tokenPtr; int numWords, i; - DefineLineInformation; /* TIP #280 */ Tcl_Token *varTokenPtr; int dictVarIndex, nameChars; const char *name; @@ -939,7 +907,7 @@ TclCompileDictSetCmd( tokenPtr = TokenAfter(varTokenPtr); numWords = parsePtr->numWords-1; for (i=1 ; i<numWords ; i++) { - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } @@ -962,7 +930,6 @@ TclCompileDictIncrCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *varTokenPtr, *keyTokenPtr; int dictVarIndex, nameChars, incrAmount; const char *name; @@ -1028,7 +995,7 @@ TclCompileDictIncrCmd( * Emit the key and the code to actually do the increment. */ - CompileWord(envPtr, keyTokenPtr, interp, 3); + CompileWord(envPtr, keyTokenPtr, interp); TclEmitInstInt4( INST_DICT_INCR_IMM, incrAmount, envPtr); TclEmitInt4( dictVarIndex, envPtr); return TCL_OK; @@ -1045,7 +1012,6 @@ TclCompileDictGetCmd( { Tcl_Token *tokenPtr; int numWords, i; - DefineLineInformation; /* TIP #280 */ /* * There must be at least two arguments after the command (the single-arg @@ -1063,7 +1029,7 @@ TclCompileDictGetCmd( */ for (i=0 ; i<numWords ; i++) { - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } TclEmitInstInt4(INST_DICT_GET, numWords-1, envPtr); @@ -1082,7 +1048,6 @@ TclCompileDictExistsCmd( { Tcl_Token *tokenPtr; int numWords, i; - DefineLineInformation; /* TIP #280 */ /* * There must be at least two arguments after the command (the single-arg @@ -1100,7 +1065,7 @@ TclCompileDictExistsCmd( */ for (i=0 ; i<numWords ; i++) { - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } TclEmitInstInt4(INST_DICT_EXISTS, numWords-1, envPtr); @@ -1118,7 +1083,6 @@ TclCompileDictUnsetCmd( CompileEnv *envPtr) /* Holds resulting instructions. */ { Tcl_Token *tokenPtr; - DefineLineInformation; /* TIP #280 */ int i, dictVarIndex, nameChars; const char *name; @@ -1157,7 +1121,7 @@ TclCompileDictUnsetCmd( for (i=2 ; i<parsePtr->numWords ; i++) { tokenPtr = TokenAfter(tokenPtr); - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); } /* @@ -1178,7 +1142,6 @@ TclCompileDictCreateCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ int worker; /* Temp var for building the value in. */ Tcl_Token *tokenPtr; Tcl_Obj *keyObj, *valueObj, *dictObj; @@ -1247,9 +1210,9 @@ TclCompileDictCreateCmd( TclEmitOpcode( INST_POP, envPtr); tokenPtr = TokenAfter(parsePtr->tokenPtr); for (i=1 ; i<parsePtr->numWords ; i+=2) { - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); - CompileWord(envPtr, tokenPtr, interp, i+1); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); TclEmitInstInt4( INST_DICT_SET, 1, envPtr); TclEmitInt4( worker, envPtr); @@ -1271,7 +1234,6 @@ TclCompileDictMergeCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr; int i, workerIndex, infoIndex, outLoop; @@ -1285,7 +1247,7 @@ TclCompileDictMergeCmd( return TCL_OK; } else if (parsePtr->numWords == 2) { tokenPtr = TokenAfter(parsePtr->tokenPtr); - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_DUP, envPtr); TclEmitOpcode( INST_DICT_VERIFY, envPtr); return TCL_OK; @@ -1309,7 +1271,7 @@ TclCompileDictMergeCmd( */ tokenPtr = TokenAfter(parsePtr->tokenPtr); - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_DUP, envPtr); TclEmitOpcode( INST_DICT_VERIFY, envPtr); Emit14Inst( INST_STORE_SCALAR, workerIndex, envPtr); @@ -1329,7 +1291,7 @@ TclCompileDictMergeCmd( */ tokenPtr = TokenAfter(tokenPtr); - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); TclEmitInstInt4( INST_DICT_FIRST, infoIndex, envPtr); TclEmitInstInt1( INST_JUMP_TRUE1, 24, envPtr); TclEmitInstInt4( INST_REVERSE, 2, envPtr); @@ -1412,7 +1374,6 @@ CompileDictEachCmd( * construct a new dictionary with the loop * body result. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *varsTokenPtr, *dictTokenPtr, *bodyTokenPtr; int keyVarIndex, valueVarIndex, nameChars, loopRange, catchRange; int infoIndex, jumpDisplacement, bodyTargetOffset, emptyTargetOffset; @@ -1521,7 +1482,7 @@ CompileDictEachCmd( * this point. */ - CompileWord(envPtr, dictTokenPtr, interp, 3); + CompileWord(envPtr, dictTokenPtr, interp); TclEmitInstInt4( INST_DICT_FIRST, infoIndex, envPtr); emptyTargetOffset = CurrentOffset(envPtr); TclEmitInstInt4( INST_JUMP_TRUE4, 0, envPtr); @@ -1556,7 +1517,6 @@ CompileDictEachCmd( * Compile the loop body itself. It should be stack-neutral. */ - SetLineInformation(3); CompileBody(envPtr, bodyTokenPtr, interp); if (collect == TCL_EACH_COLLECT) { Emit14Inst( INST_LOAD_SCALAR, keyVarIndex, envPtr); @@ -1663,7 +1623,6 @@ TclCompileDictUpdateCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ const char *name; int i, nameChars, dictIndex, numVars, range, infoIndex; Tcl_Token **keyTokenPtrs, *dictVarTokenPtr, *bodyTokenPtr, *tokenPtr; @@ -1769,7 +1728,7 @@ TclCompileDictUpdateCmd( infoIndex = TclCreateAuxData(duiPtr, &tclDictUpdateInfoType, envPtr); for (i=0 ; i<numVars ; i++) { - CompileWord(envPtr, keyTokenPtrs[i], interp, i); + CompileWord(envPtr, keyTokenPtrs[i], interp); } TclEmitInstInt4( INST_LIST, numVars, envPtr); TclEmitInstInt4( INST_DICT_UPDATE_START, dictIndex, envPtr); @@ -1780,7 +1739,6 @@ TclCompileDictUpdateCmd( ExceptionRangeStarts(envPtr, range); envPtr->currStackDepth++; - SetLineInformation(parsePtr->numWords - 1); CompileBody(envPtr, bodyTokenPtr, interp); envPtr->currStackDepth = savedStackDepth; ExceptionRangeEnds(envPtr, range); @@ -1835,7 +1793,6 @@ TclCompileDictAppendCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr; int i, dictVarIndex; @@ -1875,7 +1832,7 @@ TclCompileDictAppendCmd( tokenPtr = TokenAfter(tokenPtr); for (i=2 ; i<parsePtr->numWords ; i++) { - CompileWord(envPtr, tokenPtr, interp, i); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } if (parsePtr->numWords > 4) { @@ -1899,7 +1856,6 @@ TclCompileDictLappendCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *varTokenPtr, *keyTokenPtr, *valueTokenPtr; int dictVarIndex, nameChars; const char *name; @@ -1927,8 +1883,8 @@ TclCompileDictLappendCmd( if (dictVarIndex < 0) { return TclCompileBasic3ArgCmd(interp, parsePtr, cmdPtr, envPtr); } - CompileWord(envPtr, keyTokenPtr, interp, 3); - CompileWord(envPtr, valueTokenPtr, interp, 4); + CompileWord(envPtr, keyTokenPtr, interp); + CompileWord(envPtr, valueTokenPtr, interp); TclEmitInstInt4( INST_DICT_LAPPEND, dictVarIndex, envPtr); return TCL_OK; } @@ -1942,7 +1898,6 @@ TclCompileDictWithCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ int i, range, varNameTmp, pathTmp, keysTmp, gotPath, dictVar = -1; int bodyIsEmpty = 1; Tcl_Token *varTokenPtr, *tokenPtr; @@ -2017,7 +1972,7 @@ TclCompileDictWithCmd( tokenPtr = TokenAfter(varTokenPtr); for (i=2 ; i<parsePtr->numWords-1 ; i++) { - CompileWord(envPtr, tokenPtr, interp, i-1); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } TclEmitInstInt4(INST_LIST, parsePtr->numWords-3,envPtr); @@ -2046,7 +2001,7 @@ TclCompileDictWithCmd( tokenPtr = varTokenPtr; for (i=1 ; i<parsePtr->numWords-1 ; i++) { - CompileWord(envPtr, tokenPtr, interp, i-1); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } TclEmitInstInt4(INST_LIST, parsePtr->numWords-3,envPtr); @@ -2061,7 +2016,7 @@ TclCompileDictWithCmd( * Case: Direct dict in non-simple var with empty body. */ - CompileWord(envPtr, varTokenPtr, interp, 0); + CompileWord(envPtr, varTokenPtr, interp); TclEmitOpcode( INST_DUP, envPtr); TclEmitOpcode( INST_LOAD_STK, envPtr); PushLiteral(envPtr, "", 0); @@ -2101,13 +2056,13 @@ TclCompileDictWithCmd( */ if (varNameTmp > -1) { - CompileWord(envPtr, varTokenPtr, interp, 0); + CompileWord(envPtr, varTokenPtr, interp); Emit14Inst( INST_STORE_SCALAR, varNameTmp, envPtr); } tokenPtr = TokenAfter(varTokenPtr); if (gotPath) { for (i=2 ; i<parsePtr->numWords-1 ; i++) { - CompileWord(envPtr, tokenPtr, interp, i-1); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); } TclEmitInstInt4( INST_LIST, parsePtr->numWords-3,envPtr); @@ -2137,7 +2092,6 @@ TclCompileDictWithCmd( ExceptionRangeStarts(envPtr, range); envPtr->currStackDepth++; - SetLineInformation(parsePtr->numWords-1); CompileBody(envPtr, tokenPtr, interp); envPtr->currStackDepth = savedStackDepth; ExceptionRangeEnds(envPtr, range); @@ -2292,7 +2246,6 @@ TclCompileErrorCmd( */ Tcl_Token *messageTokenPtr; int savedStackDepth = envPtr->currStackDepth; - DefineLineInformation; /* TIP #280 */ if (parsePtr->numWords != 2) { return TCL_ERROR; @@ -2300,7 +2253,7 @@ TclCompileErrorCmd( messageTokenPtr = TokenAfter(parsePtr->tokenPtr); PushLiteral(envPtr, "-code error -level 0", 20); - CompileWord(envPtr, messageTokenPtr, interp, 1); + CompileWord(envPtr, messageTokenPtr, interp); TclEmitOpcode(INST_RETURN_STK, envPtr); envPtr->currStackDepth = savedStackDepth + 1; return TCL_OK; @@ -2339,13 +2292,6 @@ TclCompileExprCmd( return TCL_ERROR; } - /* - * TIP #280: Use the per-word line information of the current command. - */ - - envPtr->line = envPtr->extCmdMapPtr->loc[ - envPtr->extCmdMapPtr->nuloc-1].line[1]; - firstWordPtr = TokenAfter(parsePtr->tokenPtr); TclCompileExprWords(interp, firstWordPtr, parsePtr->numWords-1, envPtr); return TCL_OK; @@ -2383,7 +2329,6 @@ TclCompileForCmd( int testCodeOffset, bodyCodeOffset, nextCodeOffset, jumpDist; int bodyRange, nextRange; int savedStackDepth = envPtr->currStackDepth; - DefineLineInformation; /* TIP #280 */ if (parsePtr->numWords != 5) { return TCL_ERROR; @@ -2426,7 +2371,6 @@ TclCompileForCmd( * Inline compile the initial command. */ - SetLineInformation(1); CompileBody(envPtr, startTokenPtr, interp); TclEmitOpcode(INST_POP, envPtr); @@ -2449,7 +2393,6 @@ TclCompileForCmd( */ bodyCodeOffset = ExceptionRangeStarts(envPtr, bodyRange); - SetLineInformation(4); CompileBody(envPtr, bodyTokenPtr, interp); ExceptionRangeEnds(envPtr, bodyRange); envPtr->currStackDepth = savedStackDepth + 1; @@ -2461,7 +2404,6 @@ TclCompileForCmd( envPtr->currStackDepth = savedStackDepth; nextCodeOffset = ExceptionRangeStarts(envPtr, nextRange); - SetLineInformation(3); CompileBody(envPtr, nextTokenPtr, interp); ExceptionRangeEnds(envPtr, nextRange); envPtr->currStackDepth = savedStackDepth + 1; @@ -2482,7 +2424,6 @@ TclCompileForCmd( testCodeOffset += 3; } - SetLineInformation(2); envPtr->currStackDepth = savedStackDepth; TclCompileExprWords(interp, testTokenPtr, 1, envPtr); envPtr->currStackDepth = savedStackDepth + 1; @@ -2591,10 +2532,9 @@ CompileEachloopCmd( Tcl_Token *tokenPtr, *bodyTokenPtr; unsigned char *jumpPc; JumpFixup jumpFalseFixup; - int jumpBackDist, jumpBackOffset, infoIndex, range, bodyIndex; + int jumpBackDist, jumpBackOffset, infoIndex, range; int numWords, numLists, numVars, loopIndex, tempVar, i, j, code; int savedStackDepth = envPtr->currStackDepth; - DefineLineInformation; /* TIP #280 */ /* * We parse the variable list argument words and create two arrays: @@ -2632,8 +2572,6 @@ CompileEachloopCmd( return TCL_ERROR; } - bodyIndex = i-1; - /* * Allocate storage for the varcList and varvList arrays if necessary. */ @@ -2777,7 +2715,6 @@ CompileEachloopCmd( i < numWords-1; i++, tokenPtr = TokenAfter(tokenPtr)) { if ((i%2 == 0) && (i > 0)) { - SetLineInformation(i); CompileTokens(envPtr, tokenPtr, interp); tempVar = (firstValueTemp + loopIndex); Emit14Inst( INST_STORE_SCALAR, tempVar, envPtr); @@ -2815,7 +2752,6 @@ CompileEachloopCmd( * Inline compile the loop body. */ - SetLineInformation(bodyIndex); ExceptionRangeStarts(envPtr, range); CompileBody(envPtr, bodyTokenPtr, interp); ExceptionRangeEnds(envPtr, range); @@ -3071,7 +3007,6 @@ TclCompileFormatCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr = parsePtr->tokenPtr; Tcl_Obj **objv, *formatObj, *tmpObj; char *bytes, *start; @@ -3220,7 +3155,7 @@ TclCompileFormatCmd( * directly. */ - CompileWord(envPtr, tokenPtr, interp, j); + CompileWord(envPtr, tokenPtr, interp); tokenPtr = TokenAfter(tokenPtr); j++; i++; @@ -3292,7 +3227,6 @@ TclCompileGlobalCmd( { Tcl_Token *varTokenPtr; int localIndex, numWords, i; - DefineLineInformation; /* TIP #280 */ numWords = parsePtr->numWords; if (numWords < 2) { @@ -3325,7 +3259,7 @@ TclCompileGlobalCmd( return TCL_ERROR; } - CompileWord(envPtr, varTokenPtr, interp, 1); + CompileWord(envPtr, varTokenPtr, interp); TclEmitInstInt4( INST_NSUPVAR, localIndex, envPtr); } @@ -3384,7 +3318,6 @@ TclCompileIfCmd( * "if 0 {..}" */ int boolVal; /* Value of static condition. */ int compileScripts = 1; - DefineLineInformation; /* TIP #280 */ /* * Only compile the "if" command if all arguments are simple words, in @@ -3461,7 +3394,6 @@ TclCompileIfCmd( compileScripts = 0; } } else { - SetLineInformation(wordIdx); Tcl_ResetResult(interp); TclCompileExprWords(interp, testTokenPtr, 1, envPtr); if (jumpFalseFixupArray.next >= jumpFalseFixupArray.end) { @@ -3503,7 +3435,6 @@ TclCompileIfCmd( */ if (compileScripts) { - SetLineInformation(wordIdx); envPtr->currStackDepth = savedStackDepth; CompileBody(envPtr, tokenPtr, interp); } @@ -3591,7 +3522,6 @@ TclCompileIfCmd( * Compile the else command body. */ - SetLineInformation(wordIdx); CompileBody(envPtr, tokenPtr, interp); } @@ -3685,7 +3615,6 @@ TclCompileIncrCmd( { Tcl_Token *varTokenPtr, *incrTokenPtr; int simpleVarName, isScalar, localIndex, haveImmValue, immValue; - DefineLineInformation; /* TIP #280 */ if ((parsePtr->numWords != 2) && (parsePtr->numWords != 3)) { return TCL_ERROR; @@ -3693,8 +3622,8 @@ TclCompileIncrCmd( varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, TCL_NO_LARGE_INDEX, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, varTokenPtr, envPtr, TCL_NO_LARGE_INDEX, + &localIndex, &simpleVarName, &isScalar); /* * If an increment is given, push it, but see first if it's a small @@ -3721,7 +3650,6 @@ TclCompileIncrCmd( PushLiteral(envPtr, word, numBytes); } } else { - SetLineInformation(2); CompileTokens(envPtr, incrTokenPtr, interp); } } else { /* No incr amount given so use 1. */ @@ -3800,7 +3728,6 @@ TclCompileInfoCommandsCmd( * compiled. */ CompileEnv *envPtr) { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr; Tcl_Obj *objPtr; char *bytes; @@ -3838,7 +3765,7 @@ TclCompileInfoCommandsCmd( * that the result needs to be list-ified. */ - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_RESOLVE_COMMAND, envPtr); TclEmitOpcode( INST_DUP, envPtr); TclEmitOpcode( INST_STR_LEN, envPtr); @@ -3887,7 +3814,6 @@ TclCompileInfoExistsCmd( { Tcl_Token *tokenPtr; int isScalar, simpleVarName, localIndex; - DefineLineInformation; /* TIP #280 */ if (parsePtr->numWords != 2) { return TCL_ERROR; @@ -3902,8 +3828,8 @@ TclCompileInfoExistsCmd( */ tokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, tokenPtr, envPtr, 0, &localIndex, - &simpleVarName, &isScalar, 1); + PushVarName(interp, tokenPtr, envPtr, 0, &localIndex, + &simpleVarName, &isScalar); /* * Emit instruction to check the variable for existence. @@ -3950,14 +3876,12 @@ TclCompileInfoLevelCmd( } else if (parsePtr->numWords != 2) { return TCL_ERROR; } else { - DefineLineInformation; /* TIP #280 */ /* * Compile the argument, then add the instruction to convert it into a * list of arguments. */ - SetLineInformation(1); CompileTokens(envPtr, TokenAfter(parsePtr->tokenPtr), interp); TclEmitOpcode( INST_INFO_LEVEL_ARGS, envPtr); } @@ -3973,13 +3897,12 @@ TclCompileInfoObjectClassCmd( * compiled. */ CompileEnv *envPtr) { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); if (parsePtr->numWords != 2) { return TCL_ERROR; } - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_TCLOO_CLASS, envPtr); return TCL_OK; } @@ -3993,7 +3916,6 @@ TclCompileInfoObjectIsACmd( * compiled. */ CompileEnv *envPtr) { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); /* @@ -4015,7 +3937,7 @@ TclCompileInfoObjectIsACmd( * Issue the code. */ - CompileWord(envPtr, tokenPtr, interp, 2); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_TCLOO_IS_OBJECT, envPtr); return TCL_OK; } @@ -4029,13 +3951,12 @@ TclCompileInfoObjectNamespaceCmd( * compiled. */ CompileEnv *envPtr) { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); if (parsePtr->numWords != 2) { return TCL_ERROR; } - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_TCLOO_NS, envPtr); return TCL_OK; } @@ -4069,7 +3990,6 @@ TclCompileLappendCmd( { Tcl_Token *varTokenPtr; int simpleVarName, isScalar, localIndex, numWords; - DefineLineInformation; /* TIP #280 */ /* * If we're not in a procedure, don't compile. @@ -4101,8 +4021,8 @@ TclCompileLappendCmd( varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, 0, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, varTokenPtr, envPtr, 0, + &localIndex, &simpleVarName, &isScalar); /* * If we are doing an assignment, push the new value. In the no values @@ -4112,7 +4032,7 @@ TclCompileLappendCmd( if (numWords > 2) { Tcl_Token *valueTokenPtr = TokenAfter(varTokenPtr); - CompileWord(envPtr, valueTokenPtr, interp, 2); + CompileWord(envPtr, valueTokenPtr, interp); } /* @@ -4172,7 +4092,6 @@ TclCompileLassignCmd( { Tcl_Token *tokenPtr; int simpleVarName, isScalar, localIndex, numWords, idx; - DefineLineInformation; /* TIP #280 */ numWords = parsePtr->numWords; @@ -4189,7 +4108,7 @@ TclCompileLassignCmd( */ tokenPtr = TokenAfter(parsePtr->tokenPtr); - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); /* * Generate code to assign values from the list to variables. @@ -4202,8 +4121,8 @@ TclCompileLassignCmd( * Generate the next variable name. */ - PushVarNameWord(interp, tokenPtr, envPtr, 0, &localIndex, - &simpleVarName, &isScalar, idx+2); + PushVarName(interp, tokenPtr, envPtr, 0, &localIndex, + &simpleVarName, &isScalar); /* * Emit instructions to get the idx'th item out of the list value on @@ -4281,7 +4200,6 @@ TclCompileLindexCmd( { Tcl_Token *idxTokenPtr, *valTokenPtr; int i, numWords = parsePtr->numWords; - DefineLineInformation; /* TIP #280 */ /* * Quit if too few args. @@ -4325,7 +4243,7 @@ TclCompileLindexCmd( * by an "immediate lindex" which is the most efficient variety. */ - CompileWord(envPtr, valTokenPtr, interp, 1); + CompileWord(envPtr, valTokenPtr, interp); TclEmitInstInt4( INST_LIST_INDEX_IMM, idx, envPtr); return TCL_OK; } @@ -4342,7 +4260,7 @@ TclCompileLindexCmd( emitComplexLindex: for (i=1 ; i<numWords ; i++) { - CompileWord(envPtr, valTokenPtr, interp, i); + CompileWord(envPtr, valTokenPtr, interp); valTokenPtr = TokenAfter(valTokenPtr); } @@ -4387,7 +4305,6 @@ TclCompileListCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *valueTokenPtr; int i, numWords; @@ -4413,7 +4330,7 @@ TclCompileListCmd( numWords = parsePtr->numWords; valueTokenPtr = TokenAfter(parsePtr->tokenPtr); for (i = 1; i < numWords; i++) { - CompileWord(envPtr, valueTokenPtr, interp, i); + CompileWord(envPtr, valueTokenPtr, interp); valueTokenPtr = TokenAfter(valueTokenPtr); } TclEmitInstInt4( INST_LIST, numWords - 1, envPtr); @@ -4450,14 +4367,13 @@ TclCompileLlengthCmd( CompileEnv *envPtr) /* Holds resulting instructions. */ { Tcl_Token *varTokenPtr; - DefineLineInformation; /* TIP #280 */ if (parsePtr->numWords != 2) { return TCL_ERROR; } varTokenPtr = TokenAfter(parsePtr->tokenPtr); - CompileWord(envPtr, varTokenPtr, interp, 1); + CompileWord(envPtr, varTokenPtr, interp); TclEmitOpcode( INST_LIST_LENGTH, envPtr); return TCL_OK; } @@ -4483,7 +4399,6 @@ TclCompileLrangeCmd( CompileEnv *envPtr) /* Holds the resulting instructions. */ { Tcl_Token *tokenPtr, *listTokenPtr; - DefineLineInformation; /* TIP #280 */ Tcl_Obj *tmpObj; int idx1, idx2, result; @@ -4552,7 +4467,7 @@ TclCompileLrangeCmd( * is worth trying to do that given current knowledge. */ - CompileWord(envPtr, listTokenPtr, interp, 1); + CompileWord(envPtr, listTokenPtr, interp); TclEmitInstInt4( INST_LIST_RANGE_IMM, idx1, envPtr); TclEmitInt4( idx2, envPtr); return TCL_OK; @@ -4582,7 +4497,6 @@ TclCompileLreplaceCmd( CompileEnv *envPtr) /* Holds the resulting instructions. */ { Tcl_Token *tokenPtr, *listTokenPtr; - DefineLineInformation; /* TIP #280 */ Tcl_Obj *tmpObj; int idx1, idx2, result, guaranteedDropAll = 0; @@ -4670,7 +4584,7 @@ TclCompileLreplaceCmd( * is worth trying to do that given current knowledge. */ - CompileWord(envPtr, listTokenPtr, interp, 1); + CompileWord(envPtr, listTokenPtr, interp); if (guaranteedDropAll) { TclEmitOpcode( INST_LIST_LENGTH, envPtr); TclEmitOpcode( INST_POP, envPtr); @@ -4739,7 +4653,6 @@ TclCompileLsetCmd( int simpleVarName; /* Flag == 1 if var name is simple. */ int isScalar; /* Flag == 1 if scalar, 0 if array. */ int i; - DefineLineInformation; /* TIP #280 */ /* * Check argument count. @@ -4762,8 +4675,8 @@ TclCompileLsetCmd( */ varTokenPtr = TokenAfter(parsePtr->tokenPtr); - PushVarNameWord(interp, varTokenPtr, envPtr, 0, - &localIndex, &simpleVarName, &isScalar, 1); + PushVarName(interp, varTokenPtr, envPtr, 0, + &localIndex, &simpleVarName, &isScalar); /* * Push the "index" args and the new element value. @@ -4771,7 +4684,7 @@ TclCompileLsetCmd( for (i=2 ; i<parsePtr->numWords ; ++i) { varTokenPtr = TokenAfter(varTokenPtr); - CompileWord(envPtr, varTokenPtr, interp, i); + CompileWord(envPtr, varTokenPtr, interp); } /* @@ -4939,7 +4852,6 @@ TclCompileNamespaceCodeCmd( CompileEnv *envPtr) /* Holds resulting instructions. */ { Tcl_Token *tokenPtr; - DefineLineInformation; /* TIP #280 */ if (parsePtr->numWords != 2) { return TCL_ERROR; @@ -4974,7 +4886,7 @@ TclCompileNamespaceCodeCmd( PushLiteral(envPtr, "::namespace", 11); PushLiteral(envPtr, "inscope", 7); TclEmitOpcode( INST_NS_CURRENT, envPtr); - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); TclEmitInstInt4( INST_LIST, 4, envPtr); return TCL_OK; } @@ -4989,14 +4901,13 @@ TclCompileNamespaceQualifiersCmd( CompileEnv *envPtr) /* Holds resulting instructions. */ { Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); - DefineLineInformation; /* TIP #280 */ int off; if (parsePtr->numWords != 2) { return TCL_ERROR; } - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); PushLiteral(envPtr, "0", 1); PushLiteral(envPtr, "::", 2); TclEmitInstInt4( INST_OVER, 2, envPtr); @@ -5025,7 +4936,6 @@ TclCompileNamespaceTailCmd( CompileEnv *envPtr) /* Holds resulting instructions. */ { Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr); - DefineLineInformation; /* TIP #280 */ JumpFixup jumpFixup; if (parsePtr->numWords != 2) { @@ -5036,7 +4946,7 @@ TclCompileNamespaceTailCmd( * Take care; only add 2 to found index if the string was actually found. */ - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); PushLiteral(envPtr, "::", 2); TclEmitInstInt4( INST_OVER, 1, envPtr); TclEmitOpcode( INST_STR_FIND_LAST, envPtr); @@ -5063,7 +4973,6 @@ TclCompileNamespaceUpvarCmd( { Tcl_Token *tokenPtr, *otherTokenPtr, *localTokenPtr; int simpleVarName, isScalar, localIndex, numWords, i; - DefineLineInformation; /* TIP #280 */ if (envPtr->procPtr == NULL) { return TCL_ERROR; @@ -5083,7 +4992,7 @@ TclCompileNamespaceUpvarCmd( */ tokenPtr = TokenAfter(parsePtr->tokenPtr); - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); /* * Loop over the (otherVar, thisVar) pairs. If any of the thisVar is not a @@ -5096,9 +5005,9 @@ TclCompileNamespaceUpvarCmd( otherTokenPtr = TokenAfter(localTokenPtr); localTokenPtr = TokenAfter(otherTokenPtr); - CompileWord(envPtr, otherTokenPtr, interp, 1); - PushVarNameWord(interp, localTokenPtr, envPtr, 0, - &localIndex, &simpleVarName, &isScalar, 1); + CompileWord(envPtr, otherTokenPtr, interp); + PushVarName(interp, localTokenPtr, envPtr, 0, + &localIndex, &simpleVarName, &isScalar); if ((localIndex < 0) || !isScalar) { return TCL_ERROR; @@ -5124,7 +5033,6 @@ TclCompileNamespaceWhichCmd( * compiled. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr, *opt; int idx; @@ -5156,7 +5064,7 @@ TclCompileNamespaceWhichCmd( * Issue the bytecode. */ - CompileWord(envPtr, tokenPtr, interp, idx); + CompileWord(envPtr, tokenPtr, interp); TclEmitOpcode( INST_RESOLVE_COMMAND, envPtr); return TCL_OK; } @@ -5192,7 +5100,6 @@ TclCompileRegexpCmd( * parse of the RE or string. */ int i, len, nocase, exact, sawLast, simple; const char *str; - DefineLineInformation; /* TIP #280 */ /* * We are only interested in compiling simple regexp cases. Currently @@ -5295,7 +5202,7 @@ TclCompileRegexpCmd( } if (!simple) { - CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords-2); + CompileWord(envPtr, varTokenPtr, interp); } /* @@ -5303,7 +5210,7 @@ TclCompileRegexpCmd( */ varTokenPtr = TokenAfter(varTokenPtr); - CompileWord(envPtr, varTokenPtr, interp, parsePtr->numWords-1); + CompileWord(envPtr, varTokenPtr, interp); if (simple) { if (exact && !nocase) { @@ -5373,7 +5280,6 @@ TclCompileRegsubCmd( * The only optional part is the "--", and no other options are handled. */ - DefineLineInformation; /* TIP #280 */ Tcl_Token *tokenPtr, *stringTokenPtr; Tcl_Obj *patternObj = NULL, *replacementObj = NULL; Tcl_DString pattern; @@ -5486,7 +5392,7 @@ TclCompileRegsubCmd( PushLiteral(envPtr, bytes, len); bytes = Tcl_GetStringFromObj(replacementObj, &len); PushLiteral(envPtr, bytes, len); - CompileWord(envPtr, stringTokenPtr, interp, parsePtr->numWords-2); + CompileWord(envPtr, stringTokenPtr, interp); TclEmitOpcode( INST_STR_MAP, envPtr); done: @@ -5538,7 +5444,6 @@ TclCompileReturnCmd( int savedStackDepth = envPtr->currStackDepth; Tcl_Obj *returnOpts, **objv; Tcl_Token *wordTokenPtr = TokenAfter(parsePtr->tokenPtr); - DefineLineInformation; /* TIP #280 */ /* * Check for special case which can always be compiled: @@ -5555,8 +5460,8 @@ TclCompileReturnCmd( Tcl_Token *optsTokenPtr = TokenAfter(wordTokenPtr); Tcl_Token *msgTokenPtr = TokenAfter(optsTokenPtr); - CompileWord(envPtr, optsTokenPtr, interp, 2); - CompileWord(envPtr, msgTokenPtr, interp, 3); + CompileWord(envPtr, optsTokenPtr, interp); + CompileWord(envPtr, msgTokenPtr, interp); TclEmitOpcode(INST_RETURN_STK, envPtr); envPtr->currStackDepth = savedStackDepth + 1; return TCL_OK; @@ -5608,7 +5513,7 @@ TclCompileReturnCmd( */ if (explicitResult) { - CompileWord(envPtr, wordTokenPtr, interp, numWords-1); + CompileWord(envPtr, wordTokenPtr, interp); } else { /* * No explict result argument, so default result is empty string. @@ -5691,10 +5596,9 @@ TclCompileSyntaxError( int numBytes; const char *bytes = TclGetStringFromObj(msg, &numBytes); - TclErrorStackResetIf(interp, bytes, numBytes); TclEmitPush(TclRegisterNewLiteral(envPtr, bytes, numBytes), envPtr); CompileReturnInternal(envPtr, INST_SYNTAX, TCL_ERROR, 0, - TclNoErrorStack(interp, Tcl_GetReturnOptions(interp, TCL_ERROR))); + Tcl_GetReturnOptions(interp, TCL_ERROR)); } /* @@ -5726,7 +5630,6 @@ TclCompileUpvarCmd( { Tcl_Token *tokenPtr, *otherTokenPtr, *localTokenPtr; int simpleVarName, isScalar, localIndex, numWords, i; - DefineLineInformation; /* TIP #280 */ Tcl_Obj *objPtr = Tcl_NewObj(); if (envPtr->procPtr == NULL) { @@ -5762,7 +5665,7 @@ TclCompileUpvarCmd( if (numWords%2) { return TCL_ERROR; } - CompileWord(envPtr, tokenPtr, interp, 1); + CompileWord(envPtr, tokenPtr, interp); otherTokenPtr = TokenAfter(tokenPtr); i = 4; } else { @@ -5787,9 +5690,9 @@ TclCompileUpvarCmd( for (; i<=numWords; i+=2, otherTokenPtr = TokenAfter(localTokenPtr)) { localTokenPtr = TokenAfter(otherTokenPtr); - CompileWord(envPtr, otherTokenPtr, interp, 1); - PushVarNameWord(interp, localTokenPtr, envPtr, 0, - &localIndex, &simpleVarName, &isScalar, 1); + CompileWord(envPtr, otherTokenPtr, interp); + PushVarName(interp, localTokenPtr, envPtr, 0, + &localIndex, &simpleVarName, &isScalar); if ((localIndex < 0) || !isScalar) { return TCL_ERROR; @@ -5835,7 +5738,6 @@ TclCompileVariableCmd( { Tcl_Token *varTokenPtr, *valueTokenPtr; int localIndex, numWords, i; - DefineLineInformation; /* TIP #280 */ numWords = parsePtr->numWords; if (numWords < 2) { @@ -5865,7 +5767,7 @@ TclCompileVariableCmd( return TCL_ERROR; } - CompileWord(envPtr, varTokenPtr, interp, i); + CompileWord(envPtr, varTokenPtr, interp); TclEmitInstInt4( INST_VARIABLE, localIndex, envPtr); if (i+1 < numWords) { @@ -5873,7 +5775,7 @@ TclCompileVariableCmd( * A value has been given: set the variable, pop the value */ - CompileWord(envPtr, valueTokenPtr, interp, i+1); + CompileWord(envPtr, valueTokenPtr, interp); Emit14Inst( INST_STORE_SCALAR, localIndex, envPtr); TclEmitOpcode( INST_POP, envPtr); } @@ -6073,10 +5975,7 @@ PushVarName( int flags, /* TCL_NO_LARGE_INDEX | TCL_NO_ELEMENT. */ int *localIndexPtr, /* Must not be NULL. */ int *simpleVarNamePtr, /* Must not be NULL. */ - int *isScalarPtr, /* Must not be NULL. */ - int line, /* Line the token starts on. */ - int *clNext) /* Reference to offset of next hidden cont. - * line. */ + int *isScalarPtr) /* Must not be NULL. */ { register const char *p; const char *name, *elName; @@ -6257,8 +6156,6 @@ PushVarName( if (elName != NULL && !(flags & TCL_NO_ELEMENT)) { if (elNameChars) { - envPtr->line = line; - envPtr->clNext = clNext; TclCompileTokens(interp, elemTokenPtr, elemTokenCount, envPtr); } else { @@ -6269,9 +6166,6 @@ PushVarName( /* * The var name isn't simple: compile and push it. */ - - envPtr->line = line; - envPtr->clNext = clNext; CompileTokens(envPtr, varTokenPtr, interp); } |