1、Adopted by INCITS (InterNational Committee for Information Technology Standards) as an American National Standard.Date of ANSI Approval: 12/24/2003Published by American National Standards Institute,25 West 43rd Street, New York, New York 10036Copyright 2003 by Information Technology Industry Council
2、 (ITI).All rights reserved.These materials are subject to copyright claims of International Standardization Organization (ISO), InternationalElectrotechnical Commission (IEC), American National Standards Institute (ANSI), and Information Technology Industry Council(ITI). Not for resale. No part of t
3、his publication may be reproduced in any form, including an electronic retrieval system, withoutthe prior written permission of ITI. All requests pertaining to this standard should be submitted to ITI, 1250 Eye Street NW,Washington, DC 20005.Printed in the United States of AmericaReference numberISO
4、/IEC 23271:2003(E)ISO/IEC 2003INTERNATIONAL STANDARD ISO/IEC23271First edition2003-04-01Information technology Common Language Infrastructure Technologies de linformation Infrastructure commune de langage ISO/IEC 23271:2003(E) PDF disclaimer This PDF file may contain embedded typefaces. In accordanc
5、e with Adobes licensing policy, this file may be printed or viewed but shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file, parties accept therein the responsibility of not infringing Adobes licens
6、ing policy. The ISO Central Secretariat accepts no liability in this area. Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation parameters were optimized for printing.
7、 Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. ISO/IEC 2003 All rights reserved. Unless otherwise specified, no part of this p
8、ublication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs member body in the country of the requester. ISO copyright office Case postale 56 CH-1211 G
9、eneva 20 Tel. + 41 22 749 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.org Web www.iso.org Published in Switzerland ii ISO/IEC 2003 All rights reservedISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved iii Common Language Infrastructure (CLI) Partitions I to V Partition I: Concepts and Archit
10、ecture Partition II: Metadata Definition and Semantics Partition III: CLI Instruction Set Partition IV: Profiles and Libraries Partition V: Annexes ISO/IEC 23271:2003(E) iv ISO/IEC 2003 All rights reserved ISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved v Common Language Infrastructure (CLI)
11、Partition I: Concepts and Architecture ISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved vii Table of Contents 1 Scope 1 2 Conformance 2 3 References 3 4 Conventions 5 4.1 Organization 5 4.2 Informative Text 5 4.3 Hyperlinks 5 5 Glossary 6 6 Overview of the Common Language Infrastructure 21 6.1
12、 Relationship to Type Safety 21 6.2 Relationship to Managed Metadata-driven Execution 22 6.2.1 Managed Code 22 6.2.2 Managed Data 23 6.2.3 Summary 23 7 Common Language Specification (CLS) 24 7.1 Introduction 24 7.2 Views of CLS Compliance 24 7.2.1 CLS Framework 24 7.2.2 CLS Consumer 24 7.2.3 CLS Ext
13、ender 25 7.3 CLS Compliance 25 7.3.1 Marking Items as CLS-Compliant 26 8 Common Type System 27 8.1 Relationship to Object-Oriented Programming 29 8.2 Values and Types 29 8.2.1 Value Types and Reference Types 29 8.2.2 Built-in Types 29 8.2.3 Classes, Interfaces and Objects 30 8.2.4 Boxing and Unboxin
14、g of Values 31 8.2.5 Identity and Equality of Values 31 ISO/IEC 23271:2003(E) viii ISO/IEC 2003 All rights reserved 8.3 Locations 32 8.3.1 Assignment Compatible Locations 32 8.3.2 Coercion 32 8.3.3 Casting 33 8.4 Type Members 33 8.4.1 Fields, Array Elements, and Values 33 8.4.2 Methods 33 8.4.3 Stat
15、ic Fields and Static Methods 34 8.4.4 Virtual Methods 34 8.5 Naming 34 8.5.1 Valid Names 34 8.5.2 Assemblies and Scoping 35 8.5.3 Visibility, Accessibility, and Security 36 8.6 Contracts 38 8.6.1 Signatures 39 8.7 Assignment Compatibility 42 8.8 Type Safety and Verification 42 8.9 Type Definers 42 8
16、.9.1 Array Types 43 8.9.2 Unmanaged Pointer Types 44 8.9.3 Delegates 44 8.9.4 Interface Type Definition 45 8.9.5 Class Type Definition 46 8.9.6 Object Type Definitions 47 8.9.7 Value Type Definition 49 8.9.8 Type Inheritance 50 8.9.9 Object Type Inheritance 50 8.9.10 Value Type Inheritance 50 8.9.11
17、 Interface Type Inheritance 50 8.10 Member Inheritance 51 8.10.1 Field Inheritance 51 8.10.2 Method Inheritance 51 8.10.3 Property and Event Inheritance 51 8.10.4 Hiding, Overriding, and Layout 51 8.11 Member Definitions 52 8.11.1 Method Definitions 53 8.11.2 Field Definitions 53 8.11.3 Property Def
18、initions 53 ISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved ix 8.11.4 Event Definitions 54 8.11.5 Nested Type Definitions 55 9 Metadata 56 9.1 Components and Assemblies 56 9.2 Accessing Metadata 56 9.2.1 Metadata Tokens 56 9.2.2 Member Signatures in Metadata 57 9.3 Unmanaged Code 57 9.4 Metho
19、d Implementation Metadata 57 9.5 Class Layout 57 9.6 Assemblies: Name Scopes for Types 58 9.7 Metadata Extensibility 59 9.8 Globals, Imports, and Exports 60 9.9 Scoped Statics 60 10 Name and Type Rules for the Common Language Specification 61 10.1 Identifiers 61 10.2 Overloading 61 10.3 Operator Ove
20、rloading 62 10.3.1 Unary Operators 62 10.3.2 Binary Operators 63 10.3.3 Conversion Operators 64 10.4 Naming Patterns 64 10.5 Exceptions 65 10.6 Custom Attributes 65 11 Collected CLS Rules 67 12 Virtual Execution System 70 12.1 Supported Data Types 70 12.1.1 Native Size: native int, native unsigned i
21、nt, O and for example: “see Partition IV”, “see Section 8.7”, “see Chapter 22”, and “see clause 7.5.3”. Some tables also contain hyperlinked section number references, such as 5.10 and 6.7. End informative text ISO/IEC 23271:2003(E) 6 ISO/IEC 2003 All rights reserved 5 Glossary For the purpose of th
22、is International Standard, the following definitions apply. They are collected here for ease of reference, but the definition is presented in context elsewhere in the specification, as noted. Definitions enclosed in square brackets were not extracted from the body of the standard. The remainder of t
23、his section and its subsections contain only informative text Term Description Pt Ch Section Abstract Only an abstract object type is allowed to define method contracts for which the type or the VES does not also provide the implementation. Such method contracts are called abstract methods I 8.9.6.2
24、 Concreteness Accessibility of members A type scopes all of its members, and it also specifies the accessibility rules for its members. Except where noted, accessibility is decided based only on the statically visible type of the member being referenced and the type and assembly that is making the r
25、eference. The CTS supports seven different rules for accessibility: Compiler-Controlled; Private; Family; Assembly; Family-and-Assembly; Family-or-Assembly; Public. I 8.5.3.2 Accessibility of Members Aggregate data Data items that have sub-components (arrays, structures, or object instances) but are
26、 passed by copying the value. The sub-components can include references to managed memory. Aggregate data is represented using a value type I 12.1.6 Aggregate Data Application domain A mechanism to isolate applications running in the same operating system process from one another. I 12.5 Proxies and
27、 Remoting Array elements The representation of a value (except for those of built-in types) can be subdivided into sub-values. These sub-values are either named, in which case they are called fields, or they are accessed by an indexing expression, in which case they are called array elements. I 8.4.
28、1 Fields, Array Elements, and Values Argument Value of an operand to a method call Array types Types that describe values composed of array elements are array types. I 8.4.1 Fields, Array Elements, and Values Assembly An assembly is a configured set of loadable code modules and other resources that
29、together implement a unit of functionality. I 8.5.2 Assemblies and Scoping Assembly scope Type names are scoped by the assembly that contains the implementation of the type The type name is said to be in the assembly scope of the assembly that implements the type. I 8.5.2 Assemblies and Scoping Assi
30、gnment compatibility Assignment compatibility of a value (described by a type signature) to a location (described by a location signature) is defined as follows: One of the types supported by the exact type of the value is the same as the type in the location signature. I 8.7 Assignment Compatibilit
31、y Attributes Attributes of types and their members attach descriptive II 5.9 Attributes and ISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved 7 information to their definition. Metadata Base Class Library This Library is part of the Kernel Profile. It is a simple runtime library for a modern pr
32、ogramming language. IV 5.1 Runtime Infrastructure Library Binary operators Binary operators take two arguments, perform some operation and return a value. They are represented as static methods on the class that defines the type of one of their two operands or the return type. I 10.3.2 Binary Operat
33、ors Boolean Data Type A CLI Boolean type occupies one byte in memory. A bit pattern of all zeroes denotes a value of false. A bit pattern with any bit set (analogous to a non-zero integer) denotes a value of true. III 1.1.2 Boolean Data Type Box The box instruction is a widening (always typesafe) op
34、eration that converts a value type instance to System.Object by making a copy of the instance and embedding it in a newly allocated object. I 12.1.6.2.5 Boxing and Unboxing Boxed type For every Value Type, the CTS defines a corresponding Reference Type called the boxed type. I 8.2.4 Boxing and Unbox
35、ing of Values Boxed value The representation of a value of a boxed type (a boxed value) is a location where a value of the Value Type may be stored. I 8.2.4 Boxing and Unboxing of Values Built-in types Data types that are an integral part of the CTS and are supported directly by the Virtual Executio
36、n System (VES). I 8.2.2 Built-In Types By-ref parameters The address of the data is passed from the caller to the callee, and the type of the parameter is therefore a managed or unmanaged pointer. I 12.4.1.5 Parameter Passing By-value parameters The value of an object is passed from the caller to th
37、e callee I 12.4.1.5 Parameter Passing Calling Convention A calling convention specifies how a method expects its arguments to be passed from the caller to the called method. II 14.3 Calling Convention Casting Since a value can be of more than one type, a use of the value needs to clearly identify wh
38、ich of its types is being used. Since values are read from locations that are typed, the type of the value which is used is the type of the location from which the value was read. If a different type is to be used, the value is cast to one of its other types. . I 8.3.3 Casting CIL Common Intermediat
39、e Language Class contract A class contract specifies the representation of the values of the class type. Additionally, a class contract specifies the other contracts that the class type supports, e.g., which interfaces, methods, properties and events shall be implemented. I 8.6 Contracts Class type
40、A complete specification of the representation of the values of the class type and all of the contracts (class, I 8.9.5 Class Type Definition ISO/IEC 23271:2003(E) 8 ISO/IEC 2003 All rights reserved interface, method, property, and event) that are supported by the class type. CLI At the center of th
41、e Common Language Infrastructure (CLI) is a single type system, the Common Type System (CTS), that is shared by compilers, tools, and the CLI itself. It is the model that defines the rules the CLI follows when declaring, using, and managing types. I 6 Overview of the Common Language Infrastructure C
42、LS The Common Language Specification (CLS) is a set of conventions intended to promote language interoperability. I 7 Common Language Specification (CLS) CLS (consumer) A CLS consumer is a language or tool that is designed to allow access to all of the features supplied by CLS-compliant frameworks (
43、libraries), but not necessarily be able to produce them. I 7 Common Language Specification (CLS) CLS (extender) A CLS extender is a language or tool that is designed to allow programmers to both use and extend CLS-compliant frameworks. I 7 Common Language Specification (CLS) CLS (framework) A librar
44、y consisting of CLS-compliant code is herein referred to as a “framework”. I 7 Common Language Specification (CLS) Code labels Code labels are followed by a colon (“:”) and represent the address of an instruction to be executed II 5.4 Labels and Lists of Labels Coercion Coercion takes a value of a p
45、articular type and a desired type and attempts to create a value of the desired type that has equivalent meaning to the original value. I 8.3.2 Coercion Common Language Specification (CLS) The Common Language Specification (CLS) is a set of conventions intended to promote language interoperability.
46、I 7 Common Language Specification (CLS) Common Type System (CTS) The Common Type System (CTS) provides a rich type system that supports the types and operations found in many programming languages. I 6 Overview of the Common Language Infrastructure Compiler-controlled accessibility Accessible only t
47、hrough use of a definition, not a reference, hence only accessible from within a single compilation unit and under the control of the compiler. I 8.5.3.2 Accessibility of Members Compound types Types that describe values composed of fields are compound types. I 8.4.1 Fields, Array Elements, and Valu
48、es Computed destinations The destination of a method call may be either encoded directly in the CIL instruction stream (the call and jmp instructions) or computed (the callvirt, and calli instructions). I 12.4.1.3 Computed Destinations Concrete An object type that is not marked abstract is by defini
49、tion concrete. I 8.9.6.2 Concreteness Conformanc A system claiming conformance to this International I 2 Conformance ISO/IEC 23271:2003(E) ISO/IEC 2003 All rights reserved 9 e Standard shall implement all the mandatory requirements of this standard, and shall specify the profile that it implements. Contracts Contracts are named. They are the shared assumptions on a set of signatures between all implementers and all users of the contract. I 8.6 Contracts Conversion operators Conversion operators are unary operations t