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:
parent
0631bb2ca8
commit
49ca3b67bf
1 changed files with 13 additions and 1 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue