1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed object in CreateConstant

This commit is contained in:
Brian Fiete 2021-11-01 07:22:06 -07:00
parent 42874ed252
commit b298b232ef

View file

@ -3644,6 +3644,15 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
// CE_CREATECONST_CHECKPTR(instData, typeInst->mInstSize);
// }
if (typeInst->IsObjectOrInterface())
{
addr_ce addr = *(addr_ce*)(ptr);
if (addr == 0)
{
return irBuilder->CreateConstNull(irBuilder->MapType(typeInst));
}
instData = memStart + addr;
if (typeInst->IsInstanceOf(mCeMachine->mCompiler->mStringTypeDef))
{
BfTypeInstance* stringTypeInst = (BfTypeInstance*)ceModule->ResolveTypeDef(mCeMachine->mCompiler->mStringTypeDef, BfPopulateType_Data);
@ -3675,7 +3684,7 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
CE_CREATECONST_CHECKPTR(charPtr, lenVal);
String str(charPtr, lenVal);
return module->GetStringObjectValue(str);
}
}
if (typeInst->IsInstanceOf(mCeMachine->mCompiler->mStringViewTypeDef))
@ -4183,7 +4192,18 @@ BfTypedValue CeContext::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns
if (success)
{
BfTypedValue retValue;
if ((retInstAddr != 0) || (allocThisInstAddr != 0))
if (returnType->IsObject())
{
BfType* usedReturnType = returnType;
BfIRValue constVal = CreateConstant(module, (uint8*)&retInstAddr, returnType, &usedReturnType);
if (constVal)
returnValue = BfTypedValue(constVal, usedReturnType);
else
{
Fail("Failed to encode return argument");
}
}
else if ((retInstAddr != 0) || (allocThisInstAddr != 0))
{
auto* retPtr = memStart + retInstAddr;
if (allocThisInstAddr != 0)