X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fenum.cs;h=2523e0cf76c1cc701b5fb638ac8bc2d7254e300b;hb=109bb0350beed07567ae9d5e9aa26e0d37e05342;hp=b4a24c5eb2d8c47e9ae84599df37d3c647d371ca;hpb=5c227da87d62dff13f003485ae1dd8830c29aad4;p=mono.git diff --git a/mcs/mcs/enum.cs b/mcs/mcs/enum.cs index b4a24c5eb2d..2523e0cf76c 100644 --- a/mcs/mcs/enum.cs +++ b/mcs/mcs/enum.cs @@ -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,9 +127,7 @@ namespace Mono.CSharp { { public static readonly string UnderlyingValueField = "value__"; - FullNamedExpression base_type; - - public Type UnderlyingType; + TypeExpr base_type; const int AllowedModifiers = Modifiers.NEW | @@ -135,7 +136,7 @@ namespace Mono.CSharp { 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 ()