MCPcopy Create free account
hub / github.com/beefytech/Beef / ProcessCustomAttributeData

Method ProcessCustomAttributeData

IDEHelper/Compiler/BfModule.cpp:13223–13311  ·  view source on GitHub ↗

Checking to see if we're an attribute or not

Source from the content-addressed store, hash-verified

13221
13222// Checking to see if we're an attribute or not
13223void BfModule::ProcessCustomAttributeData()
13224{
13225 if (mCurTypeInstance->mAttributeData != NULL)
13226 return;
13227
13228 bool isAttribute = false;
13229 auto checkTypeInst = mCurTypeInstance->mBaseType;
13230 while (checkTypeInst != NULL)
13231 {
13232 if (checkTypeInst->IsInstanceOf(mCompiler->mAttributeTypeDef))
13233 isAttribute = true;
13234 checkTypeInst = checkTypeInst->mBaseType;
13235 }
13236 if (!isAttribute)
13237 return;
13238
13239 auto attributeData = new BfAttributeData();
13240 bool hasCustomAttribute = false;
13241
13242 if (mCurTypeInstance->mCustomAttributes != NULL)
13243 {
13244 for (auto& customAttribute : mCurTypeInstance->mCustomAttributes->mAttributes)
13245 {
13246 if (customAttribute.mType->IsInstanceOf(mCompiler->mAttributeUsageAttributeTypeDef))
13247 {
13248 if (customAttribute.mCtorArgs.size() > 0)
13249 {
13250 auto constant = mCurTypeInstance->mConstHolder->GetConstant(customAttribute.mCtorArgs[0]);
13251 if ((constant != NULL) && (mBfIRBuilder->IsInt(constant->mTypeCode)))
13252 attributeData->mAttributeTargets = (BfAttributeTargets)constant->mInt32;
13253 }
13254
13255 if (customAttribute.mCtorArgs.size() == 2)
13256 {
13257 auto constant = mCurTypeInstance->mConstHolder->GetConstant(customAttribute.mCtorArgs[0]);
13258 if ((constant != NULL) && (mBfIRBuilder->IsInt(constant->mTypeCode)))
13259 {
13260 attributeData->mFlags = (BfAttributeFlags)constant->mInt32;
13261 }
13262 }
13263
13264 for (auto& setProp : customAttribute.mSetProperties)
13265 {
13266 BfPropertyDef* propDef = setProp.mPropertyRef;
13267
13268 if (propDef->mName == "AllowMultiple")
13269 {
13270 auto constant = mCurTypeInstance->mConstHolder->GetConstant(setProp.mParam.mValue);
13271 if ((constant != NULL) && (constant->mBool))
13272 attributeData->mFlags = (BfAttributeFlags)(attributeData->mFlags & ~BfAttributeFlag_DisallowAllowMultiple);
13273 else
13274 attributeData->mFlags = (BfAttributeFlags)(attributeData->mFlags | BfAttributeFlag_DisallowAllowMultiple);
13275 }
13276 else if (propDef->mName == "Inherited")
13277 {
13278 auto constant = mCurTypeInstance->mConstHolder->GetConstant(setProp.mParam.mValue);
13279 if ((constant != NULL) && (constant->mBool))
13280 attributeData->mFlags = (BfAttributeFlags)(attributeData->mFlags & ~BfAttributeFlag_NotInherited);

Callers

nothing calls this directly

Calls 4

IsInstanceOfMethod · 0.45
sizeMethod · 0.45
GetConstantMethod · 0.45
IsIntMethod · 0.45

Tested by

no test coverage detected