2006-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / mbas / class.cs
index 82a432770ee608ea0fe621cfb507b9cc9d4d18d3..535d3d5ac6755228a083badbcba8f08eadfda0b5 100644 (file)
@@ -83,7 +83,7 @@ namespace Mono.MonoBASIC {
                // Holds the events
                ArrayList events;
 
-               // Holds AddHandlers stements for events
+               // Holds AddHandlers statements for events
                ArrayList handlers;
 
                // The emit context for toplevel objects.
@@ -256,9 +256,6 @@ namespace Mono.MonoBASIC {
                        if (value != null && (!(value is Method)))
                                return AdditionResult.NameExists;
 
-                       if (basename == Basename)
-                               return AdditionResult.EnclosingClash;
-                       
                        if (methods == null)
                                methods = new ArrayList ();
 
@@ -691,7 +688,7 @@ namespace Mono.MonoBASIC {
                                                                "'NotInheritable' class " + TypeManager.MonoBASIC_Name (parent));
                                        
                                if (!AsAccessible (parent, ModFlags))
-                                       Report.Error (30389, Location,
+                                        Report.Error (30389, Location,
                                                      "Inconsistent accessibility: base class `" +
                                                      TypeManager.MonoBASIC_Name (parent) + "' is less " +
                                                      "accessible than class `" +
@@ -714,7 +711,7 @@ namespace Mono.MonoBASIC {
                                }
 
                                if (is_class == false && !t.IsInterface){
-                                       Report.Error (527, "In Struct `" + Name + "', type `"+
+                                       Report.Error (527, Location, "In Struct `" + Name + "', type `"+
                                                      name +"' is not an interface");
                                        error = true;
                                        return null;
@@ -722,10 +719,10 @@ namespace Mono.MonoBASIC {
                        
                                if (t.IsSealed) {
                                        if (t.IsValueType)
-                                               Report.Error (30258, "class `"+ Name +
+                                               Report.Error (30258, Location, "class `"+ Name +
                                                        "': a class can not inherit from a struct/enum");
                                                        
-                                       /*Report.Error (509, "class `"+ Name +
+                                       /*Report.Error (509, Location, "class `"+ Name +
                                                      "': Cannot inherit from sealed class `"+
                                                      bases [i]);*/
                                        error = true;
@@ -734,7 +731,7 @@ namespace Mono.MonoBASIC {
 
                                if (t.IsClass) {
                                        if (parent != null){
-                                               Report.Error (30121, Name + ": A class cannot inherit " +
+                                               Report.Error (30121, Location, Name + ": A class cannot inherit " +
                                                        "more than one class");
                                                error = true;
                                                return null;
@@ -743,7 +740,7 @@ namespace Mono.MonoBASIC {
 
                                for (int x = 0; x < j; x++) {
                                        if (t == ifaces [x]) {
-                                               Report.Error (528, "`" + name + "' is already listed in interface list");
+                                               Report.Error (528,Location, "`" + name + "' is already listed in interface list");
                                                error = true;
                                                return null;
                                        }
@@ -871,8 +868,14 @@ namespace Mono.MonoBASIC {
                            (base_class_type == TypeManager.attribute_type ||
                             base_class_type.IsSubclassOf (TypeManager.attribute_type))) {
                                RootContext.RegisterAttribute (this);
-                       } else
-                               RootContext.RegisterOrder (this); 
+                       }
+                       else
+                       {
+                               if ( this is Interface)
+                                       RootContext.RegisterOrder ((Interface) this); 
+                               else    
+                                       RootContext.RegisterOrder (this); 
+                       }
                                
                        if (Interfaces != null) {
                                foreach (Interface iface in Interfaces)
@@ -1455,6 +1458,9 @@ namespace Mono.MonoBASIC {
                                foreach (Field f in fields) {
                                        if ((f.ModFlags & Modifiers.PUBLIC) != 0)
                                                continue;
+                                               
+                                       if (f.Name.StartsWith(@"$STATIC$"))
+                                               continue;
 
                                        if (f.status == 0){
                                                Report.Warning (
@@ -1641,7 +1647,7 @@ namespace Mono.MonoBASIC {
                        if ((flags & Modifiers.PRIVATE) != 0){
                                if ((flags & vao) != 0){
                                        Report.Error (
-                                               31408, loc, name +
+                                               30266, loc, name +
                                                ": Members marked as Overridable or Overrides can not be Private");
                                        ok = false;
                                }
@@ -2202,7 +2208,7 @@ namespace Mono.MonoBASIC {
                                                WarningNotHiding (parent);*/
 
                                        if ((ModFlags & Modifiers.OVERRIDE) != 0){
-                                               Report.Error (30284, Location,
+                                               Report.Error (30398, Location,
                                                              parent.MakeName (Name) +
                                                              " : No suitable methods found to override");
                                        }
@@ -3304,11 +3310,14 @@ namespace Mono.MonoBASIC {
                                                TypeManager.ExpandAllInterfaces (tbases, ref bases);
 
                                                foreach (Type tbase in bases) {
+                                                       /*
                                                        string bname = tbase.Name;
                                                        if (bname.LastIndexOf(".") != -1)
                                                                bname = bname.Substring(bname.LastIndexOf("."));
+                                                       */
 
-                                                       if (bname == iname)     {
+                                                       //if (bname == iname)   {
+                                                       if (tbase == InterfaceType) {
                                                                iface_found = true;
                                                                break;
                                                        }
@@ -3331,7 +3340,7 @@ namespace Mono.MonoBASIC {
                                                      TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
                                                      "accessible than property `" + Name + "'");
                                else if (this is Method)
-                                       Report.Error (50, Location,
+                                       Report.Error (30508, Location,
                                                      "Inconsistent accessibility: return type `" +
                                                      TypeManager.MonoBASIC_Name (MemberType) + "' is less " +
                                                      "accessible than method `" + Name + "'");
@@ -3546,8 +3555,14 @@ namespace Mono.MonoBASIC {
                                              "' causes a cycle in the structure layout");
                                return false;
                        }
-                       FieldBuilder = parent.TypeBuilder.DefineField (
-                               Name, t, Modifiers.FieldAttr (ModFlags));
+                       
+                       //Local Static Variable
+                        if (Name.StartsWith(@"$STATIC$"))
+                                FieldBuilder = parent.TypeBuilder.DefineField (
+                                        Name, t, Modifiers.FieldAttr (ModFlags) | FieldAttributes.SpecialName);
+                        else
+                                FieldBuilder = parent.TypeBuilder.DefineField (
+                                        Name, t, Modifiers.FieldAttr (ModFlags));
 
                        TypeManager.RegisterFieldBase (FieldBuilder, this);
                        return true;
@@ -3849,7 +3864,6 @@ namespace Mono.MonoBASIC {
 
                        if (mi != null && mi.Count > 0) 
                                parent_member = (PropertyInfo) mi [0];
-
                        if (parent_member is PropertyInfo) {
                                PropertyInfo parent_property = (PropertyInfo)parent_member;
 
@@ -3886,20 +3900,6 @@ namespace Mono.MonoBASIC {
                                /*if ((ModFlags & Modifiers.NEW) != 0)
                                        WarningNotHiding (container);
                                */
-                               if ((ModFlags & Modifiers.OVERRIDE) != 0) {
-
-                                       /*
-                                       if (this is Indexer)
-                                               Report.Error (115, Location,
-                                                       container.MakeName (Name) +
-                                                       " no suitable indexers found to override");
-                                       else
-                                       */
-                                               Report.Error (115, Location,
-                                                       container.MakeName (Name) +
-                                                       " no suitable properties found to override");
-                                       return false;
-                               }
 
                                if ((ModFlags & ( Modifiers.NEW | Modifiers.SHADOWS | Modifiers.OVERRIDE )) == 0) {
                                        if ((ModFlags & Modifiers.NONVIRTUAL) != 0)     {
@@ -3939,9 +3939,9 @@ namespace Mono.MonoBASIC {
                        Modifiers.WRITEONLY |
                        Modifiers.SHADOWS;
 
-               string set_parameter_name;
-               Parameters get_params;
-               Parameters set_params;
+               //string set_parameter_name;
+               //Parameters get_params;
+               //Parameters set_params;
                
                public Property (Expression type, string name, int mod_flags,
                                Accessor get_block, Accessor set_block,
@@ -3978,6 +3978,12 @@ namespace Mono.MonoBASIC {
                                        "'Property' inside a 'Structure' can not be declared as " +
                                        "'Protected' or 'Protected Friend'");
 
+                       if (((ModFlags & Modifiers.DEFAULT) != 0) && (Parameters == null || Parameters.CountStandardParams () == 0)) {
+                               Report.Error (31048, Location, "Properties with no required " +
+                                       "parameters cannot be declared 'Default'");
+                               return false;
+                       }
+
                        if (!DoDefine (parent))
                                return false;