| 122 | } |
| 123 | |
| 124 | void BeContext::SetStructBody(BeStructType* structType, const SizedArrayImpl<BeType*>& types, bool packed) |
| 125 | { |
| 126 | BF_ASSERT(structType->mMembers.IsEmpty()); |
| 127 | |
| 128 | int dataPos = 0; |
| 129 | for (auto& beType : types) |
| 130 | { |
| 131 | if (!packed) |
| 132 | { |
| 133 | int alignSize = beType->mAlign; |
| 134 | dataPos = (dataPos + (alignSize - 1)) & ~(alignSize - 1); |
| 135 | } |
| 136 | BF_ASSERT(beType->mSize >= 0); |
| 137 | BeStructMember member; |
| 138 | member.mType = beType; |
| 139 | member.mByteOffset = dataPos; |
| 140 | dataPos += beType->mSize; |
| 141 | if (packed) |
| 142 | structType->mAlign = 1; |
| 143 | else |
| 144 | structType->mAlign = std::max(structType->mAlign, beType->mAlign); |
| 145 | structType->mMembers.push_back(member); |
| 146 | } |
| 147 | if (!packed) |
| 148 | { |
| 149 | int alignSize = structType->mAlign; |
| 150 | dataPos = (dataPos + (alignSize - 1)) & ~(alignSize - 1); |
| 151 | } |
| 152 | structType->mSize = dataPos; |
| 153 | structType->mIsPacked = packed; |
| 154 | structType->mIsOpaque = false; |
| 155 | } |
| 156 | |
| 157 | BeSizedArrayType* BeContext::CreateSizedArrayType(BeType* type, int length) |
| 158 | { |
no test coverage detected