1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Merge pull request #1784 from disarray2077/patch-2

Add more constructors to `ObsoleteAttribute`
This commit is contained in:
Brian Fiete 2023-01-14 06:44:39 -05:00 committed by GitHub
commit 6a5c424f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 15 deletions

View file

@ -505,11 +505,21 @@ namespace System
[AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Interface | .Property)]
public struct ObsoleteAttribute : Attribute
{
public this()
{
}
public this(bool isError)
{
}
public this(String error)
{
}
public this(String error, bool isError)
{

View file

@ -3414,7 +3414,7 @@ void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstan
BfIRConstHolder* constHolder = typeInstance->mConstHolder;
auto customAttribute = customAttributes->Get(mCompiler->mObsoleteAttributeTypeDef);
if ((customAttribute != NULL) && (!customAttribute->mCtorArgs.IsEmpty()) && (targetSrc != NULL))
if ((customAttribute != NULL) && (targetSrc != NULL))
{
String err;
if (fieldInstance != NULL)
@ -3426,12 +3426,14 @@ void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstan
bool isError = false;
if (customAttribute->mCtorArgs.size() >= 1)
{
auto constant = constHolder->GetConstant(customAttribute->mCtorArgs[0]);
if (constant->mTypeCode == BfTypeCode_Boolean)
{
isError = constant->mBool;
}
else if (customAttribute->mCtorArgs.size() >= 2)
else if (constant->mTypeCode == BfTypeCode_StringId)
{
String* str = GetStringPoolString(customAttribute->mCtorArgs[0], constHolder);
if (str != NULL)
@ -3441,9 +3443,13 @@ void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstan
err += "'";
}
if (customAttribute->mCtorArgs.size() >= 2)
{
constant = constHolder->GetConstant(customAttribute->mCtorArgs[1]);
isError = constant->mBool;
}
}
}
BfError* error = NULL;
if (isError)