| 4321 | } |
| 4322 | |
| 4323 | bool CeContext::GetCustomAttribute(BfModule* module, BfIRConstHolder* constHolder, BfCustomAttributes* customAttributes, int attributeIdx, addr_ce resultAddr) |
| 4324 | { |
| 4325 | if (customAttributes == NULL) |
| 4326 | return false; |
| 4327 | |
| 4328 | auto customAttr = customAttributes->Get(attributeIdx); |
| 4329 | if (customAttr == NULL) |
| 4330 | return false; |
| 4331 | |
| 4332 | auto ceContext = mCeMachine->AllocContext(); |
| 4333 | BfIRValue foreignValue = ceContext->CreateAttribute(mCurCallSource->mRefNode, module, constHolder, customAttr); |
| 4334 | auto foreignConstant = module->mBfIRBuilder->GetConstant(foreignValue); |
| 4335 | if (foreignConstant->mConstType == BfConstType_AggCE) |
| 4336 | { |
| 4337 | auto constAggData = (BfConstantAggCE*)foreignConstant; |
| 4338 | auto value = ceContext->CreateConstant(module, ceContext->mMemory.mVals + constAggData->mCEAddr, customAttr->mType); |
| 4339 | if (!value) |
| 4340 | Fail("Failed to encoded attribute"); |
| 4341 | auto attrConstant = module->mBfIRBuilder->GetConstant(value); |
| 4342 | if ((attrConstant == NULL) || (!WriteConstant(module, resultAddr, attrConstant, customAttr->mType))) |
| 4343 | Fail("Failed to decode attribute"); |
| 4344 | } |
| 4345 | |
| 4346 | mCeMachine->ReleaseContext(ceContext); |
| 4347 | |
| 4348 | return true; |
| 4349 | } |
| 4350 | |
| 4351 | BfType* CeContext::GetCustomAttributeType(BfCustomAttributes* customAttributes, int attributeIdx) |
| 4352 | { |
nothing calls this directly
no test coverage detected