2005-10-17 Marek Safar <marek.safar@seznam.cz>
[mono.git] / mcs / mcs / typemanager.cs
index ed6c7ddf3eb9176c3ce6a17291b0a3df0b6cc056..d5060cbf04d9696e2cb71c1cb88a6af10e57798d 100644 (file)
@@ -263,7 +263,7 @@ public class TypeManager {
        //  Contains all public types from referenced assemblies.
        //  This member is used only if CLS Compliance verification is required.
        // </remarks>
-       public static Hashtable all_imported_types;
+       public static Hashtable AllClsTopLevelTypes;
 
        static Hashtable fieldbuilders_to_fields;
        static Hashtable fields;
@@ -287,11 +287,9 @@ public class TypeManager {
                builder_to_method = null;
                
                fields = null;
-               builder_to_constant = null;
                fieldbuilders_to_fields = null;
                events = null;
                priv_fields_events = null;
-               properties = null;
                type_hash = null;
                
                TypeHandle.CleanUp ();
@@ -482,11 +480,6 @@ public class TypeManager {
                return builder_to_declspace [t] as Delegate;
        }
 
-       public static Enum LookupEnum (Type t)
-       {
-               return builder_to_declspace [t] as Enum;
-       }
-
        public static Class LookupClass (Type t)
        {
                return (Class) builder_to_declspace [t];
@@ -651,7 +644,7 @@ public class TypeManager {
                                Assembly a = assemblies [i];
                                string [] namespaces = (string []) assembly_get_namespaces.Invoke (a, null);
                                foreach (string ns in namespaces){
-                                       if (ns == "")
+                                       if (ns.Length == 0)
                                                continue;
                                        Namespace.LookupNamespace (ns, true);
                                }
@@ -697,10 +690,10 @@ public class TypeManager {
        /// </summary>
        public static void LoadAllImportedTypes ()
        {
-               all_imported_types = new Hashtable ();
+               AllClsTopLevelTypes = new Hashtable (1500);
                foreach (Assembly a in assemblies) {
                        foreach (Type t in a.GetExportedTypes ()) {
-                               all_imported_types [t.FullName] = t;
+                               AllClsTopLevelTypes [t.FullName.ToLower (System.Globalization.CultureInfo.InvariantCulture)] = null;
                        }
                }
        }
@@ -803,8 +796,13 @@ public class TypeManager {
                if (mb.IsSpecialName && !mb.IsConstructor) {
                        if (iparams.Count > 1) {
                                sig.Append ("this[");
-                               int before_ret_val = parameters.LastIndexOf (',');
-                               sig.Append (parameters.Substring (1, before_ret_val - 1));
+                               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));
+                               }
                                sig.Append (']');
                        } else {
                                sig.Append (mb.Name.Substring (4));
@@ -1449,11 +1447,12 @@ public class TypeManager {
        
        public static bool IsEnumType (Type t)
        {
-               if (t.IsSubclassOf (TypeManager.enum_type))
+               if (builder_to_declspace [t] is Enum)
                        return true;
-               else
-                       return false;
+
+               return t.IsEnum;
        }
+
        public static bool IsBuiltinOrEnum (Type t)
        {
                if (IsBuiltinType (t))
@@ -1617,27 +1616,6 @@ public class TypeManager {
        {
                return t.IsArray || t.IsPointer || t.IsByRef;
        }
-
-       static Hashtable builder_to_constant;
-
-       public static void RegisterConstant (FieldBuilder fb, Const c)
-       {
-               if (builder_to_constant == null)
-                       builder_to_constant = new PtrHashtable ();
-
-               if (builder_to_constant.Contains (fb))
-                       return;
-
-               builder_to_constant.Add (fb, c);
-       }
-
-       public static Const LookupConstant (FieldBuilder fb)
-       {
-               if (builder_to_constant == null)
-                       return null;
-               
-               return (Const) builder_to_constant [fb];
-       }
        
        /// <summary>
        ///   Gigantic work around for missing features in System.Reflection.Emit follows.
@@ -1747,23 +1725,17 @@ public class TypeManager {
                }
        }
        
-       // <remarks>
-       //  This is a workaround the fact that GetValue is not
-       //  supported for dynamic types
-       // </remarks>
-       static public bool RegisterFieldValue (FieldBuilder fb, object value)
+       public static void RegisterConstant (FieldInfo fb, IConstant ic)
        {
-               if (fields.Contains (fb))
-                       return false;
-
-               fields.Add (fb, value);
-
-               return true;
+               fields.Add (fb, ic);
        }
 
-       static public object GetValue (FieldBuilder fb)
+       public static IConstant GetConstant (FieldInfo fb)
        {
-               return fields [fb];
+               if (fb == null)
+                       return null;
+
+               return (IConstant)fields [fb];
        }
 
        static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f)
@@ -1840,27 +1812,9 @@ public class TypeManager {
                        return (MemberInfo) priv_fields_events [ei];
        }
                
-       static Hashtable properties;
-       
-       static public bool RegisterProperty (PropertyBuilder pb, MethodBase get, MethodBase set)
-       {
-               if (properties == null)
-                       properties = new Hashtable ();
-
-               if (properties.Contains (pb))
-                       return false;
-
-               properties.Add (pb, new Pair (get, set));
-
-               return true;
-       }
-
        static public bool RegisterIndexer (PropertyBuilder pb, MethodBase get,
                                             MethodBase set, Type[] args)
        {
-               if (!RegisterProperty (pb, get,set))
-                       return false;
-
                indexer_arguments.Add (pb, args);
 
                return true;