mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed null coalescing for function pointers
This commit is contained in:
parent
6e58454825
commit
ed679f6f10
1 changed files with 7 additions and 2 deletions
|
@ -20615,14 +20615,19 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
return;
|
||||
}
|
||||
|
||||
if ((binaryOp == BfBinaryOp_NullCoalesce) && ((leftValue.mType->IsPointer()) || (leftValue.mType->IsObject())))
|
||||
if ((binaryOp == BfBinaryOp_NullCoalesce) && ((leftValue.mType->IsPointer()) || (leftValue.mType->IsFunction()) || (leftValue.mType->IsObject())))
|
||||
{
|
||||
auto prevBB = mModule->mBfIRBuilder->GetInsertBlock();
|
||||
|
||||
auto rhsBB = mModule->mBfIRBuilder->CreateBlock("nullc.rhs");
|
||||
auto endBB = mModule->mBfIRBuilder->CreateBlock("nullc.end");
|
||||
|
||||
auto isNull = mModule->mBfIRBuilder->CreateIsNull(leftValue.mValue);
|
||||
BfIRValue isNull;
|
||||
if (leftValue.mType->IsFunction())
|
||||
isNull = mModule->mBfIRBuilder->CreateIsNull(
|
||||
mModule->mBfIRBuilder->CreateIntToPtr(leftValue.mValue, mModule->mBfIRBuilder->MapType(mModule->GetPrimitiveType(BfTypeCode_NullPtr))));
|
||||
else
|
||||
isNull = mModule->mBfIRBuilder->CreateIsNull(leftValue.mValue);
|
||||
mModule->mBfIRBuilder->CreateCondBr(isNull, rhsBB, endBB);
|
||||
|
||||
mModule->AddBasicBlock(rhsBB);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue