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

Method ProcessMethod_SetupParams

IDEHelper/Compiler/BfModule.cpp:19967–20327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19965}
19966
19967void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfType* thisType, bool wantsDIData, SizedArrayImpl<BfIRMDNode>* diParams)
19968{
19969 auto methodDef = methodInstance->mMethodDef;
19970 auto methodDeclaration = methodDef->mMethodDeclaration;
19971
19972 bool isThisStruct = false;
19973 if (thisType != NULL)
19974 isThisStruct = thisType->IsStruct() && !thisType->IsTypedPrimitive();
19975
19976 int argIdx = 0;
19977
19978 if ((!mIsComptimeModule) && (argIdx == methodInstance->GetStructRetIdx()))
19979 argIdx++;
19980
19981 auto rootMethodState = mCurMethodState->GetRootMethodState();
19982
19983 if (!methodDef->mIsStatic)
19984 {
19985 BfTypeCode loweredTypeCode = BfTypeCode_None;
19986 BfTypeCode loweredTypeCode2 = BfTypeCode_None;
19987
19988 BfLocalVariable* paramVar = rootMethodState->mBumpAlloc.Alloc<BfLocalVariable>();
19989 paramVar->mIsBumpAlloc = true;
19990 paramVar->mResolvedType = thisType;
19991 paramVar->mName.Reference("this");
19992 if (!thisType->IsValuelessType())
19993 paramVar->mValue = mBfIRBuilder->GetArgument(argIdx);
19994 else
19995 paramVar->mValue = mBfIRBuilder->GetFakeVal();
19996
19997 if ((!mIsComptimeModule) && (thisType->IsSplattable()) && (methodInstance->AllowsSplatting(-1)))
19998 {
19999 if (!thisType->IsTypedPrimitive())
20000 paramVar->mIsSplat = true;
20001 }
20002 else if ((!mIsComptimeModule) && (!methodDef->mIsMutating) && (!methodInstance->ForcingThisPtr()))
20003 paramVar->mIsLowered = thisType->GetLoweredType(BfTypeUsage_Parameter, &loweredTypeCode, &loweredTypeCode2) != BfTypeCode_None;
20004
20005 auto thisTypeInst = thisType->ToTypeInstance();
20006 paramVar->mIsStruct = isThisStruct;
20007 paramVar->mAddr = BfIRValue();
20008 paramVar->mIsThis = true;
20009 paramVar->mParamIdx = -1;
20010 if ((methodDef->mMethodType == BfMethodType_Ctor) && (mCurTypeInstance->IsStruct()))
20011 {
20012 paramVar->mAssignedKind = BfLocalVarAssignKind_None;
20013 }
20014 else
20015 {
20016 paramVar->mAssignedKind = BfLocalVarAssignKind_Unconditional;
20017 }
20018
20019 paramVar->mReadFromId = -1;
20020 paramVar->Init();
20021 if (methodDeclaration == NULL)
20022 UseDefaultSrcPos();
20023 AddLocalVariableDef(paramVar);
20024 if (!thisType->IsValuelessType())

Callers

nothing calls this directly

Calls 15

BfIRValueClass · 0.85
FailFunction · 0.85
GetRootMethodStateMethod · 0.80
GetFakeValMethod · 0.80
AllowsSplattingMethod · 0.80
ForcingThisPtrMethod · 0.80
DbgGetTypeMethod · 0.80
DbgCreatePointerTypeMethod · 0.80
IsParamSkippedMethod · 0.80
GetParamNameNodeMethod · 0.80
IsImplicitCaptureMethod · 0.80

Tested by

no test coverage detected