Skip to content

Latest commit

 

History

History
29 lines (15 loc) · 3.02 KB

ii.23.2.2-methodrefsig.md

File metadata and controls

29 lines (15 loc) · 3.02 KB

II.23.2.2 MethodRefSig

A MethodRefSig is indexed by the MemberRef.Signature column. This provides the call site Signature for a method. Normally, this call site Signature shall match exactly the Signature specified in the definition of the target method. For example, if a method Foo is defined that takes two unsigned int32s and returns void; then any call site shall index a signature that takes exactly two unsigned int32s and returns void. In this case, the syntax diagram for a MethodRefSig is identical with that for a MethodDefSig – see §II.23.2.1

The Signature at a call site differs from that at its definition, only for a method with the VARARG calling convention. In this case, the call site Signature is extended to include info about the extra VARARG arguments (for example, corresponding to the "..." in C syntax). The syntax diagram for this case is:

This diagram uses the following abbreviations:

  • HASTHIS = 0x20, used to encode the keyword instance in the calling convention, see §II.15.3

  • EXPLICITTHIS = 0x40, used to encode the keyword explicit in the calling convention, see §II.15.3

  • VARARG = 0x5, used to encode the keyword vararg in the calling convention, see §II.15.3

  • SENTINEL = 0x41 (§II.23.1.16), used to encode "..." in the parameter list, see §II.15.3

The first byte of the Signature holds bits for HASTHIS, EXPLICITTHIS, and the calling convention VARARG. These are ORed together.

ParamCount is an unsigned integer that holds the number of parameters (0 or more). It can be any number between 0 and 0x1FFFFFFF. The compiler compresses it (see §15) – before storing into the 'blob' (ParamCount counts just the method parameters – it does not include the method's return type)

The RetType item describes the type of the method’s return value (§II.23.2.11)

The Param item describes the type of each of the method's parameters. There shall be ParamCount instances of the Param item (§II.23.2.10).

The Param item describes the type of each of the method's parameters. There shall be ParamCount instances of the Param item. This starts just like the MethodDefSig for a VARARG method (§II.23.2.1). But then a SENTINEL token is appended, followed by extra Param items to describe the extra VARARG arguments. Note that the ParamCount item shall indicate the total number of Param items in the Signature – before and after the SENTINEL byte (0x41).

In the unusual case that a call site supplies no extra arguments, the signature shall not include a SENTINEL (this is the route shown by the lower arrow that bypasses SENTINEL and goes to the end of the MethodRefSig definition).