2002-11-16 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / mcs / interface.cs
index dce7b2c5f1eb0d94b5177a0f2e2fe7b6d8991443..2c5b939f41e93f6902ef39ac9182bc7e6281993e 100755 (executable)
@@ -53,6 +53,8 @@ namespace Mono.CSharp {
                IMemberContainer parent_container;
                MemberCache member_cache;
 
+               bool members_defined;
+
                // These will happen after the semantic analysis
                
                // Hashtable defined_indexers;
@@ -228,9 +230,22 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public MethodInfo [] GetMethods ()
+               //
+               // This might trigger a definition of the methods.  This happens only
+               // with Attributes, as Attribute classes are processed before interfaces.
+               // Ideally, we should make everything just define recursively in terms
+               // of its dependencies.
+               //
+               public MethodInfo [] GetMethods (TypeContainer container)
                {
-                       int n = method_builders.Count;
+                       int n = 0;
+                       
+                       if (!members_defined){
+                               if (DefineMembers (container))
+                                       n = method_builders.Count;
+                       } else
+                               n = method_builders.Count;
+                       
                        MethodInfo [] mi = new MethodInfo [n];
                        
                        method_builders.CopyTo (mi, 0);
@@ -297,6 +312,9 @@ namespace Mono.CSharp {
                        if (return_type.IsPointer && !UnsafeOK (this))
                                return;
 
+                       if (arg_types == null)
+                               return;
+
                        foreach (Type t in arg_types){
 
                                if (t == null)
@@ -348,6 +366,9 @@ namespace Mono.CSharp {
                        PropertyBuilder pb;
                        MethodBuilder get = null, set = null;
                        ip.Type = this.ResolveTypeExpr (ip.Type, false, ip.Location);
+                       if (ip.Type == null)
+                               return;
+                       
                        Type prop_type = ip.Type.Type;
                        Type [] setter_args = new Type [1];
 
@@ -433,6 +454,9 @@ namespace Mono.CSharp {
                        MyEventBuilder eb;
                        MethodBuilder add = null, remove = null;
                        ie.Type = this.ResolveTypeExpr (ie.Type, false, ie.Location);
+                       if (ie.Type == null)
+                               return;
+                       
                        Type event_type = ie.Type.Type;
 
                        if (event_type == null)
@@ -444,7 +468,7 @@ namespace Mono.CSharp {
                        Type [] parameters = new Type [1];
                        parameters [0] = event_type;
 
-                       eb = new MyEventBuilder (TypeBuilder, ie.Name,
+                       eb = new MyEventBuilder (null, TypeBuilder, ie.Name,
                                                 EventAttributes.None, event_type);
 
                        //
@@ -496,6 +520,9 @@ namespace Mono.CSharp {
                {
                        PropertyBuilder pb;
                        ii.Type = this.ResolveTypeExpr (ii.Type, false, ii.Location);
+                       if (ii.Type == null)
+                               return;
+                       
                        Type prop_type = ii.Type.Type;
                        Type [] arg_types = ii.ParameterTypes (this);
                        Type [] value_arg_types;
@@ -639,7 +666,7 @@ namespace Mono.CSharp {
 
                Type GetInterfaceTypeByName (string name)
                {
-                       Type t = FindType (name);
+                       Type t = FindType (Location, name);
 
                        if (t == null) {
                                Report.Error (246, Location, "The type or namespace `" + name +
@@ -832,7 +859,7 @@ namespace Mono.CSharp {
 
                        member_cache = new MemberCache (this);
 #endif
-
+                       members_defined = true;
                        return true;
                }