using System.Reflection.Emit;
using System.Collections;
- public class Const : FieldBase {
+ public class Const : FieldMember {
public Expression Expr;
EmitContext const_ec;
bool resolved = false;
object ConstantValue = null;
- Type type;
bool in_transit = false;
/// </summary>
public override bool Define ()
{
- type = Parent.ResolveType (Type, false, Location);
-
- if (type == null)
+ if (!base.Define ())
return false;
- const_ec = new EmitContext (Parent, Location, null, type, ModFlags);
+ const_ec = new EmitContext (Parent, Location, null, MemberType, ModFlags);
- Type ttype = type;
+ Type ttype = MemberType;
while (ttype.IsArray)
ttype = TypeManager.GetElementType (ttype);
return false;
}
- if (!CheckBase ())
- return false;
-
- FieldBuilder = Parent.TypeBuilder.DefineField (Name, type, FieldAttr);
+ FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType, FieldAttr);
TypeManager.RegisterConstant (FieldBuilder, this);
ce = Expr as Constant;
}
- if (type != real_expr.Type) {
- ce = ChangeType (Location, ce, type);
+ if (MemberType != real_expr.Type) {
+ ce = ChangeType (Location, ce, MemberType);
if (ce == null){
value = null;
return false;
}
ConstantValue = ce.GetValue ();
- if (type.IsEnum){
+ if (MemberType.IsEnum){
//
// This sadly does not work for our user-defined enumerations types ;-(
//
try {
ConstantValue = System.Enum.ToObject (
- type, ConstantValue);
+ MemberType, ConstantValue);
} catch (ArgumentException){
Report.Error (
-16, Location,