2006-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / mbas / decl.cs
index ee5cf68e2cf30398c1a74570ceadd4e51a8cd3f0..4f17b3520e3d48ef8924f8b8a5c6a296e8fd08f8 100644 (file)
@@ -21,7 +21,8 @@ namespace Mono.MonoBASIC {
        ///   Base representation for members.  This is only used to keep track
        ///   of Name, Location and Modifier flags.
        /// </summary>
-       public abstract class MemberCore {
+       public abstract class MemberCore : Attributable
+       {
                /// <summary>
                ///   Public name
                /// </summary>
@@ -37,7 +38,8 @@ namespace Mono.MonoBASIC {
                /// </summary>
                public readonly Location Location;
 
-               public MemberCore (string name, Location loc)
+               public MemberCore (string name, Attributes attrs, Location loc)
+                       : base (attrs)
                {
                        Name = name;
                        Location = loc;
@@ -59,7 +61,7 @@ namespace Mono.MonoBASIC {
                        // FIXME: report the old/new permissions?
                        //
                        Report.Error (
-                               507, Location, parent.MakeName (Name) +
+                               31048, Location, parent.MakeName (Name) +
                                ": can't change the access modifiers when overriding inherited " +
                                "member `" + name + "'");
                }
@@ -78,7 +80,7 @@ namespace Mono.MonoBASIC {
 
                        if ((ModFlags & Modifiers.OVERRIDE) != 0){
                                // Now we check that the overriden method is not final
-                               if (mb.IsFinal) \r
+                               if (mb.IsFinal) 
                                {
                                        Report.Error (30267, Location, parent.MakeName (Name) + " : cannot " +
                                                "override inherited member `" + name +
@@ -196,15 +198,6 @@ namespace Mono.MonoBASIC {
                        /// </summary>
                        NameExists,
 
-                       /// <summary>
-                       ///   Returned if the declation being added to the
-                       ///   name space clashes with its container name.
-                       ///
-                       ///   The only exceptions for this are constructors
-                       ///   and static constructors
-                       /// </summary>
-                       EnclosingClash,
-
                        /// <summary>
                        ///   Returned if a constructor was created (because syntactically
                        ///   it looked like a constructor) but was not (because the name
@@ -257,8 +250,8 @@ namespace Mono.MonoBASIC {
 
                TypeContainer parent;           
 
-               public DeclSpace (TypeContainer parent, string name, Location l)
-                       : base (name, l)
+               public DeclSpace (TypeContainer parent, string name, Attributes attrs, Location l)
+                       : base (name, attrs, l)
                {
                        Basename = name.Substring (1 + name.LastIndexOf ('.'));
                        defined_names = new Hashtable ();
@@ -271,9 +264,6 @@ namespace Mono.MonoBASIC {
                /// </summary>
                protected AdditionResult IsValid (string name)
                {
-                       if (name == Basename)
-                               return AdditionResult.EnclosingClash;
-
                        if (defined_names.Contains (name))
                                return AdditionResult.NameExists;
 
@@ -426,7 +416,7 @@ namespace Mono.MonoBASIC {
                        Expression d = e.Resolve (type_resolve_ec, ResolveFlags.Type);
                        if (d == null || d.eclass != ExprClass.Type){
                                if (!silent && errors == Report.Errors){
-                                       Report.Error (246, loc, "Cannot find type `"+ e.ToString () +"'");
+                                       Report.Error (30002, loc, "Cannot find type `"+ e.ToString () +"'");
                                }
                                return null;
                        }
@@ -446,7 +436,7 @@ namespace Mono.MonoBASIC {
                        Expression d = e.Resolve (type_resolve_ec, ResolveFlags.Type);
                        if (d == null || d.eclass != ExprClass.Type){
                                if (!silent){
-                                       Report.Error (246, loc, "Cannot find type `"+ e +"'");
+                                       Report.Error (30002, loc, "Cannot find type `"+ e +"'");
                                }
                                return null;
                        }
@@ -567,10 +557,10 @@ namespace Mono.MonoBASIC {
                                //
                                // Now check the using clause list
                                //
-                               ICollection imports_list = RootContext.SourceBeingCompiled.ImportsTable;\r
-\r
-                               if (imports_list == null)\r
-                                       continue;\r
+                               ICollection imports_list = RootContext.SourceBeingCompiled.ImportsTable;
+
+                               if (imports_list == null)
+                                       continue;
 
                                Type match = null;
                                foreach (SourceBeingCompiled.ImportsEntry ue in imports_list){
@@ -611,8 +601,24 @@ namespace Mono.MonoBASIC {
                public abstract MemberCache MemberCache {
                        get;
                }
+
+               public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+               {
+                       try {
+                               TypeBuilder.SetCustomAttribute (cb);
+                       } catch (System.ArgumentException e) {
+                               Report.Warning (-21, a.Location,
+                                               "The CharSet named property on StructLayout\n"+
+                                               "\tdoes not work correctly on Microsoft.NET\n"+
+                                               "\tYou might want to remove the CharSet declaration\n"+
+                                               "\tor compile using the Mono runtime instead of the\n"+
+                                               "\tMicrosoft .NET runtime\n"+
+                                               "\tThe runtime gave the error: " + e);
+                       }
+               }
        }
 
+
        /// <summary>
        ///   This is a readonly list of MemberInfo's.      
        /// </summary>
@@ -885,7 +891,10 @@ namespace Mono.MonoBASIC {
 
                        IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
                        while (it.MoveNext ()) {
-                               hash [it.Key] = ((ArrayList) it.Value).Clone ();
+                               ArrayList al = (ArrayList) it.Value;
+                               // Constructors are never inherited and all have the same key
+                               if ((((CacheEntry)al [0]).EntryType & EntryType.Constructor) == 0)
+                                       hash [it.Key] = ((ArrayList) it.Value).Clone ();
                        }
 
                        return hash;
@@ -975,9 +984,9 @@ namespace Mono.MonoBASIC {
                void AddMembers (MemberTypes mt, BindingFlags bf, IMemberContainer container)
                {
                        MemberList members = container.GetMembers (mt, bf);
-                       BindingFlags new_bf = (container == Container) ?
+                       /*BindingFlags new_bf = (container == Container) ?
                                bf | BindingFlags.DeclaredOnly : bf;
-
+                       */
                        foreach (MemberInfo member in members) {
                                string name = member.Name;
 
@@ -1221,7 +1230,8 @@ bf |= BindingFlags.IgnoreCase;
                                // iteration of this loop if there are no members with the name we're
                                // looking for in the current class).
                                if (entry.Container != current) {
-                                       if (declared_only || DoneSearching (list))
+                                       //if (declared_only || DoneSearching (list))
+                                       if (declared_only)
                                                break;
 
                                        current = entry.Container;