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 committed by Rachael Alexanderson
parent dc6f116315
commit b84d28e9a7
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0

View file

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