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

Method MakeCallableTarget

IDEHelper/Compiler/BfExprEvaluator.cpp:17274–17349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17272}
17273
17274BfTypedValue BfExprEvaluator::MakeCallableTarget(BfAstNode* targetSrc, BfTypedValue target)
17275{
17276 if ((target.mType->IsRef()) || (target.mType->IsPointer()))
17277 {
17278 auto underlying = target.mType->GetUnderlyingType();
17279 bool underlyingIsStruct = underlying->IsStruct();
17280
17281 if (underlyingIsStruct)
17282 {
17283 target = mModule->LoadValue(target);
17284 target.mType = underlying;
17285 target.mKind = BfTypedValueKind_Addr;
17286 }
17287 }
17288
17289 if ((target.mType->IsStruct()) && (!target.IsAddr()))
17290 {
17291 if (IsConstEval())
17292 return target;
17293 target = mModule->MakeAddressable(target);
17294 }
17295
17296 if (IsVar(target.mType))
17297 {
17298 target.mType = mModule->mContext->mBfObjectType;
17299 return target;
17300 }
17301
17302 if (target.mType->IsWrappableType())
17303 {
17304 auto primStructType = mModule->GetWrappedStructType(target.mType);
17305 if (primStructType != NULL)
17306 {
17307 mModule->PopulateType(primStructType);
17308
17309 if (primStructType->IsTypedPrimitive())
17310 {
17311 // Type is already the same
17312 target.mType = primStructType;
17313 }
17314 else if (target.IsAddr())
17315 {
17316 auto ptrType = mModule->CreatePointerType(primStructType);
17317 target = BfTypedValue(mModule->mBfIRBuilder->CreateBitCast(target.mValue, mModule->mBfIRBuilder->MapType(ptrType)), primStructType, true);
17318 }
17319 else if ((primStructType->IsSplattable()) && (target.IsSplat()) && (!IsComptime()))
17320 {
17321 target.mType = primStructType;
17322 target.mKind = BfTypedValueKind_SplatHead;
17323 }
17324 else
17325 {
17326 auto allocPtr = mModule->CreateAlloca(primStructType);
17327 auto srcPtrType = mModule->mBfIRBuilder->CreateBitCast(allocPtr, mModule->mBfIRBuilder->GetPointerTo(mModule->mBfIRBuilder->MapType(target.mType)));
17328 mModule->mBfIRBuilder->CreateStore(target.mValue, srcPtrType);
17329 target = BfTypedValue(allocPtr, primStructType, true);
17330 }
17331 }

Callers

nothing calls this directly

Calls 15

BfTypedValueClass · 0.85
LoadValueMethod · 0.80
IsAddrMethod · 0.80
MakeAddressableMethod · 0.80
GetWrappedStructTypeMethod · 0.80
CreatePointerTypeMethod · 0.80
MapTypeMethod · 0.80
IsSplatMethod · 0.80
IsRefMethod · 0.45
IsPointerMethod · 0.45
GetUnderlyingTypeMethod · 0.45
IsStructMethod · 0.45

Tested by

no test coverage detected