diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-19 14:17:18 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-19 14:17:18 (GMT) |
commit | a584e5f052e71147186d2607dfc67e1e8c7e19c3 (patch) | |
tree | 9acfedf6c37e529d4f62831e62de906fb972fb6f /generic/tclExecute.c | |
parent | 54e225f3822c411dcc47823a5b01e22e2ce24f47 (diff) | |
download | tcl-a584e5f052e71147186d2607dfc67e1e8c7e19c3.zip tcl-a584e5f052e71147186d2607dfc67e1e8c7e19c3.tar.gz tcl-a584e5f052e71147186d2607dfc67e1e8c7e19c3.tar.bz2 |
yet another small introspector: [self]
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 1041f65..0ec16e9 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -17,6 +17,7 @@ #include "tclInt.h" #include "tclCompile.h" +#include "tclOOInt.h" #include "tommath.h" #include <math.h> @@ -4106,6 +4107,29 @@ TEBCresume( TRACE_APPEND(("%.30s\n", O2S(objResultPtr))); NEXT_INST_F(1, 1, 1); } + case INST_TCLOO_SELF: { + CallFrame *framePtr = iPtr->varFramePtr; + CallContext *contextPtr; + + if (framePtr == NULL || + !(framePtr->isProcCallFrame & FRAME_IS_METHOD)) { + TRACE(("=> ERROR: no TclOO call context\n")); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "self may only be called from inside a method", + -1)); + Tcl_SetErrorCode(interp, "TCL", "OO", "CONTEXT_REQUIRED", NULL); + goto gotError; + } + contextPtr = framePtr->clientData; + + /* + * Call out to get the name; it's expensive to compute but cached. + */ + + objResultPtr = TclOOObjectName(interp, contextPtr->oPtr); + TRACE_WITH_OBJ(("=> "), objResultPtr); + NEXT_INST_F(1, 0, 1); + } /* * ----------------------------------------------------------------- |