1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Allow ref property setter specifier

This commit is contained in:
Brian Fiete 2021-11-27 09:05:23 -08:00
parent 0d837d23cb
commit 40b0d78d16
6 changed files with 38 additions and 9 deletions

View file

@ -1078,12 +1078,19 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
if (BfNodeDynCast<BfTokenNode>(methodDeclaration->mBody) != NULL)
methodDef->mIsMutating = true; // Don't require "set mut;", just "set;"
auto paramDef = new BfParameterDef();
auto paramDef = new BfParameterDef();
paramDef->mName = "value";
if (auto refTypeRef = BfNodeDynCast<BfRefTypeRef>(propertyDeclaration->mTypeRef))
paramDef->mTypeRef = refTypeRef->mElementType;
paramDef->mTypeRef = propertyDeclaration->mTypeRef;
if (auto refTypeRef = BfNodeDynCast<BfRefTypeRef>(propertyDeclaration->mTypeRef))
{
if (methodDeclaration->mSetRefSpecifier == NULL)
paramDef->mTypeRef = refTypeRef->mElementType;
}
else
paramDef->mTypeRef = propertyDeclaration->mTypeRef;
{
if (methodDeclaration->mSetRefSpecifier != NULL)
Fail("Property setter 'ref' can only be used with a 'ref' property type", methodDeclaration->mSetRefSpecifier);
}
methodDef->mParams.Insert(0, paramDef);
propertyDef->mMethods.Add(methodDef);
}