Skip to content

Latest commit

 

History

History
21 lines (18 loc) · 2.46 KB

ii.10.2-body-of-a-type-definition.md

File metadata and controls

21 lines (18 loc) · 2.46 KB

II.10.2 Body of a type definition

A type can contain any number of further declarations. The directives .event, .field, .method, and .property are used to declare members of a type. The directive .class inside a type declaration is used to create a nested type, which is discussed in further detail in §II.10.6.

ClassMember ::= Description Clause
.class ClassHeader '{' ClassMember* '}' Defines a nested type. §II.10.6
| .custom CustomDecl Custom attribute. §II.21
| .data DataDecl Defines static data associated with the type. §II.16.3
| .event EventHeader '{' EventMember* '}' Declares an event. §II.18
| .field FieldDecl Declares a field belonging to the type. §II.16
| .method MethodHeader '{' MethodBodyItem* '}' Declares a method of the type. §II.15
| .override TypeSpec '::' MethodName with CallConv Type TypeSpec '::' MethodName '(' Parameters ')' Specifies that the first method is overridden by the definition of the second method. §II.10.3.2
| .pack Int32 Used for explicit layout of fields. §II.10.7
| .param type '[' Int32 ']' Specifies a type parameter for a generic type; for use in associating a custom attribute with that type parameter. §II.15.4.1.5
| .property PropHeader '{' PropMember* '}' Declares a property of the type. §II.17
| .size Int32 Used for explicit layout of fields. §II.10.7
| ExternSourceDecl Source line information. §II.5.7
| SecurityDecl Declarative security permissions. §II.20

The top-to-bottom order of the .method definitions within a .class declaration (§II.10) is preserved in the MethodDef table (§22.26). This is required to support variance resolution in interface dispatch (§12.2).