| 15847 | } |
| 15848 | |
| 15849 | BfTypedValue 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; |
no test coverage detected