1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 22:34:09 +02:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Brian Fiete 2023-01-23 06:57:06 -05:00
commit 59f074ba83
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)] [AttributeUsage(.Method | .Constructor | .Class | .Struct | .Alias | .Interface | .Property)]
public struct ObsoleteAttribute : Attribute public struct ObsoleteAttribute : Attribute
{ {
public this()
{
}
public this(bool isError) public this(bool isError)
{ {
} }
public this(String error)
{
}
public this(String error, bool isError) public this(String error, bool isError)
{ {

View file

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