diff options
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r-- | generic/tclCompile.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 2be8b05..ddaee64 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompile.c,v 1.97 2006/08/29 06:28:38 das Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.98 2006/09/30 17:56:46 msofer Exp $ */ #include "tclInt.h" @@ -1636,6 +1636,51 @@ TclCompileExprWords( /* *---------------------------------------------------------------------- * + * TclCompileNoOp -- + * + * Function called to compile no-op's + * + * Results: + * The return value is TCL_OK, indicating successful compilation. + * + * Side effects: + * Instructions are added to envPtr to execute a no-op at runtime. No + * result is pushed onto the stack: the compiler has to take care of this + * itself if the last compiled command is a NoOp. + * + *---------------------------------------------------------------------- + */ + +int +TclCompileNoOp( + Tcl_Interp *interp, /* Used for error reporting. */ + Tcl_Parse *parsePtr, /* Points to a parse structure for the command + * created by Tcl_ParseCommand. */ + CompileEnv *envPtr) /* Holds resulting instructions. */ +{ + Tcl_Token *tokenPtr; + int i; + int savedStackDepth = envPtr->currStackDepth; + + tokenPtr = parsePtr->tokenPtr; + for(i = 1; i < parsePtr->numWords; i++) { + tokenPtr = tokenPtr + tokenPtr->numComponents + 1; + envPtr->currStackDepth = savedStackDepth; + + if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { + TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, + envPtr); + TclEmitOpcode(INST_POP, envPtr); + } + } + envPtr->currStackDepth = savedStackDepth; + TclEmitPush(TclRegisterNewLiteral(envPtr, "", 0), envPtr); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * * TclInitByteCodeObj -- * * Create a ByteCode structure and initialize it from a CompileEnv |