diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 7 | ||||
-rw-r--r-- | generic/tclCompile.c | 4 | ||||
-rw-r--r-- | generic/tclCompile.h | 4 | ||||
-rw-r--r-- | generic/tclExecute.c | 11 |
5 files changed, 16 insertions, 16 deletions
@@ -1,5 +1,11 @@ 2008-01-15 Miguel Sofer <msofer@users.sf.net> + * 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: + + * generic/tclCompExpr.c: Fix literal leak in exprs [Bug 1869989] * generic/tclExecute.c: (dgp) 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, |