mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Suppress 'unreachable code' for 'System.Compiler' comparison branches
This commit is contained in:
parent
7cb92e4007
commit
87d403f72e
4 changed files with 52 additions and 2 deletions
|
@ -12483,7 +12483,20 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
|
|||
{
|
||||
BfTypedValue result = GetCompilerFieldValue(globalVar->mName);
|
||||
if (result)
|
||||
{
|
||||
// We want to avoid 'unreachable code' issues from values that
|
||||
// are technically constant but change depending on compilation context
|
||||
if (mCurMethodState != NULL)
|
||||
{
|
||||
auto checkScope = mCurMethodState->mCurScope;
|
||||
while (checkScope != NULL)
|
||||
{
|
||||
checkScope->mSupressNextUnreachable = true;
|
||||
checkScope = checkScope->mPrevScope;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return GetDefaultTypedValue(typedValue.mType);
|
||||
}
|
||||
}
|
||||
|
@ -14577,6 +14590,32 @@ BfTypedValue BfModule::GetCompilerFieldValue(const StringImpl& str)
|
|||
return BfTypedValue();
|
||||
}
|
||||
|
||||
BfTypedValue BfModule::GetCompilerFieldValue(BfTypedValue typedValue)
|
||||
{
|
||||
if (!typedValue.IsAddr())
|
||||
return BfTypedValue();
|
||||
|
||||
if (typedValue.mValue.IsConst())
|
||||
{
|
||||
auto constantValue = mBfIRBuilder->GetConstant(typedValue.mValue);
|
||||
if (constantValue != NULL)
|
||||
{
|
||||
if (constantValue->mConstType == BfConstType_GlobalVar)
|
||||
{
|
||||
auto globalVar = (BfGlobalVar*)constantValue;
|
||||
if (globalVar->mName[0] == '#')
|
||||
{
|
||||
BfTypedValue result = GetCompilerFieldValue(globalVar->mName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BfTypedValue();
|
||||
}
|
||||
|
||||
|
||||
BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
||||
{
|
||||
BfIRValue globalValue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue