updated browser capabilities file
[mono.git] / mcs / gmcs / rootcontext.cs
index 9c1c20c39c79a8c6ecb3ebda7974a7cb7518ece4..d1963c494ffa609154accd1e14b4ce8fac83a378 100755 (executable)
@@ -29,11 +29,6 @@ namespace Mono.CSharp {
                //
                public static Hashtable AllDefines = new Hashtable ();
                
-               //
-               // The list of global attributes (those that target the assembly)
-               //
-               static Hashtable global_attributes = new Hashtable ();
-               
                //
                // Whether we are being linked against the standard libraries.
                // This is only used to tell whether `System.Object' should
@@ -64,6 +59,9 @@ namespace Mono.CSharp {
 
                public static int WarningLevel = 2;
 
+               public static Target Target = Target.Exe;
+               public static string TargetExt = ".exe";
+
                //
                // If set, enable C# version 2 features
                //
@@ -78,6 +76,12 @@ namespace Mono.CSharp {
                        type_container_resolve_order = new ArrayList ();
                }
 
+               public static bool NeedsEntryPoint {
+                       get {
+                               return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe;
+                       }
+               }
+
                static public Tree Tree {
                        get {
                                return tree;
@@ -389,8 +393,6 @@ namespace Mono.CSharp {
                {
                        TypeContainer root = Tree.Types;
                        
-                       ArrayList ifaces = root.Interfaces;
-
                        if (root.Enums != null)
                                foreach (Enum en in root.Enums)
                                        en.CloseType ();
@@ -431,6 +433,13 @@ namespace Mono.CSharp {
                                foreach (TypeBuilder type_builder in helper_classes)
                                        type_builder.CreateType ();
                        }
+                       
+                       attribute_types = null;
+                       interface_resolve_order = null;
+                       type_container_resolve_order = null;
+                       helper_classes = null;
+                       tree = null;
+                       TypeManager.CleanUp ();
                }
 
                /// <summary>
@@ -452,7 +461,7 @@ namespace Mono.CSharp {
                //
                static public string ImplicitParent (string ns)
                {
-                       int i = ns.LastIndexOf (".");
+                       int i = ns.LastIndexOf ('.');
                        if (i < 0)
                                return null;
                        
@@ -461,12 +470,10 @@ namespace Mono.CSharp {
 
                static Type NamespaceLookup (DeclSpace ds, string name, Location loc)
                {
-                       Type t;
-
                        //
                        // Try in the current namespace and all its implicit parents
                        //
-                       for (NamespaceEntry ns = ds.Namespace; ns != null; ns = ns.ImplicitParent) {
+                       for (NamespaceEntry ns = ds.NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
                                object result = ns.Lookup (ds, name, loc);
                                if (result == null)
                                        continue;
@@ -703,20 +710,8 @@ namespace Mono.CSharp {
                        // Because of the strange way in which we do things, global
                        // attributes must be processed first.
                        //
-                       if (global_attributes.Count > 0){
-                               AssemblyBuilder ab = CodeGen.AssemblyBuilder;
-                               TypeContainer dummy = new TypeContainer (null, "", new Location (-1));
-                               EmitContext temp_ec = new EmitContext (
-                                       dummy, Mono.CSharp.Location.Null, null, null, 0, false);
-                       
-                               foreach (DictionaryEntry de in global_attributes){
-                                       NamespaceEntry ns = (NamespaceEntry) de.Key;
-                                       Attributes attrs = (Attributes) de.Value;
-                                       
-                                       dummy.Namespace = ns;
-                                       Attribute.ApplyAttributes (temp_ec, ab, ab, attrs);
-                               }
-                       }
+                       CodeGen.Assembly.Emit ();
+                       CodeGen.Module.Emit ();
                         
                        if (attribute_types != null)
                                foreach (TypeContainer tc in attribute_types)
@@ -742,18 +737,6 @@ namespace Mono.CSharp {
 
                        if (EmitCodeHook != null)
                                EmitCodeHook ();
-
-                       
-                       if (Unsafe) {
-                               if (TypeManager.unverifiable_code_ctor == null) {
-                                       Console.WriteLine ("Internal error ! Cannot set unverifiable code attribute.");
-                                       return;
-                               }
-                               
-                               CustomAttributeBuilder cb = new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor,
-                                                                                       new object [0]);
-                               CodeGen.ModuleBuilder.SetCustomAttribute (cb);
-                       }
                }
                
                //
@@ -789,10 +772,9 @@ namespace Mono.CSharp {
                static public FieldBuilder MakeStaticData (byte [] data)
                {
                        FieldBuilder fb;
-                       int size = data.Length;
                        
                        if (impl_details_class == null){
-                               impl_details_class = CodeGen.ModuleBuilder.DefineType (
+                               impl_details_class = CodeGen.Module.Builder.DefineType (
                                        "<PrivateImplementationDetails>",
                                         TypeAttributes.NotPublic,
                                         TypeManager.object_type);
@@ -806,21 +788,6 @@ namespace Mono.CSharp {
                        
                        return fb;
                }
-
-               //
-               // Adds a global attribute that was declared in `container', 
-               // the attribute is in `attr', and it was defined at `loc'
-               //
-               static public void AddGlobalAttributeSection (TypeContainer container, AttributeSection attr)
-               {
-                       NamespaceEntry ns = container.Namespace;
-                       Attributes a = (Attributes) global_attributes [ns];
-
-                       if (a == null)
-                               global_attributes [ns] = new Attributes (attr);
-                       else
-                               a.AddAttributeSection (attr);
-               }
        }
 }