X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fgmcs%2Frootcontext.cs;h=10b5bc81e5100d7fdec3d9220915e369e01dc993;hb=5319634c9b355ca01ee9baa276b29b211335e820;hp=4fbc27ec19df55f6539cba1e14189fc6338badd1;hpb=9bbfdd1a0e9bebb8fc8437529bc051a7568db4e4;p=mono.git diff --git a/mcs/gmcs/rootcontext.cs b/mcs/gmcs/rootcontext.cs index 4fbc27ec19d..10b5bc81e51 100644 --- a/mcs/gmcs/rootcontext.cs +++ b/mcs/gmcs/rootcontext.cs @@ -42,7 +42,7 @@ namespace Mono.CSharp { // This is only used to tell whether `System.Object' should // have a base class or not. // - public static bool StdLib = true; + public static bool StdLib; // // This keeps track of the order in which classes were defined @@ -54,7 +54,6 @@ namespace Mono.CSharp { // override). // static ArrayList type_container_resolve_order; - static ArrayList attribute_types; // // Holds a reference to the Private Implementation Details @@ -64,14 +63,19 @@ namespace Mono.CSharp { static TypeBuilder impl_details_class; - public static int WarningLevel = 3; + public static int WarningLevel; - public static Target Target = Target.Exe; + public static Target Target; public static string TargetExt = ".exe"; public static bool VerifyClsCompliance = true; - public static LanguageVersion Version = LanguageVersion.Default; + /// + /// Holds /optimize option + /// + public static bool Optimize = true; + + public static LanguageVersion Version; // // We keep strongname related info here because @@ -79,20 +83,40 @@ namespace Mono.CSharp { // public static string StrongNameKeyFile; public static string StrongNameKeyContainer; - public static bool StrongNameDelaySign = false; + public static bool StrongNameDelaySign; // // If set, enable XML documentation generation // public static Documentation Documentation; + static public string MainClass; + // // Constructor // static RootContext () + { + Reset (); + } + + public static void Reset () { tree = new Tree (); type_container_resolve_order = new ArrayList (); + EntryPoint = null; + WarningLevel = 3; + Checked = false; + Unsafe = false; + StdLib = true; + StrongNameKeyFile = null; + StrongNameKeyContainer = null; + StrongNameDelaySign = false; + MainClass = null; + Target = Target.Exe; + Version = LanguageVersion.Default; + Documentation = null; + impl_details_class = null; } public static bool NeedsEntryPoint { @@ -107,38 +131,21 @@ namespace Mono.CSharp { } } - static public string MainClass; - public static void RegisterOrder (TypeContainer tc) { type_container_resolve_order.Add (tc); } - - public static void RegisterAttribute (TypeContainer tc) - { - if (attribute_types == null) - attribute_types = new ArrayList (); - - attribute_types.Add (tc); - } // // The default compiler checked state // - static public bool Checked = false; + static public bool Checked; // // Whether to allow Unsafe code // - static public bool Unsafe = false; + static public bool Unsafe; - static string MakeFQN (string nsn, string name) - { - if (nsn == "") - return name; - return String.Concat (nsn, ".", name); - } - // // This function is used to resolve the hierarchy tree. // It processes interfaces, structs and classes in that order. @@ -148,13 +155,6 @@ namespace Mono.CSharp { // static public void ResolveTree () { - // - // Process the attribute types separately and before anything else - // - if (attribute_types != null) - foreach (TypeContainer tc in attribute_types) - tc.DefineType (); - // // Interfaces are processed next, as classes and // structs might inherit from an object or implement @@ -165,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 (); } @@ -276,7 +276,7 @@ namespace Mono.CSharp { object o = root.GetDefinition (name); if (o == null){ Report.Error (518, "The predefined type `" + name + "' is not defined"); - Environment.Exit (1); + return; } if (!(o is Delegate)){ @@ -298,6 +298,7 @@ namespace Mono.CSharp { TypeManager.object_type = BootstrapCorlib_ResolveClass (root, "System.Object"); TypeManager.value_type = BootstrapCorlib_ResolveClass (root, "System.ValueType"); TypeManager.attribute_type = BootstrapCorlib_ResolveClass (root, "System.Attribute"); + TypeManager.indexer_name_type = BootstrapCorlib_ResolveClass (root, "System.Runtime.CompilerServices.IndexerNameAttribute"); string [] interfaces_first_stage = { "System.IComparable", "System.ICloneable", @@ -385,22 +386,25 @@ namespace Mono.CSharp { "System.Runtime.CompilerServices.MethodImplAttribute", "System.Runtime.InteropServices.MarshalAsAttribute", "System.Runtime.CompilerServices.NewConstraintAttribute", + "System.Runtime.CompilerServices.CompilerGeneratedAttribute", + "System.Runtime.CompilerServices.FixedBufferAttribute", "System.Diagnostics.ConditionalAttribute", "System.ObsoleteAttribute", "System.ParamArrayAttribute", "System.CLSCompliantAttribute", "System.Security.UnverifiableCodeAttribute", "System.Security.Permissions.SecurityAttribute", - "System.Runtime.CompilerServices.IndexerNameAttribute", "System.Runtime.CompilerServices.DecimalConstantAttribute", "System.Runtime.InteropServices.InAttribute", "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" }; foreach (string cname in classes_second_stage) @@ -435,10 +439,6 @@ namespace Mono.CSharp { foreach (Enum en in root.Enums) en.CloseType (); - if (attribute_types != null) - foreach (TypeContainer tc in attribute_types) - tc.CloseType (); - // // We do this in two passes, first we close the structs, // then the classes, because it seems the code needs it this @@ -465,11 +465,12 @@ namespace Mono.CSharp { // If we have a class, close it // if (helper_classes != null){ - foreach (TypeBuilder type_builder in helper_classes) + foreach (TypeBuilder type_builder in helper_classes) { + type_builder.SetCustomAttribute (TypeManager.compiler_generated_attr); type_builder.CreateType (); + } } - attribute_types = null; type_container_resolve_order = null; helper_classes = null; //tree = null; @@ -480,10 +481,11 @@ namespace Mono.CSharp { /// Used to register classes that need to be closed after all the /// user defined classes /// - public static void RegisterHelperClass (TypeBuilder helper_class) + public static void RegisterCompilerGeneratedType (TypeBuilder helper_class) { if (helper_classes == null) helper_classes = new ArrayList (); + helper_classes.Add (helper_class); } @@ -507,6 +509,7 @@ namespace Mono.CSharp { PopulateCoreType (root, "System.Object"); PopulateCoreType (root, "System.ValueType"); PopulateCoreType (root, "System.Attribute"); + PopulateCoreType (root, "System.Runtime.CompilerServices.IndexerNameAttribute"); } // @@ -519,10 +522,6 @@ namespace Mono.CSharp { { TypeContainer root = Tree.Types; - if (attribute_types != null) - foreach (TypeContainer tc in attribute_types) - tc.DefineMembers (root); - if (type_container_resolve_order != null){ if (RootContext.StdLib){ foreach (TypeContainer tc in type_container_resolve_order) @@ -532,8 +531,9 @@ namespace Mono.CSharp { // 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.Attribute") || + (tc.Name == "System.ValueType") || + (tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute"))) continue; tc.DefineMembers (root); @@ -586,10 +586,6 @@ namespace Mono.CSharp { { TypeContainer root = Tree.Types; - if (attribute_types != null) - foreach (TypeContainer tc in attribute_types) - tc.Define (); - if (type_container_resolve_order != null){ foreach (TypeContainer tc in type_container_resolve_order) { // When compiling corlib, these types have already been @@ -597,7 +593,8 @@ namespace Mono.CSharp { if (!RootContext.StdLib && ((tc.Name == "System.Object") || (tc.Name == "System.Attribute") || - (tc.Name == "System.ValueType"))) + (tc.Name == "System.ValueType") || + (tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute"))) continue; if ((tc.ModFlags & Modifiers.NEW) == 0) @@ -622,13 +619,6 @@ namespace Mono.CSharp { static public void EmitCode () { - if (attribute_types != null) - foreach (TypeContainer tc in attribute_types) - tc.EmitType (); - - CodeGen.Assembly.Emit (Tree.Types); - CodeGen.Module.Emit (Tree.Types); - if (Tree.Types.Enums != null) { foreach (Enum e in Tree.Types.Enums) e.Emit (); @@ -637,6 +627,9 @@ namespace Mono.CSharp { if (type_container_resolve_order != null) { foreach (TypeContainer tc in type_container_resolve_order) tc.EmitType (); + + foreach (TypeContainer tc in type_container_resolve_order) + tc.VerifyMembers (); } if (Tree.Types.Delegates != null) { @@ -650,6 +643,9 @@ namespace Mono.CSharp { if (EmitCodeHook != null) EmitCodeHook (); + + CodeGen.Assembly.Emit (Tree.Types); + CodeGen.Module.Emit (Tree.Types); } // @@ -692,7 +688,7 @@ namespace Mono.CSharp { TypeAttributes.NotPublic, TypeManager.object_type); - RegisterHelperClass (impl_details_class); + RegisterCompilerGeneratedType (impl_details_class); } fb = impl_details_class.DefineInitializedData (