ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf

上传人:赵齐羽 文档编号:704766 上传时间:2019-01-03 格式:PDF 页数:574 大小:4.68MB
下载 相关 举报
ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf_第1页
第1页 / 共574页
ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf_第2页
第2页 / 共574页
ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf_第3页
第3页 / 共574页
ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf_第4页
第4页 / 共574页
ECMA 335-2012 Common Language Infrastructure (CLI) Partitions I to VI (6th Edition).pdf_第5页
第5页 / 共574页
点击查看更多>>
资源描述

1、 Reference number ECMA-123:2009 Ecma International 2009 ECMA-335 6th Edition / June 2012 Common Language Infrastructure (CLI) Partitions I to VI COPYRIGHT PROTECTED DOCUMENT Ecma International 2012 Ecma International 2012 i This Ecma Standard has been adopted by the General Assembly of June 2012. “C

2、OPYRIGHT NOTICE Ecma International This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are inc

3、luded on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are: (i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the docum

4、ent), (ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility, (iii) translations of this document into languages other than English and into different formats and (iv) works by making use of this specification in standard con

5、formant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein. However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into l

6、anguages other than English or into a different format. The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern. Th

7、e limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns. This document and the information contained herein is provided on an “AS IS“ basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMI

8、TED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.“ ii Ecma International 2012 Common Language Infrastructure (CLI) Partitions IVI Partition I: Concepts and Architecture P

9、artition II: Metadata Definition and Semantics Partition III: CIL Instruction Set Partition IV: Profiles and Libraries Partition V: Binary Formats Partition VI: Annexes Ecma International 2012 iii Table of Contents Foreword xxi I.1 Scope 1 I.2 Conformance 2 I.3 Normative references 3 I.4 Conventions

10、 5 I.4.1 Organization 5 I.4.2 Informative text 5 I.5 Terms and definitions 6 I.6 Overview of the Co mmon Language Infrastructure 9 I.6.1 Relationship to type safety 9 I.6.2 Relationship to managed metadata -driven execution 10 I.6.2.1 Managed code 10 I.6.2.2 Managed data 11 I.6.2.3 Summary 11 I.7 Co

11、mmon Language Specification 12 I.7.1 Introduction 12 I.7.2 Views of CLS co mpliance 12 I.7.2.1 CLS framework 12 I.7.2.2 CLS consumer 13 I.7.2.3 CLS extender 13 I.7.3 CLS co mpliance 14 I.7.3.1 Marking items as CLS -compliant 14 I.8 Common Type System 16 I.8.1 Relationship to object-oriented programm

12、ing 19 I.8.2 Values and types 19 I.8.2.1 Value types and reference types 19 I.8.2.2 Built-in value and reference types 20 I.8.2.3 Classes, interfaces, and objects 21 I.8.2.4 Boxing and unboxing of values 21 I.8.2.5 Identity and equality of values 22 I.8.3 Locations 23 I.8.3.1 Assignment-compatible l

13、ocations 23 I.8.3.2 Coercion 23 iv Ecma International 2012 I.8.3.3 Casting 24 I.8.4 Type members 24 I.8.4.1 Fields, array elements, and values 24 I.8.4.2 Methods 24 I.8.4.3 Static fields and static methods 25 I.8.4.4 Virtual methods 25 I.8.5 Naming 25 I.8.5.1 Valid names 25 I.8.5.2 Assemblies and sc

14、oping 26 I.8.5.3 Visibility, accessibility, and security 27 I.8.6 Contracts 29 I.8.6.1 Signatures 30 I.8.7 Assignment compatibility 34 I.8.7.1 Assignment compatibility for signature types 37 I.8.7.2 Assignment compatibility for location type s 38 I.8.7.3 General assignment compatibility 38 I.8.8 Typ

15、e safety and verification 39 I.8.9 Type definers 39 I.8.9.1 Array types 40 I.8.9.2 Unmanaged pointer types 41 I.8.9.3 Delegates 41 I.8.9.4 Interface type definition 42 I.8.9.5 Class type definition 43 I.8.9.6 Object type definitions 44 I.8.9.7 Value type definition 47 I.8.9.8 Type inheritance 47 I.8

16、.9.9 Object type inheritance 47 I.8.9.10 Value type inheritance 48 I.8.9.11 Interface type derivation 48 I.8.10 Member inheritance 48 I.8.10.1 Field inheritance 48 I.8.10.2 Method inheritance 48 I.8.10.3 Property and event inheritance 49 I.8.10.4 Hiding, overriding, and layo ut 49 I.8.11 Member defi

17、nitions 50 I.8.11.1 Method definitions 50 I.8.11.2 Field definitions 51 I.8.11.3 Property definitions 51 I.8.11.4 Event definitions 52 I.8.11.5 Nested type definitions 52 Ecma International 2012 v I.9 Metadata 53 I.9.1 Components and assemblies 53 I.9.2 Accessing metadata 53 I.9.2.1 Metadata tokens

18、54 I.9.2.2 Member signatures in metadata 54 I.9.3 Unmanaged code 54 I.9.4 Method implementation metadata 54 I.9.5 Class layout 55 I.9.6 Assemblies: name scopes for types 55 I.9.7 Metadata extensibility 56 I.9.8 Globals, imports, and exports 57 I.9.9 Scoped statics 58 I.10 Name and type rules for the

19、 Co mmon Language Specification 59 I.10.1 Identifiers 59 I.10.2 Overloading 59 I.10.3 Operator overloading 60 I.10.3.1 Unary operators 60 I.10.3.2 Binary operators 61 I.10.3.3 Conversion operators 62 I.10.4 Naming patterns 62 I.10.5 Exceptions 63 I.10.6 Custom attributes 63 I.10.7 Generic types and

20、methods 64 I.10.7.1 Nested type parameter re -declaration 64 I.10.7.2 Type names and arity encoding 65 I.10.7.3 Type constraint re -declaration 66 I.10.7.4 Constraint type restrictions 67 I.10.7.5 Frameworks and accessibility of nested types 67 I.10.7.6 Frameworks and abstract or virtual methods 68

21、I.11 Collected Co mmon Language Specification rules 69 I.12 Virtual Execution System 72 I.12.1 Supported data types 72 I.12.1.1 Native size: native int, native unsigned int, O and as exact type matches always took precedence over matches-by-variance. In this edition the dispatch rules for interfaces

22、 (II.12.2) allow a match-by-variance to take precedence over an exact match, so all language implementation targeting the CLI must be aware of the behavior even if it is not supported in the language (I.1.8). Additional requirements on ilasm to metadata conversion. The left-to-right order of interfa

23、ces listed in a type header (II.10.2) must now be preserved as a top-to-bottom order in the InterfaceImpl table (II.22.23); and the top-to-bottom of method definitions (II.10.2, II.25) must now be preserved as a top-to-bottom order in the MethodDef table (II.22.26). Both these additional requirement

24、s are required to support the revised variance semantics. System.Math and System.Double have been modified to better conform to IEEE (see Partition IV and IEC 60559:1989) The following types have been added to the Standard or have been significantly updated (* represents an update). Type Library Sys

25、tem.Action BCL System.Action1* System.Action8 BCL System.Comparison1* BCL xxii Ecma International 2012 System.Converter2* BCL System.IComparable1* BCL System.Predicate1* BCL System.Collections.Generic.IComparer1* BCL System.Collections.Generic.IEnumerable1* BCL System.Collections.Generic.IEqualityCo

26、mparer1* BCL System.Guid BCL System.MulticastDelegate BCL System.Reflection.CallingConventions Runtime Infrastructure System.Runtime.InteropServices.GuidAttribute Runtime Infrastructure System.Func1 System.Func9 BCL System.Collections.Generic.Comparer1 BCL System.Collections.Generic.EqualityComparer

27、1 BCL System.Collections.Generic.ISet1 BCL System.Collections.Generic.LinkedList1 BCL System.Collections.Generic.LinkedList1.Enumerator BCL System.Collections.Generic.LinkedListNode1 BCL System.Collections.Generic.Queue1 BCL System.Collections.Generic.Stack1 BCL System.Collections.Generic.Stack1.Enu

28、merator BCL System.Collections.Stack BCL System.DBNull BCL System.Runtime.InteropServices.Marshal Runtime Infrastructure System.Runtime.InteropServices.SafeBuffer Runtime Infrastructure System.Runtime.InteropServices.SafeHandle Runtime Infrastructure System.Threading.AutoResetEvent BCL System.Thread

29、ing.EventWaitHandle BCL System.Threading.ManualResetEvent BCL System.WeakReference BCL System.Runtime.CompilerServices.TypeForwardedToAttribute BCL System.Runtime.CompilerServices.TypeForwardedFromAttribute BCL System.Threading.EventResetMode BCL System.Runtime.InteropServices.DllAttribute* Runtime

30、Infrastructure System.Math* BCL One type, INullableValue, has been removed from the Standard. INullableValue is incompatible with the semantics of boxing as defined in the previous edition of the Standard. The references to it were included in error from an earlier draft and no implementations are k

31、nown to have ever included it. Ecma International 2012 xxiii Technical Report 89 (TR89), which was submitted during the third edition of this Ecma standard, will no longer be part of the submission. TR89 specified a collection of generic types, to help enhance inter-language interoperability, under

32、consideration for inclusion in a future version of the standard. That consideration has now occurred and TR89 has fulfilled its role. A selection of the types covered in TR89 has been introduced into this edition of the standard. An archive version of TR89 will continue to be available from Ecma. Th

33、e following companies and organizations have participated in the development of this standard, and their contributions are gratefully acknowledged: Eiffel Software, Kahu Research, Microsoft Corporation, Novell Corporation, Twin Roots. For previous editions, the following companies and organizations

34、are also acknowledged: Borland, Fujitsu Software Corporation, Hewlett-Packard, Intel Corporation, IBM Corporation, IT University of Copenhagen, Jagger Software Ltd., Monash University, Netscape, Phone.Com, Plum Hall, and Sun Microsystems. Ecma International 2012 1 I.1 Scope This International Standa

35、rd defines the Common Language Infrastructure (CLI) in which applications written in multiple high-level languages can be executed in different system environments without the need to rewrite those applications to take into consideration the unique characteristics of those environments. This Interna

36、tional Standard consists of the following parts: Partition I: Concepts and Architecture Describes the overall architecture of the CLI, and provides the normative description of the Common Type System (CTS), the Virtual Execution System (VES), and the Common Language Specification (CLS). It also prov

37、ides an informative description of the metadata. Partition II: Metadata Definition and Semantics Provides the normative description of the metadata: its physical layout (as a file format), its logical contents (as a set of tables and their relationships), and its semantics (as seen from a hypothetic

38、al assembler, ilasm). Partition III: CIL Instruction Set Describes the Common Intermediate Language (CIL) instruction set. Partition IV: Profiles and Libraries Provides an overview of the CLI Libraries, and a specification of their factoring into Profiles and Libraries. A companion file, CLILibrary.

39、xml, considered to be part of this Partition, but distributed in XML format, provides details of each class, value type, and interface in the CLI Libraries. Partition V: Debug Interchange Format Describes a standard way to interchange debugging information between CLI producers and consumers. Partit

40、ion VI: Annexes Contains some sample programs written in CIL Assembly Language (ILAsm), information about a particular implementation of an assembler, a machine-readable description of the CIL instruction set which can be used to derive parts of the grammar used by this assembler as well as other to

41、ols that manipulate CIL, a set of guidelines used in the design of the libraries of Partition IV, and portability considerations. 2 Ecma International 2012 I.2 Conformance A system claiming conformance to this International Standard shall implement all the normative requirements of this standard, an

42、d shall specify the profile (see Partition IV Library Profiles) that it implements. The minimal implementation is the Kernel Profile. A conforming implementation can also include additional functionality provided that functionality does not prevent running code written to rely solely on the profile

43、as specified in this standard. For example, a conforming implementation can provide additional classes, new methods on existing classes, or a new interface on a standardized class, but it shall not add methods or properties to interfaces specified in this standard. A compiler that generates Common I

44、ntermediate Language (CIL, see Partition III) and claims conformance to this International Standard shall produce output files in the format specified in this standard, and the CIL it generates shall be correct CIL as specified in this standard. Such a compiler can also claim that it generates verif

45、iable code, in which case, the CIL it generates shall be verifiable as specified in this standard. Ecma International 2012 3 I.3 Normative references Note that many of these references are cited in the XML description of the class libraries. Extensible Markup Language (XML) 1.0 (Third Edition), 2004

46、 February 4, http:/www.w3.org/TR/2004/REC-xml-20040204/ Federal Information Processing Standard (FIPS 180-1), Secure Hash Standard (SHA-1), 1995, April. IEC 60559:1989, Binary Floating-point Arithmetic for Microprocessor Systems (previously designated IEC 559:1989). ISO 639, Codes for the representa

47、tion of names of languages. ISO 3166-1:2006, Codes for the representation of names of countries. ISO/IEC 646:1991, Information Technology ISO 7-bit coded character set for information interchange ISO/IEC 9899:1999, Programming languages C. ISO/IEC 10646, Information Technology Universal Coded Character Set (UCS). ISO/IEC 11578:1996, Information Technology Open Systems Interconnection - Remote Procedure Call (RPC). ISO/IEC 14882:2011, Programming languages C+. ISO/IEC 23270:2006, Prog

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 标准规范 > 国际标准 > 其他

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1