Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove useless variables. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1b1edcdcc7fbe09672a8cd432e1550c2 |
User & Date: | dkf 2013-05-17 11:02:40 |
Context
2013-05-18
| ||
13:25 | Split tclCompCmds.c into two roughly-equal-sized pieces. check-in: acbaf52e6e user: dkf tags: trunk | |
2013-05-17
| ||
17:56 | Merge trunk. Conflicts resolved. Branch builds and runs ok. Still does not have the new expand-su... check-in: 67c1291e8a user: dgp tags: dgp-refactor | |
13:49 | merge trunk check-in: c8652a1430 user: jan.nijtmans tags: novem | |
11:02 | Remove useless variables. check-in: 1b1edcdcc7 user: dkf tags: trunk | |
07:24 | Revert defining _HAVE_32BIT_TIME_T especially for mingw-4.0-rc1: Although it works, it has the side-... check-in: f13860c832 user: jan.nijtmans tags: trunk | |
2013-05-16
| ||
13:24 | Confirmed that every caller of TclProcCompileProc() arranges for the procPtr and nsPtr arguments: ns... Closed-Leaf check-in: 9424cfeac1 user: dgp tags: dkf-review | |
Changes
Changes to generic/tclCompile.c.
︙ | ︙ | |||
553 554 555 556 557 558 559 | Tcl_Obj *copyPtr); static unsigned char * EncodeCmdLocMap(CompileEnv *envPtr, ByteCode *codePtr, unsigned char *startPtr); static void EnterCmdExtentData(CompileEnv *envPtr, int cmdNumber, int numSrcBytes, int numCodeBytes); static void EnterCmdStartData(CompileEnv *envPtr, int cmdNumber, int srcOffset, int codeOffset); | | | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | Tcl_Obj *copyPtr); static unsigned char * EncodeCmdLocMap(CompileEnv *envPtr, ByteCode *codePtr, unsigned char *startPtr); static void EnterCmdExtentData(CompileEnv *envPtr, int cmdNumber, int numSrcBytes, int numCodeBytes); static void EnterCmdStartData(CompileEnv *envPtr, int cmdNumber, int srcOffset, int codeOffset); static Command * FindCompiledCommandFromToken(Tcl_Interp *interp, Tcl_Token *tokenPtr); static void FreeByteCodeInternalRep(Tcl_Obj *objPtr); static void FreeSubstCodeInternalRep(Tcl_Obj *objPtr); static int GetCmdLocEncodingSize(CompileEnv *envPtr); static int IsCompactibleCompileEnv(Tcl_Interp *interp, CompileEnv *envPtr); static void PeepholeOptimize(CompileEnv *envPtr); #ifdef TCL_COMPILE_STATS |
︙ | ︙ | |||
621 622 623 624 625 626 627 628 629 630 631 632 633 634 | static const Tcl_ObjType tclInstNameType = { "instname", /* name */ NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ UpdateStringOfInstName, /* updateStringProc */ NULL, /* setFromAnyProc */ }; /* *---------------------------------------------------------------------- * * TclSetByteCodeFromAny -- * * Part of the bytecode Tcl object type implementation. Attempts to | > > > > > > > | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | static const Tcl_ObjType tclInstNameType = { "instname", /* name */ NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ UpdateStringOfInstName, /* updateStringProc */ NULL, /* setFromAnyProc */ }; /* * Helper macros. */ #define TclIncrUInt4AtPtr(ptr, delta) \ TclStoreInt4AtPtr(TclGetUInt4AtPtr(ptr)+(delta), (ptr)); /* *---------------------------------------------------------------------- * * TclSetByteCodeFromAny -- * * Part of the bytecode Tcl object type implementation. Attempts to |
︙ | ︙ | |||
1773 1774 1775 1776 1777 1778 1779 | } return 1; } /* * --------------------------------------------------------------------- * | | | | < > > > > > | > | | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 | } return 1; } /* * --------------------------------------------------------------------- * * FindCompiledCommandFromToken -- * * A simple helper that looks up a command's compiler from its token. * * --------------------------------------------------------------------- */ static Command * FindCompiledCommandFromToken( Tcl_Interp *interp, Tcl_Token *tokenPtr) { Tcl_DString ds; Command *cmdPtr; /* * If we have a non-trivial token or are suppressing compilation, we stop * right now. */ if ((tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) || (((Interp *) interp)->flags & DONT_COMPILE_CMDS_INLINE)) { return NULL; } /* * We copy the string before trying to find the command by name. We used * to modify the string in place, but this is not safe because the name * resolution handlers could have side effects that rely on the unmodified * string. */ Tcl_DStringInit(&ds); TclDStringAppendToken(&ds, &tokenPtr[1]); cmdPtr = (Command *) Tcl_FindCommand(interp, Tcl_DStringValue(&ds), NULL, /*flags*/ 0); if (cmdPtr != NULL && (cmdPtr->compileProc == NULL || (cmdPtr->nsPtr->flags & NS_SUPPRESS_COMPILATION) || (cmdPtr->flags & CMD_HAS_EXEC_TRACES))) { cmdPtr = NULL; } Tcl_DStringFree(&ds); return cmdPtr; |
︙ | ︙ | |||
1842 1843 1844 1845 1846 1847 1848 | * commands. May not be NULL. */ const char *script, /* The source script to compile. */ int numBytes, /* Number of bytes in script. If < 0, the * script consists of all bytes up to the * first null character. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { | < < < < < < < < | 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 | * commands. May not be NULL. */ const char *script, /* The source script to compile. */ int numBytes, /* Number of bytes in script. If < 0, the * script consists of all bytes up to the * first null character. */ CompileEnv *envPtr) /* Holds resulting instructions. */ { int lastTopLevelCmdIndex = -1; /* Index of most recent toplevel command in * the command location table. Initialized to * avoid compiler warning. */ int startCodeOffset = -1; /* Offset of first byte of current command's * code. Init. to avoid compiler warning. */ unsigned char *entryCodeNext = envPtr->codeNext; const char *p, *next; Command *cmdPtr; Tcl_Token *tokenPtr; int bytesLeft, isFirstCmd, wordIdx, currCmdIndex, commandLength, objIndex; /* TIP #280 */ ExtCmdLoc *eclPtr = envPtr->extCmdMapPtr; int *wlines, wlineat, cmdLine, *clNext; Tcl_Parse *parsePtr = TclStackAlloc(interp, sizeof(Tcl_Parse)); if (envPtr->iPtr == NULL) { Tcl_Panic("TclCompileScript() called on uninitialized CompileEnv"); } if (numBytes < 0) { numBytes = strlen(script); } Tcl_ResetResult(interp); isFirstCmd = 1; /* * Each iteration through the following loop compiles the next command * from the script. */ p = script; bytesLeft = numBytes; |
︙ | ︙ | |||
1976 1977 1978 1979 1980 1981 1982 | } } /* * If expansion was requested, check if the command declares that * it knows how to compile it. Note that if expansion is requested * for the first word, this check will fail as the token type will | | | | | | 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 | } } /* * If expansion was requested, check if the command declares that * it knows how to compile it. Note that if expansion is requested * for the first word, this check will fail as the token type will * inhibit it. (Checked inside FindCompiledCommandFromToken.) This * is as it should be. */ if (expand) { cmdPtr = FindCompiledCommandFromToken(interp, parsePtr->tokenPtr); if (cmdPtr && (cmdPtr->flags & CMD_COMPILES_EXPANDED)) { expand = 0; } } envPtr->numCommands++; currCmdIndex = envPtr->numCommands - 1; |
︙ | ︙ | |||
2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 | * Each iteration of the following loop compiles one word from the * command. */ for (wordIdx = 0, tokenPtr = parsePtr->tokenPtr; wordIdx < parsePtr->numWords; wordIdx++, tokenPtr += tokenPtr->numComponents + 1) { envPtr->line = eclPtr->loc[wlineat].line[wordIdx]; envPtr->clNext = eclPtr->loc[wlineat].next[wordIdx]; if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { /* * The word is not a simple string of characters. */ TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, envPtr); | > > > > | 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 | * Each iteration of the following loop compiles one word from the * command. */ for (wordIdx = 0, tokenPtr = parsePtr->tokenPtr; wordIdx < parsePtr->numWords; wordIdx++, tokenPtr += tokenPtr->numComponents + 1) { /* * Note the parse location information. */ envPtr->line = eclPtr->loc[wlineat].line[wordIdx]; envPtr->clNext = eclPtr->loc[wlineat].next[wordIdx]; if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { /* * The word is not a simple string of characters. */ TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, envPtr); |
︙ | ︙ | |||
2051 2052 2053 2054 2055 2056 2057 | * This is a simple string of literal characters (i.e. we know * it absolutely and can use it directly). If this is the * first word and the command has a compile procedure, let it * compile the command. */ if ((wordIdx == 0) && !expand) { | | < < | < | | | | < < < | | < < | 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 | * This is a simple string of literal characters (i.e. we know * it absolutely and can use it directly). If this is the * first word and the command has a compile procedure, let it * compile the command. */ if ((wordIdx == 0) && !expand) { cmdPtr = FindCompiledCommandFromToken(interp, tokenPtr); if (cmdPtr) { int savedNumCmds = envPtr->numCommands; unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart; int update = 0; #ifdef TCL_COMPILE_DEBUG int startStackDepth = envPtr->currStackDepth; #endif /* * Mark the start of the command; the proper bytecode * length will be updated later. There is no need to * do this for the first bytecode in the compile env, * as the check is done before calling * TclNRExecuteByteCode(). Do emit an INST_START_CMD * in special cases where the first bytecode is in a * loop, to insure that the corresponding command is * counted properly. Compilers for commands able to * produce such a beast (currently 'while 1' only) set * envPtr->atCmdStart to 0 in order to signal this * case. [Bug 1752146] * * Note that the environment is initialised with * atCmdStart=1 to avoid emitting ISC for the first * command. */ if (envPtr->atCmdStart == 1) { if (savedCodeNext != 0) { /* * Increase the number of commands being * started at the current point. Note that * this depends on the exact layout of the * INST_START_CMD's operands, so be careful! */ TclIncrUInt4AtPtr(envPtr->codeNext - 4, 1) } } else if (envPtr->atCmdStart == 0) { TclEmitInstInt4(INST_START_CMD, 0, envPtr); TclEmitInt4(1, envPtr); update = 1; } if (cmdPtr->compileProc(interp, parsePtr, cmdPtr, envPtr) == TCL_OK) { /* * Confirm that the command compiler generated a * single value on the stack as its result. This * is only done in debugging mode, as it *should* * be correct and normal users have no reasonable * way to fix it anyway. */ |
︙ | ︙ | |||
2148 2149 2150 2151 2152 2153 2154 | /* * Decrease the number of commands being started * at the current point. Note that this depends on * the exact layout of the INST_START_CMD's * operands, so be careful! */ | | < < < | 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 | /* * Decrease the number of commands being started * at the current point. Note that this depends on * the exact layout of the INST_START_CMD's * operands, so be careful! */ TclIncrUInt4AtPtr(envPtr->codeNext - 4, -1); } /* * Restore numCommands and codeNext to their correct * values, removing any commands compiled before the * failure to produce bytecode got reported. [Bugs * 705406 and 735055] |
︙ | ︙ | |||
2174 2175 2176 2177 2178 2179 2180 | * was found, push a CmdName object to reduce runtime * lookups. Mark this as a command name literal to reduce * shimmering. */ objIndex = TclRegisterNewCmdLiteral(envPtr, tokenPtr[1].start, tokenPtr[1].size); | | | 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 | * was found, push a CmdName object to reduce runtime * lookups. Mark this as a command name literal to reduce * shimmering. */ objIndex = TclRegisterNewCmdLiteral(envPtr, tokenPtr[1].start, tokenPtr[1].size); if (cmdPtr) { TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, objIndex), cmdPtr); } } else { /* * Simple argument word of a command. We reach this if and * only if the command word was not compiled for whatever |
︙ | ︙ |