public class Const : MemberCore {
public Expression ConstantType;
public Expression Expr;
- public Attributes OptAttributes;
public FieldBuilder FieldBuilder;
object ConstantValue = null;
public Const (Expression constant_type, string name, Expression expr, int mod_flags,
Attributes attrs, Location loc)
- : base (name, loc)
+ : base (name, attrs, loc)
{
ConstantType = constant_type;
Name = name;
Expr = expr;
ModFlags = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PRIVATE, loc);
- OptAttributes = attrs;
+ }
+
+ public override AttributeTargets AttributeTargets {
+ get {
+ return AttributeTargets.Field;
+ }
}
public FieldAttributes FieldAttr {
/*else if ((ModFlags & Modifiers.NEW) != 0)
WarningNotHiding (parent);*/
+ if ((parent is Struct) && ((ModFlags & Modifiers.PROTECTED) != 0))
+ Report.Error (30435, Location,
+ "'Const' inside a 'Structure' can not be " +
+ "declared as 'Protected'");
+
FieldBuilder = parent.TypeBuilder.DefineField (Name, type, FieldAttr);
TypeManager.RegisterConstant (FieldBuilder, this);
Expr = un_expr.Expr;
else if ((ch_expr != null) && (ch_expr.Expr is Constant))
Expr = ch_expr.Expr;
- else \r
+ else
{
Report.Error (30059, Location, "A constant value is expected");
return null;
return;
}
+
+ public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+ {
+ FieldBuilder.SetCustomAttribute (cb);
+ }
+
}
}