Jump to content

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

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sundström (talk | contribs) at 12:07, 13 February 2010 (Datat types). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Main article: Common Intermediate Language

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

Basics

Data types

  • Numerics types: int32, int64, native int, F
  • Object reference: O
  • Pointer types: native unsigned int, &

Instruction set

See also: List of CIL instructions

CIL bytecode has instructions for the following groups of tasks:

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


Modifier attributes

Declarations

Modules

Global functions

Classes

Methods

Try-Catch blocks

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 .get and .set methods reside inside the declaration. These are implemented separately like any other method but are treated specially at runtime.

 //An instance property with both a getter and a setter.
 .property instance int32 Age
 {
     .get instance int32 Person::get_Age()
     .set instance void Person::set_Age(int32)
 }

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 given then it will implicitly inherit System.Object which is the ultimate base class of all objects in the Common Language Infrastructure.

 .class public auto ansi beforefieldinit Horse
     extends Mammal
 {
 }
Implement interfaces

A class can implement multiple interfaces.

 .class public auto ansi beforefieldinit Whale
     extends Mammal implements ISeaDweller
 {
 }


Interfaces

Enumerations

See also