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

Method GetReflectKind

IDEHelper/Compiler/BfModule.cpp:16687–16752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16685}
16686
16687BfReflectKind BfModule::GetReflectKind(BfReflectKind reflectKind, BfTypeInstance* typeInstance)
16688{
16689 auto checkTypeInstance = typeInstance;
16690 while (checkTypeInstance != NULL)
16691 {
16692 if (checkTypeInstance->mCustomAttributes != NULL)
16693 {
16694 auto checkReflectKind = BfReflectKind_None;
16695
16696 for (auto& customAttr : checkTypeInstance->mCustomAttributes->mAttributes)
16697 {
16698 if (customAttr.mType->mTypeDef->mName->ToString() == "ReflectAttribute")
16699 {
16700 if (customAttr.mCtorArgs.size() > 0)
16701 {
16702 auto constant = checkTypeInstance->mConstHolder->GetConstant(customAttr.mCtorArgs[0]);
16703 checkReflectKind = (BfReflectKind)((int)checkReflectKind | constant->mInt32);
16704 }
16705 else
16706 {
16707 checkReflectKind = BfReflectKind_All;
16708 }
16709 }
16710 else
16711 {
16712 auto userReflectKind = GetUserReflectKind(customAttr.mType);
16713 checkReflectKind = (BfReflectKind)(checkReflectKind | userReflectKind);
16714 }
16715 }
16716
16717 if ((checkTypeInstance == typeInstance) ||
16718 ((checkReflectKind & BfReflectKind_ApplyToInnerTypes) != 0))
16719 {
16720 reflectKind = (BfReflectKind)(reflectKind | checkReflectKind);
16721 }
16722 }
16723
16724 for (auto ifaceEntry : typeInstance->mInterfaces)
16725 {
16726 if (ifaceEntry.mInterfaceType->mCustomAttributes != NULL)
16727 {
16728 auto iface = ifaceEntry.mInterfaceType;
16729 auto customAttr = iface->mCustomAttributes->Get(mCompiler->mReflectAttributeTypeDef);
16730 if (customAttr != NULL)
16731 {
16732 for (auto& prop : customAttr->mSetProperties)
16733 {
16734 auto propDef = prop.mPropertyRef.mTypeInstance->mTypeDef->mProperties[prop.mPropertyRef.mPropIdx];
16735 if (propDef->mName == "ReflectImplementer")
16736 {
16737 if (prop.mParam.mValue.IsConst())
16738 {
16739 auto constant = iface->mConstHolder->GetConstant(prop.mParam.mValue);
16740 reflectKind = (BfReflectKind)(reflectKind | (BfReflectKind)constant->mInt32);
16741 }
16742 }
16743 }
16744 }

Callers 1

PopulateReifiedMethod · 0.80

Calls 6

GetOuterTypeMethod · 0.80
ToStringMethod · 0.45
sizeMethod · 0.45
GetConstantMethod · 0.45
GetMethod · 0.45
IsConstMethod · 0.45

Tested by

no test coverage detected