Added few unsafe tests.
[mono.git] / mcs / mcs / roottypes.cs
index bfc7f7b8d28494078fb90e2f4c65033ed97ea191..d2492778b419e13e8d28776ff1fb17aa030dd876 100644 (file)
@@ -3,10 +3,10 @@
 //
 // Author: Miguel de Icaza (miguel@gnu.org)
 //
-// Licensed under the terms of the GNU GPL
-//
-// (C) 2001 Ximian, Inc (http://www.ximian.com)
+// Dual licensed under the terms of the MIT X11 or GNU GPL
 //
+// Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+// Copyright 2003-2008 Novell, Inc.
 //
 
 using System;
@@ -23,10 +23,24 @@ namespace Mono.CSharp
        // </summary>
        public sealed class RootTypes : TypeContainer
        {
+               // TODO: It'd be so nice to have generics
+               Hashtable anonymous_types;
+
                public RootTypes ()
                        : base (null, null, MemberName.Null, null, Kind.Root)
                {
                        types = new ArrayList ();
+                       anonymous_types = new Hashtable ();
+               }
+
+               public void AddAnonymousType (AnonymousTypeClass type)
+               {
+                       ArrayList existing = (ArrayList)anonymous_types [type.Parameters.Count];
+                       if (existing == null) {
+                               existing = new ArrayList ();
+                               anonymous_types.Add (type.Parameters.Count, existing);
+                       }
+                       existing.Add (type);
                }
 
                public override bool IsClsComplianceRequired ()
@@ -34,6 +48,26 @@ namespace Mono.CSharp
                        return true;
                }
 
+               public AnonymousTypeClass GetAnonymousType (ArrayList parameters)
+               {
+                       ArrayList candidates = (ArrayList) anonymous_types [parameters.Count];
+                       if (candidates == null)
+                               return null;
+
+                       int i;
+                       foreach (AnonymousTypeClass at in candidates) {
+                               for (i = 0; i < parameters.Count; ++i) {
+                                       if (!parameters [i].Equals (at.Parameters [i]))
+                                               break;
+                               }
+
+                               if (i == parameters.Count)
+                                       return at;
+                       }
+
+                       return null;
+               }
+
                public override bool GetClsCompliantAttributeValue ()
                {
                        return CodeGen.Assembly.IsClsCompliant;
@@ -52,9 +86,9 @@ namespace Mono.CSharp
                        return true;
                }
 
-               public override TypeContainer AddPartial (TypeContainer nextPart, bool is_interface)
+               public override TypeContainer AddPartial (TypeContainer nextPart)
                {
-                       return AddPartial (nextPart, nextPart.Name, is_interface);
+                       return AddPartial (nextPart, nextPart.Name);
                }
        }
 
@@ -83,11 +117,6 @@ namespace Mono.CSharp
                        throw new InternalErrorException ("should not be called");
                }
 
-               public override MemberList FindMembers (MemberTypes mt, BindingFlags bf, MemberFilter filter, object criteria)
-               {
-                       throw new InternalErrorException ("should not be called");
-               }
-
                public override MemberCache MemberCache {
                        get { return PartialContainer.MemberCache; }
                }