diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-05-05 23:33:11 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-05-05 23:33:11 (GMT) |
commit | 29cf1d7bf639866e48ef946d326a229a9514f492 (patch) | |
tree | 1d78768bab303fef7c4c0ad56f5d8d65f3841216 /generic/tclProc.c | |
parent | e3a939a3c254481c00ee564e3e5bb4306ddeb7bf (diff) | |
download | tcl-29cf1d7bf639866e48ef946d326a229a9514f492.zip tcl-29cf1d7bf639866e48ef946d326a229a9514f492.tar.gz tcl-29cf1d7bf639866e48ef946d326a229a9514f492.tar.bz2 |
Changes to allow the tip257 code to work as an extension properly post-tip280
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r-- | generic/tclProc.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index c87da49..4f75d14 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.113 2007/04/30 19:46:03 kennykb Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.114 2007/05/05 23:33:19 dkf Exp $ */ #include "tclInt.h" @@ -2264,39 +2264,40 @@ SetLambdaFromAny( if (context.type == TCL_LOCATION_BC) { /* - * Retrieve the source context from the bytecode. This - * call accounts for the reference to the source file, - * if any, held in 'context.data.eval.path'. + * Retrieve the source context from the bytecode. This call + * accounts for the reference to the source file, if any, held in + * 'context.data.eval.path'. */ + TclGetSrcInfoForPc(&context); } else if (context.type == TCL_LOCATION_SOURCE) { /* - * We created a new reference to the source file path - * name when we created 'context' above. Account for the reference. + * We created a new reference to the source file path name when we + * created 'context' above. Account for the reference. */ + Tcl_IncrRefCount(context.data.eval.path); } if (context.type == TCL_LOCATION_SOURCE) { - /* - * We can record source location within a lambda - * only if the body was not created by substitution. + * We can record source location within a lambda only if the body + * was not created by substitution. */ if (context.line - && (context.nline >= 2) && (context.line[1] >= 0)) { + && (context.nline >= 2) && (context.line[1] >= 0)) { int isNew, buf[2]; CmdFrame *cfPtr = (CmdFrame *) ckalloc(sizeof(CmdFrame)); - + /* * Move from approximation (line of list cmd word) to actual * location (line of 2nd list element). */ - + TclListLines(name, context.line[1], 2, buf); - + cfPtr->level = -1; cfPtr->type = context.type; cfPtr->line = (int *) ckalloc(sizeof(int)); @@ -2304,20 +2305,19 @@ SetLambdaFromAny( cfPtr->nline = 1; cfPtr->framePtr = NULL; cfPtr->nextPtr = NULL; - + cfPtr->data.eval.path = context.data.eval.path; Tcl_IncrRefCount(cfPtr->data.eval.path); cfPtr->cmd.str.cmd = NULL; cfPtr->cmd.str.len = 0; - + Tcl_SetHashValue(Tcl_CreateHashEntry(iPtr->linePBodyPtr, - (char *) procPtr, &isNew), - cfPtr); + (char *) procPtr, &isNew), cfPtr); } - /* - * 'context' is going out of scope. Release the reference that + /* + * 'context' is going out of scope. Release the reference that * it's holding to the source file path */ @@ -2390,6 +2390,7 @@ Tcl_ApplyObjCmd( Command cmd; Tcl_Namespace *nsPtr; int isRootEnsemble; + ExtraFrameInfo efi; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "lambdaExpr ?arg1 arg2 ...?"); @@ -2437,15 +2438,20 @@ Tcl_ApplyObjCmd( procPtr->cmdPtr = &cmd; /* - * TIP#280 HACK! + * TIP#280 (semi-)HACK! * - * Using cmd.clientData to remember the 'lambdaPtr' for 'info frame'. The - * InfoFrameCmd will detect this case by testing cmd.hPtr for NULL. This - * condition holds here because of the 'memset' above, and nowhere else. - * Regular commands always have a valid 'hPtr', and lambda's never. + * Using cmd.clientData to tell [info frame] how to render the + * 'lambdaPtr'. The InfoFrameCmd will detect this case by testing cmd.hPtr + * for NULL. This condition holds here because of the 'memset' above, and + * nowhere else (in the core). Regular commands always have a valid + * 'hPtr', and lambda's never. */ - cmd.clientData = (ClientData) lambdaPtr; + efi.length = 1; + efi.fields[0].name = "lambda"; + efi.fields[0].proc = NULL; + efi.fields[0].clientData = lambdaPtr; + cmd.clientData = &efi; /* * Find the namespace where this lambda should run, and push a call frame |