mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
hacks to make thedebugger work again.
This commit is contained in:
parent
717c7acca9
commit
a449fadde2
8 changed files with 123 additions and 9 deletions
|
|
@ -864,6 +864,37 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char *
|
|||
if ( frame < 0 )
|
||||
frame = 0;
|
||||
|
||||
// Local variables use their own memory management and can't be queried by just executing
|
||||
// TorqueScript, we have to go digging into the interpreter.
|
||||
S32 evalBufferLen = dStrlen(evalBuffer);
|
||||
bool isEvaluatingLocalVariable = evalBufferLen > 0 && evalBuffer[0] == '%';
|
||||
if (isEvaluatingLocalVariable)
|
||||
{
|
||||
const char* format = "EVALOUT %s %s\r\n";
|
||||
|
||||
Dictionary &stackFrame = gEvalState.getFrameAt(frame);
|
||||
StringTableEntry functionName = stackFrame.scopeName;
|
||||
S32 registerId = stackFrame.code->variableRegisterTable.lookup(functionName, StringTable->insert(evalBuffer));
|
||||
|
||||
if (registerId == -1)
|
||||
{
|
||||
// ERROR, can't read the variable!
|
||||
send("EVALOUT \"\" \"\"");
|
||||
return;
|
||||
}
|
||||
|
||||
const char* varResult = gEvalState.getLocalStringVariable(registerId);
|
||||
|
||||
S32 len = dStrlen(format) + dStrlen(tag) + dStrlen(varResult);
|
||||
char* buffer = new char[len];
|
||||
dSprintf(buffer, len, format, tag, varResult[0] ? varResult : "\"\"");
|
||||
|
||||
send(buffer);
|
||||
delete[] buffer;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Build a buffer just big enough for this eval.
|
||||
const char* format = "return %s;";
|
||||
dsize_t len = dStrlen( format ) + dStrlen( evalBuffer );
|
||||
|
|
@ -872,14 +903,14 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char *
|
|||
|
||||
// Execute the eval.
|
||||
CodeBlock *newCodeBlock = new CodeBlock();
|
||||
const char* result = newCodeBlock->compileExec( NULL, buffer, false, frame );
|
||||
ConsoleValue result = newCodeBlock->compileExec( NULL, buffer, false, frame );
|
||||
delete [] buffer;
|
||||
|
||||
// Create a new buffer that fits the result.
|
||||
format = "EVALOUT %s %s\r\n";
|
||||
len = dStrlen( format ) + dStrlen( tag ) + dStrlen( result );
|
||||
len = dStrlen( format ) + dStrlen( tag ) + dStrlen( result.getString() );
|
||||
buffer = new char[ len ];
|
||||
dSprintf( buffer, len, format, tag, result[0] ? result : "\"\"" );
|
||||
dSprintf( buffer, len, format, tag, result.getString()[0] ? result.getString() : "\"\"" );
|
||||
|
||||
send( buffer );
|
||||
delete [] buffer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue