2007-03-21 Mike Kestner <mkestner@novell.com>
[mono.git] / mcs / mcs / codegen.cs
index 7f95441bc020d33c5cf7108c698c8babace64b7d..af6d336ad482c243e386e998a898f30e03de6a74 100644 (file)
@@ -8,9 +8,14 @@
 // (C) 2004 Novell, Inc.
 //
 
-#if !DEBUG
-       #define PRODUCTION
-#endif
+//
+// Please leave this defined on SVN: The idea is that when we ship the
+// compiler to end users, if the compiler crashes, they have a chance
+// to narrow down the problem.   
+//
+// Only remove it if you need to debug locally on your tree.
+//
+//#define PRODUCTION
 
 using System;
 using System.IO;
@@ -378,6 +383,8 @@ namespace Mono.CSharp {
                        Emitting
                }
 
+               public static EmitContext TempEc;
+               
                bool isAnonymousMethodAllowed = true;
 
                Phase current_phase;
@@ -990,6 +997,7 @@ namespace Mono.CSharp {
                public AssemblyBuilder Builder;
                bool is_cls_compliant;
                bool wrap_non_exception_throws;
+               bool has_extension_method;
 
                public Attribute ClsCompliantAttribute;
 
@@ -1005,7 +1013,13 @@ namespace Mono.CSharp {
 
                public AssemblyClass (): base ()
                {
+#if GMCS_SOURCE
                        wrap_non_exception_throws = true;
+#endif
+               }
+
+               public bool HasExtensionMethods {
+                       set { has_extension_method = value; }
                }
 
                public bool IsClsCompliant {
@@ -1311,6 +1325,10 @@ namespace Mono.CSharp {
                                return;
                        }
                        
+                       if (a.Type == TypeManager.extension_attribute_type) {
+                               a.Error_MisusedExtensionAttribute ();
+                               return;
+                       }
 #endif
                        Builder.SetCustomAttribute (customBuilder);
                }
@@ -1320,6 +1338,9 @@ namespace Mono.CSharp {
                        base.Emit (tc);
 
 #if GMCS_SOURCE
+                       if (has_extension_method)
+                               Builder.SetCustomAttribute (TypeManager.extension_attribute_attr);
+
                        // FIXME: Does this belong inside SRE.AssemblyBuilder instead?
                        if (OptAttributes == null || !OptAttributes.Contains (TypeManager.runtime_compatibility_attr_type)) {
                                ConstructorInfo ci = TypeManager.GetConstructor (
@@ -1394,6 +1415,7 @@ namespace Mono.CSharp {
                // TODO: make it private and move all builder based methods here
                public ModuleBuilder Builder;
                bool m_module_is_unsafe;
+               bool has_default_charset;
 
                public CharSet DefaultCharSet = CharSet.Ansi;
                public TypeAttributes DefaultCharSetType = TypeAttributes.AnsiClass;
@@ -1447,6 +1469,12 @@ namespace Mono.CSharp {
                        Builder.SetCustomAttribute (customBuilder);
                }
 
+               public bool HasDefaultCharSet {
+                       get {
+                               return has_default_charset;
+                       }
+               }
+
                /// <summary>
                /// It is called very early therefore can resolve only predefined attributes
                /// </summary>
@@ -1461,6 +1489,7 @@ namespace Mono.CSharp {
 
                        Attribute a = ResolveAttribute (TypeManager.default_charset_type);
                        if (a != null) {
+                               has_default_charset = true;
                                DefaultCharSet = a.GetCharSetValue ();
                                switch (DefaultCharSet) {
                                        case CharSet.Ansi: