Exec() with noCalls broken
by Tom Spilman · in Torque Game Engine · 02/13/2006 (11:31 pm) · 3 replies
I was experimenting with adding a precompile step into Torsion and ran into this in CodeBlock::exec()...
So what value should 'failJump' have on the first OP_CREATE_OBJECT instruction? Isn't it just supposed to skip over to the next instruction?
Regardless... soon after that i found the compile() TorqueScript command. So i didn't need this exec() noCalls functionality anyway. =)
case OP_CREATE_OBJECT:
{
// If we don't allow calls, we certainly don't allow creating objects!
if(noCalls)
{
ip = failJump; // THIS IS NOT INITIALIZED
break;
}
// Read some useful info.
objParent = U32toSTE(code[ip ]);
bool isDataBlock = code[ip + 1];
failJump = code[ip + 2]; // BUT HERE IT's ASSIGNED A VALUESo what value should 'failJump' have on the first OP_CREATE_OBJECT instruction? Isn't it just supposed to skip over to the next instruction?
Regardless... soon after that i found the compile() TorqueScript command. So i didn't need this exec() noCalls functionality anyway. =)
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
#2
The code i have listed above is C++ code from the Torque class CodeBlock, which itself executes TorqueScript code.
This bug is that a feature exposed to script, the noCalls argument for the TorqueScript exec() call, does not work and will crash when the OP_CREATE_OBJECT opcode above is processed.
=)
02/15/2006 (8:47 am)
I must have not been clear. The code i have listed above is C++ code from the Torque class CodeBlock, which itself executes TorqueScript code.
This bug is that a feature exposed to script, the noCalls argument for the TorqueScript exec() call, does not work and will crash when the OP_CREATE_OBJECT opcode above is processed.
=)
#3
... and i fixed something that didn't make sense. It currently does this...
This means that if noCalls is enabled that the new function declarations won't be linked to the namespaces. This doesn't seem like the spirit of what noCalls does... don't call functions or create objects. I think noCalls doesn't need to be checked for this case and i see no ill effects from removing it.
Does this make sense to everyone?
04/16/2006 (10:55 pm)
I've fixed this noCalls bug. I'll post the fix as a bigger TelnetDebugger fix here soon, but this is what i did...case OP_CREATE_OBJECT:
{
failJump = code[ip + 2]; // Moved this here... seems to work.
if(noCalls)
{
ip = failJump;
break;
}
objParent = U32toSTE(code[ip]);
bool dataBlock = code[ip + 1];... and i fixed something that didn't make sense. It currently does this...
case OP_FUNC_DECL:
if(!noCalls)
{
fnName = U32toSTE(code[ip]);
fnNamespace = U32toSTE(code[ip+1]);
fnPackage = U32toSTE(code[ip+2]);
bool hasBody = bool(code[ip+3]);
Namespace::unlinkPackages();This means that if noCalls is enabled that the new function declarations won't be linked to the namespaces. This doesn't seem like the spirit of what noCalls does... don't call functions or create objects. I think noCalls doesn't need to be checked for this case and i see no ill effects from removing it.
Does this make sense to everyone?
Associate Anthony Rosenbaum