Nothing to see here
[mono.git] / mcs / mcs / typemanager.cs
index 527c0b3898ad1f8ed705c5523b93c4163b0cad18..4ee2508abedac106cabb08e1ba73a8e4b8246767 100644 (file)
@@ -115,7 +115,6 @@ namespace Mono.CSharp {
        static internal Type default_charset_type;
        static internal Type type_forwarder_attr_type;
        static internal Type isvolatile_type;
-       static public Type activator_type;
        static public Type generic_ilist_type;
        static public Type generic_icollection_type;
        static public Type generic_ienumerator_type;
@@ -182,6 +181,7 @@ namespace Mono.CSharp {
 
        // C# 2.0
        static internal ConstructorInfo fixed_buffer_attr_ctor;
+       static internal CustomAttributeBuilder unsafe_value_type_attr;
 
        // C# 3.0
        static internal CustomAttributeBuilder extension_attribute_attr;
@@ -321,6 +321,7 @@ namespace Mono.CSharp {
 
                param_array_attr =
                compiler_generated_attr =
+               unsafe_value_type_attr =
                extension_attribute_attr = null;
 
                isvolatile_type = null;
@@ -599,8 +600,11 @@ namespace Mono.CSharp {
                if (t == typeof (AnonymousMethodBody))
                        return "anonymous method";
 
+               if (t == null)
+                       return "internal error";
+
                return CSharpName (GetFullName (t));
-    }
+       }
 
        static readonly char [] elements = new char [] { '*', '[' };
 
@@ -651,19 +655,8 @@ namespace Mono.CSharp {
                }
                return sb.ToString ();
        }
-       
-       // Used for error reporting to show symbolic name instead of underlying value
-       public static string CSharpEnumValue (Type t, object value)
-       {
-               t = DropGenericTypeArguments (t);
-               Enum e = LookupDeclSpace (t) as Enum;
-               if (e == null)
-                       return System.Enum.GetName (t, value);
-
-               return e.GetDefinition (value).GetSignatureForError ();
-       }
 
-        /// <summary>
+       /// <summary>
        ///  Returns the signature of the method with full namespace classification
        /// </summary>
        static public string GetFullNameSignature (MemberInfo mi)
@@ -780,8 +773,14 @@ namespace Mono.CSharp {
                if (!mb.IsConstructor && TypeManager.IsSpecialMethod (mb)) {
                        string op_name = Operator.GetName (mb.Name);
                        if (op_name != null) {
-                               sig.Append ("operator ");
-                               sig.Append (op_name);
+                               if (op_name == "explicit" || op_name == "implicit") {
+                                       sig.Append (op_name);
+                                       sig.Append (" operator ");
+                                       sig.Append (CSharpName (((MethodInfo)mb).ReturnType));
+                               } else {
+                                       sig.Append ("operator ");
+                                       sig.Append (op_name);
+                               }
                                sig.Append (parameters);
                                return sig.ToString ();
                        }
@@ -1044,6 +1043,28 @@ namespace Mono.CSharp {
        //
        public static void InitOptionalCoreTypes ()
        {
+               system_string_expr.Type = string_type;
+               system_boolean_expr.Type = bool_type;
+               system_decimal_expr.Type = decimal_type;
+               system_single_expr.Type = float_type;
+               system_double_expr.Type = double_type;
+               system_sbyte_expr.Type = sbyte_type;
+               system_byte_expr.Type = byte_type;
+               system_int16_expr.Type = short_type;
+               system_uint16_expr.Type = ushort_type;
+               system_int32_expr.Type = int32_type;
+               system_uint32_expr.Type = uint32_type;
+               system_int64_expr.Type = int64_type;
+               system_uint64_expr.Type = uint64_type;
+               system_char_expr.Type = char_type;
+               system_void_expr.Type = void_type;
+
+               //
+               // These are only used for compare purposes
+               //
+               anonymous_method_type = typeof (AnonymousMethodBody);
+               null_type = typeof (NullLiteral);
+               
                void_ptr_type = GetPointerType (void_type);
                char_ptr_type = GetPointerType (char_type);
 
@@ -1067,7 +1088,7 @@ namespace Mono.CSharp {
                if (obsolete_attribute_type != null) {
                        Class c = TypeManager.LookupClass (obsolete_attribute_type);
                        if (c != null)
-                               c.DefineMembers ();
+                               c.Define ();
                }
 
                dllimport_type = CoreLookupType ("System.Runtime.InteropServices", "DllImportAttribute", Kind.Class, false);
@@ -1142,28 +1163,6 @@ namespace Mono.CSharp {
                                        TypeManager.CSharpName (system_4_type_arg));
                        }
                }
-
-               system_string_expr.Type = string_type;
-               system_boolean_expr.Type = bool_type;
-               system_decimal_expr.Type = decimal_type;
-               system_single_expr.Type = float_type;
-               system_double_expr.Type = double_type;
-               system_sbyte_expr.Type = sbyte_type;
-               system_byte_expr.Type = byte_type;
-               system_int16_expr.Type = short_type;
-               system_uint16_expr.Type = ushort_type;
-               system_int32_expr.Type = int32_type;
-               system_uint32_expr.Type = uint32_type;
-               system_int64_expr.Type = int64_type;
-               system_uint64_expr.Type = uint64_type;
-               system_char_expr.Type = char_type;
-               system_void_expr.Type = void_type;
-
-               //
-               // These are only used for compare purposes
-               //
-               anonymous_method_type = typeof (AnonymousMethodBody);
-               null_type = typeof (NullLiteral);
        }
 
        const BindingFlags instance_and_static = BindingFlags.Static | BindingFlags.Instance;
@@ -1628,6 +1627,11 @@ namespace Mono.CSharp {
                return false;
        }
 
+       public static bool IsSpecialType (Type t)
+       {
+               return t == arg_iterator_type || t == typed_reference_type;
+       }
+
        //
        // Checks whether `extern_type' is friend of the output assembly
        //
@@ -1698,10 +1702,9 @@ namespace Mono.CSharp {
 
        static void Error_FriendAccessNameNotMatching (string other_name)
        {
-               Report.Error (281, "Friend access was granted to `" + other_name + 
-                               "', but the output assembly is named `" + CodeGen.Assembly.Name.FullName +
-                               "'. Try adding a reference to `" + other_name + 
-                               "' or change the output assembly name to match it");
+               Report.Error (281,
+                       "Friend access was granted to `{0}', but the output assembly is named `{1}'. Try adding a reference to `{0}' or change the output assembly name to match it",
+                       other_name, CodeGen.Assembly.Name.FullName);
        }
 #endif