User:Sundström/Drafts/Common Intermediate Language syntax


 * Main article: Common Intermediate Language

This article describes the syntax of the Common Intermediate Language assembly language, abbr. as CIL.

= Basics =

Data types
CIL has three groups of built-in datatypes.


 * Numerics types:,  ,  ,
 * Object reference:
 * Pointer types: ,

Instruction set

 * See also: List of CIL instructions

CIL bytecode has instructions for the following groups of tasks:
 * Load and store
 * Arithmetic
 * Type conversion
 * Object creation and manipulation
 * Operand stack management (push / pop)
 * Control transfer (branching)
 * Method invocation and return
 * Throwing exceptions
 * Monitor-based concurrency

These are written inside of the body of a function declaration.

Modifier attributes
Member attributes instance

= Declarations =

Methods
A method is a function or subroutin that belongs to a class. It contains a return type and possibly a parameter list is such is defined. A method in CIL can either be an instance member or a type member that is part of the class and not any specific object.

This is an instance method called  and that takes one parameter. It takes the parameter does something to it

Constructors
A constructor, or initializer, is a method that is called when a type is about to get created or used for the first time. CIL supports both instance initializers and type initializers.

Initializers are simply ordinary methods that return  but have special names.

Instance initializer An instance initializer is what usually is called a constructor. As the name suggests it initialize an object instance with initial data. It is called when the  instruction is called with it as its argument.

In the example above the constructor of the base class  is called first.

Properties
Properties are a piece of syntactic sugar wraps the traditional accessor convention that what often would be getter and setter methods. In CIL they are treated as a special member that usually in a high-level language like C# is implemented with a field like syntax.

In the CIL the properties are declared as a separate structure. The signatures of the  and   methods reside inside the declaration. These are implemented separately like any other method but are treated specially at runtime.

A property must have a getter but the setter can be left to make it read-only. Properties can be both static class members as well as instance members.

Inheritance
In CIL class can extend, or inherit, one class. If none is specified then it will implicitly inherit  which is the ultimate base class of all objects in the Common Language Infrastructure.

Implement interfaces
A class can implement multiple interfaces.

Enumerations
= See also =
 * Common Intermediate Language

= External links =