In mcs:
[mono.git] / mcs / mcs / rootcontext.cs
index 2837a14d83af56c98b7f3bd305a017e5e06ad206..4e1e1abfc3f14cea12cc384b4a12a6c7c1088723 100644 (file)
@@ -65,7 +65,7 @@ namespace Mono.CSharp {
                public static int WarningLevel;
                
                public static Target Target;
-               public static string TargetExt = ".exe";
+               public static string TargetExt;
 
                public static bool VerifyClsCompliance = true;
 
@@ -113,8 +113,10 @@ namespace Mono.CSharp {
                        StrongNameDelaySign = false;
                        MainClass = null;
                        Target = Target.Exe;
+                       TargetExt = ".exe";
                        Version = LanguageVersion.Default;
                        Documentation = null;
+                       impl_details_class = null;
                }
                
                public static bool NeedsEntryPoint {
@@ -144,13 +146,6 @@ namespace Mono.CSharp {
                //
                static public bool Unsafe;
                
-               static string MakeFQN (string nsn, string name)
-               {
-                       if (nsn == "")
-                               return name;
-                       return String.Concat (nsn, ".", name);
-               }
-
                // <remarks>
                //   This function is used to resolve the hierarchy tree.
                //   It processes interfaces, structs and classes in that order.
@@ -170,7 +165,7 @@ namespace Mono.CSharp {
 
                        ArrayList ifaces = root.Interfaces;
                        if (ifaces != null){
-                               foreach (Interface i in ifaces) 
+                               foreach (TypeContainer i in ifaces) 
                                        i.DefineType ();
                        }
 
@@ -205,7 +200,7 @@ namespace Mono.CSharp {
                {
                        object o = root.GetDefinition (name);
                        if (o == null){
-                               Report.Error (518, "The predefined type `" + name + "' is not defined");
+                               Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
                                return null;
                        }
 
@@ -230,7 +225,7 @@ namespace Mono.CSharp {
                {
                        object o = root.GetDefinition (name);
                        if (o == null){
-                               Report.Error (518, "The predefined type `" + name + "' is not defined");
+                               Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
                                return;
                        }
 
@@ -255,7 +250,7 @@ namespace Mono.CSharp {
                {
                        object o = root.GetDefinition (name);
                        if (o == null){
-                               Report.Error (518, "The predefined type `" + name + "' is not defined");
+                               Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
                                return;
                        }
 
@@ -280,7 +275,7 @@ namespace Mono.CSharp {
                {
                        object o = root.GetDefinition (name);
                        if (o == null){
-                               Report.Error (518, "The predefined type `" + name + "' is not defined");
+                               Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
                                return;
                        }
 
@@ -396,7 +391,10 @@ namespace Mono.CSharp {
                                "System.InvalidOperationException",
                                "System.NotSupportedException",
                                "System.MarshalByRefObject",
-                               "System.Security.CodeAccessPermission"
+                               "System.Security.CodeAccessPermission",
+                               "System.Runtime.CompilerServices.RequiredAttributeAttribute",
+                               "System.Runtime.InteropServices.GuidAttribute",
+                               "System.Reflection.AssemblyCultureAttribute"
                        };
 
                        foreach (string cname in classes_second_stage)
@@ -481,11 +479,6 @@ namespace Mono.CSharp {
                        helper_classes.Add (helper_class);
                }
                
-               static void Report1530 (Location loc)
-               {
-                       Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
-               }
-               
                static public void PopulateCoreType (TypeContainer root, string name)
                {
                        DeclSpace ds = (DeclSpace) root.GetDefinition (name);
@@ -518,6 +511,7 @@ namespace Mono.CSharp {
                                if (RootContext.StdLib){
                                        foreach (TypeContainer tc in type_container_resolve_order)
                                                tc.DefineMembers (root);
+
                                } else {
                                        foreach (TypeContainer tc in type_container_resolve_order) {
                                                // When compiling corlib, these types have already been
@@ -536,19 +530,13 @@ namespace Mono.CSharp {
                        ArrayList delegates = root.Delegates;
                        if (delegates != null){
                                foreach (Delegate d in delegates)
-                                       if ((d.ModFlags & Modifiers.NEW) == 0)
-                                               d.DefineMembers (root);
-                                       else
-                                               Report1530 (d.Location);
+                                       d.DefineMembers (root);
                        }
 
                        ArrayList enums = root.Enums;
                        if (enums != null){
                                foreach (Enum en in enums)
-                                       if ((en.ModFlags & Modifiers.NEW) == 0)
-                                               en.DefineMembers (root);
-                                       else
-                                               Report1530 (en.Location);
+                                       en.DefineMembers (root);
                        }
 
                        //
@@ -578,6 +566,12 @@ namespace Mono.CSharp {
                {
                        TypeContainer root = Tree.Types;
 
+                       ArrayList delegates = root.Delegates;
+                       if (delegates != null){
+                               foreach (Delegate d in delegates)
+                                       d.Define ();
+                       }
+
                        if (type_container_resolve_order != null){
                                foreach (TypeContainer tc in type_container_resolve_order) {
                                        // When compiling corlib, these types have already been
@@ -589,23 +583,14 @@ namespace Mono.CSharp {
                                             (tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute")))
                                                continue;
 
-                                       if ((tc.ModFlags & Modifiers.NEW) == 0)
-                                               tc.Define ();
+                                       tc.Define ();
                                }
                        }
 
-                       ArrayList delegates = root.Delegates;
-                       if (delegates != null){
-                               foreach (Delegate d in delegates)
-                                       if ((d.ModFlags & Modifiers.NEW) == 0)
-                                               d.Define ();
-                       }
-
                        ArrayList enums = root.Enums;
                        if (enums != null){
                                foreach (Enum en in enums)
-                                       if ((en.ModFlags & Modifiers.NEW) == 0)
-                                               en.Define ();
+                                       en.Define ();
                        }
                }
 
@@ -619,6 +604,12 @@ namespace Mono.CSharp {
                        if (type_container_resolve_order != null) {
                                foreach (TypeContainer tc in type_container_resolve_order)
                                        tc.EmitType ();
+
+                               if (Report.Errors > 0)
+                                       return;
+
+                               foreach (TypeContainer tc in type_container_resolve_order)
+                                       tc.VerifyMembers ();
                        }
                        
                        if (Tree.Types.Delegates != null) {
@@ -686,6 +677,14 @@ namespace Mono.CSharp {
                        
                        return fb;
                }
+
+               public static void CheckUnsafeOption (Location loc)
+               {
+                       if (!Unsafe) {
+                               Report.Error (227, loc, 
+                                       "Unsafe code requires the `unsafe' command line option to be specified");
+                       }
+               }
        }
 }