mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-14 18:00:48 +00:00
Shifted CodeBlock::smCurrentLineText to be a const char* so it's use is clearer
Ensured CodeBlock::smCurrentLineText is cleared at the end of execution Tweaked and cleaned up the context lines passed along for further debugging data in the event of a script assert
This commit is contained in:
parent
171211c4e2
commit
9084e81bc1
11 changed files with 107 additions and 23 deletions
|
|
@ -60,7 +60,7 @@ inline FuncVars* getFuncVars(S32 lineNumber)
|
|||
if (gFuncVars == &gGlobalScopeFuncVars)
|
||||
{
|
||||
const char* lineTxt = CodeBlock::smCurrentLineText;
|
||||
const char* str = avar("Attemping to use local variable in global scope. File: %s Line Num: %d \nLine: %s", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineTxt);
|
||||
const char* str = avar("Attemping to use local variable in global scope. File: %s\nLine Num: %d\nLine: \"%s\"", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineTxt);
|
||||
scriptErrorHandler(str);
|
||||
}
|
||||
return gFuncVars;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ using namespace Compiler;
|
|||
|
||||
bool CodeBlock::smInFunction = false;
|
||||
CodeBlock * CodeBlock::smCodeBlockList = NULL;
|
||||
StringTableEntry CodeBlock::smCurrentLineText = StringTable->EmptyString();
|
||||
const char* CodeBlock::smCurrentLineText = "\0";
|
||||
TorqueScriptParser *CodeBlock::smCurrentParser = NULL;
|
||||
|
||||
extern FuncVars gEvalFuncVars;
|
||||
|
|
@ -625,6 +625,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
|
|||
|
||||
if (!Script::gStatementList)
|
||||
{
|
||||
smCurrentLineText = "\0";
|
||||
delete this;
|
||||
return Con::EvalResult(Con::getVariable("$ScriptError"));
|
||||
}
|
||||
|
|
@ -670,7 +671,10 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
|
|||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
||||
|
||||
// repurpose argc as local register counter for global state
|
||||
return (exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
|
||||
Con::EvalResult execResult = (exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
|
||||
|
||||
smCurrentLineText = "\0";
|
||||
return execResult;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ private:
|
|||
public:
|
||||
static bool smInFunction;
|
||||
static TorqueScriptParser * smCurrentParser;
|
||||
static StringTableEntry smCurrentLineText;
|
||||
static const char* smCurrentLineText;
|
||||
|
||||
static CodeBlock *getCodeBlockList()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,8 +160,16 @@ S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber,
|
|||
|
||||
if (found->second.isConstant)
|
||||
{
|
||||
const char* lineTxt = CodeBlock::smCurrentLineText;
|
||||
const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s Line Num: %d \nLine: %s", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineTxt);
|
||||
const char* lineText = CodeBlock::smCurrentLineText;
|
||||
|
||||
String codeString = CodeBlock::smCurrentLineText;
|
||||
Vector<String> splitLines;
|
||||
codeString.split("\n", splitLines);
|
||||
|
||||
if (lineNumber > 0 && splitLines.size() > lineNumber)
|
||||
lineText = splitLines[lineNumber - 1].c_str();
|
||||
|
||||
const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
|
||||
scriptErrorHandler(str);
|
||||
}
|
||||
return found->second.reg;
|
||||
|
|
@ -180,8 +188,16 @@ S32 FuncVars::lookup(StringTableEntry var, S32 lineNumber)
|
|||
|
||||
if (found == vars.end())
|
||||
{
|
||||
const char* lineTxt = CodeBlock::smCurrentLineText;
|
||||
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line Num: %d \nLine: %s", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineTxt);
|
||||
const char* lineText = CodeBlock::smCurrentLineText;
|
||||
|
||||
String codeString = CodeBlock::smCurrentLineText;
|
||||
Vector<String> splitLines;
|
||||
codeString.split("\n", splitLines);
|
||||
|
||||
if (lineNumber > 0 && splitLines.size() > lineNumber)
|
||||
lineText = splitLines[lineNumber - 1].c_str();
|
||||
|
||||
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
|
||||
scriptErrorHandler(str);
|
||||
|
||||
return assign(var, TypeReqString, lineNumber, false);
|
||||
|
|
@ -197,7 +213,15 @@ TypeReq FuncVars::lookupType(StringTableEntry var, S32 lineNumber)
|
|||
if (found == vars.end())
|
||||
{
|
||||
const char* lineText = CodeBlock::smCurrentLineText;
|
||||
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line Num: %d \nLine: %s", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
|
||||
|
||||
String codeString = CodeBlock::smCurrentLineText;
|
||||
Vector<String> splitLines;
|
||||
codeString.split("\n", splitLines);
|
||||
|
||||
if (lineNumber > 0 && splitLines.size() > lineNumber)
|
||||
lineText = splitLines[lineNumber-1].c_str();
|
||||
|
||||
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
|
||||
scriptErrorHandler(str);
|
||||
|
||||
assign(var, TypeReqString, lineNumber, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue