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

Method EmitObjectAccessCheck

IDEHelper/Compiler/BfModule.cpp:10857–10894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10855}
10856
10857void BfModule::EmitObjectAccessCheck(BfTypedValue typedVal)
10858{
10859 if ((mBfIRBuilder->mIgnoreWrites) || (!typedVal.mType->IsObjectOrInterface()) || (mCurMethodState == NULL) || (mCurMethodState->mIgnoreObjectAccessCheck))
10860 return;
10861
10862 if ((!mCompiler->mOptions.mObjectHasDebugFlags) || (mIsComptimeModule))
10863 return;
10864
10865 if (typedVal.mValue.IsConst())
10866 {
10867 int stringIdx = GetStringPoolIdx(typedVal.mValue, mBfIRBuilder);
10868 if (stringIdx != -1)
10869 return;
10870 auto constant = mBfIRBuilder->GetConstant(typedVal.mValue);
10871 if (constant->mTypeCode == BfTypeCode_NullPtr)
10872 return;
10873 if (constant->mConstType == BfConstType_BitCastNull)
10874 return;
10875 }
10876
10877 bool emitObjectAccessCheck = mCompiler->mOptions.mEmitObjectAccessCheck;
10878 auto typeOptions = GetTypeOptions();
10879 if (typeOptions != NULL)
10880 emitObjectAccessCheck = typeOptions->Apply(emitObjectAccessCheck, BfOptionFlags_EmitObjectAccessCheck);
10881 if (!emitObjectAccessCheck)
10882 return;
10883
10884 if ((typedVal.mValue.mFlags & BfIRValueFlags_Value) != 0)
10885 {
10886 if (mCurMethodState->mSkipObjectAccessChecks.Contains(typedVal.mValue.mId))
10887 return;
10888 }
10889
10890 if (typedVal.IsAddr())
10891 typedVal = LoadValue(typedVal);
10892
10893 mBfIRBuilder->CreateObjectAccessCheck(typedVal.mValue, !IsOptimized());
10894}
10895
10896bool BfModule::WantsDebugHelpers()
10897{

Callers 3

LoadFieldMethod · 0.80
CreateCallMethod · 0.80
GetResultMethod · 0.80

Calls 7

IsAddrMethod · 0.80
IsObjectOrInterfaceMethod · 0.45
IsConstMethod · 0.45
GetConstantMethod · 0.45
ApplyMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected