|
@@ -470,11 +470,11 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
|
|
|
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
|
|
|
"%s(", thisFunctionName);
|
|
|
}
|
|
|
- for (i = 0; i < wantedArgc; i++)
|
|
|
+ for(i = 0; i < wantedArgc; i++)
|
|
|
{
|
|
|
- dStrcat(traceBuffer, argv[i + 1]);
|
|
|
- if (i != wantedArgc - 1)
|
|
|
- dStrcat(traceBuffer, ", ");
|
|
|
+ dStrcat(traceBuffer, argv[i+1]);
|
|
|
+ if(i != wantedArgc - 1)
|
|
|
+ dStrcat(traceBuffer, ", ");
|
|
|
}
|
|
|
dStrcat(traceBuffer, ")");
|
|
|
Con::printf("%s", traceBuffer);
|
|
@@ -533,9 +533,16 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Reset the console stack frame which at this point will contain
|
|
|
- // either nothing or argv[] which we just copied
|
|
|
- CSTK.resetFrame();
|
|
|
+ bool doResetValueStack = !gEvalState.mResetLocked;
|
|
|
+ gEvalState.mResetLocked = true;
|
|
|
+
|
|
|
+ if (gEvalState.mShouldReset)
|
|
|
+ {
|
|
|
+ // Ensure all stacks are clean in case anything became unbalanced during the previous execution
|
|
|
+ STR.clearFrames();
|
|
|
+ CSTK.clearFrames();
|
|
|
+ gEvalState.mShouldReset = false;
|
|
|
+ }
|
|
|
|
|
|
// Grab the state of the telenet debugger here once
|
|
|
// so that the push and pop frames are always balanced.
|
|
@@ -1817,7 +1824,7 @@ breakContinue:
|
|
|
ConsoleValueRef ret;
|
|
|
if(nsEntry->mFunctionOffset)
|
|
|
ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage);
|
|
|
-
|
|
|
+
|
|
|
STR.popFrame();
|
|
|
// Functions are assumed to return strings, so look ahead to see if we can skip the conversion
|
|
|
if(code[ip] == OP_STR_TO_UINT)
|
|
@@ -1837,7 +1844,7 @@ breakContinue:
|
|
|
}
|
|
|
else
|
|
|
STR.setStringValue((const char*)ret);
|
|
|
-
|
|
|
+
|
|
|
// This will clear everything including returnValue
|
|
|
CSTK.popFrame();
|
|
|
STR.clearFunctionOffset();
|
|
@@ -2219,15 +2226,7 @@ execFinished:
|
|
|
Con::printf("%s", traceBuffer);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- delete[] globalStrings;
|
|
|
- globalStringsMaxLen = 0;
|
|
|
|
|
|
- delete[] globalFloats;
|
|
|
- globalStrings = NULL;
|
|
|
- globalFloats = NULL;
|
|
|
- }
|
|
|
smCurrentCodeBlock = saveCodeBlock;
|
|
|
if(saveCodeBlock && saveCodeBlock->name)
|
|
|
{
|
|
@@ -2235,6 +2234,13 @@ execFinished:
|
|
|
Con::gCurrentRoot = saveCodeBlock->modPath;
|
|
|
}
|
|
|
|
|
|
+ // Mark the reset flag for the next run if we've finished execution
|
|
|
+ if (doResetValueStack)
|
|
|
+ {
|
|
|
+ gEvalState.mShouldReset = true;
|
|
|
+ gEvalState.mResetLocked = false;
|
|
|
+ }
|
|
|
+
|
|
|
decRefCount();
|
|
|
|
|
|
#ifdef TORQUE_DEBUG
|