Skip to content

Latest commit

 

History

History
45 lines (23 loc) · 2.84 KB

ii.22.27-methodimpl-0x19.md

File metadata and controls

45 lines (23 loc) · 2.84 KB

II.22.27 MethodImpl: 0x19

MethodImpl tables let a compiler override the default inheritance rules provided by the CLI. Their original use was to allow a class C, that inherited method M from both interfaces I and J, to provide implementations for both methods (rather than have only one slot for M in its vtable). However, MethodImpls can be used for other reasons too, limited only by the compiler writer's ingenuity within the constraints defined in the Validation rules below.

In the example above, Class specifies C, MethodDeclaration specifies I::M, MethodBody specifies the method which provides the implementation for I::M (either a method body within C, or a method body implemented by a base class of C).

The MethodImpl table has the following columns:

  • Class (an index into the TypeDef table)

  • MethodBody (an index into the MethodDef or MemberRef table; more precisely, a MethodDefOrRefII.24.2.6) coded index)

  • MethodDeclaration (an index into the MethodDef or MemberRef table; more precisely, a MethodDefOrRefII.24.2.6) coded index)

ILAsm uses the .override directive to specify the rows of the MethodImpl table (§II.10.3.2 and §II.15.4.1).

This contains informative text only.

  1. The MethodImpl table can contain zero or more rows

  2. Class shall index a valid row in the TypeDef table [ERROR]

  3. MethodBody shall index a valid row in the MethodDef or MemberRef table [ERROR]

  4. The method indexed by MethodDeclaration shall have Flags.Virtual set [ERROR]

  5. The owner Type of the method indexed by MethodDeclaration shall not have Flags.Sealed = 0 [ERROR]

  6. The method indexed by MethodBody shall be a member of Class or some base class of Class (MethodImpls do not allow compilers to 'hook' arbitrary method bodies) [ERROR]

  7. The method indexed by MethodBody shall be virtual [ERROR]

  8. The method indexed by MethodBody shall have its Method.RVA ≠ 0 (cannot be an unmanaged method reached via PInvoke, for example) [ERROR]

  9. MethodDeclaration shall index a method in the ancestor chain of Class (reached via its Extends chain) or in the interface tree of Class (reached via its InterfaceImpl entries) [ERROR]

  10. The method indexed by MethodDeclaration shall not be final (its Flags.Final shall be 0) [ERROR]

  11. If MethodDeclaration has the Strict flag set, the method indexed by MethodDeclaration shall be accessible to Class. [ERROR]

  12. The method signature defined by MethodBody shall match those defined by MethodDeclaration [ERROR]

  13. There shall be no duplicate rows, based upon Class+MethodDeclaration [ERROR]

End informative text.