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

Method LoadProperty

IDEHelper/Compiler/BfExprEvaluator.cpp:5117–5298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5115}
5116
5117BfTypedValue BfExprEvaluator::LoadProperty(BfAstNode* targetSrc, BfTypedValue target, BfTypeInstance* typeInstance, BfPropertyDef* prop, BfLookupFieldFlags flags, BfCheckedKind checkedKind, bool isInlined)
5118{
5119 BfTypedValue origTarget = target;
5120 if ((target.mType != NULL) && (target.mType->IsStructPtr()))
5121 {
5122 target = mModule->LoadValue(target);
5123 target = BfTypedValue(target.mValue, target.mType->GetUnderlyingType(), target.IsReadOnly() ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
5124 }
5125
5126 if ((flags & BfLookupFieldFlag_IsAnonymous) == 0)
5127 mModule->SetElementType(targetSrc, BfSourceElementType_Method);
5128
5129 if ((!prop->mIsStatic) && ((flags & BfLookupFieldFlag_IsImplicitThis) != 0))
5130 mModule->MarkUsingThis();
5131
5132 mPropSrc = targetSrc;
5133 mPropDef = prop;
5134 mPropCheckedKind = checkedKind;
5135 if (isInlined)
5136 mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_ForceInline);
5137
5138 if ((mModule->mAttributeState != NULL) && (mModule->mAttributeState->mCustomAttributes != NULL))
5139 {
5140 if (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mFriendAttributeTypeDef))
5141 {
5142 mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_Friend);
5143 mModule->mAttributeState->mUsed = true;
5144 }
5145 if (mModule->mAttributeState->mCustomAttributes->Contains(mModule->mCompiler->mDisableObjectAccessChecksAttributeTypeDef))
5146 {
5147 mPropGetMethodFlags = (BfGetMethodInstanceFlags)(mPropGetMethodFlags | BfGetMethodInstanceFlag_DisableObjectAccessChecks);
5148 mModule->mAttributeState->mUsed = true;
5149 }
5150 }
5151
5152 if (mPropDef->mIsStatic)
5153 {
5154 if ((target) && ((flags & BfLookupFieldFlag_IsImplicitThis) == 0) && (!typeInstance->mTypeDef->IsGlobalsContainer()))
5155 {
5156 //CS0176: Member 'Program.sVal' cannot be accessed with an instance reference; qualify it with a type name instead
5157 mModule->Fail(StrFormat("Property '%s.%s' cannot be accessed with an instance reference; qualify it with a type name instead",
5158 mModule->TypeToString(typeInstance).c_str(), mPropDef->mName.c_str()), targetSrc);
5159 }
5160 }
5161
5162 bool isBaseLookup = (target.mType) && (typeInstance != target.mType);
5163 if ((isBaseLookup) && (target.mType->IsWrappableType()))
5164 isBaseLookup = false;
5165
5166 if (prop->mIsStatic)
5167 mPropTarget = BfTypedValue(typeInstance);
5168 else if (isBaseLookup)
5169 {
5170 if (target.mValue.IsFake())
5171 {
5172 mPropTarget = BfTypedValue(target.mValue, typeInstance, target.mKind);
5173 }
5174 else

Callers

nothing calls this directly

Calls 15

BfTypedValueClass · 0.85
LoadValueMethod · 0.80
IsReadOnlyMethod · 0.80
MarkUsingThisMethod · 0.80
GetBasePropertyDefMethod · 0.80
IsAutocompleteNodeMethod · 0.80
SetDefinitionLocationMethod · 0.80
HasAutoPropertyMethod · 0.80
GetAutoPropertyNameMethod · 0.80
MakeReadOnlyMethod · 0.80
IsStructPtrMethod · 0.45

Tested by

no test coverage detected