mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
- Add a name to VMFunction so that the disassembly can be more informative.
SVN r3768 (scripting)
This commit is contained in:
parent
d85604da19
commit
644f0c0e05
7 changed files with 53 additions and 23 deletions
|
@ -549,4 +549,11 @@ xx(Inter_Strife_Bad)
|
|||
xx(Inter_Strife_Lose)
|
||||
xx(Inter_Strife_MAP03)
|
||||
xx(Inter_Strife_MAP10)
|
||||
xx(Multiplayer)
|
||||
xx(Multiplayer)
|
||||
|
||||
// Decorate compatibility functions
|
||||
xx(DecoRandom)
|
||||
xx(DecoFRandom)
|
||||
xx(DecoCallLineSpecial)
|
||||
xx(DecoNameToClass)
|
||||
xx(DecoFindMultiNameState)
|
||||
|
|
|
@ -264,6 +264,7 @@ static void FinishThingdef()
|
|||
{
|
||||
int errorcount = StateParams.ResolveAll();
|
||||
unsigned i, j;
|
||||
int codesize = 0;
|
||||
|
||||
FILE *dump = fopen("disasm.txt", "w");
|
||||
for (i = 0; i < StateTempCalls.Size(); ++i)
|
||||
|
@ -316,6 +317,7 @@ static void FinishThingdef()
|
|||
VMDumpConstants(dump, sfunc);
|
||||
fprintf(dump, "\nDisassembly @ %p:\n", sfunc->Code);
|
||||
VMDisasm(dump, sfunc->Code, sfunc->CodeSize, sfunc);
|
||||
codesize += sfunc->CodeSize;
|
||||
#endif
|
||||
}
|
||||
for (int k = 0; k < tcall->NumStates; ++k)
|
||||
|
@ -323,6 +325,9 @@ static void FinishThingdef()
|
|||
tcall->ActorClass->OwnedStates[tcall->FirstState + k].SetAction(func);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
fprintf(dump, "\n*************************************************************************\n%i code bytes\n", codesize * 4);
|
||||
#endif
|
||||
fclose(dump);
|
||||
|
||||
for (i = 0; i < PClassActor::AllActorClasses.Size(); i++)
|
||||
|
|
|
@ -613,7 +613,7 @@ void InitThingdef()
|
|||
{
|
||||
AFuncDesc *afunc = (AFuncDesc *)*probe;
|
||||
assert(afunc->VMPointer != NULL);
|
||||
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function);
|
||||
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->Name);
|
||||
AFTable.Push(*afunc);
|
||||
}
|
||||
AFTable.ShrinkToFit();
|
||||
|
|
|
@ -2487,11 +2487,11 @@ ExpEmit FxRandom::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoRandom function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoRandom", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoRandom, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoRandom");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoRandom);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoRandom);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoRandom, NAME_DecoRandom);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
@ -2593,11 +2593,11 @@ ExpEmit FxFRandom::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoFRandom function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoFRandom", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoFRandom, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoFRandom");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoFRandom);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoFRandom);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoFRandom, NAME_DecoFRandom);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
@ -2683,11 +2683,11 @@ ExpEmit FxRandom2::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoRandom function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoRandom", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoRandom, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoRandom");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoRandom);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoRandom);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoRandom, NAME_DecoRandom);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
@ -3530,11 +3530,11 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoCallLineSpecial function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoCallLineSpecial", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoCallLineSpecial, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoCallLineSpecial");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoCallLineSpecial);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoCallLineSpecial);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoCallLineSpecial, NAME_DecoCallLineSpecial);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
@ -3795,11 +3795,11 @@ ExpEmit FxClassTypeCast::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoNameToClass function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoNameToClass", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoNameToClass, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoNameToClass");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoNameToClass);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoNameToClass);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoNameToClass, NAME_DecoNameToClass);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
@ -3995,11 +3995,11 @@ ExpEmit FxMultiNameState::Emit(VMFunctionBuilder *build)
|
|||
// Find the DecoFindMultiNameState function. If not found, create it and install it
|
||||
// in Actor.
|
||||
VMFunction *callfunc;
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol("DecoFindMultiNameState", false);
|
||||
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoNameToClass, false);
|
||||
if (sym == NULL)
|
||||
{
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction("DecoFindMultiNameState");
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoFindMultiNameState);
|
||||
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoNameToClass);
|
||||
VMNativeFunction *calldec = new VMNativeFunction(DecoFindMultiNameState, NAME_DecoNameToClass);
|
||||
symfunc->Function = calldec;
|
||||
sym = symfunc;
|
||||
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);
|
||||
|
|
|
@ -149,6 +149,10 @@ class VMFunction : public DObject
|
|||
DECLARE_ABSTRACT_CLASS(VMFunction, DObject);
|
||||
public:
|
||||
bool Native;
|
||||
FName Name;
|
||||
|
||||
VMFunction() : Native(false), Name(NAME_None) {}
|
||||
VMFunction(FName name) : Native(false), Name(name) {}
|
||||
};
|
||||
|
||||
enum EVMOpMode
|
||||
|
@ -712,7 +716,7 @@ struct VMRegisters
|
|||
|
||||
struct VMException : public DObject
|
||||
{
|
||||
DECLARE_CLASS(VMFunction, DObject);
|
||||
DECLARE_CLASS(VMException, DObject);
|
||||
};
|
||||
|
||||
union FVoidObj
|
||||
|
@ -725,7 +729,7 @@ class VMScriptFunction : public VMFunction
|
|||
{
|
||||
DECLARE_CLASS(VMScriptFunction, VMFunction);
|
||||
public:
|
||||
VMScriptFunction();
|
||||
VMScriptFunction(FName name=NAME_None);
|
||||
~VMScriptFunction();
|
||||
size_t PropagateMark();
|
||||
void Alloc(int numops, int numkonstd, int numkonstf, int numkonsts, int numkonsta);
|
||||
|
@ -788,6 +792,7 @@ public:
|
|||
|
||||
VMNativeFunction() : NativeCall(NULL) { Native = true; }
|
||||
VMNativeFunction(NativeCallType call) : NativeCall(call) { Native = true; }
|
||||
VMNativeFunction(NativeCallType call, FName name) : VMFunction(name), NativeCall(call) { Native = true; }
|
||||
|
||||
// Return value is the number of results.
|
||||
NativeCallType NativeCall;
|
||||
|
|
|
@ -173,6 +173,8 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
|
|||
|
||||
void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction *func)
|
||||
{
|
||||
VMFunction *callfunc;
|
||||
const char *callname;
|
||||
const char *name;
|
||||
int col;
|
||||
int mode;
|
||||
|
@ -212,6 +214,12 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
|||
col = printf_wrapper(out, "%d", code[i].i24);
|
||||
break;
|
||||
|
||||
case OP_CALL_K:
|
||||
callfunc = (VMFunction *)func->KonstA[code[i].a].o;
|
||||
callname = callfunc->Name != NAME_None ? callfunc->Name : "[anonfunc]";
|
||||
col = printf_wrapper(out, "%.23s,%d,%d", callname, code[i].b, code[i].c);
|
||||
break;
|
||||
|
||||
case OP_RET:
|
||||
if (code[i].b != REGT_NIL)
|
||||
{
|
||||
|
@ -308,6 +316,10 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
|||
{
|
||||
printf_wrapper(out, "%d\n", code[i].i24);
|
||||
}
|
||||
else if (code[i].op == OP_CALL_K)
|
||||
{
|
||||
printf_wrapper(out, "%d,%d,%d [%p]\n", code[i].a, code[i].b, code[i].c, callfunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf_wrapper(out, "%d,%d,%d\n", code[i].a, code[i].b, code[i].c);
|
||||
|
|
|
@ -6,9 +6,10 @@ IMPLEMENT_ABSTRACT_CLASS(VMFunction)
|
|||
IMPLEMENT_CLASS(VMScriptFunction)
|
||||
IMPLEMENT_CLASS(VMNativeFunction)
|
||||
|
||||
VMScriptFunction::VMScriptFunction()
|
||||
VMScriptFunction::VMScriptFunction(FName name)
|
||||
{
|
||||
Native = false;
|
||||
Name = name;
|
||||
Code = NULL;
|
||||
KonstD = NULL;
|
||||
KonstF = NULL;
|
||||
|
|
Loading…
Reference in a new issue