summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-10-19 14:17:18 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-10-19 14:17:18 (GMT)
commit72693da145d4b3a7f165eb5cdff0bd0defb87993 (patch)
tree9acfedf6c37e529d4f62831e62de906fb972fb6f /generic/tclExecute.c
parent8f82c0e9f68bc243d27e129a7163a122e5cf254b (diff)
downloadtcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.zip
tcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.tar.gz
tcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.tar.bz2
yet another small introspector: [self]
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c24
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);
+ }
/*
* -----------------------------------------------------------------