Allow using Self as the class name in the default block to refer to the current class

This commit is contained in:
Ricardo Luís Vaz Silva 2024-10-25 21:32:52 -03:00
parent 2ba57b5068
commit 7b95977e2a

View file

@ -724,8 +724,15 @@ void ZCCDoomCompiler::ProcessDefaultProperty(PClassActor *cls, ZCC_PropertyStmt
}
else if (namenode->SiblingNext->SiblingNext == namenode)
{
FName name(namenode->Id);
if(name == NAME_self)
{
name = cls->TypeName;
}
// a two-name property
propname << FName(namenode->Id).GetChars() << "." << FName(static_cast<ZCC_Identifier *>(namenode->SiblingNext)->Id).GetChars();
propname << name.GetChars() << "." << FName(static_cast<ZCC_Identifier *>(namenode->SiblingNext)->Id).GetChars();
}
else
{
@ -784,6 +791,13 @@ void ZCCDoomCompiler::ProcessDefaultFlag(PClassActor *cls, ZCC_FlagStmt *flg)
else if (namenode->SiblingNext->SiblingNext == namenode)
{
// a two-name flag
if(namenode->Id == NAME_self)
{
n1 = cls->TypeName.GetChars();
}
n2 = FName(static_cast<ZCC_Identifier *>(namenode->SiblingNext)->Id).GetChars();
}
else