2006-05-01 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
[mono.git] / mcs / gmcs / rootcontext.cs
index a57c64146e265dfc903a10511127536e6cdc2efd..f5ad0c98a628e98b442f466f84a483d464fe13c3 100644 (file)
@@ -66,7 +66,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;
 
@@ -85,6 +85,7 @@ namespace Mono.CSharp {
                public static string StrongNameKeyContainer;
                public static bool StrongNameDelaySign;
 
+               public static bool BrokenCircularDeps;
                //
                // If set, enable XML documentation generation
                //
@@ -114,6 +115,7 @@ namespace Mono.CSharp {
                        StrongNameDelaySign = false;
                        MainClass = null;
                        Target = Target.Exe;
+                       TargetExt = ".exe";
                        Version = LanguageVersion.Default;
                        Documentation = null;
                        impl_details_class = null;
@@ -200,7 +202,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;
                        }
 
@@ -225,7 +227,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;
                        }
 
@@ -250,7 +252,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;
                        }
 
@@ -275,7 +277,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;
                        }
 
@@ -296,7 +298,9 @@ namespace Mono.CSharp {
                        TypeContainer root = Tree.Types;
 
                        TypeManager.object_type = BootstrapCorlib_ResolveClass (root, "System.Object");
+                       TypeManager.system_object_expr.Type = TypeManager.object_type;
                        TypeManager.value_type = BootstrapCorlib_ResolveClass (root, "System.ValueType");
+                       TypeManager.system_valuetype_expr.Type = TypeManager.value_type;
                        TypeManager.attribute_type = BootstrapCorlib_ResolveClass (root, "System.Attribute");
                        TypeManager.indexer_name_type = BootstrapCorlib_ResolveClass (root, "System.Runtime.CompilerServices.IndexerNameAttribute");
                        
@@ -321,7 +325,7 @@ namespace Mono.CSharp {
                                // Generic types
                                //
                                "System.Collections.Generic.IEnumerator`1",
-                               "System.Collections.Generic.IEnumerable`1",
+                               "System.Collections.Generic.IEnumerable`1"
                        };
 
                        foreach (string iname in interfaces_first_stage)
@@ -385,7 +389,6 @@ namespace Mono.CSharp {
                                "System.Runtime.InteropServices.DllImportAttribute",
                                "System.Runtime.CompilerServices.MethodImplAttribute",
                                "System.Runtime.InteropServices.MarshalAsAttribute",
-                               "System.Runtime.CompilerServices.NewConstraintAttribute",
                                "System.Runtime.CompilerServices.CompilerGeneratedAttribute",
                                "System.Runtime.CompilerServices.FixedBufferAttribute",
                                "System.Diagnostics.ConditionalAttribute",
@@ -399,10 +402,14 @@ namespace Mono.CSharp {
                                "System.Runtime.InteropServices.OutAttribute",
                                "System.Runtime.InteropServices.StructLayoutAttribute",
                                "System.Runtime.InteropServices.FieldOffsetAttribute",
+                               "System.Runtime.InteropServices.DefaultCharSetAttribute",
                                "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)
@@ -487,16 +494,11 @@ 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);
 
-                       ds.DefineMembers (root);
+                       ds.DefineMembers ();
                        ds.Define ();
                }
                
@@ -521,40 +523,22 @@ namespace Mono.CSharp {
                        TypeContainer root = Tree.Types;
 
                        if (type_container_resolve_order != null){
-                               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
-                                               // populated from BootCorlib_PopulateCoreTypes ().
-                                               if (((tc.Name == "System.Object") ||
-                                                       (tc.Name == "System.Attribute") ||
-                                                       (tc.Name == "System.ValueType") ||
-                                                       (tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute")))
-                                               continue;
-
-                                               tc.DefineMembers (root);
-                                       }
-                               } 
+                               foreach (TypeContainer tc in type_container_resolve_order)
+                                       tc.ResolveType ();
+                               foreach (TypeContainer tc in type_container_resolve_order)
+                                       tc.DefineMembers ();
                        }
 
                        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 ();
                        }
 
                        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 ();
                        }
 
                        //
@@ -584,6 +568,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
@@ -595,23 +585,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 ();
                        }
                }
 
@@ -625,6 +606,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) {
@@ -692,6 +679,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");
+                       }
+               }
        }
 }