diff options
author | dgp <dgp@users.sourceforge.net> | 2007-08-27 19:56:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-08-27 19:56:50 (GMT) |
commit | 5bddf0fdb52a72eb7ae2b5753c3fcbef906981ce (patch) | |
tree | 7e1f3cc06712ff04517ef7e2c61db6318919c555 /generic/tclCompile.h | |
parent | d807bb087b7c5fdec280d68120900066bb8e05ae (diff) | |
download | tcl-5bddf0fdb52a72eb7ae2b5753c3fcbef906981ce.zip tcl-5bddf0fdb52a72eb7ae2b5753c3fcbef906981ce.tar.gz tcl-5bddf0fdb52a72eb7ae2b5753c3fcbef906981ce.tar.bz2 |
* generic/tclCompExpr.c: Call TclCompileSyntaxError() when
expression syntax errors are found when compiling expressions. With
this in place, convert TclCompileExpr to return void, since there's no
longer any need to report TCL_ERROR.
* generic/tclCompile.c: Update callers.
* generic/tclExecute.c:
* generic/tclCompCmds.c: New routine TclCompileSyntaxError()
* generic/tclCompile.h: to directly compile bytecodes that report a
* generic/tclCompile.c: syntax error, rather than (ab)use a call to
TclCompileReturnCmd. Also, undo the most recent commit that papered
over some issues with that (ab)use. New routine produces a new
opcode INST_SYNTAX, which is a minor variation of INST_RETURN_IMM.
Also a bit of constification.
Diffstat (limited to 'generic/tclCompile.h')
-rw-r--r-- | generic/tclCompile.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/generic/tclCompile.h b/generic/tclCompile.h index bdc190e..0dc8eef 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -8,7 +8,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.h,v 1.75 2007/07/31 17:03:37 msofer Exp $ + * RCS: @(#) $Id: tclCompile.h,v 1.76 2007/08/27 19:56:51 dgp Exp $ */ #ifndef _TCLCOMPILATION @@ -215,7 +215,7 @@ typedef struct CompileEnv { * compiled. Commands and their compile procs * are specific to an interpreter so the code * emitted will depend on the interpreter. */ - char *source; /* The source string being compiled by + const char *source; /* The source string being compiled by * SetByteCodeFromAny. This pointer is not * owned by the CompileEnv and must not be * freed or changed by it. */ @@ -346,7 +346,7 @@ typedef struct ByteCode { unsigned int flags; /* flags describing state for the codebyte. * this variable holds ORed values from the * TCL_BYTECODE_ masks defined above */ - char *source; /* The source string from which this ByteCode + const char *source; /* The source string from which this ByteCode * was compiled. Note that this pointer is not * owned by the ByteCode and must not be freed * or modified by it. */ @@ -626,8 +626,12 @@ typedef struct ByteCode { #define INST_NSUPVAR 123 #define INST_VARIABLE 124 +/* Instruction to support compiling syntax error to bytecode */ + +#define INST_SYNTAX 125 + /* The last opcode */ -#define LAST_INST_OPCODE 124 +#define LAST_INST_OPCODE 125 /* * Table describing the Tcl bytecode instructions: their name (for displaying @@ -834,7 +838,7 @@ MODULE_SCOPE void TclCleanupByteCode(ByteCode *codePtr); MODULE_SCOPE void TclCompileCmdWord(Tcl_Interp *interp, Tcl_Token *tokenPtr, int count, CompileEnv *envPtr); -MODULE_SCOPE int TclCompileExpr(Tcl_Interp *interp, CONST char *script, +MODULE_SCOPE void TclCompileExpr(Tcl_Interp *interp, CONST char *script, int numBytes, CompileEnv *envPtr); MODULE_SCOPE void TclCompileExprWords(Tcl_Interp *interp, Tcl_Token *tokenPtr, int numWords, @@ -842,6 +846,8 @@ MODULE_SCOPE void TclCompileExprWords(Tcl_Interp *interp, MODULE_SCOPE void TclCompileScript(Tcl_Interp *interp, CONST char *script, int numBytes, CompileEnv *envPtr); +MODULE_SCOPE void TclCompileSyntaxError(Tcl_Interp *interp, + CompileEnv *envPtr); MODULE_SCOPE void TclCompileTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr, int count, CompileEnv *envPtr); @@ -879,8 +885,8 @@ MODULE_SCOPE void TclInitByteCodeObj(Tcl_Obj *objPtr, CompileEnv *envPtr); MODULE_SCOPE void TclInitCompilation(void); MODULE_SCOPE void TclInitCompileEnv(Tcl_Interp *interp, - CompileEnv *envPtr, char *string, int numBytes, - CONST CmdFrame* invoker, int word); + CompileEnv *envPtr, const char *string, + int numBytes, CONST CmdFrame* invoker, int word); MODULE_SCOPE void TclInitJumpFixupArray(JumpFixupArray *fixupArrayPtr); MODULE_SCOPE void TclInitLiteralTable(LiteralTable *tablePtr); #ifdef TCL_COMPILE_STATS |