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);
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;
{
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)
{
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
//
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 ()