summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-08-10 05:16:38 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-08-10 05:16:38 (GMT)
commitde857ca207e4dceea586bf2dbfe497df4d9d02c8 (patch)
tree8047783a9771beff85554397a4263d1d93acde9b /generic/tclCmdIL.c
parentfec32bb50c597bfbb21ad55211339355034f6d55 (diff)
downloadtcl-de857ca207e4dceea586bf2dbfe497df4d9d02c8.zip
tcl-de857ca207e4dceea586bf2dbfe497df4d9d02c8.tar.gz
tcl-de857ca207e4dceea586bf2dbfe497df4d9d02c8.tar.bz2
Arrange for both execution traces and [info frame] to get their pre-subst
source strings from a common routine, with care taken to reduce copying by that routine.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 180d814..da9edd6 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -1266,6 +1266,25 @@ InfoFrameCmd(
*/
Tcl_Obj *
+TclGetSourceFromFrame(
+ CmdFrame *cfPtr,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ if (cfPtr == NULL) {
+ return Tcl_NewListObj(objc, objv);
+ }
+ if (cfPtr->cmdObj == NULL) {
+ if (cfPtr->cmd == NULL) {
+ cfPtr->cmd = TclGetSrcInfoForCmdFrame(cfPtr, &cfPtr->len);
+ }
+ cfPtr->cmdObj = Tcl_NewStringObj(cfPtr->cmd, cfPtr->len);
+ Tcl_IncrRefCount(cfPtr->cmdObj);
+ }
+ return cfPtr->cmdObj;
+}
+
+Tcl_Obj *
TclInfoFrame(
Tcl_Interp *interp, /* Current interpreter. */
CmdFrame *framePtr) /* Frame to get info for. */
@@ -1307,7 +1326,7 @@ TclInfoFrame(
} else {
ADD_PAIR("line", Tcl_NewIntObj(1));
}
- ADD_PAIR("cmd", Tcl_NewStringObj(framePtr->cmd, framePtr->len));
+ ADD_PAIR("cmd", TclGetSourceFromFrame(framePtr, 0, NULL));
break;
case TCL_LOCATION_PREBC:
@@ -1355,7 +1374,7 @@ TclInfoFrame(
Tcl_DecrRefCount(fPtr->data.eval.path);
}
- ADD_PAIR("cmd", Tcl_NewStringObj(fPtr->cmd, fPtr->len));
+ ADD_PAIR("cmd", TclGetSourceFromFrame(fPtr, 0, NULL));
TclStackFree(interp, fPtr);
break;
}
@@ -1374,7 +1393,7 @@ TclInfoFrame(
* the result list object.
*/
- ADD_PAIR("cmd", Tcl_NewStringObj(framePtr->cmd, framePtr->len));
+ ADD_PAIR("cmd", TclGetSourceFromFrame(framePtr, 0, NULL));
break;
case TCL_LOCATION_PROC: