mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
fix builtin attrib matching
This commit is contained in:
parent
4d0f4b76bc
commit
b58c0d4055
7 changed files with 38 additions and 7 deletions
|
@ -1195,6 +1195,23 @@ bool BfTypeReference::IsTypeDefTypeReference()
|
|||
return IsA<BfNamedTypeReference>() || IsA<BfDirectStrTypeReference>() || IsA<BfDirectTypeDefReference>();
|
||||
}
|
||||
|
||||
String BfTypeReference::ToCleanAttributeString()
|
||||
{
|
||||
// ToString might return something like "System.InlineAttribute", which we want to clean before we test for "Inline"
|
||||
auto typeRefName = ToString();
|
||||
if (typeRefName.EndsWith("Attribute"))
|
||||
{
|
||||
int attribNameStart = (int)typeRefName.LastIndexOf('.');
|
||||
if (attribNameStart != -1)
|
||||
typeRefName.Remove(0, attribNameStart + 1);
|
||||
|
||||
if (typeRefName.EndsWith("Attribute"))
|
||||
typeRefName.RemoveFromEnd(9);
|
||||
}
|
||||
|
||||
return typeRefName;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BfPropertyMethodDeclaration* BfPropertyDeclaration::GetMethod(const StringImpl& findName)
|
||||
|
@ -1262,6 +1279,10 @@ bool BfAttributeDirective::Contains(const StringImpl& findName)
|
|||
return true;
|
||||
if (name.EndsWith("Attribute"))
|
||||
{
|
||||
int attribNameStart = (int)name.LastIndexOf('.');
|
||||
if (attribNameStart != -1)
|
||||
name.Remove(0, attribNameStart + 1);
|
||||
|
||||
name.RemoveToEnd(name.length() - 9);
|
||||
if (findName == name)
|
||||
return true;
|
||||
|
|
|
@ -2329,6 +2329,7 @@ public:
|
|||
|
||||
bool IsNamedTypeReference();
|
||||
bool IsTypeDefTypeReference();
|
||||
String ToCleanAttributeString();
|
||||
|
||||
}; BF_AST_DECL(BfTypeReference, BfAstNode);
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
|
||||
if (typeRefName == "StdCall")
|
||||
methodDef->mCallingConvention = BfCallingConvention_Stdcall;
|
||||
|
@ -788,7 +788,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
|
||||
if (typeRefName == "CLink")
|
||||
methodDef->mCLink = true;
|
||||
|
@ -874,7 +874,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfTypeDef*
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
|
||||
if (typeRefName == "AlwaysInclude")
|
||||
typeDef->mIsAlwaysInclude = true;
|
||||
|
@ -2098,7 +2098,7 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
|
||||
if (typeRefName == "ThreadStatic")
|
||||
hasThreadStatics = true;
|
||||
|
|
|
@ -2367,7 +2367,7 @@ void BfMangler::HandleParamCustomAttributes(BfAttributeDirective* attributes, bo
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
if (typeRefName == "MangleConst")
|
||||
isConst = true;
|
||||
}
|
||||
|
|
|
@ -11367,7 +11367,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
|
|||
{
|
||||
if (prevCustomAttribute.mType == attrTypeInst)
|
||||
{
|
||||
Fail(StrFormat("Duplicate '%s' attribute", attributesDirective->mAttributeTypeRef->ToString().c_str()), attributesDirective->mAttributeTypeRef); // CS0579
|
||||
Fail(StrFormat("Duplicate '%s' attribute", attributesDirective->mAttributeTypeRef->ToCleanAttributeString().c_str()), attributesDirective->mAttributeTypeRef); // CS0579
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5158,7 +5158,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|||
{
|
||||
if (attributes->mAttributeTypeRef != NULL)
|
||||
{
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||
|
||||
if (typeRefName == "AlwaysInclude")
|
||||
implRequired = true;
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
namespace Tests
|
||||
{
|
||||
typealias DDDDAttribute = System.InlineAttribute;
|
||||
|
||||
class Program
|
||||
{
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
A();
|
||||
}
|
||||
|
||||
[DDDD]
|
||||
public static void A()
|
||||
{
|
||||
int i = 1 + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue