ConstantType = constant_type;
Name = name;
Expr = expr;
- ModFlags = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PRIVATE);
+ ModFlags = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PRIVATE, loc);
OptAttributes = attrs;
}
}
}
+#if DEBUG
void dump_tree (Type t)
{
Console.WriteLine ("Dumping hierarchy");
t = t.BaseType;
}
}
+#endif
/// <summary>
/// Defines the constant in the @parent
return null;
}
- Expr = Expression.Reduce (ec, Expr);
-
- if (!(Expr is Literal)) {
+ if (!(Expr is Constant)) {
Report.Error (150, Location, "A constant value is expected");
return null;
}
- ConstantValue = ((Literal) Expr).GetValue ();
+ ConstantValue = ((Constant) Expr).GetValue ();
if (type.IsEnum){
//
ConstantValue = System.Enum.ToObject (
type, ConstantValue);
}
-
+
FieldBuilder.SetConstant (ConstantValue);
- if (!TypeManager.RegisterField (FieldBuilder, ConstantValue))
+ if (!TypeManager.RegisterFieldValue (FieldBuilder, ConstantValue))
return null;
return ConstantValue;
/// </summary>
public void EmitConstant (TypeContainer parent)
{
- if (FieldBuilder == null)
- return;
-
EmitContext ec = new EmitContext (parent, Location, null, type, ModFlags);
LookupConstantValue (ec);