MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / evaluateExpression

Method evaluateExpression

Engine/source/console/telnetDebugger.cpp:856–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char *evalBuffer)
857{
858 // Make sure we're passing a valid frame to the eval.
859 if ( frame > gEvalState.getStackDepth() )
860 frame = gEvalState.getStackDepth() - 1;
861 if ( frame < 0 )
862 frame = 0;
863
864 // Build a buffer just big enough for this eval.
865 const char* format = "return %s;";
866 dsize_t len = dStrlen( format ) + dStrlen( evalBuffer );
867 char* buffer = new char[ len ];
868 dSprintf( buffer, len, format, evalBuffer );
869
870 // Execute the eval.
871 CodeBlock *newCodeBlock = new CodeBlock();
872 const char* result = newCodeBlock->compileExec( NULL, buffer, false, frame );
873 delete [] buffer;
874
875 // Create a new buffer that fits the result.
876 format = "EVALOUT %s %s\r\n";
877 len = dStrlen( format ) + dStrlen( tag ) + dStrlen( result );
878 buffer = new char[ len ];
879 dSprintf( buffer, len, format, tag, result[0] ? result : "\"\"" );
880
881 send( buffer );
882 delete [] buffer;
883}
884
885void TelnetDebugger::dumpFileList()
886{

Callers

nothing calls this directly

Calls 4

dSprintfFunction · 0.85
getStackDepthMethod · 0.80
compileExecMethod · 0.80
dStrlenFunction · 0.50

Tested by

no test coverage detected