static readonly string[] attribute_targets = new string [] { "field" };
- protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod,
- Modifiers allowed_mod, MemberName name, Attributes attrs)
- : base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE,
- name, attrs)
+ protected FieldBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
+ : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs)
{
if ((mod & Modifiers.ABSTRACT) != 0)
Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
}
}
+ public string Name {
+ get {
+ return MemberName.Name;
+ }
+ }
+
public FieldSpec Spec {
get {
return spec;
declarators.Add (declarator);
- // TODO: This will probably break
- Parent.AddMember (this, declarator.Name.Value);
+ Parent.AddNameToContainer (this, declarator.Name.Value);
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder);
- } else if (!(Parent is CompilerGeneratedClass) && member_type.HasDynamicElement) {
+ } else if (!Parent.IsCompilerGenerated && member_type.HasDynamicElement) {
Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder, member_type, Location);
}
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (FieldBuilder);
+ if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
+ Module.PredefinedAttributes.DebuggerBrowsable.EmitAttribute (FieldBuilder, System.Diagnostics.DebuggerBrowsableState.Never);
if (OptAttributes != null) {
OptAttributes.Emit ();
Modifiers.PRIVATE |
Modifiers.UNSAFE;
- public FixedField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
+ public FixedField (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}
GetSignatureForError ());
} else if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
- int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
f.initializer = d.Initializer;
((ConstInitializer) f.initializer).Name = d.Name.Value;
- Parent.PartialContainer.Fields.Insert (++index, f);
+ f.Define ();
+ Parent.PartialContainer.Members.Add (f);
}
}
Modifiers.UNSAFE |
Modifiers.READONLY;
- public Field (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name,
- Attributes attrs)
+ public Field (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
: base (parent, type, mod, AllowedModifiers, name, attrs)
{
}
}
if (initializer != null) {
- ((TypeContainer) Parent).RegisterFieldForInitialization (this,
- new FieldInitializer (spec, initializer, this));
+ Parent.RegisterFieldForInitialization (this, new FieldInitializer (this, initializer, TypeExpression.Location));
}
if (declarators != null) {
- var t = new TypeExpression (MemberType, TypeExpression.Location);
- int index = Parent.PartialContainer.Fields.IndexOf (this);
foreach (var d in declarators) {
+ var t = new TypeExpression (MemberType, d.Name.Location);
var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
if (d.Initializer != null)
f.initializer = d.Initializer;
- Parent.PartialContainer.Fields.Insert (++index, f);
+ f.Define ();
+ Parent.PartialContainer.Members.Add (f);
}
}