mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-24 18:48:01 +02:00
Added const expr reflection type
This commit is contained in:
parent
674f0f6a56
commit
0eb19245eb
6 changed files with 214 additions and 23 deletions
|
@ -447,6 +447,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
|||
mReflectPointerType = NULL;
|
||||
mReflectRefType = NULL;
|
||||
mReflectSizedArrayType = NULL;
|
||||
mReflectConstExprType = NULL;
|
||||
mReflectSpecializedGenericType = NULL;
|
||||
mReflectTypeInstanceTypeDef = NULL;
|
||||
mReflectUnspecializedGenericType = NULL;
|
||||
|
@ -6805,6 +6806,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
mReflectPointerType = _GetRequiredType("System.Reflection.PointerType");
|
||||
mReflectRefType = _GetRequiredType("System.Reflection.RefType");
|
||||
mReflectSizedArrayType = _GetRequiredType("System.Reflection.SizedArrayType");
|
||||
mReflectConstExprType = _GetRequiredType("System.Reflection.ConstExprType");
|
||||
mReflectSpecializedGenericType = _GetRequiredType("System.Reflection.SpecializedGenericType");
|
||||
mReflectTypeInstanceTypeDef = _GetRequiredType("System.Reflection.TypeInstance");
|
||||
mReflectUnspecializedGenericType = _GetRequiredType("System.Reflection.UnspecializedGenericType");
|
||||
|
|
|
@ -402,6 +402,7 @@ public:
|
|||
BfTypeDef* mReflectPointerType;
|
||||
BfTypeDef* mReflectRefType;
|
||||
BfTypeDef* mReflectSizedArrayType;
|
||||
BfTypeDef* mReflectConstExprType;
|
||||
BfTypeDef* mReflectSpecializedGenericType;
|
||||
BfTypeDef* mReflectTypeInstanceTypeDef;
|
||||
BfTypeDef* mReflectUnspecializedGenericType;
|
||||
|
|
|
@ -5333,6 +5333,8 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
typeDataSource = ResolveTypeDef(mCompiler->mReflectRefType)->ToTypeInstance();
|
||||
else if (type->IsSizedArray())
|
||||
typeDataSource = ResolveTypeDef(mCompiler->mReflectSizedArrayType)->ToTypeInstance();
|
||||
else if (type->IsConstExprValue())
|
||||
typeDataSource = ResolveTypeDef(mCompiler->mReflectConstExprType)->ToTypeInstance();
|
||||
else
|
||||
typeDataSource = mContext->mBfTypeType;
|
||||
|
||||
|
@ -5430,6 +5432,8 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
typeFlags |= BfTypeFlags_Nullable;
|
||||
if (type->IsSizedArray())
|
||||
typeFlags |= BfTypeFlags_SizedArray;
|
||||
if (type->IsConstExprValue())
|
||||
typeFlags |= BfTypeFlags_ConstExpr;
|
||||
if (type->IsSplattable())
|
||||
typeFlags |= BfTypeFlags_Splattable;
|
||||
if (type->IsUnion())
|
||||
|
@ -5545,6 +5549,23 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
mBfIRBuilder->GlobalVar_SetAlignment(typeDataVar, mSystem->mPtrSize);
|
||||
typeDataVar = mBfIRBuilder->CreateBitCast(typeDataVar, mBfIRBuilder->MapType(mContext->mBfTypeType));
|
||||
}
|
||||
else if (type->IsConstExprValue())
|
||||
{
|
||||
auto constExprType = (BfConstExprValueType*)type;
|
||||
SizedArray<BfIRValue, 3> constExprTypeDataParms =
|
||||
{
|
||||
typeData,
|
||||
GetConstValue(constExprType->mType->mTypeId, typeIdType),
|
||||
GetConstValue(constExprType->mValue.mInt64, longType)
|
||||
};
|
||||
|
||||
auto reflectConstExprType = ResolveTypeDef(mCompiler->mReflectConstExprType)->ToTypeInstance();
|
||||
auto ConstExprTypeData = mBfIRBuilder->CreateConstAgg_Value(mBfIRBuilder->MapTypeInst(reflectConstExprType, BfIRPopulateType_Full), constExprTypeDataParms);
|
||||
typeDataVar = mBfIRBuilder->CreateGlobalVariable(mBfIRBuilder->MapTypeInst(reflectConstExprType), true,
|
||||
BfIRLinkageType_External, ConstExprTypeData, typeDataName);
|
||||
mBfIRBuilder->GlobalVar_SetAlignment(typeDataVar, mSystem->mPtrSize);
|
||||
typeDataVar = mBfIRBuilder->CreateBitCast(typeDataVar, mBfIRBuilder->MapType(mContext->mBfTypeType));
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDataVar = mBfIRBuilder->CreateGlobalVariable(mBfIRBuilder->MapTypeInst(mContext->mBfTypeType), true,
|
||||
|
|
|
@ -180,11 +180,12 @@ enum BfTypeFlags
|
|||
BfTypeFlags_SizedArray = 0x1000,
|
||||
BfTypeFlags_Splattable = 0x2000,
|
||||
BfTypeFlags_Union = 0x4000,
|
||||
BfTypeFlags_ConstExpr = 0x8000,
|
||||
//
|
||||
BfTypeFlags_WantsMarking = 0x8000,
|
||||
BfTypeFlags_Delegate = 0x10000,
|
||||
BfTypeFlags_Function = 0x20000,
|
||||
BfTypeFlags_HasDestructor = 0x40000,
|
||||
BfTypeFlags_WantsMarking = 0x10000,
|
||||
BfTypeFlags_Delegate = 0x20000,
|
||||
BfTypeFlags_Function = 0x40000,
|
||||
BfTypeFlags_HasDestructor = 0x80000,
|
||||
};
|
||||
|
||||
enum BfMethodFlags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue