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

Method DoPopulateType_FinishEnum

IDEHelper/Compiler/BfModuleTypeUtils.cpp:3629–3793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3627}
3628
3629void BfModule::DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType)
3630{
3631 if (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotting)
3632 {
3633 // Already locked
3634 return;
3635 }
3636
3637 if (typeInstance->IsEnum())
3638 {
3639 int64 min = 0;
3640 int64 max = 0;
3641
3642 bool isFirst = true;
3643
3644 if (typeInstance->mTypeInfoEx == NULL)
3645 typeInstance->mTypeInfoEx = new BfTypeInfoEx();
3646
3647 bool isAllInt64 = true;
3648
3649 for (auto& fieldInstanceRef : typeInstance->mFieldInstances)
3650 {
3651 auto fieldInstance = &fieldInstanceRef;
3652 auto fieldDef = fieldInstance->GetFieldDef();
3653 if (fieldDef != NULL)
3654 {
3655 if ((fieldInstance->mConstIdx == -1) || (fieldInstance->mResolvedType != typeInstance))
3656 continue;
3657
3658 auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx);
3659 if (constant->mTypeCode != BfTypeCode_Int64)
3660 isAllInt64 = false;
3661
3662 if (isFirst)
3663 {
3664 min = constant->mInt64;
3665 max = constant->mInt64;
3666 isFirst = false;
3667 }
3668 else
3669 {
3670 min = BF_MIN(constant->mInt64, min);
3671 max = BF_MAX(constant->mInt64, max);
3672 }
3673 }
3674 }
3675
3676 typeInstance->mTypeInfoEx->mMinValue = min;
3677 typeInstance->mTypeInfoEx->mMaxValue = max;
3678
3679 if (underlyingTypeDeferred)
3680 {
3681 BfTypeCode typeCode;
3682
3683 if ((min == 0) && (max == 0))
3684 typeCode = BfTypeCode_None;
3685 else if ((min >= -0x80) && (max <= 0x7F))
3686 typeCode = BfTypeCode_Int8;

Callers

nothing calls this directly

Calls 8

GetFieldDefMethod · 0.80
GetConstantByIdMethod · 0.80
IsEnumMethod · 0.45
CreateConstMethod · 0.45
backMethod · 0.45
IsPayloadEnumMethod · 0.45
IsBoxedMethod · 0.45
MixinMethod · 0.45

Tested by

no test coverage detected