Tcl Source Code

Artifact [97bd438ecf]
Login

Artifact 97bd438ecf7c8dcb80477af74eae1302f6055a73:

Attachment "exprCleanup.diff" to ticket [562383ffff] added by msofer 2002-05-30 21:43:36.
Index: generic/tclCompExpr.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompExpr.c,v
retrieving revision 1.8
diff -u -r1.8 tclCompExpr.c
--- generic/tclCompExpr.c	11 Dec 2001 14:29:40 -0000	1.8
+++ generic/tclCompExpr.c	30 May 2002 14:18:34 -0000
@@ -59,18 +59,6 @@
 				 * 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 @@
  *	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 @@
     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 @@
     Tcl_FreeParse(&parse);
 
     done:
-    envPtr->exprIsJustVarRef = info.exprIsJustVarRef;
-    envPtr->exprIsComparison = info.exprIsComparison;
     return code;
 }
 
@@ -351,16 +325,6 @@
  *	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 @@
 		goto done;
 	    }
 	    tokenPtr += (tokenPtr->numComponents + 1);
-	    infoPtr->exprIsJustVarRef = 0;
 	    break;
 	    
         case TCL_TOKEN_TEXT:
@@ -419,7 +382,6 @@
 	    }
 	    TclEmitPush(objIndex, envPtr);
 	    tokenPtr += 1;
-	    infoPtr->exprIsJustVarRef = 0;
 	    break;
 	    
         case TCL_TOKEN_BS:
@@ -433,7 +395,6 @@
 	    }
 	    TclEmitPush(objIndex, envPtr);
 	    tokenPtr += 1;
-	    infoPtr->exprIsJustVarRef = 0;
 	    break;
 	    
         case TCL_TOKEN_COMMAND:
@@ -443,7 +404,6 @@
 		goto done;
 	    }
 	    tokenPtr += 1;
-	    infoPtr->exprIsJustVarRef = 0;
 	    break;
 	    
         case TCL_TOKEN_VARIABLE:
@@ -455,7 +415,6 @@
 	    break;
 	    
         case TCL_TOKEN_SUB_EXPR:
-	    infoPtr->exprIsComparison = 0;
 	    code = CompileSubExpr(tokenPtr, infoPtr, envPtr);
 	    if (code != TCL_OK) {
 		goto done;
@@ -489,8 +448,6 @@
 		    goto done;
 		}
 		tokenPtr = endPtr;
-		infoPtr->exprIsJustVarRef = 0;
-		infoPtr->exprIsComparison = 0;
 		break;
 	    }
 	    operator[tokenPtr->size] = (char) savedChar;
@@ -519,10 +476,6 @@
 		}
 		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 @@
 		        opIndex);
 	    } /* end switch on operator requiring special treatment */
 	    infoPtr->hasOperators = 1;
-	    infoPtr->exprIsJustVarRef = 0;
-	    infoPtr->exprIsComparison = 0;
 	    break;
 
         default:
@@ -938,7 +889,6 @@
 		code = TCL_ERROR;
 		goto done;
 	    }
-	    infoPtr->exprIsComparison = 0;
 	    code = CompileSubExpr(tokenPtr, infoPtr, envPtr);
 	    if (code != TCL_OK) {
 		goto done;
Index: generic/tclCompile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompile.c,v
retrieving revision 1.32
diff -u -r1.32 tclCompile.c
--- generic/tclCompile.c	15 Mar 2002 15:39:06 -0000	1.32
+++ generic/tclCompile.c	30 May 2002 14:18:37 -0000
@@ -704,8 +704,6 @@
     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 @@
     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 @@
 	TclEmitOpcode(INST_EXPR_STK, envPtr);
     }
 
-    envPtr->exprIsJustVarRef = saveExprIsJustVarRef;
-    envPtr->exprIsComparison = saveExprIsComparison;
     return code;
 }
 
Index: generic/tclCompile.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompile.h,v
retrieving revision 1.26
diff -u -r1.26 tclCompile.h
--- generic/tclCompile.h	29 Mar 2002 21:01:11 -0000	1.26
+++ generic/tclCompile.h	30 May 2002 14:18:38 -0000
@@ -223,18 +223,6 @@
 				 * 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