mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Properly fill in padding members in innerconst aggs
This commit is contained in:
parent
619a711e42
commit
d9de51a019
1 changed files with 31 additions and 0 deletions
|
@ -429,6 +429,33 @@ void BeIRCodeGen::FixValues(BeStructType* structType, CmdParamVec<BeValue*>& val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BeIRCodeGen::FixValues(BeStructType* structType, SizedArrayImpl<BeConstant*>& values)
|
||||||
|
{
|
||||||
|
if (values.size() >= structType->mMembers.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int readIdx = values.size() - 1;
|
||||||
|
values.resize(structType->mMembers.size());
|
||||||
|
for (int i = (int)values.size() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (mBeContext->AreTypesEqual(values[readIdx]->GetType(), structType->mMembers[i].mType))
|
||||||
|
{
|
||||||
|
values[i] = values[readIdx];
|
||||||
|
readIdx--;
|
||||||
|
}
|
||||||
|
else if (structType->mMembers[i].mType->IsSizedArray())
|
||||||
|
{
|
||||||
|
auto beConst = mBeModule->mAlloc.Alloc<BeConstant>();
|
||||||
|
beConst->mType = structType->mMembers[i].mType;
|
||||||
|
values[i] = beConst;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalError("Malformed structure values");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BeIRCodeGen::Init(const BfSizedArray<uint8>& buffer)
|
void BeIRCodeGen::Init(const BfSizedArray<uint8>& buffer)
|
||||||
{
|
{
|
||||||
BP_ZONE("BeIRCodeGen::Init");
|
BP_ZONE("BeIRCodeGen::Init");
|
||||||
|
@ -905,6 +932,10 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
||||||
|
|
||||||
constStruct->mMemberValues.Add(constant);
|
constStruct->mMemberValues.Add(constant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type->IsStruct())
|
||||||
|
FixValues((BeStructType*)type, constStruct->mMemberValues);
|
||||||
|
|
||||||
beValue = constStruct;
|
beValue = constStruct;
|
||||||
|
|
||||||
BE_MEM_END("ParamType_Const_Array");
|
BE_MEM_END("ParamType_Const_Array");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue