mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +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>();
|
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)
|
BfPropertyMethodDeclaration* BfPropertyDeclaration::GetMethod(const StringImpl& findName)
|
||||||
|
@ -1262,6 +1279,10 @@ bool BfAttributeDirective::Contains(const StringImpl& findName)
|
||||||
return true;
|
return true;
|
||||||
if (name.EndsWith("Attribute"))
|
if (name.EndsWith("Attribute"))
|
||||||
{
|
{
|
||||||
|
int attribNameStart = (int)name.LastIndexOf('.');
|
||||||
|
if (attribNameStart != -1)
|
||||||
|
name.Remove(0, attribNameStart + 1);
|
||||||
|
|
||||||
name.RemoveToEnd(name.length() - 9);
|
name.RemoveToEnd(name.length() - 9);
|
||||||
if (findName == name)
|
if (findName == name)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2329,6 +2329,7 @@ public:
|
||||||
|
|
||||||
bool IsNamedTypeReference();
|
bool IsNamedTypeReference();
|
||||||
bool IsTypeDefTypeReference();
|
bool IsTypeDefTypeReference();
|
||||||
|
String ToCleanAttributeString();
|
||||||
|
|
||||||
}; BF_AST_DECL(BfTypeReference, BfAstNode);
|
}; BF_AST_DECL(BfTypeReference, BfAstNode);
|
||||||
|
|
||||||
|
|
|
@ -555,7 +555,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
|
||||||
if (typeRefName == "StdCall")
|
if (typeRefName == "StdCall")
|
||||||
methodDef->mCallingConvention = BfCallingConvention_Stdcall;
|
methodDef->mCallingConvention = BfCallingConvention_Stdcall;
|
||||||
|
@ -788,7 +788,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
|
||||||
if (typeRefName == "CLink")
|
if (typeRefName == "CLink")
|
||||||
methodDef->mCLink = true;
|
methodDef->mCLink = true;
|
||||||
|
@ -874,7 +874,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfTypeDef*
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
|
||||||
if (typeRefName == "AlwaysInclude")
|
if (typeRefName == "AlwaysInclude")
|
||||||
typeDef->mIsAlwaysInclude = true;
|
typeDef->mIsAlwaysInclude = true;
|
||||||
|
@ -2098,7 +2098,7 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
|
||||||
if (typeRefName == "ThreadStatic")
|
if (typeRefName == "ThreadStatic")
|
||||||
hasThreadStatics = true;
|
hasThreadStatics = true;
|
||||||
|
|
|
@ -2367,7 +2367,7 @@ void BfMangler::HandleParamCustomAttributes(BfAttributeDirective* attributes, bo
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
if (typeRefName == "MangleConst")
|
if (typeRefName == "MangleConst")
|
||||||
isConst = true;
|
isConst = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11367,7 +11367,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
|
||||||
{
|
{
|
||||||
if (prevCustomAttribute.mType == attrTypeInst)
|
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)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
|
||||||
if (typeRefName == "AlwaysInclude")
|
if (typeRefName == "AlwaysInclude")
|
||||||
implRequired = true;
|
implRequired = true;
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
namespace Tests
|
namespace Tests
|
||||||
{
|
{
|
||||||
|
typealias DDDDAttribute = System.InlineAttribute;
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void Main()
|
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