mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
WIP nullable fix
This commit is contained in:
parent
047ae9acc3
commit
0bedd77f0a
1 changed files with 13 additions and 2 deletions
|
@ -22925,10 +22925,19 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
|
|||
|
||||
bool BfExprEvaluator::PerformBinaryOperation_NullCoalesce(BfTokenNode* opToken, BfExpression* leftExpression, BfExpression* rightExpression, BfTypedValue leftValue, BfType* wantType, BfTypedValue* assignTo)
|
||||
{
|
||||
if ((leftValue) && ((leftValue.mType->IsPointer()) || (leftValue.mType->IsFunction()) || (leftValue.mType->IsObject())))
|
||||
if ((leftValue) && ((leftValue.mType->IsPointer()) || (leftValue.mType->IsFunction()) || (leftValue.mType->IsObject())) /* || (leftValue.mType->IsNullable())*/)
|
||||
{
|
||||
leftValue = mModule->LoadValue(leftValue);
|
||||
|
||||
BfIRValue nullableHasValue;
|
||||
if (leftValue.mType->IsNullable())
|
||||
{
|
||||
if (wantType == leftValue.mType)
|
||||
wantType = leftValue.mType->GetUnderlyingType();
|
||||
nullableHasValue = mModule->mBfIRBuilder->CreateExtractValue(leftValue.mValue, 1);
|
||||
leftValue = BfTypedValue(mModule->mBfIRBuilder->CreateExtractValue(leftValue.mValue, 0), leftValue.mType->GetUnderlyingType());
|
||||
}
|
||||
|
||||
if (leftValue.mValue.IsConst())
|
||||
{
|
||||
auto constant = mModule->mBfIRBuilder->GetConstant(leftValue.mValue);
|
||||
|
@ -22954,7 +22963,9 @@ bool BfExprEvaluator::PerformBinaryOperation_NullCoalesce(BfTokenNode* opToken,
|
|||
auto endLhsBB = prevBB;
|
||||
|
||||
BfIRValue isNull;
|
||||
if (leftValue.mType->IsFunction())
|
||||
if (nullableHasValue)
|
||||
isNull = mModule->mBfIRBuilder->CreateCmpEQ(nullableHasValue, mModule->mBfIRBuilder->CreateConst(BfTypeCode_Boolean, 0));
|
||||
else if (leftValue.mType->IsFunction())
|
||||
isNull = mModule->mBfIRBuilder->CreateIsNull(
|
||||
mModule->mBfIRBuilder->CreateIntToPtr(leftValue.mValue, mModule->mBfIRBuilder->MapType(mModule->GetPrimitiveType(BfTypeCode_NullPtr))));
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue