summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-08-27 19:56:50 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-08-27 19:56:50 (GMT)
commit5bddf0fdb52a72eb7ae2b5753c3fcbef906981ce (patch)
tree7e1f3cc06712ff04517ef7e2c61db6318919c555 /generic/tclCompExpr.c
parentd807bb087b7c5fdec280d68120900066bb8e05ae (diff)
downloadtcl-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/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 0d8a72e..cc31754 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.82 2007/08/27 15:12:38 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.83 2007/08/27 19:56:51 dgp Exp $
*/
#include "tclInt.h"
@@ -2014,9 +2014,7 @@ ParseLexeme(
*----------------------------------------------------------------------
*/
-/* TODO: Convert this to return void. Generate error throwing bytecode
- * for syntax errors instead of failing to compile. */
-int
+void
TclCompileExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *script, /* The source script to compile. */
@@ -2048,6 +2046,8 @@ TclCompileExpr(
Tcl_ListObjGetElements(NULL, funcList, &objc, &funcObjv);
CompileExprTree(interp, opTree, 0, &litObjv, funcObjv,
parsePtr->tokenPtr, envPtr, 1 /* optimize */);
+ } else {
+ TclCompileSyntaxError(interp, envPtr);
}
Tcl_FreeParse(parsePtr);
@@ -2055,7 +2055,6 @@ TclCompileExpr(
Tcl_DecrRefCount(funcList);
Tcl_DecrRefCount(litList);
ckfree((char *) opTree);
- return code;
}
/*
@@ -2350,24 +2349,7 @@ CompileExprTree(
TclEmitPush(TclAddLiteralObj(envPtr,
Tcl_GetObjResult(interp), NULL), envPtr);
} else {
- char *cmd;
- int length;
- Tcl_Obj *returnCmd;
- Tcl_Parse *parsePtr = (Tcl_Parse *)
- TclStackAlloc(interp, sizeof(Tcl_Parse));
-
- TclNewLiteralStringObj(returnCmd, "return ");
- Tcl_IncrRefCount(returnCmd);
- Tcl_AppendObjToObj(returnCmd,
- Tcl_GetReturnOptions(interp, TCL_ERROR));
- Tcl_ListObjAppendElement(NULL, returnCmd,
- Tcl_GetObjResult(interp));
- cmd = Tcl_GetStringFromObj(returnCmd, &length);
- Tcl_ParseCommand(interp, cmd, length, 0, parsePtr);
- TclCompileReturnCmd(interp, parsePtr, envPtr);
- Tcl_DecrRefCount(returnCmd);
- Tcl_FreeParse(parsePtr);
- TclStackFree(interp, parsePtr);
+ TclCompileSyntaxError(interp, envPtr);
}
Tcl_RestoreInterpState(interp, save);
convert = 0;