MCPcopy Create free account
hub / github.com/beefytech/Beef / GetReflectTypeDecl

Method GetReflectTypeDecl

IDEHelper/Compiler/CeMachine.cpp:3938–4001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3936}
3937
3938addr_ce CeContext::GetReflectTypeDecl(int typeId)
3939{
3940 if (mTypeDeclState == NULL)
3941 mTypeDeclState = new CeTypeDeclState();
3942 if (mTypeDeclState->mReflectDeclMap.IsEmpty())
3943 {
3944 CeRebuildKey rebuildKey;
3945 rebuildKey.mKind = CeRebuildKey::Kind_TypeDeclListHash;
3946 CeRebuildValue rebuildValue;
3947 rebuildValue.mInt = mCeMachine->mCompiler->mSystem->GetTypeDeclListHash();
3948 AddRebuild(rebuildKey, rebuildValue);
3949 }
3950
3951 addr_ce* addrPtr = NULL;
3952 if (!mTypeDeclState->mReflectDeclMap.TryAdd(typeId, NULL, &addrPtr))
3953 return *addrPtr;
3954
3955 auto ceModule = mCeMachine->mCeModule;
3956 SetAndRestoreValue<bool> ignoreWrites(ceModule->mBfIRBuilder->mIgnoreWrites, false);
3957
3958 if (ceModule->mContext->mBfTypeType == NULL)
3959 ceModule->mContext->ReflectInit();
3960
3961 if ((uintptr)typeId >= (uintptr)mCeMachine->mCeModule->mContext->mTypes.mSize)
3962 return 0;
3963 auto bfType = mCeMachine->mCeModule->mContext->mTypes[typeId];
3964 if (bfType == NULL)
3965 return 0;
3966
3967 if (bfType->mDefineState < BfTypeDefineState_HasCustomAttributes)
3968 ceModule->PopulateType(bfType, BfPopulateType_CustomAttributes);
3969
3970 BfProject* curProject = NULL;
3971 auto activeTypeDef = mCurModule->GetActiveTypeDef();
3972 if (activeTypeDef != NULL)
3973 curProject = activeTypeDef->mProject;
3974
3975 if (curProject == NULL)
3976 return 0;
3977
3978 BfCreateTypeDataContext createTypeDataCtx;
3979 auto irData = ceModule->CreateTypeDeclData(bfType, curProject);
3980
3981 BeValue* beValue = NULL;
3982 if (auto constant = mCeMachine->mCeModule->mBfIRBuilder->GetConstant(irData))
3983 {
3984 if (constant->mConstType == BfConstType_BitCast)
3985 {
3986 auto bitcast = (BfConstantBitCast*)constant;
3987 constant = mCeMachine->mCeModule->mBfIRBuilder->GetConstantById(bitcast->mTarget);
3988 }
3989 if (constant->mConstType == BfConstType_GlobalVar)
3990 {
3991 auto globalVar = (BfGlobalVar*)constant;
3992 beValue = mCeMachine->mCeModule->mBfIRBuilder->mBeIRCodeGen->GetBeValue(globalVar->mStreamId);
3993 }
3994 }
3995

Callers

nothing calls this directly

Calls 10

GetTypeDeclListHashMethod · 0.80
ReflectInitMethod · 0.80
GetActiveTypeDefMethod · 0.80
CreateTypeDeclDataMethod · 0.80
GetConstantByIdMethod · 0.80
GetBeValueMethod · 0.80
IsEmptyMethod · 0.45
TryAddMethod · 0.45
PopulateTypeMethod · 0.45
GetConstantMethod · 0.45

Tested by

no test coverage detected