This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / gmcs / support.cs
index 2f638f2f2662c7f5c5180cd99503bac17d97feac..5f9dc55b7662ce8add873fed3e6581ca15cce9c8 100755 (executable)
@@ -39,7 +39,6 @@ namespace Mono.CSharp {
 
        public class ReflectionParameters : ParameterData {
                ParameterInfo [] pi;
-               Type[] type_params;
                bool last_arg_is_params = false;
                bool is_varargs = false;
                ParameterData gpd;
@@ -65,9 +64,6 @@ namespace Mono.CSharp {
                                return;
                        }
 
-                       if (mb.IsGenericMethodDefinition)
-                               type_params = mb.GetGenericArguments ();
-
                        attrs = pi [count].GetCustomAttributes (TypeManager.param_array_type, true);
                        if (attrs == null)
                                return;
@@ -100,10 +96,11 @@ namespace Mono.CSharp {
                        if (gpd != null)
                                return gpd.GenericConstraints (pos);
 
-                       if (type_params == null)
+                       Type t = ParameterType (pos);
+                       if (!t.IsGenericParameter)
                                return null;
 
-                       return ReflectionConstraints.Create (type_params [pos]);
+                       return ReflectionConstraints.Create (t);
                }
 
                public string ParameterName (int pos)
@@ -238,7 +235,6 @@ namespace Mono.CSharp {
                int count;
 
                public readonly Parameters Parameters;
-               public readonly TypeParameter[] TypeParameters;
                
                public InternalParameters (Type [] param_types, Parameters parameters)
                {
@@ -257,13 +253,6 @@ namespace Mono.CSharp {
                                count = param_types.Length;
                }
 
-               public InternalParameters (DeclSpace ds, Parameters parameters,
-                                          TypeParameter [] type_params)
-                       : this (ds, parameters)
-               {
-                       this.TypeParameters = type_params;
-               }
-
                public int Count {
                        get {
                                return has_varargs ? count + 1 : count;
@@ -299,10 +288,10 @@ namespace Mono.CSharp {
 
                public GenericConstraints GenericConstraints (int pos)
                {
-                       if (TypeParameters == null)
+                       if (param_types == null)
                                return null;
 
-                       return TypeParameters [pos].Constraints;
+                       return GetParameter (pos).GenericConstraints;
                }
 
                public string ParameterName (int pos)
@@ -416,6 +405,29 @@ namespace Mono.CSharp {
                }
        }                       
 
+       //
+       // Compares member infos based on their name and
+       // also allows one argument to be a string
+       //
+       class MemberInfoCompare : IComparer {
+
+               public int Compare (object a, object b)
+               {
+                       if (a == null || b == null){
+                               Console.WriteLine ("Invalid information passed");
+                               throw new Exception ();
+                       }
+                       
+                       if (a is string)
+                               return String.Compare ((string) a, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
+
+                       if (b is string)
+                               return String.Compare (((MemberInfo)a).Name, (string) b, false, CultureInfo.InvariantCulture);
+
+                       return String.Compare (((MemberInfo)a).Name, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
+               }
+       }
+
        struct Pair {
                public object First;
                public object Second;