diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2006-10-23 22:49:24 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2006-10-23 22:49:24 (GMT) |
commit | 94919dd9c565db95ae21cf14b91f8cdeb2446b46 (patch) | |
tree | 5b48faeb4f251c92945b7f4621754d51b85e3817 /generic | |
parent | ff4058f01143ad058843bf7e6f0a0ff599a4ac50 (diff) | |
download | tcl-94919dd9c565db95ae21cf14b91f8cdeb2446b46.zip tcl-94919dd9c565db95ae21cf14b91f8cdeb2446b46.tar.gz tcl-94919dd9c565db95ae21cf14b91f8cdeb2446b46.tar.bz2 |
* library/clock.tcl (format, scan): corrected wrong # args
* tests/clock.test (3.1, 34.1): messages to make use of the
new rewrite capabilities of [info level]
* generic/tcl.h: Lets TEOV update the iPtr->objc/objv
* generic/tclBasic.c: fields, except when the (new) flag bit
* generic/tclInt.h: TCL_EVAL_NOREWRITE is present. This
* generic/tclNamesp.c: causes [info level] to know and use
* generic/tclProc.c: ensemble rewrites [Bug 1577492]
* tests/namespace.test:
***POTENTIAL INCOMPATIBILITY***
The return value from [info level 0] on interp alias calls is
changed: previously returned the target command (including curried
values), now returns the source - what was actually called.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tcl.h | 5 | ||||
-rw-r--r-- | generic/tclBasic.c | 14 | ||||
-rw-r--r-- | generic/tclInt.h | 14 | ||||
-rw-r--r-- | generic/tclNamesp.c | 24 | ||||
-rw-r--r-- | generic/tclProc.c | 5 |
5 files changed, 43 insertions, 19 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 2522fa2..8e309a2 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -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: tcl.h,v 1.223 2006/10/23 21:36:54 msofer Exp $ + * RCS: @(#) $Id: tcl.h,v 1.224 2006/10/23 22:49:24 msofer Exp $ */ #ifndef _TCL @@ -1066,11 +1066,14 @@ typedef struct Tcl_DString { * o Cut out of error traces * o Don't reset the flags controlling ensemble * error message rewriting. + * TCL_EVAL_NOREWRITE Do not update the interp's last call info; + * used by the ensemble rewrite machinery */ #define TCL_NO_EVAL 0x10000 #define TCL_EVAL_GLOBAL 0x20000 #define TCL_EVAL_DIRECT 0x40000 #define TCL_EVAL_INVOKE 0x80000 +#define TCL_EVAL_NOREWRITE 0x100000 /* * Special freeProc values that may be passed to Tcl_SetResult (see the man diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 5bccd2e..a633a85 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.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: tclBasic.c,v 1.201 2006/10/23 21:36:54 msofer Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.202 2006/10/23 22:49:24 msofer Exp $ */ #include "tclInt.h" @@ -362,6 +362,8 @@ Tcl_CreateInterp(void) if (iPtr->globalNsPtr == NULL) { Tcl_Panic("Tcl_CreateInterp: can't create global namespace"); } + iPtr->callObjc = 0; + iPtr->callObjv = NULL; /* * Initialise the rootCallframe. It cannot be allocated on the stack, as @@ -3301,6 +3303,16 @@ TclEvalObjvInternal( } } + + /* + * Record the calling objc/objv except if requested not to + */ + + if (!(flags & TCL_EVAL_NOREWRITE)) { + iPtr->callObjc = objc; + iPtr->callObjv = objv; + } + /* * Find the function to execute this command. If there isn't one, then see * if there is an unknown command handler registered for this namespace. diff --git a/generic/tclInt.h b/generic/tclInt.h index fffcffe..6a06fb0 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.282 2006/10/23 21:36:55 msofer Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.283 2006/10/23 22:49:25 msofer Exp $ */ #ifndef _TCLINT @@ -1529,8 +1529,16 @@ typedef struct Interp { * i.e the package require preferences. */ - int packagePrefer; /* Current package selection mode. - */ + int packagePrefer; /* Current package selection mode. */ + + /* + * Let [info level] know about ensemble rewriting + */ + + int callObjc; + Tcl_Obj *CONST *callObjv; + + /* * Statistical information about the bytecode compiler and interpreter's * operation. diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index b360211..a2a1632 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -22,7 +22,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclNamesp.c,v 1.104 2006/10/23 21:36:55 msofer Exp $ + * RCS: @(#) $Id: tclNamesp.c,v 1.105 2006/10/23 22:49:25 msofer Exp $ */ #include "tclInt.h" @@ -425,8 +425,8 @@ Tcl_PushCallFrame( nsPtr->activationCount++; framePtr->nsPtr = nsPtr; framePtr->isProcCallFrame = isProcCallFrame; - framePtr->objc = 0; - framePtr->objv = NULL; + framePtr->objc = iPtr->callObjc; + framePtr->objv = iPtr->callObjv; framePtr->callerPtr = iPtr->framePtr; framePtr->callerVarPtr = iPtr->varFramePtr; if (iPtr->varFramePtr != NULL) { @@ -3433,9 +3433,6 @@ NamespaceEvalCmd( if (result != TCL_OK) { return TCL_ERROR; } - framePtr->objc = objc; - framePtr->objv = objv; /* Reference counts do not need to be - * incremented here. */ if (objc == 4) { result = Tcl_EvalObjEx(interp, objv[3], 0); @@ -3834,8 +3831,6 @@ NamespaceInscopeCmd( if (result != TCL_OK) { return result; } - framePtr->objc = objc; - framePtr->objv = objv; /* * Execute the command. If there is just one argument, just treat it as a @@ -6281,7 +6276,7 @@ NsEnsembleImplementationCmd( memcpy(tempObjv, prefixObjv, sizeof(Tcl_Obj *) * prefixObjc); memcpy(tempObjv+prefixObjc, objv+2, sizeof(Tcl_Obj *) * (objc-2)); result = Tcl_EvalObjv(interp, objc-2+prefixObjc, tempObjv, - TCL_EVAL_INVOKE); + TCL_EVAL_INVOKE|TCL_EVAL_NOREWRITE); Tcl_DecrRefCount(prefixObj); ckfree((char *) tempObjv); if (isRootEnsemble) { @@ -6301,10 +6296,11 @@ NsEnsembleImplementationCmd( */ if (ensemblePtr->unknownHandler != NULL && reparseCount++ < 1) { + Interp *iPtr = (Interp *) interp; int paramc, i; Tcl_Obj **paramv, *unknownCmd, *ensObj; - unknownCmd = Tcl_DuplicateObj(ensemblePtr->unknownHandler); + unknownCmd = Tcl_NewListObj(1, &ensemblePtr->unknownHandler); TclNewObj(ensObj); Tcl_GetCommandFullName(interp, ensemblePtr->token, ensObj); Tcl_ListObjAppendElement(NULL, unknownCmd, ensObj); @@ -6346,6 +6342,14 @@ NsEnsembleImplementationCmd( } /* + * Restore the interp's call data, which may have been wiped out + * while processing the unknown handler. + */ + + iPtr->callObjc = objc; + iPtr->callObjv = objv; + + /* * Namespace alive & empty result => reparse. */ diff --git a/generic/tclProc.c b/generic/tclProc.c index e6a70ab..b0df000 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.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: tclProc.c,v 1.96 2006/10/23 21:36:55 msofer Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.97 2006/10/23 22:49:25 msofer Exp $ */ #include "tclInt.h" @@ -1198,9 +1198,6 @@ ObjInterpProcEx( return result; } - - framePtr->objc = objc; - framePtr->objv = objv; /* ref counts for args are incremented below */ framePtr->procPtr = procPtr; /* |