diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index b27b3d98..90eb05e5 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -4340,31 +4340,7 @@ BfTypedValue BfExprEvaluator::LoadLocal(BfLocalVariable* varDecl, bool allowRef) } else if (varDecl->mConstValue) { - localResult = BfTypedValue(varDecl->mConstValue, varDecl->mResolvedType, false); - - if ((varDecl->mResolvedType->IsRef()) && (!allowRef)) - { - BfRefType* refType = (BfRefType*)varDecl->mResolvedType; - BfType* innerType = refType->mElementType; - - if (innerType->IsValuelessNonOpaqueType()) - { - if (refType->mRefKind == BfRefType::RefKind_Mut) - return BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), innerType, BfTypedValueKind_MutableValue); - return BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), innerType, varDecl->mIsReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr); - } - - if (refType->mRefKind == BfRefType::RefKind_Mut) - { - if (innerType->IsGenericParam()) - { - localResult = BfTypedValue(varDecl->mConstValue, innerType, BfTypedValueKind_MutableValue); - return localResult; - } - } - - localResult = BfTypedValue(varDecl->mConstValue, innerType, varDecl->mIsReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr); - } + localResult = BfTypedValue(varDecl->mConstValue, varDecl->mResolvedType, false); } else if (varDecl->mIsSplat) { diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index d8ff8714..a38840a7 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -666,6 +666,10 @@ bool BfIRConstHolder::IsConstValue(BfIRValue value) return false; if (constant->mConstType == BfConstType_Undef) return false; + if (constant->mConstType == BfConstType_GEP32_2) + return IsConstValue(BfIRValue(BfIRValueFlags_Const, ((BfConstantGEP32_2*)constant)->mTarget)); + if (constant->mConstType == BfConstType_BitCast) + return IsConstValue(BfIRValue(BfIRValueFlags_Const, ((BfConstantBitCast*)constant)->mTarget)); return true; } diff --git a/IDEHelper/Compiler/BfStmtEvaluator.cpp b/IDEHelper/Compiler/BfStmtEvaluator.cpp index 0af8a1d5..ef72c27c 100644 --- a/IDEHelper/Compiler/BfStmtEvaluator.cpp +++ b/IDEHelper/Compiler/BfStmtEvaluator.cpp @@ -1714,10 +1714,10 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD localDef->mIsReadOnly = true; if (initValue) { - if ((initValue.mValue) && (initValue.mValue.IsConst())) + if (mBfIRBuilder->IsConstValue(initValue.mValue)) { isConst = true; - } + } } } }