X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fenum.cs;h=437940f6cc837cc6aaca3742409e3ecf67f955d0;hb=5c7308bc4df12e9e19e07ec6518b2db1ae80ff86;hp=8bc58c0c54e8d8caf43e5cc583328704cb9acb6c;hpb=43effcbccaa34493aa9ca15f249be10ef638f1b2;p=mono.git diff --git a/mcs/mcs/enum.cs b/mcs/mcs/enum.cs index 8bc58c0c54e..437940f6cc8 100644 --- a/mcs/mcs/enum.cs +++ b/mcs/mcs/enum.cs @@ -61,7 +61,7 @@ namespace Mono.CSharp { return (t == TypeManager.int32_type || t == TypeManager.uint32_type || t == TypeManager.int64_type || t == TypeManager.byte_type || t == TypeManager.sbyte_type || t == TypeManager.short_type || t == TypeManager.ushort_type || t == TypeManager.uint64_type || t == TypeManager.char_type || - t.IsEnum); + TypeManager.IsEnumType (t)); } public object Value { @@ -70,6 +70,9 @@ namespace Mono.CSharp { public override bool Define () { + if (!ResolveMemberType ()) + return false; + const FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal; FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType, attr); Parent.MemberCache.AddMember (FieldBuilder, this); @@ -87,7 +90,7 @@ namespace Mono.CSharp { if (c is EnumConstant) c = ((EnumConstant)c).Child; - c = c.ImplicitConversionRequired (ParentEnum.UnderlyingType, Location); + c = c.ImplicitConversionRequired (ec, ParentEnum.UnderlyingType, Location); if (c == null) return null; @@ -124,18 +127,16 @@ namespace Mono.CSharp { { public static readonly string UnderlyingValueField = "value__"; - FullNamedExpression base_type; + TypeExpr base_type; - public Type UnderlyingType; - - public const int AllowedModifiers = + const int AllowedModifiers = Modifiers.NEW | Modifiers.PUBLIC | Modifiers.PROTECTED | Modifiers.INTERNAL | Modifiers.PRIVATE; - public Enum (NamespaceEntry ns, DeclSpace parent, FullNamedExpression type, + public Enum (NamespaceEntry ns, DeclSpace parent, TypeExpr type, int mod_flags, MemberName name, Attributes attrs) : base (ns, parent, name, attrs, Kind.Enum) { @@ -166,26 +167,6 @@ namespace Mono.CSharp { if (!base.DefineNestedTypes ()) return false; - if (!(base_type is TypeLookupExpression)) { - Error_1008 (Location); - return false; - } - - TypeExpr ute = base_type.ResolveAsTypeTerminal (this, false); - UnderlyingType = ute.Type; - - if (UnderlyingType != TypeManager.int32_type && - UnderlyingType != TypeManager.uint32_type && - UnderlyingType != TypeManager.int64_type && - UnderlyingType != TypeManager.uint64_type && - UnderlyingType != TypeManager.short_type && - UnderlyingType != TypeManager.ushort_type && - UnderlyingType != TypeManager.byte_type && - UnderlyingType != TypeManager.sbyte_type) { - Error_1008 (Location); - return false; - } - // // Call MapToInternalType for corlib // @@ -196,24 +177,22 @@ namespace Mono.CSharp { return true; } - protected override bool DoDefineMembers () + public override bool Define () { member_cache = new MemberCache (TypeManager.enum_type, this); DefineContainerMembers (constants); return true; } - // - // Used for error reporting only - // - public EnumMember GetDefinition (object value) + public override bool IsUnmanagedType () { - foreach (EnumMember e in defined_names.Values) { - if (value.Equals (e.Value)) - return e; - } + return true; + } - throw new ArgumentOutOfRangeException (value.ToString ()); + public Type UnderlyingType { + get { + return base_type.Type; + } } protected override bool VerifyClsCompliance () @@ -224,7 +203,7 @@ namespace Mono.CSharp { if (UnderlyingType == TypeManager.uint32_type || UnderlyingType == TypeManager.uint64_type || UnderlyingType == TypeManager.ushort_type) { - Report.Error (3009, Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (UnderlyingType)); + Report.Warning (3009, 1, Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (UnderlyingType)); } return true;