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

Method GetLocalMethodDef

IDEHelper/Compiler/BfModule.cpp:23271–23401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23269}
23270
23271BfMethodDef* BfModule::GetLocalMethodDef(BfLocalMethod* localMethod)
23272{
23273 if (localMethod->mMethodDef != NULL)
23274 return localMethod->mMethodDef;
23275
23276 auto rootMethodState = mCurMethodState->GetRootMethodState();
23277 auto declMethodState = localMethod->mDeclMethodState;
23278 auto declMixinState = localMethod->mDeclMixinState;
23279
23280 auto typeInst = mCurTypeInstance;
23281 BfAstNode* body = NULL;
23282 BfAstNode* anchorNode = NULL;
23283
23284 auto _AllocDirectTypeRef = [&](BfType* type)
23285 {
23286 BfDirectTypeReference* directTypeRef = localMethod->mDirectTypeRefs.Alloc();
23287 directTypeRef->Init(type);
23288 return directTypeRef;
23289 };
23290
23291 auto methodDeclaration = localMethod->mMethodDeclaration;
23292 if (methodDeclaration != NULL)
23293 {
23294 body = methodDeclaration->mBody;
23295 anchorNode = methodDeclaration->mOpenParen;
23296 }
23297 else
23298 {
23299 body = localMethod->mLambdaBindExpr->mBody;
23300 anchorNode = localMethod->mLambdaBindExpr->mFatArrowToken;
23301 }
23302
23303 BF_ASSERT(rootMethodState->mCurLocalVarId >= 0);
23304 int methodLocalIdx = rootMethodState->mCurLocalVarId++;
23305
23306 BfMethodDef* methodDef;
23307
23308 BfMethodDef* outerMethodDef = NULL;
23309 if (localMethod->mOuterLocalMethod != NULL)
23310 outerMethodDef = localMethod->mOuterLocalMethod->mMethodDef;
23311 else if (rootMethodState->mMethodInstance != NULL)
23312 outerMethodDef = rootMethodState->mMethodInstance->mMethodDef;
23313
23314 if (methodDeclaration != NULL)
23315 {
23316 BfDefBuilder defBuilder(mCompiler->mSystem);
23317 defBuilder.mCurSource = localMethod->mMethodDeclaration->GetParser();
23318 defBuilder.mPassInstance = mCompiler->mPassInstance;
23319 defBuilder.mCurTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
23320 defBuilder.mCurDeclaringTypeDef = defBuilder.mCurTypeDef;
23321 methodDef = defBuilder.CreateMethodDef(methodDeclaration, outerMethodDef);
23322 }
23323 else
23324 {
23325 auto invokeMethod = localMethod->mLambdaInvokeMethodInstance;
23326
23327 methodDef = new BfMethodDef();
23328 methodDef->mName = localMethod->mMethodName;

Callers 1

CheckLocalMethodsMethod · 0.80

Calls 15

GetRootMethodStateMethod · 0.80
GetParserMethod · 0.80
CreateMethodDefMethod · 0.80
HandleLocalReferenceMethod · 0.80
IsAutocompleteNodeMethod · 0.80
SetDefinitionLocationMethod · 0.80
AllocMethod · 0.45
InitMethod · 0.45
GetParamCountMethod · 0.45
GetParamTypeMethod · 0.45
sizeMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected