Update mcs/class/Commons.Xml.Relaxng/Commons.Xml.Relaxng/RelaxngPattern.cs
[mono.git] / mcs / class / IKVM.Reflection / Missing.cs
index 30560d9f0828ee84f3754309ed35af1724bb0ac9..dfc7791b1404b376beca0471f1bb3364191103d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2011 Jeroen Frijters
+  Copyright (C) 2011-2012 Jeroen Frijters
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -102,7 +102,7 @@ namespace IKVM.Reflection
 
                public MissingGenericMethodBuilder(Type declaringType, CallingConventions callingConvention, string name, int genericParameterCount)
                {
-                       method = new MissingMethod(declaringType, name, new MethodSignature(null, null, null, callingConvention, genericParameterCount));
+                       method = new MissingMethod(declaringType, name, new MethodSignature(null, null, new PackedCustomModifiers(), callingConvention, genericParameterCount));
                }
 
                public Type[] GetGenericArguments()
@@ -110,6 +110,17 @@ namespace IKVM.Reflection
                        return method.GetGenericArguments();
                }
 
+               public void SetSignature(Type returnType, CustomModifiers returnTypeCustomModifiers, Type[] parameterTypes, CustomModifiers[] parameterTypeCustomModifiers)
+               {
+                       method.signature = new MethodSignature(
+                               returnType ?? method.Module.universe.System_Void,
+                               Util.Copy(parameterTypes),
+                               PackedCustomModifiers.CreateFromExternal(returnTypeCustomModifiers, parameterTypeCustomModifiers, parameterTypes.Length),
+                               method.signature.CallingConvention,
+                               method.signature.GenericParameterCount);
+               }
+
+               [Obsolete("Please use SetSignature(Type, CustomModifiers, Type[], CustomModifiers[]) instead.")]
                public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
                {
                        method.signature = new MethodSignature(
@@ -129,13 +140,12 @@ namespace IKVM.Reflection
        sealed class MissingAssembly : Assembly
        {
                private readonly MissingModule module;
-               private readonly string name;
 
                internal MissingAssembly(Universe universe, string name)
                        : base(universe)
                {
                        module = new MissingModule(this);
-                       this.name = name;
+                       this.fullName = name;
                }
 
                public override Type[] GetTypes()
@@ -143,14 +153,9 @@ namespace IKVM.Reflection
                        throw new MissingAssemblyException(this);
                }
 
-               public override string FullName
-               {
-                       get { return name; }
-               }
-
                public override AssemblyName GetName()
                {
-                       return new AssemblyName(name);
+                       return new AssemblyName(fullName);
                }
 
                public override string ImageRuntimeVersion
@@ -218,6 +223,11 @@ namespace IKVM.Reflection
                        return null;
                }
 
+               internal override Type FindTypeIgnoreCase(TypeName lowerCaseName)
+               {
+                       return null;
+               }
+
                internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
                {
                        throw new MissingAssemblyException(this);
@@ -269,6 +279,11 @@ namespace IKVM.Reflection
                        return null;
                }
 
+               internal override Type FindTypeIgnoreCase(TypeName lowerCaseName)
+               {
+                       return null;
+               }
+
                internal override void GetTypesImpl(System.Collections.Generic.List<Type> list)
                {
                        throw new MissingModuleException(this);
@@ -350,6 +365,7 @@ namespace IKVM.Reflection
                        this.declaringType = declaringType;
                        this.ns = ns;
                        this.name = name;
+                       MarkEnumOrValueType(ns, name);
                }
 
                internal override MethodBase FindMethod(string name, MethodSignature signature)
@@ -372,6 +388,11 @@ namespace IKVM.Reflection
                        return null;
                }
 
+               internal override Type FindNestedTypeIgnoreCase(TypeName lowerCaseName)
+               {
+                       return null;
+               }
+
                public override bool __IsMissing
                {
                        get { return true; }
@@ -407,6 +428,11 @@ namespace IKVM.Reflection
                        get { return module; }
                }
 
+               public override int MetadataToken
+               {
+                       get { return token; }
+               }
+
                public override bool IsValueType
                {
                        get
@@ -418,7 +444,15 @@ namespace IKVM.Reflection
                                        case TypeFlags.NotValueType:
                                                return false;
                                        default:
-                                               throw new MissingMemberException(this);
+                                               if (module.universe.ResolveMissingTypeIsValueType(this))
+                                               {
+                                                       typeFlags |= TypeFlags.ValueType;
+                                               }
+                                               else
+                                               {
+                                                       typeFlags |= TypeFlags.NotValueType;
+                                               }
+                                               return (typeFlags & TypeFlags.ValueType) != 0;
                                }
                        }
                }
@@ -468,12 +502,7 @@ namespace IKVM.Reflection
                        throw new MissingMemberException(this);
                }
 
-               public override Type[] __GetRequiredCustomModifiers()
-               {
-                       throw new MissingMemberException(this);
-               }
-
-               public override Type[] __GetOptionalCustomModifiers()
+               public override CustomModifiers __GetCustomModifiers()
                {
                        throw new MissingMemberException(this);
                }
@@ -483,12 +512,7 @@ namespace IKVM.Reflection
                        throw new MissingMemberException(this);
                }
 
-               public override Type[][] __GetGenericArgumentsRequiredCustomModifiers()
-               {
-                       throw new MissingMemberException(this);
-               }
-
-               public override Type[][] __GetGenericArgumentsOptionalCustomModifiers()
+               public override CustomModifiers[] __GetGenericArgumentsCustomModifiers()
                {
                        throw new MissingMemberException(this);
                }
@@ -531,11 +555,6 @@ namespace IKVM.Reflection
                        return this;
                }
 
-               internal int GetMetadataTokenForMissing()
-               {
-                       return token;
-               }
-
                internal override Type SetMetadataTokenForMissing(int token)
                {
                        this.token = token;
@@ -578,6 +597,18 @@ namespace IKVM.Reflection
                {
                        get { return owner as Type; }
                }
+
+               internal override Type BindTypeParameters(IGenericBinder binder)
+               {
+                       if (owner is MethodBase)
+                       {
+                               return binder.BindMethodParameter(this);
+                       }
+                       else
+                       {
+                               return binder.BindTypeParameter(this);
+                       }
+               }
        }
 
        sealed class MissingMethod : MethodInfo
@@ -692,22 +723,11 @@ namespace IKVM.Reflection
                                get { return Forwarder.RawDefaultValue; }
                        }
 
-                       public override Type[] GetOptionalCustomModifiers()
-                       {
-                               if (index == -1)
-                               {
-                                       return Util.Copy(method.signature.GetReturnTypeOptionalCustomModifiers(method));
-                               }
-                               return Util.Copy(method.signature.GetParameterOptionalCustomModifiers(method, index));
-                       }
-
-                       public override Type[] GetRequiredCustomModifiers()
+                       public override CustomModifiers __GetCustomModifiers()
                        {
-                               if (index == -1)
-                               {
-                                       return Util.Copy(method.signature.GetReturnTypeRequiredCustomModifiers(method));
-                               }
-                               return Util.Copy(method.signature.GetParameterRequiredCustomModifiers(method, index));
+                               return index == -1
+                                       ? method.signature.GetReturnTypeCustomModifiers(method)
+                                       : method.signature.GetParameterCustomModifiers(method, index);
                        }
 
                        public override MemberInfo Member
@@ -761,6 +781,11 @@ namespace IKVM.Reflection
                        return Forwarder.GetMethodBody();
                }
 
+               public override int __MethodRVA
+               {
+                       get { return Forwarder.__MethodRVA; }
+               }
+
                public override CallingConventions CallingConvention
                {
                        get { return signature.CallingConvention; }
@@ -1079,6 +1104,11 @@ namespace IKVM.Reflection
                        get { throw new MissingMemberException(this); }
                }
 
+               internal override bool IsNonPrivate
+               {
+                       get { throw new MissingMemberException(this); }
+               }
+
                internal override bool IsStatic
                {
                        get { throw new MissingMemberException(this); }