summaryrefslogtreecommitdiffstats
path: root/generic/tclAssembly.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-07-18 20:27:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-07-18 20:27:01 (GMT)
commit06b6a3eb94e2e9cd2c73e08ba68bb234bf6b6d4f (patch)
tree054d9ea09ad9e162f640d47306181917d0f14df2 /generic/tclAssembly.c
parent517197f8571ca5ff1c51b2cadc771505922d9137 (diff)
parentf06af4fe86a953a20b9ef90f5605331707370765 (diff)
downloadtcl-06b6a3eb94e2e9cd2c73e08ba68bb234bf6b6d4f.zip
tcl-06b6a3eb94e2e9cd2c73e08ba68bb234bf6b6d4f.tar.gz
tcl-06b6a3eb94e2e9cd2c73e08ba68bb234bf6b6d4f.tar.bz2
Rewrite of the TclCompileScript() routine.
Primarily this breaks that large, rather convoluted routine into many smaller more single-purpose routines for greater clarity. This also permits more sharing of function components. Ensemble compiles now share the same low level routines as top-level command compiles. This refactoring should also have the benefit of easing merging between branches by better locating patches according to what function or data structure they tweak. Also in this checkin: Minimized calls to Tcl_ResetResult() during compile. Several commands compile their detected syntax errors into bytecode that reports the syntax error. Significant reform to the TIP 280 machinery, including elimination of the litInfo hash table. Its function of finding the index of a compiled command in a script from a pc value has been redone using the codeDelta information already stored in ByteCode.
Diffstat (limited to 'generic/tclAssembly.c')
-rw-r--r--generic/tclAssembly.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 416ee10..9b9b6f8 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -930,6 +930,12 @@ TclCompileAssembleCmd(
{
Tcl_Token *tokenPtr; /* Token in the input script */
+#if 1
+ int numCommands = envPtr->numCommands;
+ int offset = envPtr->codeNext - envPtr->codeStart;
+ int depth = envPtr->currStackDepth;
+#endif
+
/*
* Make sure that the command has a single arg that is a simple word.
*/
@@ -943,10 +949,28 @@ TclCompileAssembleCmd(
}
/*
- * Compile the code and return any error from the compilation.
+ * Compile the code and convert any error from the compilation into
+ * bytecode reporting the error;
*/
- return TclAssembleCode(envPtr, tokenPtr[1].start, tokenPtr[1].size, 0);
+ if (TCL_ERROR == TclAssembleCode(envPtr, tokenPtr[1].start,
+ tokenPtr[1].size, TCL_EVAL_DIRECT)) {
+
+#if 1
+ Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
+ "\n (\"%.*s\" body, line %d)",
+ parsePtr->tokenPtr->size, parsePtr->tokenPtr->start,
+ Tcl_GetErrorLine(interp)));
+ envPtr->numCommands = numCommands;
+ envPtr->codeNext = envPtr->codeStart + offset;
+ envPtr->currStackDepth = depth;
+ TclCompileSyntaxError(interp, envPtr);
+#else
+ Tcl_ResetResult(interp);
+ return TCL_ERROR;
+#endif
+ }
+ return TCL_OK;
}
/*
@@ -1108,7 +1132,7 @@ NewAssemblyEnv(
assemEnvPtr->envPtr = envPtr;
assemEnvPtr->parsePtr = parsePtr;
- assemEnvPtr->cmdLine = envPtr->line;
+ assemEnvPtr->cmdLine = 1;
assemEnvPtr->clNext = envPtr->clNext;
/*