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

Fix for undef index of sized array

This commit is contained in:
Brian Fiete 2020-10-14 17:37:25 -07:00
parent 5e4ecade6d
commit a944aa6d24

View file

@ -17949,7 +17949,7 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
mModule->MakeAddressable(target); mModule->MakeAddressable(target);
mModule->PopulateType(underlyingType); mModule->PopulateType(underlyingType);
if (sizedArrayType->IsUnknownSizedArray()) if ((sizedArrayType->IsUnknownSizedArray()) || (isUndefIndex))
{ {
mResult = mModule->GetDefaultTypedValue(underlyingType, false, BfDefaultValueKind_Addr); mResult = mModule->GetDefaultTypedValue(underlyingType, false, BfDefaultValueKind_Addr);
} }
@ -17968,11 +17968,6 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
{ {
if (target.mType->IsSizeAligned()) if (target.mType->IsSizeAligned())
{ {
// auto ptrType = mModule->CreatePointerType(underlyingType);
// auto ptrValue = mModule->mBfIRBuilder->CreateBitCast(target.mValue, mModule->mBfIRBuilder->MapType(ptrType));
// auto gepResult = mModule->mBfIRBuilder->CreateInBoundsGEP(ptrValue, indexArgument.mValue);
// mResult = BfTypedValue(gepResult, underlyingType, target.IsReadOnly() ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
auto gepResult = mModule->mBfIRBuilder->CreateInBoundsGEP(target.mValue, mModule->GetConstValue(0), indexArgument.mValue); auto gepResult = mModule->mBfIRBuilder->CreateInBoundsGEP(target.mValue, mModule->GetConstValue(0), indexArgument.mValue);
mResult = BfTypedValue(gepResult, underlyingType, target.IsReadOnly() ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr); mResult = BfTypedValue(gepResult, underlyingType, target.IsReadOnly() ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
} }