summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmds.c
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2012-10-30 22:16:35 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2012-10-30 22:16:35 (GMT)
commita1ee0c2449ab963c064a63f205719846b4fb8515 (patch)
treeb17e5dfef8dc6c254530aa39fd546732f4a47c41 /generic/tclCompCmds.c
parent137dac970c7203528a2ca4cdf7d305f02d0f60bb (diff)
downloadtcl-a1ee0c2449ab963c064a63f205719846b4fb8515.zip
tcl-a1ee0c2449ab963c064a63f205719846b4fb8515.tar.gz
tcl-a1ee0c2449ab963c064a63f205719846b4fb8515.tar.bz2
Added [dict exists] compilation; implementation is 95% shared with [dict get].
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r--generic/tclCompCmds.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 029606e..068848f 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -787,6 +787,42 @@ TclCompileDictGetCmd(
}
int
+TclCompileDictExistsCmd(
+ Tcl_Interp *interp, /* Used for looking up stuff. */
+ 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. */
+{
+ Tcl_Token *tokenPtr;
+ int numWords, i;
+ DefineLineInformation; /* TIP #280 */
+
+ /*
+ * There must be at least two arguments after the command (the single-arg
+ * case is legal, but too special and magic for us to deal with here).
+ */
+
+ if (parsePtr->numWords < 3) {
+ return TCL_ERROR;
+ }
+ tokenPtr = TokenAfter(parsePtr->tokenPtr);
+ numWords = parsePtr->numWords-1;
+
+ /*
+ * Now we do the code generation.
+ */
+
+ for (i=0 ; i<numWords ; i++) {
+ CompileWord(envPtr, tokenPtr, interp, i);
+ tokenPtr = TokenAfter(tokenPtr);
+ }
+ TclEmitInstInt4(INST_DICT_EXISTS, numWords-1, envPtr);
+ return TCL_OK;
+}
+
+int
TclCompileDictUnsetCmd(
Tcl_Interp *interp, /* Used for looking up stuff. */
Tcl_Parse *parsePtr, /* Points to a parse structure for the command