summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2006-10-23 21:36:54 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2006-10-23 21:36:54 (GMT)
commit00a65742087d6d3b1aca1c8153ba4d16b169ee27 (patch)
tree3333dae28c1795f39b85a6647ffc38ca89c7e9b1 /generic/tclVar.c
parenta45dac076ba36370d50f550d483af81d54f88513 (diff)
downloadtcl-00a65742087d6d3b1aca1c8153ba4d16b169ee27.zip
tcl-00a65742087d6d3b1aca1c8153ba4d16b169ee27.tar.gz
tcl-00a65742087d6d3b1aca1c8153ba4d16b169ee27.tar.bz2
* generic/tcl.h: Modified the Tcl call stack so
* generic/tclBasic.c: there is always a valid CallFrame, even * generic/tclCmdIL.c: at level 0 [Patch 1577278]. Most of the * generic/tclInt.h: changes involve removing tests for * generic/tclNamesp.c: iPtr->(var)framePtr==NULL. There is now a * generic/tclObj.c: CallFrame pushed at interp creation * generic/tclProc.c: with a pointer to it stored in * generic/tclTrace.c: iPtr->rootFramePtr. A second unused * generic/tclVar.c: field in Interp is hijacked to enable further functionality, currently unused (but with several FRQs depending on it).
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 5f47e7e..4c22bd2 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.124 2006/10/20 15:16:47 dkf Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.125 2006/10/23 21:36:55 msofer Exp $
*/
#include "tclInt.h"
@@ -390,7 +390,7 @@ TclObjLookupVar(
}
part1 = Tcl_GetStringFromObj(part1Ptr, &len1);
- nsPtr = ((varFramePtr == NULL)? iPtr->globalNsPtr : varFramePtr->nsPtr);
+ nsPtr = varFramePtr->nsPtr;
if (nsPtr->varResProc != NULL || iPtr->resolverPtr != NULL) {
goto doParse;
}
@@ -398,8 +398,7 @@ TclObjLookupVar(
if (typePtr == &localVarNameType) {
int localIndex = (int) part1Ptr->internalRep.longValue;
- if ((varFramePtr != NULL)
- && (varFramePtr->isProcCallFrame & FRAME_IS_PROC)
+ if ((varFramePtr->isProcCallFrame & FRAME_IS_PROC)
&& !(flags & (TCL_GLOBAL_ONLY | TCL_NAMESPACE_ONLY))
&& (localIndex < varFramePtr->numCompiledLocals)) {
/*
@@ -422,20 +421,18 @@ TclObjLookupVar(
useGlobal = (cachedNsPtr == iPtr->globalNsPtr) && (
(flags & TCL_GLOBAL_ONLY) ||
(*part1==':' && *(part1+1)==':') ||
- (varFramePtr == NULL) ||
(!(varFramePtr->isProcCallFrame & FRAME_IS_PROC)
&& (nsPtr == iPtr->globalNsPtr)));
useReference = useGlobal || ((cachedNsPtr == nsPtr) && (
(flags & TCL_NAMESPACE_ONLY) ||
- (varFramePtr &&
- !(varFramePtr->isProcCallFrame & FRAME_IS_PROC) &&
- !(flags & TCL_GLOBAL_ONLY) &&
+ (!(varFramePtr->isProcCallFrame & FRAME_IS_PROC) &&
+ !(flags & TCL_GLOBAL_ONLY) &&
/*
* Careful: an undefined ns variable could be hiding a valid
* global reference.
*/
- !TclIsVarUndefined(varPtr))));
+ !TclIsVarUndefined(varPtr))));
if (useReference && (varPtr->hPtr != NULL)) {
/*
@@ -689,7 +686,7 @@ TclLookupSimpleVar(
varNsPtr = NULL; /* set non-NULL if a nonlocal variable */
*indexPtr = -3;
- if ((flags & TCL_GLOBAL_ONLY) || iPtr->varFramePtr == NULL) {
+ if (flags & TCL_GLOBAL_ONLY) {
cxtNsPtr = iPtr->globalNsPtr;
} else {
cxtNsPtr = iPtr->varFramePtr->nsPtr;
@@ -744,7 +741,6 @@ TclLookupSimpleVar(
*/
if (((flags & (TCL_GLOBAL_ONLY | TCL_NAMESPACE_ONLY)) != 0)
- || (varFramePtr == NULL)
|| !(varFramePtr->isProcCallFrame & FRAME_IS_PROC)
|| (strstr(varName, "::") != NULL)) {
CONST char *tail;
@@ -3214,6 +3210,10 @@ ObjMakeUpvar(
* interpreter in order to use TclObjLookupVar.
*/
+ if (framePtr == NULL) {
+ framePtr = iPtr->rootFramePtr;
+ }
+
varFramePtr = iPtr->varFramePtr;
if (!(otherFlags & TCL_NAMESPACE_ONLY)) {
iPtr->varFramePtr = framePtr;
@@ -3553,8 +3553,7 @@ Tcl_GlobalObjCmd(
* If we are not executing inside a Tcl procedure, just return.
*/
- if ((iPtr->varFramePtr == NULL)
- || !(iPtr->varFramePtr->isProcCallFrame & FRAME_IS_PROC)) {
+ if (!(iPtr->varFramePtr->isProcCallFrame & FRAME_IS_PROC)) {
return TCL_OK;
}
@@ -3705,8 +3704,7 @@ Tcl_VariableObjCmd(
* linked to the new namespace variable "varName".
*/
- if ((iPtr->varFramePtr != NULL)
- && (iPtr->varFramePtr->isProcCallFrame & FRAME_IS_PROC)) {
+ if (iPtr->varFramePtr->isProcCallFrame & FRAME_IS_PROC) {
/*
* varName might have a scope qualifier, but the name for the
* local "link" variable must be the simple name at the tail.