Change disassembly dumps to be controlled from one spot

- Instead of changing three places to turn disassembly dumps on and off,
  do it with just one place. As a side effect, this now handles the case
  where the dump file can't be opened.
This commit is contained in:
Randy Heit 2013-08-23 21:43:56 -05:00
parent 3f6c3fa927
commit a69089ffd7

View file

@ -280,7 +280,11 @@ static void FinishThingdef()
unsigned i, j; unsigned i, j;
int codesize = 0; int codesize = 0;
#if 1
FILE *dump = fopen("disasm.txt", "w"); FILE *dump = fopen("disasm.txt", "w");
#else
FILE *dump = NULL;
#endif
for (i = 0; i < StateTempCalls.Size(); ++i) for (i = 0; i < StateTempCalls.Size(); ++i)
{ {
FStateTempCall *tcall = StateTempCalls[i]; FStateTempCall *tcall = StateTempCalls[i];
@ -317,13 +321,15 @@ static void FinishThingdef()
VMScriptFunction *sfunc = buildit.MakeFunction(); VMScriptFunction *sfunc = buildit.MakeFunction();
sfunc->NumArgs = NAP; sfunc->NumArgs = NAP;
func = sfunc; func = sfunc;
#if 1
char label[64]; if (dump != NULL)
int labellen = mysnprintf(label, countof(label), "Function %s.States[%d] (*%d)", {
tcall->ActorClass->TypeName.GetChars(), tcall->FirstState, tcall->NumStates); char label[64];
DumpFunction(dump, sfunc, label, labellen); int labellen = mysnprintf(label, countof(label), "Function %s.States[%d] (*%d)",
codesize += sfunc->CodeSize; tcall->ActorClass->TypeName.GetChars(), tcall->FirstState, tcall->NumStates);
#endif DumpFunction(dump, sfunc, label, labellen);
codesize += sfunc->CodeSize;
}
} }
for (int k = 0; k < tcall->NumStates; ++k) for (int k = 0; k < tcall->NumStates; ++k)
{ {
@ -370,8 +376,8 @@ static void FinishThingdef()
dmg->SetFunction(sfunc); dmg->SetFunction(sfunc);
} }
def->Damage = sfunc; def->Damage = sfunc;
#if 1
if (sfunc != NULL) if (dump != NULL && sfunc != NULL)
{ {
char label[64]; char label[64];
int labellen = mysnprintf(label, countof(label), "Function %s.Damage", int labellen = mysnprintf(label, countof(label), "Function %s.Damage",
@ -379,13 +385,13 @@ static void FinishThingdef()
DumpFunction(dump, sfunc, label, labellen); DumpFunction(dump, sfunc, label, labellen);
codesize += sfunc->CodeSize; codesize += sfunc->CodeSize;
} }
#endif
} }
} }
#if 1 if (dump != NULL)
fprintf(dump, "\n*************************************************************************\n%i code bytes\n", codesize * 4); {
#endif fprintf(dump, "\n*************************************************************************\n%i code bytes\n", codesize * 4);
fclose(dump); fclose(dump);
}
if (errorcount > 0) if (errorcount > 0)
{ {
I_Error("%d errors during actor postprocessing", errorcount); I_Error("%d errors during actor postprocessing", errorcount);