summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmds.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/tclCompCmds.c
parent8f82c0e9f68bc243d27e129a7163a122e5cf254b (diff)
downloadtcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.zip
tcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.tar.gz
tcl-72693da145d4b3a7f165eb5cdff0bd0defb87993.tar.bz2
yet another small introspector: [self]
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r--generic/tclCompCmds.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 64417c5..3f916a6 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -4687,6 +4687,40 @@ IndexTailVarIfKnown(
return localIndex;
}
+int
+TclCompileObjectSelfCmd(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Parse *parsePtr, /* Points to a parse structure for the command
+ * created by Tcl_ParseCommand. */
+ Command *cmdPtr, /* Points to defintion of command being
+ * compiled. */
+ CompileEnv *envPtr) /* Holds resulting instructions. */
+{
+ /*
+ * We only handle [self] and [self object] (which is the same operation).
+ * These are the only very common operations on [self] for which
+ * bytecoding is at all reasonable.
+ */
+
+ if (parsePtr->numWords > 2) {
+ return TCL_ERROR;
+ } else if (parsePtr->numWords == 2) {
+ Tcl_Token *tokenPtr = TokenAfter(parsePtr->tokenPtr);
+
+ if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD || tokenPtr[1].size==0 ||
+ strncmp(tokenPtr[1].start, "object", tokenPtr[1].size) != 0) {
+ return TCL_ERROR;
+ }
+ }
+
+ /*
+ * This delegates the entire problem to a single opcode.
+ */
+
+ TclEmitOpcode( INST_TCLOO_SELF, envPtr);
+ return TCL_OK;
+}
+
/*
*----------------------------------------------------------------------
*