1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Reflect Filtered, extension attribs fix, generic arg BfAstNode

This commit is contained in:
Brian Fiete 2022-02-04 12:00:43 -05:00
parent 6315d81207
commit 361be9dc92
13 changed files with 75 additions and 26 deletions

View file

@ -71,7 +71,8 @@ namespace IDE
No, No,
IncludeType, IncludeType,
AssumeInstantiated, AssumeInstantiated,
IncludeAll IncludeAll,
IncludeFiltered
} }
} }

View file

@ -26,8 +26,9 @@ namespace IDE.Compiler
ReflectStaticMethods = 0x800, ReflectStaticMethods = 0x800,
ReflectNonStaticMethods = 0x1000, ReflectNonStaticMethods = 0x1000,
ReflectConstructors = 0x2000, ReflectConstructors = 0x2000,
ReflectAlwaysIncludeFiltered= 0x4000,
All = 0x3FFF All = 0x7FFF
}; };
[CallingConvention(.Stdcall), CLink] [CallingConvention(.Stdcall), CLink]
@ -401,6 +402,8 @@ namespace IDE.Compiler
orFlags |= .ReflectAssumeInstantiated; orFlags |= .ReflectAssumeInstantiated;
case .IncludeAll: case .IncludeAll:
orFlags |= .ReflectAlwaysIncludeType | .ReflectAlwaysIncludeAll | .ReflectAssumeInstantiated; orFlags |= .ReflectAlwaysIncludeType | .ReflectAlwaysIncludeAll | .ReflectAssumeInstantiated;
case .IncludeFiltered:
orFlags |= .ReflectAlwaysIncludeType | .ReflectAlwaysIncludeFiltered | .ReflectAssumeInstantiated;
} }
SetFlag(typeOption.mReflectBoxing, .ReflectBoxing); SetFlag(typeOption.mReflectBoxing, .ReflectBoxing);

View file

@ -2534,7 +2534,7 @@ public:
BF_AST_TYPE(BfGenericInstanceTypeRef, BfElementedTypeRef); BF_AST_TYPE(BfGenericInstanceTypeRef, BfElementedTypeRef);
BfTokenNode* mOpenChevron; BfTokenNode* mOpenChevron;
BfSizedArray<BfTypeReference*> mGenericArguments; BfSizedArray<BfAstNode*> mGenericArguments;
BfSizedArray<ASTREF(BfAstNode*)> mCommas; BfSizedArray<ASTREF(BfAstNode*)> mCommas;
BfTokenNode* mCloseChevron; BfTokenNode* mCloseChevron;
int GetGenericArgCount() int GetGenericArgCount()

View file

@ -2075,7 +2075,8 @@ void BfAutoComplete::CheckTypeRef(BfTypeReference* typeRef, bool mayBeIdentifier
{ {
CheckTypeRef(genericTypeRef->mElementType, mayBeIdentifier, isInExpression, onlyAttribute); CheckTypeRef(genericTypeRef->mElementType, mayBeIdentifier, isInExpression, onlyAttribute);
for (auto genericArg : genericTypeRef->mGenericArguments) for (auto genericArg : genericTypeRef->mGenericArguments)
CheckTypeRef(genericArg, false, isInExpression, false); CheckNode(genericArg);
//CheckTypeRef(genericArg, false, isInExpression, false);
return; return;
} }

View file

@ -11851,6 +11851,8 @@ BfCustomAttributes* BfModule::GetCustomAttributes(BfAttributeDirective* attribut
BfCustomAttributes* BfModule::GetCustomAttributes(BfTypeDef* typeDef) BfCustomAttributes* BfModule::GetCustomAttributes(BfTypeDef* typeDef)
{ {
BF_ASSERT(mCompiler->IsAutocomplete());
BfAttributeTargets attrTarget; BfAttributeTargets attrTarget;
if (typeDef->mIsDelegate) if (typeDef->mIsDelegate)
attrTarget = BfAttributeTargets_Delegate; attrTarget = BfAttributeTargets_Delegate;

View file

@ -1727,7 +1727,7 @@ public:
BfGenericExtensionEntry* BuildGenericExtensionInfo(BfTypeInstance* genericTypeInst, BfTypeDef* partialTypeDef); BfGenericExtensionEntry* BuildGenericExtensionInfo(BfTypeInstance* genericTypeInst, BfTypeDef* partialTypeDef);
bool InitGenericParams(BfType* resolvedTypeRef); bool InitGenericParams(BfType* resolvedTypeRef);
bool FinishGenericParams(BfType* resolvedTypeRef); bool FinishGenericParams(BfType* resolvedTypeRef);
bool ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstance* genericTypeInstance, bool ignoreErrors); bool ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* genericTypeInstance, bool ignoreErrors);
BfType* ResolveGenericMethodTypeRef(BfTypeReference* typeRef, BfMethodInstance* methodInstance, BfGenericParamInstance* genericParamInstance, BfTypeVector* methodGenericArgsOverride); BfType* ResolveGenericMethodTypeRef(BfTypeReference* typeRef, BfMethodInstance* methodInstance, BfGenericParamInstance* genericParamInstance, BfTypeVector* methodGenericArgsOverride);
bool AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGenericParamInstance* checkOuter); bool AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGenericParamInstance* checkOuter);
bool CheckConstraintState(BfAstNode* refNode); bool CheckConstraintState(BfAstNode* refNode);
@ -1852,7 +1852,7 @@ public:
BfTypeInstance* GetBaseType(BfTypeInstance* typeInst); BfTypeInstance* GetBaseType(BfTypeInstance* typeInst);
void HandleTypeGenericParamRef(BfAstNode* refNode, BfTypeDef* typeDef, int typeGenericParamIdx); void HandleTypeGenericParamRef(BfAstNode* refNode, BfTypeDef* typeDef, int typeGenericParamIdx);
void HandleMethodGenericParamRef(BfAstNode* refNode, BfTypeDef* typeDef, BfMethodDef* methodDef, int typeGenericParamIdx); void HandleMethodGenericParamRef(BfAstNode* refNode, BfTypeDef* typeDef, BfMethodDef* methodDef, int typeGenericParamIdx);
bool ResolveTypeResult_Validate(BfTypeReference* typeRef, BfType* resolvedTypeRef); bool ResolveTypeResult_Validate(BfAstNode* typeRef, BfType* resolvedTypeRef);
BfType* ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTypeRef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags); BfType* ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTypeRef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags);
void ShowAmbiguousTypeError(BfAstNode* refNode, BfTypeDef* typeDef, BfTypeDef* otherTypeDef); void ShowAmbiguousTypeError(BfAstNode* refNode, BfTypeDef* typeDef, BfTypeDef* otherTypeDef);
void ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericParams); void ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericParams);
@ -1865,7 +1865,7 @@ public:
void CheckTypeRefFixit(BfAstNode* typeRef, const char* appendName = NULL); void CheckTypeRefFixit(BfAstNode* typeRef, const char* appendName = NULL);
void CheckIdentifierFixit(BfAstNode* node); void CheckIdentifierFixit(BfAstNode* node);
void TypeRefNotFound(BfTypeReference* typeRef, const char* appendName = NULL); void TypeRefNotFound(BfTypeReference* typeRef, const char* appendName = NULL);
bool ValidateTypeWildcard(BfTypeReference* typeRef, bool isAttributeRef); bool ValidateTypeWildcard(BfAstNode* typeRef, bool isAttributeRef);
void GetDelegateTypeRefAttributes(BfDelegateTypeRef* delegateTypeRef, BfCallingConvention& callingConvention); void GetDelegateTypeRefAttributes(BfDelegateTypeRef* delegateTypeRef, BfCallingConvention& callingConvention);
BfType* ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0, int numGenericArgs = 0); BfType* ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0, int numGenericArgs = 0);
BfType* ResolveTypeRefAllowUnboundGenerics(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, bool resolveGenericParam = true); BfType* ResolveTypeRefAllowUnboundGenerics(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, bool resolveGenericParam = true);

View file

@ -300,7 +300,7 @@ bool BfModule::FinishGenericParams(BfType* resolvedTypeRef)
return true; return true;
} }
bool BfModule::ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors) bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors)
{ {
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance())) if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance()))
{ {
@ -1730,8 +1730,6 @@ BfTypeOptions* BfModule::GetTypeOptions(BfTypeDef* typeDef)
if (typeOptions.mEmitDebugInfo != -1) if (typeOptions.mEmitDebugInfo != -1)
mergedTypeOptions.mEmitDebugInfo = typeOptions.mEmitDebugInfo; mergedTypeOptions.mEmitDebugInfo = typeOptions.mEmitDebugInfo;
if (typeOptions.mReflectMethodFilters.IsEmpty())
mergedTypeOptions.mOrFlags = (BfOptionFlags)(mergedTypeOptions.mOrFlags | typeOptions.mOrFlags); mergedTypeOptions.mOrFlags = (BfOptionFlags)(mergedTypeOptions.mOrFlags | typeOptions.mOrFlags);
mergedTypeOptions.mAndFlags = (BfOptionFlags)(mergedTypeOptions.mAndFlags | typeOptions.mOrFlags); mergedTypeOptions.mAndFlags = (BfOptionFlags)(mergedTypeOptions.mAndFlags | typeOptions.mOrFlags);
@ -3835,7 +3833,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (!typeInstance->IsBoxed()) if (!typeInstance->IsBoxed())
{ {
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL)) if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->HasCustomAttributes()))
{ {
BfAttributeTargets attrTarget; BfAttributeTargets attrTarget;
if ((typeDef->mIsDelegate) || (typeDef->mIsFunction)) if ((typeDef->mIsDelegate) || (typeDef->mIsFunction))
@ -5411,8 +5409,12 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
} }
bool typeOptionsIncludeAll = false; bool typeOptionsIncludeAll = false;
bool typeOptionsIncludeFiltered = false;
if (typeOptions != NULL) if (typeOptions != NULL)
{
typeOptionsIncludeAll = typeOptions->Apply(typeOptionsIncludeAll, BfOptionFlags_ReflectAlwaysIncludeAll); typeOptionsIncludeAll = typeOptions->Apply(typeOptionsIncludeAll, BfOptionFlags_ReflectAlwaysIncludeAll);
typeOptionsIncludeFiltered = typeOptions->Apply(typeOptionsIncludeAll, BfOptionFlags_ReflectAlwaysIncludeFiltered);
}
// Generate all methods. Pass 1 // Generate all methods. Pass 1
for (auto methodDef : typeDef->mMethods) for (auto methodDef : typeDef->mMethods)
@ -5543,6 +5545,8 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
implRequired = true; implRequired = true;
if ((typeOptionsIncludeAll) && (ApplyTypeOptionMethodFilters(true, methodDef, typeOptions))) if ((typeOptionsIncludeAll) && (ApplyTypeOptionMethodFilters(true, methodDef, typeOptions)))
if ((typeOptionsIncludeAll || typeOptionsIncludeFiltered) && (ApplyTypeOptionMethodFilters(typeOptionsIncludeAll, methodDef, typeOptions)))
implRequired = true; implRequired = true;
// if ((typeOptions != NULL) && (CheckTypeOptionMethodFilters(typeOptions, methodDef))) // if ((typeOptions != NULL) && (CheckTypeOptionMethodFilters(typeOptions, methodDef)))
@ -7416,7 +7420,7 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfAstNode* typeRef, BfPopu
{ {
for (auto genericArgTypeRef : genericTypeRef->mGenericArguments) for (auto genericArgTypeRef : genericTypeRef->mGenericArguments)
{ {
auto genericArgType = ResolveTypeRef(genericArgTypeRef, BfPopulateType_IdentityNoRemapAlias); auto genericArgType = ResolveTypeRef(genericArgTypeRef, NULL, BfPopulateType_IdentityNoRemapAlias);
if (genericArgType == NULL) if (genericArgType == NULL)
return NULL; return NULL;
genericArgs.push_back(genericArgType); genericArgs.push_back(genericArgType);
@ -8426,7 +8430,7 @@ BfGenericParamInstance* BfModule::GetGenericParamInstance(BfGenericParamType* ty
return GetGenericTypeParamInstance(type->mGenericParamIdx); return GetGenericTypeParamInstance(type->mGenericParamIdx);
} }
bool BfModule::ResolveTypeResult_Validate(BfTypeReference* typeRef, BfType* resolvedTypeRef) bool BfModule::ResolveTypeResult_Validate(BfAstNode* typeRef, BfType* resolvedTypeRef)
{ {
if ((typeRef == NULL) || (resolvedTypeRef == NULL)) if ((typeRef == NULL) || (resolvedTypeRef == NULL))
return true; return true;
@ -9311,7 +9315,7 @@ void BfModule::TypeRefNotFound(BfTypeReference* typeRef, const char* appendName)
CheckTypeRefFixit(typeRef, appendName); CheckTypeRefFixit(typeRef, appendName);
} }
bool BfModule::ValidateTypeWildcard(BfTypeReference* typeRef, bool isAttributeRef) bool BfModule::ValidateTypeWildcard(BfAstNode* typeRef, bool isAttributeRef)
{ {
if (typeRef == NULL) if (typeRef == NULL)
return false; return false;
@ -10042,7 +10046,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
{ {
for (auto genericParamTypeRef : genericTypeRef->mGenericArguments) for (auto genericParamTypeRef : genericTypeRef->mGenericArguments)
{ {
auto genericParam = ResolveTypeRef(genericParamTypeRef, BfPopulateType_Declaration); auto genericParam = ResolveTypeRef(genericParamTypeRef, NULL, BfPopulateType_Declaration);
if (genericParam == NULL) if (genericParam == NULL)
return ResolveTypeResult(typeRef, NULL, populateType, resolveFlags); return ResolveTypeResult(typeRef, NULL, populateType, resolveFlags);
genericArgs.push_back(genericParam); genericArgs.push_back(genericParam);
@ -10560,9 +10564,10 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
int wantNumGenericParams = genericTypeInstRef->GetGenericArgCount(); int wantNumGenericParams = genericTypeInstRef->GetGenericArgCount();
BfTypeDef* ambiguousTypeDef = NULL; BfTypeDef* ambiguousTypeDef = NULL;
Array<BfTypeReference*> genericArguments; Array<BfAstNode*> genericArguments;
std::function<void(BfTypeReference*)> _GetTypeRefs = [&](BfTypeReference* typeRef) std::function<void(BfTypeReference*)> _GetTypeRefs = [&](BfTypeReference* typeRef)
{ {
//TODO:GENERICS
if (auto elementedTypeRef = BfNodeDynCast<BfElementedTypeRef>(typeRef)) if (auto elementedTypeRef = BfNodeDynCast<BfElementedTypeRef>(typeRef))
{ {
_GetTypeRefs(elementedTypeRef->mElementType); _GetTypeRefs(elementedTypeRef->mElementType);
@ -10612,7 +10617,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
for (auto genericArgRef : genericArguments) for (auto genericArgRef : genericArguments)
{ {
auto genericArg = ResolveTypeRef(genericArgRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_AllowGenericTypeParamConstValue | BfResolveTypeRefFlag_AllowGenericMethodParamConstValue)); auto genericArg = ResolveTypeRef(genericArgRef, NULL, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_AllowGenericTypeParamConstValue | BfResolveTypeRefFlag_AllowGenericMethodParamConstValue));
if ((genericArg == NULL) || (genericArg->IsVar())) if ((genericArg == NULL) || (genericArg->IsVar()))
{ {
mContext->mResolvedTypes.RemoveEntry(resolvedEntry); mContext->mResolvedTypes.RemoveEntry(resolvedEntry);
@ -11368,6 +11373,9 @@ BfTypeInstance* BfModule::GetUnspecializedTypeInstance(BfTypeInstance* typeInst)
BfType* BfModule::ResolveTypeRef(BfAstNode* astNode, const BfSizedArray<BfTypeReference*>* genericArgs, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags) BfType* BfModule::ResolveTypeRef(BfAstNode* astNode, const BfSizedArray<BfTypeReference*>* genericArgs, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
{ {
if (auto typeRef = BfNodeDynCast<BfTypeReference>(astNode))
return ResolveTypeRef(typeRef, populateType, resolveFlags);
if ((genericArgs == NULL) || (genericArgs->size() == 0)) if ((genericArgs == NULL) || (genericArgs->size() == 0))
{ {
if (auto identifier = BfNodeDynCast<BfIdentifierNode>(astNode)) if (auto identifier = BfNodeDynCast<BfIdentifierNode>(astNode))
@ -11429,7 +11437,7 @@ BfType* BfModule::ResolveTypeRef(BfAstNode* astNode, const BfSizedArray<BfTypeRe
typeRef->mParent = genericInstanceTypeRef; typeRef->mParent = genericInstanceTypeRef;
#endif #endif
BfDeferredAstSizedArray<BfTypeReference*> arguments(genericInstanceTypeRef->mGenericArguments, &alloc); BfDeferredAstSizedArray<BfAstNode*> arguments(genericInstanceTypeRef->mGenericArguments, &alloc);
for (auto genericArg : *genericArgs) for (auto genericArg : *genericArgs)
{ {

View file

@ -5208,7 +5208,7 @@ BfTypeReference* BfReducer::DoCreateTypeRef(BfAstNode* firstNode, CreateTypeRefF
} }
auto genericInstance = mAlloc->Alloc<BfGenericInstanceTypeRef>(); auto genericInstance = mAlloc->Alloc<BfGenericInstanceTypeRef>();
BfDeferredSizedArray<BfTypeReference*> genericArguments(genericInstance->mGenericArguments, mAlloc); BfDeferredSizedArray<BfAstNode*> genericArguments(genericInstance->mGenericArguments, mAlloc);
BfDeferredAstSizedArray<BfAstNode*> commas(genericInstance->mCommas, mAlloc); BfDeferredAstSizedArray<BfAstNode*> commas(genericInstance->mCommas, mAlloc);
ReplaceNode(typeRef, genericInstance); ReplaceNode(typeRef, genericInstance);
genericInstance->mOpenChevron = tokenNode; genericInstance->mOpenChevron = tokenNode;

View file

@ -3255,7 +3255,7 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
BfTypeVector genericArgs; BfTypeVector genericArgs;
for (auto genericArgTypeRef : genericInstTypeRef->mGenericArguments) for (auto genericArgTypeRef : genericInstTypeRef->mGenericArguments)
{ {
auto argType = ctx->mModule->ResolveTypeRef(genericArgTypeRef, BfPopulateType_Identity, ctx->mResolveFlags); auto argType = ctx->mModule->ResolveTypeRef(genericArgTypeRef, NULL, BfPopulateType_Identity, ctx->mResolveFlags);
if (argType != NULL) if (argType != NULL)
genericArgs.Add(argType); genericArgs.Add(argType);
else else
@ -3747,6 +3747,16 @@ int BfResolvedTypeSet::Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHash
return HASH_MIX(hashVal, hashSeed); return HASH_MIX(hashVal, hashSeed);
} }
int BfResolvedTypeSet::Hash(BfAstNode* typeRefNode, LookupContext* ctx, BfHashFlags flags, int hashSeed)
{
if (auto typeRef = BfNodeDynCast<BfTypeReference>(typeRefNode))
return Hash(typeRef, ctx, flags, hashSeed);
BF_FATAL("Not supported");
return 0;
}
// These types can be from different contexts ("foreign" types) so we can't just compare ptrs // These types can be from different contexts ("foreign" types) so we can't just compare ptrs
bool BfResolvedTypeSet::Equals(BfType* lhs, BfType* rhs, LookupContext* ctx) bool BfResolvedTypeSet::Equals(BfType* lhs, BfType* rhs, LookupContext* ctx)
{ {
@ -4577,6 +4587,16 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
return false; return false;
} }
bool BfResolvedTypeSet::Equals(BfType* lhs, BfAstNode* rhs, LookupContext* ctx)
{
if (auto rhsTypeRef = BfNodeDynCast<BfTypeReference>(rhs))
return Equals(lhs, rhsTypeRef, ctx);
BF_FATAL("Illegal");
return false;
}
void BfResolvedTypeSet::RemoveEntry(BfResolvedTypeSet::Entry* entry) void BfResolvedTypeSet::RemoveEntry(BfResolvedTypeSet::Entry* entry)
{ {
int hashIdx = (entry->mHash & 0x7FFFFFFF) % mHashSize; int hashIdx = (entry->mHash & 0x7FFFFFFF) % mHashSize;

View file

@ -1810,7 +1810,7 @@ class BfGenericTypeInfo
public: public:
typedef Array<BfGenericTypeParamInstance*> GenericParamsVector; typedef Array<BfGenericTypeParamInstance*> GenericParamsVector;
Array<BfTypeReference*> mTypeGenericArgumentRefs; Array<BfAstNode*> mTypeGenericArgumentRefs;
BfTypeVector mTypeGenericArguments; BfTypeVector mTypeGenericArguments;
GenericParamsVector mGenericParams; GenericParamsVector mGenericParams;
BfGenericExtensionInfo* mGenericExtensionInfo; BfGenericExtensionInfo* mGenericExtensionInfo;
@ -2571,8 +2571,10 @@ public:
static int DirectHash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None, int hashSeed = 0); static int DirectHash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None, int hashSeed = 0);
static int DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags, int& hashSeed); static int DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags, int& hashSeed);
static int Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None, int hashSeed = 0); static int Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None, int hashSeed = 0);
static int Hash(BfAstNode* typeRefNode, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None, int hashSeed = 0);
static bool Equals(BfType* lhs, BfType* rhs, LookupContext* ctx); static bool Equals(BfType* lhs, BfType* rhs, LookupContext* ctx);
static bool Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx); static bool Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx);
static bool Equals(BfType* lhs, BfAstNode* rhs, LookupContext* ctx);
static bool Equals(BfType* lhs, BfTypeReference* rhs, BfTypeDef* rhsTypeDef, LookupContext* ctx); static bool Equals(BfType* lhs, BfTypeReference* rhs, BfTypeDef* rhsTypeDef, LookupContext* ctx);
public: public:

View file

@ -974,6 +974,16 @@ bool BfTypeDef::HasSource(BfSource* source)
return false; return false;
} }
bool BfTypeDef::HasCustomAttributes()
{
if ((mTypeDeclaration != NULL) && (mTypeDeclaration->mAttributes != NULL))
return true;
for (auto& partial : mPartials)
if ((partial->mTypeDeclaration != NULL) && (partial->mTypeDeclaration->mAttributes != NULL))
return true;
return false;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
BfProject::BfProject() BfProject::BfProject()

View file

@ -1136,6 +1136,7 @@ public:
return mTypeCode == BfTypeCode_Extension; return mTypeCode == BfTypeCode_Extension;
} }
bool HasSource(BfSource* source); bool HasSource(BfSource* source);
bool HasCustomAttributes();
}; };
struct BfTypeDefMapFuncs : public MultiHashSetFuncs struct BfTypeDefMapFuncs : public MultiHashSetFuncs
@ -1463,6 +1464,7 @@ enum BfOptionFlags
BfOptionFlags_ReflectStaticMethods = 0x800, BfOptionFlags_ReflectStaticMethods = 0x800,
BfOptionFlags_ReflectNonStaticMethods = 0x1000, BfOptionFlags_ReflectNonStaticMethods = 0x1000,
BfOptionFlags_ReflectConstructors = 0x2000, BfOptionFlags_ReflectConstructors = 0x2000,
BfOptionFlags_ReflectAlwaysIncludeFiltered = 0x4000,
BfOptionFlags_Reflect_MethodMask = BfOptionFlags_ReflectStaticMethods | BfOptionFlags_ReflectNonStaticMethods | BfOptionFlags_ReflectConstructors, BfOptionFlags_Reflect_MethodMask = BfOptionFlags_ReflectStaticMethods | BfOptionFlags_ReflectNonStaticMethods | BfOptionFlags_ReflectConstructors,
BfOptionFlags_Mask = 0x3FFF BfOptionFlags_Mask = 0x3FFF