| 397 | } |
| 398 | |
| 399 | BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaration, BfMethodDef* outerMethodDef) |
| 400 | { |
| 401 | BfMethodDef* methodDef; |
| 402 | |
| 403 | if (auto operatorDecl = BfNodeDynCast<BfOperatorDeclaration>(methodDeclaration)) |
| 404 | { |
| 405 | auto operatorDef = new BfOperatorDef(); |
| 406 | operatorDef->mOperatorDeclaration = operatorDecl; |
| 407 | operatorDef->mIsOperator = true; |
| 408 | methodDef = operatorDef; |
| 409 | } |
| 410 | else |
| 411 | methodDef = new BfMethodDef(); |
| 412 | |
| 413 | BF_ASSERT(mCurDeclaringTypeDef != NULL); |
| 414 | methodDef->mDeclaringType = mCurDeclaringTypeDef; |
| 415 | methodDef->mMethodDeclaration = methodDeclaration; |
| 416 | methodDef->mExplicitInterface = methodDeclaration->mExplicitInterface; |
| 417 | methodDef->mReturnTypeRef = methodDeclaration->mReturnType; |
| 418 | methodDef->mProtection = GetProtection(methodDeclaration->mProtectionSpecifier); |
| 419 | methodDef->mIsReadOnly = methodDeclaration->mReadOnlySpecifier != NULL; |
| 420 | methodDef->mIsStatic = methodDeclaration->mStaticSpecifier != NULL; |
| 421 | methodDef->mIsVirtual = methodDeclaration->mVirtualSpecifier != NULL; |
| 422 | methodDef->mIsPartial = methodDeclaration->mPartialSpecifier != NULL; |
| 423 | methodDef->mIsNew = methodDeclaration->mNewSpecifier != NULL; |
| 424 | methodDef->mIsMutating = methodDeclaration->mMutSpecifier != NULL; |
| 425 | methodDef->mIsExtern = methodDeclaration->mExternSpecifier != NULL; |
| 426 | methodDef->mBody = methodDeclaration->mBody; |
| 427 | |
| 428 | if ((methodDeclaration->mThisToken != NULL) && (!methodDeclaration->mParams.IsEmpty())) |
| 429 | { |
| 430 | methodDef->mMethodType = BfMethodType_Extension; |
| 431 | if (!methodDef->mIsStatic) |
| 432 | { |
| 433 | methodDef->mIsStatic = true; |
| 434 | Fail("Extension methods must be declared 'static'", methodDef->GetRefNode()); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | HashContext signatureHashCtx; |
| 439 | HashNode(signatureHashCtx, methodDeclaration, methodDef->mBody); |
| 440 | //methodDef->mSignatureHash = signatureHashCtx.Finish128(); |
| 441 | if (mSignatureHashCtx != NULL) |
| 442 | HashNode(*mSignatureHashCtx, methodDeclaration, methodDef->mBody); |
| 443 | |
| 444 | HashContext fullHash; |
| 445 | HashNode(fullHash, methodDeclaration); |
| 446 | methodDef->mFullHash = fullHash.Finish128(); |
| 447 | |
| 448 | if (methodDeclaration->mVirtualSpecifier != NULL) |
| 449 | { |
| 450 | methodDef->mIsOverride = methodDeclaration->mVirtualSpecifier->GetToken() == BfToken_Override; |
| 451 | methodDef->mIsAbstract = methodDeclaration->mVirtualSpecifier->GetToken() == BfToken_Abstract; |
| 452 | |
| 453 | if (methodDef->mIsOverride) |
| 454 | mCurTypeDef->mHasOverrideMethods = true; |
| 455 | |
| 456 | if (methodDeclaration->mVirtualSpecifier->GetToken() == BfToken_Concrete) |
no test coverage detected