Author: jbevain
Date: 2008-02-05 05:56:40 -0500 (Tue, 05 Feb 2008)
New Revision: 94867
Modified:
trunk/mcs/class/Mono.Cecil/ChangeLog
trunk/mcs/class/Mono.Cecil/Mono.Cecil/DefaultImporter.cs
Log:
2008-02-05 Jb Evain <[EMAIL PROTECTED]>
* Mono.Cecil.Binary/DefaultImporter.cs:
Import modifiers and sentinels, patch from:
Andrea Carlo Ornstein <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/Mono.Cecil/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Cecil/ChangeLog 2008-02-05 10:51:36 UTC (rev
94866)
+++ trunk/mcs/class/Mono.Cecil/ChangeLog 2008-02-05 10:56:40 UTC (rev
94867)
@@ -1,3 +1,9 @@
+2008-02-05 Jb Evain <[EMAIL PROTECTED]>
+
+ * Mono.Cecil.Binary/DefaultImporter.cs:
+ Import modifiers and sentinels, patch from:
+ Andrea Carlo Ornstein <[EMAIL PROTECTED]>
+
2008-02-04 Jb Evain <[EMAIL PROTECTED]>
* Mono.Cecil.Binary/CLIHeader.cs
Modified: trunk/mcs/class/Mono.Cecil/Mono.Cecil/DefaultImporter.cs
===================================================================
--- trunk/mcs/class/Mono.Cecil/Mono.Cecil/DefaultImporter.cs 2008-02-05
10:51:36 UTC (rev 94866)
+++ trunk/mcs/class/Mono.Cecil/Mono.Cecil/DefaultImporter.cs 2008-02-05
10:56:40 UTC (rev 94867)
@@ -29,7 +29,6 @@
namespace Mono.Cecil {
using System;
- using System.Collections;
public class DefaultImporter : IImporter {
@@ -67,37 +66,38 @@
return null;
}
- TypeReference GetTypeSpec (TypeReference t, ImportContext
context)
+ TypeSpecification GetTypeSpec (TypeSpecification original,
ImportContext context)
{
- Stack s = new Stack ();
- while (t is TypeSpecification) {
- s.Push (t);
- t = (t as TypeSpecification).ElementType;
- }
+ TypeSpecification typeSpec;
- TypeReference elementType = ImportTypeReference (t,
context);
- while (s.Count > 0) {
- t = (TypeReference) s.Pop ();
- if (t is PointerType)
- elementType = new PointerType
(elementType);
- else if (t is ArrayType) // deal with complex
arrays
- elementType = new ArrayType
(elementType);
- else if (t is ReferenceType)
- elementType = new ReferenceType
(elementType);
- else if (t is GenericInstanceType) {
- GenericInstanceType git = t as
GenericInstanceType;
- GenericInstanceType genElemType = new
GenericInstanceType (elementType);
+ TypeReference elementType = ImportTypeReference
(original.ElementType, context);
+ if (original is PointerType) {
+ typeSpec = new PointerType (elementType);
+ } else if (original is ArrayType) { // deal with
complex arrays
+ typeSpec = new ArrayType (elementType);
+ } else if (original is ReferenceType) {
+ typeSpec = new ReferenceType (elementType);
+ } else if (original is GenericInstanceType) {
+ GenericInstanceType git = original as
GenericInstanceType;
+ GenericInstanceType genElemType = new
GenericInstanceType (elementType);
- context.GenericContext.CheckProvider
(genElemType.GetOriginalType (), git.GenericArguments.Count);
- foreach (TypeReference arg in
git.GenericArguments)
-
genElemType.GenericArguments.Add (ImportTypeReference (arg, context));
+ context.GenericContext.CheckProvider
(genElemType.GetOriginalType (), git.GenericArguments.Count);
+ foreach (TypeReference arg in
git.GenericArguments)
+ genElemType.GenericArguments.Add
(ImportTypeReference (arg, context));
- elementType = genElemType;
- } else
- throw new ReflectionException ("Unknown
element type: {0}", t.GetType ().Name);
- }
+ typeSpec = genElemType;
+ } else if (original is ModifierOptional) {
+ TypeReference mt = (original as
ModifierOptional).ModifierType;
+ typeSpec = new ModifierOptional (elementType,
ImportTypeReference (mt, context));
+ } else if (original is ModifierRequired) {
+ TypeReference mt = (original as
ModifierRequired).ModifierType;
+ typeSpec = new ModifierRequired (elementType,
ImportTypeReference (mt, context));
+ } else if (original is SentinelType) {
+ typeSpec = new SentinelType (elementType);
+ } else
+ throw new ReflectionException ("Unknown element
type: {0}", original.GetType ().Name);
- return elementType;
+ return typeSpec;
}
static GenericParameter GetGenericParameter (GenericParameter
gp, ImportContext context)
@@ -119,7 +119,7 @@
return t;
if (t is TypeSpecification)
- return GetTypeSpec (t, context);
+ return GetTypeSpec (t as TypeSpecification,
context);
if (t is GenericParameter)
return GetGenericParameter (t as
GenericParameter, context);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches