CLI) Partitions I to IV
Total Page:16
File Type:pdf, Size:1020Kb
Standard ECMA-335 December 2001 Standardizing Information and Communication Systems Common Language Infrastructure (CLI) Partitions I to IV Phone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http://www.ecma.ch - Internet: [email protected] Standard ECMA-335 December 2001 Standardizing Information and Communication Systems Common Language Infrastructure (CLI) Partitions I to IV Partition I : Concepts and Architecture Partition II : Metadata Definition and Semantics Partition III : CIL Instruction Set Partition IV : Profiles and Libraries Phone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http://www.ecma.ch - Internet: [email protected] mb - Ecma-335-Part-I-IV.doc - 16.01.2002 16:02 Common Language Infrastructure (CLI) Partition I: Concepts and Architecture - i - Table of Contents 1Scope 1 2 Conformance 2 3 References 3 4 Glossary 4 5 Overview of the Common Language Infrastructure 19 5.1 Relationship to Type Safety 19 5.2 Relationship to Managed Metadata-driven Execution 20 5.2.1 Managed Code 20 5.2.2 Managed Data 21 5.2.3 Summary 21 6 Common Language Specification (CLS) 22 6.1 Introduction 22 6.2 Views of CLS Compliance 22 6.2.1 CLS Framework 22 6.2.2 CLS Consumer 22 6.2.3 CLS Extender 23 6.3 CLS Compliance 23 6.3.1 Marking Items as CLS-Compliant 24 7 Common Type System 25 7.1 Relationship to Object-Oriented Programming 27 7.2 Values and Types 27 7.2.1 Value Types and Reference Types 27 7.2.2 Built-in Types 27 7.2.3 Classes, Interfaces and Objects 28 7.2.4 Boxing and Unboxing of Values 29 7.2.5 Identity and Equality of Values 29 7.3 Locations 30 7.3.1 Assignment Compatible Locations 30 7.3.2 Coercion 30 7.3.3 Casting 31 7.4 Type Members 31 - ii - 7.4.1 Fields, Array Elements, and Values 31 7.4.2 Methods 31 7.4.3 Static Fields and Static Methods 32 7.4.4 Virtual Methods 32 7.5 Naming 32 7.5.1 Valid Names 32 7.5.2 Assemblies and Scoping 33 7.5.3 Visibility, Accessibility, and Security 34 7.6 Contracts 36 7.6.1 Signatures 37 7.7 Assignment Compatibility 40 7.8 Type Safety and Verification 40 7.9 Type Definers 40 7.9.1 Array Types 41 7.9.2 Unmanaged Pointer Types 43 7.9.3 Delegates 43 7.9.4 Interface Type Definition 43 7.9.5 Class Type Definition 44 7.9.6 Object Type Definitions 46 7.9.7 Value Type Definition 48 7.9.8 Type Inheritance 49 7.9.9 Object Type Inheritance 49 7.9.10 Value Type Inheritance 49 7.9.11 Interface Type Inheritance 49 7.10 Member Inheritance 50 7.10.1 Field Inheritance 50 7.10.2 Method Inheritance 50 7.10.3 Property and Event Inheritance 50 7.10.4 Hiding, Overriding, and Layout 50 7.11 Member Definitions 51 7.11.1 Method Definitions 52 7.11.2 Field Definitions 52 7.11.3 Property Definitions 52 7.11.4 Event Definitions 53 7.11.5 Nested Type Definitions 54 8 CLI Metadata 55 8.1 Components and Assemblies 55 - iii - 8.2 Accessing Metadata 55 8.2.1 Metadata Tokens 55 8.2.2 Member Signatures in Metadata 56 8.3 Unmanaged Code 56 8.4 Method Implementation Metadata 56 8.5 Class Layout 56 8.6 Assemblies: Name Scopes for Types 57 8.7 Metadata Extensibility 58 8.8 Globals, Imports, and Exports 59 8.9 Scoped Statics 59 9 Name and Type Rules for the Common Language Specification 60 9.1 Identifiers 60 9.2 Overloading 60 9.3 Operator Overloading 61 9.3.1 Unary Operators 61 9.3.2 Binary Operators 62 9.3.3 Conversion Operators 63 9.4 Naming Patterns 63 9.5 Exceptions 64 9.6 Custom Attributes 64 10 Collected CLS Rules 66 11 Virtual Execution System 69 11.1 Supported Data Types 69 11.1.1 Native Size: native int, native unsigned int, O and & 70 11.1.2 Handling of Short Integer Data Types 71 11.1.3 Handling of Floating Point Datatypes 71 11.1.4 CIL Instructions and Numeric Types 74 11.1.5 CIL Instructions and Pointer Types 75 11.1.6 Aggregate Data 76 11.2 Module Information 79 11.3 Machine State 79 11.3.1 The Global State 79 11.3.2 Method State 80 11.4 Control Flow 83 11.4.1 Method Calls 84 11.4.2 Exception Handling 87 - iv - 11.5 Proxies and Remoting 92 11.6 Memory Model and Optimizations 92 11.6.1 The Memory Store 92 11.6.2 Alignment 92 11.6.3 Byte Ordering 93 11.6.4 Optimization 93 11.6.5 Locks and Threads 93 11.6.6 Atomic Reads and Writes 94 11.6.7 Volatile Reads and Writes 94 11.6.8 Other Memory Model Issues 94 11.7 Atomicity of Memory Accesses 95 12 Index 97 1 1Scope 2 This ECMA Standard defines the Common Language Infrastructure (CLI) in which applications written in 3 multiple high level languages may be executed in different system environments without the need to rewrite the 4 application to take into consideration the unique characteristics of those environments. This ECMA Standard 5 consists of several sections in order to facilitate understanding various components by describing those 6 components in their separate sections. These sections are: 7 Partition I: Architecture 8 Partition II: Metadata Definition and Semantics 9 Partition III: CIL Instruction Set 10 Partition IV: Profiles and Libraries 11 Partition V: Annexes - 2 - 1 2Conformance 2 A system claiming conformance to this ECMA Standard shall implement all the mandatory requirements of 3 this standard, and shall specify the profile (see Partition IV) that it implements. The minimal implementation is 4 the Kernel Profile (see Partition IV). A conforming implementation may also include additional functionality 5 that does not prevent running code written to rely solely on the profile as specified in this standard. For 6 example, it may provide additional classes, new methods on existing classes, or a new interface on a 7 standardized class, but it shall not add methods or properties to interfaces specified in this standard. 8 A compiler that generates Common Intermediate Language (CIL, see Partition III) and claims conformance to 9 this ECMA Standard shall produce output files in the format specified in this standard and the CIL it generates 10 shall be valid CIL as specified in this standard. Such a compiler may also claim that it generates verifiable 11 code, in which case the CIL it generates shall be verifiable as specified in this standard. - 3 - 1 3 References 2 IEC 60559:1989, Binary Floating-point Arithmetic for Microprocessor Systems (previously designated IEC 3 559:1989) 4 ISO/IEC 10646 (all parts), Information technology — Universal Multiple-Octet Coded Character Set (UCS). 5 The Unicode Consortium. The Unicode Standard, Version 3.0, defined by: The Unicode Standard, Version 3.0 6 (Reading, MA, Addison-Wesley, 2000. ISBN 0-201-61633-5), and Unicode Technical Report #15: Unicode 7 Normalization Forms. 8 ISO/IEC 646:1991 Information technology -- ISO 7-bit coded character set for information interchange 9 ISO/IEC 11578:1996 (E) Information technology - Open Systems Interconnection - Remote Procedure Call 10 (RPC), Annex A: Universal Unique Identifier 11 Federal Information Processing Standard (FIPS 180-1), Secure Hash Standard (SHA-1), 1995 April 7. 12 Extensible Markup Language (XML) 1.0 (Second Edition), 2000 October 6, http://www.w3.org/TR/2000/REC- 13 xml-20001006 14 Network Working Group. RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1. R. Fielding, J. Gettys, J. 15 Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee. 1999 June, ftp://ftp.isi.edu/in-notes/rfc2616.txt 16 Network Working Group. RFC 2617: HTTP Authentication: Basic and Digest Access Authentication. J. 17 Franks, P. Hallam-Baker, J. Hostetler, S. Lawrence, P. Leach, A. Luotonen, L. Stewart. 1999 June, 18 ftp://ftp.isi.edu/in-notes/rfc2617.txt 19 IETF (Internet Engineering Task Force). RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax. T. 20 Berners-Lee, R. Fielding, L. Masinter. 1998 August, http://www.ietf.org/rfc/rfc2396.txt. 21 Network Working Group. RFC-1222: Advancing the NSFNET Routing Architecture. H-W Braun, Y. Rekhter. 22 1991 May, ftp://ftp.isi.edu/in-notes/rfc1222.txt -4- 1 4Glossary 2 For the purpose of this ECMA Standard, the following definitions apply. They are collected here for ease of 3 reference, but the definition is presented in context elsewhere in the specification, as noted. Definitions 4 enclosed in square brackets [ ] were not extracted from the body of the standard. 5 The remainder of this section and its subsections contain only informative text Term Description Pt Ch Section Abstract Only an abstract object type is allowed to define method I 7.9.6.2 Concreteness contracts for which the type or the VES does not also provide the implementation. Such method contracts are called abstract methods Accessibility A type scopes all of its members, and it also specifies I 7.5.3.2 Accessibility of of members the accessibility rules for its members. Except where Members 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 reference. The CTS supports seven different rules for accessibility: Compiler-Controlled; Private; Family; Assembly; Family-and-Assembly; Family-or-Assembly; Public.