1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

ConstantToCurrent span fix

This commit is contained in:
Brian Fiete 2022-08-28 11:52:04 -07:00
parent cc3fe5e40c
commit 2b7d0284f7

View file

@ -11768,16 +11768,35 @@ BfIRValue BfModule::ConstantToCurrent(BfConstant* constant, BfIRConstHolder* con
if (wantType->IsArray())
wantType = CreateSizedArrayType(wantType->GetUnderlyingType(), (int)constArray->mValues.mSize);
bool handleAsArray = false;
SizedArray<BfIRValue, 8> newVals;
if (wantType->IsSizedArray())
{
auto elementType = wantType->GetUnderlyingType();
for (auto val : constArray->mValues)
{
newVals.Add(ConstantToCurrent(constHolder->GetConstant(val), constHolder, elementType));
}
handleAsArray = true;
}
else if (wantType->IsInstanceOf(mCompiler->mSpanTypeDef))
{
auto valueType = ResolveTypeDef(mCompiler->mValueTypeTypeDef);
handleAsArray = true;
if (!constArray->mValues.IsEmpty())
{
auto firstConstant = constHolder->GetConstant(constArray->mValues[0]);
if ((firstConstant->mConstType == BfConstType_AggZero) && (firstConstant->mIRType.mKind == BfIRType::TypeKind_TypeId) &&
(firstConstant->mIRType.mId == valueType->mTypeId))
handleAsArray = false;
if (firstConstant->mConstType == BfConstType_Agg)
{
auto firstConstArray = (BfConstantAgg*)firstConstant;
if ((firstConstArray->mType.mKind == BfIRType::TypeKind_TypeId) &&
(firstConstArray->mType.mId == valueType->mTypeId))
handleAsArray = false;
}
}
}
if (handleAsArray)
{
auto elementType = wantType->GetUnderlyingType();
for (auto val : constArray->mValues)