- 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 committed by drfrag
parent a259cd700d
commit d0c609eeee
4 changed files with 29 additions and 9 deletions

View file

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

View file

@ -6119,6 +6119,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;
}
@ -6206,9 +6215,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:
@ -8630,6 +8642,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];
@ -8716,9 +8729,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

@ -1357,13 +1357,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

@ -621,7 +621,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)
{