summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-03-30 18:01:48 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-03-30 18:01:48 (GMT)
commit5a1359a5e8aa149cea117f4f34239cd3a23872f4 (patch)
tree85a0e53462d5b6da6b74451e0c3f9d59004369ed /generic/tclCompile.c
parentedb3e7b8d2efcb3a1282f910f1e7120d5d34c6f8 (diff)
downloadtcl-5a1359a5e8aa149cea117f4f34239cd3a23872f4.zip
tcl-5a1359a5e8aa149cea117f4f34239cd3a23872f4.tar.gz
tcl-5a1359a5e8aa149cea117f4f34239cd3a23872f4.tar.bz2
TIP 660. No compiler warnings. Tests suite pass on Win and Ubuntu
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index be308e3..48947f1 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -680,9 +680,9 @@ static void DupByteCodeInternalRep(Tcl_Obj *srcPtr,
static unsigned char * EncodeCmdLocMap(CompileEnv *envPtr,
ByteCode *codePtr, unsigned char *startPtr);
static void EnterCmdExtentData(CompileEnv *envPtr,
- size_t cmdNumber, size_t numSrcBytes, size_t numCodeBytes);
+ Tcl_Size cmdNumber, Tcl_Size numSrcBytes, Tcl_Size numCodeBytes);
static void EnterCmdStartData(CompileEnv *envPtr,
- size_t cmdNumber, size_t srcOffset, size_t codeOffset);
+ Tcl_Size cmdNumber, Tcl_Size srcOffset, Tcl_Size codeOffset);
static void FreeByteCodeInternalRep(Tcl_Obj *objPtr);
static void FreeSubstCodeInternalRep(Tcl_Obj *objPtr);
static int GetCmdLocEncodingSize(CompileEnv *envPtr);
@@ -699,9 +699,9 @@ static void StartExpanding(CompileEnv *envPtr);
* TIP #280: Helper for building the per-word line information of all compiled
* commands.
*/
-static void EnterCmdWordData(ExtCmdLoc *eclPtr, size_t srcOffset,
+static void EnterCmdWordData(ExtCmdLoc *eclPtr, Tcl_Size srcOffset,
Tcl_Token *tokenPtr, const char *cmd,
- size_t numWords, size_t line, int *clNext, int **lines,
+ Tcl_Size numWords, Tcl_Size line, int *clNext, int **lines,
CompileEnv *envPtr);
static void ReleaseCmdWordData(ExtCmdLoc *eclPtr);
@@ -1391,7 +1391,7 @@ static void
ReleaseCmdWordData(
ExtCmdLoc *eclPtr)
{
- size_t i;
+ Tcl_Size i;
if (eclPtr->type == TCL_LOCATION_SOURCE) {
Tcl_DecrRefCount(eclPtr->path);
@@ -1553,7 +1553,7 @@ TclInitCompileEnv(
pc = 1;
}
- if ((ctxPtr->nline <= (size_t)word) || (ctxPtr->line[word] < 0)) {
+ if ((ctxPtr->nline <= word) || (ctxPtr->line[word] < 0)) {
/*
* Word is not a literal, relative counting.
*/
@@ -1647,7 +1647,7 @@ TclFreeCompileEnv(
* have transferred to it.
*/
- size_t i;
+ Tcl_Size i;
LiteralEntry *entryPtr = envPtr->literalArrayPtr;
AuxData *auxDataPtr = envPtr->auxDataArrayPtr;
@@ -2161,7 +2161,7 @@ TclCompileScript(
*/
if (iPtr->numLevels / 5 > iPtr->maxNestingDepth / 4) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "too many nested compilations (infinite loop?)", TCL_INDEX_NONE));
+ "too many nested compilations (infinite loop?)", -1));
Tcl_SetErrorCode(interp, "TCL", "LIMIT", "STACK", NULL);
TclCompileSyntaxError(interp, envPtr);
return;
@@ -2323,8 +2323,8 @@ TclCompileVarSubst(
CompileEnv *envPtr)
{
const char *p, *name = tokenPtr[1].start;
- size_t i, nameBytes = tokenPtr[1].size;
- size_t localVar;
+ Tcl_Size i, nameBytes = tokenPtr[1].size;
+ Tcl_Size localVar;
int localVarName = 1;
/*
@@ -2352,11 +2352,11 @@ TclCompileVarSubst(
* of local variables in a procedure frame.
*/
- localVar = TCL_INDEX_NONE;
+ localVar = -1;
if (localVarName != -1) {
localVar = TclFindCompiledLocal(name, nameBytes, localVarName, envPtr);
}
- if (localVar == TCL_INDEX_NONE) {
+ if (localVar < 0) {
PushLiteral(envPtr, name, nameBytes);
}
@@ -2368,7 +2368,7 @@ TclCompileVarSubst(
tokenPtr[1].start + tokenPtr[1].size);
if (tokenPtr->numComponents == 1) {
- if (localVar == TCL_INDEX_NONE) {
+ if (localVar < 0) {
TclEmitOpcode(INST_LOAD_STK, envPtr);
} else if (localVar <= 255) {
TclEmitInstInt1(INST_LOAD_SCALAR1, localVar, envPtr);
@@ -2377,7 +2377,7 @@ TclCompileVarSubst(
}
} else {
TclCompileTokens(interp, tokenPtr+2, tokenPtr->numComponents-1, envPtr);
- if (localVar == TCL_INDEX_NONE) {
+ if (localVar < 0) {
TclEmitOpcode(INST_LOAD_ARRAY_STK, envPtr);
} else if (localVar <= 255) {
TclEmitInstInt1(INST_LOAD_ARRAY1, localVar, envPtr);
@@ -2776,7 +2776,7 @@ PreventCycle(
Tcl_Obj *objPtr,
CompileEnv *envPtr)
{
- size_t i;
+ Tcl_Size i;
for (i = 0; i < envPtr->literalArrayNext; i++) {
if (objPtr == TclFetchLiteral(envPtr, i)) {
@@ -2791,7 +2791,7 @@ PreventCycle(
* can be sure we do not have any lingering cycles hiding in
* the internalrep.
*/
- size_t numBytes;
+ Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes);
Tcl_Obj *copyPtr = Tcl_NewStringObj(bytes, numBytes);
@@ -2993,19 +2993,19 @@ TclInitByteCodeObj(
*----------------------------------------------------------------------
*/
-size_t
+Tcl_Size
TclFindCompiledLocal(
const char *name, /* Points to first character of the name of a
* scalar or array variable. If NULL, a
* temporary var should be created. */
- size_t nameBytes, /* Number of bytes in the name. */
+ Tcl_Size nameBytes, /* Number of bytes in the name. */
int create, /* If 1, allocate a local frame entry for the
* variable if it is new. */
CompileEnv *envPtr) /* Points to the current compile environment*/
{
CompiledLocal *localPtr;
- size_t localVar = TCL_INDEX_NONE;
- size_t i;
+ Tcl_Size localVar = TCL_INDEX_NONE;
+ Tcl_Size i;
Proc *procPtr;
/*
@@ -3024,7 +3024,7 @@ TclFindCompiledLocal(
LocalCache *cachePtr = envPtr->iPtr->varFramePtr->localCachePtr;
const char *localName;
Tcl_Obj **varNamePtr;
- size_t len;
+ Tcl_Size len;
if (!cachePtr || !name) {
return TCL_INDEX_NONE;
@@ -3043,7 +3043,7 @@ TclFindCompiledLocal(
}
if (name != NULL) {
- size_t localCt = procPtr->numCompiledLocals;
+ Tcl_Size localCt = procPtr->numCompiledLocals;
localPtr = procPtr->firstLocalPtr;
for (i = 0; i < localCt; i++) {
@@ -3171,14 +3171,14 @@ EnterCmdStartData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
- size_t cmdIndex, /* Index of the command whose start data is
+ Tcl_Size cmdIndex, /* Index of the command whose start data is
* being set. */
- size_t srcOffset, /* Offset of first char of the command. */
- size_t codeOffset) /* Offset of first byte of command code. */
+ Tcl_Size srcOffset, /* Offset of first char of the command. */
+ Tcl_Size codeOffset) /* Offset of first byte of command code. */
{
CmdLocation *cmdLocPtr;
- if (cmdIndex >= envPtr->numCommands) {
+ if (cmdIndex < 0 || cmdIndex >= envPtr->numCommands) {
Tcl_Panic("EnterCmdStartData: bad command index %" TCL_Z_MODIFIER "u", cmdIndex);
}
@@ -3250,14 +3250,14 @@ EnterCmdExtentData(
CompileEnv *envPtr, /* Points to the compilation environment
* structure in which to enter command
* location information. */
- size_t cmdIndex, /* Index of the command whose source and code
+ Tcl_Size cmdIndex, /* Index of the command whose source and code
* length data is being set. */
- size_t numSrcBytes, /* Number of command source chars. */
- size_t numCodeBytes) /* Offset of last byte of command code. */
+ Tcl_Size numSrcBytes, /* Number of command source chars. */
+ Tcl_Size numCodeBytes) /* Offset of last byte of command code. */
{
CmdLocation *cmdLocPtr;
- if (cmdIndex >= envPtr->numCommands) {
+ if (cmdIndex < 0 || cmdIndex >= envPtr->numCommands) {
Tcl_Panic("EnterCmdExtentData: bad command index %" TCL_Z_MODIFIER "u", cmdIndex);
}
@@ -3296,18 +3296,18 @@ EnterCmdWordData(
ExtCmdLoc *eclPtr, /* Points to the map environment structure in
* which to enter command location
* information. */
- size_t srcOffset, /* Offset of first char of the command. */
+ Tcl_Size srcOffset, /* Offset of first char of the command. */
Tcl_Token *tokenPtr,
const char *cmd,
- size_t numWords,
- size_t line,
+ Tcl_Size numWords,
+ Tcl_Size line,
int *clNext,
int **wlines,
CompileEnv *envPtr)
{
ECL *ePtr;
const char *last;
- size_t wordIdx, wordLine;
+ Tcl_Size wordIdx, wordLine;
int *wwlines, *wordNext;
if (eclPtr->nuloc >= eclPtr->nloc) {
@@ -3373,7 +3373,7 @@ EnterCmdWordData(
*----------------------------------------------------------------------
*/
-size_t
+Tcl_Size
TclCreateExceptRange(
ExceptionRangeType type, /* The kind of ExceptionRange desired. */
CompileEnv *envPtr)/* Points to CompileEnv for which to create a
@@ -3381,7 +3381,7 @@ TclCreateExceptRange(
{
ExceptionRange *rangePtr;
ExceptionAux *auxPtr;
- size_t index = envPtr->exceptArrayNext;
+ Tcl_Size index = envPtr->exceptArrayNext;
if (index >= envPtr->exceptArrayEnd) {
/*
@@ -3734,7 +3734,7 @@ TclFinalizeLoopExceptionRange(
*----------------------------------------------------------------------
*/
-size_t
+Tcl_Size
TclCreateAuxData(
void *clientData, /* The compilation auxiliary data to store in
* the new aux data record. */
@@ -3743,7 +3743,7 @@ TclCreateAuxData(
CompileEnv *envPtr)/* Points to the CompileEnv for which a new
* aux data structure is to be allocated. */
{
- size_t index; /* Index for the new AuxData structure. */
+ Tcl_Size index; /* Index for the new AuxData structure. */
AuxData *auxDataPtr;
/* Points to the new AuxData structure */
@@ -4416,8 +4416,8 @@ EncodeCmdLocMap(
* is to be stored. */
{
CmdLocation *mapPtr = envPtr->cmdMapPtr;
- size_t i, codeDelta, codeLen, srcLen, prevOffset;
- size_t numCmds = envPtr->numCommands;
+ Tcl_Size i, codeDelta, codeLen, srcLen, prevOffset;
+ Tcl_Size numCmds = envPtr->numCommands;
unsigned char *p = startPtr;
int srcDelta;
@@ -4429,7 +4429,7 @@ EncodeCmdLocMap(
prevOffset = 0;
for (i = 0; i < numCmds; i++) {
codeDelta = mapPtr[i].codeOffset - prevOffset;
- if (codeDelta == TCL_INDEX_NONE) {
+ if (codeDelta < 0) {
Tcl_Panic("EncodeCmdLocMap: bad code offset");
} else if (codeDelta <= 127) {
TclStoreInt1AtPtr(codeDelta, p);
@@ -4450,7 +4450,7 @@ EncodeCmdLocMap(
codePtr->codeLengthStart = p;
for (i = 0; i < numCmds; i++) {
codeLen = mapPtr[i].numCodeBytes;
- if (codeLen == TCL_INDEX_NONE) {
+ if (codeLen < 0) {
Tcl_Panic("EncodeCmdLocMap: bad code length");
} else if (codeLen <= 127) {
TclStoreInt1AtPtr(codeLen, p);
@@ -4490,7 +4490,7 @@ EncodeCmdLocMap(
codePtr->srcLengthStart = p;
for (i = 0; i < numCmds; i++) {
srcLen = mapPtr[i].numSrcBytes;
- if (srcLen == TCL_INDEX_NONE) {
+ if (srcLen < 0) {
Tcl_Panic("EncodeCmdLocMap: bad source length");
} else if (srcLen <= 127) {
TclStoreInt1AtPtr(srcLen, p);