mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Support for matching interface conformance in distinct build options
This commit is contained in:
parent
6cb1235fd6
commit
0b20ef867b
6 changed files with 87 additions and 25 deletions
|
@ -13051,8 +13051,14 @@ BfTypedValue BfExprEvaluator::MakeCallableTarget(BfAstNode* targetSrc, BfTypedVa
|
|||
}
|
||||
else if (primStructType->IsSplattable())
|
||||
{
|
||||
BF_ASSERT(target.IsSplat());
|
||||
target.mKind = BfTypedValueKind_SplatHead;
|
||||
BF_ASSERT(target.IsSplat() || target.mValue.IsFake());
|
||||
if (target.IsSplat())
|
||||
target.mKind = BfTypedValueKind_SplatHead;
|
||||
else
|
||||
{
|
||||
if (!target.mValue.IsFake())
|
||||
mModule->FailInternal("MakeCallableTarget splat fail", targetSrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1673,9 +1673,10 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
|
|||
|
||||
int typeOptionsCount = (int)mContext->mSystem->mTypeOptions.size();
|
||||
if (checkTypeName)
|
||||
{
|
||||
auto _CheckTypeName = [&](const StringImpl& typeName)
|
||||
{
|
||||
{
|
||||
auto _CheckType = [&](BfType* type)
|
||||
{
|
||||
StringImpl typeName = TypeToString(type);
|
||||
for (int optionIdx = 0; optionIdx < (int)mContext->mSystem->mTypeOptions.size(); optionIdx++)
|
||||
{
|
||||
auto& typeOptions = mContext->mSystem->mTypeOptions[optionIdx];
|
||||
|
@ -1686,7 +1687,35 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
|
|||
int filterIdx = 0;
|
||||
int typeNameIdx = 0;
|
||||
|
||||
if (BfCheckWildcard(filter, typeName))
|
||||
if (filter.StartsWith(':'))
|
||||
{
|
||||
BfTypeInstance* typeInst = type->ToTypeInstance();
|
||||
if (typeInst != NULL)
|
||||
{
|
||||
int startPos = 1;
|
||||
for (; startPos < (int)filter.length(); startPos++)
|
||||
if (filter[startPos] != ' ')
|
||||
break;
|
||||
String checkFilter;
|
||||
checkFilter.Reference(filter.c_str() + startPos, filter.mLength - startPos);
|
||||
|
||||
BfTypeInstance* checkTypeInst = typeInst;
|
||||
while (checkTypeInst != NULL)
|
||||
{
|
||||
for (auto& iface : checkTypeInst->mInterfaces)
|
||||
{
|
||||
StringT<128> ifaceName = TypeToString(iface.mInterfaceType);
|
||||
if (BfCheckWildcard(checkFilter, ifaceName))
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
checkTypeInst = checkTypeInst->mBaseType;
|
||||
}
|
||||
if (matched)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (BfCheckWildcard(filter, typeName))
|
||||
{
|
||||
matched = true;
|
||||
break;
|
||||
|
@ -1702,9 +1731,8 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
|
|||
{
|
||||
auto underlyingType = typeInstance->GetUnderlyingType();
|
||||
if (underlyingType != NULL)
|
||||
{
|
||||
String typeName = TypeToString(underlyingType);
|
||||
_CheckTypeName(typeName);
|
||||
{
|
||||
_CheckType(underlyingType);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1716,13 +1744,11 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
|
|||
{
|
||||
BF_ASSERT(typeInstance->IsGenericTypeInstance());
|
||||
auto innerType = typeInstance->mGenericTypeInfo->mTypeGenericArguments[0];
|
||||
auto ptrType = CreatePointerType(innerType);
|
||||
String typeName = TypeToString(ptrType);
|
||||
_CheckTypeName(typeName);
|
||||
auto ptrType = CreatePointerType(innerType);
|
||||
_CheckType(ptrType);
|
||||
}
|
||||
|
||||
String typeName = TypeToString(typeInstance);
|
||||
_CheckTypeName(typeName);
|
||||
|
||||
_CheckType(typeInstance);
|
||||
}
|
||||
|
||||
int matchedIdx = -1;
|
||||
|
|
|
@ -1978,10 +1978,11 @@ bool BfTypeInstance::IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfProje
|
|||
|
||||
bool BfTypeInstance::WantsGCMarking()
|
||||
{
|
||||
BF_ASSERT(mTypeDef->mTypeCode != BfTypeCode_Extension);
|
||||
if (IsObjectOrInterface())
|
||||
return true;
|
||||
if ((IsEnum()) && (!IsPayloadEnum()))
|
||||
return false;
|
||||
return false;
|
||||
BF_ASSERT(mDefineState >= BfTypeDefineState_Defined);
|
||||
return mWantsGCMarking;
|
||||
}
|
||||
|
@ -2198,13 +2199,14 @@ BfType* BfTypeInstance::GetUnderlyingType()
|
|||
|
||||
bool BfTypeInstance::IsValuelessType()
|
||||
{
|
||||
BF_ASSERT(mTypeDef->mTypeCode != BfTypeCode_Extension);
|
||||
if ((mTypeDef->mTypeCode == BfTypeCode_Object) || (mTypeDef->mTypeCode == BfTypeCode_Interface))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (mTypeDef->mIsOpaque)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
|
||||
BF_ASSERT(mDefineState >= BfTypeDefineState_Defined);
|
||||
BF_ASSERT(mInstSize >= 0);
|
||||
if (mInstSize == 0)
|
||||
|
|
|
@ -2617,12 +2617,11 @@ void BfSystem::InjectNewRevision(BfTypeDef* typeDef)
|
|||
BF_ASSERT(typeDef->mFullNameEx == nextTypeDef->mFullNameEx);
|
||||
|
||||
typeDef->mProtection = nextTypeDef->mProtection;
|
||||
if ((typeDef->mTypeCode != BfTypeCode_Extension) && (!typeDef->mIsCombinedPartial))
|
||||
BF_ASSERT(nextTypeDef->mTypeCode != BfTypeCode_Extension);
|
||||
|
||||
BF_ASSERT(typeDef->mTypeCode == nextTypeDef->mTypeCode);
|
||||
|
||||
typeDef->mTypeCode = nextTypeDef->mTypeCode;
|
||||
|
||||
typeDef->mIsAlwaysInclude = nextTypeDef->mIsAlwaysInclude;
|
||||
typeDef->mIsNoDiscard = nextTypeDef->mIsNoDiscard;
|
||||
typeDef->mIsPartial = nextTypeDef->mIsPartial;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue