1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +02:00

Fixed reflection of compile-time compiler constants

This commit is contained in:
Brian Fiete 2020-09-16 04:38:44 -07:00
parent 0631bb2ca8
commit 49ca3b67bf

View file

@ -5881,12 +5881,24 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
if (fieldInstance->mConstIdx != -1) if (fieldInstance->mConstIdx != -1)
{ {
auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx); auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx);
constValue = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, constant->mUInt64); constValue = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, constant->mUInt64);
} }
} }
else if (fieldInstance->GetFieldDef()->mIsStatic) else if (fieldInstance->GetFieldDef()->mIsStatic)
{ {
auto refVal = ReferenceStaticField(fieldInstance); auto refVal = ReferenceStaticField(fieldInstance);
if (refVal.mValue.IsConst())
{
auto constant = mBfIRBuilder->GetConstant(refVal.mValue);
if (constant->mConstType == BfConstType_GlobalVar)
{
auto globalVar = (BfGlobalVar*)constant;
if (globalVar->mName[0] == '#')
refVal = BfTypedValue();
}
}
if (refVal.IsAddr()) if (refVal.IsAddr())
{ {
constValue = mBfIRBuilder->CreatePtrToInt(refVal.mValue, BfTypeCode_IntPtr); constValue = mBfIRBuilder->CreatePtrToInt(refVal.mValue, BfTypeCode_IntPtr);