/// </summary>
public abstract class TypeContainer : DeclSpace, IMemberContainer {
+ protected class CircularDepException: Exception
+ {
+ public TypeContainer Container;
+ public CircularDepException (TypeContainer tc)
+ {
+ Container = tc;
+ }
+ }
+
public class MemberCoreArrayList: ArrayList
{
/// <summary>
// Register all the operators we care about.
foreach (Operator op in this){
int reg = 0;
-
+
+ // Skip erroneous code.
+ if (op.OperatorMethod == null)
+ continue;
+
switch (op.OperatorType){
case Operator.OpType.Equality:
reg = 1;
MemberCache member_cache;
public const string DefaultIndexerName = "Item";
+
+ // This is used to catch recursive definitions in declarations.
+ protected bool InTransit;
public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
Attributes attrs, Kind kind, Location l)
: base (ns, parent, name, attrs, l)
{
+ if (parent != null && parent != RootContext.Tree.Types && parent.NamespaceEntry != ns)
+ throw new InternalErrorException ("A nested type should be in the same NamespaceEntry as its enclosing class");
+
this.Kind = kind;
types = new ArrayList ();
public bool AddToMemberContainer (MemberCore symbol)
{
- return AddToContainer (symbol, String.Concat (Name, '.', symbol.Name), symbol.Name);
+ return AddToContainer (symbol, symbol.Name);
}
bool AddToTypeContainer (DeclSpace ds)
{
- return AddToContainer (ds, ds.Name, ds.Basename);
+ // Parent == null ==> this == RootContext.Tree.Types
+ return AddToContainer (ds, (Parent == null) ? ds.Name : ds.Basename);
}
public void AddConstant (Const constant)
if (methods == null)
methods = new MethodArrayList (this);
- if (method.Name.IndexOf ('.') != -1)
+ if (method.MemberName.Left != null)
methods.Insert (0, method);
else
methods.Add (method);
fields.Add (field);
- if (field.HasInitializer){
- if ((field.ModFlags & Modifiers.STATIC) != 0){
- if (initialized_static_fields == null)
- initialized_static_fields = new ArrayList ();
-
- initialized_static_fields.Add (field);
- } else {
- if (initialized_fields == null)
- initialized_fields = new ArrayList ();
-
- initialized_fields.Add (field);
- }
- }
+ if (field.HasInitializer)
+ RegisterFieldForInitialization (field);
if ((field.ModFlags & Modifiers.STATIC) == 0)
have_nonstatic_fields = true;
if (properties == null)
properties = new MemberCoreArrayList ();
- if (prop.Name.IndexOf ('.') != -1)
+ if (prop.MemberName.Left != null)
properties.Insert (0, prop);
else
properties.Add (prop);
}
}
- public virtual TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
- return Modifiers.TypeAttr (ModFlags, this);
+ return Modifiers.TypeAttr (ModFlags, this) | base.TypeAttr;
}
}
}
}
+ public virtual void RegisterFieldForInitialization (FieldMember field)
+ {
+ if ((field.ModFlags & Modifiers.STATIC) != 0){
+ if (initialized_static_fields == null)
+ initialized_static_fields = new ArrayList ();
+
+ initialized_static_fields.Add (field);
+ } else {
+ if (initialized_fields == null)
+ initialized_fields = new ArrayList ();
+
+ initialized_fields.Add (field);
+ }
+ }
+
//
// Emits the instance field initializers
//
- public bool EmitFieldInitializers (EmitContext ec)
+ public virtual bool EmitFieldInitializers (EmitContext ec)
{
ArrayList fields;
Expression instance_expr;
if (fields == null)
return true;
- foreach (Field f in fields){
+ foreach (FieldMember f in fields){
Expression e = f.GetInitializerExpression (ec);
if (e == null)
return false;
Location l = f.Location;
- FieldExpr fe = new FieldExpr (f.FieldBuilder, l);
+ FieldExpr fe = new FieldExpr (f.FieldBuilder, l, true);
fe.InstanceExpression = instance_expr;
ExpressionStatement a = new Assign (fe, e, l);
if (a == null)
return false;
- if (RootContext.Optimize) {
- Constant c = e as Constant;
- if (c != null) {
- if (c.IsDefaultValue)
- continue;
- }
+ Constant c = e as Constant;
+ if (c != null) {
+ if (c.IsDefaultValue)
+ continue;
}
a.EmitStatement (ec);
else if ((ModFlags & Modifiers.ABSTRACT) != 0)
mods = Modifiers.PROTECTED;
- c = new Constructor (this, Basename, mods, Parameters.EmptyReadOnlyParameters,
+ TypeContainer constructor_parent = this;
+ if (Parts != null)
+ constructor_parent = (TypeContainer) Parts [0];
+
+ c = new Constructor (constructor_parent, Basename, mods,
+ Parameters.EmptyReadOnlyParameters,
new ConstructorBaseInitializer (
null, Parameters.EmptyReadOnlyParameters,
Location),
/// </remarks>
public PendingImplementation Pending;
- public abstract void Register ();
-
public abstract PendingImplementation GetPendingImplementations ();
- TypeExpr[] GetPartialBases (out TypeExpr base_class, out bool error)
+ TypeExpr[] GetPartialBases (out TypeExpr base_class)
{
ArrayList ifaces = new ArrayList ();
TypeExpr new_base_class;
TypeExpr[] new_ifaces;
- new_ifaces = part.GetClassBases (out new_base_class, out error);
- if (error)
+ new_ifaces = part.GetClassBases (out new_base_class);
+ if (new_ifaces == null && base_type != null)
return null;
if ((base_class != null) && (new_base_class != null) &&
if (!Location.IsNull (base_loc))
Report.LocationOfPreviousError (base_loc);
- error = true;
return null;
}
}
}
- error = false;
-
TypeExpr[] retval = new TypeExpr [ifaces.Count];
ifaces.CopyTo (retval, 0);
return retval;
}
- TypeExpr[] GetNormalBases (out TypeExpr base_class, out bool error)
+ TypeExpr[] GetNormalBases (out TypeExpr base_class)
{
base_class = null;
(Expression) Bases [0], false, Location);
if (name == null){
- error = true;
return null;
}
for (i = start, j = 0; i < count; i++, j++){
TypeExpr resolved = ResolveBaseTypeExpr ((Expression) Bases [i], false, Location);
if (resolved == null) {
- error = true;
return null;
}
ifaces [j] = resolved;
}
- error = false;
return ifaces;
}
/// The @base_class argument is set to the base object or null
/// if this is `System.Object'.
/// </summary>
- TypeExpr [] GetClassBases (out TypeExpr base_class, out bool error)
+ TypeExpr [] GetClassBases (out TypeExpr base_class)
{
int i;
- error = false;
-
TypeExpr[] ifaces;
if (parts != null)
- ifaces = GetPartialBases (out base_class, out error);
+ ifaces = GetPartialBases (out base_class);
else if (Bases == null){
base_class = null;
return null;
} else
- ifaces = GetNormalBases (out base_class, out error);
+ ifaces = GetNormalBases (out base_class);
- if (error)
+ if (ifaces == null)
return null;
if ((base_class != null) && (Kind == Kind.Class)){
if (base_class.Type.IsArray || base_class.Type.IsPointer) {
Report.Error (1521, base_class.Location, "Invalid base type");
- error = true;
return null;
}
if (base_class.IsSealed){
- error = true;
Report.SymbolRelatedToPreviousError (base_class.Type);
if (base_class.Type.IsAbstract) {
Report.Error (709, Location, "'{0}': Cannot derive from static class", GetSignatureForError ());
Report.Error (644, Location,
"`{0}' cannot inherit from special class `{1}'",
Name, base_class.Name);
- error = true;
return null;
}
TypeExpr iface = (TypeExpr) ifaces [i];
if (!iface.IsInterface) {
- error = true;
if (Kind != Kind.Class) {
- string what = Kind == Kind.Struct ? "Struct" : "Interface";
-
- Report.Error (527, Location,
- "In {0} `{1}', type `{2}' is not "+
- "an interface", what, Name, iface.Name);
+ // TODO: location of symbol related ....
+ Error_TypeInListIsNotInterface (Location, iface.FullName);
}
else if (base_class != null)
Report.Error (1721, Location,
"In Class `{0}', `{1}' is not " +
"an interface, a base class must be listed first", Name, iface.Name);
}
- continue;
+ return null;
}
for (int x = 0; x < i; x++) {
Report.Error (528, Location,
"`{0}' is already listed in " +
"interface list", iface.Name);
- error = true;
+ return null;
}
}
"interface `{0}' is less accessible " +
"than interface `{1}'", iface.Name,
Name);
- error = true;
+ return null;
}
}
-
- if (error)
- return null;
-
return ifaces;
}
- bool error = false;
-
+ protected void Error_TypeInListIsNotInterface (Location loc, string type)
+ {
+ Report.Error (527, loc, "'{0}': type in interface list is not an interface", type);
+ }
+
//
// Defines the type in the appropriate ModuleBuilder or TypeBuilder.
//
{
if (TypeBuilder != null)
return TypeBuilder;
-
- if (error)
- return null;
-
- if (InTransit) {
- Report.Error (146, Location, "Class definition is circular: `{0}'", Name);
- error = true;
- return null;
- }
InTransit = true;
- ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
-
- TypeExpr[] iface_exprs = GetClassBases (out base_type, out error);
- if (error)
+ TypeExpr[] iface_exprs = GetClassBases (out base_type);
+ if (iface_exprs == null && base_type != null) {
+ InTransit = false;
return null;
+ }
if (base_type == null) {
if (Kind == Kind.Class){
if (base_type != null) {
// FIXME: I think this should be ...ResolveType (Parent.EmitContext).
// However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
- ptype = base_type.ResolveType (ec);
+ ptype = base_type.ResolveType (TypeResolveEmitContext);
if (ptype == null) {
- error = true;
+ InTransit = false;
return null;
}
}
try {
if (IsTopLevel){
if (TypeManager.NamespaceClash (Name, Location)) {
- error = true;
+ InTransit = false;
return null;
}
Name, type_attributes, ptype, null);
} else {
- TypeBuilder builder = Parent.DefineType ();
- if (builder == null)
+ TypeBuilder builder = Parent.TypeBuilder;
+ if (builder == null) {
+ InTransit = false;
return null;
+ }
TypeBuilder = builder.DefineNestedType (
Basename, type_attributes, ptype, null);
}
catch (ArgumentException) {
Report.RuntimeMissingSupport (Location, "static classes");
+ InTransit = false;
return null;
}
-
- //
- // Structs with no fields need to have at least one byte.
- // The right thing would be to set the PackingSize in a DefineType
- // but there are no functions that allow interfaces *and* the size to
- // be specified.
- //
- if ((Kind == Kind.Struct) && !have_nonstatic_fields){
- TypeBuilder.DefineField ("$PRIVATE$", TypeManager.byte_type,
- FieldAttributes.Private);
+ if (Parts != null) {
+ ec = null;
+ foreach (ClassPart part in Parts) {
+ part.TypeBuilder = TypeBuilder;
+ part.ptype = ptype;
+ part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
+ part.ec.ContainerType = TypeBuilder;
+ }
+ }
+ else {
+ ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
+ ec.ContainerType = TypeBuilder;
}
// add interfaces that were not added at type creation
if (iface_exprs != null) {
// FIXME: I think this should be ...ExpandInterfaces (Parent.EmitContext, ...).
// However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
- ifaces = TypeManager.ExpandInterfaces (ec, iface_exprs);
+ TypeResolveEmitContext.ContainerType = TypeBuilder;
+ ifaces = TypeManager.ExpandInterfaces (TypeResolveEmitContext, iface_exprs);
if (ifaces == null) {
- error = true;
+ InTransit = false;
return null;
}
TypeManager.RegisterBuilder (TypeBuilder, ifaces);
}
- //
- // Finish the setup for the EmitContext
- //
- ec.ContainerType = TypeBuilder;
-
TypeManager.AddUserType (Name, TypeBuilder, this);
if (!(this is Iterator))
RootContext.RegisterOrder (this);
+ InTransit = false;
+
if (!DefineNestedTypes ()) {
- error = true;
return null;
}
- InTransit = false;
return TypeBuilder;
}
return false;
}
- if (Parts != null) {
- foreach (ClassPart part in Parts) {
- part.TypeBuilder = TypeBuilder;
- part.ptype = ptype;
- part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
- }
- }
-
return true;
}
}
}
- if (Parts != null) {
- foreach (ClassPart cp in Parts) {
- Type t = cp.PartFindNestedType (name);
- if (t != null)
- return t;
- }
- }
-
return null;
}
return;
}
- protected virtual void VerifyMembers (EmitContext ec)
+ void CheckMemberUsage (MemberCoreArrayList al, string member_type)
+ {
+ if (al == null)
+ return;
+
+ foreach (MemberCore mc in al) {
+ if ((mc.ModFlags & Modifiers.Accessibility) != Modifiers.PRIVATE)
+ continue;
+
+ if (!mc.IsUsed) {
+ Report.Warning (169, mc.Location, "The private {0} '{1}' is never used", member_type, mc.GetSignatureForError ());
+ }
+ }
+ }
+
+ public virtual void VerifyMembers ()
{
//
// Check for internal or private fields that were never assigned
//
- if (RootContext.WarningLevel >= 4) {
+ if (RootContext.WarningLevel >= 3) {
+ CheckMemberUsage (properties, "property");
+ CheckMemberUsage (methods, "method");
+ CheckMemberUsage (constants, "constant");
+
if (fields != null){
- foreach (Field f in fields) {
+ foreach (FieldMember f in fields) {
if ((f.ModFlags & Modifiers.Accessibility) != Modifiers.PRIVATE)
continue;
- if ((f.status & Field.Status.USED) == 0){
+ if (!f.IsUsed){
Report.Warning (169, f.Location, "The private field '{0}' is never used", f.GetSignatureForError ());
continue;
}
if (OptAttributes != null)
OptAttributes.Emit (ec, this);
+ //
+ // Structs with no fields need to have at least one byte.
+ // The right thing would be to set the PackingSize in a DefineType
+ // but there are no functions that allow interfaces *and* the size to
+ // be specified.
+ //
+
+ if ((Kind == Kind.Struct) && !have_nonstatic_fields){
+ FieldBuilder fb = TypeBuilder.DefineField ("$PRIVATE$", TypeManager.byte_type,
+ FieldAttributes.Private);
+
+ if (HasExplicitLayout){
+ object [] ctor_args = new object [1];
+ ctor_args [0] = 0;
+
+ CustomAttributeBuilder cba = new CustomAttributeBuilder (
+ TypeManager.field_offset_attribute_ctor, ctor_args);
+ fb.SetCustomAttribute (cba);
+ }
+ }
+
Emit ();
if (instance_constructors != null) {
if (Pending.VerifyPendingMethods ())
return;
- VerifyMembers (ec);
-
if (iterators != null)
foreach (Iterator iterator in iterators)
iterator.EmitType ();
Location loc)
{
PartialContainer pc;
- string full_name = member_name.GetName (true);
- DeclSpace ds = (DeclSpace) RootContext.Tree.Decls [full_name];
+ DeclSpace ds = RootContext.Tree.GetDecl (member_name);
if (ds != null) {
pc = ds as PartialContainer;
return pc;
}
- pc = new PartialContainer (ns, parent, member_name, mod_flags, kind, loc);
- RootContext.Tree.RecordDecl (full_name, pc);
- parent.AddType (pc);
- pc.Register ();
+ if (parent is ClassPart)
+ parent = ((ClassPart) parent).PartialContainer;
+
+ pc = new PartialContainer (ns.NS, parent, member_name, mod_flags, kind, loc);
+ RootContext.Tree.RecordDecl (member_name, pc);
+
+ if (kind == Kind.Interface)
+ parent.AddInterface (pc);
+ else if (kind == Kind.Class || kind == Kind.Struct)
+ parent.AddClassOrStruct (pc);
+ else
+ throw new InvalidOperationException ();
+
return pc;
}
if (pc == null) {
// An error occured; create a dummy container, but don't
// register it.
- pc = new PartialContainer (ns, parent, name, mod, kind, loc);
+ pc = new PartialContainer (ns.NS, parent, name, mod, kind, loc);
}
- ClassPart part = new ClassPart (ns, pc, mod, attrs, kind, loc);
+ ClassPart part = new ClassPart (ns, pc, parent, mod, attrs, kind, loc);
pc.AddPart (part);
return part;
}
- protected PartialContainer (NamespaceEntry ns, TypeContainer parent,
+ protected PartialContainer (Namespace ns, TypeContainer parent,
MemberName name, int mod, Kind kind, Location l)
- : base (ns, parent, name, null, kind, l)
+ : base (null, parent, name, null, kind, l)
{
- this.Namespace = ns.NS;
+ this.Namespace = ns;
switch (kind) {
case Kind.Class:
this.OriginalModFlags = mod;
}
- public override void Register ()
- {
- if (Kind == Kind.Interface)
- Parent.AddInterface (this);
- else if (Kind == Kind.Class || Kind == Kind.Struct)
- Parent.AddClassOrStruct (this);
- else
- throw new InvalidOperationException ();
- }
-
public override PendingImplementation GetPendingImplementations ()
{
return PendingImplementation.GetPendingImplementations (this);
}
- public ClassPart AddPart (NamespaceEntry ns, int mod, Attributes attrs,
- Location l)
- {
- ClassPart part = new ClassPart (ns, this, mod, attrs, Kind, l);
- AddPart (part);
- return part;
- }
-
- public override TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
return base.TypeAttr | DefaultTypeAttributes;
}
public readonly PartialContainer PartialContainer;
public readonly bool IsPartial;
- public ClassPart (NamespaceEntry ns, PartialContainer parent,
+ public ClassPart (NamespaceEntry ns, PartialContainer pc, TypeContainer parent,
int mod, Attributes attrs, Kind kind, Location l)
- : base (ns, parent.Parent, parent.MemberName, attrs, kind, l)
+ : base (ns, parent, pc.MemberName, attrs, kind, l)
{
- this.PartialContainer = parent;
+ this.PartialContainer = pc;
this.IsPartial = true;
int accmods;
- if (parent.Parent == null)
+ if (parent == null || parent == RootContext.Tree.Types)
accmods = Modifiers.INTERNAL;
else
accmods = Modifiers.PRIVATE;
- this.ModFlags = Modifiers.Check (
- parent.AllowedModifiers, mod, accmods, l);
- }
-
- public override void Register ()
- {
+ this.ModFlags = Modifiers.Check (pc.AllowedModifiers, mod, accmods, l);
}
public override PendingImplementation GetPendingImplementations ()
interface_type, full, name, loc);
}
- public override Type FindNestedType (string name)
+
+ public override void RegisterFieldForInitialization (FieldMember field)
{
- return PartialContainer.FindNestedType (name);
+ PartialContainer.RegisterFieldForInitialization (field);
+ }
+
+ public override bool EmitFieldInitializers (EmitContext ec)
+ {
+ return PartialContainer.EmitFieldInitializers (ec);
}
- public Type PartFindNestedType (string name)
+ public override Type FindNestedType (string name)
{
- return base.FindNestedType (name);
+ return PartialContainer.FindNestedType (name);
}
public override MemberCache BaseCache {
}
public abstract class ClassOrStruct : TypeContainer {
- bool hasExplicitLayout = false;
+ bool has_explicit_layout = false;
ListDictionary declarative_security;
public ClassOrStruct (NamespaceEntry ns, TypeContainer parent,
public override bool HasExplicitLayout {
get {
- return hasExplicitLayout;
+ return has_explicit_layout;
}
}
- protected override void VerifyMembers (EmitContext ec)
+ public override void VerifyMembers ()
{
- base.VerifyMembers (ec);
+ base.VerifyMembers ();
if ((events != null) && (RootContext.WarningLevel >= 3)) {
foreach (Event e in events){
return;
}
- if (a.Type == TypeManager.struct_layout_attribute_type &&
- a.GetLayoutKindValue () == LayoutKind.Explicit)
- hasExplicitLayout = true;
+ if (a.Type == TypeManager.struct_layout_attribute_type && a.GetLayoutKindValue () == LayoutKind.Explicit)
+ has_explicit_layout = true;
base.ApplyAttributeBuilder (a, cb);
}
}
}
}
-
- public override void Register ()
- {
- Parent.AddClassOrStruct (this);
- }
}
/// <summary>
{
if (RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized (l, "static classes");
- Environment.Exit (1);
}
}
if ((m.ModFlags & Modifiers.PROTECTED) != 0)
Report.Warning (628, 4, m.Location, "'{0}': new protected member declared in static class", m.GetSignatureForError (this));
+ if (m is Indexer) {
+ Report.Error (720, m.Location, "'{0}': cannot declare indexers in a static class", m.GetSignatureForError (this));
+ continue;
+ }
+
if ((m.ModFlags & Modifiers.STATIC) != 0 || m is Enum || m is Delegate)
continue;
return tb;
}
- public override TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
return base.TypeAttr | TypeAttributes.Abstract | TypeAttributes.Sealed;
}
Modifiers.SEALED |
Modifiers.UNSAFE;
+ bool WasTransitError;
+
public Class (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
Attributes attrs, Location l)
: base (ns, parent, name, attrs, Kind.Class, l)
}
}
+ if (a.Type == TypeManager.conditional_attribute_type &&
+ !(ptype == TypeManager.attribute_type || ptype.IsSubclassOf (TypeManager.attribute_type))) {
+ Report.Error (1689, a.Location, "Attribute 'System.Diagnostics.ConditionalAttribute' is only valid on methods or attribute classes");
+ return;
+ }
+
+ if (AttributeTester.IsAttributeExcluded (a.Type))
+ return;
+
base.ApplyAttributeBuilder (a, cb);
}
public override TypeBuilder DefineType()
{
+ if (InTransit) {
+ if (WasTransitError)
+ return null;
+ throw new CircularDepException (this);
+ }
+
if ((ModFlags & Modifiers.ABSTRACT) == Modifiers.ABSTRACT && (ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) != 0) {
Report.Error (418, Location, "'{0}': an abstract class cannot be sealed or static", GetSignatureForError ());
return null;
int accmods = Parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
ModFlags = Modifiers.Check (AllowedModifiersProp, ModFlags, accmods, Location);
- return base.DefineType ();
+ try {
+ return base.DefineType ();
+ }
+ catch (CircularDepException e) {
+ Report.SymbolRelatedToPreviousError (e.Container);
+ Report.Error (146, Location, "Circular base class dependency involving '{0}' and '{1}'",
+ GetSignatureForError (), e.Container.GetSignatureForError ());
+ WasTransitError = true;
+ return null;
+ }
+ }
+
+ /// Search for at least one defined condition in ConditionalAttribute of attribute class
+ /// Valid only for attribute classes.
+ public bool IsExcluded ()
+ {
+ if ((caching_flags & Flags.Excluded_Undetected) == 0)
+ return (caching_flags & Flags.Excluded) != 0;
+
+ caching_flags &= ~Flags.Excluded_Undetected;
+
+ if (OptAttributes == null)
+ return false;
+
+ Attribute[] attrs = OptAttributes.SearchMulti (TypeManager.conditional_attribute_type, ec);
+
+ if (attrs == null)
+ return false;
+
+ foreach (Attribute a in attrs) {
+ string condition = a.GetConditionalAttributeValue (Parent.EmitContext);
+ if (RootContext.AllDefines.Contains (condition))
+ return false;
+ }
+
+ caching_flags |= Flags.Excluded;
+ return true;
}
//
// FIXME: How do we deal with the user specifying a different
// layout?
//
- public override TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
return base.TypeAttr | DefaultTypeAttributes;
}
// in some cases (Sealed for example is mandatory for a class,
// but what SequentialLayout can be changed
//
- public override TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
return base.TypeAttr | DefaultTypeAttributes;
}
}
+
+ public override TypeBuilder DefineType()
+ {
+ if (InTransit) {
+ InTransit = false;
+ throw new CircularDepException (this);
+ }
+
+ try {
+ return base.DefineType ();
+ }
+ catch (CircularDepException e) {
+ InTransit = false;
+ Report.SymbolRelatedToPreviousError (this);
+ Error_TypeInListIsNotInterface (e.Container.Location, GetSignatureForError ());
+ return null;
+ }
+ }
}
/// <summary>
/// Interfaces
/// </summary>
public class Interface : TypeContainer, IMemberContainer {
+
+ bool WasTransitError;
+
/// <summary>
/// Modifiers allowed in a class declaration
/// </summary>
this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
}
- public override void Register ()
- {
- Parent.AddInterface (this);
- }
-
public override PendingImplementation GetPendingImplementations ()
{
return null;
TypeAttributes.Abstract |
TypeAttributes.Interface;
- public override TypeAttributes TypeAttr {
+ protected override TypeAttributes TypeAttr {
get {
return base.TypeAttr | DefaultTypeAttributes;
}
}
+
+ public override TypeBuilder DefineType()
+ {
+ if (InTransit) {
+ if (WasTransitError)
+ return null;
+ throw new CircularDepException (this);
+ }
+
+ try {
+ return base.DefineType ();
+ }
+ catch (CircularDepException e) {
+ Report.SymbolRelatedToPreviousError (e.Container);
+ Report.Error (529, Location, "Inherited interface '{0}' causes a cycle in the interface hierarchy of '{1}'",
+ e.Container.GetSignatureForError (), GetSignatureForError ());
+ WasTransitError = true;
+ return null;
+ }
+ }
+
+ protected override bool VerifyClsCompliance (DeclSpace ds)
+ {
+ if (!base.VerifyClsCompliance (ds))
+ return false;
+
+ if (ifaces != null) {
+ foreach (Type t in ifaces) {
+ if (AttributeTester.IsClsCompliant (t))
+ continue;
+
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Warning (3027, 1, Location, "'{0}' is not CLS-compliant because base interface '{1}' is not CLS-compliant",
+ GetSignatureForError (), TypeManager.CSharpName (t));
+ }
+ }
+
+ return true;
+ }
}
public abstract class MethodCore : MemberBase {
if ((ModFlags & Modifiers.NEW) == 0) {
if (MemberType != TypeManager.TypeToCoreType (base_ret_type)) {
Report.SymbolRelatedToPreviousError (base_method);
- Report.Error (508, Location, GetSignatureForError (Parent) + ": cannot " +
- "change return type when overriding inherited member");
+ if (this is PropertyBase) {
+ Report.Error (1715, Location, "'{0}': type must be '{1}' to match overridden member '{2}'",
+ GetSignatureForError (), TypeManager.CSharpName (base_ret_type), TypeManager.CSharpSignature (base_method));
+ }
+ else {
+ Report.Error (508, Location, GetSignatureForError (Parent) + ": cannot " +
+ "change return type when overriding inherited member");
+ }
return false;
}
} else {
return true;
}
+ public override bool IsUsed
+ {
+ get {
+ if (IsExplicitImpl)
+ return true;
+
+ return base.IsUsed;
+ }
+ }
+
//
// Returns a string that represents the signature for this
// member which should be used in XML documentation.
}
if (ReturnType != TypeManager.void_type) {
- Report.Error (578, Location, "Conditional not valid on '{0}' because its return new ErrorData ( type is not void", GetSignatureForError ());
+ Report.Error (578, Location, "Conditional not valid on '{0}' because its return type is not void", GetSignatureForError ());
return;
}
if (!MethodData.Define (Parent))
return false;
+ if (ReturnType == TypeManager.void_type && ParameterTypes.Length == 0 &&
+ Name == "Finalize" && !(this is Destructor)) {
+ Report.Warning (465, 1, Location, "Introducing a 'Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
+ }
+
//
// Setup iterator if we are one
//
if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
Iterator iterator = new Iterator (
- Parent, Name, MemberType, ParameterTypes,
+ Parent, Name, MemberType,
ParameterInfo, ModFlags, block, Location);
if (!iterator.DefineIterator ())
(RootContext.MainClass == null ||
RootContext.MainClass == Parent.TypeBuilder.FullName)){
if (IsEntryPoint (MethodBuilder, ParameterInfo)) {
+ IMethodData md = TypeManager.GetMethod (MethodBuilder);
+ md.SetMemberIsUsed ();
+
if (RootContext.EntryPoint == null) {
RootContext.EntryPoint = MethodBuilder;
RootContext.EntryPointLocation = Location;
}
}
- public bool Resolve (ConstructorBuilder caller_builder, EmitContext ec)
+ public bool Resolve (ConstructorBuilder caller_builder, Block block, EmitContext ec)
{
Expression base_constructor_group;
Type t;
bool error = false;
- ec.CurrentBlock = new ToplevelBlock (Block.Flags.Implicit, parameters, loc);
+ ec.CurrentBlock = block;
if (argument_list != null){
foreach (Argument a in argument_list){
Invocation.EmitCall (ec, true, false, ec.GetThis (loc), base_constructor, argument_list, loc);
}
}
-
- /// <summary>
- /// Method search for base ctor. (We do not cache it).
- /// </summary>
- Constructor GetOverloadedConstructor (TypeContainer tc)
- {
- if (tc.InstanceConstructors == null)
- return null;
-
- foreach (Constructor c in tc.InstanceConstructors) {
- if (Arguments == null) {
- if (c.ParameterTypes.Length == 0)
- return c;
-
- continue;
- }
-
- bool ok = true;
-
- int count = c.ParameterInfo.Count;
- if ((count > 0) &&
- c.ParameterInfo.ParameterModifier (count - 1) == Parameter.Modifier.PARAMS) {
- for (int i = 0; i < count-1; i++)
- if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
- ok = false;
- break;
- }
- } else {
- if (c.ParameterTypes.Length != Arguments.Count)
- continue;
-
- for (int i = 0; i < Arguments.Count; ++i)
- if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
- ok = false;
- break;
- }
- }
-
- if (!ok)
- continue;
-
- return c;
- }
-
- return null;
- }
-
- //TODO: implement caching when it will be necessary
- public virtual void CheckObsoleteAttribute (TypeContainer tc, Location loc)
- {
- Constructor ctor = GetOverloadedConstructor (tc);
- if (ctor == null)
- return;
-
- ObsoleteAttribute oa = ctor.GetObsoleteAttribute (tc);
- if (oa == null)
- return;
-
- AttributeTester.Report_ObsoleteMessage (oa, ctor.GetSignatureForError (), loc);
- }
}
public class ConstructorBaseInitializer : ConstructorInitializer {
base (argument_list, pars, l)
{
}
-
- public override void CheckObsoleteAttribute(TypeContainer tc, Location loc) {
- if (base_constructor == null)
- return;
-
- TypeContainer type_ds = TypeManager.LookupTypeContainer (tc.TypeBuilder.BaseType);
- if (type_ds == null) {
- ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (base_constructor);
-
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (base_constructor), loc);
-
- return;
- }
-
- base.CheckObsoleteAttribute (type_ds, loc);
- }
-
}
public class ConstructorThisInitializer : ConstructorInitializer {
return;
}
+ // If this is a non-static `struct' constructor and doesn't have any
+ // initializer, it must initialize all of the struct's fields.
+ if ((Parent.Kind == Kind.Struct) &&
+ ((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
+ Block.AddThisVariable (Parent, Location);
+
+ if (block != null)
+ block.ResolveMeta (ec, ParameterInfo);
+
if ((ModFlags & Modifiers.STATIC) == 0){
if (Parent.Kind == Kind.Class && Initializer == null)
Initializer = new ConstructorBaseInitializer (
// `this' access
//
ec.IsStatic = true;
- if (Initializer != null && !Initializer.Resolve (ConstructorBuilder, ec))
+ if ((Initializer != null) &&
+ !Initializer.Resolve (ConstructorBuilder, block, ec))
return;
ec.IsStatic = false;
}
- Parameters.LabelParameters (ec, ConstructorBuilder, Location);
+ Parameters.LabelParameters (ec, ConstructorBuilder);
SourceMethod source = SourceMethod.Create (
Parent, ConstructorBuilder, block);
}
}
if (Initializer != null) {
- if (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent.Parent) == null)
- Initializer.CheckObsoleteAttribute (Parent, Location);
- else
+ if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute (Parent) != null)
ec.TestObsoleteMethodUsage = false;
+
Initializer.Emit (ec);
}
if (OptAttributes != null)
OptAttributes.Emit (ec, this);
- // If this is a non-static `struct' constructor and doesn't have any
- // initializer, it must initialize all of the struct's fields.
- if ((Parent.Kind == Kind.Struct) &&
- ((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
- Block.AddThisVariable (Parent, Location);
-
ec.EmitTopBlock (block, ParameterInfo, Location);
if (source != null)
public ObsoleteAttribute GetObsoleteAttribute ()
{
- return null;
+ return GetObsoleteAttribute (Parent);
}
public bool IsExcluded(EmitContext ec)
string GetSignatureForError (TypeContainer tc);
bool IsExcluded (EmitContext ec);
bool IsClsCompliaceRequired (DeclSpace ds);
+ void SetMemberIsUsed ();
}
//
if (container.Pending != null){
if (member is Indexer) // TODO: test it, but it should work without this IF
implementing = container.Pending.IsInterfaceIndexer (
- member.InterfaceType, method.ReturnType, ParameterTypes);
+ member.InterfaceType, method.ReturnType, ParameterInfo);
else
implementing = container.Pending.IsInterfaceMethod (
- member.InterfaceType, name, method.ReturnType, ParameterTypes);
+ member.InterfaceType, name, method.ReturnType, ParameterInfo);
if (member.InterfaceType != null){
if (implementing == null){
if (member is PropertyBase) {
Report.Error (550, method.Location, "'{0}' is an accessor not found in interface member '{1}'",
- method.GetSignatureForError (container), member.ExplicitInterfaceName);
+ method.GetSignatureForError (container), member.Name);
} else {
Report.Error (539, method.Location,
}
return false;
}
+ if (implementing.IsSpecialName && !((member is PropertyBase || member is EventProperty))) {
+ Report.SymbolRelatedToPreviousError (implementing);
+ Report.Error (683, method.Location, "'{0}' explicit method implementation cannot implement '{1}' because it is an accessor",
+ member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
+ return false;
+ }
method_name = member.InterfaceType.FullName + "." + name;
} else {
if (implementing != null && method is AbstractPropertyEventMethod && !implementing.IsSpecialName) {
Report.SymbolRelatedToPreviousError (implementing);
- Report.Error (688, method.Location, "Accessor '{0}' cannot implement interface member '{1}' for type '{2}'. Use an explicit interface implementation",
+ Report.Error (686, method.Location, "Accessor '{0}' cannot implement interface member '{1}' for type '{2}'. Use an explicit interface implementation",
method.GetSignatureForError (container), TypeManager.CSharpSignature (implementing), container.GetSignatureForError ());
return false;
}
if (member is Indexer) {
container.Pending.ImplementIndexer (
member.InterfaceType, builder, method.ReturnType,
- ParameterTypes, member.IsExplicitImpl);
+ ParameterInfo, member.IsExplicitImpl);
} else
container.Pending.ImplementMethod (
member.InterfaceType, name, method.ReturnType,
- ParameterTypes, member.IsExplicitImpl);
+ ParameterInfo, member.IsExplicitImpl);
if (member.IsExplicitImpl)
container.TypeBuilder.DefineMethodOverride (
else
ec = method.CreateEmitContext (container, null);
- if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container.Parent) != null)
+ if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container) != null)
ec.TestObsoleteMethodUsage = false;
Location loc = method.Location;
OptAttributes.Emit (ec, kind);
if (member is MethodCore)
- ((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder, loc);
+ ((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder);
ToplevelBlock block = method.Block;
// The "short" name of this property / indexer / event. This is the
// name without the explicit interface.
//
- public string ShortName;
+ public string ShortName {
+ get { return MemberName.Name; }
+ set {
+ SetMemberName (new MemberName (MemberName.Left, value));
+ }
+ }
//
// The type of this property / indexer / event
//
- public Type MemberType;
+ Type member_type;
+ public Type MemberType {
+ get {
+ if (member_type == null && Type != null) {
+ EmitContext ec = Parent.EmitContext;
+ bool old_unsafe = ec.InUnsafe;
+ ec.InUnsafe = InUnsafe;
+ Type = Type.ResolveAsTypeTerminal (ec, false);
+ ec.InUnsafe = old_unsafe;
- //
- // If true, this is an explicit interface implementation
- //
- public bool IsExplicitImpl = false;
+ member_type = Type == null ? null : Type.Type;
+ }
+ return member_type;
+ }
+ }
//
- // The name of the interface we are explicitly implementing
+ // Whether this is an interface member.
//
- public MemberName ExplicitInterfaceName = null;
+ public bool IsInterface;
//
- // Whether this is an interface member.
+ // If true, this is an explicit interface implementation
//
- public bool IsInterface;
+ public bool IsExplicitImpl;
//
- // If true, the interface type we are explicitly implementing
+ // The interface type we are explicitly implementing
//
public Type InterfaceType = null;
explicit_mod_flags = mod;
Type = type;
ModFlags = Modifiers.Check (allowed_mod, mod, def_mod, loc);
-
- // Check for explicit interface implementation
- if (MemberName.Left != null) {
- ExplicitInterfaceName = MemberName.Left;
- ShortName = MemberName.Name;
- IsExplicitImpl = true;
- } else
- ShortName = Name;
+ IsExplicitImpl = (MemberName.Left != null);
}
protected virtual bool CheckBase ()
flags = Modifiers.MethodAttr (ModFlags);
}
- // Lookup Type, verify validity
- bool old_unsafe = ec.InUnsafe;
- ec.InUnsafe = InUnsafe;
- Type = Type.ResolveAsTypeTerminal (ec, false);
- ec.InUnsafe = old_unsafe;
-
- if (Type == null)
+ if (MemberType == null)
return false;
- MemberType = Type.Type;
-
if ((Parent.ModFlags & Modifiers.SEALED) != 0){
if ((ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0){
Report.Error (549, Location, "Virtual method can not be contained in sealed class");
return false;
if (IsExplicitImpl) {
- Expression expr = ExplicitInterfaceName.GetTypeExpression (Location);
+ Expression expr = MemberName.Left.GetTypeExpression (Location);
TypeExpr texpr = expr.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
return false;
Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
return false;
}
-
-#if FIXME
- // Compute the full name that we need to export.
- if (InterfaceType.FullName != ExplicitInterfaceName) {
- ExplicitInterfaceName = InterfaceType.FullName;
- UpdateMemberName ();
- }
-#endif
if (!Parent.VerifyImplements (InterfaceType, ShortName, Name, Location))
return false;
return true;
}
- /// <summary>
- /// The name of the member can be changed during definition (see IndexerName attribute)
- /// </summary>
- protected virtual void UpdateMemberName ()
- {
- MemberName.Name = ShortName;
- }
-
public override string GetSignatureForError (TypeContainer tc)
{
return String.Concat (tc.Name, '.', base.GetSignatureForError (tc));
[Flags]
public enum Status : byte {
ASSIGNED = 1,
- USED = 2,
HAS_OFFSET = 4 // Used by FieldMember.
}
else
e = new ArrayCreation (Type, "", (ArrayList)init, Location);
- ec.IsFieldInitializer = true;
- e = e.DoResolve (ec);
- ec.IsFieldInitializer = false;
+ EmitContext parent_ec = Parent.EmitContext;
+
+ bool old_is_static = parent_ec.IsStatic;
+ parent_ec.IsStatic = ec.IsStatic;
+ parent_ec.IsFieldInitializer = true;
+ e = e.DoResolve (parent_ec);
+ parent_ec.IsFieldInitializer = false;
+ parent_ec.IsStatic = old_is_static;
init_expr = e;
init_expr_initialized = true;
public abstract class FieldMember: FieldBase
{
-
-
protected FieldMember (TypeContainer parent, Expression type, int mod,
int allowed_mod, MemberName name, object init, Attributes attrs, Location loc)
- : base (parent, type, mod, allowed_mod, name, init, attrs, loc)
+ : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, init, attrs, loc)
{
+ if ((mod & Modifiers.ABSTRACT) != 0)
+ Report.Error (681, loc, "The modifier 'abstract' is not valid on fields. Try using a property instead");
}
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
return;
}
}
+
+#if NET_2_0
+ if (a.Type == TypeManager.fixed_buffer_attr_type) {
+ Report.Error (1716, Location, "Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the 'fixed' field modifier instead");
+ return;
+ }
+#endif
+
base.ApplyAttributeBuilder (a, cb);
}
if (ec == null)
throw new InternalErrorException ("FieldMember.Define called too early");
- bool old_unsafe = ec.InUnsafe;
- ec.InUnsafe = InUnsafe;
- TypeExpr texpr = Type.ResolveAsTypeTerminal (ec, false);
- if (texpr == null)
+ if (MemberType == null)
return false;
- MemberType = texpr.ResolveType (ec);
-
- ec.InUnsafe = old_unsafe;
-
if (MemberType == TypeManager.void_type) {
Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
return false;
{
#if !NET_2_0
if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) != 0)
- Report.Warning (-23, Location, "Only not private or internal fixed sized buffers are supported by .NET 1.x");
+ Report.Warning (-23, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
#endif
if (Parent.Kind != Kind.Struct) {
if (!base.Define ())
return false;
- if (!MemberType.IsPrimitive) {
+ if (!TypeManager.IsPrimitiveType (MemberType)) {
Report.Error (1663, Location, "Fixed sized buffer type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double");
return false;
}
return false;
}
- buffer_size = (int)c.GetValue ();
+ IntConstant buffer_size_const = c.ToInt (Location);
+ if (buffer_size_const == null)
+ return false;
+
+ buffer_size = buffer_size_const.Value;
+
if (buffer_size <= 0) {
Report.Error (1665, Location, "Fixed sized buffer '{0}' must have a length greater than zero", GetSignatureForError ());
return false;
}
- buffer_size *= Expression.GetTypeSize (MemberType);
+
+ int type_size = Expression.GetTypeSize (MemberType);
+
+ if (buffer_size > int.MaxValue / type_size) {
+ Report.Error (1664, Location, "Fixed sized buffer of length '{0}' and type '{1}' exceeded 2^31 limit",
+ buffer_size.ToString (), TypeManager.CSharpName (MemberType));
+ return false;
+ }
+
+ buffer_size *= type_size;
// Define nested
string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
return true;
}
+
+ protected override bool VerifyClsCompliance (DeclSpace ds)
+ {
+ if (!base.VerifyClsCompliance (ds))
+ return false;
+
+ if ((ModFlags & Modifiers.VOLATILE) != 0) {
+ Report.Warning (3026, 1, Location, "CLS-compliant field '{0}' cannot be volatile", GetSignatureForError ());
+ }
+
+ return true;
+ }
}
//
static MemberName SetupName (string prefix, MemberBase member)
{
- MemberName name = member.MemberName.Clone ();
- name.Name = prefix + member.ShortName;
- return name;
+ return new MemberName (member.MemberName.Left, prefix + member.ShortName);
}
public void UpdateName (MemberBase member)
{
- MemberName.Name = prefix + member.ShortName;
+ SetMemberName (SetupName (prefix, member));
}
#region IMethodData Members
public virtual void Emit (TypeContainer container)
{
- method_data.Emit (container, this);
+ EmitMethod (container);
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
block = null;
}
+ protected virtual void EmitMethod (TypeContainer container)
+ {
+ method_data.Emit (container, this);
+ }
+
public override bool IsClsCompliaceRequired(DeclSpace ds)
{
return false;
return true;
}
+ public override bool IsUsed
+ {
+ get {
+ if (IsDummy)
+ return false;
+
+ return base.IsUsed;
+ }
+ }
+
public new Location Location {
get {
return base.Location;
{
if (a.Target == AttributeTargets.Parameter) {
if (param_attr == null)
- param_attr = new ImplicitParameter (method_data.MethodBuilder);
+ param_attr = new ImplicitParameter (method_data.MethodBuilder, method.Location);
param_attr.ApplyAttributeBuilder (a, cb);
return;
protected virtual InternalParameters GetParameterInfo (EmitContext ec)
{
Parameter [] parms = new Parameter [1];
- parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null);
- Parameters parameters = new Parameters (parms, null, method.Location);
+ parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null, method.Location);
+ Parameters parameters = new Parameters (parms, null);
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
if (accessor.ModFlags != 0 && RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized (Location, "accessor modifiers");
- Environment.Exit (1);
}
}
ModFlags = method.ModFlags;
flags = method.flags;
} else {
+ if ((method.ModFlags & Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) {
+ Report.Error (442, Location, "{0}': abstract properties cannot have private accessors", GetSignatureForError (container));
+ }
+
CheckModifiers (container, ModFlags);
ModFlags |= (method.ModFlags & (~Modifiers.Accessibility));
+ ModFlags |= Modifiers.PROPERTY_CUSTOM;
flags = Modifiers.MethodAttr (ModFlags);
flags |= (method.flags & (~MethodAttributes.MemberAccessMask));
}
}
+ public bool HasCustomAccessModifier
+ {
+ get {
+ return (ModFlags & Modifiers.PROPERTY_CUSTOM) != 0;
+ }
+ }
+
public override Type[] ParameterTypes {
get {
return TypeManager.NoTypes;
return Get.IsDuplicateImplementation (mc) || Set.IsDuplicateImplementation (mc);
}
- protected override void UpdateMemberName ()
+ public override bool IsUsed
{
- base.UpdateMemberName ();
+ get {
+ if (IsExplicitImpl)
+ return true;
- Get.UpdateName (this);
- Set.UpdateName (this);
+ return Get.IsUsed | Set.IsUsed;
+ }
}
- protected override bool VerifyClsCompliance (DeclSpace ds)
+ protected override void SetMemberName (MemberName new_name)
{
- if (!base.VerifyClsCompliance (ds))
- return false;
+ base.SetMemberName (new_name);
- if ((Get.ModFlags != ModFlags && !Get.IsDummy) || (Set.ModFlags != ModFlags && !Set.IsDummy)) {
- Report.Error (3025, Get.ModFlags != ModFlags ? Get.Location : Set.Location,
- "CLS-compliant accessors must have the same accessibility as their property");
- }
- return true;
+ Get.UpdateName (this);
+ Set.UpdateName (this);
}
public override string[] ValidAttributeTargets {
if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
Iterator iterator = new Iterator (
Parent, "get", MemberType,
- TypeManager.NoTypes, Get.ParameterInfo,
+ Get.ParameterInfo,
ModFlags, Get.Block, Location);
if (!iterator.DefineIterator ())
public void SetUsed ()
{
- if (my_event != null)
- my_event.status = (FieldBase.Status.ASSIGNED | FieldBase.Status.USED);
+ if (my_event != null) {
+ my_event.status = FieldBase.Status.ASSIGNED;
+ my_event.SetMemberIsUsed ();
+ }
}
}
{
if (a.Target == AttributeTargets.Parameter) {
if (param_attr == null)
- param_attr = new ImplicitParameter (method_data.MethodBuilder);
+ param_attr = new ImplicitParameter (method_data.MethodBuilder, method.Location);
param_attr.ApplyAttributeBuilder (a, cb);
return;
}
- public override void Emit (TypeContainer tc)
+ protected override void EmitMethod (TypeContainer tc)
{
if (block != null) {
- base.Emit (tc);
+ base.EmitMethod (tc);
return;
}
+ if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0)
+ return;
+
ILGenerator ig = method_data.MethodBuilder.GetILGenerator ();
FieldInfo field_info = (FieldInfo)method.FieldBuilder;
ec.InUnsafe = InUnsafe;
Parameter [] parms = new Parameter [1];
- parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null);
- Parameters parameters = new Parameters (parms, null, Location);
+ parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null, Location);
+ Parameters parameters = new Parameters (parms, null);
Type [] types = parameters.GetParameterInfo (ec);
InternalParameters ip = new InternalParameters (types, parameters);
OptAttributes.Emit (ec, this);
}
- if (!IsInterface) {
- Add.Emit (Parent);
- Remove.Emit (Parent);
- }
+ Add.Emit (Parent);
+ Remove.Emit (Parent);
base.Emit ();
}
fixed_parms.CopyTo (tmp, 0);
tmp [fixed_parms.Length] = new Parameter (
- method.Type, "value", Parameter.Modifier.NONE, null);
+ method.Type, "value", Parameter.Modifier.NONE, null, method.Location);
- Parameters set_formal_params = new Parameters (tmp, null, method.Location);
+ Parameters set_formal_params = new Parameters (tmp, null);
Type [] types = set_formal_params.GetParameterInfo (ec);
return new InternalParameters (types, set_formal_params);
"The argument to the 'IndexerName' attribute must be a valid identifier");
return false;
}
-
- UpdateMemberName ();
}
}
string base_IndexerName = TypeManager.IndexerPropertyName (InterfaceType);
if (base_IndexerName != Name)
ShortName = base_IndexerName;
- UpdateMemberName ();
}
if (!Parent.AddToMemberContainer (this) ||