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

Method GetAlign

IDEHelper/Compiler/BfResolvedTypeUtils.cpp:615–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615int BfFieldInstance::GetAlign(int packing)
616{
617 int align = mResolvedType->mAlign;
618 if (IsAppendedObject())
619 align = mResolvedType->ToTypeInstance()->mInstAlign;
620 if (packing > 0)
621 align = BF_MIN(align, packing);
622 if (mCustomAttributes != NULL)
623 {
624 auto module = mOwner->mModule;
625 for (auto& attrib : mCustomAttributes->mAttributes)
626 {
627 if (attrib.mType->IsInstanceOf(module->mCompiler->mAlignAttributeTypeDef))
628 {
629 align = 16; // System conservative default
630
631 if (!attrib.mCtorArgs.IsEmpty())
632 {
633 BfIRConstHolder* constHolder = module->mCurTypeInstance->mConstHolder;
634 auto constant = constHolder->GetConstant(attrib.mCtorArgs[0]);
635 if (constant != NULL)
636 {
637 int alignOverride = (int)BF_MAX(1, constant->mInt64);
638 if ((alignOverride & (alignOverride - 1)) == 0)
639 align = alignOverride;
640 else
641 module->Fail("Alignment must be a power of 2", attrib.GetRefNode());
642 }
643 }
644 }
645 }
646 }
647 return align;
648}
649
650bool BfFieldInstance::IsAppendedObject()
651{

Callers 1

DoPopulateTypeMethod · 0.45

Calls 6

ToTypeInstanceMethod · 0.45
IsInstanceOfMethod · 0.45
IsEmptyMethod · 0.45
GetConstantMethod · 0.45
FailMethod · 0.45
GetRefNodeMethod · 0.45

Tested by

no test coverage detected