1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Support for matching interface conformance in distinct build options

This commit is contained in:
Brian Fiete 2020-09-16 04:37:28 -07:00
parent 6cb1235fd6
commit 0b20ef867b
6 changed files with 87 additions and 25 deletions

View file

@ -267,11 +267,21 @@ namespace IDE.ui
else
{
bool isValid = true;
for (let typeName in typeNames.Split(';'))
for (var typeName in typeNames.Split(';'))
{
if ((!typeNames.StartsWith("@")) && (!gApp.mBfResolveCompiler.VerifyTypeName(scope String(typeName), -1)))
if (!typeNames.StartsWith("@"))
{
while (!typeName.IsEmpty)
{
if ((typeName[0] != ':') && (!typeName[0].IsWhiteSpace))
break;
typeName.RemoveFromStart(1);
}
if (!gApp.mBfResolveCompiler.VerifyTypeName(scope String(typeName), -1))
isValid = false;
}
}
subItem.mTextColor = isValid ? 0xFFFFFFFF : 0xFFFF8080;
propEntry.mColorOverride = subItem.mTextColor;
}

View file

@ -34,6 +34,14 @@ namespace IDE.ui
editOffset = semiPos + 1;
}
while (editOffset < editText.Length)
{
char8 c = editText[editOffset];
if ((c != ':') && (!c.IsWhiteSpace))
break;
editOffset++;
}
editText.Remove(0, editOffset);
cursorPos -= editOffset;
//
@ -47,7 +55,9 @@ namespace IDE.ui
if (editText.StartsWith("@"))
isValid = true;
else
{
isValid = gApp.mBfResolveCompiler.VerifyTypeName(editText, cursorPos);
}
for (int ofs < editText.Length)
{
@ -82,14 +92,23 @@ namespace IDE.ui
text[i].mDisplayTypeId = 0;
}
for (let typeName in editText.Split(';'))
for (var typeName in editText.Split(';'))
{
int startOfs = 0;
while (!typeName.IsEmpty)
{
if ((typeName[0] != ':') && (!typeName[0].IsWhiteSpace))
break;
typeName.RemoveFromStart(1);
startOfs++;
}
bool isValid = gApp.mBfResolveCompiler.VerifyTypeName(scope String(typeName), -1);
if (!isValid)
{
for (int ofs < typeName.Length)
{
text[@typeName.Pos + ofs].mDisplayTypeId = 1;
text[@typeName.Pos + startOfs + ofs].mDisplayTypeId = 1;
}
}
}

View file

@ -13051,8 +13051,14 @@ BfTypedValue BfExprEvaluator::MakeCallableTarget(BfAstNode* targetSrc, BfTypedVa
}
else if (primStructType->IsSplattable())
{
BF_ASSERT(target.IsSplat());
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);
}
}
}

View file

@ -1674,8 +1674,9 @@ 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;
@ -1703,8 +1732,7 @@ int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeIn
auto underlyingType = typeInstance->GetUnderlyingType();
if (underlyingType != NULL)
{
String typeName = TypeToString(underlyingType);
_CheckTypeName(typeName);
_CheckType(underlyingType);
}
else
{
@ -1717,12 +1745,10 @@ 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);
_CheckType(ptrType);
}
String typeName = TypeToString(typeInstance);
_CheckTypeName(typeName);
_CheckType(typeInstance);
}
int matchedIdx = -1;

View file

@ -1978,6 +1978,7 @@ bool BfTypeInstance::IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfProje
bool BfTypeInstance::WantsGCMarking()
{
BF_ASSERT(mTypeDef->mTypeCode != BfTypeCode_Extension);
if (IsObjectOrInterface())
return true;
if ((IsEnum()) && (!IsPayloadEnum()))
@ -2198,6 +2199,7 @@ BfType* BfTypeInstance::GetUnderlyingType()
bool BfTypeInstance::IsValuelessType()
{
BF_ASSERT(mTypeDef->mTypeCode != BfTypeCode_Extension);
if ((mTypeDef->mTypeCode == BfTypeCode_Object) || (mTypeDef->mTypeCode == BfTypeCode_Interface))
{
return false;

View file

@ -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;