diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2008-07-25 20:30:24 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2008-07-25 20:30:24 (GMT) |
commit | fda70348e3d85160f022abcc1ccc3aad7ee4b942 (patch) | |
tree | 87d311ea52aa54f2769f6a3585c367411bdd337e /generic/tclCompile.c | |
parent | 3e12d4be085349faa2110b266755220e6dbcb758 (diff) | |
download | tcl-fda70348e3d85160f022abcc1ccc3aad7ee4b942.zip tcl-fda70348e3d85160f022abcc1ccc3aad7ee4b942.tar.gz tcl-fda70348e3d85160f022abcc1ccc3aad7ee4b942.tar.bz2 |
* tests/info.test: Tests 38.* added, exactly testing the tracking
of location for uplevel scripts.
* generic/tclCompile.c (TclInitCompileEnv): Reorganized the
initialization of the #280 location information to match the flow
in TclEvalObjEx to get more absolute contexts.
* generic/tclBasic.c (TclEvalObjEx): Moved the pure-list
optimization out of the eval-direct code path to be done always,
i.e. even when a compile is requested. This way we do not loose
the association between #280 location information and the list
elements, if any.
FossilOrigin-Name: 8102aefa68d7f11bae74141a7934ba04034fbb25
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r-- | generic/tclCompile.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index e557860..3c7ca6e 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.146.2.5 2008/07/23 20:47:32 andreas_kupries Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.146.2.6 2008/07/25 20:30:44 andreas_kupries Exp $ */ #include "tclInt.h" @@ -933,7 +933,22 @@ TclInitCompileEnv( * ...) which may make change the type as well. */ - if ((invoker->nline <= word) || (invoker->line[word] < 0)) { + CmdFrame* ctxPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame)); + int pc = 0; + + *ctxPtr = *invoker; + + if (invoker->type == TCL_LOCATION_BC) { + /* + * Note: Type BC => ctx.data.eval.path is not used. + * ctx.data.tebc.codePtr is used instead. + */ + + TclGetSrcInfoForPc(ctxPtr); + pc = 1; + } + + if ((ctxPtr->nline <= word) || (ctxPtr->line[word] < 0)) { /* * Word is not a literal, relative counting. */ @@ -941,45 +956,37 @@ TclInitCompileEnv( envPtr->line = 1; envPtr->extCmdMapPtr->type = (envPtr->procPtr ? TCL_LOCATION_PROC : TCL_LOCATION_BC); - } else { - CmdFrame *ctxPtr; - int pc = 0; - - ctxPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame)); - *ctxPtr = *invoker; - if (invoker->type == TCL_LOCATION_BC) { + if (pc && (ctxPtr->type == TCL_LOCATION_SOURCE)) { /* - * Note: Type BC => ctx.data.eval.path is not used. - * ctx.data.tebc.codePtr is used instead. + * The reference made by 'TclGetSrcInfoForPc' is dead. */ - - TclGetSrcInfoForPc(ctxPtr); - pc = 1; + Tcl_DecrRefCount(ctxPtr->data.eval.path); } - + } else { envPtr->line = ctxPtr->line[word]; envPtr->extCmdMapPtr->type = ctxPtr->type; if (ctxPtr->type == TCL_LOCATION_SOURCE) { + envPtr->extCmdMapPtr->path = ctxPtr->data.eval.path; + if (pc) { /* * The reference 'TclGetSrcInfoForPc' made is transfered. */ - envPtr->extCmdMapPtr->path = ctxPtr->data.eval.path; ctxPtr->data.eval.path = NULL; } else { /* * We have a new reference here. */ - envPtr->extCmdMapPtr->path = ctxPtr->data.eval.path; - Tcl_IncrRefCount(envPtr->extCmdMapPtr->path); + Tcl_IncrRefCount(ctxPtr->data.eval.path); } } - TclStackFree(interp, ctxPtr); } + + TclStackFree(interp, ctxPtr); } envPtr->auxDataArrayPtr = envPtr->staticAuxDataArraySpace; |