- ensure proper emission of deprecations.

For global variables this wasn't implemented.

# Conflicts:
#	src/namedef.h
#	src/scripting/backend/codegen.cpp
#	wadsrc/static/zscript/base.txt
This commit is contained in:
Christoph Oelckers 2019-01-12 16:36:21 +01:00
parent c6ee8e084c
commit 7c3ec662e1
5 changed files with 30 additions and 10 deletions

View file

@ -1072,4 +1072,4 @@ xx(SpotOuterAngle)
xx(lightflags)
xx(lighttype)
xx(InternalDynamicLight)
xx(_a_chase_default)
xx(_a_chase_default)

View file

@ -164,7 +164,7 @@ struct FScriptPosition
static int ErrorCounter;
static bool StrictErrors;
static bool errorout;
FString FileName;
FName FileName;
int ScriptLine;
FScriptPosition()

View file

@ -6114,6 +6114,15 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
// internally defined global variable
ScriptPosition.Message(MSG_DEBUGLOG, "Resolving name '%s' as global variable\n", Identifier.GetChars());
if ((vsym->Flags & VARF_Deprecated))
{
if (sym->mVersion <= ctx.Version)
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated global variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
}
}
newex = new FxGlobalVariable(static_cast<PField *>(sym), ScriptPosition);
goto foundit;
}
@ -6201,9 +6210,12 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType *
object = nullptr;
return nullptr;
}
if ((vsym->Flags & VARF_Deprecated) && sym->mVersion <= ctx.Version)
if ((vsym->Flags & VARF_Deprecated))
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
if (sym->mVersion <= ctx.Version)
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
}
}
// We have 4 cases to consider here:
@ -8625,6 +8637,7 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
emitters.AddParameterIntConst(abs(Special)); // pass special number
emitters.AddParameter(build, Self);
for (; i < ArgList.Size(); ++i)
{
FxExpression *argex = ArgList[i];
@ -8711,9 +8724,12 @@ bool FxVMFunctionCall::CheckAccessibility(const VersionInfo &ver)
ScriptPosition.Message(MSG_ERROR, "%s not accessible to %s", Function->SymbolName.GetChars(), VersionString.GetChars());
return false;
}
if ((Function->Variants[0].Flags & VARF_Deprecated) && Function->mVersion <= ver)
if ((Function->Variants[0].Flags & VARF_Deprecated))
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated function %s - deprecated since %d.%d.%d", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision);
if (Function->mVersion <= ver)
{
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated function %s - deprecated since %d.%d.%d", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision);
}
}
return true;
}

View file

@ -1348,13 +1348,18 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
}
else
{
// This is a global variable.
if (fd->BitValue != 0) thisfieldtype = fd->FieldSize == 1 ? TypeUInt8 : fd->FieldSize == 2 ? TypeUInt16 : TypeUInt32;
PField *field = Create<PField>(name->Name, thisfieldtype, varflags | VARF_Native | VARF_Static, fd->FieldOffset, fd->BitValue);
PField *f = Create<PField>(name->Name, thisfieldtype, varflags | VARF_Native | VARF_Static, fd->FieldOffset, fd->BitValue);
if (f->Flags & (ZCC_Version | ZCC_Deprecated))
{
f->mVersion = field->Version;
}
if (OutNamespace->Symbols.AddSymbol(field) == nullptr)
if (OutNamespace->Symbols.AddSymbol(f) == nullptr)
{ // name is already in use
field->Destroy();
f->Destroy();
return false;
}
}

View file

@ -615,7 +615,6 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe
for (i = 0; i<anims.Size(); i++)
{
in_anim_t * a = &anims[i];
level_info_t * li;
switch (a->type & ANIM_CONDITION)
{