2009-12-03 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Thu, 3 Dec 2009 17:25:18 +0000 (17:25 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 3 Dec 2009 17:25:18 +0000 (17:25 -0000)
*.cs: Moving to generics world.

svn path=/trunk/mcs/; revision=147572

20 files changed:
mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/attribute.cs
mcs/mcs/class.cs
mcs/mcs/codegen.cs
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs
mcs/mcs/doc.cs
mcs/mcs/driver.cs
mcs/mcs/enum.cs
mcs/mcs/expression.cs
mcs/mcs/linq.cs
mcs/mcs/location.cs
mcs/mcs/namespace.cs
mcs/mcs/pending.cs
mcs/mcs/report.cs
mcs/mcs/rootcontext.cs
mcs/mcs/roottypes.cs
mcs/mcs/statement.cs
mcs/mcs/typemanager.cs

index 11926c2b19981c8abbc28076ec9aa58e9d281203..e96ffa8b339c0b0b13dad36e054b1dee1e2da5d3 100644 (file)
@@ -1,3 +1,7 @@
+2009-12-03  Marek Safar  <marek.safar@gmail.com>
+
+       *.cs: Moving to generics world.
+
 2009-12-02  Marek Safar  <marek.safar@gmail.com>
 
        * typemanager.cs, parameter.cs, class.cs, delegate.cs, attribute.cs:
index 2f410cff091feae476fd116f62d36b5bce2739a4..b57c2e3c501a5159491ac05614b0c6f72fda48b4 100644 (file)
@@ -12,7 +12,7 @@
 using System;
 using System.Text;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 
@@ -866,13 +866,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               ListDictionary compatibles;
+               Dictionary<Type, Expression> compatibles;
                public ToplevelBlock Block;
 
                public AnonymousMethodExpression (Location loc)
                {
                        this.loc = loc;
-                       this.compatibles = new ListDictionary ();
+                       this.compatibles = new Dictionary<Type, Expression> ();
                }
 
                public override string ExprClassName {
@@ -1049,8 +1049,8 @@ namespace Mono.CSharp {
                //
                public Expression Compatible (ResolveContext ec, Type type)
                {
-                       Expression am = (Expression) compatibles [type];
-                       if (am != null)
+                       Expression am;
+                       if (compatibles.TryGetValue (type, out am))
                                return am;
 
                        Type delegate_type = CompatibleChecks (ec, type);
@@ -1708,15 +1708,15 @@ namespace Mono.CSharp {
                public const string ClassNamePrefix = "<>__AnonType";
                public const string SignatureForError = "anonymous type";
                
-               readonly ArrayList parameters;
+               readonly IList<AnonymousTypeParameter> parameters;
 
-               private AnonymousTypeClass (DeclSpace parent, MemberName name, ArrayList parameters, Location loc)
+               private AnonymousTypeClass (DeclSpace parent, MemberName name, IList<AnonymousTypeParameter> parameters, Location loc)
                        : base (parent, name, (RootContext.EvalMode ? Modifiers.PUBLIC : 0) | Modifiers.SEALED)
                {
                        this.parameters = parameters;
                }
 
-               public static AnonymousTypeClass Create (CompilerContext ctx, TypeContainer parent, ArrayList parameters, Location loc)
+               public static AnonymousTypeClass Create (CompilerContext ctx, TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
                {
                        string name = ClassNamePrefix + types_counter++;
 
@@ -1980,7 +1980,7 @@ namespace Mono.CSharp {
                        return SignatureForError;
                }
 
-               public ArrayList Parameters {
+               public IList<AnonymousTypeParameter> Parameters {
                        get {
                                return parameters;
                        }
index 784e92a12c3edc013c4146490b7464d0f1d5b261..cf7b1397a8df92deff2e4246852f68d8344abbd4 100644 (file)
@@ -13,7 +13,7 @@
 using System;
 using System.Diagnostics;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.InteropServices;
@@ -919,7 +919,7 @@ namespace Mono.CSharp {
                /// Creates instance of SecurityAttribute class and add result of CreatePermission method to permission table.
                /// </summary>
                /// <returns></returns>
-               public void ExtractSecurityPermissionSet (ListDictionary permissions)
+               public void ExtractSecurityPermissionSet (Dictionary<SecurityAction, PermissionSet> permissions)
                {
                        Type orig_assembly_type = null;
 
@@ -998,8 +998,8 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       PermissionSet ps = (PermissionSet)permissions [action];
-                       if (ps == null) {
+                       PermissionSet ps;
+                       if (!permissions.TryGetValue (action, out ps)) {
                                if (sa is PermissionSetAttribute)
                                        ps = new PermissionSet (sa.Unrestricted ? PermissionState.Unrestricted : PermissionState.None);
                                else
@@ -1186,13 +1186,13 @@ namespace Mono.CSharp {
 
                public override int GetHashCode ()
                {
-                       return base.GetHashCode ();
+                       return type.GetHashCode () ^ Target.GetHashCode ();
                }
 
                /// <summary>
                /// Emit attribute for Attributable symbol
                /// </summary>
-               public void Emit (ListDictionary allEmitted)
+               public void Emit (Dictionary<Attribute, List<Attribute>> allEmitted)
                {
                        CustomAttributeBuilder cb = Resolve ();
                        if (cb == null)
@@ -1217,10 +1217,10 @@ namespace Mono.CSharp {
                        }
 
                        if (!usage_attr.AllowMultiple && allEmitted != null) {
-                               if (allEmitted.Contains (this)) {
-                                       ArrayList a = allEmitted [this] as ArrayList;
+                               if (allEmitted.ContainsKey (this)) {
+                                       var a = allEmitted [this];
                                        if (a == null) {
-                                               a = new ArrayList (2);
+                                               a = new List<Attribute> (2);
                                                allEmitted [this] = a;
                                        }
                                        a.Add (this);
@@ -1383,20 +1383,20 @@ namespace Mono.CSharp {
        }
 
        public class Attributes {
-               public readonly ArrayList Attrs;
+               public readonly List<Attribute> Attrs;
 
                public Attributes (Attribute a)
                {
-                       Attrs = new ArrayList ();
+                       Attrs = new List<Attribute> ();
                        Attrs.Add (a);
                }
 
-               public Attributes (ArrayList attrs)
+               public Attributes (List<Attribute> attrs)
                {
                        Attrs = attrs;
                }
 
-               public void AddAttributes (ArrayList attrs)
+               public void AddAttributes (List<Attribute> attrs)
                {
                        Attrs.AddRange (attrs);
                }
@@ -1409,7 +1409,7 @@ namespace Mono.CSharp {
 
                public Attributes Clone ()
                {
-                       ArrayList al = new ArrayList (Attrs.Count);
+                       var al = new List<Attribute> (Attrs.Count);
                        foreach (Attribute a in Attrs)
                                al.Add (a.Clone ());
 
@@ -1459,7 +1459,7 @@ namespace Mono.CSharp {
                {
                        CheckTargets ();
 
-                       ListDictionary ld = Attrs.Count > 1 ? new ListDictionary () : null;
+                       Dictionary<Attribute, List<Attribute>> ld = Attrs.Count > 1 ? new Dictionary<Attribute, List<Attribute>> () : null;
 
                        foreach (Attribute a in Attrs)
                                a.Emit (ld);
@@ -1467,13 +1467,13 @@ namespace Mono.CSharp {
                        if (ld == null || ld.Count == 0)
                                return;
 
-                       foreach (DictionaryEntry d in ld) {
+                       foreach (var d in ld) {
                                if (d.Value == null)
                                        continue;
 
-                               Attribute a = (Attribute) d.Key;
+                               Attribute a = d.Key;
 
-                               foreach (Attribute collision in (ArrayList)d.Value)
+                               foreach (Attribute collision in d.Value)
                                        a.Report.SymbolRelatedToPreviousError (collision.Location, "");
 
                                a.Report.Error (579, a.Location, "The attribute `{0}' cannot be applied multiple times",
index 97c1f8e733bc331557ea69ecbda1fb9915fc011f..d2f0fd5eebee993f464e24a19f2f7d1d7607cfff 100644 (file)
@@ -13,7 +13,7 @@
 
 using System;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
@@ -241,7 +241,7 @@ namespace Mono.CSharp {
                public readonly Kind Kind;
 
                // Holds a list of classes and structures
-               protected ArrayList types;
+               protected MemberCoreArrayList types;
 
                MemberCoreArrayList ordered_explicit_member_list;
                MemberCoreArrayList ordered_member_list;
@@ -2583,8 +2583,9 @@ namespace Mono.CSharp {
                }
        }
 
-       public abstract class ClassOrStruct : TypeContainer {
-               ListDictionary declarative_security;
+       public abstract class ClassOrStruct : TypeContainer
+       {
+               Dictionary<SecurityAction, PermissionSet> declarative_security;
 
                public ClassOrStruct (NamespaceEntry ns, DeclSpace parent,
                                      MemberName name, Attributes attrs, Kind kind)
@@ -2632,7 +2633,7 @@ namespace Mono.CSharp {
                {
                        if (a.IsValidSecurityAttribute ()) {
                                if (declarative_security == null)
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
 
                                a.ExtractSecurityPermissionSet (declarative_security);
                                return;
@@ -2700,8 +2701,8 @@ namespace Mono.CSharp {
                        base.Emit ();
 
                        if (declarative_security != null) {
-                               foreach (DictionaryEntry de in declarative_security) {
-                                       TypeBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
+                               foreach (var de in declarative_security) {
+                                       TypeBuilder.AddDeclarativeSecurity (de.Key, de.Value);
                                }
                        }
                }
@@ -3786,7 +3787,7 @@ namespace Mono.CSharp {
        {
                public MethodBuilder MethodBuilder;
                ReturnParameter return_attributes;
-               ListDictionary declarative_security;
+               Dictionary<SecurityAction, PermissionSet> declarative_security;
                protected MethodData MethodData;
 
                static string[] attribute_targets = new string [] { "method", "return" };
@@ -3823,7 +3824,7 @@ namespace Mono.CSharp {
 
                        if (a.IsValidSecurityAttribute ()) {
                                if (declarative_security == null)
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
                                a.ExtractSecurityPermissionSet (declarative_security);
                                return;
                        }
@@ -3968,8 +3969,8 @@ namespace Mono.CSharp {
                                OptAttributes.Emit ();
 
                        if (declarative_security != null) {
-                               foreach (DictionaryEntry de in declarative_security) {
-                                       MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
+                               foreach (var de in declarative_security) {
+                                       MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
                                }
                        }
 
@@ -4630,7 +4631,7 @@ namespace Mono.CSharp {
        public class Constructor : MethodCore, IMethodData {
                public ConstructorBuilder ConstructorBuilder;
                public ConstructorInitializer Initializer;
-               ListDictionary declarative_security;
+               Dictionary<SecurityAction, PermissionSet> declarative_security;
                bool has_compliant_args;
 
                // <summary>
@@ -4684,7 +4685,7 @@ namespace Mono.CSharp {
                {
                        if (a.IsValidSecurityAttribute ()) {
                                if (declarative_security == null) {
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
                                }
                                a.ExtractSecurityPermissionSet (declarative_security);
                                return;
@@ -4856,8 +4857,8 @@ namespace Mono.CSharp {
                                source.CloseMethod ();
 
                        if (declarative_security != null) {
-                               foreach (DictionaryEntry de in declarative_security) {
-                                       ConstructorBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
+                               foreach (var de in declarative_security) {
+                                       ConstructorBuilder.AddDeclarativeSecurity (de.Key, de.Value);
                                }
                        }
 
@@ -6049,7 +6050,7 @@ namespace Mono.CSharp {
        public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData {
                protected MethodData method_data;
                protected ToplevelBlock block;
-               protected ListDictionary declarative_security;
+               protected Dictionary<SecurityAction, PermissionSet> declarative_security;
 
                // The accessor are created even if they are not wanted.
                // But we need them because their names are reserved.
@@ -6148,7 +6149,7 @@ namespace Mono.CSharp {
 
                        if (a.IsValidSecurityAttribute ()) {
                                if (declarative_security == null)
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
                                a.ExtractSecurityPermissionSet (declarative_security);
                                return;
                        }
@@ -6208,8 +6209,8 @@ namespace Mono.CSharp {
                                OptAttributes.Emit ();
 
                        if (declarative_security != null) {
-                               foreach (DictionaryEntry de in declarative_security) {
-                                       method_data.MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
+                               foreach (var de in declarative_security) {
+                                       method_data.MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
                                }
                        }
 
index 202671c7c8d638e9636f470220f0c60b3ad72ec6..5f7d7bc512df61c813a181917eb4df7df442aa55 100644 (file)
@@ -20,7 +20,7 @@
 using System;
 using System.IO;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Globalization;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -436,7 +436,7 @@ namespace Mono.CSharp {
 
        public abstract class CommonAssemblyModulClass : Attributable, IMemberContext
        {
-               public void AddAttributes (ArrayList attrs, IMemberContext context)
+               public void AddAttributes (List<Attribute> attrs, IMemberContext context)
                {
                        foreach (Attribute a in attrs)
                                a.AttachTo (this, context);
@@ -526,11 +526,11 @@ namespace Mono.CSharp {
 
                public Attribute ClsCompliantAttribute;
 
-               ListDictionary declarative_security;
+               Dictionary<SecurityAction, PermissionSet> declarative_security;
                bool has_extension_method;              
                public AssemblyName Name;
                MethodInfo add_type_forwarder;
-               ListDictionary emitted_forwarders;
+               Dictionary<Type, Attribute> emitted_forwarders;
 
                // Module is here just because of error messages
                static string[] attribute_targets = new string [] { "assembly", "module" };
@@ -598,7 +598,7 @@ namespace Mono.CSharp {
                                g.AttachTo (this, this);
 
                                if (g.Resolve () != null) {
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
                                        g.ExtractSecurityPermissionSet (declarative_security);
                                }
                        }
@@ -827,7 +827,7 @@ namespace Mono.CSharp {
                {
                        if (a.IsValidSecurityAttribute ()) {
                                if (declarative_security == null)
-                                       declarative_security = new ListDictionary ();
+                                       declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
 
                                a.ExtractSecurityPermissionSet (declarative_security);
                                return;
@@ -869,9 +869,9 @@ namespace Mono.CSharp {
 
                                t = TypeManager.DropGenericTypeArguments (t);
                                if (emitted_forwarders == null) {
-                                       emitted_forwarders = new ListDictionary();
-                               } else if (emitted_forwarders.Contains(t)) {
-                                       Report.SymbolRelatedToPreviousError(((Attribute)emitted_forwarders[t]).Location, null);
+                                       emitted_forwarders = new Dictionary<Type, Attribute>  ();
+                               } else if (emitted_forwarders.ContainsKey (t)) {
+                                       Report.SymbolRelatedToPreviousError(emitted_forwarders[t].Location, null);
                                        Report.Error(739, a.Location, "A duplicate type forward of type `{0}'",
                                                TypeManager.CSharpName(t));
                                        return;
@@ -949,9 +949,10 @@ namespace Mono.CSharp {
                                                builder_instance = fi.GetValue (Builder);
                                        }
 
-                                       object[] args = new object [] { declarative_security [SecurityAction.RequestMinimum],
-                                                                                                 declarative_security [SecurityAction.RequestOptional],
-                                                                                                 declarative_security [SecurityAction.RequestRefuse] };
+                                       var args = new PermissionSet [3];
+                                       declarative_security.TryGetValue (SecurityAction.RequestMinimum, out args [0]);
+                                       declarative_security.TryGetValue (SecurityAction.RequestOptional, out args [1]);
+                                       declarative_security.TryGetValue (SecurityAction.RequestRefuse, out args [2]);
                                        add_permission.Invoke (builder_instance, args);
                                }
                                catch {
index c00c43b4bb259a77d63daf42ebbcdc3e3e65c3a7..e84823e8b7a506f9a07ec4e47646489ad7e32db7 100644 (file)
 using System.Text;
 using System.IO;
 using System;
+using System.Collections;
+using System.Collections.Generic;
 
 namespace Mono.CSharp
 {
-       using System.Collections;
-
        /// <summary>
        ///    The C# Parser
        /// </summary>
@@ -669,7 +669,7 @@ attribute_sections
        : attribute_section
          {
                if (current_attr_target != String.Empty) {
-                       ArrayList sect = (ArrayList) $1;
+                       var sect = (List<Attribute>) $1;
 
                        if (global_attrs_enabled) {
                                if (current_attr_target == "module") {
@@ -700,7 +700,7 @@ attribute_sections
          {
                if (current_attr_target != String.Empty) {
                        Attributes attrs = $1 as Attributes;
-                       ArrayList sect = (ArrayList) $2;
+                       var sect = (List<Attribute>) $2;
 
                        if (global_attrs_enabled) {
                                if (current_attr_target == "module") {
@@ -766,12 +766,12 @@ attribute_target
 attribute_list
        : attribute
          {
-               $$ = new ArrayList (4) { $1 };
+               $$ = new List<Attribute> (4) { (Attribute) $1 };
          }
        | attribute_list COMMA attribute
          {
-               ArrayList attrs = (ArrayList) $1;
-               attrs.Add ($3);
+               var attrs = (List<Attribute>) $1;
+               attrs.Add ((Attribute) $3);
 
                $$ = attrs;
          }
@@ -3486,7 +3486,7 @@ anonymous_type_expression
                else if (RootContext.Version <= LanguageVersion.ISO_2)
                        Report.FeatureIsNotAvailable (GetLocation ($1), "anonymous types");
 
-               $$ = new NewAnonymousType ((ArrayList) $3, current_container, GetLocation ($1));
+               $$ = new NewAnonymousType ((List<AnonymousTypeParameter>) $3, current_container, GetLocation ($1));
          }
        ;
 
@@ -3503,14 +3503,14 @@ anonymous_type_parameters_opt
 anonymous_type_parameters
        : anonymous_type_parameter
          {
-               ArrayList a = new ArrayList (4);
-               a.Add ($1);
+               var a = new List<AnonymousTypeParameter> (4);
+               a.Add ((AnonymousTypeParameter) $1);
                $$ = a;
          }
        | anonymous_type_parameters COMMA anonymous_type_parameter
          {
-               ArrayList a = (ArrayList) $1;
-               a.Add ($3);
+               var a = (List<AnonymousTypeParameter>) $1;
+               a.Add ((AnonymousTypeParameter) $3);
                $$ = a;
          }
        ;
@@ -3540,8 +3540,9 @@ anonymous_type_parameter
          }
        | error
          {
-               Report.Error (746, lexer.Location, "Invalid anonymous type member declarator. " +
-               "Anonymous type members must be a member assignment, simple name or member access expression");
+               Report.Error (746, lexer.Location,
+                       "Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression");
+               $$ = null;
          }
        ;
 
index ce616923b6cfcc4f7ddf87d4b727a063b746cf07..11e0d326950723ab895f5146187499855d2c4241 100644 (file)
@@ -1951,9 +1951,9 @@ namespace Mono.CSharp
 
                        if (arg.StartsWith (w_restore)) {
                                int[] codes = ParseNumbers (arg.Substring (w_restore.Length));
-                               Hashtable w_table = Report.warning_ignore_table;
+                               var w_table = Report.warning_ignore_table;
                                foreach (int code in codes) {
-                                       if (w_table != null && w_table.Contains (code))
+                                       if (w_table != null && w_table.ContainsKey (code))
                                                Report.Warning (1635, 1, Location, "Cannot restore warning `CS{0:0000}' because it was disabled globally", code);
                                        Report.RegisterWarningRegion (Location).WarningEnable (Location, code, Report);
                                }
index 986990c423245e571515557bc2355ba21592d651..b8307a3b7975f03bb5fcfd94cc7a6b93043de54c 100644 (file)
@@ -12,7 +12,7 @@
 
 using System;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.IO;
 using System.Reflection;
 using System.Reflection.Emit;
index 5de50f09a159365dfaf64bd0d2c681ec07fbc812..844ce2f1ca0cb81aea7b3046b05d88d364078f39 100644 (file)
@@ -17,7 +17,7 @@ namespace Mono.CSharp
        using System.Reflection;
        using System.Reflection.Emit;
        using System.Collections;
-       using System.Collections.Specialized;
+       using System.Collections.Generic;
        using System.IO;
        using System.Text;
        using System.Globalization;
@@ -39,27 +39,27 @@ namespace Mono.CSharp
                //
                // Assemblies references to be linked.   Initialized with
                // mscorlib.dll here.
-               ArrayList references;
+               List<string> references;
 
                //
                // If any of these fail, we ignore the problem.  This is so
                // that we can list all the assemblies in Windows and not fail
                // if they are missing on Linux.
                //
-               ArrayList soft_references;
+               List<string> soft_references;
 
                // 
                // External aliases for assemblies.
                //
-               Hashtable external_aliases;
+               Dictionary<string, string> external_aliases;
 
                //
                // Modules to be linked
                //
-               ArrayList modules;
+               List<string> modules;
 
                // Lookup paths
-               static ArrayList link_paths;
+               List<string> link_paths;
 
                // Whether we want to only run the tokenizer
                bool tokenize;
@@ -483,8 +483,8 @@ namespace Mono.CSharp
                        foreach (string r in references)
                                LoadAssembly (r, false);
 
-                       foreach (DictionaryEntry entry in external_aliases)
-                               LoadAssembly ((string) entry.Value, (string) entry.Key, false);
+                       foreach (var entry in external_aliases)
+                               LoadAssembly (entry.Value, entry.Key, false);
                                
                        GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
                }
@@ -588,11 +588,11 @@ namespace Mono.CSharp
 
                bool ParseArguments (string[] args, bool require_files)
                {
-                       references = new ArrayList ();
-                       external_aliases = new Hashtable ();
-                       soft_references = new ArrayList ();
-                       modules = new ArrayList (2);
-                       link_paths = new ArrayList ();
+                       references = new List<string> ();
+                       external_aliases = new Dictionary<string, string> ();
+                       soft_references = new List<string> ();
+                       modules = new List<string> (2);
+                       link_paths = new List<string> ();
 
                        ArrayList response_file_list = null;
                        bool parsing_options = true;
@@ -691,12 +691,12 @@ namespace Mono.CSharp
                {
                        Location.Initialize ();
 
-                       ArrayList cu = Location.SourceFiles;
+                       var cu = Location.SourceFiles;
                        for (int i = 0; i < cu.Count; ++i) {
                                if (tokenize) {
-                                       tokenize_file ((CompilationUnit) cu [i], ctx);
+                                       tokenize_file (cu [i], ctx);
                                } else {
-                                       Parse ((CompilationUnit) cu [i]);
+                                       Parse (cu [i]);
                                }
                        }
                }
@@ -1937,7 +1937,7 @@ namespace Mono.CSharp
                }
 
 
-               IDictionary embedded_resources = new HybridDictionary ();
+               Dictionary<string, IResource> embedded_resources = new Dictionary<string, IResource> ();
                readonly CompilerContext ctx;
 
                public Resources (CompilerContext ctx)
@@ -1952,7 +1952,7 @@ namespace Mono.CSharp
 
                public void Add (bool embeded, string file, string name, bool isPrivate)
                {
-                       if (embedded_resources.Contains (name)) {
+                       if (embedded_resources.ContainsKey (name)) {
                                ctx.Report.Error (1508, "The resource identifier `{0}' has already been used in this assembly", name);
                                return;
                        }
index 75801c617e42aa4e22b4c5e39b8230e658bd7589..aeabce500c74d5ef932d897f6f7fe0edc045a3f2 100644 (file)
@@ -13,7 +13,7 @@
 
 using System;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Globalization;
index 8b4f747cc70ea2c4ba300f20571e9d6a07d7a212..9e6aafa230e545927719a4fafd8e89b4b4c91365 100644 (file)
@@ -9777,13 +9777,13 @@ namespace Mono.CSharp {
 
        public class NewAnonymousType : New
        {
-               static readonly ArrayList EmptyParameters = new ArrayList (0);
+               static readonly IList<AnonymousTypeParameter> EmptyParameters = Array.AsReadOnly (new AnonymousTypeParameter[0]);
 
-               ArrayList parameters;
+               List<AnonymousTypeParameter> parameters;
                readonly TypeContainer parent;
                AnonymousTypeClass anonymous_type;
 
-               public NewAnonymousType (ArrayList parameters, TypeContainer parent, Location loc)
+               public NewAnonymousType (List<AnonymousTypeParameter> parameters, TypeContainer parent, Location loc)
                         : base (null, null, loc)
                {
                        this.parameters = parameters;
@@ -9796,12 +9796,12 @@ namespace Mono.CSharp {
                                return;
 
                        NewAnonymousType t = (NewAnonymousType) target;
-                       t.parameters = new ArrayList (parameters.Count);
+                       t.parameters = new List<AnonymousTypeParameter> (parameters.Count);
                        foreach (AnonymousTypeParameter atp in parameters)
-                               t.parameters.Add (atp.Clone (clonectx));
+                               t.parameters.Add ((AnonymousTypeParameter) atp.Clone (clonectx));
                }
 
-               AnonymousTypeClass CreateAnonymousType (ResolveContext ec, ArrayList parameters)
+               AnonymousTypeClass CreateAnonymousType (ResolveContext ec, IList<AnonymousTypeParameter> parameters)
                {
                        AnonymousTypeClass type = parent.Module.Compiled.GetAnonymousType (parameters);
                        if (type != null)
index 3697ef0fe0010bc8775517f7bf386dbf2f63ac03..a4b427e482b8231432c6052aff4b40383cab8c4d 100644 (file)
@@ -10,7 +10,7 @@
 
 using System;
 using System.Reflection;
-using System.Collections;
+using System.Collections.Generic;
 
 namespace Mono.CSharp.Linq
 {
@@ -253,7 +253,7 @@ namespace Mono.CSharp.Linq
 
                protected static Expression CreateRangeVariableType (ToplevelBlock block, IMemberContext context, SimpleMemberName name, Expression init)
                {
-                       ArrayList args = new ArrayList (2);
+                       var args = new List<AnonymousTypeParameter> (2);
                        args.Add (new AnonymousTypeParameter (block.Parameters [0]));
                        args.Add (new RangeAnonymousTypeParameter (init, name));
                        return new NewAnonymousType (args, context.CurrentTypeDefinition, name.Location);
index dbc700b2618f4f8c5df6b572521d7dd0f5b7b249..9565345bf8d9652e213be9287bc6f66efbdc54ef 100644 (file)
@@ -11,7 +11,7 @@
 
 using System;
 using System.IO;
-using System.Collections;
+using System.Collections.Generic;
 using Mono.CompilerServices.SymbolWriter;
 
 namespace Mono.CSharp {
@@ -75,8 +75,8 @@ namespace Mono.CSharp {
        public class CompilationUnit : SourceFile, ICompileUnit
        {
                CompileUnitEntry comp_unit;
-               Hashtable include_files;
-               Hashtable conditionals;
+               Dictionary<string, SourceFile> include_files;
+               Dictionary<string, bool> conditionals;
 
                public CompilationUnit (string name, string path, int index)
                        : base (name, path, index, false)
@@ -88,16 +88,16 @@ namespace Mono.CSharp {
                                return;
                        
                        if (include_files == null)
-                               include_files = new Hashtable ();
+                               include_files = new Dictionary<string, SourceFile> ();
 
-                       if (!include_files.Contains (file.Path))
+                       if (!include_files.ContainsKey (file.Path))
                                include_files.Add (file.Path, file);
                }
 
                public void AddDefine (string value)
                {
                        if (conditionals == null)
-                               conditionals = new Hashtable (2);
+                               conditionals = new Dictionary<string, bool> (2);
 
                        conditionals [value] = true;
                }
@@ -105,9 +105,9 @@ namespace Mono.CSharp {
                public void AddUndefine (string value)
                {
                        if (conditionals == null)
-                               conditionals = new Hashtable (2);
+                               conditionals = new Dictionary<string, bool> (2);
 
-                       conditionals [value] = null;
+                       conditionals [value] = false;
                }
 
                CompileUnitEntry ICompileUnit.Entry {
@@ -135,12 +135,12 @@ namespace Mono.CSharp {
                public bool IsConditionalDefined (string value)
                {
                        if (conditionals != null) {
-                               object res = conditionals [value];
-                               if (res != null)
-                                       return (bool)res;
+                               bool res;
+                               if (conditionals.TryGetValue (value, out res))
+                                       return res;
                                
                                // When conditional was undefined
-                               if (conditionals.Contains (value))
+                               if (conditionals.ContainsKey (value))
                                        return false;                                   
                        }
 
@@ -180,9 +180,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               static ArrayList source_list;
-               static ArrayList compile_units;
-               static Hashtable source_files;
+               static List<SourceFile> source_list;
+               static List<CompilationUnit> compile_units;
+               static Dictionary<string, int> source_files;
                static int checkpoint_bits;
                static int source_count;
                static int current_source;
@@ -199,19 +199,15 @@ namespace Mono.CSharp {
                
                static Location ()
                {
-                       source_files = new Hashtable ();
-                       source_list = new ArrayList ();
-                       compile_units = new ArrayList ();
-                       current_source = 0;
-                       current_compile_unit = 0;
+                       Reset ();
                        checkpoints = new Checkpoint [10];
                }
 
                public static void Reset ()
                {
-                       source_files = new Hashtable ();
-                       source_list = new ArrayList ();
-                       compile_units = new ArrayList ();
+                       source_files = new Dictionary<string, int> ();
+                       source_list = new List<SourceFile> ();
+                       compile_units = new List<CompilationUnit> ();
                        current_source = 0;
                        current_compile_unit = 0;
                        source_count = 0;
@@ -223,10 +219,9 @@ namespace Mono.CSharp {
                static public void AddFile (Report r, string name)
                {
                        string path = Path.GetFullPath (name);
-
-                       if (source_files.Contains (path)){
-                               int id = (int) source_files [path];
-                               string other_name = ((SourceFile) source_list [id - 1]).Name;
+                       int id;
+                       if (source_files.TryGetValue (path, out id)){
+                               string other_name = source_list [id - 1].Name;
                                if (name.Equals (other_name))
                                        r.Warning (2002, 1, "Source file `{0}' specified multiple times", other_name);
                                else
@@ -240,8 +235,7 @@ namespace Mono.CSharp {
                        compile_units.Add (unit);
                }
 
-               // IList<CompilationUnit>
-               static public ArrayList SourceFiles {
+               public static IList<CompilationUnit> SourceFiles {
                        get {
                                return compile_units;
                        }
@@ -279,7 +273,7 @@ namespace Mono.CSharp {
                        } else
                                path = name;
 
-                       if (!source_files.Contains (path)) {
+                       if (!source_files.ContainsKey (path)) {
                                if (source_count >= (1 << checkpoint_bits))
                                        return new SourceFile (name, path, 0, true);
 
index f1e3cfd23bb5bb1244c852dfb80419693f5c94bb..2e3fb5ed13e210e85fb5e7c977eec657cc15f3dc 100644 (file)
@@ -10,7 +10,7 @@
 //
 using System;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 using System.Reflection;
 
 namespace Mono.CSharp {
@@ -26,7 +26,7 @@ namespace Mono.CSharp {
                protected readonly string alias_name;
                protected Assembly [] referenced_assemblies;
 
-               Hashtable all_namespaces;
+               Dictionary<string, Namespace> all_namespaces;
 
                static RootNamespace ()
                {
@@ -39,7 +39,7 @@ namespace Mono.CSharp {
                        this.alias_name = alias_name;
                        referenced_assemblies = new Assembly [0];
 
-                       all_namespaces = new Hashtable ();
+                       all_namespaces = new Dictionary<string, Namespace> ();
                        all_namespaces.Add ("", this);
                }
 
@@ -147,7 +147,7 @@ namespace Mono.CSharp {
 
                public bool IsNamespace (string name)
                {
-                       return all_namespaces.Contains (name);
+                       return all_namespaces.ContainsKey (name);
                }
 
                protected void RegisterNamespace (string dotted_name)
@@ -159,7 +159,12 @@ namespace Mono.CSharp {
                void RegisterExtensionMethodClass (Type t)
                {
                        string n = t.Namespace;
-                       Namespace ns = n == null ? GlobalRootNamespace.Instance : (Namespace) all_namespaces[n];
+                       Namespace ns = null;
+                       if (n == null)
+                               ns = GlobalRootNamespace.Instance;
+                       else
+                               all_namespaces.TryGetValue (n, out ns);
+
                        if (ns == null)
                                ns = GetNamespace (n, true);
  
@@ -228,14 +233,14 @@ namespace Mono.CSharp {
 
        public class GlobalRootNamespace : RootNamespace {
                Module [] modules;
-               ListDictionary root_namespaces;
+               Dictionary<string, RootNamespace> root_namespaces;
 
                public static GlobalRootNamespace Instance = new GlobalRootNamespace ();
 
                GlobalRootNamespace ()
                        : base ("global")
                {
-                       root_namespaces = new ListDictionary ();
+                       root_namespaces = new Dictionary<string, RootNamespace> ();
                        root_namespaces.Add (alias_name, this);
                }
 
@@ -306,7 +311,11 @@ namespace Mono.CSharp {
 
                public RootNamespace GetRootNamespace (string name)
                {
-                       return (RootNamespace) root_namespaces[name];
+                       RootNamespace rn;
+                       if (!root_namespaces.TryGetValue (name, out rn))
+                               return null;
+
+                       return rn;
                }
 
                public override Type LookupTypeReflection (CompilerContext ctx, string name, Location loc, bool must_be_unique)
@@ -351,8 +360,8 @@ namespace Mono.CSharp {
                
                Namespace parent;
                string fullname;
-               IDictionary namespaces;
-               IDictionary declspaces;
+               Dictionary<string, Namespace> namespaces;
+               Dictionary<string, DeclSpace> declspaces;
                Hashtable cached_types;
                RootNamespace root;
                ArrayList external_exmethod_classes;
@@ -398,7 +407,7 @@ namespace Mono.CSharp {
                        else
                                MemberName = new MemberName (name);
 
-                       namespaces = new HybridDictionary ();
+                       namespaces = new Dictionary<string, Namespace> ();
                        cached_types = new Hashtable ();
 
                        root.RegisterNamespace (this);
@@ -453,8 +462,7 @@ namespace Mono.CSharp {
                        else
                                first = name;
 
-                       ns = (Namespace) namespaces [first];
-                       if (ns == null) {
+                       if (!namespaces.TryGetValue (first, out ns)) {
                                if (!create)
                                        return null;
 
@@ -480,8 +488,8 @@ namespace Mono.CSharp {
 
                        Type t = null;
                        if (declspaces != null) {
-                               DeclSpace tdecl = declspaces [name] as DeclSpace;
-                               if (tdecl != null) {
+                               DeclSpace tdecl;
+                               if (declspaces.TryGetValue (name, out tdecl)) {
                                        //
                                        // Note that this is not:
                                        //
@@ -526,19 +534,19 @@ namespace Mono.CSharp {
 
                        typeName = SimpleName.RemoveGenericArity (typeName);
 
-                       foreach (DictionaryEntry de in declspaces) {
-                               string type_item = (string) de.Key;
+                       foreach (var de in declspaces) {
+                               string type_item = de.Key;
                                int pos = type_item.LastIndexOf ('`');
                                if (pos == typeName.Length && String.Compare (typeName, 0, type_item, 0, pos) == 0)
-                                       return ((DeclSpace) de.Value).TypeBuilder;
+                                       return de.Value.TypeBuilder;
                        }
                        return null;
                }
 
                public FullNamedExpression Lookup (CompilerContext ctx, string name, Location loc)
                {
-                       if (namespaces.Contains (name))
-                               return (Namespace) namespaces [name];
+                       if (namespaces.ContainsKey (name))
+                               return namespaces [name];
 
                        return LookupType (ctx, name, loc);
                }
@@ -644,7 +652,7 @@ namespace Mono.CSharp {
                public void AddDeclSpace (string name, DeclSpace ds)
                {
                        if (declspaces == null)
-                               declspaces = new HybridDictionary ();
+                               declspaces = new Dictionary<string, DeclSpace> ();
                        declspaces.Add (name, ds);
                }
 
index 045cef29348aed6299c0afd4fb9829b903748bf0..e2aed9a1cf31e5fd7bebe0deb14a21c3dfbf6624 100644 (file)
@@ -11,7 +11,7 @@
 //
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 
@@ -87,9 +87,9 @@ namespace Mono.CSharp {
                //   bases that we must implement.  Notice that this `flattens' the
                //   method search space, and takes into account overrides.  
                // </remarks>
-               static ArrayList GetAbstractMethods (Type t)
+               static IList<MethodBase> GetAbstractMethods (Type t)
                {
-                       ArrayList list = null;
+                       List<MethodBase> list = null;
                        bool searching = true;
                        Type current_type = t;
                        
@@ -133,7 +133,7 @@ namespace Mono.CSharp {
                        return list;
                }
 
-               PendingImplementation (TypeContainer container, MissingInterfacesInfo [] missing_ifaces, ArrayList abstract_methods, int total)
+               PendingImplementation (TypeContainer container, MissingInterfacesInfo[] missing_ifaces, IList<MethodBase> abstract_methods, int total)
                {
                        TypeBuilder type_builder = container.TypeBuilder;
                        
@@ -299,7 +299,7 @@ namespace Mono.CSharp {
                        // We also pre-compute the methods.
                        //
                        bool implementing_abstract = ((b != null) && b.IsAbstract && !type_builder.IsAbstract);
-                       ArrayList abstract_methods = null;
+                       IList<MethodBase> abstract_methods = null;
 
                        if (implementing_abstract){
                                abstract_methods = GetAbstractMethods (b);
index 66e9446e998c7d462858cabda8114053dfc572a0..63a1fab8e5b4936918dd3369aac27524ba5b3e17 100644 (file)
@@ -10,7 +10,7 @@
 using System;
 using System.IO;
 using System.Text;
-using System.Collections;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -30,17 +30,17 @@ namespace Mono.CSharp {
                ///   Whether warnings should be considered errors
                /// </summary>
                public bool WarningsAreErrors;
-               ArrayList warnings_as_error;
-               ArrayList warnings_only;
+               List<int> warnings_as_error;
+               List<int> warnings_only;
 
                public static int DebugFlags = 0;
 
                //
                // Keeps track of the warnings that we are ignoring
                //
-               public Hashtable warning_ignore_table;
+               public Dictionary<int, bool> warning_ignore_table;
 
-               Hashtable warning_regions_table;
+               Dictionary<string, WarningRegions> warning_regions_table;
 
                int warning_level;
 
@@ -51,7 +51,7 @@ namespace Mono.CSharp {
                /// <summary>
                /// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
                /// </summary>
-               ArrayList extra_information = new ArrayList ();
+               List<string> extra_information = new List<string> ();
 
                // 
                // IF YOU ADD A NEW WARNING YOU HAVE TO ADD ITS ID HERE
@@ -139,7 +139,7 @@ namespace Mono.CSharp {
                                return false;
 
                        if (warning_ignore_table != null) {
-                               if (warning_ignore_table.Contains (code)) {
+                               if (warning_ignore_table.ContainsKey (code)) {
                                        return false;
                                }
                        }
@@ -147,8 +147,8 @@ namespace Mono.CSharp {
                        if (warning_regions_table == null || loc.IsNull)
                                return true;
 
-                       WarningRegions regions = (WarningRegions) warning_regions_table [loc.Name];
-                       if (regions == null)
+                       WarningRegions regions;
+                       if (!warning_regions_table.TryGetValue (loc.Name, out regions))
                                return true;
 
                        return regions.IsWarningEnabled (code, loc.Row);
@@ -267,7 +267,7 @@ namespace Mono.CSharp {
                                return;
 
                        if (warnings_as_error == null)
-                               warnings_as_error = new ArrayList ();
+                               warnings_as_error = new List<int> ();
                        
                        warnings_as_error.Add (id);
                }
@@ -285,7 +285,7 @@ namespace Mono.CSharp {
                                return;
 
                        if (warnings_only == null)
-                               warnings_only = new ArrayList ();
+                               warnings_only = new List<int> ();
 
                        warnings_only.Add (id);
                }
@@ -311,14 +311,19 @@ namespace Mono.CSharp {
 
                public WarningRegions RegisterWarningRegion (Location location)
                {
-                       if (warning_regions_table == null)
-                               warning_regions_table = new Hashtable ();
+                       WarningRegions regions;
+                       if (warning_regions_table == null) {
+                               regions = null;
+                               warning_regions_table = new Dictionary<string, WarningRegions> ();
+                       } else {
+                               warning_regions_table.TryGetValue (location.Name, out regions);
+                       }
 
-                       WarningRegions regions = (WarningRegions)warning_regions_table [location.Name];
                        if (regions == null) {
                                regions = new WarningRegions ();
                                warning_regions_table.Add (location.Name, regions);
                        }
+
                        return regions;
                }
 
@@ -445,7 +450,7 @@ namespace Mono.CSharp {
                public void SetIgnoreWarning (int code)
                {
                        if (warning_ignore_table == null)
-                               warning_ignore_table = new Hashtable ();
+                               warning_ignore_table = new Dictionary<int, bool> ();
 
                        warning_ignore_table [code] = true;
                }
@@ -491,8 +496,8 @@ namespace Mono.CSharp {
                                                sb.Append (", ");
                                        if (arg == null)
                                                sb.Append ("null");
-                                       else if (arg is ICollection)
-                                               sb.Append (PrintCollection ((ICollection) arg));
+//                                     else if (arg is ICollection)
+//                                             sb.Append (PrintCollection ((ICollection) arg));
                                        else
                                                sb.Append (arg);
                                }
@@ -500,7 +505,7 @@ namespace Mono.CSharp {
 
                        Console.WriteLine (sb.ToString ());
                }
-
+/*
                static public string PrintCollection (ICollection collection)
                {
                        StringBuilder sb = new StringBuilder ();
@@ -520,6 +525,7 @@ namespace Mono.CSharp {
                        sb.Append (")");
                        return sb.ToString ();
                }
+*/ 
        }
 
        public abstract class AbstractMessage
@@ -529,7 +535,7 @@ namespace Mono.CSharp {
                protected readonly Location location;
                readonly string message;
 
-               protected AbstractMessage (int code, Location loc, string msg, ArrayList extraInfo)
+               protected AbstractMessage (int code, Location loc, string msg, List<string> extraInfo)
                {
                        this.code = code;
                        if (code < 0)
@@ -538,7 +544,7 @@ namespace Mono.CSharp {
                        this.location = loc;
                        this.message = msg;
                        if (extraInfo.Count != 0) {
-                               this.extra_info = (string[])extraInfo.ToArray (typeof (string));
+                               this.extra_info = extraInfo.ToArray ();
                        }
                }
 
@@ -587,7 +593,7 @@ namespace Mono.CSharp {
 
        sealed class WarningMessage : AbstractMessage
        {
-               public WarningMessage (int code, Location loc, string message, ArrayList extra_info)
+               public WarningMessage (int code, Location loc, string message, List<string> extra_info)
                        : base (code, loc, message, extra_info)
                {
                }
@@ -605,7 +611,7 @@ namespace Mono.CSharp {
 
        sealed class ErrorMessage : AbstractMessage
        {
-               public ErrorMessage (int code, Location loc, string message, ArrayList extraInfo)
+               public ErrorMessage (int code, Location loc, string message, List<string> extraInfo)
                        : base (code, loc, message, extraInfo)
                {
                }
@@ -698,16 +704,16 @@ namespace Mono.CSharp {
        //
        class SessionReportPrinter : ReportPrinter
        {
-               ArrayList session_messages;
+               List<AbstractMessage> session_messages;
                //
                // A collection of exactly same messages reported in all sessions
                //
-               ArrayList common_messages;
+               List<AbstractMessage> common_messages;
 
                //
                // A collection of unique messages reported in all sessions
                //
-               ArrayList merged_messages;
+               List<AbstractMessage> merged_messages;
 
                public override void Print (AbstractMessage msg)
                {
@@ -717,7 +723,7 @@ namespace Mono.CSharp {
                        // Console.WriteLine ("RECORDING: {0} {1} {2}", code, location, message);
 
                        if (session_messages == null)
-                               session_messages = new ArrayList ();
+                               session_messages = new List<AbstractMessage> ();
 
                        session_messages.Add (msg);
 
@@ -733,7 +739,7 @@ namespace Mono.CSharp {
                        // Handles the first session
                        //
                        if (common_messages == null) {
-                               common_messages = new ArrayList (session_messages);
+                               common_messages = new List<AbstractMessage> (session_messages);
                                merged_messages = session_messages;
                                session_messages = null;
                                return;
@@ -785,7 +791,7 @@ namespace Mono.CSharp {
                //
                public bool Merge (ReportPrinter dest)
                {
-                       ArrayList messages_to_print = merged_messages;
+                       var messages_to_print = merged_messages;
                        if (common_messages != null && common_messages.Count > 0) {
                                messages_to_print = common_messages;
                        }
@@ -1166,7 +1172,7 @@ namespace Mono.CSharp {
                }
 
 
-               ArrayList regions = new ArrayList ();
+               List<PragmaCmd> regions = new List<PragmaCmd> ();
 
                public void WarningDisable (int line)
                {
index 287943898b97f16fdfa71fa34f978bac07492364..6db750a4b159dcffaa8926158f443015d704a5b5 100644 (file)
@@ -12,7 +12,7 @@
 // Copyright 2004-2008 Novell, Inc
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Diagnostics;
@@ -114,7 +114,7 @@ namespace Mono.CSharp {
                // This hashtable contains all of the #definitions across the source code
                // it is used by the ConditionalAttribute handler.
                //
-               static ArrayList AllDefines;
+               static List<string> AllDefines;
                
                //
                // This keeps track of the order in which classes were defined
@@ -125,13 +125,13 @@ namespace Mono.CSharp {
                // or abstract as well as the parent names (to implement new, 
                // override).
                //
-               static ArrayList type_container_resolve_order;
+               static List<TypeContainer> type_container_resolve_order;
 
                //
                // Holds a reference to the Private Implementation Details
                // class.
                //
-               static ArrayList helper_classes;
+               static List<TypeBuilder> helper_classes;
                
                static TypeBuilder impl_details_class;
 
@@ -153,7 +153,7 @@ namespace Mono.CSharp {
                        if (full)
                                root = null;
                        
-                       type_container_resolve_order = new ArrayList ();
+                       type_container_resolve_order = new List<TypeContainer> ();
                        EntryPoint = null;
                        Checked = false;
                        Unsafe = false;
@@ -179,7 +179,7 @@ namespace Mono.CSharp {
                        //
                        // Setup default defines
                        //
-                       AllDefines = new ArrayList ();
+                       AllDefines = new List<string> ();
                        AddConditional ("__MonoCS__");
                }
 
@@ -290,7 +290,7 @@ namespace Mono.CSharp {
                public static void RegisterCompilerGeneratedType (TypeBuilder helper_class)
                {
                        if (helper_classes == null)
-                               helper_classes = new ArrayList ();
+                               helper_classes = new List<TypeBuilder> ();
 
                        helper_classes.Add (helper_class);
                }
@@ -338,7 +338,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       ArrayList delegates = root.Delegates;
+                       var delegates = root.Delegates;
                        if (delegates != null){
                                foreach (Delegate d in delegates)
                                        d.Define ();
@@ -348,7 +348,7 @@ namespace Mono.CSharp {
                        // Check for cycles in the struct layout
                        //
                        if (type_container_resolve_order != null){
-                               Hashtable seen = new Hashtable ();
+                               var seen = new Dictionary<TypeContainer, object> ();
                                foreach (TypeContainer tc in type_container_resolve_order)
                                        TypeManager.CheckStructCycles (tc, seen);
                        }
index 0c9b6b23e7793a0f8ee41ffdf223fede16d977bf..17b63c55fe52445061052a4d00f62b6598ad80af 100644 (file)
@@ -11,7 +11,7 @@
 //
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.InteropServices;
@@ -55,8 +55,7 @@ namespace Mono.CSharp
        //
        public class ModuleCompiled : ModuleContainer
        {
-               // TODO: It'd be so nice to have generics
-               Hashtable anonymous_types;
+               Dictionary<int, List<AnonymousTypeClass>> anonymous_types;
                readonly bool is_unsafe;
                readonly CompilerContext context;
 
@@ -72,8 +71,8 @@ namespace Mono.CSharp
                        this.is_unsafe = isUnsafe;
                        this.context = context;
 
-                       types = new ArrayList ();
-                       anonymous_types = new Hashtable ();
+                       types = new MemberCoreArrayList ();
+                       anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
                }
 
                public override AttributeTargets AttributeTargets {
@@ -84,15 +83,17 @@ namespace Mono.CSharp
 
                public void AddAnonymousType (AnonymousTypeClass type)
                {
-                       ArrayList existing = (ArrayList)anonymous_types [type.Parameters.Count];
+                       List<AnonymousTypeClass> existing;
+                       if (!anonymous_types.TryGetValue (type.Parameters.Count, out existing))
                        if (existing == null) {
-                               existing = new ArrayList ();
+                               existing = new List<AnonymousTypeClass> ();
                                anonymous_types.Add (type.Parameters.Count, existing);
                        }
+
                        existing.Add (type);
                }
 
-               public void AddAttributes (ArrayList attrs)
+               public void AddAttributes (List<Attribute> attrs)
                {
                        foreach (Attribute a in attrs)
                                a.AttachTo (this, CodeGen.Assembly);
@@ -155,10 +156,10 @@ namespace Mono.CSharp
                        }
                }
 
-               public AnonymousTypeClass GetAnonymousType (ArrayList parameters)
+               public AnonymousTypeClass GetAnonymousType (IList<AnonymousTypeParameter> parameters)
                {
-                       ArrayList candidates = (ArrayList) anonymous_types [parameters.Count];
-                       if (candidates == null)
+                       List<AnonymousTypeClass> candidates;
+                       if (!anonymous_types.TryGetValue (parameters.Count, out candidates))
                                return null;
 
                        int i;
index d5589ad1a5926566e6c2dbe45cb474f6b9a9ede4..9dc0f93bdac3d77c1cb399df0160421f829cc2a0 100644 (file)
@@ -16,7 +16,7 @@ using System.Reflection;
 using System.Reflection.Emit;
 using System.Diagnostics;
 using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
 
 namespace Mono.CSharp {
        
@@ -1442,7 +1442,7 @@ namespace Mono.CSharp {
                //
                // The statements in this block
                //
-               protected ArrayList statements;
+               protected List<Statement> statements;
 
                //
                // An array of Blocks.  We keep track of children just
@@ -1451,35 +1451,35 @@ namespace Mono.CSharp {
                // Statements and child statements are handled through the
                // statements.
                //
-               ArrayList children;
+               List<Block> children;
 
                //
                // Labels.  (label, block) pairs.
                //
-               protected HybridDictionary labels;
+               protected Dictionary<string, LabeledStatement> labels;
 
                //
                // Keeps track of (name, type) pairs
                //
-               IDictionary variables;
+               Dictionary<string, LocalInfo> variables;
 
                //
                // Keeps track of constants
-               HybridDictionary constants;
+               Dictionary<string, Expression> constants;
 
                //
                // Temporary variables.
                //
-               ArrayList temporary_variables;
+               List<LocalInfo> temporary_variables;
                
                //
                // If this is a switch section, the enclosing switch block.
                //
                Block switch_block;
 
-               protected ArrayList scope_initializers;
+               protected List<Statement> scope_initializers;
 
-               ArrayList anonymous_children;
+               List<ToplevelBlock> anonymous_children;
 
                protected static int id;
 
@@ -1531,7 +1531,7 @@ namespace Mono.CSharp {
                        this.EndLocation = end;
                        this.loc = start;
                        this_id = id++;
-                       statements = new ArrayList (4);
+                       statements = new List<Statement> (4);
                }
 
                public Block CreateSwitchBlock (Location start)
@@ -1546,10 +1546,10 @@ namespace Mono.CSharp {
                        get { return this_id; }
                }
 
-               public IDictionary Variables {
+               public IDictionary<string, LocalInfo> Variables {
                        get {
                                if (variables == null)
-                                       variables = new ListDictionary ();
+                                       variables = new Dictionary<string, LocalInfo> ();
                                return variables;
                        }
                }
@@ -1557,7 +1557,7 @@ namespace Mono.CSharp {
                void AddChild (Block b)
                {
                        if (children == null)
-                               children = new ArrayList (1);
+                               children = new List<Block> (1);
                        
                        children.Add (b);
                }
@@ -1628,7 +1628,7 @@ namespace Mono.CSharp {
                        Toplevel.CheckError158 (name, target.loc);
 
                        if (labels == null)
-                               labels = new HybridDictionary();
+                               labels = new Dictionary<string, LabeledStatement> ();
 
                        labels.Add (name, target);
                        return true;
@@ -1661,8 +1661,8 @@ namespace Mono.CSharp {
                                return switch_block.LookupLabel (name);
 
                        if (labels != null)
-                               if (labels.Contains (name))
-                                       return ((LabeledStatement) labels [name]);
+                               if (labels.ContainsKey (name))
+                                       return labels [name];
 
                        return null;
                }
@@ -1824,7 +1824,7 @@ namespace Mono.CSharp {
                                return false;
                        
                        if (constants == null)
-                               constants = new HybridDictionary();
+                               constants = new Dictionary<string, Expression> ();
 
                        constants.Add (name, value);
 
@@ -1840,7 +1840,7 @@ namespace Mono.CSharp {
                        Report.Debug (64, "ADD TEMPORARY", this, Toplevel, loc);
 
                        if (temporary_variables == null)
-                               temporary_variables = new ArrayList ();
+                               temporary_variables = new List<LocalInfo> ();
 
                        int id = ++next_temp_id;
                        string name = "$s_" + id.ToString ();
@@ -1856,8 +1856,7 @@ namespace Mono.CSharp {
                        LocalInfo ret;
                        for (Block b = this; b != null; b = b.Parent) {
                                if (b.variables != null) {
-                                       ret = (LocalInfo) b.variables [name];
-                                       if (ret != null)
+                                       if (b.variables.TryGetValue (name, out ret))
                                                return ret;
                                }
                        }
@@ -1873,10 +1872,10 @@ namespace Mono.CSharp {
 
                public Expression GetConstantExpression (string name)
                {
+                       Expression ret;
                        for (Block b = this; b != null; b = b.Parent) {
                                if (b.constants != null) {
-                                       Expression ret = b.constants [name] as Expression;
-                                       if (ret != null)
+                                       if (b.constants.TryGetValue (name, out ret))
                                                return ret;
                                }
                        }
@@ -1890,7 +1889,7 @@ namespace Mono.CSharp {
                public void AddScopeStatement (Statement s)
                {
                        if (scope_initializers == null)
-                               scope_initializers = new ArrayList ();
+                               scope_initializers = new List<Statement> ();
 
                        scope_initializers.Add (s);
                }
@@ -1923,14 +1922,14 @@ namespace Mono.CSharp {
                        }
                }
 
-               public ArrayList AnonymousChildren {
+               public IList<ToplevelBlock> AnonymousChildren {
                        get { return anonymous_children; }
                }
 
                public void AddAnonymousChild (ToplevelBlock b)
                {
                        if (anonymous_children == null)
-                               anonymous_children = new ArrayList ();
+                               anonymous_children = new List<ToplevelBlock> ();
 
                        anonymous_children.Add (b);
                }
@@ -1943,9 +1942,9 @@ namespace Mono.CSharp {
                        if (variables == null)
                                throw new InternalErrorException ("cannot happen");
 
-                       foreach (DictionaryEntry de in variables) {
-                               string name = (string) de.Key;
-                               LocalInfo vi = (LocalInfo) de.Value;
+                       foreach (var de in variables) {
+                               string name = de.Key;
+                               LocalInfo vi = de.Value;
                                Type variable_type = vi.VariableType;
 
                                if (variable_type == null) {
@@ -1955,8 +1954,8 @@ namespace Mono.CSharp {
                                        continue;
                                }
 
-                               Expression cv = (Expression) constants [name];
-                               if (cv == null)
+                               Expression cv;
+                               if (!constants.TryGetValue (name, out cv))
                                        continue;
 
                                // Don't let 'const int Foo = Foo;' succeed.
@@ -2051,11 +2050,11 @@ namespace Mono.CSharp {
                        if (variables == null || ec.Report.WarningLevel < 3)
                                return;
 
-                       foreach (DictionaryEntry de in variables) {
-                               LocalInfo vi = (LocalInfo) de.Value;
+                       foreach (var de in variables) {
+                               LocalInfo vi = de.Value;
 
                                if (!vi.Used) {
-                                       string name = (string) de.Key;
+                                       string name = de.Key;
 
                                        // vi.VariableInfo can be null for 'catch' variables
                                        if (vi.VariableInfo != null && vi.VariableInfo.IsEverAssigned)
@@ -2304,21 +2303,21 @@ namespace Mono.CSharp {
                                target.Parent = clonectx.RemapBlockCopy (Parent);
 
                        if (variables != null){
-                               target.variables = new Hashtable ();
+                               target.variables = new Dictionary<string, LocalInfo> ();
 
-                               foreach (DictionaryEntry de in variables){
-                                       LocalInfo newlocal = ((LocalInfo) de.Value).Clone (clonectx);
+                               foreach (var de in variables){
+                                       LocalInfo newlocal = de.Value.Clone (clonectx);
                                        target.variables [de.Key] = newlocal;
-                                       clonectx.AddVariableMap ((LocalInfo) de.Value, newlocal);
+                                       clonectx.AddVariableMap (de.Value, newlocal);
                                }
                        }
 
-                       target.statements = new ArrayList (statements.Count);
+                       target.statements = new List<Statement> (statements.Count);
                        foreach (Statement s in statements)
                                target.statements.Add (s.Clone (clonectx));
 
                        if (target.children != null){
-                               target.children = new ArrayList (children.Count);
+                               target.children = new List<Block> (children.Count);
                                foreach (Block b in children){
                                        target.children.Add (clonectx.LookupBlock (b));
                                }
@@ -2330,8 +2329,9 @@ namespace Mono.CSharp {
                }
        }
 
-       public class ExplicitBlock : Block {
-               HybridDictionary known_variables;
+       public class ExplicitBlock : Block
+       {
+               Dictionary<string, IKnownVariable> known_variables;
                protected AnonymousMethodStorey am_storey;
 
                public ExplicitBlock (Block parent, Location start, Location end)
@@ -2353,7 +2353,7 @@ namespace Mono.CSharp {
                internal void AddKnownVariable (string name, IKnownVariable info)
                {
                        if (known_variables == null)
-                               known_variables = new HybridDictionary();
+                               known_variables = new Dictionary<string, IKnownVariable> ();
 
                        known_variables [name] = info;
 
@@ -2465,7 +2465,14 @@ namespace Mono.CSharp {
 
                internal IKnownVariable GetKnownVariable (string name)
                {
-                       return known_variables == null ? null : (IKnownVariable) known_variables [name];
+                       if (known_variables == null)
+                               return null;
+
+                       IKnownVariable kw;
+                       if (!known_variables.TryGetValue (name, out kw))
+                               return null;
+
+                       return kw;
                }
 
                public bool HasCapturedThis
@@ -2736,7 +2743,7 @@ namespace Mono.CSharp {
                        // Creates block with original statements
                        AddStatement (new IteratorStatement (iterator, new Block (this, source)));
 
-                       source.statements = new ArrayList (1);
+                       source.statements = new List<Statement> (1);
                        source.AddStatement (new Return (iterator, iterator.Location));
                        source.IsIterator = false;
 
@@ -3264,9 +3271,7 @@ namespace Mono.CSharp {
                bool CheckSwitch (ResolveContext ec)
                {
                        bool error = false;
-                       Elements = Sections.Count > 10 ? 
-                               (IDictionary)new Hashtable () : 
-                               (IDictionary)new ListDictionary ();
+                       Elements = new Dictionary<object, SwitchLabel> ();
                                
                        foreach (SwitchSection ss in Sections){
                                foreach (SwitchLabel sl in ss.Labels){
index 458d03ad7130c036fb6cb9db43c60867b5592fb5..bd400a2fbf6aeb3deddf6a3af2712665f8cd75ba 100644 (file)
@@ -1891,14 +1891,14 @@ namespace Mono.CSharp {
                return (EventField) events [ei];
        }
 
-       public static bool CheckStructCycles (TypeContainer tc, Hashtable seen)
+       public static bool CheckStructCycles (TypeContainer tc, Dictionary<TypeContainer, object> seen)
        {
-               Hashtable hash = new Hashtable ();
+               var hash = new Dictionary<TypeContainer, object> ();
                return CheckStructCycles (tc, seen, hash);
        }
 
-       public static bool CheckStructCycles (TypeContainer tc, Hashtable seen,
-                                             Hashtable hash)
+       public static bool CheckStructCycles (TypeContainer tc, Dictionary<TypeContainer, object> seen,
+                                                 Dictionary<TypeContainer, object> hash)
        {
                if ((tc.Kind != Kind.Struct) || IsBuiltinType (tc.TypeBuilder))
                        return true;
@@ -1906,7 +1906,7 @@ namespace Mono.CSharp {
                //
                // `seen' contains all types we've already visited.
                //
-               if (seen.Contains (tc))
+               if (seen.ContainsKey (tc))
                        return true;
                seen.Add (tc, null);
 
@@ -1922,7 +1922,7 @@ namespace Mono.CSharp {
                        if (ftc == null)
                                continue;
 
-                       if (hash.Contains (ftc)) {
+                       if (hash.ContainsKey (ftc)) {
                                tc.Compiler.Report.Error (523, tc.Location,
                                              "Struct member `{0}.{1}' of type `{2}' " +
                                              "causes a cycle in the struct layout",
@@ -1942,7 +1942,7 @@ namespace Mono.CSharp {
                        if (!ok)
                                return false;
 
-                       if (!seen.Contains (ftc))
+                       if (!seen.ContainsKey (ftc))
                                seen.Add (ftc, null);
                }
 
@@ -2432,19 +2432,19 @@ namespace Mono.CSharp {
        //
        // The name is assumed to be the same.
        //
-       public static ArrayList CopyNewMethods (ArrayList target_list, IList new_members)
+       public static List<MethodBase> CopyNewMethods (List<MethodBase> target_list, IList new_members)
        {
                if (target_list == null){
-                       target_list = new ArrayList ();
+                       target_list = new List<MethodBase> ();
 
                        foreach (MemberInfo mi in new_members){
                                if (mi is MethodBase)
-                                       target_list.Add (mi);
+                                       target_list.Add ((MethodBase) mi);
                        }
                        return target_list;
                }
-               
-               MemberInfo [] target_array = new MemberInfo [target_list.Count];
+
+               MethodBase[] target_array = new MethodBase[target_list.Count];
                target_list.CopyTo (target_array, 0);
                
                foreach (MemberInfo mi in new_members){
@@ -2927,7 +2927,7 @@ namespace Mono.CSharp {
        {
                BindingFlags bf = original_bf;
                
-               ArrayList method_list = null;
+               List<MethodBase> method_list = null;
                Type current_type = queried_type;
                bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
                bool skip_iface_check = true, used_cache = false;
@@ -3054,7 +3054,7 @@ namespace Mono.CSharp {
                        return first_members_list;
 
                if (method_list != null && method_list.Count > 0) {
-                       return (MemberInfo []) method_list.ToArray (typeof (MemberInfo));
+                       return method_list.ToArray ();
                }
                //
                // This happens if we already used the cache in the first iteration, in this case