mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-05-30 08:31:29 +00:00
- implemented super calls and proper dispatch of scripted virtual overrides for Destroy.
This commit is contained in:
parent
72e77a6c65
commit
924096694e
5 changed files with 93 additions and 4 deletions
|
@ -1350,7 +1350,7 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx)
|
|||
// first deal with the simple types
|
||||
if (ValueType == TypeError || basex->ValueType == TypeError)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Trying to cast to invalid type. This error message means that somewhere in the script compiler an error check is missing.");
|
||||
ScriptPosition.Message(MSG_ERROR, "Trying to cast to invalid type.");
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -5433,6 +5433,25 @@ ExpEmit FxSelf::Emit(VMFunctionBuilder *build)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FxExpression *FxSuper::Resolve(FCompileContext& ctx)
|
||||
{
|
||||
CHECKRESOLVED();
|
||||
if (ctx.Function == nullptr || ctx.Function->Variants[0].SelfClass == nullptr)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "super used outside of a member function");
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
ValueType = TypeError; // this intentionally resolves to an invalid type so that it cannot be used outside of super calls.
|
||||
return this;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -6268,6 +6287,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
ABORT(ctx.Class);
|
||||
PClass *cls;
|
||||
bool staticonly = false;
|
||||
bool novirtual = false;
|
||||
|
||||
if (Self->ExprType == EFX_Identifier)
|
||||
{
|
||||
|
@ -6282,6 +6302,15 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
}
|
||||
SAFE_RESOLVE(Self, ctx);
|
||||
|
||||
if (Self->ExprType == EFX_Super)
|
||||
{
|
||||
// give the node the proper value type now that we know it's properly used.
|
||||
cls = ctx.Function->Variants[0].SelfClass->ParentClass;
|
||||
Self->ValueType = NewPointer(cls);
|
||||
Self->ExprType = EFX_Self;
|
||||
novirtual = true; // super calls are always non-virtual
|
||||
}
|
||||
|
||||
if (Self->IsVector())
|
||||
{
|
||||
// handle builtins: Vectors got 2: Length and Unit.
|
||||
|
@ -6349,7 +6378,7 @@ isresolved:
|
|||
|
||||
// do not pass the self pointer to static functions.
|
||||
auto self = (afd->Variants[0].Flags & VARF_Method) ? Self : nullptr;
|
||||
auto x = new FxVMFunctionCall(self, afd, ArgList, ScriptPosition, staticonly);
|
||||
auto x = new FxVMFunctionCall(self, afd, ArgList, ScriptPosition, staticonly|novirtual);
|
||||
if (Self == self) Self = nullptr;
|
||||
delete this;
|
||||
return x->Resolve(ctx);
|
||||
|
@ -6971,6 +7000,11 @@ FxExpression *FxSequence::Resolve(FCompileContext &ctx)
|
|||
{
|
||||
fail = true;
|
||||
}
|
||||
if (Expressions[i]->ValueType == TypeError)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Invalid statement");
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
if (fail)
|
||||
{
|
||||
|
|
|
@ -276,6 +276,7 @@ enum EFxType
|
|||
EFX_TypeCheck,
|
||||
EFX_DynamicCast,
|
||||
EFX_GlobalVariable,
|
||||
EFX_Super,
|
||||
EFX_COUNT
|
||||
};
|
||||
|
||||
|
@ -1241,6 +1242,23 @@ public:
|
|||
ExpEmit Emit(VMFunctionBuilder *build);
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxSuper
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
class FxSuper : public FxSelf
|
||||
{
|
||||
public:
|
||||
FxSuper(const FScriptPosition&pos)
|
||||
: FxSelf(pos)
|
||||
{
|
||||
ExprType = EFX_Super;
|
||||
}
|
||||
FxExpression *Resolve(FCompileContext&);
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxArrayElement
|
||||
|
|
|
@ -2898,6 +2898,16 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast)
|
|||
return list;
|
||||
}
|
||||
|
||||
case AST_Expression:
|
||||
{
|
||||
auto ret = static_cast<ZCC_Expression *>(ast);
|
||||
if (ret->Operation == PEX_Super)
|
||||
{
|
||||
return new FxSuper(*ast);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AST_ExpressionStmt:
|
||||
return ConvertNode(static_cast<ZCC_ExpressionStmt *>(ast)->Expression);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue