2006-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / mbas / class.cs
index 7626716053d8a4aa8e98a43559c4e4b65d96a033..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 ();
 
@@ -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 (
@@ -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;
                                                        }
@@ -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;