Merge pull request #2528 from vargaz/jit-errors2
[mono.git] / mcs / mcs / modifiers.cs
index 788c1f891e001036adb75aead377ccb82673af5e..bfae5985a0345f1d5058e6e6586618d0fd185ba1 100644 (file)
@@ -1,18 +1,28 @@
 //
-// modifiers.cs: Modifier handling.
-// 
+// modifiers.cs: Modifiers handling
+//
+// Authors: Miguel de Icaza (miguel@gnu.org)
+//          Marek Safar (marek.safar@gmail.com)
+//
+// Dual licensed under the terms of the MIT X11 or GNU GPL
+//
+// Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
+// Copyright 2004-2010 Novell, Inc
+//
+
 using System;
+
+#if STATIC
+using IKVM.Reflection;
+#else
 using System.Reflection;
+#endif
 
 namespace Mono.CSharp
 {
        [Flags]
        public enum Modifiers
        {
-               //
-               // The ordering of the following 4 constants
-               // has been carefully done.
-               //
                PROTECTED = 0x0001,
                PUBLIC    = 0x0002,
                PRIVATE   = 0x0004,
@@ -27,19 +37,22 @@ namespace Mono.CSharp
                EXTERN    = 0x0800,
                VOLATILE  = 0x1000,
                UNSAFE    = 0x2000,
-               TOP       = 0x4000,
+               ASYNC     = 0x4000,
+               TOP       = 0x8000,
 
                //
                // Compiler specific flags
                //
-               PROPERTY_CUSTOM                 = 0x4000,
-               OVERRIDE_UNCHECKED              = 0x8000,
+               PROPERTY_CUSTOM                 = 0x10000,
+
                PARTIAL                                 = 0x20000,
-               DEFAULT_ACCESS_MODIFER  = 0x40000,
+               DEFAULT_ACCESS_MODIFIER = 0x40000,
                METHOD_EXTENSION                = 0x80000,
                COMPILER_GENERATED              = 0x100000,
                BACKING_FIELD                   = 0x200000,
                DEBUGGER_HIDDEN                 = 0x400000,
+               DEBUGGER_STEP_THROUGH   = 0x800000,
+               AutoProperty                    = 0x1000000,
 
                AccessibilityMask = PUBLIC | PROTECTED | INTERNAL | PRIVATE,
                AllowedExplicitImplFlags = UNSAFE | EXTERN,
@@ -98,6 +111,8 @@ namespace Mono.CSharp
                                s = "volatile"; break;
                        case Modifiers.UNSAFE:
                                s = "unsafe"; break;
+                       case Modifiers.ASYNC:
+                               s = "async"; break;
                        }
 
                        return s;
@@ -235,11 +250,6 @@ namespace Mono.CSharp
                        int i;
 
                        if (invalid_flags == 0){
-
-                               if ((mod & Modifiers.UNSAFE) != 0){
-                                       RootContext.CheckUnsafeOption (l, Report);
-                               }
-                               
                                //
                                // If no accessibility bits provided
                                // then provide the defaults.
@@ -247,40 +257,27 @@ namespace Mono.CSharp
                                if ((mod & Modifiers.AccessibilityMask) == 0) {
                                        mod |= def_access;
                                        if (def_access != 0)
-                                               mod |= Modifiers.DEFAULT_ACCESS_MODIFER;
+                                               mod |= Modifiers.DEFAULT_ACCESS_MODIFIER;
                                        return mod;
                                }
 
-                               //
-                               // Make sure that no conflicting accessibility
-                               // bits have been set.  Protected+Internal is
-                               // allowed, that is why they are placed on bits
-                               // 1 and 4 (so the shift 3 basically merges them)
-                               //
-                               int a = (int) mod;
-                               a &= 15;
-                               a |= (a >> 3);
-                               a = ((a & 2) >> 1) + (a & 5);
-                               a = ((a & 4) >> 2) + (a & 3);
-                               if (a > 1)
-                                       Report.Error (107, l, "More than one protection modifier specified");
-                               
                                return mod;
                        }
 
-                       for (i = 1; i <= (int) Modifiers.TOP; i <<= 1) {
+                       for (i = 1; i < (int) Modifiers.TOP; i <<= 1) {
                                if ((i & invalid_flags) == 0)
                                        continue;
 
-                               Error_InvalidModifier (l, Name ((Modifiers) i), Report);
+                               Error_InvalidModifier ((Modifiers)i, l, Report);
                        }
 
                        return allowed & mod;
                }
 
-               public static void Error_InvalidModifier (Location l, string name, Report Report)
+               static void Error_InvalidModifier (Modifiers mod, Location l, Report Report)
                {
-                       Report.Error (106, l, "The modifier `{0}' is not valid for this item", name);
+                       Report.Error (106, l, "The modifier `{0}' is not valid for this item",
+                               Name (mod));
                }
        }
 }