summaryrefslogtreecommitdiffstats
path: root/generic/tclEnsemble.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-07-17 13:57:23 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-07-17 13:57:23 (GMT)
commitc2d6c48dd921e7120d626f1a85977ae130dd109e (patch)
treefaf878da5bac9463e56a9537afeb4aaa54b84309 /generic/tclEnsemble.c
parentd383707870a66078dd83c9532e7dbcb1002e62ba (diff)
downloadtcl-c2d6c48dd921e7120d626f1a85977ae130dd109e.zip
tcl-c2d6c48dd921e7120d626f1a85977ae130dd109e.tar.gz
tcl-c2d6c48dd921e7120d626f1a85977ae130dd109e.tar.bz2
Factor out the call to a compileProc into one place used by both ensemble
subcommand compiles and toplevel command compiles in TclCompileScript.
Diffstat (limited to 'generic/tclEnsemble.c')
-rw-r--r--generic/tclEnsemble.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index e4f96c0..bab63c9 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -35,9 +35,6 @@ static void MakeCachedEnsembleCommand(Tcl_Obj *objPtr,
static void FreeEnsembleCmdRep(Tcl_Obj *objPtr);
static void DupEnsembleCmdRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr);
static void StringOfEnsembleCmdRep(Tcl_Obj *objPtr);
-static int CompileToCompiledCommand(Tcl_Interp *interp,
- Tcl_Parse *parsePtr, int depth, Command *cmdPtr,
- CompileEnv *envPtr);
static void CompileToInvokedCommand(Tcl_Interp *interp,
Tcl_Parse *parsePtr, Tcl_Obj *replacements,
Command *cmdPtr, CompileEnv *envPtr);
@@ -2994,8 +2991,8 @@ TclCompileEnsemble(
*/
invokeAnyway = 1;
- if (CompileToCompiledCommand(interp, parsePtr, depth, cmdPtr,
- envPtr) == TCL_OK) {
+ if (TCL_OK == TclAttemptCompileProc(interp, parsePtr, depth, cmdPtr,
+ envPtr)) {
ourResult = TCL_OK;
goto cleanup;
}
@@ -3029,8 +3026,8 @@ TclCompileEnsemble(
return ourResult;
}
-static int
-CompileToCompiledCommand(
+int
+TclAttemptCompileProc(
Tcl_Interp *interp,
Tcl_Parse *parsePtr,
int depth,
@@ -3092,6 +3089,23 @@ CompileToCompiledCommand(
if (result != TCL_OK) {
envPtr->currStackDepth = savedStackDepth;
envPtr->codeNext = envPtr->codeStart + savedCodeNext;
+#ifdef TCL_COMPILE_DEBUG
+ } else {
+ /*
+ * Confirm that the command compiler generated a single value on
+ * the stack as its result. This is only done in debugging mode,
+ * as it *should* be correct and normal users have no reasonable
+ * way to fix it anyway.
+ */
+
+ int diff = envPtr->currStackDepth - savedStackDepth;
+
+ if (diff != 1) {
+ Tcl_Panic("bad stack adjustment when compiling"
+ " %.*s (was %d instead of 1)", parsePtr->tokenPtr->size,
+ parsePtr->tokenPtr->start, diff);
+ }
+#endif
}
return result;