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

Method GetThis

IDEHelper/Compiler/BfModule.cpp:15849–16035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15847}
15848
15849BfTypedValue BfModule::GetThis(bool markUsing)
15850{
15851 if ((mIsComptimeModule) && (mCompiler->mCeMachine->mDebugger != NULL) && (mCompiler->mCeMachine->mDebugger->mCurDbgState != NULL))
15852 {
15853 if (mCompiler->mCeMachine->mDebugger->mCurDbgState->mExplicitThis)
15854 return mCompiler->mCeMachine->mDebugger->mCurDbgState->mExplicitThis;
15855
15856 auto ceDebugger = mCompiler->mCeMachine->mDebugger;
15857 auto activeFrame = ceDebugger->mCurDbgState->mActiveFrame;
15858 if ((activeFrame != NULL) && (activeFrame->mFunction->mDbgInfo != NULL))
15859 {
15860 for (auto& dbgVar : activeFrame->mFunction->mDbgInfo->mVariables)
15861 {
15862 if (dbgVar.mName == "this")
15863 return BfTypedValue(mBfIRBuilder->CreateConstAggCE(mBfIRBuilder->MapType(dbgVar.mType), activeFrame->mFrameAddr + dbgVar.mValue.mFrameOfs), dbgVar.mType,
15864 dbgVar.mIsConst ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr);
15865 }
15866 }
15867
15868 return BfTypedValue();
15869 }
15870
15871 auto useMethodState = mCurMethodState;
15872 while ((useMethodState != NULL) && (useMethodState->mClosureState != NULL) && (useMethodState->mClosureState->mCapturing))
15873 {
15874 useMethodState = useMethodState->mPrevMethodState;
15875 }
15876
15877 if (useMethodState != NULL)
15878 {
15879 // Fake a 'this' for var field resolution
15880 if (useMethodState->mTempKind == BfMethodState::TempKind_NonStatic)
15881 {
15882 auto thisType = mCurTypeInstance;
15883 if (thisType->IsValueType())
15884 return BfTypedValue(mBfIRBuilder->CreateConstNull(mBfIRBuilder->MapTypeInstPtr(thisType)), thisType, BfTypedValueKind_ThisAddr);
15885 else
15886 return BfTypedValue(mBfIRBuilder->CreateConstNull(mBfIRBuilder->MapTypeInst(thisType)), thisType, BfTypedValueKind_ThisValue);
15887 }
15888 else if (useMethodState->mTempKind == BfMethodState::TempKind_Static)
15889 {
15890 return BfTypedValue();
15891 }
15892 }
15893 else
15894 {
15895 //TODO: Do we allow useMethodState to be NULL anymore?
15896 return BfTypedValue();
15897 }
15898
15899 // Check mixin state for 'this'
15900 {
15901 auto checkMethodState = mCurMethodState;
15902 while (checkMethodState != NULL)
15903 {
15904 if (checkMethodState->mMixinState != NULL)
15905 {
15906 BfTypedValue thisValue = checkMethodState->mMixinState->mTarget;

Callers 9

LoadLocalMethod · 0.45
LookupIdentifierMethod · 0.45
MatchMethodMethod · 0.45
LookupQualifiedNameMethod · 0.45
VisitMethod · 0.45
DoImplicitArgCaptureMethod · 0.45
InjectMixinMethod · 0.45
DoInvocationMethod · 0.45

Calls 15

BfTypedValueClass · 0.85
CreateConstAggCEMethod · 0.80
MapTypeMethod · 0.80
CreateConstNullMethod · 0.80
MapTypeInstPtrMethod · 0.80
MapTypeInstMethod · 0.80
HasTypeMethod · 0.80
GetRootMethodStateMethod · 0.80
GetFakeValMethod · 0.80
GetFieldDefMethod · 0.80
CreateInBoundsGEPMethod · 0.80
ForcingThisPtrMethod · 0.80

Tested by

no test coverage detected