mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
AllowDuplicatesAttribute
This commit is contained in:
parent
2618b29daa
commit
8808da307f
13 changed files with 39 additions and 2 deletions
|
@ -762,6 +762,15 @@ bool BfAstNode::IsExpression()
|
|||
return IsA<BfExpression>();
|
||||
}
|
||||
|
||||
bool BfAstNode::WantsWarning(int warningNumber)
|
||||
{
|
||||
auto parserData = GetParserData();
|
||||
if (parserData == NULL)
|
||||
return true;
|
||||
int srcStart = GetSrcStart();
|
||||
return (!parserData->IsUnwarnedAt(this)) && (parserData->IsWarningEnabledAtSrcIndex(warningNumber, GetSrcStart()));
|
||||
}
|
||||
|
||||
bool BfAstNode::LocationEquals(BfAstNode* otherNode)
|
||||
{
|
||||
return (GetSourceData() == otherNode->GetSourceData()) &&
|
||||
|
|
|
@ -1040,6 +1040,7 @@ public:
|
|||
void Add(BfAstNode* bfAstNode);
|
||||
bool IsMissingSemicolon();
|
||||
bool IsExpression();
|
||||
bool WantsWarning(int warningNumber);
|
||||
|
||||
template <typename T>
|
||||
bool IsA()
|
||||
|
|
|
@ -382,6 +382,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
|||
mImportAttributeTypeDef = NULL;
|
||||
mCReprAttributeTypeDef = NULL;
|
||||
mAlignAttributeTypeDef = NULL;
|
||||
mAllowDuplicatesAttributeTypeDef = NULL;
|
||||
mNoDiscardAttributeTypeDef = NULL;
|
||||
mDisableChecksAttributeTypeDef = NULL;
|
||||
mDisableObjectAccessChecksAttributeTypeDef = NULL;
|
||||
|
@ -5856,6 +5857,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
mImportAttributeTypeDef = _GetRequiredType("System.ImportAttribute");
|
||||
mCReprAttributeTypeDef = _GetRequiredType("System.CReprAttribute");
|
||||
mAlignAttributeTypeDef = _GetRequiredType("System.AlignAttribute");
|
||||
mAllowDuplicatesAttributeTypeDef = _GetRequiredType("System.AllowDuplicatesAttribute");
|
||||
mNoDiscardAttributeTypeDef = _GetRequiredType("System.NoDiscardAttribute");
|
||||
mDisableChecksAttributeTypeDef = _GetRequiredType("System.DisableChecksAttribute");
|
||||
mDisableObjectAccessChecksAttributeTypeDef = _GetRequiredType("System.DisableObjectAccessChecksAttribute");
|
||||
|
|
|
@ -380,6 +380,7 @@ public:
|
|||
BfTypeDef* mImportAttributeTypeDef;
|
||||
BfTypeDef* mCReprAttributeTypeDef;
|
||||
BfTypeDef* mAlignAttributeTypeDef;
|
||||
BfTypeDef* mAllowDuplicatesAttributeTypeDef;
|
||||
BfTypeDef* mNoDiscardAttributeTypeDef;
|
||||
BfTypeDef* mDisableChecksAttributeTypeDef;
|
||||
BfTypeDef* mDisableObjectAccessChecksAttributeTypeDef;
|
||||
|
|
|
@ -2940,7 +2940,7 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
|||
}
|
||||
}
|
||||
|
||||
if ((mModule->mCurMethodInstance == NULL) && (mModule->mCurTypeInstance->IsEnum()))
|
||||
if ((mModule->mCurMethodInstance == NULL) && (mModule->mCurTypeInstance != NULL) && (mModule->mCurTypeInstance->IsEnum()))
|
||||
{
|
||||
if (findName == "_")
|
||||
{
|
||||
|
|
|
@ -2990,7 +2990,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
{
|
||||
*fieldDefPtr = fieldDef;
|
||||
}
|
||||
else
|
||||
else if ((typeInstance->mCustomAttributes == NULL) || (typeInstance->mCustomAttributes->Get(mCompiler->mAllowDuplicatesAttributeTypeDef) == NULL))
|
||||
{
|
||||
auto error = Warn(0, StrFormat("Enum value '%lld' for field '%s' is not unique", foreignConst->mInt64, fieldDef->mName.c_str()), fieldDef->GetRefNode(), true);
|
||||
if (error != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue