summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2008-01-16 21:05:46 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2008-01-16 21:05:46 (GMT)
commit6101ed5d08da556682f4d6c8870f87180eeef50a (patch)
tree5ccefed6827a363ec7449b2b710f2f55806a4c92 /generic
parent649a6115420f5c28c50feee55a7e0e441b22188d (diff)
downloadtcl-6101ed5d08da556682f4d6c8870f87180eeef50a.zip
tcl-6101ed5d08da556682f4d6c8870f87180eeef50a.tar.gz
tcl-6101ed5d08da556682f4d6c8870f87180eeef50a.tar.bz2
* generic/tclCompExpr.c: add an 'optimize' argument to
* generic/tclCompile.c: TclCompileExpr() to profit from better * generic/tclCompile.h: literal management according to usage. * generic/tclExecute.c:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompExpr.c7
-rw-r--r--generic/tclCompile.c4
-rw-r--r--generic/tclCompile.h4
-rw-r--r--generic/tclExecute.c11
4 files changed, 10 insertions, 16 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 22022cf..c3d7532 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,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.92 2008/01/16 19:44:13 msofer Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.93 2008/01/16 21:05:47 msofer Exp $
*/
#include "tclInt.h"
@@ -2000,7 +2000,8 @@ TclCompileExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *script, /* The source script to compile. */
int numBytes, /* Number of bytes in script. */
- CompileEnv *envPtr) /* Holds resulting instructions. */
+ CompileEnv *envPtr, /* Holds resulting instructions. */
+ int optimize) /* 0 for one-off expressions */
{
OpNode *opTree = NULL; /* Will point to the tree of operators */
Tcl_Obj *litList = Tcl_NewObj(); /* List to hold the literals */
@@ -2026,7 +2027,7 @@ TclCompileExpr(
TclListObjGetElements(NULL, litList, &objc, (Tcl_Obj ***)&litObjv);
TclListObjGetElements(NULL, funcList, &objc, &funcObjv);
CompileExprTree(interp, opTree, 0, &litObjv, funcObjv,
- parsePtr->tokenPtr, envPtr, 1 /* optimize */);
+ parsePtr->tokenPtr, envPtr, optimize);
} else {
TclCompileSyntaxError(interp, envPtr);
}
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index c6a48fc..b4f4d97 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.144 2007/12/13 15:23:15 dgp Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.145 2008/01/16 21:05:48 msofer Exp $
*/
#include "tclInt.h"
@@ -1823,7 +1823,7 @@ TclCompileExprWords(
*/
if ((numWords == 1) && (tokenPtr->type == TCL_TOKEN_SIMPLE_WORD)) {
- TclCompileExpr(interp, tokenPtr[1].start, tokenPtr[1].size, envPtr);
+ TclCompileExpr(interp, tokenPtr[1].start, tokenPtr[1].size, envPtr, 1);
return;
}
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index f9eec91..98776ca 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -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: tclCompile.h,v 1.87 2008/01/15 11:59:28 msofer Exp $
+ * RCS: @(#) $Id: tclCompile.h,v 1.88 2008/01/16 21:05:48 msofer Exp $
*/
#ifndef _TCLCOMPILATION
@@ -858,7 +858,7 @@ MODULE_SCOPE void TclCompileCmdWord(Tcl_Interp *interp,
Tcl_Token *tokenPtr, int count,
CompileEnv *envPtr);
MODULE_SCOPE void TclCompileExpr(Tcl_Interp *interp, CONST char *script,
- int numBytes, CompileEnv *envPtr);
+ int numBytes, CompileEnv *envPtr, int optimize);
MODULE_SCOPE void TclCompileExprWords(Tcl_Interp *interp,
Tcl_Token *tokenPtr, int numWords,
CompileEnv *envPtr);
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 472ed7f..d28fd74 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.359 2008/01/16 19:44:13 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.360 2008/01/16 21:05:48 msofer Exp $
*/
#include "tclInt.h"
@@ -1228,14 +1228,7 @@ Tcl_ExprObj(
const char *string = TclGetStringFromObj(objPtr, &length);
TclInitCompileEnv(interp, &compEnv, string, length, NULL, 0);
-
- /*
- * TODO: Consider creating and calling an alternative routine
- * that will compile bytecode for one-off expressions like this
- * one with optimize==0, for improved efficiency.
- */
-
- TclCompileExpr(interp, string, length, &compEnv);
+ TclCompileExpr(interp, string, length, &compEnv, 0);
/*
* Successful compilation. If the expression yielded no instructions,