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:
parent
cc3fe5e40c
commit
2b7d0284f7
1 changed files with 24 additions and 5 deletions
|
@ -11768,16 +11768,35 @@ BfIRValue BfModule::ConstantToCurrent(BfConstant* constant, BfIRConstHolder* con
|
||||||
if (wantType->IsArray())
|
if (wantType->IsArray())
|
||||||
wantType = CreateSizedArrayType(wantType->GetUnderlyingType(), (int)constArray->mValues.mSize);
|
wantType = CreateSizedArrayType(wantType->GetUnderlyingType(), (int)constArray->mValues.mSize);
|
||||||
|
|
||||||
|
bool handleAsArray = false;
|
||||||
|
|
||||||
SizedArray<BfIRValue, 8> newVals;
|
SizedArray<BfIRValue, 8> newVals;
|
||||||
if (wantType->IsSizedArray())
|
if (wantType->IsSizedArray())
|
||||||
{
|
{
|
||||||
auto elementType = wantType->GetUnderlyingType();
|
handleAsArray = true;
|
||||||
for (auto val : constArray->mValues)
|
|
||||||
{
|
|
||||||
newVals.Add(ConstantToCurrent(constHolder->GetConstant(val), constHolder, elementType));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (wantType->IsInstanceOf(mCompiler->mSpanTypeDef))
|
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();
|
auto elementType = wantType->GetUnderlyingType();
|
||||||
for (auto val : constArray->mValues)
|
for (auto val : constArray->mValues)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue