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

Method MakeAddressable

IDEHelper/Compiler/BfModule.cpp:13810–13850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13808}
13809
13810BfTypedValue BfModule::MakeAddressable(BfTypedValue typedVal, bool forceMutable, bool forceAddressable)
13811{
13812 if (!typedVal)
13813 return typedVal;
13814
13815 bool wasReadOnly = typedVal.IsReadOnly();
13816
13817 if ((forceAddressable) ||
13818 ((typedVal.mType->IsValueType()) &&
13819 (!typedVal.mType->IsValuelessNonOpaqueType())))
13820 {
13821 wasReadOnly = true; // Any non-addr is implicitly read-only
13822
13823 //static int gCallIdx = 0;
13824 FixValueActualization(typedVal);
13825 if (typedVal.IsAddr())
13826 return typedVal;
13827 BfType* type = typedVal.mType;
13828 PopulateType(type);
13829 BfIRValue tempVar;
13830 if (typedVal.mValue.IsFake())
13831 tempVar = mBfIRBuilder->GetFakeVal();
13832 else
13833 {
13834 tempVar = CreateAlloca(type);
13835 if (typedVal.IsSplat())
13836 AggregateSplatIntoAddr(typedVal, tempVar);
13837 else
13838 mBfIRBuilder->CreateAlignedStore(typedVal.mValue, tempVar, type->mAlign);
13839 }
13840
13841 if (forceMutable)
13842 wasReadOnly = false;
13843
13844 return BfTypedValue(tempVar, type,
13845 typedVal.IsThis() ?
13846 (wasReadOnly ? BfTypedValueKind_ReadOnlyThisAddr : BfTypedValueKind_ThisAddr) :
13847 (wasReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr));
13848 }
13849 return LoadValue(typedVal);
13850}
13851
13852BfTypedValue BfModule::RemoveReadOnly(BfTypedValue typedValue)
13853{

Callers 15

CheckMemberReferenceMethod · 0.80
LoadFieldMethod · 0.80
PushArgMethod · 0.80
PushThisMethod · 0.80
CreateCallMethod · 0.80
MatchMethodMethod · 0.80
LookupQualifiedNameMethod · 0.80
VisitMethod · 0.80
MakeCallableTargetMethod · 0.80
DoInvocationMethod · 0.80
SetupNullConditionalMethod · 0.80
DoMemberReferenceMethod · 0.80

Calls 10

BfTypedValueClass · 0.85
IsReadOnlyMethod · 0.80
IsAddrMethod · 0.80
GetFakeValMethod · 0.80
IsSplatMethod · 0.80
IsThisMethod · 0.80
IsValueTypeMethod · 0.45
IsFakeMethod · 0.45
CreateAlignedStoreMethod · 0.45

Tested by

no test coverage detected