陳俊良臺灣大學:資訊工程學研究所何銘哲Ho, Ming-CheMing-CheHo2007-11-262018-07-052007-11-262018-07-052006http://ntur.lib.ntu.edu.tw//handle/246246/53811Generic programming recently has been commercially implemented into several popular programming languages, such as Java and C#, because of its productivity improvement to the software developers. We design and implement a deploy-time binary file translator for .NET executable files, also called “Assembly” files in .NET glossary, which translates the generic code. The binary file translator makes the generic code executable in the previous version of the runtime framework that did not support generics. Our whole implementation is based on the shared source runtime implementation of Microsoft’s .NET Framework. Our research first elaborates all of the translation techniques for parametric polymorphism and compares the different translations. Then, we implement the binary file translator to translate the generic code in a .NET application file into a non-generic application file that provides exactly the same functionality. This binary translator is especially useful when the users are not able to upgrade the .NET runtime version in a deployment environment, but they would still like to leverage the power of new generics feature in the programming language while developing the application. In this case, the user can develop the application with generics and build the executable assembly file then use the translator to transform the application into the non-generic form with the same functionality. On the other hand, the translator can also help to reduce resources, such as space, when some users deploy the application with generic code to those limited-resource embedded devices with .NET Compact Framework.Abstract i Table of Contents ii 1 Introduction 1 1.1 Parametric Polymorphism (Generics) 3 1.2 .NET Common Language Runtime and Shared Source CLI 3 1.3 Summary of Design 5 2 Generic Programming in .NET 7 2.1 C# Generics Language Features 7 2.2 Generics Support in .NET CLR 10 2.2.1 Generics Support in Intermediate Language (IL) 11 2.2.2 Instantiation of Generic Types 14 2.2.3 Generics in Base Class Library 15 3 Translation of Generics 16 3.1 Generalized Translation 16 3.2 Generalized Translation with Type Management 18 3.2.1 Runtime Type Management 19 3.2.2 Load-time Type Management 21 3.3 Specialized Translation 21 3.4 Specialized Translation with Runtime Support 22 3.5 Comparison of Translation 25 4 Strategy and Implementation 26 4.1 Strategy 26 4.2 Process of Translation 28 4.3 Specialized Translation 31 4.4 Generalized Translation 35 4.5 Insert Type Casting Instructions 36 4.6 Inheritance and Interface Implementation 41 4.7 Inline Invocation 45 5 Experimental Result 49 5.1 Test Environment and Benchmarks 49 5.2 Testing Result 50 5.3 Tests Analysis 51 6 Conclusion 52 6.1 Conclusion 52 6.2 Future Works 53 7 References 55376715 bytesapplication/pdfen-US泛型GenericParametric Polymorphism.NET 泛型移植到舊有系統之二進位碼轉換Binary Translator of .NET Generics for Legacy Runtime Environmentthesishttp://ntur.lib.ntu.edu.tw/bitstream/246246/53811/1/ntu-95-P92922004-1.pdf