diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-30 22:16:35 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-30 22:16:35 (GMT) |
commit | aafa72469da7da2db317ded2198ef6cfa52b50fa (patch) | |
tree | b17e5dfef8dc6c254530aa39fd546732f4a47c41 /generic/tclCompCmds.c | |
parent | 7a5c743e0954c68b53eba4f1425743f83f83fc45 (diff) | |
download | tcl-aafa72469da7da2db317ded2198ef6cfa52b50fa.zip tcl-aafa72469da7da2db317ded2198ef6cfa52b50fa.tar.gz tcl-aafa72469da7da2db317ded2198ef6cfa52b50fa.tar.bz2 |
Added [dict exists] compilation; implementation is 95% shared with [dict get].
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 36 |
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 |