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

Fix for sized array with const member size

This commit is contained in:
Brian Fiete 2020-03-09 13:10:34 -07:00
parent 20d0dcf8de
commit e9ef8ed27c
2 changed files with 69 additions and 64 deletions

View file

@ -3237,11 +3237,6 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
mPropDef = NULL; mPropDef = NULL;
mPropDefBypassVirtual = false; mPropDefBypassVirtual = false;
if ((target.mType != NULL) && (mModule->mCurMethodState != NULL))
{
mModule->PopulateType(target.mType, BfPopulateType_BaseType);
}
if (target) if (target)
{ {
if ((!target.mType->IsValueType()) && (target.IsAddr())) if ((!target.mType->IsValueType()) && (target.IsAddr()))
@ -3265,6 +3260,9 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
startCheckType = target.mType->ToTypeInstance(); startCheckType = target.mType->ToTypeInstance();
} }
if ((startCheckType != NULL) && (startCheckType->mBaseType == NULL))
mModule->PopulateType(startCheckType, BfPopulateType_BaseType);
String findName; String findName;
int varSkipCount = 0; int varSkipCount = 0;
if (fieldName.StartsWith('@')) if (fieldName.StartsWith('@'))

View file

@ -2236,8 +2236,14 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
int enumCaseEntryIdx = 0; int enumCaseEntryIdx = 0;
for (int pass = 0; pass < 2; pass++)
{
for (auto field : typeDef->mFields) for (auto field : typeDef->mFields)
{ {
// Do consts then non-consts. Somewhat of a hack for using consts as sized array size
if (field->mIsConst != (pass == 0))
continue;
auto fieldInstance = &typeInstance->mFieldInstances[field->mIdx]; auto fieldInstance = &typeInstance->mFieldInstances[field->mIdx];
if ((fieldInstance->mResolvedType != NULL) || (!fieldInstance->mFieldIncluded)) if ((fieldInstance->mResolvedType != NULL) || (!fieldInstance->mFieldIncluded))
continue; continue;
@ -2308,6 +2314,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
// because we may have re-entry and create multiple instances of this static field // because we may have re-entry and create multiple instances of this static field
} }
} }
}
if (!resolvedTypeRef->IsIncomplete()) if (!resolvedTypeRef->IsIncomplete())
{ {