2 // roottypes.cs: keeps a tree representation of the generated code
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
13 using System.Collections;
14 using System.Reflection;
15 using System.Reflection.Emit;
21 // We store here all the toplevel types that we have parsed,
22 // this is the root of all information we have parsed.
24 public sealed class RootTypes : TypeContainer
26 // TODO: It'd be so nice to have generics
27 Hashtable anonymous_types;
30 : base (null, null, MemberName.Null, null, Kind.Root)
32 types = new ArrayList ();
33 anonymous_types = new Hashtable ();
36 public void AddAnonymousType (AnonymousTypeClass type)
38 ArrayList existing = (ArrayList)anonymous_types [type.Parameters.Count];
39 if (existing == null) {
40 existing = new ArrayList ();
41 anonymous_types.Add (type.Parameters.Count, existing);
46 public override bool IsClsComplianceRequired ()
51 public AnonymousTypeClass GetAnonymousType (ArrayList parameters)
53 ArrayList candidates = (ArrayList) anonymous_types [parameters.Count];
54 if (candidates == null)
58 foreach (AnonymousTypeClass at in candidates) {
59 for (i = 0; i < parameters.Count; ++i) {
60 if (!parameters [i].Equals (at.Parameters [i]))
64 if (i == parameters.Count)
71 public override bool GetClsCompliantAttributeValue ()
73 return CodeGen.Assembly.IsClsCompliant;
76 public override string GetSignatureForError ()
81 protected override bool AddMemberType (DeclSpace ds)
83 if (!AddToContainer (ds, ds.Name))
85 ds.NamespaceEntry.NS.AddDeclSpace (ds.Basename, ds);
89 public override TypeContainer AddPartial (TypeContainer nextPart)
91 return AddPartial (nextPart, nextPart.Name);
95 public class RootDeclSpace : DeclSpace {
96 public RootDeclSpace (NamespaceEntry ns)
97 : base (ns, null, MemberName.Null, null)
99 PartialContainer = RootContext.ToplevelTypes;
102 public override AttributeTargets AttributeTargets {
103 get { throw new InternalErrorException ("should not be called"); }
106 public override string DocCommentHeader {
107 get { throw new InternalErrorException ("should not be called"); }
110 public override bool Define ()
112 throw new InternalErrorException ("should not be called");
115 public override TypeBuilder DefineType ()
117 throw new InternalErrorException ("should not be called");
120 public override MemberList FindMembers (MemberTypes mt, BindingFlags bf, MemberFilter filter, object criteria)
122 throw new InternalErrorException ("should not be called");
125 public override MemberCache MemberCache {
126 get { return PartialContainer.MemberCache; }
129 public override bool GetClsCompliantAttributeValue ()
131 return PartialContainer.GetClsCompliantAttributeValue ();
134 public override bool IsClsComplianceRequired ()
136 return PartialContainer.IsClsComplianceRequired ();