mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Make initializer expression work with 'in' ref values
This commit is contained in:
parent
91c0ec9239
commit
b34a14502d
3 changed files with 8 additions and 5 deletions
|
@ -11625,7 +11625,10 @@ void BfExprEvaluator::Visit(BfInitializerExpression* initExpr)
|
|||
mModule->mBfIRBuilder->SetInsertPoint(initBlock);
|
||||
}
|
||||
|
||||
BfTypedValue initValue = GetResult(true);
|
||||
BfTypedValue origInitValue = GetResult(true);
|
||||
BfTypedValue initValue = origInitValue;
|
||||
if ((initValue) && (initValue.mType->IsRef()))
|
||||
initValue = mModule->RemoveRef(initValue, false);
|
||||
bool isFirstAdd = true;
|
||||
|
||||
for (auto elementExpr : initExpr->mValues)
|
||||
|
@ -11749,7 +11752,7 @@ void BfExprEvaluator::Visit(BfInitializerExpression* initExpr)
|
|||
mModule->mBfIRBuilder->SetInsertPoint(curBlock);
|
||||
}
|
||||
|
||||
mResult = initValue;
|
||||
mResult = origInitValue;
|
||||
}
|
||||
|
||||
void BfExprEvaluator::Visit(BfCollectionInitializerExpression* arrayInitExpr)
|
||||
|
|
|
@ -12944,7 +12944,7 @@ BfVariant BfModule::TypedValueToVariant(BfAstNode* refNode, const BfTypedValue&
|
|||
return variant;
|
||||
}
|
||||
|
||||
BfTypedValue BfModule::RemoveRef(BfTypedValue typedValue)
|
||||
BfTypedValue BfModule::RemoveRef(BfTypedValue typedValue, bool makeInReadOnly)
|
||||
{
|
||||
if ((typedValue.mType != NULL) && (typedValue.mType->IsRef()))
|
||||
{
|
||||
|
@ -12969,7 +12969,7 @@ BfTypedValue BfModule::RemoveRef(BfTypedValue typedValue)
|
|||
BF_ASSERT(typedValue.mValue.IsFake());
|
||||
}
|
||||
|
||||
if (refType->mRefKind == BfRefType::RefKind_In)
|
||||
if ((refType->mRefKind == BfRefType::RefKind_In) && (makeInReadOnly))
|
||||
{
|
||||
if (typedValue.mKind == BfTypedValueKind_Addr)
|
||||
typedValue.mKind = BfTypedValueKind_ReadOnlyAddr;
|
||||
|
|
|
@ -1752,7 +1752,7 @@ public:
|
|||
void EmitDynamicCastCheck(const BfTypedValue& targetValue, BfType* targetType, BfIRBlock trueBlock, BfIRBlock falseBlock, bool nullSucceeds = false);
|
||||
void EmitDynamicCastCheck(BfTypedValue typedVal, BfType* type, bool allowNull);
|
||||
void CheckStaticAccess(BfTypeInstance* typeInstance);
|
||||
BfTypedValue RemoveRef(BfTypedValue typedValue);
|
||||
BfTypedValue RemoveRef(BfTypedValue typedValue, bool makeInReadOnly = true);
|
||||
BfTypedValue SanitizeAddr(BfTypedValue typedValue);
|
||||
BfTypedValue ToRef(BfTypedValue typedValue, BfRefType* refType = NULL);
|
||||
BfTypedValue LoadOrAggregateValue(BfTypedValue typedValue);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue