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

Method GetCustomAttribute

IDEHelper/Compiler/CeMachine.cpp:4323–4349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4321}
4322
4323bool 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
4351BfType* CeContext::GetCustomAttributeType(BfCustomAttributes* customAttributes, int attributeIdx)
4352{

Callers

nothing calls this directly

Calls 7

FailFunction · 0.85
AllocContextMethod · 0.80
CreateAttributeMethod · 0.80
CreateConstantMethod · 0.80
ReleaseContextMethod · 0.80
GetMethod · 0.45
GetConstantMethod · 0.45

Tested by

no test coverage detected