diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-26 13:13:27 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-26 13:13:27 (GMT) |
commit | 4f20c3d555d869755b8fbe5cf295f4898929c8a3 (patch) | |
tree | 6c8fe78d397d6aa4bde624d40f39d906e66484e6 /generic/tclCompCmdsSZ.c | |
parent | ecb8fcec67eaa9ecc3902b669ad242dd76038562 (diff) | |
download | tcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.zip tcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.tar.gz tcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.tar.bz2 |
Working towards a BCCed [yield]; this doesn't work right now.
Diffstat (limited to 'generic/tclCompCmdsSZ.c')
-rw-r--r-- | generic/tclCompCmdsSZ.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 8ed3a95..d7dd58e 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -2752,6 +2752,49 @@ TclCompileWhileCmd( /* *---------------------------------------------------------------------- * + * TclCompileYieldCmd -- + * + * Procedure called to compile the "yield" command. + * + * Results: + * Returns TCL_OK for a successful compile. Returns TCL_ERROR to defer + * evaluation to runtime. + * + * Side effects: + * Instructions are added to envPtr to execute the "yield" command at + * runtime. + * + *---------------------------------------------------------------------- + */ + +int +TclCompileYieldCmd( + 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. */ +{ + if (parsePtr->numWords < 1 || parsePtr->numWords > 2) { + return TCL_ERROR; + } + + if (parsePtr->numWords == 1) { + PushLiteral(envPtr, "", 0); + } else { + DefineLineInformation; /* TIP #280 */ + Tcl_Token *valueTokenPtr = TokenAfter(parsePtr->tokenPtr); + + CompileWord(envPtr, valueTokenPtr, interp, 1); + } + TclEmitOpcode(INST_YIELD, envPtr); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * * PushVarName -- * * Procedure used in the compiling where pushing a variable name is |