diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2011-03-09 14:06:53 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2011-03-09 14:06:53 (GMT) |
commit | 1111254200cc2b8bc8aa2d899f43d56884f1f1cb (patch) | |
tree | 321682fffd0f114d52e16ad5231ed933e40ad10e /generic/tclCompCmds.c | |
parent | 47412dd55bfb480602e28ca7d73b0aef74b622cb (diff) | |
download | tcl-1111254200cc2b8bc8aa2d899f43d56884f1f1cb.zip tcl-1111254200cc2b8bc8aa2d899f43d56884f1f1cb.tar.gz tcl-1111254200cc2b8bc8aa2d899f43d56884f1f1cb.tar.bz2 |
Turn namespace into an ensemble. Not yet on trunk because of some mysterious failures that need resolving...
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index c4d88a0..83e99aa 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -3211,7 +3211,8 @@ TclCompileLsetCmd( * TclCompileNamespaceCmd -- * * Procedure called to compile the "namespace" command; currently, only - * the subcommand "namespace upvar" is compiled to bytecodes. + * the subcommand "namespace upvar" is compiled to bytecodes, and then + * only inside a procedure(-like) context. * * Results: * Returns TCL_OK for a successful compile. Returns TCL_ERROR to defer @@ -3225,7 +3226,7 @@ TclCompileLsetCmd( */ int -TclCompileNamespaceCmd( +TclCompileNamespaceUpvarCmd( Tcl_Interp *interp, /* Used for error reporting. */ Tcl_Parse *parsePtr, /* Points to a parse structure for the command * created by Tcl_ParseCommand. */ @@ -3242,21 +3243,11 @@ TclCompileNamespaceCmd( } /* - * Only compile [namespace upvar ...]: needs an odd number of args, >=5 + * Only compile [namespace upvar ...]: needs an even number of args, >=4 */ numWords = parsePtr->numWords; - if (!(numWords%2) || (numWords < 5)) { - return TCL_ERROR; - } - - /* - * Check if the second argument is "upvar" - */ - - tokenPtr = TokenAfter(parsePtr->tokenPtr); - if ((tokenPtr->size != 5) /* 5 == strlen("upvar") */ - || strncmp(tokenPtr->start, "upvar", 5)) { + if ((numWords % 2) || (numWords < 4)) { return TCL_ERROR; } @@ -3264,7 +3255,7 @@ TclCompileNamespaceCmd( * Push the namespace */ - tokenPtr = TokenAfter(tokenPtr); + tokenPtr = TokenAfter(parsePtr->tokenPtr); CompileWord(envPtr, tokenPtr, interp, 1); /* @@ -3274,7 +3265,7 @@ TclCompileNamespaceCmd( */ localTokenPtr = tokenPtr; - for (i=4; i<=numWords; i+=2) { + for (i=3; i<=numWords; i+=2) { otherTokenPtr = TokenAfter(localTokenPtr); localTokenPtr = TokenAfter(otherTokenPtr); |