- Fixed errors and warnings when compiling with GCC. (Unfortunately, the VC++ debug builds

become ungodly slow when using mods with complex DECORATE. The GCC debug builds run just
  fine, however. Hopefully this is something that can be fixed later with an assembly-optimized
  version of the main VM loop, because I don't relish the thought of being stuck with GDB
  for debugging.)
- Fixed: The ACS_Named* action specials were erroneously defined as taking strings instead of
  names.
- Fixed: Copy-paste error caused FxMultiNameState::Emit to generate code that called
  DecoNameToClass instead of DecoFindMultiNameState.
- Updated FxActionSpecialCall::Emit for named script specials.
- Fixed inverted asserts for FxMinusSign::Emit and FxUnaryNotBitwise::Emit.


SVN r3893 (scripting)
This commit is contained in:
Randy Heit 2012-10-18 03:19:27 +00:00
parent e7efa1d802
commit 38d7b7d203
23 changed files with 73 additions and 65 deletions

View file

@ -566,11 +566,6 @@ else( NO_ASM )
ADD_ASM_FILE( asm_ia32 tmap2 ) ADD_ASM_FILE( asm_ia32 tmap2 )
ADD_ASM_FILE( asm_ia32 tmap3 ) ADD_ASM_FILE( asm_ia32 tmap3 )
endif( X64 ) endif( X64 )
if( WIN32 )
if( NOT X64 )
ADD_ASM_FILE( win32 wrappers )
endif( NOT X64 )
endif( WIN32 )
endif( NO_ASM ) endif( NO_ASM )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h
@ -880,7 +875,6 @@ add_executable( zdoom WIN32
thingdef/thingdef_data.cpp thingdef/thingdef_data.cpp
thingdef/thingdef_exp.cpp thingdef/thingdef_exp.cpp
thingdef/thingdef_expression.cpp thingdef/thingdef_expression.cpp
thingdef/thingdef_function.cpp
thingdef/thingdef_parse.cpp thingdef/thingdef_parse.cpp
thingdef/thingdef_properties.cpp thingdef/thingdef_properties.cpp
thingdef/thingdef_states.cpp thingdef/thingdef_states.cpp
@ -910,6 +904,7 @@ add_executable( zdoom WIN32
r_data/renderstyle.cpp r_data/renderstyle.cpp
r_data/r_interpolate.cpp r_data/r_interpolate.cpp
r_data/r_translate.cpp r_data/r_translate.cpp
zscript/ast.cpp
zscript/vmbuilder.cpp zscript/vmbuilder.cpp
zscript/vmdisasm.cpp zscript/vmdisasm.cpp
zscript/vmexec.cpp zscript/vmexec.cpp

View file

@ -500,7 +500,7 @@ inline AActor *GetDefaultByType (const PClass *type)
template<class T> template<class T>
inline T *GetDefault () inline T *GetDefault ()
{ {
return (T *)(RUNTIME_CLASS(T)->Defaults); return (T *)(RUNTIME_CLASS_CASTLESS(T)->Defaults);
} }
struct line_t; struct line_t;
@ -634,7 +634,7 @@ public:
AInventory *FindInventory (FName type); AInventory *FindInventory (FName type);
template<class T> T *FindInventory () template<class T> T *FindInventory ()
{ {
return static_cast<T *> (FindInventory (RUNTIME_CLASS(T))); return static_cast<T *> (FindInventory (RUNTIME_TEMPLATE_CLASS(T)));
} }
// Adds one item of a particular type. Returns NULL if it could not be added. // Adds one item of a particular type. Returns NULL if it could not be added.
@ -1018,7 +1018,7 @@ public:
do do
{ {
actor = FActorIterator::Next (); actor = FActorIterator::Next ();
} while (actor && !actor->IsKindOf (RUNTIME_CLASS(T))); } while (actor && !actor->IsKindOf (RUNTIME_TEMPLATE_CLASS(T)));
return static_cast<T *>(actor); return static_cast<T *>(actor);
} }
}; };
@ -1055,7 +1055,7 @@ AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allow
template<class T> template<class T>
inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement)
{ {
return static_cast<T *>(AActor::StaticSpawn (RUNTIME_CLASS(T), x, y, z, allowreplacement)); return static_cast<T *>(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), x, y, z, allowreplacement));
} }

View file

@ -2040,7 +2040,7 @@ static int PatchCodePtrs (int dummy)
if (!symname.CompareNoCase(MBFCodePointers[i].alias)) if (!symname.CompareNoCase(MBFCodePointers[i].alias))
{ {
symname = MBFCodePointers[i].name; symname = MBFCodePointers[i].name;
Printf("%s --> %s\n", MBFCodePointers[i].alias, MBFCodePointers[i].name); Printf("%s --> %s\n", MBFCodePointers[i].alias, MBFCodePointers[i].name.GetChars());
} }
} }

View file

@ -82,6 +82,7 @@ class PClassActor;
#define RUNTIME_CLASS_CASTLESS(cls) (cls::RegistrationInfo.MyClass) // Passed a native class name, returns a PClass representing that class #define RUNTIME_CLASS_CASTLESS(cls) (cls::RegistrationInfo.MyClass) // Passed a native class name, returns a PClass representing that class
#define RUNTIME_CLASS(cls) ((cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // Like above, but returns the true type of the meta object #define RUNTIME_CLASS(cls) ((cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // Like above, but returns the true type of the meta object
#define RUNTIME_TEMPLATE_CLASS(cls) ((class cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // RUNTIME_CLASS, but works with templated parameters on GCC
#define NATIVE_TYPE(object) (object->StaticType()) // Passed an object, returns the type of the C++ class representing the object #define NATIVE_TYPE(object) (object->StaticType()) // Passed an object, returns the type of the C++ class representing the object
// Enumerations for the meta classes created by ClassReg::RegisterClass() // Enumerations for the meta classes created by ClassReg::RegisterClass()

View file

@ -103,7 +103,7 @@ void DumpTypeTable()
if (len > max) if (len > max)
max = len; max = len;
} }
if (len < countof(lens)) if (len < (int)countof(lens))
{ {
lens[len]++; lens[len]++;
} }
@ -114,7 +114,7 @@ void DumpTypeTable()
Printf("Max bucket size: %d\n", max); Printf("Max bucket size: %d\n", max);
Printf("Avg bucket size: %.2f\n", double(all) / used); Printf("Avg bucket size: %.2f\n", double(all) / used);
int j,k; int j,k;
for (k = k = countof(lens)-1; k > 0; --k) for (k = countof(lens)-1; k > 0; --k)
if (lens[k]) if (lens[k])
break; break;
for (j = 0; j <= k; ++j) for (j = 0; j <= k; ++j)
@ -224,8 +224,8 @@ bool PType::IsMatch(intptr_t id1, intptr_t id2) const
void PType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const void PType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const
{ {
id1 = NULL; id1 = 0;
id2 = NULL; id2 = 0;
} }
//========================================================================== //==========================================================================
@ -486,7 +486,7 @@ PPointer::PPointer(PType *pointsat)
bool PPointer::IsMatch(intptr_t id1, intptr_t id2) const bool PPointer::IsMatch(intptr_t id1, intptr_t id2) const
{ {
assert(id2 == NULL); assert(id2 == 0);
PType *pointat = (PType *)id1; PType *pointat = (PType *)id1;
return pointat == PointedType; return pointat == PointedType;
@ -733,7 +733,7 @@ PDynArray::PDynArray(PType *etype)
bool PDynArray::IsMatch(intptr_t id1, intptr_t id2) const bool PDynArray::IsMatch(intptr_t id1, intptr_t id2) const
{ {
assert(id2 == NULL); assert(id2 == 0);
const PType *elemtype = (const PType *)id1; const PType *elemtype = (const PType *)id1;
return elemtype == ElementType; return elemtype == ElementType;

View file

@ -121,10 +121,10 @@ public:
template <class T> class TThinkerIterator : public FThinkerIterator template <class T> class TThinkerIterator : public FThinkerIterator
{ {
public: public:
TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_CLASS(T), statnum) TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_TEMPLATE_CLASS(T), statnum)
{ {
} }
TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_CLASS(T), statnum, prev) TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_TEMPLATE_CLASS(T), statnum, prev)
{ {
} }
TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum) TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum)

View file

@ -272,7 +272,7 @@ inline FArchive &operator<< (FArchive &arc, PalEntry &p)
template<class T> template<class T>
inline FArchive &operator<< (FArchive &arc, T* &object) inline FArchive &operator<< (FArchive &arc, T* &object)
{ {
return arc.SerializeObject ((DObject*&)object, RUNTIME_CLASS(T)); return arc.SerializeObject ((DObject*&)object, RUNTIME_TEMPLATE_CLASS(T));
} }
FArchive &operator<< (FArchive &arc, PClass * &info); FArchive &operator<< (FArchive &arc, PClass * &info);

View file

@ -1273,7 +1273,7 @@ bool AInventory::DoRespawn ()
void AInventory::GiveQuest (AActor *toucher) void AInventory::GiveQuest (AActor *toucher)
{ {
int quest = GetClass()->GiveQuest; int quest = GetClass()->GiveQuest;
if (quest > 0 && quest <= countof(QuestItemClasses)) if (quest > 0 && quest <= (int)countof(QuestItemClasses))
{ {
toucher->GiveInventoryType (QuestItemClasses[quest-1]); toucher->GiveInventoryType (QuestItemClasses[quest-1]);
} }

View file

@ -240,7 +240,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres)
void DBaseStatusBar::Destroy () void DBaseStatusBar::Destroy ()
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *msg = Messages[i]; DHUDMessage *msg = Messages[i];
while (msg) while (msg)
@ -342,7 +342,7 @@ void DBaseStatusBar::MultiplayerChanged ()
void DBaseStatusBar::Tick () void DBaseStatusBar::Tick ()
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *msg = Messages[i]; DHUDMessage *msg = Messages[i];
DHUDMessage **prev = &Messages[i]; DHUDMessage **prev = &Messages[i];
@ -424,7 +424,7 @@ void DBaseStatusBar::AttachMessage (DHUDMessage *msg, DWORD id, int layer)
DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg) DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *probe = Messages[i]; DHUDMessage *probe = Messages[i];
DHUDMessage **prev = &Messages[i]; DHUDMessage **prev = &Messages[i];
@ -451,7 +451,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg)
DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id) DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id)
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *probe = Messages[i]; DHUDMessage *probe = Messages[i];
DHUDMessage **prev = &Messages[i]; DHUDMessage **prev = &Messages[i];
@ -484,7 +484,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id)
void DBaseStatusBar::DetachAllMessages () void DBaseStatusBar::DetachAllMessages ()
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *probe = Messages[i]; DHUDMessage *probe = Messages[i];
@ -1627,7 +1627,7 @@ void DBaseStatusBar::Serialize (FArchive &arc)
} }
else else
{ {
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
arc << Messages[i]; arc << Messages[i];
} }
@ -1639,7 +1639,7 @@ void DBaseStatusBar::ScreenSizeChanged ()
st_scale.Callback (); st_scale.Callback ();
SB_state = screen->GetPageCount (); SB_state = screen->GetPageCount ();
for (int i = 0; i < countof(Messages); ++i) for (size_t i = 0; i < countof(Messages); ++i)
{ {
DHUDMessage *message = Messages[i]; DHUDMessage *message = Messages[i];
while (message != NULL) while (message != NULL)

View file

@ -35,7 +35,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem)
PARAM_INT(questitem); PARAM_INT(questitem);
// Give one of these quest items to every player in the game // Give one of these quest items to every player in the game
if (questitem >= 0 && questitem < countof(QuestItemClasses)) if (questitem >= 0 && questitem < (int)countof(QuestItemClasses))
{ {
for (int i = 0; i < MAXPLAYERS; ++i) for (int i = 0; i < MAXPLAYERS; ++i)
{ {

View file

@ -352,7 +352,7 @@ void M_SetMenu(FName menu, int param)
GameStartupInfo.Episode = -1; GameStartupInfo.Episode = -1;
GameStartupInfo.PlayerClass = GameStartupInfo.PlayerClass =
param == -1000? NULL : param == -1000? NULL :
param == -1? "Random" : GetPrintableDisplayName(PlayerClasses[param].Type); param == -1? "Random" : GetPrintableDisplayName(PlayerClasses[param].Type).GetChars();
break; break;
case NAME_Skillmenu: case NAME_Skillmenu:

View file

@ -2621,7 +2621,7 @@ AActor *AActor::TIDHash[128];
void AActor::ClearTIDHashes () void AActor::ClearTIDHashes ()
{ {
memset(TIDHash, NULL, sizeof(TIDHash)); memset(TIDHash, 0, sizeof(TIDHash));
} }
// //

View file

@ -420,7 +420,7 @@ IMPLEMENT_CLASS(PClassPlayerPawn)
PClassPlayerPawn::PClassPlayerPawn() PClassPlayerPawn::PClassPlayerPawn()
{ {
for (int i = 0; i < countof(HexenArmor); ++i) for (size_t i = 0; i < countof(HexenArmor); ++i)
{ {
HexenArmor[i] = 0; HexenArmor[i] = 0;
} }
@ -433,7 +433,7 @@ void PClassPlayerPawn::Derive(PClass *newclass)
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn))); assert(newclass->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
Super::Derive(newclass); Super::Derive(newclass);
PClassPlayerPawn *newp = static_cast<PClassPlayerPawn *>(newclass); PClassPlayerPawn *newp = static_cast<PClassPlayerPawn *>(newclass);
int i; size_t i;
newp->DisplayName = DisplayName; newp->DisplayName = DisplayName;
newp->SoundClass = SoundClass; newp->SoundClass = SoundClass;

View file

@ -952,7 +952,7 @@ void R_InitSprites ()
FString classface = basetype->Face; FString classface = basetype->Face;
strcpy (skins[i].name, "Base"); strcpy (skins[i].name, "Base");
if (classface.IsEmpty() == NULL || strcmp(classface, "None") == 0) if (classface.IsEmpty() || strcmp(classface, "None") == 0)
{ {
skins[i].face[0] = 'S'; skins[i].face[0] = 'S';
skins[i].face[1] = 'T'; skins[i].face[1] = 'T';

View file

@ -779,7 +779,7 @@ void R_SetupFrame (AActor *actor)
{ {
iview->nviewx = camera->x; iview->nviewx = camera->x;
iview->nviewy = camera->y; iview->nviewy = camera->y;
iview->nviewz = camera->player ? camera->player->viewz : camera->z + camera->GetClass()->CameraHeight; iview->nviewz = camera->player ? camera->player->viewz : camera->z + camera->GetCameraHeight();
viewsector = camera->Sector; viewsector = camera->Sector;
r_showviewer = false; r_showviewer = false;
} }

View file

@ -2280,7 +2280,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Log)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STRING(text); PARAM_STRING(text);
Printf("%s\n", text); Printf("%s\n", text.GetChars());
ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains! ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains!
return numret; return numret;
} }
@ -2737,7 +2737,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg)
PARAM_INT(argnum); PARAM_INT(argnum);
PARAM_STATE_OPT(state) { state = self->FindState(NAME_Death); } PARAM_STATE_OPT(state) { state = self->FindState(NAME_Death); }
if (argnum > 0 && argnum < countof(self->args)) if (argnum > 0 && argnum < (int)countof(self->args))
{ {
if (!self->args[argnum]--) if (!self->args[argnum]--)
{ {
@ -3542,7 +3542,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
} }
else else
{ {
Printf("Unknown flag '%s' in '%s'\n", flagname, cls->TypeName.GetChars()); Printf("Unknown flag '%s' in '%s'\n", flagname.GetChars(), cls->TypeName.GetChars());
} }
return 0; return 0;
} }
@ -3598,7 +3598,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag)
} }
else else
{ {
Printf("Unknown flag '%s' in '%s'\n", flagname, cls->TypeName.GetChars()); Printf("Unknown flag '%s' in '%s'\n", flagname.GetChars(), cls->TypeName.GetChars());
} }
return numret; return numret;
} }
@ -4092,7 +4092,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_ANGLE_OPT(angle); PARAM_ANGLE_OPT(angle) { angle = 0; }
self->angle += angle; self->angle += angle;
return 0; return 0;
} }

View file

@ -831,7 +831,7 @@ ExpEmit FxMinusSign::Emit(VMFunctionBuilder *build)
{ {
assert(ValueType.Type == Operand->ValueType.Type); assert(ValueType.Type == Operand->ValueType.Type);
ExpEmit from = Operand->Emit(build); ExpEmit from = Operand->Emit(build);
assert(from.Konst != 0); assert(from.Konst == 0);
// Do it in-place. // Do it in-place.
if (ValueType == VAL_Int) if (ValueType == VAL_Int)
{ {
@ -929,7 +929,7 @@ ExpEmit FxUnaryNotBitwise::Emit(VMFunctionBuilder *build)
assert(ValueType.Type == Operand->ValueType.Type); assert(ValueType.Type == Operand->ValueType.Type);
assert(ValueType == VAL_Int); assert(ValueType == VAL_Int);
ExpEmit from = Operand->Emit(build); ExpEmit from = Operand->Emit(build);
assert(from.Konst != 0); assert(from.Konst == 0);
// Do it in-place. // Do it in-place.
build->Emit(OP_NOT, from.RegNum, from.RegNum, 0); build->Emit(OP_NOT, from.RegNum, from.RegNum, 0);
return from; return from;
@ -3507,23 +3507,32 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
assert(Self == NULL); assert(Self == NULL);
unsigned i = 0; unsigned i = 0;
build->Emit(OP_PARAMI, Special); // pass special number build->Emit(OP_PARAMI, abs(Special)); // pass special number
build->Emit(OP_PARAM, 0, REGT_POINTER, 0); // pass self build->Emit(OP_PARAM, 0, REGT_POINTER, 0); // pass self
if (ArgList != NULL) if (ArgList != NULL)
{ {
for (; i < ArgList->Size(); ++i) for (; i < ArgList->Size(); ++i)
{ {
FxExpression *argex = (*ArgList)[i]; FxExpression *argex = (*ArgList)[i];
assert(argex->ValueType == VAL_Int); if (Special < 0 && i == 0)
if (argex->isConstant())
{ {
EmitConstantInt(build, argex->EvalExpression(NULL).GetInt()); assert(argex->ValueType == VAL_Name);
assert(argex->isConstant());
EmitConstantInt(build, -argex->EvalExpression(NULL).GetName());
} }
else else
{ {
ExpEmit arg(argex->Emit(build)); assert(argex->ValueType == VAL_Int);
build->Emit(OP_PARAM, 0, arg.RegType, arg.RegNum); if (argex->isConstant())
arg.Free(build); {
EmitConstantInt(build, argex->EvalExpression(NULL).GetInt());
}
else
{
ExpEmit arg(argex->Emit(build));
build->Emit(OP_PARAM, 0, arg.RegType, arg.RegNum);
arg.Free(build);
}
} }
} }
} }
@ -3995,11 +4004,11 @@ ExpEmit FxMultiNameState::Emit(VMFunctionBuilder *build)
// Find the DecoFindMultiNameState function. If not found, create it and install it // Find the DecoFindMultiNameState function. If not found, create it and install it
// in Actor. // in Actor.
VMFunction *callfunc; VMFunction *callfunc;
PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoNameToClass, false); PSymbol *sym = RUNTIME_CLASS(AActor)->Symbols.FindSymbol(NAME_DecoFindMultiNameState, false);
if (sym == NULL) if (sym == NULL)
{ {
PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoNameToClass); PSymbolVMFunction *symfunc = new PSymbolVMFunction(NAME_DecoFindMultiNameState);
VMNativeFunction *calldec = new VMNativeFunction(DecoFindMultiNameState, NAME_DecoNameToClass); VMNativeFunction *calldec = new VMNativeFunction(DecoFindMultiNameState, NAME_DecoFindMultiNameState);
symfunc->Function = calldec; symfunc->Function = calldec;
sym = symfunc; sym = symfunc;
RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym); RUNTIME_CLASS(AActor)->Symbols.AddSymbol(sym);

View file

@ -88,7 +88,7 @@ static PClassActor *FindClassTentative(const char *name, PClass *ancestor)
assert(cls != NULL); // cls can not be NULL here assert(cls != NULL); // cls can not be NULL here
if (!cls->IsDescendantOf(ancestor)) if (!cls->IsDescendantOf(ancestor))
{ {
I_Error("%s does not inherit from %s\n", name, ancestor); I_Error("%s does not inherit from %s\n", name, ancestor->TypeName.GetChars());
} }
return static_cast<PClassActor *>(cls); return static_cast<PClassActor *>(cls);
} }

View file

@ -446,7 +446,7 @@ size_t VMFunctionBuilder::Emit(int opcode, int opa, VM_SHALF opbc)
{ {
assert(opcode >= 0 && opcode < NUM_OPS); assert(opcode >= 0 && opcode < NUM_OPS);
assert(opa >= 0 && opa <= 255); assert(opa >= 0 && opa <= 255);
assert(opbc >= -32768 && opbc <= 32767); //assert(opbc >= -32768 && opbc <= 32767); always true due to parameter's width
VMOP op; VMOP op;
op.op = opcode; op.op = opcode;
op.a = opa; op.a = opa;

View file

@ -157,7 +157,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
{ {
for (j = 0, k = i; j < 4 && k < func->NumKonstA; j++, k += kk) for (j = 0, k = i; j < 4 && k < func->NumKonstA; j++, k += kk)
{ {
mysnprintf(tmp, countof(tmp), "%3d. %p:%d", k, func->KonstA[k], func->KonstATags()[k]); mysnprintf(tmp, countof(tmp), "%3d. %p:%d", k, func->KonstA[k].v, func->KonstATags()[k]);
printf_wrapper(out, "%-20s", tmp); printf_wrapper(out, "%-20s", tmp);
} }
printf_wrapper(out, "\n"); printf_wrapper(out, "\n");

View file

@ -1264,7 +1264,7 @@ begin:
c = 0; c = 0;
} }
reg.a[a] = (VM_UBYTE *)reg.a[B] + c; reg.a[a] = (VM_UBYTE *)reg.a[B] + c;
reg.atag[a] = c == 0 ? reg.atag[B] : ATAG_GENERIC; reg.atag[a] = c == 0 ? reg.atag[B] : (int)ATAG_GENERIC;
NEXTOP; NEXTOP;
OP(ADDA_RK): OP(ADDA_RK):
ASSERTA(a); ASSERTA(B); ASSERTKD(C); ASSERTA(a); ASSERTA(B); ASSERTKD(C);

View file

@ -168,7 +168,8 @@ static void DoParse(const char *filename)
failed = false; failed = false;
#ifdef _DEBUG #ifdef _DEBUG
FILE *f = fopen("trace.txt", "w"); FILE *f = fopen("trace.txt", "w");
ZCCParseTrace(f, ""); char prompt = '\0';
ZCCParseTrace(f, &prompt);
#endif #endif
ZCCParseState state(sc); ZCCParseState state(sc);
@ -232,12 +233,14 @@ static void DoParse(const char *filename)
FString ast = ZCC_PrintAST(state.TopNode); FString ast = ZCC_PrintAST(state.TopNode);
FString astfile = ExtractFileBase(filename, false); FString astfile = ExtractFileBase(filename, false);
astfile << ".ast"; astfile << ".ast";
#ifdef _DEBUG
f = fopen(astfile, "w"); f = fopen(astfile, "w");
if (f != NULL) if (f != NULL)
{ {
fputs(ast.GetChars(), f); fputs(ast.GetChars(), f);
fclose(f); fclose(f);
} }
#endif
} }
CCMD(parse) CCMD(parse)
@ -255,7 +258,7 @@ static FString ZCCTokenName(int terminal)
return "end of file"; return "end of file";
} }
int sc_token; int sc_token;
if (terminal > 0 && terminal < countof(BackTokenMap)) if (terminal > 0 && terminal < (int)countof(BackTokenMap))
{ {
sc_token = BackTokenMap[terminal]; sc_token = BackTokenMap[terminal];
if (sc_token == 0) if (sc_token == 0)

View file

@ -300,13 +300,13 @@ ACTOR Actor native //: Thinker
action native A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); action native A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);
action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER); action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER);
action native ACS_NamedExecute(string script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); action native ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0);
action native ACS_NamedSuspend(string script, int mapnum=0); action native ACS_NamedSuspend(name script, int mapnum=0);
action native ACS_NamedTerminate(string script, int mapnum=0); action native ACS_NamedTerminate(name script, int mapnum=0);
action native ACS_NamedLockedExecute(string script, int mapnum=0, int arg1=0, int arg2=0, int lock=0); action native ACS_NamedLockedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0);
action native ACS_NamedLockedExecuteDoor(string script, int mapnum=0, int arg1=0, int arg2=0, int lock=0); action native ACS_NamedLockedExecuteDoor(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0);
action native ACS_NamedExecuteWithResult(string script, int arg1=0, int arg2=0, int arg3=0, int arg4=0); action native ACS_NamedExecuteWithResult(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0);
action native ACS_NamedExecuteAlways(string script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); action native ACS_NamedExecuteAlways(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0);
States States
{ {