In mcs:
[mono.git] / mcs / mcs / typemanager.cs
index d5060cbf04d9696e2cb71c1cb88a6af10e57798d..c65cf80ef1085cfe49123af140b1aefedf947368 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author: Miguel de Icaza (miguel@gnu.org)
 //         Ravi Pratap     (ravi@ximian.com)
+//         Marek Safar     (marek.safar@seznam.cz)
 //
 // Licensed under the terms of the GNU GPL
 //
@@ -89,6 +90,8 @@ public class TypeManager {
        static public Type conditional_attribute_type;
        static public Type in_attribute_type;
        static public Type out_attribute_type;
+       static public Type default_parameter_value_attribute_type;
+
        static public Type anonymous_method_type;
        static public Type cls_compliant_attribute_type;
        static public Type typed_reference_type;
@@ -100,23 +103,19 @@ public class TypeManager {
        static public Type required_attr_type;
        static public Type guid_attr_type;
        static public Type assembly_culture_attribute_type;
+       static public Type coclass_attr_type;
+       static public Type comimport_attr_type;
 
        /// 
        /// .NET 2.0
        ///
 #if NET_2_0
+       static internal Type runtime_compatibility_attr_type;
        static internal Type compiler_generated_attr_type;
        static internal Type fixed_buffer_attr_type;
        static internal Type default_charset_type;
 #endif
 
-       //
-       // An empty array of types
-       //
-       static public Type [] NoTypes;
-       static public TypeExpr [] NoTypeExprs;
-
-
        // 
        // Expressions representing the internal types.  Used during declaration
        // definition.
@@ -191,7 +190,7 @@ public class TypeManager {
        // The attribute constructors.
        //
        static public ConstructorInfo object_ctor;
-       static public ConstructorInfo cons_param_array_attribute;
+       static private ConstructorInfo cons_param_array_attribute;
        static public ConstructorInfo void_decimal_ctor_five_args;
        static public ConstructorInfo void_decimal_ctor_int_arg;
        static public ConstructorInfo unverifiable_code_ctor;
@@ -208,19 +207,6 @@ public class TypeManager {
        static internal ConstructorInfo fixed_buffer_attr_ctor;
 #endif
 
-       // <remarks>
-       //   Holds the Array of Assemblies that have been loaded
-       //   (either because it is the default or the user used the
-       //   -r command line option)
-       // </remarks>
-       static Assembly [] assemblies;
-
-       // <remarks>
-       //  Keeps a list of modules. We used this to do lookups
-       //  on the module using GetType -- needed for arrays
-       // </remarks>
-       static Module [] modules;
-
        static PtrHashtable builder_to_declspace;
 
        static PtrHashtable builder_to_member_cache;
@@ -231,12 +217,6 @@ public class TypeManager {
        // </remarks>
        static PtrHashtable builder_to_ifaces;
 
-       // <remarks>
-       //   Maps MethodBase.RuntimeTypeHandle to a Type array that contains
-       //   the arguments to the method
-       // </remarks>
-       static Hashtable method_arguments;
-
        // <remarks>
        //   Maps PropertyBuilder to a Type array that contains
        //   the arguments to the indexer
@@ -266,7 +246,9 @@ public class TypeManager {
        public static Hashtable AllClsTopLevelTypes;
 
        static Hashtable fieldbuilders_to_fields;
+       static Hashtable propertybuilder_to_property;
        static Hashtable fields;
+       static Hashtable events;
 
        struct Signature {
                public string name;
@@ -276,12 +258,9 @@ public class TypeManager {
        public static void CleanUp ()
        {
                // Lets get everything clean so that we can collect before generating code
-               assemblies = null;
-               modules = null;
                builder_to_declspace = null;
                builder_to_member_cache = null;
                builder_to_ifaces = null;
-               method_arguments = null;
                indexer_arguments = null;
                method_params = null;
                builder_to_method = null;
@@ -291,6 +270,7 @@ public class TypeManager {
                events = null;
                priv_fields_events = null;
                type_hash = null;
+               propertybuilder_to_property = null;
                
                TypeHandle.CleanUp ();
        }
@@ -312,7 +292,7 @@ public class TypeManager {
                int count = sig.args.Length;
                
                if (mi is MethodBuilder || mi is ConstructorBuilder){
-                       Type [] candidate_args = GetArgumentTypes ((MethodBase) mi);
+                       Type [] candidate_args = GetParameterData ((MethodBase) mi).Types;
 
                        if (candidate_args.Length != count)
                                return false;
@@ -376,27 +356,24 @@ public class TypeManager {
 
        static public void Reset ()
        {
-               assemblies = new Assembly [0];
-               modules = null;
-               
                builder_to_declspace = new PtrHashtable ();
                builder_to_member_cache = new PtrHashtable ();
                builder_to_method = new PtrHashtable ();
-               method_arguments = new PtrHashtable ();
                method_params = new PtrHashtable ();
                method_overrides = new PtrHashtable ();
                indexer_arguments = new PtrHashtable ();
                builder_to_ifaces = new PtrHashtable ();
                
-               NoTypes = new Type [0];
-               NoTypeExprs = new TypeExpr [0];
-
                fieldbuilders_to_fields = new Hashtable ();
+               propertybuilder_to_property = new Hashtable ();
                fields = new Hashtable ();
                type_hash = new DoubleHash ();
+
+               // to uncover regressions
+               cons_param_array_attribute = null;
        }
 
-       public static void AddUserType (string name, DeclSpace ds)
+       public static void AddUserType (DeclSpace ds)
        {
                builder_to_declspace.Add (ds.TypeBuilder, ds);
        }
@@ -413,6 +390,7 @@ public class TypeManager {
        public static void AddMethod (MethodBase builder, IMethodData method)
        {
                builder_to_method.Add (builder, method);
+               method_params.Add (builder, method.ParameterInfo);
        }
 
        public static IMethodData GetMethod (MethodBase builder)
@@ -484,50 +462,6 @@ public class TypeManager {
        {
                return (Class) builder_to_declspace [t];
        }
-       
-       /// <summary>
-       ///   Registers an assembly to load types from.
-       /// </summary>
-       public static void AddAssembly (Assembly a)
-       {
-               foreach (Assembly assembly in assemblies) {
-                       if (a == assembly)
-                               return;
-               }
-
-               int top = assemblies.Length;
-               Assembly [] n = new Assembly [top + 1];
-
-               assemblies.CopyTo (n, 0);
-               
-               n [top] = a;
-               assemblies = n;
-       }
-
-        public static Assembly [] GetAssemblies ()
-        {
-                return assemblies;
-        }
-
-       /// <summary>
-       ///  Registers a module builder to lookup types from
-       /// </summary>
-       public static void AddModule (Module mb)
-       {
-               int top = modules != null ? modules.Length : 0;
-               Module [] n = new Module [top + 1];
-
-               if (modules != null)
-                       modules.CopyTo (n, 0);
-               n [top] = mb;
-               modules = n;
-       }
-
-       public static Module[] Modules {
-               get {
-                       return modules;
-               }
-       }
 
        //
        // We use this hash for multiple kinds of constructed types:
@@ -578,112 +512,6 @@ public class TypeManager {
                return (Type) ret;
        }
 
-       public static Type LookupTypeReflection (string name, Location loc)
-       {
-               Type found_type = null;
-
-               foreach (Assembly a in assemblies) {
-                       Type t = a.GetType (name);
-                       if (t == null)
-                               continue;
-
-                       if (t.IsPointer)
-                               throw new InternalErrorException ("Use GetPointerType() to get a pointer");
-
-                       TypeAttributes ta = t.Attributes & TypeAttributes.VisibilityMask;
-                       if (ta != TypeAttributes.NotPublic && ta != TypeAttributes.NestedPrivate &&
-                               ta != TypeAttributes.NestedAssembly && ta != TypeAttributes.NestedFamANDAssem) {
-                               if (found_type == null) {
-                                       found_type = t;
-                                       continue;
-                               }
-
-                               Report.SymbolRelatedToPreviousError (found_type);
-                               Report.SymbolRelatedToPreviousError (t);
-                               Report.Error (433, loc, "The imported type `{0}' is defined multiple times", name);
-                               return found_type;
-                       }
-               }
-
-               foreach (Module mb in modules) {
-                       Type t = mb.GetType (name);
-                       if (t == null)
-                               continue;
-                       
-                       if (found_type == null) {
-                               found_type = t;
-                               continue;
-                       }
-
-                       Report.SymbolRelatedToPreviousError (t);
-                       Report.SymbolRelatedToPreviousError (found_type);
-                       Report.Warning (436, 2, loc, "Ignoring imported type `{0}' since the current assembly already has a declaration with the same name",
-                               TypeManager.CSharpName (t));
-                       return t;
-               }
-
-               return found_type;
-       }
-
-       /// <summary>
-       ///   Computes the namespaces that we import from the assemblies we reference.
-       /// </summary>
-       public static void ComputeNamespaces ()
-       {
-               MethodInfo assembly_get_namespaces = typeof (Assembly).GetMethod ("GetNamespaces", BindingFlags.Instance|BindingFlags.NonPublic);
-
-               Hashtable cache = null;
-
-               //
-               // First add the assembly namespaces
-               //
-               if (assembly_get_namespaces != null){
-                       int count = assemblies.Length;
-
-                       for (int i = 0; i < count; i++){
-                               Assembly a = assemblies [i];
-                               string [] namespaces = (string []) assembly_get_namespaces.Invoke (a, null);
-                               foreach (string ns in namespaces){
-                                       if (ns.Length == 0)
-                                               continue;
-                                       Namespace.LookupNamespace (ns, true);
-                               }
-                       }
-               } else {
-                       cache = new Hashtable ();
-                       cache.Add ("", null);
-                       foreach (Assembly a in assemblies) {
-                               foreach (Type t in a.GetExportedTypes ()) {
-                                       string ns = t.Namespace;
-                                       if (ns == null || cache.Contains (ns))
-                                               continue;
-
-                                       Namespace.LookupNamespace (ns, true);
-                                       cache.Add (ns, null);
-                               }
-                       }
-               }
-
-               //
-               // Then add module namespaces
-               //
-               foreach (Module m in modules) {
-                       if (m == CodeGen.Module.Builder)
-                               continue;
-                       if (cache == null) {
-                               cache = new Hashtable ();
-                               cache.Add ("", null);
-                       }
-                       foreach (Type t in m.GetTypes ()) {
-                               string ns = t.Namespace;
-                               if (ns == null || cache.Contains (ns))
-                                       continue;
-                               Namespace.LookupNamespace (ns, true);
-                               cache.Add (ns, null);
-                       }
-               }
-       }
-
        /// <summary>
        /// Fills static table with exported types from all referenced assemblies.
        /// This information is required for CLS Compliance tests.
@@ -691,7 +519,7 @@ public class TypeManager {
        public static void LoadAllImportedTypes ()
        {
                AllClsTopLevelTypes = new Hashtable (1500);
-               foreach (Assembly a in assemblies) {
+               foreach (Assembly a in RootNamespace.Global.Assemblies) {
                        foreach (Type t in a.GetExportedTypes ()) {
                                AllClsTopLevelTypes [t.FullName.ToLower (System.Globalization.CultureInfo.InvariantCulture)] = null;
                        }
@@ -700,7 +528,7 @@ public class TypeManager {
 
        public static bool NamespaceClash (string name, Location loc)
        {
-               if (Namespace.LookupNamespace (name, false) == null)
+               if (! RootNamespace.Global.IsNamespace (name))
                        return false;
 
                Report.Error (519, loc, String.Format ("`{0}' clashes with a predefined namespace", name));
@@ -752,6 +580,14 @@ public class TypeManager {
        /// </summary>
        static public string GetFullNameSignature (MemberInfo mi)
        {
+               PropertyInfo pi = mi as PropertyInfo;
+               if (pi != null) {
+                       MethodBase pmi = pi.GetGetMethod (true);
+                       if (pmi == null)
+                               pmi = pi.GetSetMethod (true);
+                       if (GetParameterData (pmi).Count > 0)
+                               mi = pmi;
+               }
                return (mi is MethodBase)
                        ? CSharpSignature (mi as MethodBase) 
                        : CSharpName (mi.DeclaringType) + '.' + mi.Name;
@@ -794,14 +630,17 @@ public class TypeManager {
 
                // Is indexer
                if (mb.IsSpecialName && !mb.IsConstructor) {
-                       if (iparams.Count > 1) {
+                       if (iparams.Count > (mb.Name.StartsWith ("get_") ? 0 : 1)) {
                                sig.Append ("this[");
                                if (show_accessor) {
                                        sig.Append (parameters.Substring (1, parameters.Length - 2));
                                }
                                else {
                                        int before_ret_val = parameters.LastIndexOf (',');
-                                       sig.Append (parameters.Substring (1, before_ret_val - 1));
+                                       if (before_ret_val < 0)
+                                               sig.Append (parameters.Substring (1, parameters.Length - 2));
+                                       else
+                                               sig.Append (parameters.Substring (1, before_ret_val - 1));
                                }
                                sig.Append (']');
                        } else {
@@ -835,7 +674,7 @@ public class TypeManager {
        /// </summary>
        static Type CoreLookupType (string ns_name, string name)
        {
-               Namespace ns = Namespace.LookupNamespace (ns_name, true);
+               Namespace ns = RootNamespace.Global.GetNamespace (ns_name, true);
                FullNamedExpression fne = ns.Lookup (RootContext.Tree.Types, name, Location.Null);
                Type t = fne == null ? null : fne.Type;
                if (t == null)
@@ -911,13 +750,16 @@ public class TypeManager {
        /// <summary>
        ///    Returns the ConstructorInfo for "args"
        /// </summary>
-       public static ConstructorInfo GetConstructor (Type t, Type [] args)
+       private static ConstructorInfo GetConstructor (Type t, Type [] args)
        {
                MemberList list;
                Signature sig;
 
                sig.name = ".ctor";
                sig.args = args;
+
+               if (t == null)
+                       throw new InternalErrorException ("Core types haven't been initialized yet?");
                
                list = FindMembers (t, MemberTypes.Constructor,
                                    instance_and_static | BindingFlags.Public | BindingFlags.DeclaredOnly,
@@ -1000,6 +842,9 @@ public class TypeManager {
                param_array_type     = CoreLookupType ("System", "ParamArrayAttribute");
                in_attribute_type    = CoreLookupType ("System.Runtime.InteropServices", "InAttribute");
                out_attribute_type   = CoreLookupType ("System.Runtime.InteropServices", "OutAttribute");
+#if NET_2_0
+               default_parameter_value_attribute_type = CoreLookupType ("System.Runtime.InteropServices", "DefaultParameterValueAttribute");
+#endif
                typed_reference_type = CoreLookupType ("System", "TypedReference");
                arg_iterator_type    = CoreLookupType ("System", "ArgIterator");
                mbr_type             = CoreLookupType ("System", "MarshalByRefObject");
@@ -1027,6 +872,8 @@ public class TypeManager {
                required_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "RequiredAttributeAttribute");
                guid_attr_type = CoreLookupType ("System.Runtime.InteropServices", "GuidAttribute");
                assembly_culture_attribute_type = CoreLookupType ("System.Reflection", "AssemblyCultureAttribute");
+               comimport_attr_type = CoreLookupType ("System.Runtime.InteropServices", "ComImportAttribute");
+               coclass_attr_type = CoreLookupType ("System.Runtime.InteropServices", "CoClassAttribute");
 
                //
                // .NET 2.0
@@ -1035,6 +882,7 @@ public class TypeManager {
                compiler_generated_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "CompilerGeneratedAttribute");
                fixed_buffer_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "FixedBufferAttribute");
                default_charset_type = CoreLookupType ("System.Runtime.InteropServices", "DefaultCharSetAttribute");
+               runtime_compatibility_attr_type = CoreLookupType ("System.Runtime.CompilerServices", "RuntimeCompatibilityAttribute");
 #endif
                //
                // When compiling corlib, store the "real" types here.
@@ -1045,13 +893,12 @@ public class TypeManager {
                        system_type_type = typeof (System.Type);
                        system_assemblybuilder_type = typeof (System.Reflection.Emit.AssemblyBuilder);
 
-                       Type [] void_arg = {  };
                        system_int_array_get_length = GetMethod (
-                               system_array_type, "get_Length", void_arg);
+                               system_array_type, "get_Length", Type.EmptyTypes);
                        system_int_array_get_rank = GetMethod (
-                               system_array_type, "get_Rank", void_arg);
+                               system_array_type, "get_Rank", Type.EmptyTypes);
                        system_object_array_clone = GetMethod (
-                               system_array_type, "Clone", void_arg);
+                               system_array_type, "Clone", Type.EmptyTypes);
 
                        Type [] system_int_arg = { system_int32_type };
                        system_int_array_get_length_int = GetMethod (
@@ -1178,23 +1025,22 @@ public class TypeManager {
                //
                // Void arguments
                //
-               Type [] void_arg = {  };
                ienumerator_getcurrent = GetProperty (
                        ienumerator_type, "Current");
                bool_movenext_void = GetMethod (
-                       ienumerator_type, "MoveNext", void_arg);
+                       ienumerator_type, "MoveNext", Type.EmptyTypes);
                void_reset_void = GetMethod (
-                       ienumerator_type, "Reset", void_arg);
+                       ienumerator_type, "Reset", Type.EmptyTypes);
                void_dispose_void = GetMethod (
-                       idisposable_type, "Dispose", void_arg);
+                       idisposable_type, "Dispose", Type.EmptyTypes);
                int_get_offset_to_string_data = GetMethod (
-                       runtime_helpers_type, "get_OffsetToStringData", void_arg);
+                       runtime_helpers_type, "get_OffsetToStringData", Type.EmptyTypes);
                int_array_get_length = GetMethod (
-                       array_type, "get_Length", void_arg);
+                       array_type, "get_Length", Type.EmptyTypes);
                int_array_get_rank = GetMethod (
-                       array_type, "get_Rank", void_arg);
+                       array_type, "get_Rank", Type.EmptyTypes);
                ienumerable_getenumerator_void = GetMethod (
-                       ienumerable_type, "GetEnumerator", void_arg);
+                       ienumerable_type, "GetEnumerator", Type.EmptyTypes);
                
                //
                // Int32 arguments
@@ -1211,7 +1057,7 @@ public class TypeManager {
                // System.Array methods
                //
                object_array_clone = GetMethod (
-                       array_type, "Clone", void_arg);
+                       array_type, "Clone", Type.EmptyTypes);
                Type [] array_int_arg = { array_type, int32_type };
                void_array_copyto_array_int = GetMethod (
                        array_type, "CopyTo", array_int_arg);
@@ -1248,8 +1094,7 @@ public class TypeManager {
                //
                // Attributes
                //
-               cons_param_array_attribute = GetConstructor (param_array_type, void_arg);
-               unverifiable_code_ctor = GetConstructor (unverifiable_code_type, void_arg);
+               unverifiable_code_ctor = GetConstructor (unverifiable_code_type, Type.EmptyTypes);
                default_member_ctor = GetConstructor (default_member_type, string_);
 
                Type[] short_arg = { short_type };
@@ -1266,15 +1111,23 @@ public class TypeManager {
                //
 #if NET_2_0
                compiler_generated_attr = new CustomAttributeBuilder (
-                       GetConstructor (compiler_generated_attr_type, void_arg), new object[0]);
+                       GetConstructor (compiler_generated_attr_type, Type.EmptyTypes), new object[0]);
 
                Type[] type_int_arg = { type_type, int32_type };
                fixed_buffer_attr_ctor = GetConstructor (fixed_buffer_attr_type, type_int_arg);
 #endif
 
                // Object
-               object_ctor = GetConstructor (object_type, void_arg);
+               object_ctor = GetConstructor (object_type, Type.EmptyTypes);
+
+       }
 
+       static public ConstructorInfo ConsParamArrayAttribute {
+               get {
+                       if (cons_param_array_attribute == null)
+                               cons_param_array_attribute = GetConstructor (param_array_type, Type.EmptyTypes);
+                       return cons_param_array_attribute;
+               }
        }
 
        const BindingFlags instance_and_static = BindingFlags.Static | BindingFlags.Instance;
@@ -1304,7 +1157,7 @@ public class TypeManager {
                // a TypeBuilder array will return a Type, not a TypeBuilder,
                // and we can not call FindMembers on this type.
                //
-               if (t.IsSubclassOf (TypeManager.array_type))
+               if (TypeManager.IsSubclassOf (t, TypeManager.array_type))
                        return new MemberList (TypeManager.array_type.FindMembers (mt, bf, filter, criteria));
 
                //
@@ -1500,7 +1353,7 @@ public class TypeManager {
                if (t is TypeBuilder){
                        TypeContainer tc = LookupTypeContainer (t);
                        if (tc.Fields != null){
-                               foreach (Field f in tc.Fields){
+                               foreach (FieldMember f in tc.Fields){
                                        // Avoid using f.FieldBuilder: f.Define () may not yet have been invoked.
                                        if ((f.ModFlags & Modifiers.STATIC) != 0)
                                                continue;
@@ -1626,36 +1479,30 @@ public class TypeManager {
        ///   for anything which is dynamic, and we need this in a number of places,
        ///   we register this information here, and use it afterwards.
        /// </remarks>
-       static public void RegisterMethod (MethodBase mb, InternalParameters ip, Type [] args)
+       static public void RegisterMethod (MethodBase mb, Parameters ip)
        {
-               if (args == null)
-                       args = NoTypes;
-                               
-               method_arguments.Add (mb, args);
                method_params.Add (mb, ip);
        }
        
        static public ParameterData GetParameterData (MethodBase mb)
        {
-               object pd = method_params [mb];
+               ParameterData pd = (ParameterData)method_params [mb];
                if (pd == null) {
                        if (mb is MethodBuilder || mb is ConstructorBuilder)
                                throw new InternalErrorException ("Argument for Method not registered" + mb);
 
-                       method_params [mb] = pd = new ReflectionParameters (mb);
+                       pd = new ReflectionParameters (mb);
+                       method_params.Add (mb, pd);
                }
-
-               return (ParameterData) pd;
+               return pd;
        }
 
        static public void RegisterOverride (MethodBase override_method, MethodBase base_method)
        {
-               if (method_overrides.Contains (override_method)) {
-                       if (method_overrides [override_method] != base_method)
-                               throw new InternalErrorException ("Override mismatch: " + override_method);
-                       return;
-               }
-               method_overrides [override_method] = base_method;
+               if (!method_overrides.Contains (override_method))
+                       method_overrides [override_method] = base_method;
+               if (method_overrides [override_method] != base_method)
+                       throw new InternalErrorException ("Override mismatch: " + override_method);
        }
 
        static public bool IsOverride (MethodBase m)
@@ -1665,32 +1512,9 @@ public class TypeManager {
                        (m is MethodBuilder || method_overrides.Contains (m));
        }
 
-       /// <summary>
-       ///    Returns the argument types for a method based on its methodbase
-       ///
-       ///    For dynamic methods, we use the compiler provided types, for
-       ///    methods from existing assemblies we load them from GetParameters,
-       ///    and insert them into the cache
-       /// </summary>
-       static public Type [] GetArgumentTypes (MethodBase mb)
+       static public MethodBase TryGetBaseDefinition (MethodBase m)
        {
-               object t = method_arguments [mb];
-               if (t != null)
-                       return (Type []) t;
-
-               ParameterInfo [] pi = mb.GetParameters ();
-               int c = pi.Length;
-               Type [] types;
-
-               if (c == 0) {
-                       types = NoTypes;
-               } else {
-                       types = new Type [c];
-                       for (int i = 0; i < c; i++)
-                               types [i] = pi [i].ParameterType;
-               }
-               method_arguments.Add (mb, types);
-               return types;
+               return (MethodBase) method_overrides [m];
        }
 
        /// <summary>
@@ -1708,12 +1532,12 @@ public class TypeManager {
                        // If we're a PropertyBuilder and not in the
                        // `indexer_arguments' hash, then we're a property and
                        // not an indexer.
-                       return NoTypes;
+                       return Type.EmptyTypes;
                else {
                        ParameterInfo [] pi = indexer.GetIndexParameters ();
                        // Property, not an indexer.
                        if (pi == null)
-                               return NoTypes;
+                               return Type.EmptyTypes;
                        int c = pi.Length;
                        Type [] types = new Type [c];
                        
@@ -1738,6 +1562,16 @@ public class TypeManager {
                return (IConstant)fields [fb];
        }
 
+       public static void RegisterProperty (PropertyInfo pi, PropertyBase pb)
+       {
+               propertybuilder_to_property.Add (pi, pb);
+       }
+
+       public static PropertyBase GetProperty (PropertyInfo pi)
+       {
+               return (PropertyBase)propertybuilder_to_property [pi];
+       }
+
        static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f)
        {
                if (fieldbuilders_to_fields.Contains (fb))
@@ -1757,8 +1591,6 @@ public class TypeManager {
                return (FieldBase) fieldbuilders_to_fields [fb];
        }
        
-       static Hashtable events;
-
        static public void RegisterEvent (MyEventBuilder eb, MethodBase add, MethodBase remove)
        {
                if (events == null)
@@ -1887,14 +1719,12 @@ public class TypeManager {
        ///   This expands in context like: IA; IB : IA; IC : IA, IB; the interface "IC" to
        ///   be IA, IB, IC.
        /// </remarks>
-       public static Type[] ExpandInterfaces (EmitContext ec, TypeExpr [] base_interfaces)
+       public static Type[] ExpandInterfaces (TypeExpr [] base_interfaces)
        {
                ArrayList new_ifaces = new ArrayList ();
 
                foreach (TypeExpr iface in base_interfaces){
-                       Type itype = iface.ResolveType (ec);
-                       if (itype == null)
-                               return null;
+                       Type itype = iface.Type;
 
                        if (!new_ifaces.Contains (itype))
                                new_ifaces.Add (itype);
@@ -1919,7 +1749,6 @@ public class TypeManager {
        /// </summary>
        public static Type [] GetInterfaces (Type t)
        {
-               
                Type [] cached = iface_cache [t] as Type [];
                if (cached != null)
                        return cached;
@@ -1941,13 +1770,13 @@ public class TypeManager {
                        Type [] base_ifaces;
                        
                        if (t.BaseType == null)
-                               base_ifaces = NoTypes;
+                               base_ifaces = Type.EmptyTypes;
                        else
                                base_ifaces = GetInterfaces (t.BaseType);
                        Type [] type_ifaces = (Type []) builder_to_ifaces [t];
-                       if (type_ifaces == null)
-                               type_ifaces = NoTypes;
-
+                       if (type_ifaces == null || type_ifaces.Length == 0)
+                               type_ifaces = Type.EmptyTypes;
+                       
                        int base_count = base_ifaces.Length;
                        Type [] result = new Type [base_count + type_ifaces.Length];
                        base_ifaces.CopyTo (result, 0);
@@ -2222,9 +2051,7 @@ public class TypeManager {
                                new Type [] { typeof (Type), typeof (bool)},
                                null);
                        if (declare_local_method == null){
-                               Report.Warning (-30, new Location (-1),
-                                               "This version of the runtime does not support making pinned local variables.  " +
-                                               "This code may cause errors on a runtime with a moving GC");
+                               Report.RuntimeMissingSupport (Location.Null, "pinned local variables");
                                return ig.DeclareLocal (t);
                        }
                }
@@ -2236,7 +2063,7 @@ public class TypeManager {
        //
        public static bool ArrayContainsMethod (MemberInfo [] array, MethodBase new_method)
        {
-               Type [] new_args = TypeManager.GetArgumentTypes (new_method);
+               Type [] new_args = TypeManager.GetParameterData (new_method).Types;
                
                foreach (MethodBase method in array) {
                        if (method.Name != new_method.Name)
@@ -2247,7 +2074,7 @@ public class TypeManager {
                                         continue;
 
                         
-                       Type [] old_args = TypeManager.GetArgumentTypes (method);
+                       Type [] old_args = TypeManager.GetParameterData (method).Types;
                        int old_count = old_args.Length;
                        int i;
                        
@@ -2298,6 +2125,18 @@ public class TypeManager {
        }
 
 
+       // This method always return false for non-generic compiler,
+       // while Type.IsGenericParameter is returned if it is supported.
+       public static bool IsGenericParameter (Type type)
+       {
+               return false;
+       }
+
+       public static int GenericParameterPosition (Type type)
+       {
+               throw new InternalErrorException ("should not be called");
+       }
+
 #region MemberLookup implementation
        
        //
@@ -2305,11 +2144,6 @@ public class TypeManager {
        // uses NonPublic for both protected and private), we need to distinguish.
        //
 
-       static internal bool FilterNone (MemberInfo m, object filter_criteria)
-       {
-               return true;
-       }
-
        internal class Closure {
                internal bool     private_ok;
 
@@ -2618,9 +2452,9 @@ public class TypeManager {
                        return (MemberInfo []) first_members_list;
                }
 
-               if (method_list != null && method_list.Count > 0)
+               if (method_list != null && method_list.Count > 0) {
                         return (MemberInfo []) method_list.ToArray (typeof (MemberInfo));
-                
+                }
                //
                // This happens if we already used the cache in the first iteration, in this case
                // the cache already looked in all interfaces.