| 17290 | } |
| 17291 | |
| 17292 | void BfModule::CreateDelegateInvokeMethod() |
| 17293 | { |
| 17294 | // Clear out debug loc - otherwise we'll single step onto the delegate type declaration |
| 17295 | //mBfIRBuilder->ClearDebugLocation(); |
| 17296 | |
| 17297 | SetIllegalSrcPos(); |
| 17298 | |
| 17299 | auto typeInstance = mCurTypeInstance; |
| 17300 | auto memberFuncType = mBfIRBuilder->MapMethod(mCurMethodInstance); |
| 17301 | SizedArray<BfIRType, 4> staticParamTypes; |
| 17302 | SizedArray<BfIRValue, 4> staticFuncArgs; |
| 17303 | SizedArray<BfIRValue, 4> memberFuncArgs; |
| 17304 | |
| 17305 | auto multicastDelegateType = typeInstance->mBaseType; |
| 17306 | if (multicastDelegateType->mFieldInstances.size() != 2) |
| 17307 | { |
| 17308 | AssertErrorState(); |
| 17309 | return; |
| 17310 | } |
| 17311 | |
| 17312 | auto multicastDelegate = mBfIRBuilder->CreateBitCast(mCurMethodState->mLocals[0]->mValue, mBfIRBuilder->MapType(multicastDelegateType)); |
| 17313 | auto fieldPtr = mBfIRBuilder->CreateInBoundsGEP(multicastDelegate, 0, 2); // Load 'delegate.mTarget' |
| 17314 | auto fieldVal = mBfIRBuilder->CreateAlignedLoad(fieldPtr, mSystem->mPtrSize); |
| 17315 | |
| 17316 | BfExprEvaluator exprEvaluator(this); |
| 17317 | |
| 17318 | SizedArray<BfIRType, 8> origParamTypes; |
| 17319 | BfIRType origReturnType; |
| 17320 | BfIRType staticReturnType; |
| 17321 | mCurMethodInstance->GetIRFunctionInfo(this, origReturnType, origParamTypes); |
| 17322 | |
| 17323 | if (mCurMethodInstance->mReturnType->IsValueType()) |
| 17324 | mBfIRBuilder->PopulateType(mCurMethodInstance->mReturnType, BfIRPopulateType_Full); |
| 17325 | |
| 17326 | if ((mIsComptimeModule) || (mCurMethodInstance->GetStructRetIdx() != 0)) |
| 17327 | memberFuncArgs.push_back(BfIRValue()); // Push 'target' |
| 17328 | |
| 17329 | int thisIdx = 0; |
| 17330 | if ((!mIsComptimeModule) && (mCurMethodInstance->GetStructRetIdx() != -1)) |
| 17331 | { |
| 17332 | thisIdx = mCurMethodInstance->GetStructRetIdx() ^ 1; |
| 17333 | memberFuncArgs.push_back(mBfIRBuilder->GetArgument(mCurMethodInstance->GetStructRetIdx())); |
| 17334 | } |
| 17335 | |
| 17336 | if ((!mIsComptimeModule) && (mCurMethodInstance->GetStructRetIdx(true) != -1)) |
| 17337 | staticFuncArgs.push_back(mBfIRBuilder->GetArgument(mCurMethodInstance->GetStructRetIdx())); |
| 17338 | |
| 17339 | if ((!mIsComptimeModule) && (mCurMethodInstance->GetStructRetIdx() == 0)) |
| 17340 | memberFuncArgs.push_back(BfIRValue()); // Push 'target' |
| 17341 | |
| 17342 | mCurMethodInstance->GetIRFunctionInfo(this, staticReturnType, staticParamTypes, true); |
| 17343 | |
| 17344 | for (int i = 1; i < (int)mCurMethodState->mLocals.size(); i++) |
| 17345 | { |
| 17346 | if (mCurMethodState->mLocals[i]->mCompositeCount >= 0) |
| 17347 | continue; |
| 17348 | BfTypedValue localVal = exprEvaluator.LoadLocal(mCurMethodState->mLocals[i], true); |
| 17349 | exprEvaluator.PushArg(localVal, staticFuncArgs); |
nothing calls this directly
no test coverage detected