mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-12 07:05:21 +00:00
- Added a new intrinsic for class pointers to check if the class is abstract (#1308)
This commit is contained in:
parent
cdb24b214a
commit
387abf81a0
3 changed files with 69 additions and 0 deletions
|
@ -305,6 +305,7 @@ xx(BuiltinNew)
|
||||||
xx(GetClass)
|
xx(GetClass)
|
||||||
xx(GetParentClass)
|
xx(GetParentClass)
|
||||||
xx(GetClassName)
|
xx(GetClassName)
|
||||||
|
xx(IsAbstract)
|
||||||
xx(GetDefaultByType)
|
xx(GetDefaultByType)
|
||||||
xx(Exp)
|
xx(Exp)
|
||||||
xx(Log10)
|
xx(Log10)
|
||||||
|
|
|
@ -8256,6 +8256,14 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
return x->Resolve(ctx);
|
return x->Resolve(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MethodName == NAME_IsAbstract && Self->ValueType->isClassPointer())
|
||||||
|
{
|
||||||
|
if (CheckArgSize(NAME_IsAbstract, ArgList, 0, 0, ScriptPosition))
|
||||||
|
{
|
||||||
|
auto x = new FxIsAbstract(Self);
|
||||||
|
return x->Resolve(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Self->ValueType->isRealPointer())
|
if (Self->ValueType->isRealPointer())
|
||||||
{
|
{
|
||||||
|
@ -9252,6 +9260,47 @@ ExpEmit FxGetClassName::Emit(VMFunctionBuilder *build)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
FxIsAbstract::FxIsAbstract(FxExpression *self)
|
||||||
|
:FxExpression(EFX_IsAbstract, self->ScriptPosition)
|
||||||
|
{
|
||||||
|
Self = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
FxIsAbstract::~FxIsAbstract()
|
||||||
|
{
|
||||||
|
SAFE_DELETE(Self);
|
||||||
|
}
|
||||||
|
|
||||||
|
FxExpression *FxIsAbstract::Resolve(FCompileContext &ctx)
|
||||||
|
{
|
||||||
|
SAFE_RESOLVE(Self, ctx);
|
||||||
|
|
||||||
|
if (!Self->ValueType->isClassPointer())
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "IsAbstract() requires a class pointer");
|
||||||
|
delete this;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
ValueType = TypeBool;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpEmit FxIsAbstract::Emit(VMFunctionBuilder *build)
|
||||||
|
{
|
||||||
|
ExpEmit op = Self->Emit(build);
|
||||||
|
op.Free(build);
|
||||||
|
|
||||||
|
ExpEmit to(build, REGT_INT);
|
||||||
|
build->Emit(OP_LBU, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, bAbstract)));
|
||||||
|
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
FxColorLiteral::FxColorLiteral(FArgumentList &args, FScriptPosition &sc)
|
FxColorLiteral::FxColorLiteral(FArgumentList &args, FScriptPosition &sc)
|
||||||
:FxExpression(EFX_ColorLiteral, sc)
|
:FxExpression(EFX_ColorLiteral, sc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -298,6 +298,7 @@ enum EFxType
|
||||||
EFX_GetClass,
|
EFX_GetClass,
|
||||||
EFX_GetParentClass,
|
EFX_GetParentClass,
|
||||||
EFX_GetClassName,
|
EFX_GetClassName,
|
||||||
|
EFX_IsAbstract,
|
||||||
EFX_StrLen,
|
EFX_StrLen,
|
||||||
EFX_ColorLiteral,
|
EFX_ColorLiteral,
|
||||||
EFX_GetDefaultByType,
|
EFX_GetDefaultByType,
|
||||||
|
@ -1663,6 +1664,24 @@ public:
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// FxIsAbstract
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
class FxIsAbstract : public FxExpression
|
||||||
|
{
|
||||||
|
FxExpression* Self;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
FxIsAbstract(FxExpression* self);
|
||||||
|
~FxIsAbstract();
|
||||||
|
FxExpression *Resolve(FCompileContext&);
|
||||||
|
ExpEmit Emit(VMFunctionBuilder* build);
|
||||||
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FxColorLiteral
|
// FxColorLiteral
|
||||||
|
|
Loading…
Reference in a new issue