mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Sized array encoding fix
This commit is contained in:
parent
e5e11d52d4
commit
e018c08134
1 changed files with 20 additions and 4 deletions
|
@ -3362,7 +3362,17 @@ bool CeContext::WriteConstant(BfModule* module, addr_ce addr, BfConstant* consta
|
||||||
auto aggConstant = (BfConstantAgg*)constant;
|
auto aggConstant = (BfConstantAgg*)constant;
|
||||||
if (type->IsSizedArray())
|
if (type->IsSizedArray())
|
||||||
{
|
{
|
||||||
return false;
|
auto sizedArrayType = (BfSizedArrayType*)type;
|
||||||
|
for (int i = 0; i < sizedArrayType->mSize; i++)
|
||||||
|
{
|
||||||
|
auto fieldConstant = module->mBfIRBuilder->GetConstant(aggConstant->mValues[i]);
|
||||||
|
if (fieldConstant == NULL)
|
||||||
|
return false;
|
||||||
|
if (!WriteConstant(module, addr + i * sizedArrayType->mElementType->mSize, fieldConstant, sizedArrayType->mElementType))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (type->IsArray())
|
else if (type->IsArray())
|
||||||
{
|
{
|
||||||
|
@ -3477,6 +3487,13 @@ bool CeContext::WriteConstant(BfModule* module, addr_ce addr, BfConstant* consta
|
||||||
auto constTarget = module->mBfIRBuilder->GetConstantById(constBitCast->mTarget);
|
auto constTarget = module->mBfIRBuilder->GetConstantById(constBitCast->mTarget);
|
||||||
return WriteConstant(module, addr, constTarget, type);
|
return WriteConstant(module, addr, constTarget, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (constant->mConstType == BfConstType_BitCastNull)
|
||||||
|
{
|
||||||
|
BF_ASSERT(type->IsPointer() || type->IsObjectOrInterface());
|
||||||
|
memset(mMemory.mVals + addr, 0, type->mSize);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (constant->mConstType == BfConstType_GEP32_2)
|
if (constant->mConstType == BfConstType_GEP32_2)
|
||||||
{
|
{
|
||||||
|
@ -4110,9 +4127,8 @@ BfTypedValue CeContext::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns
|
||||||
|
|
||||||
auto constant = module->mBfIRBuilder->GetConstant(arg);
|
auto constant = module->mBfIRBuilder->GetConstant(arg);
|
||||||
if (paramType->IsComposite())
|
if (paramType->IsComposite())
|
||||||
{
|
{
|
||||||
auto paramTypeInst = paramType->ToTypeInstance();
|
useCompositeAddr -= paramType->mSize;
|
||||||
useCompositeAddr -= paramTypeInst->mInstSize;
|
|
||||||
if (!WriteConstant(module, useCompositeAddr, constant, paramType, isParams))
|
if (!WriteConstant(module, useCompositeAddr, constant, paramType, isParams))
|
||||||
{
|
{
|
||||||
Fail(StrFormat("Failed to process argument for param '%s'", methodInstance->GetParamName(paramIdx).c_str()));
|
Fail(StrFormat("Failed to process argument for param '%s'", methodInstance->GetParamName(paramIdx).c_str()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue