summaryrefslogtreecommitdiffstats
path: root/generic/tclAssembly.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclAssembly.c')
-rw-r--r--generic/tclAssembly.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 5786975..6701acf 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -234,6 +234,8 @@ typedef struct AssemblyEnv {
static void AddBasicBlockRangeToErrorInfo(AssemblyEnv*,
BasicBlock*);
+static void AdvanceLines(int *line, const char *start,
+ const char *end);
static BasicBlock * AllocBB(AssemblyEnv*);
static int AssembleOneLine(AssemblyEnv* envPtr);
static void BBAdjustStackDepth(BasicBlock* bbPtr, int consumed,
@@ -323,22 +325,6 @@ static const Tcl_ObjType assembleCodeType = {
NULL /* setFromAnyProc */
};
-/*
- * TIP #280: Remember the per-word line information of the current command. An
- * index is used instead of a pointer as recursive compilation may reallocate,
- * i.e. move, the array. This is also the reason to save the nuloc now, it may
- * change during the course of the function.
- *
- * Macro to encapsulate the variable definition and setup.
- */
-
-#define DefineLineInformation \
- ExtCmdLoc *mapPtr = envPtr->extCmdMapPtr; \
- int eclIndex = mapPtr->nuloc - 1
-
-#define SetLineInformation(word) \
- envPtr->line = mapPtr->loc[eclIndex].line[(word)]; \
- envPtr->clNext = mapPtr->loc[eclIndex].next[(word)]
/*
* Flags bits used by PushVarName.
@@ -527,6 +513,21 @@ static const unsigned char NonThrowingByteCodes[] = {
INST_INFO_LEVEL_NUM, /* 152 */
INST_RESOLVE_COMMAND /* 154 */
};
+
+static void
+AdvanceLines(
+ int *line,
+ const char *start,
+ const char *end)
+{
+ register const char *p;
+
+ for (p = start; p < end; p++) {
+ if (*p == '\n') {
+ (*line)++;
+ }
+ }
+}
/*
* Helper macros.
@@ -870,17 +871,14 @@ CompileAssembleObj(
FreeAssembleCodeInternalRep(objPtr);
}
- /*
- * Set up the compilation environment, and assemble the code.
- */
+ /* Set up the compilation environment, and assemble the code */
source = TclGetStringFromObj(objPtr, &sourceLen);
- TclInitCompileEnv(interp, &compEnv, source, sourceLen, NULL, 0);
+ TclInitCompileEnv(interp, &compEnv, source, sourceLen);
status = TclAssembleCode(&compEnv, source, sourceLen, TCL_EVAL_DIRECT);
if (status != TCL_OK) {
- /*
- * Assembly failed. Clean up and report the error.
- */
+
+ /* Assembly failed. Clean up and report the error */
TclFreeCompileEnv(&compEnv);
return NULL;
}
@@ -1045,10 +1043,8 @@ TclAssembleCode(
* Advance the pointers around any leading commentary.
*/
- TclAdvanceLines(&assemEnvPtr->cmdLine, instPtr,
+ AdvanceLines(&assemEnvPtr->cmdLine, instPtr,
parsePtr->commandStart);
- TclAdvanceContinuations(&assemEnvPtr->cmdLine, &assemEnvPtr->clNext,
- parsePtr->commandStart - envPtr->source);
/*
* Process the line of code.
@@ -1086,10 +1082,8 @@ TclAssembleCode(
nextPtr = parsePtr->commandStart + parsePtr->commandSize;
bytesLeft -= (nextPtr - instPtr);
instPtr = nextPtr;
- TclAdvanceLines(&assemEnvPtr->cmdLine, parsePtr->commandStart,
+ AdvanceLines(&assemEnvPtr->cmdLine, parsePtr->commandStart,
instPtr);
- TclAdvanceContinuations(&assemEnvPtr->cmdLine, &assemEnvPtr->clNext,
- instPtr - envPtr->source);
Tcl_FreeParse(parsePtr);
} while (bytesLeft > 0);
@@ -1130,8 +1124,7 @@ NewAssemblyEnv(
assemEnvPtr->envPtr = envPtr;
assemEnvPtr->parsePtr = parsePtr;
- assemEnvPtr->cmdLine = envPtr->line;
- assemEnvPtr->clNext = envPtr->clNext;
+ assemEnvPtr->cmdLine = 1;
/*
* Make the hashtables that store symbol resolution.