using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
-using System.Xml;
namespace Mono.CSharp {
Constant value;
bool in_transit;
+ // TODO: remove or simplify
+ EmitContext ec;
+
public EnumMember (Enum parent_enum, EnumMember prev_member, Expression expr,
MemberName name, Attributes attrs):
- base (parent_enum.Parent, name, attrs)
+ base (parent_enum, name, attrs)
{
this.parent_enum = parent_enum;
this.ModFlags = parent_enum.ModFlags;
this.ValueExpr = expr;
this.prev_member = prev_member;
+
+ ec = new EmitContext (this, parent_enum, parent_enum, Location, null, null, ModFlags, false);
+ ec.InEnumContext = true;
}
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
if (marshal != null) {
builder.SetMarshal (marshal);
}
- return;
- }
+ return;
+ }
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
const FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal;
TypeBuilder tb = parent_enum.TypeBuilder;
builder = tb.DefineField (Name, tb, attr);
+ ec.ContainerType = tb;
TypeManager.RegisterConstant (builder, this);
return true;
if (ValueExpr != null) {
in_transit = true;
- Constant c = ValueExpr.ResolveAsConstant (parent_enum.EmitContext, this);
+ Constant c = ValueExpr.ResolveAsConstant (ec, this);
in_transit = false;
if (c == null)
return true;
}
- public bool Emit (EmitContext ec)
+ public override void Emit ()
{
if (OptAttributes != null)
- OptAttributes.Emit (ec, this);
+ OptAttributes.Emit ();
if (!ResolveValue ())
- return false;
+ return;
builder.SetConstant (value.GetValue ());
- Emit ();
- return true;
+ base.Emit ();
}
public override string GetSignatureForError()
}
}
- protected override bool VerifyClsCompliance(DeclSpace ds)
- {
- // Because parent is TypeContainer and we have only DeclSpace parent.
- // Parameter replacing is required
- return base.VerifyClsCompliance (parent_enum);
- }
-
public override string DocCommentHeader {
get { return "F:"; }
}
if (TypeBuilder != null)
return TypeBuilder;
- ec = new EmitContext (this, this, Location, null, null, ModFlags, false);
- ec.InEnumContext = true;
-
if (!(BaseType is TypeLookupExpression)) {
Report.Error (1008, Location,
"Type byte, sbyte, short, ushort, int, uint, long or ulong expected");
return null;
}
- TypeExpr ute = ResolveBaseTypeExpr (BaseType, false, Location);
- if (ute == null)
- return null;
-
+ TypeExpr ute = BaseType.ResolveAsTypeTerminal (this, false);
UnderlyingType = ute.Type;
if (UnderlyingType != TypeManager.int32_type &&
Basename, TypeAttr, TypeManager.enum_type);
}
- ec.ContainerType = TypeBuilder;
-
//
// Call MapToInternalType for corlib
//
public override bool Define ()
{
- if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
- ec.TestObsoleteMethodUsage = false;
-
return true;
}
public override void Emit ()
{
if (OptAttributes != null) {
- OptAttributes.Emit (ec, this);
+ OptAttributes.Emit ();
}
foreach (EnumMember em in defined_names.Values) {
- if (!em.Emit (ec))
- return;
+ em.Emit ();
}
base.Emit ();
{
HybridDictionary dict = new HybridDictionary (defined_names.Count, true);
foreach (EnumMember em in defined_names.Values) {
- if (!em.IsClsComplianceRequired (this))
+ if (!em.IsClsComplianceRequired ())
continue;
try {
}
}
- protected override bool VerifyClsCompliance (DeclSpace ds)
+ protected override bool VerifyClsCompliance ()
{
- if (!base.VerifyClsCompliance (ds))
+ if (!base.VerifyClsCompliance ())
return false;
VerifyClsName ();