2009-12-08 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Tue, 8 Dec 2009 12:23:58 +0000 (12:23 -0000)
committerMarek Safar <marek.safar@gmail.com>
Tue, 8 Dec 2009 12:23:58 +0000 (12:23 -0000)
*.cs: Moving to generics world.

cs-parser.jay: Removed current_array_type.

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

17 files changed:
mcs/mcs/ChangeLog
mcs/mcs/argument.cs
mcs/mcs/class.cs
mcs/mcs/complete.cs
mcs/mcs/cs-parser.jay
mcs/mcs/decl.cs
mcs/mcs/dynamic.cs
mcs/mcs/ecore.cs
mcs/mcs/eval.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs
mcs/mcs/namespace.cs
mcs/mcs/parameter.cs
mcs/mcs/statement.cs
mcs/mcs/support.cs
mcs/mcs/symbolwriter.cs
mcs/mcs/typemanager.cs

index 8c5c238e49c0fd6e38f0f147ecf817a2fe8cca94..45bb8ab351fb71c67256ed175b06289eeffc16f0 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-08  Marek Safar  <marek.safar@gmail.com>
+
+       *.cs: Moving to generics world.
+
+       cs-parser.jay: Removed current_array_type.
+
 2009-12-07  Marek Safar  <marek.safar@gmail.com>
 
        *.cs: Moving to generics world.
index 53d08b7e20e98709214282b6218273b28871ee29..0942a7ce46b4275da9783c250c546ad2d1bb12e4 100644 (file)
@@ -12,7 +12,6 @@
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
-using System.Collections;
 using System.Collections.Generic;
 
 namespace Mono.CSharp
@@ -224,10 +223,10 @@ namespace Mono.CSharp
                        this.args.AddRange (args.args);
                }
 
-               public ArrayList CreateDynamicBinderArguments (ResolveContext rc)
+               public ArrayInitializer CreateDynamicBinderArguments (ResolveContext rc)
                {
-                       var all = new ArrayList (args.Count);
                        Location loc = Location.Null;
+                       var all = new ArrayInitializer (args.Count, loc);
 
                        MemberAccess binder = DynamicExpressionStatement.GetBinderNamespace (loc);
 
index a8f6844fdf8635613f07a3dbb79f9d674f3805c1..2560b1b7cd069b895d922be265aae57b68fd737d 100644 (file)
@@ -12,7 +12,6 @@
 //
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -172,7 +171,7 @@ namespace Mono.CSharp {
                List<MemberCore> operators;
 
                // Holds the compiler generated classes
-               ArrayList compiler_generated;
+               List<CompilerGeneratedClass> compiler_generated;
 
                //
                // Pointers to the default constructor and the default static constructor
@@ -505,7 +504,7 @@ namespace Mono.CSharp {
                        Report.Debug (64, "ADD COMPILER GENERATED CLASS", this, c);
 
                        if (compiler_generated == null)
-                               compiler_generated = new ArrayList ();
+                               compiler_generated = new List<CompilerGeneratedClass> ();
 
                        compiler_generated.Add (c);
                }
@@ -807,7 +806,7 @@ namespace Mono.CSharp {
 
                TypeExpr[] GetNormalPartialBases (ref TypeExpr base_class)
                {
-                       ArrayList ifaces = new ArrayList (0);
+                       var ifaces = new List<TypeExpr> (0);
                        if (iface_exprs != null)
                                ifaces.AddRange (iface_exprs);
 
@@ -843,7 +842,7 @@ namespace Mono.CSharp {
                        if (ifaces.Count == 0)
                                return null;
 
-                       return (TypeExpr[])ifaces.ToArray (typeof (TypeExpr));
+                       return ifaces.ToArray ();
                }
 
                //
@@ -919,7 +918,7 @@ namespace Mono.CSharp {
 
                bool CheckGenericInterfaces (Type[] ifaces)
                {
-                       ArrayList already_checked = new ArrayList ();
+                       var already_checked = new List<Type> ();
 
                        for (int i = 0; i < ifaces.Length; i++) {
                                Type iface = ifaces [i];
@@ -1431,7 +1430,7 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               protected virtual void DefineContainerMembers (IList mcal) // IList<MemberCore>
+               protected virtual void DefineContainerMembers (System.Collections.IList mcal) // IList<MemberCore>
                {
                        if (mcal != null) {
                                foreach (MemberCore mc in mcal) {
@@ -1531,7 +1530,7 @@ namespace Mono.CSharp {
 
                public MethodInfo[] GetMethods ()
                {
-                       ArrayList members = new ArrayList ();
+                       var members = new List<MethodInfo> ();
 
                        Define ();
 
@@ -1589,9 +1588,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       MethodInfo[] retMethods = new MethodInfo [members.Count];
-                       members.CopyTo (retMethods, 0);
-                       return retMethods;
+                       return members.ToArray ();
                }
                
                // Indicated whether container has StructLayout attribute set Explicit
@@ -2382,10 +2379,10 @@ namespace Mono.CSharp {
                /// </summary>
                void VerifyClsName ()
                {
-                       Hashtable base_members = base_cache == null ? 
-                               new Hashtable () :
+                       Dictionary<string, object> base_members = base_cache == null ?
+                               new Dictionary<string, object> () :
                                base_cache.GetPublicMembers ();
-                       Hashtable this_members = new Hashtable ();
+                       var this_members = new Dictionary<string, object> ();
 
                        foreach (var entry in defined_names) {
                                MemberCore mc = entry.Value;
@@ -2396,10 +2393,9 @@ namespace Mono.CSharp {
                                string basename = name.Substring (name.LastIndexOf ('.') + 1);
 
                                string lcase = basename.ToLower (System.Globalization.CultureInfo.InvariantCulture);
-                               object found = base_members [lcase];
-                               if (found == null) {
-                                       found = this_members [lcase];
-                                       if (found == null) {
+                               object found;
+                               if (!base_members.TryGetValue (lcase, out found)) {
+                                       if (!this_members.TryGetValue (lcase, out found)) {
                                                this_members.Add (lcase, mc);
                                                continue;
                                        }
@@ -2687,7 +2683,7 @@ namespace Mono.CSharp {
                                while (top_level.Parent != null)
                                        top_level = top_level.Parent;
 
-                               ArrayList candidates = NamespaceEntry.NS.LookupExtensionMethod (extensionType, this, name);
+                               var candidates = NamespaceEntry.NS.LookupExtensionMethod (extensionType, this, name);
                                if (candidates != null)
                                        return new ExtensionMethodGroupExpr (candidates, NamespaceEntry, extensionType, loc);
                        }
@@ -2777,7 +2773,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               protected override void DefineContainerMembers (IList list)
+               protected override void DefineContainerMembers (System.Collections.IList list)
                {
                        if (list == null)
                                return;
@@ -4459,7 +4455,7 @@ namespace Mono.CSharp {
                                return false;
 
                        if (!Parameters.IsEmpty) {
-                               ArrayList al = (ArrayList)Parent.PartialContainer.MemberCache.Members [Name];
+                               var al = Parent.PartialContainer.MemberCache.Members [Name];
                                if (al.Count > 1)
                                        MemberCache.VerifyClsParameterConflict (al, this, MethodBuilder, Report);
                        }
@@ -4862,7 +4858,7 @@ namespace Mono.CSharp {
                        }
                        
                        if (!Parameters.IsEmpty) {
-                               ArrayList al = (ArrayList)Parent.MemberCache.Members [ConstructorInfo.ConstructorName];
+                               var al = Parent.MemberCache.Members [ConstructorInfo.ConstructorName];
                                if (al.Count > 2)
                                        MemberCache.VerifyClsParameterConflict (al, this, ConstructorBuilder, Report);
  
index 3cb68acb0a32884e7985e3d53cd0ecc61d8667c5..ed55d57fd75a03a292b55e1274f153056153384f 100644 (file)
@@ -15,7 +15,7 @@
 //
 namespace Mono.CSharp {
        using System;
-       using System.Collections;
+       using System.Collections.Generic;
        using System.Reflection;
        using System.Reflection.Emit;
        using System.Text;
@@ -50,7 +50,7 @@ namespace Mono.CSharp {
                        this.Prefix = prefix;
                }
 
-               public static void AppendResults (ArrayList results, string prefix, IEnumerable names)
+               public static void AppendResults (List<string> results, string prefix, IEnumerable<string> names)
                {
                        foreach (string name in names){
                                if (name == null)
@@ -72,13 +72,13 @@ namespace Mono.CSharp {
                
                protected override Expression DoResolve (ResolveContext ec)
                {
-                       ArrayList results = new ArrayList ();
+                       var results = new List<string> ();
 
                        AppendResults (results, Prefix, Evaluator.GetVarNames ());
                        AppendResults (results, Prefix, ec.CurrentTypeDefinition.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
                        AppendResults (results, Prefix, Evaluator.GetUsingList ());
                        
-                       throw new CompletionResult (Prefix, (string []) results.ToArray (typeof (string)));
+                       throw new CompletionResult (Prefix, results.ToArray ());
                }
 
                protected override void CloneTo (CloneContext clonectx, Expression t)
@@ -151,7 +151,7 @@ namespace Mono.CSharp {
                                        return null;
                        }
 
-                       ArrayList results = new ArrayList ();
+                       var results = new List<string> ();
                        if (expr_resolved is Namespace){
                                Namespace nexpr = expr_resolved as Namespace;
                                string namespaced_partial;
@@ -195,7 +195,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       throw new CompletionResult (partial_name == null ? "" : partial_name, (string []) results.ToArray (typeof (string)));
+                       throw new CompletionResult (partial_name == null ? "" : partial_name, results.ToArray ());
                }
 
                protected override void CloneTo (CloneContext clonectx, Expression t)
index 0b17197afe2dd4e4aadb21d92b0bd4022f0b42fd..6cfe93ef61b824dcead128806576e243451f4829 100644 (file)
 //       great spot to put an `error' because you can reproduce it with this input:
 //      "public X { }"
 //
-// Possible optimization:
-//   Run memory profiler with parsing only, and consider dropping 
-//   arraylists where not needed.   Some pieces can use linked lists.
-
 
 using System.Text;
 using System.IO;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 
 namespace Mono.CSharp
@@ -79,12 +74,6 @@ namespace Mono.CSharp
                FullNamedExpression implicit_value_parameter_type;
                ParametersCompiled indexer_parameters;
 
-               /// <summary>
-               ///   Hack to help create non-typed array initializer
-               /// </summary>
-               public static FullNamedExpression current_array_type;
-               FullNamedExpression pushed_current_array_type;
-
                /// <summary>
                ///   Used to determine if we are parsing the get/set pair
                ///   of an indexer or a property
@@ -96,12 +85,12 @@ namespace Mono.CSharp
                ///
                /// An out-of-band stack.
                ///
-               static Stack oob_stack;
+               static Stack<object> oob_stack;
 
                ///
                /// Switch stack.
                ///
-               Stack switch_stack;
+               Stack<Block> switch_stack;
 
                ///
                /// Controls the verbosity of the errors produced by the parser
@@ -146,8 +135,7 @@ namespace Mono.CSharp
                //
                public Undo undo;
                
-               // Stack<ToplevelBlock>
-               Stack linq_clause_blocks;
+               Stack<Block> linq_clause_blocks;
 
                // A counter to create new class names in interactive mode
                static int class_count;
@@ -159,8 +147,8 @@ namespace Mono.CSharp
                // share the bucket for very common constructs which can never
                // be recursive
                //
-               static ArrayList parameters_bucket = new ArrayList (6);
-               static ArrayList variables_bucket = new ArrayList (6);
+               static List<Parameter> parameters_bucket = new List<Parameter> (6);
+               static List<object> variables_bucket = new List<object> (6);
 %}
 
 %token EOF
@@ -1018,7 +1006,7 @@ constant_declaration
          SEMICOLON
          {
                int modflags = (int) $2;
-               foreach (VariableDeclaration constant in (ArrayList) $5){
+               foreach (VariableDeclaration constant in (List<object>) $5){
                        Location l = constant.Location;
                        if ((modflags & Modifiers.STATIC) != 0) {
                                Report.Error (504, l, "The constant `{0}' cannot be marked static", current_container.GetSignatureForError () + "." + (string) constant.identifier);
@@ -1027,7 +1015,7 @@ constant_declaration
 
                        Const c = new Const (
                                current_class, (FullNamedExpression) $4, (string) constant.identifier, 
-                               (Expression) constant.expression_or_array_initializer, modflags, 
+                               constant.GetInitializer ((FullNamedExpression) $4), modflags, 
                                (Attributes) $1, l);
 
                        if (RootContext.Documentation != null) {
@@ -1050,7 +1038,7 @@ constant_declarators
        | constant_declarators COMMA constant_declarator
          {
                if ($3 != null) {
-                       ArrayList constants = (ArrayList) $1;
+                       var constants = (List<object>) $1;
                        constants.Add ($3);
                }
          }
@@ -1064,7 +1052,7 @@ constant_declarator
          constant_initializer
          {
                --lexer.parsing_block;
-               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, $4);
+               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, (Expression) $4);
          }
        | IDENTIFIER
          {
@@ -1092,12 +1080,10 @@ field_declaration
                
                int mod = (int) $2;
 
-               current_array_type = null;
-
-               foreach (VariableMemberDeclaration var in (ArrayList) $4){
+               foreach (VariableMemberDeclaration var in (List<object>) $4){
                        Field field = new Field (current_class, type, mod, var.MemberName, (Attributes) $1);
 
-                       field.Initializer = var.expression_or_array_initializer;
+                       field.Initializer = var.GetInitializer (type);
 
                        if (RootContext.Documentation != null) {
                                field.DocComment = Lexer.consume_doc_comment ();
@@ -1118,11 +1104,9 @@ field_declaration
                        
                        int mod = (int) $2;
 
-                       current_array_type = null;
-
-                       foreach (VariableDeclaration var in (ArrayList) $5) {
+                       foreach (VariableDeclaration var in (List<VariableDeclaration>) $5) {
                                FixedField field = new FixedField (current_class, type, mod, var.identifier,
-                                       (Expression)var.expression_or_array_initializer, (Attributes) $1, var.Location);
+                                       var.GetInitializer (type), (Attributes) $1, var.Location);
 
                                if (RootContext.Documentation != null) {
                                        field.DocComment = Lexer.consume_doc_comment ();
@@ -1145,14 +1129,14 @@ field_declaration
 fixed_variable_declarators
        : fixed_variable_declarator
          {
-               ArrayList decl = new ArrayList (2);
-               decl.Add ($1);
+               var decl = new List<VariableDeclaration> (2);
+               decl.Add ((VariableDeclaration)$1);
                $$ = decl;
          }
        | fixed_variable_declarators COMMA fixed_variable_declarator
          {
-               ArrayList decls = (ArrayList) $1;
-               decls.Add ($3);
+               var decls = (List<VariableDeclaration>) $1;
+               decls.Add ((VariableDeclaration)$3);
                $$ = $1;
          }
        ;
@@ -1160,7 +1144,7 @@ fixed_variable_declarators
 fixed_variable_declarator
        : IDENTIFIER OPEN_BRACKET expression CLOSE_BRACKET
          {
-               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, $3);
+               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, (Expression) $3);
          }
        | IDENTIFIER OPEN_BRACKET CLOSE_BRACKET
          {
@@ -1180,7 +1164,7 @@ local_variable_declarators
          }
        | local_variable_declarators COMMA local_variable_declarator
          {
-               ArrayList decls = (ArrayList) $1;
+               var decls = (List<object>) $1;
                decls.Add ($3);
                $$ = $1;
          }
@@ -1189,7 +1173,7 @@ local_variable_declarators
 local_variable_declarator
        : IDENTIFIER ASSIGN local_variable_initializer
          {
-               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, $3);
+               $$ = new VariableDeclaration ((Tokenizer.LocatedToken) $1, (Expression) $3);
          }
        | IDENTIFIER
          {
@@ -1229,7 +1213,7 @@ variable_declarators
          }
        | variable_declarators COMMA variable_declarator
          {
-               ArrayList decls = (ArrayList) $1;
+               var decls = (List<object>) $1;
                decls.Add ($3);
                $$ = $1;
          }
@@ -1244,7 +1228,7 @@ variable_declarator
          variable_initializer
          {
                --lexer.parsing_block;
-               $$ = new VariableMemberDeclaration ((MemberName) $1, $4);
+               $$ = new VariableMemberDeclaration ((MemberName) $1, (Expression) $4);
          }
        | member_declaration_name
          {
@@ -1433,32 +1417,21 @@ opt_formal_parameter_list
 formal_parameter_list
        : fixed_parameters
          { 
-               ArrayList pars_list = (ArrayList) $1;
-
-               Parameter [] pars = new Parameter [pars_list.Count];
-               pars_list.CopyTo (pars);
-
-               $$ = new ParametersCompiled (compiler, pars); 
+               var pars_list = (List<Parameter>) $1;
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray ());
          } 
        | fixed_parameters COMMA parameter_array
          {
-               ArrayList pars_list = (ArrayList) $1;
-               pars_list.Add ($3);
+               var pars_list = (List<Parameter>) $1;
+               pars_list.Add ((Parameter) $3);
 
-               Parameter [] pars = new Parameter [pars_list.Count];
-               pars_list.CopyTo (pars);
-
-               $$ = new ParametersCompiled (compiler, pars); 
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray ()); 
          }
        | fixed_parameters COMMA arglist_modifier
          {
-               ArrayList pars_list = (ArrayList) $1;
+               var pars_list = (List<Parameter>) $1;
                pars_list.Add (new ArglistParameter (GetLocation ($3)));
-
-               Parameter [] pars = new Parameter [pars_list.Count];
-               pars_list.CopyTo (pars);
-
-               $$ = new ParametersCompiled (compiler, pars, true);
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray (), true);
          }
        | parameter_array COMMA error
          {
@@ -1471,14 +1444,11 @@ formal_parameter_list
          {
                if ($3 != null)
                        Report.Error (231, ((Parameter) $3).Location, "A params parameter must be the last parameter in a formal parameter list");
-                       
-               ArrayList pars_list = (ArrayList) $1;
-               pars_list.Add (new ArglistParameter (GetLocation ($3)));
 
-               Parameter [] pars = new Parameter [pars_list.Count];
-               pars_list.CopyTo (pars);
+               var pars_list = (List<Parameter>) $1;
+               pars_list.Add (new ArglistParameter (GetLocation ($3)));
 
-               $$ = new ParametersCompiled (compiler, pars, true);
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray (), true);
          }
        | arglist_modifier COMMA error
          {
@@ -1489,14 +1459,11 @@ formal_parameter_list
        | fixed_parameters COMMA ARGLIST COMMA error 
          {
                Report.Error (257, GetLocation ($3), "An __arglist parameter must be the last parameter in a formal parameter list");
-               
-               ArrayList pars_list = (ArrayList) $1;
-               pars_list.Add (new ArglistParameter (GetLocation ($3)));
 
-               Parameter [] pars = new Parameter [pars_list.Count];
-               pars_list.CopyTo (pars);
+               var pars_list = (List<Parameter>) $1;
+               pars_list.Add (new ArglistParameter (GetLocation ($3)));
 
-               $$ = new ParametersCompiled (compiler, pars, true);
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray (), true);
          }
        | parameter_array 
          {
@@ -1520,7 +1487,7 @@ fixed_parameters
          }
        | fixed_parameters COMMA fixed_parameter
          {
-               ArrayList pars = (ArrayList) $1;
+               var pars = (List<Parameter>) $1;
                Parameter p = (Parameter) $3;
                if (p != null) {
                        if (p.HasExtensionMethodModifier)
@@ -2273,18 +2240,14 @@ event_declaration
          opt_modifiers
          EVENT type variable_declarators SEMICOLON
          {
-               current_array_type = null;
-               foreach (VariableMemberDeclaration var in (ArrayList) $5) {
+               foreach (VariableMemberDeclaration var in (List<object>) $5) {
 
                        EventField e = new EventField (
                                current_class, (FullNamedExpression) $4, (int) $2, var.MemberName, (Attributes) $1);
                                
-                       if (var.expression_or_array_initializer != null) {
-                               if (current_container.Kind == Kind.Interface) {
-                                       Report.Error (68, e.Location, "`{0}': event in interface cannot have initializer", e.GetSignatureForError ());
-                               }
-
-                               e.Initializer = var.expression_or_array_initializer;
+                       e.Initializer = var.GetInitializer ((FullNamedExpression) $4);
+                       if (current_container.Kind == Kind.Interface && e.Initializer != null) {
+                               Report.Error (68, e.Location, "`{0}': event in interface cannot have initializer", e.GetSignatureForError ());
                        }
                        
                        if (var.MemberName.Left != null) {
@@ -2518,9 +2481,9 @@ enum_declaration
 
 
                EnumMember em = null;
-               foreach (VariableDeclaration ev in (ArrayList) $7) {
+               foreach (VariableDeclaration ev in (IList<VariableDeclaration>) $7) {
                        em = new EnumMember (
-                               e, em, ev.identifier, (Expression) ev.expression_or_array_initializer,
+                               e, em, ev.identifier, ev.GetInitializer ((FullNamedExpression) $5),
                                ev.OptAttributes, ev.Location);
 
 //                     if (RootContext.Documentation != null)
@@ -2581,24 +2544,21 @@ enum_body
        ;
 
 opt_enum_member_declarations
-       : /* empty */                   { $$ = new ArrayList (0); }
+       : /* empty */                   { $$ = new VariableDeclaration [0]; }
        | enum_member_declarations opt_comma { $$ = $1; }
        ;
 
 enum_member_declarations
        : enum_member_declaration 
          {
-               ArrayList l = new ArrayList (4);
-
-               l.Add ($1);
+               var l = new List<VariableDeclaration> (4);
+               l.Add ((VariableDeclaration) $1);
                $$ = l;
          }
        | enum_member_declarations COMMA enum_member_declaration
          {
-               ArrayList l = (ArrayList) $1;
-
-               l.Add ($3);
-
+               var l = (List<VariableDeclaration>) $1;
+               l.Add ((VariableDeclaration) $3);
                $$ = l;
          }
        ;
@@ -2628,7 +2588,7 @@ enum_member_declaration
          { 
                --lexer.parsing_block;    
                VariableDeclaration vd = new VariableDeclaration (
-                       (Tokenizer.LocatedToken) $2, $5, (Attributes) $1);
+                       (Tokenizer.LocatedToken) $2, (Expression) $5, (Attributes) $1);
 
                if (RootContext.Documentation != null)
                        vd.DocComment = ConsumeStoredComment ();
@@ -2925,7 +2885,7 @@ type_expression_or_array
        | type_expression rank_specifiers
          {
                string rank_specifiers = (string) $2;
-               $$ = current_array_type = new ComposedCast ((FullNamedExpression) $1, rank_specifiers);
+               $$ = new ComposedCast ((FullNamedExpression) $1, rank_specifiers);
          }
        ;
        
@@ -2938,7 +2898,7 @@ type_expression
                        $$ = new ComposedCast (name.GetTypeExpression (), "?", lexer.Location);
                } else {
                        if (name.Left == null && name.Name == "var")
-                               $$ = current_array_type = new VarExpr (name.Location);
+                               $$ = new VarExpr (name.Location);
                        else
                                $$ = name.GetTypeExpression ();
                }
@@ -3205,7 +3165,7 @@ member_initializer
          }
        | OPEN_BRACE expression_list CLOSE_BRACE
          {
-               $$ = new CollectionElementInitializer ((ArrayList)$2, GetLocation ($1));
+               $$ = new CollectionElementInitializer ((List<Expression>)$2, GetLocation ($1));
          }
        | OPEN_BRACE CLOSE_BRACE
          {
@@ -3338,22 +3298,20 @@ element_access
                        Error_ExpectingTypeName (expr);
                        $$ = TypeManager.system_object_expr;
                }
-               
-               current_array_type = (FullNamedExpression)$$;
          }
        ;
 
 expression_list
        : expression
          {
-               ArrayList list = new ArrayList (4);
-               list.Add ($1);
+               var list = new List<Expression> (4);
+               list.Add ((Expression) $1);
                $$ = list;
          }
        | expression_list COMMA expression
          {
-               ArrayList list = (ArrayList) $1;
-               list.Add ($3);
+               var list = (List<Expression>) $1;
+               list.Add ((Expression) $3);
                $$ = list;
          }
        ;
@@ -3445,21 +3403,21 @@ array_creation_expression
          opt_rank_specifier    // shift/reduce on OPEN_BRACE
          opt_array_initializer
          {
-               $$ = new ArrayCreation ((FullNamedExpression) $1, (ArrayList) $3, (string) $5, (ArrayList) $6, GetLocation ($1));
+               $$ = new ArrayCreation ((FullNamedExpression) $1, (List<Expression>) $3, (string) $5, (ArrayInitializer) $6, GetLocation ($1));
          }
        | new_expr_start rank_specifiers opt_array_initializer
          {
                if ($3 == null)
                        Report.Error (1586, GetLocation ($1), "Array creation must have array size or array initializer");
 
-               $$ = new ArrayCreation ((FullNamedExpression) $1, (string) $2, (ArrayList) $3, GetLocation ($1));
+               $$ = new ArrayCreation ((FullNamedExpression) $1, (string) $2, (ArrayInitializer) $3, GetLocation ($1));
          }
        | NEW rank_specifiers array_initializer
          {
                if (RootContext.Version <= LanguageVersion.ISO_2)
                        Report.FeatureIsNotAvailable (GetLocation ($1), "implicitly typed arrays");
          
-               $$ = new ImplicitlyTypedArrayCreation ((string) $2, (ArrayList) $3, GetLocation ($1));
+               $$ = new ImplicitlyTypedArrayCreation ((string) $2, (ArrayInitializer) $3, GetLocation ($1));
          }
        | new_expr_start error
          {
@@ -3625,38 +3583,37 @@ opt_array_initializer
 array_initializer
        : OPEN_BRACE CLOSE_BRACE
          {
-               $$ = new ArrayList (0);
+               $$ = new ArrayInitializer (0, GetLocation ($1));
          }
        | OPEN_BRACE variable_initializer_list opt_comma CLOSE_BRACE
          {
-               $$ = $2;
+               $$ = new ArrayInitializer ((List<Expression>) $2, GetLocation ($1));
          }
        ;
 
 variable_initializer_list
        : variable_initializer
          {
-               ArrayList list = new ArrayList (4);
-               list.Add ($1);
+               var list = new List<Expression> (4);
+               list.Add ((Expression) $1);
                $$ = list;
          }
        | variable_initializer_list COMMA variable_initializer
          {
-               ArrayList list = (ArrayList) $1;
-               list.Add ($3);
+               var list = (List<Expression>) $1;
+               list.Add ((Expression) $3);
                $$ = list;
          }
        | error
          {
                Error_SyntaxError (yyToken);
-               $$ = new ArrayList ();
+               $$ = new List<Expression> ();
          }
        ;
 
 typeof_expression
        : TYPEOF
       {
-               pushed_current_array_type = current_array_type;
                lexer.TypeOfParsing = true;
          }
          open_parens_any typeof_type_expression CLOSE_PARENS
@@ -3667,7 +3624,6 @@ typeof_expression
                        $$ = new TypeOfVoid (GetLocation ($1));
                else
                        $$ = new TypeOf (type, GetLocation ($1));
-               current_array_type = pushed_current_array_type;
          }
        ;
        
@@ -4088,14 +4044,14 @@ assignment_expression
 lambda_parameter_list
        : lambda_parameter
          {
-               ArrayList pars = new ArrayList (4);
-               pars.Add ($1);
+               var pars = new List<Parameter> (4);
+               pars.Add ((Parameter) $1);
 
                $$ = pars;
          }
        | lambda_parameter_list COMMA lambda_parameter
          {
-               ArrayList pars = (ArrayList) $1;
+               var pars = (List<Parameter>) $1;
                Parameter p = (Parameter)$3;
                if (pars[0].GetType () != p.GetType ()) {
                        Report.Error (748, p.Location, "All lambda parameters must be typed either explicitly or implicitly");
@@ -4129,8 +4085,8 @@ lambda_parameter
 opt_lambda_parameter_list
        : /* empty */                   { $$ = ParametersCompiled.EmptyReadOnlyParameters; }
        | lambda_parameter_list         { 
-               ArrayList pars_list = (ArrayList) $1;
-               $$ = new ParametersCompiled (compiler, (Parameter[])pars_list.ToArray (typeof (Parameter)));
+               var pars_list = (List<Parameter>) $1;
+               $$ = new ParametersCompiled (compiler, pars_list.ToArray ());
          }
        ;
 
@@ -4558,22 +4514,18 @@ labeled_statement
 declaration_statement
        : local_variable_declaration SEMICOLON
          {
-               current_array_type = null;
                if ($1 != null){
-                       DictionaryEntry de = (DictionaryEntry) $1;
-                       Expression e = (Expression) de.Key;
-
-                       $$ = declare_local_variables (e, (ArrayList) de.Value, e.Location);
+                       var de = (Tuple<FullNamedExpression, List<object>>) $1;
+                       $$ = declare_local_variables (de.Item1, de.Item2, de.Item1.Location);
                }
          }
 
        | local_constant_declaration SEMICOLON
          {
-               current_array_type = null;
                if ($1 != null){
-                       DictionaryEntry de = (DictionaryEntry) $1;
+                       var de = (Tuple<FullNamedExpression, List<object>>) $1;
 
-                       $$ = declare_local_constants ((Expression) de.Key, (ArrayList) de.Value);
+                       $$ = declare_local_constants (de.Item1, de.Item2);
                }
          }
        ;
@@ -4616,7 +4568,7 @@ variable_type
                        if (rank_or_nullable.Length == 0) {
                                SimpleName sn = expr as SimpleName;
                                if (sn != null && sn.Name == "var")
-                                       $$ = current_array_type = new VarExpr (sn.Location);
+                                       $$ = new VarExpr (sn.Location);
                                else
                                        $$ = $1;
                        } else {
@@ -4632,7 +4584,7 @@ variable_type
                if ((string) $2 == "")
                        $$ = $1;
                else
-                       $$ = current_array_type = new ComposedCast ((FullNamedExpression) $1, (string) $2, lexer.Location);
+                       $$ = new ComposedCast ((FullNamedExpression) $1, (string) $2, lexer.Location);
          }
        | VOID opt_rank_specifier
          {
@@ -4677,7 +4629,7 @@ local_variable_type
                        if (rank == "")
                                $$ = $1;
                        else
-                               $$ = current_array_type = new ComposedCast ((FullNamedExpression) $1, rank);
+                               $$ = new ComposedCast ((FullNamedExpression) $1, rank);
                } else {
                        $$ = null;
                }
@@ -4690,13 +4642,13 @@ local_variable_declaration
                if ($1 != null) {
                        VarExpr ve = $1 as VarExpr;
                        if (ve != null) {
-                               if (((VariableDeclaration)((ArrayList)$2) [0]).expression_or_array_initializer == null)
+                               if (!((VariableDeclaration) ((List<object>)$2) [0]).HasInitializer)
                                        ve.VariableInitializersCount = 0;
                                else
-                                       ve.VariableInitializersCount = ((ArrayList)$2).Count;
+                                       ve.VariableInitializersCount = ((List<object>)$2).Count;
                        }
                                
-                       $$ = new DictionaryEntry ($1, $2);
+                       $$ = new Tuple<FullNamedExpression, List<object>> ((FullNamedExpression) $1, (List<object>) $2);
                } else
                        $$ = null;
          }
@@ -4706,7 +4658,7 @@ local_constant_declaration
        : CONST variable_type constant_declarators
          {
                if ($2 != null)
-                       $$ = new DictionaryEntry ($2, $3);
+                       $$ = new Tuple<FullNamedExpression, List<object>> ((FullNamedExpression) $2, (List<object>) $3);
                else
                        $$ = null;
          }
@@ -4797,7 +4749,7 @@ switch_statement
        : SWITCH open_parens_any
          { 
                if (switch_stack == null)
-                       switch_stack = new Stack (2);
+                       switch_stack = new Stack<Block> (2);
                switch_stack.Push (current_block);
          }
          expression CLOSE_PARENS 
@@ -4914,13 +4866,12 @@ for_statement
                start_block (l);  
                Block assign_block = current_block;
 
-               if ($3 is DictionaryEntry){
-                       DictionaryEntry de = (DictionaryEntry) $3;
+               if ($3 is Tuple<FullNamedExpression, List<object>>){
+                       var de = (Tuple<FullNamedExpression, List<object>>) $3;
                        
-                       Expression type = (Expression) de.Key;
-                       ArrayList var_declarators = (ArrayList) de.Value;
+                       var type = de.Item1;
 
-                       foreach (VariableDeclaration decl in var_declarators){
+                       foreach (VariableDeclaration decl in de.Item2){
 
                                LocalInfo vi;
 
@@ -4928,7 +4879,7 @@ for_statement
                                if (vi == null)
                                        continue;
 
-                               Expression expr = decl.expression_or_array_initializer;
+                               Expression expr = decl.GetInitializer (type);
                                        
                                LocalVariableReference var;
                                var = new LocalVariableReference (assign_block, decl.identifier, l);
@@ -5196,20 +5147,17 @@ opt_identifier
 catch_clause 
        : CATCH opt_catch_args 
          {
-               Expression type = null;
-               
                if ($2 != null) {
-                       DictionaryEntry cc = (DictionaryEntry) $2;
-                       type = (Expression) cc.Key;
-                       var lt = (Tokenizer.LocatedToken) cc.Value;
+                       var cc = (Tuple<FullNamedExpression, Tokenizer.LocatedToken>) $2;
+                       var lt = cc.Item2;
 
                        if (lt != null){
-                               ArrayList one = new ArrayList (2);
+                               List<object> one = new List<object> (1);
 
                                one.Add (new VariableDeclaration (lt, null));
 
                                start_block (lexer.Location);
-                               current_block = declare_local_variables (type, one, lt.Location);
+                               current_block = declare_local_variables (cc.Item1, one, lt.Location);
                        }
                }
          } block {
@@ -5218,9 +5166,9 @@ catch_clause
                Block var_block = null;
 
                if ($2 != null){
-                       DictionaryEntry cc = (DictionaryEntry) $2;
-                       type = (Expression) cc.Key;
-                       var lt = (Tokenizer.LocatedToken) cc.Value;
+                       var cc = (Tuple<FullNamedExpression, Tokenizer.LocatedToken>) $2;
+                       type = cc.Item1;
+                       var lt = cc.Item2;
 
                        if (lt != null){
                                id = lt.Value;
@@ -5240,7 +5188,7 @@ opt_catch_args
 catch_args 
        : open_parens_any type opt_identifier CLOSE_PARENS 
          {
-               $$ = new DictionaryEntry ($2, $3);
+               $$ = new Tuple<FullNamedExpression, Tokenizer.LocatedToken> ((FullNamedExpression)$2, (Tokenizer.LocatedToken) $3);
          }
        | open_parens_any CLOSE_PARENS 
          {
@@ -5345,21 +5293,18 @@ using_statement
                start_block (lexer.Location);
                Block assign_block = current_block;
 
-               DictionaryEntry de = (DictionaryEntry) $3;
+               var de = (Tuple<FullNamedExpression, List<object>>) $3;
                Location l = GetLocation ($1);
 
-               Expression type = (Expression) de.Key;
-               ArrayList var_declarators = (ArrayList) de.Value;
+               var vars = new Stack<Tuple<LocalVariableReference, Expression>> ();
 
-               Stack vars = new Stack ();
-
-               foreach (VariableDeclaration decl in var_declarators) {
-                       LocalInfo vi = current_block.AddVariable (type, decl.identifier, decl.Location);
+               foreach (VariableDeclaration decl in de.Item2) {
+                       LocalInfo vi = current_block.AddVariable (de.Item1, decl.identifier, decl.Location);
                        if (vi == null)
                                continue;
                        vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Using);
 
-                       Expression expr = decl.expression_or_array_initializer;
+                       Expression expr = decl.GetInitializer (de.Item1);
                        if (expr == null) {
                                Report.Error (210, l, "You must provide an initializer in a fixed or using statement declaration");
                                continue;
@@ -5372,7 +5317,7 @@ using_statement
                        // This is so that it is not a warning on using variables
                        vi.Used = true;
 
-                       vars.Push (new DictionaryEntry (var, expr));
+                       vars.Push (new Tuple<LocalVariableReference, Expression> (var, expr));
 
                        // Assign a = new SimpleAssign (var, expr, decl.Location);
                        // assign_block.AddStatement (new StatementExpression (a));
@@ -5385,12 +5330,12 @@ using_statement
          embedded_statement
          {
                Statement stmt = (Statement) $6;
-               Stack vars = (Stack) $5;
+               var vars = (Stack<Tuple<LocalVariableReference, Expression>>) $5;
                Location l = GetLocation ($1);
 
                while (vars.Count > 0) {
-                         DictionaryEntry de = (DictionaryEntry) vars.Pop ();
-                         stmt = new Using ((Expression) de.Key, (Expression) de.Value, stmt, l);
+                         var de = vars.Pop ();
+                         stmt = new Using (de.Item1, de.Item2, stmt, l);
                }
                current_block.AddStatement (stmt);
                $$ = end_block (lexer.Location);
@@ -5533,7 +5478,7 @@ select_or_group_clause
        | GROUP
          {
                if (linq_clause_blocks == null)
-                       linq_clause_blocks = new Stack ();
+                       linq_clause_blocks = new Stack<Block> ();
                        
                current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
                linq_clause_blocks.Push (current_block);
@@ -5612,7 +5557,7 @@ join_clause
        : JOIN IDENTIFIER IN
          {
                if (linq_clause_blocks == null)
-                       linq_clause_blocks = new Stack ();
+                       linq_clause_blocks = new Stack<Block> ();
                        
                current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
                linq_clause_blocks.Push (current_block);
@@ -5664,7 +5609,7 @@ join_clause
        | JOIN type IDENTIFIER IN
          {
                if (linq_clause_blocks == null)
-                       linq_clause_blocks = new Stack ();
+                       linq_clause_blocks = new Stack<Block> ();
                        
                current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
                linq_clause_blocks.Push (current_block);
@@ -5907,42 +5852,54 @@ close_brace_or_complete_completion
 // </summary>
 class VariableDeclaration {
        public string identifier;
-       public Expression expression_or_array_initializer;
+       Expression initializer;
        public Location Location;
        public Attributes OptAttributes;
        public string DocComment;
 
-       public VariableDeclaration (Tokenizer.LocatedToken lt, object eoai, Attributes opt_attrs)
+       public VariableDeclaration (Tokenizer.LocatedToken lt, Expression initializer, Attributes opt_attrs)
        {
                this.identifier = lt.Value;
-               if (eoai is ArrayList) {
-                       this.expression_or_array_initializer = new ArrayCreation (CSharpParser.current_array_type, "", (ArrayList)eoai, lt.Location);
-               } else {
-                       this.expression_or_array_initializer = (Expression)eoai;
-               }
+               this.initializer = initializer;
                this.Location = lt.Location;
                this.OptAttributes = opt_attrs;
        }
 
-       public VariableDeclaration (Tokenizer.LocatedToken lt, object eoai) : this (lt, eoai, null)
+       public VariableDeclaration (Tokenizer.LocatedToken lt, Expression initializer)
+               : this (lt, initializer, null)
+       {
+       }
+
+       public Expression GetInitializer (FullNamedExpression type)
        {
+               if (initializer is ArrayInitializer)
+                       return new ArrayCreation (type, "", (ArrayInitializer)initializer, Location);
+
+               return initializer;
+       }
+
+       public bool HasInitializer {
+               get { return initializer != null; }
        }
 }
 
 class VariableMemberDeclaration
 {
        public readonly MemberName MemberName;
-       public Expression expression_or_array_initializer;
+       Expression initializer;
        
-       public VariableMemberDeclaration (MemberName mn, object initializer)
+       public VariableMemberDeclaration (MemberName mn, Expression initializer)
        {
                MemberName = mn;
-               
-               if (initializer is ArrayList) {
-                       this.expression_or_array_initializer = new ArrayCreation (CSharpParser.current_array_type, "", (ArrayList)initializer, mn.Location);
-               } else {
-                       this.expression_or_array_initializer = (Expression)initializer;
-               }
+               this.initializer = initializer;
+       }
+
+       public Expression GetInitializer (FullNamedExpression type)
+       {
+               if (initializer is ArrayInitializer)
+                       return new ArrayCreation (type, "", (ArrayInitializer)initializer, MemberName.Location);
+
+               return initializer;
        }
 }
 
@@ -6039,7 +5996,7 @@ MakeName (MemberName class_name)
        }
 }
 
-Block declare_local_variables (Expression type, ArrayList variable_declarators, Location loc)
+Block declare_local_variables (FullNamedExpression type, List<object> variable_declarators, Location loc)
 {
        Block implicit_block;
 
@@ -6065,7 +6022,8 @@ Block declare_local_variables (Expression type, ArrayList variable_declarators,
                        foreach (VariableDeclaration decl in variable_declarators){
                                // We can not use the super-handy f.Initializer, because
                                // multiple lines would force code to be executed out of sync
-                               if (decl.expression_or_array_initializer != null){
+                               var init = decl.GetInitializer (type);
+                               if (init != null){
                                        string id = "$" + decl.identifier;
                                        LocalInfo vi = current_block.AddVariable (type, id, decl.Location);                                     
 
@@ -6074,7 +6032,7 @@ Block declare_local_variables (Expression type, ArrayList variable_declarators,
 
                                        LocalVariableReference var;
                                        var = new LocalVariableReferenceWithClassSideEffect (current_container, decl.identifier, current_block, id, vi, decl.Location);
-                                       Assign assign = new SimpleAssign (var, decl.expression_or_array_initializer, decl.Location);
+                                       Assign assign = new SimpleAssign (var, init, decl.Location);
                                        current_block.AddStatement (new StatementExpression (assign));
                                        assign = new SimpleAssign (new SimpleName (decl.identifier, decl.Location), var);
                                        current_block.AddStatement (new StatementExpression (assign));
@@ -6115,13 +6073,12 @@ Block declare_local_variables (Expression type, ArrayList variable_declarators,
        foreach (VariableDeclaration decl in variable_declarators){
 
                if (implicit_block.AddVariable (type, decl.identifier, decl.Location) != null) {
-                       if (decl.expression_or_array_initializer != null){
+                       if (decl.HasInitializer){
                                Assign assign;
-                               Expression expr = decl.expression_or_array_initializer;
                                
                                var lvr = new LocalVariableReference (implicit_block, decl.identifier, loc);
 
-                               assign = new SimpleAssign (lvr, expr, decl.Location);
+                               assign = new SimpleAssign (lvr, decl.GetInitializer (type), decl.Location);
 
                                implicit_block.AddStatement (new StatementExpression (assign));
                        }
@@ -6131,7 +6088,7 @@ Block declare_local_variables (Expression type, ArrayList variable_declarators,
        return implicit_block;
 }
 
-Block declare_local_constants (Expression type, ArrayList declarators)
+Block declare_local_constants (FullNamedExpression type, List<object> declarators)
 {
        Block implicit_block;
 
@@ -6141,7 +6098,7 @@ Block declare_local_constants (Expression type, ArrayList declarators)
                implicit_block = current_block;
 
        foreach (VariableDeclaration decl in declarators){
-               implicit_block.AddConstant (type, decl.identifier, (Expression) decl.expression_or_array_initializer, decl.Location);
+               implicit_block.AddConstant (type, decl.identifier, decl.GetInitializer (type), decl.Location);
        }
        
        return implicit_block;
@@ -6191,7 +6148,7 @@ public Tokenizer Lexer {
 
 static CSharpParser ()
 {
-       oob_stack = new Stack ();
+       oob_stack = new Stack<object> ();
 }
 
 public CSharpParser (SeekableStreamReader reader, CompilationUnit file, CompilerContext ctx)
@@ -6364,7 +6321,7 @@ void Error_SyntaxError (int error_code, int token, string msg)
 string GetExpecting ()
 {
        int [] tokens = yyExpectingTokens (yyExpectingState);
-       ArrayList names = new ArrayList (tokens.Length);
+       var names = new List<string> (tokens.Length);
        bool has_type = false;
        bool has_identifier = false;
        for (int i = 0; i < tokens.Length; i++){
index b1c3da89707ab3914f9f3015db8c89928259ea69..26015d18ff13d933e0f30f862cbd3ccf0dbb4bc2 100644 (file)
@@ -13,7 +13,6 @@
 
 using System;
 using System.Text;
-using System.Collections;
 using System.Collections.Generic;
 using System.Globalization;
 using System.Reflection.Emit;
@@ -1315,7 +1314,7 @@ namespace Mono.CSharp {
                        if (this is GenericMethod)
                                the_parent = null;
 
-                       ArrayList list = new ArrayList ();
+                       var list = new List<TypeParameter> ();
                        if (the_parent != null && the_parent.IsGeneric) {
                                // FIXME: move generics info out of DeclSpace
                                TypeParameter[] parent_params = the_parent.TypeParameters;
@@ -1456,12 +1455,12 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       IDictionary cache = TypeManager.AllClsTopLevelTypes;
+                       var cache = TypeManager.AllClsTopLevelTypes;
                        if (cache == null)
                                return true;
 
                        string lcase = Name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
-                       if (!cache.Contains (lcase)) {
+                       if (!cache.ContainsKey (lcase)) {
                                cache.Add (lcase, this);
                                return true;
                        }
@@ -1550,7 +1549,7 @@ namespace Mono.CSharp {
                        return List.GetEnumerator ();
                }
 
-               IEnumerator IEnumerable.GetEnumerator ()
+               System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
                {
                        return List.GetEnumerator ();
                }
@@ -1692,8 +1691,12 @@ namespace Mono.CSharp {
        /// </summary>
        public class MemberCache {
                public readonly IMemberContainer Container;
-               protected Hashtable member_hash;
-               protected Hashtable method_hash;
+               protected Dictionary<string, List<CacheEntry>> member_hash;
+               protected Dictionary<string, List<CacheEntry>> method_hash;
+
+               Dictionary<string, object> locase_table;
+
+               static List<MethodInfo> overrides = new List<MethodInfo> ();
 
                /// <summary>
                ///   Create a new MemberCache for the given IMemberContainer `container'.
@@ -1710,7 +1713,7 @@ namespace Mono.CSharp {
                        if (Container.BaseCache != null)
                                member_hash = SetupCache (Container.BaseCache);
                        else
-                               member_hash = new Hashtable ();
+                               member_hash = new Dictionary<string, List<CacheEntry>> ();
 
                        // If this is neither a dynamic type nor an interface, create a special
                        // method cache with all declared and inherited methods.
@@ -1719,8 +1722,8 @@ namespace Mono.CSharp {
                            // !(type.IsGenericType && (type.GetGenericTypeDefinition () is TypeBuilder)) &&
                            !TypeManager.IsGenericType (type) && !TypeManager.IsGenericParameter (type) &&
                            (Container.BaseCache == null || Container.BaseCache.method_hash != null)) {
-                               method_hash = new Hashtable ();
-                               AddMethods (type);
+                                       method_hash = new Dictionary<string, List<CacheEntry>> ();
+                                       AddMethods (type);
                        }
 
                        // Add all members from the current class.
@@ -1733,7 +1736,7 @@ namespace Mono.CSharp {
                {
                        this.Container = container;
                        if (baseType == null)
-                               this.member_hash = new Hashtable ();
+                               this.member_hash = new Dictionary<string, List<CacheEntry>> ();
                        else
                                this.member_hash = SetupCache (TypeManager.LookupMemberCache (baseType));
                }
@@ -1746,7 +1749,7 @@ namespace Mono.CSharp {
                        //
                        this.Container = null;
 
-                       member_hash = new Hashtable ();
+                       member_hash = new Dictionary<string, List<CacheEntry>> ();
                        if (ifaces == null)
                                return;
 
@@ -1763,7 +1766,7 @@ namespace Mono.CSharp {
                        if (Container.BaseCache != null)
                                member_hash = SetupCache (Container.BaseCache);
                        else
-                               member_hash = new Hashtable ();
+                               member_hash = new Dictionary<string, List<CacheEntry>> ();
 
                        if (base_class != null)
                                AddCacheContents (TypeManager.LookupMemberCache (base_class));
@@ -1779,16 +1782,16 @@ namespace Mono.CSharp {
                /// <summary>
                ///   Bootstrap this member cache by doing a deep-copy of our base.
                /// </summary>
-               static Hashtable SetupCache (MemberCache base_class)
+               static Dictionary<string, List<CacheEntry>> SetupCache (MemberCache base_class)
                {
                        if (base_class == null)
-                               return new Hashtable ();
+                               return new Dictionary<string, List<CacheEntry>> ();
 
-                       Hashtable hash = new Hashtable (base_class.member_hash.Count);
-                       IDictionaryEnumerator it = base_class.member_hash.GetEnumerator ();
+                       var hash = new Dictionary<string, List<CacheEntry>> (base_class.member_hash.Count);
+                       var it = base_class.member_hash.GetEnumerator ();
                        while (it.MoveNext ()) {
-                               hash.Add (it.Key, ((ArrayList) it.Value).Clone ());
-                        }
+                               hash.Add (it.Current.Key, new List<CacheEntry> (it.Current.Value));
+                       }
                                 
                        return hash;
                }
@@ -1817,15 +1820,15 @@ namespace Mono.CSharp {
                /// </summary>
                void AddCacheContents (MemberCache cache)
                {
-                       IDictionaryEnumerator it = cache.member_hash.GetEnumerator ();
+                       var it = cache.member_hash.GetEnumerator ();
                        while (it.MoveNext ()) {
-                               ArrayList list = (ArrayList) member_hash [it.Key];
-                               if (list == null)
-                                       member_hash [it.Key] = list = new ArrayList ();
+                               List<CacheEntry> list;
+                               if (!member_hash.TryGetValue (it.Current.Key, out list))
+                                       member_hash [it.Current.Key] = list = new List<CacheEntry> ();
 
-                               ArrayList entries = (ArrayList) it.Value;
+                               var entries = it.Current.Value;
                                for (int i = entries.Count-1; i >= 0; i--) {
-                                       CacheEntry entry = (CacheEntry) entries [i];
+                                       var entry = entries [i];
 
                                        if (entry.Container != cache.Container)
                                                break;
@@ -1890,9 +1893,9 @@ namespace Mono.CSharp {
                                string name, MemberInfo member)
                {
                        // We use a name-based hash table of ArrayList's.
-                       ArrayList list = (ArrayList) member_hash [name];
-                       if (list == null) {
-                               list = new ArrayList (1);
+                       List<CacheEntry> list;
+                       if (!member_hash.TryGetValue (name, out list)) {
+                               list = new List<CacheEntry> (1);
                                member_hash.Add (name, list);
                        }
 
@@ -1939,8 +1942,6 @@ namespace Mono.CSharp {
                        AddMethods (BindingFlags.Instance | BindingFlags.NonPublic, type);
                }
 
-               static ArrayList overrides = new ArrayList ();
-
                void AddMethods (BindingFlags bf, Type type)
                {
                        MethodBase [] members = type.GetMethods (bf);
@@ -1951,9 +1952,9 @@ namespace Mono.CSharp {
                                string name = member.Name;
 
                                // We use a name-based hash table of ArrayList's.
-                               ArrayList list = (ArrayList) method_hash [name];
-                               if (list == null) {
-                                       list = new ArrayList (1);
+                               List<CacheEntry> list;
+                               if (!method_hash.TryGetValue (name, out list)) {
+                                       list = new List<CacheEntry> (1);
                                        method_hash.Add (name, list);
                                }
 
@@ -2048,7 +2049,7 @@ namespace Mono.CSharp {
                ///   number to speed up the searching process.
                /// </summary>
                [Flags]
-               protected enum EntryType {
+               public enum EntryType {
                        None            = 0x000,
 
                        Instance        = 0x001,
@@ -2073,7 +2074,7 @@ namespace Mono.CSharp {
                        MaskType        = Constructor|Event|Field|Method|Property|NestedType
                }
 
-               protected class CacheEntry {
+               public class CacheEntry {
                        public readonly IMemberContainer Container;
                        public EntryType EntryType;
                        public readonly MemberInfo Member;
@@ -2098,7 +2099,7 @@ namespace Mono.CSharp {
                ///   and checks whether we can abort the search since we've already found what
                ///   we were looking for.
                /// </summary>
-               protected bool DoneSearching (ArrayList list)
+               protected bool DoneSearching (IList<MemberInfo> list)
                {
                        //
                        // We've found exactly one member in the current class and it's not
@@ -2135,8 +2136,8 @@ namespace Mono.CSharp {
                ///   The lookup process will automatically restart itself in method-only
                ///   search mode if it discovers that it's about to return methods.
                /// </summary>
-               ArrayList global = new ArrayList ();
-               bool using_global = false;
+               List<MemberInfo> global = new List<MemberInfo> ();
+               bool using_global;
                
                static MemberInfo [] emptyMemberInfo = new MemberInfo [0];
                
@@ -2152,16 +2153,16 @@ namespace Mono.CSharp {
                        // then we restart a method search if the first match is a method.
                        bool do_method_search = !method_search && (method_hash != null);
 
-                       ArrayList applicable;
+                       List<CacheEntry> applicable;
 
                        // If this is a method-only search, we try to use the method cache if
                        // possible; a lookup in the method cache will return a MemberInfo with
                        // the correct ReflectedType for inherited methods.
                        
                        if (method_search && (method_hash != null))
-                               applicable = (ArrayList) method_hash [name];
+                               method_hash.TryGetValue (name, out applicable);
                        else
-                               applicable = (ArrayList) member_hash [name];
+                               member_hash.TryGetValue (name, out applicable);
 
                        if (applicable == null)
                                return emptyMemberInfo;
@@ -2280,12 +2281,12 @@ namespace Mono.CSharp {
                // find the nested type @name in @this.
                public Type FindNestedType (string name)
                {
-                       ArrayList applicable = (ArrayList) member_hash [name];
-                       if (applicable == null)
+                       List<CacheEntry> applicable;
+                       if (!member_hash.TryGetValue (name, out applicable))
                                return null;
                        
                        for (int i = applicable.Count-1; i >= 0; i--) {
-                               CacheEntry entry = (CacheEntry) applicable [i];
+                               CacheEntry entry = applicable [i];
                                if ((entry.EntryType & EntryType.NestedType & EntryType.MaskType) != 0)
                                        return (Type) entry.Member;
                        }
@@ -2295,8 +2296,8 @@ namespace Mono.CSharp {
 
                public MemberInfo FindBaseEvent (Type invocation_type, string name)
                {
-                       ArrayList applicable = (ArrayList) member_hash [name];
-                       if (applicable == null)
+                       List<CacheEntry> applicable;
+                       if (!member_hash.TryGetValue (name, out applicable))
                                return null;
 
                        //
@@ -2304,7 +2305,7 @@ namespace Mono.CSharp {
                        //
                        for (int i = applicable.Count - 1; i >= 0; i--) 
                        {
-                               CacheEntry entry = (CacheEntry) applicable [i];
+                               CacheEntry entry = applicable [i];
                                if ((entry.EntryType & EntryType.Event) == 0)
                                        continue;
                                
@@ -2318,13 +2319,14 @@ namespace Mono.CSharp {
                //
                // Looks for extension methods with defined name and extension type
                //
-               public ArrayList FindExtensionMethods (Assembly thisAssembly, Type extensionType, string name, bool publicOnly)
+               public List<MethodBase> FindExtensionMethods (Assembly thisAssembly, Type extensionType, string name, bool publicOnly)
                {
-                       ArrayList entries;
+                       List<CacheEntry> entries;
                        if (method_hash != null)
-                               entries = (ArrayList)method_hash [name];
-                       else
-                               entries = (ArrayList)member_hash [name];
+                               method_hash.TryGetValue (name, out entries);
+                       else {
+                               member_hash.TryGetValue (name, out entries);
+                       }
 
                        if (entries == null)
                                return null;
@@ -2332,7 +2334,7 @@ namespace Mono.CSharp {
                        EntryType entry_type = EntryType.Static | EntryType.Method | EntryType.NotExtensionMethod;
                        EntryType found_entry_type = entry_type & ~EntryType.NotExtensionMethod;
 
-                       ArrayList candidates = null;
+                       List<MethodBase> candidates = null;
                        foreach (CacheEntry entry in entries) {
                                if ((entry.EntryType & entry_type) == found_entry_type) {
                                        MethodBase mb = (MethodBase)entry.Member;
@@ -2359,7 +2361,7 @@ namespace Mono.CSharp {
 
                                        //if (implicit conversion between ex_type and extensionType exist) {
                                                if (candidates == null)
-                                                       candidates = new ArrayList (2);
+                                                       candidates = new List<MethodBase> (2);
                                                candidates.Add (mb);
                                        //}
                                }
@@ -2378,11 +2380,11 @@ namespace Mono.CSharp {
                //
                public MemberInfo FindMemberToOverride (Type invocation_type, string name, AParametersCollection parameters, GenericMethod generic_method, bool is_property)
                {
-                       ArrayList applicable;
+                       List<CacheEntry> applicable;
                        if (method_hash != null && !is_property)
-                               applicable = (ArrayList) method_hash [name];
+                               method_hash.TryGetValue (name, out applicable);
                        else
-                               applicable = (ArrayList) member_hash [name];
+                               member_hash.TryGetValue (name, out applicable);
                        
                        if (applicable == null)
                                return null;
@@ -2390,7 +2392,7 @@ namespace Mono.CSharp {
                        // Walk the chain of methods, starting from the top.
                        //
                        for (int i = applicable.Count - 1; i >= 0; i--) {
-                               CacheEntry entry = (CacheEntry) applicable [i];
+                               CacheEntry entry = applicable [i];
                                
                                if ((entry.EntryType & (is_property ? (EntryType.Property | EntryType.Field) : EntryType.Method)) == 0)
                                        continue;
@@ -2520,10 +2522,10 @@ namespace Mono.CSharp {
                /// </summary>
                public MemberInfo FindMemberWithSameName (string name, bool ignore_complex_types, MemberInfo ignore_member)
                {
-                       ArrayList applicable = null;
+                       List<CacheEntry> applicable = null;
  
                        if (method_hash != null)
-                               applicable = (ArrayList) method_hash [name];
+                               method_hash.TryGetValue (name, out applicable);
  
                        if (applicable != null) {
                                for (int i = applicable.Count - 1; i >= 0; i--) {
@@ -2535,9 +2537,8 @@ namespace Mono.CSharp {
  
                        if (member_hash == null)
                                return null;
-                       applicable = (ArrayList) member_hash [name];
-                       
-                       if (applicable != null) {
+
+                       if (member_hash.TryGetValue (name, out applicable)) {
                                for (int i = applicable.Count - 1; i >= 0; i--) {
                                        CacheEntry entry = (CacheEntry) applicable [i];
                                        if ((entry.EntryType & EntryType.Public) != 0 & entry.Member != ignore_member) {
@@ -2559,21 +2560,20 @@ namespace Mono.CSharp {
                        return null;
                }
 
-               Hashtable locase_table;
+
                /// <summary>
                /// Builds low-case table for CLS Compliance test
                /// </summary>
-               public Hashtable GetPublicMembers ()
+               public Dictionary<string, object> GetPublicMembers ()
                {
                        if (locase_table != null)
                                return locase_table;
-                       locase_table = new Hashtable ();
-                       foreach (DictionaryEntry entry in member_hash) {
-                               ArrayList members = (ArrayList)entry.Value;
+
+                       locase_table = new Dictionary<string, object> ();
+                       foreach (var entry in member_hash) {
+                               var members = entry.Value;
                                for (int ii = 0; ii < members.Count; ++ii) {
-                                       CacheEntry member_entry = (CacheEntry) members [ii];
+                                       CacheEntry member_entry = members [ii];
  
                                        if ((member_entry.EntryType & EntryType.Public) == 0)
                                                continue;
@@ -2614,7 +2614,7 @@ namespace Mono.CSharp {
                        return locase_table;
                }
  
-               public Hashtable Members {
+               public IDictionary<string, List<CacheEntry>> Members {
                        get {
                                return member_hash;
                        }
@@ -2625,12 +2625,12 @@ namespace Mono.CSharp {
                /// </summary>
                /// 
                // TODO: refactor as method is always 'this'
-               public static void VerifyClsParameterConflict (ArrayList al, MethodCore method, MemberInfo this_builder, Report Report)
+               public static void VerifyClsParameterConflict (IList<CacheEntry> al, MethodCore method, MemberInfo this_builder, Report Report)
                {
                        EntryType tested_type = (method is Constructor ? EntryType.Constructor : EntryType.Method) | EntryType.Public;
  
                        for (int i = 0; i < al.Count; ++i) {
-                               MemberCache.CacheEntry entry = (MemberCache.CacheEntry) al [i];
+                               var entry = al [i];
                
                                // skip itself
                                if (entry.Member == this_builder)
@@ -2673,8 +2673,8 @@ namespace Mono.CSharp {
 
                public bool CheckExistingMembersOverloads (MemberCore member, string name, ParametersCompiled parameters, Report Report)
                {
-                       ArrayList entries = (ArrayList)member_hash [name];
-                       if (entries == null)
+                       List<CacheEntry> entries;
+                       if (!member_hash.TryGetValue (name, out entries))
                                return true;
 
                        int method_param_count = parameters.Count;
index 7e11028f4d401b2dd77b501f4e1f7ecfe7e11bff..70081e313681dfb2e1c7c927b7b41b581bb02dcc 100644 (file)
@@ -9,7 +9,6 @@
 //
 
 using System;
-using System.Collections;
 using System.Reflection.Emit;
 
 #if NET_4_0
@@ -613,7 +612,7 @@ namespace Mono.CSharp
                        if (member != null && member.HasTypeArguments) {
                                TypeArguments ta = member.TypeArguments;
                                if (ta.Resolve (ec)) {
-                                       ArrayList targs = new ArrayList (ta.Count);
+                                       var targs = new ArrayInitializer (ta.Count, loc);
                                        foreach (Type t in ta.Arguments)
                                                targs.Add (new TypeOf (new TypeExpression (t, loc), loc));
 
@@ -628,7 +627,9 @@ namespace Mono.CSharp
                        Expression real_args;
                        if (args == null) {
                                // Cannot be null because .NET trips over
-                               real_args = new ArrayCreation (new MemberAccess (GetBinderNamespace (loc), "CSharpArgumentInfo", loc), "[]", new ArrayList (0), loc);
+                               real_args = new ArrayCreation (
+                                       new MemberAccess (GetBinderNamespace (loc), "CSharpArgumentInfo", loc), "[]",
+                                       new ArrayInitializer (0, loc), loc);
                        } else {
                                real_args = new ImplicitlyTypedArrayCreation ("[]", args.CreateDynamicBinderArguments (ec), loc);
                        }
index 9f19b28015e32bfd8c27a7b1b353ef6a1568f207..0f4b738f31b98147d409852c0e988dca5850fb21 100644 (file)
@@ -12,7 +12,6 @@
 
 namespace Mono.CSharp {
        using System;
-       using System.Collections;
        using System.Collections.Generic;
        using System.Diagnostics;
        using System.Reflection;
@@ -684,21 +683,21 @@ namespace Mono.CSharp {
 
                        if (mi.Length > 1) {
                                bool is_interface = qualifier_type != null && qualifier_type.IsInterface;
-                               ArrayList methods = new ArrayList (2);
-                               ArrayList non_methods = null;
+                               var methods = new List<MethodBase> (2);
+                               List<MemberInfo> non_methods = null;
 
                                foreach (MemberInfo m in mi) {
                                        if (m is MethodBase) {
-                                               methods.Add (m);
+                                               methods.Add ((MethodBase) m);
                                                continue;
                                        }
 
                                        if (non_methods == null)
-                                               non_methods = new ArrayList (2);
+                                               non_methods = new List<MemberInfo> (2);
 
                                        bool is_candidate = true;
                                        for (int i = 0; i < non_methods.Count; ++i) {
-                                               MemberInfo n_m = (MemberInfo) non_methods [i];
+                                               MemberInfo n_m = non_methods [i];
                                                if (n_m.DeclaringType.IsInterface && TypeManager.ImplementsInterface (m.DeclaringType, n_m.DeclaringType)) {
                                                        non_methods.Remove (n_m);
                                                        --i;
@@ -714,11 +713,11 @@ namespace Mono.CSharp {
                                }
                                
                                if (methods.Count == 0 && non_methods != null && non_methods.Count > 1) {
-                                       ctx.Report.SymbolRelatedToPreviousError ((MemberInfo)non_methods [1]);
-                                       ctx.Report.SymbolRelatedToPreviousError ((MemberInfo)non_methods [0]);
+                                       ctx.Report.SymbolRelatedToPreviousError (non_methods [1]);
+                                       ctx.Report.SymbolRelatedToPreviousError (non_methods [0]);
                                        ctx.Report.Error (229, loc, "Ambiguity between `{0}' and `{1}'",
-                                               TypeManager.GetFullNameSignature ((MemberInfo)non_methods [1]),
-                                               TypeManager.GetFullNameSignature ((MemberInfo)non_methods [0]));
+                                               TypeManager.GetFullNameSignature (non_methods [1]),
+                                               TypeManager.GetFullNameSignature (non_methods [0]));
                                        return null;
                                }
 
@@ -1499,7 +1498,7 @@ namespace Mono.CSharp {
        /// </summary>
        public class CastFromDecimal : TypeCast
        {
-               static IDictionary operators;
+               static Dictionary<Type, MethodInfo> operators;
 
                public CastFromDecimal (Expression child, Type return_type)
                        : base (child, return_type)
@@ -1514,11 +1513,11 @@ namespace Mono.CSharp {
                public Expression Resolve ()
                {
                        if (operators == null) {
-                                MemberInfo[] all_oper = TypeManager.MemberLookup (TypeManager.decimal_type,
-                                       TypeManager.decimal_type, TypeManager.decimal_type, MemberTypes.Method,
-                                       BindingFlags.Static | BindingFlags.Public, "op_Explicit", null);
+                               MemberInfo[] all_oper = TypeManager.MemberLookup (TypeManager.decimal_type,
+                                  TypeManager.decimal_type, TypeManager.decimal_type, MemberTypes.Method,
+                                  BindingFlags.Static | BindingFlags.Public, "op_Explicit", null);
 
-                               operators = new System.Collections.Specialized.HybridDictionary ();
+                               operators = new Dictionary<Type, MethodInfo> (ReferenceEquality<Type>.Default);
                                foreach (MethodInfo oper in all_oper) {
                                        AParametersCollection pd = TypeManager.GetParameterData (oper);
                                        if (pd.Types [0] == TypeManager.decimal_type)
@@ -1526,7 +1525,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       return operators.Contains (type) ? this : null;
+                       return operators.ContainsKey (type) ? this : null;
                }
 
                public override void Emit (EmitContext ec)
@@ -1534,7 +1533,7 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
                        child.Emit (ec);
 
-                       ig.Emit (OpCodes.Call, (MethodInfo)operators [type]);
+                       ig.Emit (OpCodes.Call, operators [type]);
                }
        }
 
@@ -3261,7 +3260,7 @@ namespace Mono.CSharp {
                public Expression ExtensionExpression;
                Argument extension_argument;
 
-               public ExtensionMethodGroupExpr (ArrayList list, NamespaceEntry n, Type extensionType, Location l)
+               public ExtensionMethodGroupExpr (List<MethodBase> list, NamespaceEntry n, Type extensionType, Location l)
                        : base (list, extensionType, l)
                {
                        this.namespace_entry = n;
@@ -3354,11 +3353,11 @@ namespace Mono.CSharp {
                        has_inaccessible_candidates_only = inacessibleCandidatesOnly;
                }
 
-               public MethodGroupExpr (ArrayList list, Type type, Location l)
+               public MethodGroupExpr (List<MethodBase> list, Type type, Location l)
                        : this (type, l)
                {
                        try {
-                               Methods = (MethodBase[])list.ToArray (typeof (MethodBase));
+                               Methods = list.ToArray ();
                        } catch {
                                foreach (MemberInfo m in list){
                                        if (!(m is MethodBase)){
@@ -4103,8 +4102,8 @@ namespace Mono.CSharp {
 
                        if (mg2 == null)
                                return mg1;
-                       
-                       ArrayList all = new ArrayList (mg1.Methods);
+
+                       var all = new List<MethodBase> (mg1.Methods);
                        foreach (MethodBase m in mg2.Methods){
                                if (!TypeManager.ArrayContainsMethod (mg1.Methods, m, false))
                                        all.Add (m);
@@ -4190,8 +4189,8 @@ namespace Mono.CSharp {
                {
                        bool method_params = false;
                        Type applicable_type = null;
-                       ArrayList candidates = new ArrayList (2);
-                       ArrayList candidate_overrides = null;
+                       var candidates = new List<MethodBase> (2);
+                       List<MethodBase> candidate_overrides = null;
 
                        //
                        // Used to keep a map between the candidate
@@ -4230,7 +4229,7 @@ namespace Mono.CSharp {
                                        MethodBase m = Methods [i];
                                        if (TypeManager.IsOverride (m)) {
                                                if (candidate_overrides == null)
-                                                       candidate_overrides = new ArrayList ();
+                                                       candidate_overrides = new List<MethodBase> ();
                                                candidate_overrides.Add (m);
                                                m = TypeManager.TryGetBaseDefinition (m);
                                        }
@@ -4386,7 +4385,7 @@ namespace Mono.CSharp {
                                        int j = finalized; // where to put the next finalized candidate
                                        int k = finalized; // where to put the next undiscarded candidate
                                        for (int i = finalized; i < candidate_top; ++i) {
-                                               MethodBase candidate = (MethodBase) candidates [i];
+                                               MethodBase candidate = candidates [i];
                                                Type decl_type = candidate.DeclaringType;
 
                                                if (decl_type == applicable_type) {
@@ -4419,7 +4418,7 @@ namespace Mono.CSharp {
                        // Now we actually find the best method
                        //
 
-                       best_candidate = (MethodBase) candidates [0];
+                       best_candidate = candidates [0];
                        method_params = candidate_to_form != null && candidate_to_form.ContainsKey (best_candidate);
 
                        //
@@ -4452,7 +4451,7 @@ namespace Mono.CSharp {
                        //
                        MethodBase ambiguous = null;
                        for (int ix = 1; ix < candidate_top; ix++) {
-                               MethodBase candidate = (MethodBase) candidates [ix];
+                               MethodBase candidate = candidates [ix];
 
                                if (candidate == best_candidate)
                                        continue;
@@ -4617,7 +4616,7 @@ namespace Mono.CSharp {
                        Type pt = null;
                        int a_idx = 0, a_pos = 0;
                        Argument a = null;
-                       ArrayList params_initializers = null;
+                       ArrayInitializer params_initializers = null;
                        bool has_unsafe_arg = method is MethodInfo ? ((MethodInfo) method).ReturnType.IsPointer : false;
 
                        for (; a_idx < arg_count; a_idx++, ++a_pos) {
@@ -4629,7 +4628,7 @@ namespace Mono.CSharp {
 
                                        if (p_mod == Parameter.Modifier.PARAMS) {
                                                if (chose_params_expanded) {
-                                                       params_initializers = new ArrayList (arg_count - a_idx);
+                                                       params_initializers = new ArrayInitializer (arg_count - a_idx, a.Expr.Location);
                                                        pt = TypeManager.GetElementType (pt);
                                                }
                                        }
@@ -4721,7 +4720,7 @@ namespace Mono.CSharp {
                                pt = pd.Types [param_count - 1];
                                pt = TypeManager.GetElementType (pt);
                                has_unsafe_arg |= pt.IsPointer;
-                               params_initializers = new ArrayList (0);
+                               params_initializers = new ArrayInitializer (0, loc);
                        }
 
                        //
@@ -4729,8 +4728,7 @@ namespace Mono.CSharp {
                        //
                        if (params_initializers != null) {
                                arguments.Add (new Argument (
-                                                      new ArrayCreation (new TypeExpression (pt, loc), "[]",
-                                                                         params_initializers, loc).Resolve (ec)));
+                                       new ArrayCreation (new TypeExpression (pt, loc), "[]", params_initializers, loc).Resolve (ec)));
                                arg_count++;
                        }
 
index 57d36158de6f99ff48457afe9d5c90410f218fd8..0176a5194a859184dc121348f0df21ed23ab9d7e 100644 (file)
@@ -11,7 +11,6 @@
 //
 using System;
 using System.Threading;
-using System.Collections;
 using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -55,10 +54,10 @@ namespace Mono.CSharp {
                static string current_debug_name;
                static int count;
                static Thread invoke_thread;
-               
-               static ArrayList using_alias_list = new ArrayList ();
-               internal static ArrayList using_list = new ArrayList ();
-               static Hashtable fields = new Hashtable ();
+
+               static List<NamespaceEntry.UsingAliasEntry> using_alias_list = new List<NamespaceEntry.UsingAliasEntry> ();
+               internal static List<NamespaceEntry.UsingEntry> using_list = new List<NamespaceEntry.UsingEntry> ();
+               static Dictionary<string, FieldInfo> fields = new Dictionary<string, FieldInfo> ();
 
                static Type   interactive_base_class = typeof (InteractiveBase);
                static Driver driver;
@@ -118,7 +117,7 @@ namespace Mono.CSharp {
                                
                                driver.ProcessDefaultConfig ();
 
-                               ArrayList startup_files = new ArrayList ();
+                               var startup_files = new List<string> ();
                                foreach (CompilationUnit file in Location.SourceFiles)
                                        startup_files.Add (file.Path);
                                
@@ -129,7 +128,7 @@ namespace Mono.CSharp {
                                RootContext.EvalMode = true;
                                inited = true;
 
-                               return (string []) startup_files.ToArray (typeof (string));
+                               return startup_files.ToArray ();
                        }
                }
 
@@ -682,7 +681,7 @@ namespace Mono.CSharp {
                // or reflection gets confused (it basically gets confused, and variables override each
                // other).
                //
-               static ArrayList queued_fields = new ArrayList ();
+               static List<Field> queued_fields = new List<Field> ();
                
                //static ArrayList types = new ArrayList ();
 
@@ -745,11 +744,11 @@ namespace Mono.CSharp {
                        foreach (Field field in queued_fields){
                                FieldInfo fi = tt.GetField (field.Name);
                                
-                               FieldInfo old = (FieldInfo) fields [field.Name];
+                               FieldInfo old;
                                
                                // If a previous value was set, nullify it, so that we do
                                // not leak memory
-                               if (old != null){
+                               if (fields.TryGetValue (field.Name, out old)){
                                        if (TypeManager.IsStruct (old.FieldType)){
                                                //
                                                // TODO: Clear fields for structs
@@ -831,9 +830,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               static internal ICollection GetUsingList ()
+               static internal ICollection<string> GetUsingList ()
                {
-                       ArrayList res = new ArrayList (using_list.Count);
+                       var res = new List<string> (using_list.Count);
                        foreach (object ue in using_list)
                                res.Add (ue.ToString ());
                        return res;
@@ -842,7 +841,7 @@ namespace Mono.CSharp {
                static internal string [] GetVarNames ()
                {
                        lock (evaluator_lock){
-                               return (string []) new ArrayList (fields.Keys).ToArray (typeof (string));
+                               return new List<string> (fields.Keys).ToArray ();
                        }
                }
                
@@ -851,8 +850,8 @@ namespace Mono.CSharp {
                        lock (evaluator_lock){
                                StringBuilder sb = new StringBuilder ();
                                
-                               foreach (DictionaryEntry de in fields){
-                                       FieldInfo fi = LookupField ((string) de.Key);
+                               foreach (var de in fields){
+                                       FieldInfo fi = LookupField (de.Key);
                                        object value = null;
                                        bool error = false;
                                        
index a473d380826bd50e2078ca7f41abdaaf36ad6118..34d0a915c90af2a50a4aa1eec94364725ce0047a 100644 (file)
@@ -12,7 +12,6 @@
 
 namespace Mono.CSharp {
        using System;
-       using System.Collections;
        using System.Collections.Generic;
        using System.Reflection;
        using System.Reflection.Emit;
@@ -2463,7 +2462,7 @@ namespace Mono.CSharp {
 
                static void CreatePointerOperatorsTable ()
                {
-                       ArrayList temp = new ArrayList ();
+                       var temp = new List<PredefinedPointerOperator> ();
 
                        //
                        // Pointer arithmetic:
@@ -2494,12 +2493,12 @@ namespace Mono.CSharp {
                        //
                        temp.Add (new PredefinedPointerOperator (null, Operator.SubtractionMask, TypeManager.int64_type));
 
-                       pointer_operators = (PredefinedOperator []) temp.ToArray (typeof (PredefinedOperator));
+                       pointer_operators = temp.ToArray ();
                }
 
                static void CreateStandardOperatorsTable ()
                {
-                       ArrayList temp = new ArrayList ();
+                       var temp = new List<PredefinedOperator> ();
                        Type bool_type = TypeManager.bool_type;
 
                        temp.Add (new PredefinedOperator (TypeManager.int32_type, Operator.ArithmeticMask | Operator.BitwiseMask));
@@ -2532,7 +2531,7 @@ namespace Mono.CSharp {
                        temp.Add (new PredefinedShiftOperator (TypeManager.int64_type, Operator.ShiftMask));
                        temp.Add (new PredefinedShiftOperator (TypeManager.uint64_type, Operator.ShiftMask));
 
-                       standard_operators = (PredefinedOperator []) temp.ToArray (typeof (PredefinedOperator));
+                       standard_operators = temp.ToArray ();
                }
 
                //
@@ -5775,6 +5774,57 @@ namespace Mono.CSharp {
                }
        }
 
+       public class ArrayInitializer : ShimExpression
+       {
+               List<Expression> elements;
+
+               public ArrayInitializer (List<Expression> init, Location loc)
+                       : base (null)
+               {
+                       elements = init;
+               }
+
+               public ArrayInitializer (int count, Location loc)
+                       : base (null)
+               {
+                       elements = new List<Expression> (count);
+               }
+
+               public ArrayInitializer (Location loc)
+                       : this (4, loc)
+               {
+               }
+
+               public void Add (Expression expr)
+               {
+                       elements.Add (expr);
+               }
+
+               protected override void CloneTo (CloneContext clonectx, Expression t)
+               {
+                       var target = (ArrayInitializer) t;
+
+                       target.elements = new List<Expression> (elements.Count);
+                       foreach (var element in elements)
+                               target.elements.Add (element.Clone (clonectx));
+
+                       base.CloneTo (clonectx, t);
+               }
+
+               public int Count {
+                       get { return elements.Count; }
+               }
+
+               protected override Expression DoResolve (ResolveContext rc)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Expression this [int index] {
+                       get { return elements [index]; }
+               }
+       }
+
        /// <summary>
        ///   14.5.10.2: Represents an array creation expression.
        /// </summary>
@@ -5785,15 +5835,16 @@ namespace Mono.CSharp {
        ///   initialization data and the other which does not need dimensions
        ///   specified but where initialization data is mandatory.
        /// </remarks>
-       public class ArrayCreation : Expression {
+       class ArrayCreation : Expression
+       {
                FullNamedExpression requested_base_type;
-               ArrayList initializers;
+               ArrayInitializer initializers;
 
                //
                // The list of Argument types.
                // This is used to construct the `newarray' or constructor signature
                //
-               protected ArrayList arguments;
+               protected List<Expression> arguments;
                
                protected Type array_element_type;
                bool expect_initializers = false;
@@ -5805,28 +5856,24 @@ namespace Mono.CSharp {
 
                protected List<Expression> array_data;
 
-               IDictionary bounds;
+               Dictionary<int, int> bounds;
 
                // The number of constants in array initializers
                int const_initializers_count;
                bool only_constant_initializers;
-               
-               public ArrayCreation (FullNamedExpression requested_base_type, ArrayList exprs, string rank, ArrayList initializers, Location l)
+
+               public ArrayCreation (FullNamedExpression requested_base_type, List<Expression> exprs, string rank, ArrayInitializer initializers, Location l)
                {
                        this.requested_base_type = requested_base_type;
                        this.initializers = initializers;
                        this.rank = rank;
                        loc = l;
 
-                       arguments = new ArrayList (exprs.Count);
-
-                       foreach (Expression e in exprs) {
-                               arguments.Add (e);
-                               num_arguments++;
-                       }
+                       arguments = new List<Expression> (exprs);
+                       num_arguments = arguments.Count;
                }
 
-               public ArrayCreation (FullNamedExpression requested_base_type, string rank, ArrayList initializers, Location l)
+               public ArrayCreation (FullNamedExpression requested_base_type, string rank, ArrayInitializer initializers, Location l)
                {
                        this.requested_base_type = requested_base_type;
                        this.initializers = initializers;
@@ -5846,10 +5893,10 @@ namespace Mono.CSharp {
                        ec.Report.Error (248, loc, "Cannot create an array with a negative size");
                }
 
-               bool CheckIndices (ResolveContext ec, ArrayList probe, int idx, bool specified_dims, int child_bounds)
+               bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds)
                {
                        if (specified_dims) { 
-                               Expression a = (Expression) arguments [idx];
+                               Expression a = arguments [idx];
                                a = a.Resolve (ec);
                                if (a == null)
                                        return false;
@@ -5876,9 +5923,9 @@ namespace Mono.CSharp {
 
                        only_constant_initializers = true;
                        for (int i = 0; i < probe.Count; ++i) {
-                               object o = probe [i];
-                               if (o is ArrayList) {
-                                       ArrayList sub_probe = o as ArrayList;
+                               var o = probe [i];
+                               if (o is ArrayInitializer) {
+                                       var sub_probe = o as ArrayInitializer;
                                        if (idx + 1 >= dimensions){
                                                ec.Report.Error (623, loc, "Array initializers can only be used in a variable or field initializer. Try using a new expression instead");
                                                return false;
@@ -5888,9 +5935,9 @@ namespace Mono.CSharp {
                                        if (!ret)
                                                return false;
                                } else if (child_bounds > 1) {
-                                       ec.Report.Error (846, ((Expression) o).Location, "A nested array initializer was expected");
+                                       ec.Report.Error (846, o.Location, "A nested array initializer was expected");
                                } else {
-                                       Expression element = ResolveArrayElement (ec, (Expression) o);
+                                       Expression element = ResolveArrayElement (ec, o);
                                        if (element == null)
                                                continue;
 
@@ -5938,7 +5985,7 @@ namespace Mono.CSharp {
                                for (int i = 0; i < array_data.Count; ++i) {
                                        Expression e = array_data [i];
                                        if (e == null)
-                                               e = Convert.ImplicitConversion (ec, (Expression) initializers [i], array_element_type, loc);
+                                               e = Convert.ImplicitConversion (ec, initializers [i], array_element_type, loc);
 
                                        args.Add (new Argument (e.CreateExpressionTree (ec)));
                                }
@@ -5950,14 +5997,14 @@ namespace Mono.CSharp {
                public void UpdateIndices ()
                {
                        int i = 0;
-                       for (ArrayList probe = initializers; probe != null;) {
-                               if (probe.Count > 0 && probe [0] is ArrayList) {
+                       for (var probe = initializers; probe != null;) {
+                               if (probe.Count > 0 && probe [0] is ArrayInitializer) {
                                        Expression e = new IntConstant (probe.Count, Location.Null);
                                        arguments.Add (e);
 
-                                       bounds [i++] =  probe.Count;
-                                       
-                                       probe = (ArrayList) probe [0];
+                                       bounds [i++] = probe.Count;
+
+                                       probe = (ArrayInitializer) probe[0];
                                        
                                } else {
                                        Expression e = new IntConstant (probe.Count, Location.Null);
@@ -5997,12 +6044,12 @@ namespace Mono.CSharp {
                        // will need to store them in the byte blob later
                        //
                        array_data = new List<Expression> ();
-                       bounds = new System.Collections.Specialized.HybridDictionary ();
+                       bounds = new Dictionary<int, int> ();
                        
                        if (arguments != null)
                                return CheckIndices (ec, initializers, 0, true, dimensions);
 
-                       arguments = new ArrayList ();
+                       arguments = new List<Expression> ();
 
                        if (!CheckIndices (ec, initializers, 0, false, dimensions))
                                return false;
@@ -6017,11 +6064,6 @@ namespace Mono.CSharp {
                //
                bool ResolveArrayType (ResolveContext ec)
                {
-                       if (requested_base_type == null) {
-                               ec.Report.Error (622, loc, "Can only use array initializer expressions to assign to array types. Try using a new expression instead");
-                               return false;
-                       }
-
                        if (requested_base_type is VarExpr) {
                                ec.Report.Error (820, loc, "An implicitly typed local variable declarator cannot use an array initializer");
                                return false;
@@ -6050,6 +6092,11 @@ namespace Mono.CSharp {
                                return false;
 
                        type = array_type_expr.Type;
+                       if (!type.IsArray) {
+                               ec.Report.Error (622, loc, "Can only use array initializer expressions to assign to array types. Try using a new expression instead");
+                               return false;
+                       }
+
                        array_element_type = TypeManager.GetElementType (type);
                        dimensions = type.GetArrayRank ();
 
@@ -6072,7 +6119,7 @@ namespace Mono.CSharp {
                                return null;
 
                        for (int i = 0; i < arguments.Count; ++i) {
-                               Expression e = ((Expression) arguments[i]).Resolve (ec);
+                               Expression e = arguments[i].Resolve (ec);
                                if (e == null)
                                        continue;
 
@@ -6349,7 +6396,7 @@ namespace Mono.CSharp {
 
                        for (int i = 0; i < array_data.Count; i++){
 
-                               Expression e = (Expression)array_data [i];
+                               Expression e = array_data [i];
 
                                // Constant can be initialized via StaticInitializer
                                if (e != null && !(!emitConstants && e is Constant)) {
@@ -6392,7 +6439,7 @@ namespace Mono.CSharp {
                                //
                                for (int j = dims - 1; j >= 0; j--){
                                        current_pos [j]++;
-                                       if (current_pos [j] < (int) bounds [j])
+                                       if (current_pos [j] < bounds [j])
                                                break;
                                        current_pos [j] = 0;
                                }
@@ -6445,7 +6492,7 @@ namespace Mono.CSharp {
                        }
 
                        if (array_data == null) {
-                               Expression arg = (Expression) arguments[0];
+                               Expression arg = arguments [0];
                                object arg_value;
                                if (arg.GetAttributableValue (ec, arg.Type, out arg_value) && arg_value is int && (int)arg_value == 0) {
                                        value = Array.CreateInstance (array_element_type, 0);
@@ -6460,7 +6507,7 @@ namespace Mono.CSharp {
                        object element_value;
                        for (int i = 0; i < ret.Length; ++i)
                        {
-                               Expression e = (Expression)array_data [i];
+                               Expression e = array_data [i];
 
                                // Is null when an initializer is optimized (value == predefined value)
                                if (e == null) 
@@ -6484,33 +6531,22 @@ namespace Mono.CSharp {
                                target.requested_base_type = (FullNamedExpression)requested_base_type.Clone (clonectx);
 
                        if (arguments != null){
-                               target.arguments = new ArrayList (arguments.Count);
+                               target.arguments = new List<Expression> (arguments.Count);
                                foreach (Expression e in arguments)
                                        target.arguments.Add (e.Clone (clonectx));
                        }
 
-                       if (initializers != null){
-                               target.initializers = new ArrayList (initializers.Count);
-                               foreach (object initializer in initializers)
-                                       if (initializer is ArrayList) {
-                                               ArrayList this_al = (ArrayList)initializer;
-                                               ArrayList al = new ArrayList (this_al.Count);
-                                               target.initializers.Add (al);
-                                               foreach (Expression e in this_al)
-                                                       al.Add (e.Clone (clonectx));
-                                       } else {
-                                               target.initializers.Add (((Expression)initializer).Clone (clonectx));
-                                       }
-                       }
+                       if (initializers != null)
+                               target.initializers = (ArrayInitializer) initializers.Clone (clonectx);
                }
        }
        
        //
        // Represents an implicitly typed array epxression
        //
-       public class ImplicitlyTypedArrayCreation : ArrayCreation
+       class ImplicitlyTypedArrayCreation : ArrayCreation
        {
-               public ImplicitlyTypedArrayCreation (string rank, ArrayList initializers, Location loc)
+               public ImplicitlyTypedArrayCreation (string rank, ArrayInitializer initializers, Location loc)
                        : base (null, rank, initializers, loc)
                {                       
                        if (rank.Length > 2) {
@@ -8330,7 +8366,7 @@ namespace Mono.CSharp {
                        public IndexerMethodGroupExpr (Indexers indexers, Location loc)
                                : base (null, loc)
                        {
-                               Methods = (MethodBase []) indexers.Methods.ToArray (typeof (MethodBase));
+                               Methods = indexers.Methods.ToArray ();
                        }
 
                        public override string Name {
@@ -8357,8 +8393,8 @@ namespace Mono.CSharp {
                class Indexers
                {
                        // Contains either property getter or setter
-                       public ArrayList Methods;
-                       public ArrayList Properties;
+                       public List<MethodBase> Methods;
+                       public List<PropertyInfo> Properties;
 
                        Indexers ()
                        {
@@ -8375,8 +8411,8 @@ namespace Mono.CSharp {
                                                accessor = property.GetSetMethod (true);
 
                                        if (Methods == null) {
-                                               Methods = new ArrayList ();
-                                               Properties = new ArrayList ();
+                                               Methods = new List<MethodBase> ();
+                                               Properties = new List<PropertyInfo> ();
                                        }
 
                                        Methods.Add (accessor);
@@ -9451,7 +9487,7 @@ namespace Mono.CSharp {
                        this.loc = argument.Location;
                }
 
-               public CollectionElementInitializer (ArrayList arguments, Location loc)
+               public CollectionElementInitializer (List<Expression> arguments, Location loc)
                        : base (null, new Arguments (arguments.Count))
                {
                        foreach (Expression e in arguments)
@@ -9465,7 +9501,7 @@ namespace Mono.CSharp {
                        Arguments args = new Arguments (2);
                        args.Add (new Argument (mg.CreateExpressionTree (ec)));
 
-                       ArrayList expr_initializers = new ArrayList (arguments.Count);
+                       var expr_initializers = new ArrayInitializer (arguments.Count, loc);
                        foreach (Argument a in arguments)
                                expr_initializers.Add (a.CreateExpressionTree (ec));
 
@@ -9529,7 +9565,7 @@ namespace Mono.CSharp {
 
                public override Expression CreateExpressionTree (ResolveContext ec)
                {
-                       var expr_initializers = new ArrayList (initializers.Count);
+                       var expr_initializers = new ArrayInitializer (initializers.Count, loc);
                        foreach (Expression e in initializers) {
                                Expression expr = e.CreateExpressionTree (ec);
                                if (expr != null)
@@ -9541,14 +9577,14 @@ namespace Mono.CSharp {
                
                protected override Expression DoResolve (ResolveContext ec)
                {
-                       ArrayList element_names = null;
+                       List<string> element_names = null;
                        for (int i = 0; i < initializers.Count; ++i) {
                                Expression initializer = (Expression) initializers [i];
                                ElementInitializer element_initializer = initializer as ElementInitializer;
 
                                if (i == 0) {
                                        if (element_initializer != null) {
-                                               element_names = new ArrayList (initializers.Count);
+                                               element_names = new List<string> (initializers.Count);
                                                element_names.Add (element_initializer.Name);
                                        } else if (initializer is CompletingExpression){
                                                initializer.Resolve (ec);
@@ -9826,11 +9862,11 @@ namespace Mono.CSharp {
                        if (parameters == null)
                                return base.CreateExpressionTree (ec);
 
-                       var init = new ArrayList (parameters.Count);
+                       var init = new ArrayInitializer (parameters.Count, loc);
                        foreach (Property p in anonymous_type.Properties)
                                init.Add (new TypeOfMethod (TypeBuilder.GetMethod (type, p.GetBuilder), loc));
 
-                       var ctor_args = new ArrayList (Arguments.Count);
+                       var ctor_args = new ArrayInitializer (Arguments.Count, loc);
                        foreach (Argument a in Arguments)
                                ctor_args.Add (a.CreateExpressionTree (ec));
 
index 50520b9d30217b0c21110905e5276e026bfdb278..ddf34fbd5be22d94593e4b0bf782ec1f478049f4 100644 (file)
@@ -14,7 +14,6 @@ using System;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Globalization;
-using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 using System.Text.RegularExpressions;
@@ -1950,10 +1949,8 @@ namespace Mono.CSharp {
                }
        }
 
-       public partial class TypeManager
+       partial class TypeManager
        {
-               static public Type activator_type;
-       
                public static TypeContainer LookupGenericTypeContainer (Type t)
                {
                        t = DropGenericTypeArguments (t);
index 7a8c39f81c6c7c3cec90f6be368b2727a81277e7..480185af63eef61c7f9839ff6fa54e2cbe2a42dd 100644 (file)
@@ -9,7 +9,6 @@
 // Copyright 2003-2008 Novell, Inc.
 //
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Reflection;
 
@@ -111,9 +110,9 @@ namespace Mono.CSharp {
                //
                // Returns the types starting with the given prefix
                //
-               public ICollection CompletionGetTypesStartingWith (string prefix)
+               public ICollection<string> CompletionGetTypesStartingWith (string prefix)
                {
-                       Hashtable result = null;
+                       Dictionary<string, string> result = null;
 
                        foreach (Assembly a in referenced_assemblies){
                                Type [] mtypes = a.GetTypes ();
@@ -121,15 +120,15 @@ namespace Mono.CSharp {
                                foreach (Type t in mtypes){
                                        string f = t.FullName;
 
-                                       if (f.StartsWith (prefix) && (result == null || !result.Contains (f))){
+                                       if (f.StartsWith (prefix) && (result == null || !result.ContainsKey (f))){
                                                if (result == null)
-                                                       result = new Hashtable ();
+                                                       result = new Dictionary<string, string> ();
 
                                                result [f] = f;
                                        }
                                }
                        }
-                       return result == null ? result : result.Keys;
+                       return result == null ? null : result.Keys;
                }
                
                protected static void Error_AmbiguousPredefinedType (CompilerContext ctx, Location loc, string name, Type type)
@@ -555,10 +554,10 @@ namespace Mono.CSharp {
                //
                // Completes types with the given `prefix' and stores the results in `result'
                //
-               public void CompletionGetTypesStartingWith (string prefix, Hashtable result)
+               public void CompletionGetTypesStartingWith (string prefix, Dictionary<string, string> result)
                {
                        int l = fullname.Length + 1;
-                       ICollection res = root.CompletionGetTypesStartingWith (fullname + "." + prefix);
+                       var res = root.CompletionGetTypesStartingWith (fullname + "." + prefix);
 
                        if (res == null)
                                return;
@@ -579,7 +578,7 @@ namespace Mono.CSharp {
                                if (p != -1)
                                        x = x.Substring (0, p) + "<";
 
-                               if (!result.Contains (x))
+                               if (!result.ContainsKey (x))
                                        result [x] = x;
                        }
                }
@@ -603,16 +602,15 @@ namespace Mono.CSharp {
                /// 
                /// Looks for extension method in this namespace
                /// 
-               public ArrayList LookupExtensionMethod (Type extensionType, ClassOrStruct currentClass, string name)
+               public List<MethodBase> LookupExtensionMethod (Type extensionType, ClassOrStruct currentClass, string name)
                {
-                       ArrayList found = null;
+                       List<MethodBase> found = null;
 
                        // TODO: problematic
                        var invocation_assembly = CodeGen.Assembly.Builder;
 
                        if (declspaces != null) {
-                               IEnumerator e = declspaces.Values.GetEnumerator ();
-                               e.Reset ();
+                               var e = declspaces.Values.GetEnumerator ();
                                while (e.MoveNext ()) {
                                        Class c = e.Current as Class;
                                        if (c == null)
@@ -621,7 +619,7 @@ namespace Mono.CSharp {
                                        if ((c.ModFlags & Modifiers.METHOD_EXTENSION) == 0)
                                                continue;
 
-                                       ArrayList res = c.MemberCache.FindExtensionMethods (invocation_assembly, extensionType, name, c != currentClass);
+                                       var res = c.MemberCache.FindExtensionMethods (invocation_assembly, extensionType, name, c != currentClass);
                                        if (res == null)
                                                continue;
 
@@ -637,7 +635,7 @@ namespace Mono.CSharp {
 
                        foreach (Type t in external_exmethod_classes) {
                                MemberCache m = TypeHandle.GetMemberCache (t);
-                               ArrayList res = m.FindExtensionMethods (invocation_assembly, extensionType, name, true);
+                               var res = m.FindExtensionMethods (invocation_assembly, extensionType, name, true);
                                if (res == null)
                                        continue;
 
@@ -683,7 +681,7 @@ namespace Mono.CSharp {
        //
        public class NamespaceEntry : IMemberContext {
 
-               class UsingEntry {
+               public class UsingEntry {
                        readonly MemberName name;
                        Namespace resolved;
                        
@@ -734,7 +732,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               class UsingAliasEntry {
+               public class UsingAliasEntry {
                        public readonly string Alias;
                        public Location Location;
 
@@ -806,7 +804,7 @@ namespace Mono.CSharp {
 
                // Namespace using import block
                List<UsingAliasEntry> using_aliases;
-               ArrayList using_clauses;
+               List<UsingEntry> using_clauses;
                public bool DeclarationFound;
                // End
 
@@ -815,11 +813,11 @@ namespace Mono.CSharp {
                static readonly Namespace [] empty_namespaces = new Namespace [0];
                Namespace [] namespace_using_table;
 
-               static ArrayList entries = new ArrayList ();
+               static List<NamespaceEntry> entries = new List<NamespaceEntry> ();
 
                public static void Reset ()
                {
-                       entries = new ArrayList ();
+                       entries = new List<NamespaceEntry> ();
                }
 
                public NamespaceEntry (NamespaceEntry parent, CompilationUnit file, string name)
@@ -850,7 +848,7 @@ namespace Mono.CSharp {
                // Populates the Namespace with some using declarations, used by the
                // eval mode. 
                //
-               public void Populate (ArrayList source_using_aliases, ArrayList source_using_clauses)
+               public void Populate (List<UsingAliasEntry> source_using_aliases, List<UsingEntry> source_using_clauses)
                {
                        foreach (UsingAliasEntry uae in source_using_aliases){
                                if (using_aliases == null)
@@ -861,7 +859,7 @@ namespace Mono.CSharp {
 
                        foreach (UsingEntry ue in source_using_clauses){
                                if (using_clauses == null)
-                                       using_clauses = new ArrayList ();
+                                       using_clauses = new List<UsingEntry> ();
                                
                                using_clauses.Add (ue);
                        }
@@ -872,7 +870,7 @@ namespace Mono.CSharp {
                // arrays that might already have the same information;  Used by the
                // C# Eval mode.
                //
-               public void Extract (ArrayList out_using_aliases, ArrayList out_using_clauses)
+               public void Extract (List<UsingAliasEntry> out_using_aliases, List<UsingEntry> out_using_clauses)
                {
                        if (using_aliases != null){
                                foreach (UsingAliasEntry uae in using_aliases){
@@ -959,7 +957,7 @@ namespace Mono.CSharp {
                        }
 
                        if (using_clauses == null) {
-                               using_clauses = new ArrayList ();
+                               using_clauses = new List<UsingEntry> ();
                        } else {
                                foreach (UsingEntry old_entry in using_clauses) {
                                        if (name.Equals (old_entry.MemberName)) {
@@ -1035,9 +1033,9 @@ namespace Mono.CSharp {
                ///
                public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
                {
-                       ArrayList candidates = null;
+                       List<MethodBase> candidates = null;
                        foreach (Namespace n in GetUsingTable ()) {
-                               ArrayList a = n.LookupExtensionMethod (extensionType, null, name);
+                               var a = n.LookupExtensionMethod (extensionType, null, name);
                                if (a == null)
                                        continue;
 
@@ -1082,9 +1080,9 @@ namespace Mono.CSharp {
                        return resolved;
                }
 
-               public ICollection CompletionGetTypesStartingWith (string prefix)
+               public ICollection<string> CompletionGetTypesStartingWith (string prefix)
                {
-                       Hashtable result = new Hashtable ();
+                       var result = new Dictionary<string, string> ();
                        
                        for (NamespaceEntry curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent){
                                foreach (Namespace using_ns in GetUsingTable ()){
@@ -1193,7 +1191,7 @@ namespace Mono.CSharp {
                                return namespace_using_table;
                        }
 
-                       ArrayList list = new ArrayList (using_clauses.Count);
+                       var list = new List<Namespace> (using_clauses.Count);
 
                        foreach (UsingEntry ue in using_clauses) {
                                Namespace using_ns = ue.Resolve (Doppelganger);
@@ -1203,7 +1201,7 @@ namespace Mono.CSharp {
                                list.Add (using_ns);
                        }
 
-                       namespace_using_table = (Namespace[])list.ToArray (typeof (Namespace));
+                       namespace_using_table = list.ToArray ();
                        return namespace_using_table;
                }
 
index e3cb8df376ac55b7ae0c97f451b3e82586b159b8..e6761d38096d1254f2da733c077eabfbf62ac70e 100644 (file)
@@ -13,7 +13,6 @@
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
-using System.Collections;
 using System.Text;
 
 namespace Mono.CSharp {
@@ -1184,7 +1183,7 @@ namespace Mono.CSharp {
 
                public Expression CreateExpressionTree (BlockContext ec, Location loc)
                {
-                       var initializers = new ArrayList (Count);
+                       var initializers = new ArrayInitializer (Count, loc);
                        foreach (Parameter p in FixedParameters) {
                                //
                                // Each parameter expression is stored to local variable
index a3d893b7f9f3fef8c17822d874baca3d7f231ee5..610213e405f233b1e5185682ea9b13dc363f2f16 100644 (file)
@@ -15,7 +15,6 @@ using System.Text;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Diagnostics;
-using System.Collections;
 using System.Collections.Generic;
 
 namespace Mono.CSharp {
@@ -3750,7 +3749,7 @@ namespace Mono.CSharp {
                                                continue;
 
                                        value = (string) sl.Converted;
-                                       ArrayList init_args = new ArrayList (2);
+                                       var init_args = new List<Expression> (2);
                                        init_args.Add (new StringLiteral (value, sl.Location));
                                        init_args.Add (new IntConstant (counter, loc));
                                        init.Add (new CollectionElementInitializer (init_args, loc));
index 88a58f66bf5b3c2dcaf5bd2ac8f86a04e2e1b1d8..433012e90f4016dc2691c744704ad8d485f4a18e 100644 (file)
@@ -39,6 +39,18 @@ namespace Mono.CSharp {
                }
        }
 
+       class Tuple<T1, T2>
+       {
+               public Tuple (T1 item1, T2 item2)
+               {
+                       Item1 = item1;
+                       Item2 = item2;
+               }
+
+               public T1 Item1 { get; private set; }
+               public T2 Item2 { get; private set; }
+       }
+
        public class Accessors {
                public Accessor get_or_add;
                public Accessor set_or_remove;
index 12fa163d966a79711e7343bd2d1bcfaf787258e3..acdaff64e7c6b286082178617bebf8183885ffd9 100644 (file)
@@ -9,7 +9,6 @@
 //
 
 using System;
-using System.Collections;
 using System.Reflection;
 using System.Reflection.Emit;
 
index 15d9367736e0b159c1f4e715c99430ed6bd494d0..4f053063020a59394e94c5bba6f3db5cd58b8a83 100644 (file)
@@ -3256,7 +3256,7 @@ namespace Mono.CSharp {
 /// <summary>
 ///   There is exactly one instance of this class per type.
 /// </summary>
-public sealed class TypeHandle : IMemberContainer {
+sealed class TypeHandle : IMemberContainer {
        public readonly IMemberContainer BaseType;
 
        readonly int id = ++next_id;