diff --git a/IDEHelper/Compiler/BfAst.h b/IDEHelper/Compiler/BfAst.h index 36eba795..d7b15a1d 100644 --- a/IDEHelper/Compiler/BfAst.h +++ b/IDEHelper/Compiler/BfAst.h @@ -536,6 +536,7 @@ enum BfTypedValueKind BfTypedValueKind_Addr, BfTypedValueKind_ReadOnlyAddr, BfTypedValueKind_TempAddr, + BfTypedValueKind_RestrictedTempAddr, BfTypedValueKind_ReadOnlyTempAddr, BfTypedValueKind_ThisAddr, BfTypedValueKind_BaseAddr, @@ -647,7 +648,7 @@ public: bool IsTempAddr() const { - return ((mKind == BfTypedValueKind_ReadOnlyTempAddr) || (mKind == BfTypedValueKind_TempAddr)); + return ((mKind == BfTypedValueKind_ReadOnlyTempAddr) || (mKind == BfTypedValueKind_RestrictedTempAddr) || (mKind == BfTypedValueKind_TempAddr)); } bool IsReadOnly() const @@ -727,6 +728,7 @@ public: mKind = BfTypedValueKind_ReadOnlyAddr; break; case BfTypedValueKind_TempAddr: + case BfTypedValueKind_RestrictedTempAddr: mKind = BfTypedValueKind_ReadOnlyTempAddr; break; default: diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index de2efa62..c2f98575 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -4516,7 +4516,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV { auto val = mModule->GetDefaultTypedValue(returnType, true, (methodInstance->GetStructRetIdx() != -1) ? BfDefaultValueKind_Addr : BfDefaultValueKind_Value); if (val.mKind == BfTypedValueKind_Addr) - val.mKind = BfTypedValueKind_TempAddr; + val.mKind = BfTypedValueKind_RestrictedTempAddr; return val; } }; @@ -4543,7 +4543,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV if (sret == NULL) { - sretVal = BfTypedValue(mModule->CreateAlloca(returnType), returnType, BfTypedValueKind_TempAddr); + sretVal = BfTypedValue(mModule->CreateAlloca(returnType), returnType, BfTypedValueKind_RestrictedTempAddr); sret = &sretVal; } } @@ -5008,7 +5008,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV loweredIRType = mModule->mBfIRBuilder->GetPointerTo(loweredIRType); auto castedRetVal = mModule->mBfIRBuilder->CreateBitCast(retVal, loweredIRType); mModule->mBfIRBuilder->CreateStore(callInst, castedRetVal); - result = BfTypedValue(retVal, methodInstance->mReturnType, BfTypedValueKind_TempAddr); + result = BfTypedValue(retVal, methodInstance->mReturnType, BfTypedValueKind_RestrictedTempAddr); } else result = BfTypedValue(callInst, methodInstance->mReturnType); @@ -8440,7 +8440,7 @@ void BfExprEvaluator::Visit(BfInitializerExpression* initExpr) StringT<128> findName; identifierNode->ToString(findName); fieldResult = LookupField(identifierNode, initValue, findName, BfLookupFieldFlag_IsImplicitThis); - if (fieldResult.mKind == BfTypedValueKind_TempAddr) + if ((fieldResult.mKind == BfTypedValueKind_TempAddr) || (fieldResult.mKind == BfTypedValueKind_RestrictedTempAddr)) fieldResult.mKind = BfTypedValueKind_Addr; wasValidInitKind = true; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index a6c46c07..296e5454 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -11102,7 +11102,7 @@ bool BfModule::CheckModifyValue(BfTypedValue& typedValue, BfAstNode* refNode, co return false; } - if (typedValue.mKind == BfTypedValueKind_TempAddr) + if (typedValue.mKind == BfTypedValueKind_RestrictedTempAddr) { Fail(StrFormat("Cannot %s temporary value", modifyType), refNode); return false;