2007-10-19 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / mcs / modifiers.cs
index 441e6ff83d3ab6f89d977314117b24c3e2e01c9c..dae3dd86a09a5e6323df8e680d7394d3b4db07a3 100644 (file)
@@ -25,16 +25,19 @@ namespace Mono.CSharp {
                public const int EXTERN    = 0x0800;
                public const int VOLATILE  = 0x1000;
                public const int UNSAFE    = 0x2000;
-               public const int TOP       = 0x2000;
+               private const int TOP      = 0x2000;
 
                public const int PROPERTY_CUSTOM = 0x4000; // Custom property modifier
-               public const int PARTIAL   = 0x20000;
 
                //
                // We use this internally to flag that the method contains an iterator
                //
-               public const int METHOD_YIELDS = 0x8000;
-               public const int METHOD_GENERIC = 0x10000;
+               public const int METHOD_YIELDS                  = 0x8000;
+               public const int METHOD_GENERIC                 = 0x10000;
+               public const int PARTIAL                                        = 0x20000;
+               public const int DEFAULT_ACCESS_MODIFER = 0x40000;
+               public const int METHOD_EXTENSION               = 0x80000;
+               public const int COMPILER_GENERATED             = 0x100000;
 
                public const int Accessibility =
                        PUBLIC | PROTECTED | INTERNAL | PRIVATE;
@@ -128,19 +131,6 @@ namespace Mono.CSharp {
 
                        return t;
                }
-               
-               public static TypeAttributes TypeAttr (int mod_flags, TypeContainer caller)
-               {
-                       TypeAttributes t = TypeAttr (mod_flags, caller.IsTopLevel);
-
-                       // If we do not have static constructors, static methods
-                       // can be invoked without initializing the type.
-                       if (!caller.UserDefinedStaticConstructor &&
-                           (caller.Kind != Kind.Interface))
-                               t |= TypeAttributes.BeforeFieldInit;
-                               
-                       return t;
-               }
 
                public static FieldAttributes FieldAttr (int mod_flags)
                {
@@ -214,7 +204,7 @@ namespace Mono.CSharp {
                // </summary>
                public static int Check (int allowed, int mod, int def_access, Location l)
                {
-                       int invalid_flags  = (~allowed) & mod;
+                       int invalid_flags  = (~allowed) & (mod & (Modifiers.TOP - 1));
                        int i;
 
                        if (invalid_flags == 0){
@@ -230,6 +220,8 @@ namespace Mono.CSharp {
                                //
                                if ((mod & Accessibility) == 0){
                                        mod |= def_access;
+                                       if (def_access != 0)
+                                               mod |= DEFAULT_ACCESS_MODIFER;
                                        return mod;
                                }