summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2002-05-30 15:03:56 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2002-05-30 15:03:56 (GMT)
commit4fad013842bba77cfb05f7f123ed77ff006d8c74 (patch)
treecfff63a211f06f2de572598136ae6438ca72ef5f /generic
parentcc88c140a0a394a4427eb1b96c89546939ee599d (diff)
downloadtcl-4fad013842bba77cfb05f7f123ed77ff006d8c74.zip
tcl-4fad013842bba77cfb05f7f123ed77ff006d8c74.tar.gz
tcl-4fad013842bba77cfb05f7f123ed77ff006d8c74.tar.bz2
cleanup in [expr] compiler
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompExpr.c52
-rw-r--r--generic/tclCompile.c8
-rw-r--r--generic/tclCompile.h14
3 files changed, 3 insertions, 71 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 8db30b2..b21477a 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.8 2001/12/11 14:29:40 msofer Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.9 2002/05/30 15:03:56 msofer Exp $
*/
#include "tclInt.h"
@@ -59,18 +59,6 @@ typedef struct ExprInfo {
* compiling an expr, a tryCvtToNumeric
* instruction is emitted to convert the
* primary to a number if possible. */
- int exprIsJustVarRef; /* Set 1 if the expr consists of just a
- * variable reference as in the expression
- * of "if $b then...". Otherwise 0. If 1 the
- * expr is compiled out-of-line in order to
- * implement expr's 2 level substitution
- * semantics properly. */
- int exprIsComparison; /* Set 1 if the top-level operator in the
- * expr is a comparison. Otherwise 0. If 1,
- * because the operands might be strings,
- * the expr is compiled out-of-line in order
- * to implement expr's 2 level substitution
- * semantics properly. */
} ExprInfo;
/*
@@ -206,16 +194,6 @@ static void LogSyntaxError _ANSI_ARGS_((ExprInfo *infoPtr));
* on failure. If TCL_ERROR is returned, then the interpreter's result
* contains an error message.
*
- * envPtr->exprIsJustVarRef is set 1 if the expression consisted of
- * a single variable reference as in the expression of "if $b then...".
- * Otherwise it is set 0. This is used to implement Tcl's two level
- * expression substitution semantics properly.
- *
- * envPtr->exprIsComparison is set 1 if the top-level operator in the
- * expr is a comparison. Otherwise it is set 0. If 1, because the
- * operands might be strings, the expr is compiled out-of-line in order
- * to implement expr's 2 level substitution semantics properly.
- *
* Side effects:
* Adds instructions to envPtr to evaluate the expression at runtime.
*
@@ -270,8 +248,6 @@ TclCompileExpr(interp, script, numBytes, envPtr)
info.expr = script;
info.lastChar = (script + numBytes);
info.hasOperators = 0;
- info.exprIsJustVarRef = 1; /* will be set 0 if anything else is seen */
- info.exprIsComparison = 0;
/*
* Parse the expression then compile it.
@@ -301,8 +277,6 @@ TclCompileExpr(interp, script, numBytes, envPtr)
Tcl_FreeParse(&parse);
done:
- envPtr->exprIsJustVarRef = info.exprIsJustVarRef;
- envPtr->exprIsComparison = info.exprIsComparison;
return code;
}
@@ -351,16 +325,6 @@ TclFinalizeCompilation()
* on failure. If TCL_ERROR is returned, then the interpreter's result
* contains an error message.
*
- * envPtr->exprIsJustVarRef is set 1 if the subexpression consisted of
- * a single variable reference as in the expression of "if $b then...".
- * Otherwise it is set 0. This is used to implement Tcl's two level
- * expression substitution semantics properly.
- *
- * envPtr->exprIsComparison is set 1 if the top-level operator in the
- * subexpression is a comparison. Otherwise it is set 0. If 1, because
- * the operands might be strings, the expr is compiled out-of-line in
- * order to implement expr's 2 level substitution semantics properly.
- *
* Side effects:
* Adds instructions to envPtr to evaluate the subexpression.
*
@@ -407,7 +371,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
goto done;
}
tokenPtr += (tokenPtr->numComponents + 1);
- infoPtr->exprIsJustVarRef = 0;
break;
case TCL_TOKEN_TEXT:
@@ -419,7 +382,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
}
TclEmitPush(objIndex, envPtr);
tokenPtr += 1;
- infoPtr->exprIsJustVarRef = 0;
break;
case TCL_TOKEN_BS:
@@ -433,7 +395,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
}
TclEmitPush(objIndex, envPtr);
tokenPtr += 1;
- infoPtr->exprIsJustVarRef = 0;
break;
case TCL_TOKEN_COMMAND:
@@ -443,7 +404,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
goto done;
}
tokenPtr += 1;
- infoPtr->exprIsJustVarRef = 0;
break;
case TCL_TOKEN_VARIABLE:
@@ -455,7 +415,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
break;
case TCL_TOKEN_SUB_EXPR:
- infoPtr->exprIsComparison = 0;
code = CompileSubExpr(tokenPtr, infoPtr, envPtr);
if (code != TCL_OK) {
goto done;
@@ -489,8 +448,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
goto done;
}
tokenPtr = endPtr;
- infoPtr->exprIsJustVarRef = 0;
- infoPtr->exprIsComparison = 0;
break;
}
operator[tokenPtr->size] = (char) savedChar;
@@ -519,10 +476,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
}
TclEmitOpcode(opDescPtr->instruction, envPtr);
infoPtr->hasOperators = 1;
- infoPtr->exprIsJustVarRef = 0;
- infoPtr->exprIsComparison =
- (((opIndex >= OP_LESS) && (opIndex <= OP_NEQ))
- || ((opIndex >= OP_STREQ) && (opIndex <= OP_STRNEQ)));
break;
}
@@ -591,8 +544,6 @@ CompileSubExpr(exprTokenPtr, infoPtr, envPtr)
opIndex);
} /* end switch on operator requiring special treatment */
infoPtr->hasOperators = 1;
- infoPtr->exprIsJustVarRef = 0;
- infoPtr->exprIsComparison = 0;
break;
default:
@@ -938,7 +889,6 @@ CompileMathFuncCall(exprTokenPtr, funcName, infoPtr, envPtr, endPtrPtr)
code = TCL_ERROR;
goto done;
}
- infoPtr->exprIsComparison = 0;
code = CompileSubExpr(tokenPtr, infoPtr, envPtr);
if (code != TCL_OK) {
goto done;
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index d461309..bd94b86 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.32 2002/03/15 15:39:06 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.33 2002/05/30 15:03:57 msofer Exp $
*/
#include "tclInt.h"
@@ -704,8 +704,6 @@ TclInitCompileEnv(interp, envPtr, string, numBytes)
envPtr->maxStackDepth = 0;
envPtr->currStackDepth = 0;
TclInitLiteralTable(&(envPtr->localLitTable));
- envPtr->exprIsJustVarRef = 0;
- envPtr->exprIsComparison = 0;
envPtr->codeStart = envPtr->staticCodeSpace;
envPtr->codeNext = envPtr->codeStart;
@@ -1399,8 +1397,6 @@ TclCompileExprWords(interp, tokenPtr, numWords, envPtr)
Tcl_Token *wordPtr;
int range, numBytes, i, code;
char *script;
- int saveExprIsJustVarRef = envPtr->exprIsJustVarRef;
- int saveExprIsComparison = envPtr->exprIsComparison;
range = -1;
code = TCL_OK;
@@ -1452,8 +1448,6 @@ TclCompileExprWords(interp, tokenPtr, numWords, envPtr)
TclEmitOpcode(INST_EXPR_STK, envPtr);
}
- envPtr->exprIsJustVarRef = saveExprIsJustVarRef;
- envPtr->exprIsComparison = saveExprIsComparison;
return code;
}
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 074cb91..8a04dac 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompile.h,v 1.26 2002/03/29 21:01:11 dgp Exp $
+ * RCS: @(#) $Id: tclCompile.h,v 1.27 2002/05/30 15:03:57 msofer Exp $
*/
#ifndef _TCLCOMPILATION
@@ -223,18 +223,6 @@ typedef struct CompileEnv {
* compiled code. Indexed by the string
* representations of the literals. Used to
* avoid creating duplicate objects. */
- int exprIsJustVarRef; /* Set 1 if the expression last compiled by
- * TclCompileExpr consisted of just a
- * variable reference as in the expression
- * of "if $b then...". Otherwise 0. Used
- * to implement expr's 2 level substitution
- * semantics properly. */
- int exprIsComparison; /* Set 1 if the top-level operator in the
- * expression last compiled is a comparison.
- * Otherwise 0. If 1, since the operands
- * might be strings, the expr is compiled
- * out-of-line to implement expr's 2 level
- * substitution semantics properly. */
unsigned char *codeStart; /* Points to the first byte of the code. */
unsigned char *codeNext; /* Points to next code array byte to use. */
unsigned char *codeEnd; /* Points just after the last allocated