mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Sized array .InitAll
elemented initializer
This commit is contained in:
parent
05e002d8f5
commit
77a99bdacc
3 changed files with 45 additions and 7 deletions
|
@ -15,6 +15,8 @@ namespace System
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public explicit static operator T[CSize] (Self val)
|
||||
{
|
||||
return val.mVal;
|
||||
|
@ -109,6 +111,28 @@ namespace System
|
|||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public static T[CSize] InitAll
|
||||
{
|
||||
[Error("Element type has no default constructor")]
|
||||
get
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SizedArray<T, CSize> where T : struct, new
|
||||
{
|
||||
public static T[CSize] InitAll
|
||||
{
|
||||
get
|
||||
{
|
||||
T[CSize] val;
|
||||
for (int i < CSize)
|
||||
val[i] = T();
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5709,14 +5709,22 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
|
||||
if (matchedProp != NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
if ((matchedProp->mDeclaringType->IsExtension()) && (!prop->mDeclaringType->IsExtension()))
|
||||
{
|
||||
auto error = mModule->Fail(StrFormat("Ambiguous reference to property '%s.%s'", mModule->TypeToString(curCheckType).c_str(), fieldName.c_str()), targetSrc);
|
||||
if (error != NULL)
|
||||
// Prefer non-extension
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
{
|
||||
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See property declaration in project '%s'", matchedProp->mDeclaringType->mProject->mName.c_str()), matchedProp->mFieldDeclaration);
|
||||
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See property declaration in project '%s'", prop->mDeclaringType->mProject->mName.c_str()), prop->mFieldDeclaration);
|
||||
break;
|
||||
auto error = mModule->Fail(StrFormat("Ambiguous reference to property '%s.%s'", mModule->TypeToString(curCheckType).c_str(), fieldName.c_str()), targetSrc);
|
||||
if (error != NULL)
|
||||
{
|
||||
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See property declaration in project '%s'", matchedProp->mDeclaringType->mProject->mName.c_str()), matchedProp->mFieldDeclaration);
|
||||
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See property declaration in project '%s'", prop->mDeclaringType->mProject->mName.c_str()), prop->mFieldDeclaration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21406,6 +21414,11 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
return;
|
||||
}
|
||||
|
||||
if (mExpectingType->IsSizedArray())
|
||||
{
|
||||
expectingTypeInst = mModule->GetWrappedStructType(mExpectingType);
|
||||
}
|
||||
|
||||
if (expectingTypeInst == NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
|
|
|
@ -941,7 +941,8 @@ void BfModule::CheckMemberNames(BfTypeInstance* typeInst)
|
|||
MemberRef* prevMemberRef = NULL;
|
||||
if (memberMap.TryGetValue(memberRef.mName, &prevMemberRef))
|
||||
{
|
||||
//auto& prevMemberRef = itr->second;
|
||||
if ((prevMemberRef->mDeclaringType->IsExtension()) && (!memberRef.mDeclaringType->IsExtension()))
|
||||
continue;
|
||||
|
||||
MemberRef* firstMemberRef = &memberRef;
|
||||
MemberRef* secondMemberRef = prevMemberRef;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue