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

Method PrepareMethodArguments

IDEHelper/Compiler/BfConstResolver.cpp:245–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245bool BfConstResolver::PrepareMethodArguments(BfAstNode* targetSrc, BfMethodMatcher* methodMatcher, Array<BfIRValue>& llvmArgs)
246{
247 int argIdx = 0;
248 int paramIdx = 0;
249
250 int extendedParamIdx = 0;
251
252 SetAndRestoreValue<bool> ignoreWrites(mModule->mBfIRBuilder->mIgnoreWrites, true);
253
254 llvm::SmallVector<BfIRValue, 4> expandedParamsConstValues;
255 BfType* expandedParamsElementType = NULL;
256
257 // We don't do GetMethodInstance in mModule, because our module may not have init finished yet
258 //auto targetModule = methodMatcher->mBestMethodTypeInstance->mModule;
259 auto targetModule = mModule->mContext->mUnreifiedModule;
260 auto moduleMethodInstance = targetModule->GetMethodInstance(methodMatcher->mBestMethodTypeInstance, methodMatcher->mBestMethodDef, methodMatcher->mBestMethodGenericArguments);
261 auto methodInstance = moduleMethodInstance.mMethodInstance;
262
263 if (methodInstance->mReturnType == NULL)
264 {
265 mModule->AssertErrorState();
266 return false;
267 }
268
269 auto methodDef = methodMatcher->mBestMethodDef;
270 auto& arguments = methodMatcher->mArguments;
271
272 mModule->AddDependency(methodInstance->mReturnType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_LocalUsage);
273 for (int paramIdx = 0; paramIdx < methodInstance->GetParamCount(); paramIdx++)
274 {
275 auto paramType = methodInstance->GetParamType(paramIdx);
276 mModule->AddDependency(paramType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_LocalUsage);
277 }
278
279 while (true)
280 {
281 if (paramIdx >= (int)methodInstance->GetParamCount())
282 {
283 if (argIdx < (int)arguments.size())
284 {
285 BfAstNode* errorRef = arguments[methodInstance->GetParamCount()].mExpression;
286 if (errorRef->GetSourceData() == NULL)
287 errorRef = targetSrc;
288 mModule->Fail(StrFormat("Too many arguments. Expected %d fewer.", (int)arguments.size() - methodInstance->GetParamCount()), errorRef);
289 if (methodInstance->mMethodDef->mMethodDeclaration != NULL)
290 mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See method declaration"), methodInstance->mMethodDef->mMethodDeclaration);
291 return false;
292 }
293 break;
294 }
295
296 BfType* wantType = NULL;
297 if (expandedParamsElementType != NULL)
298 {
299 wantType = expandedParamsElementType;
300 }
301 else
302 {

Callers 1

GetCustomAttributesMethod · 0.80

Calls 15

BfTypedValueClass · 0.85
AssertErrorStateMethod · 0.80
AddDependencyMethod · 0.80
GetSourceDataMethod · 0.80
MoreInfoMethod · 0.80
GetParamKindMethod · 0.80
CheckEmptyStartMethod · 0.80
PreFailMethod · 0.80
GetDefaultValueMethod · 0.80
MapTypeMethod · 0.80
CreateConstAggMethod · 0.80

Tested by

no test coverage detected