return new EmitContext (tc, ds, Location, ig, ReturnType, ModFlags, false);
}
+ public ObsoleteAttribute GetObsoleteAttribute ()
+ {
+ return GetObsoleteAttribute (ds);
+ }
#endregion
}
}
//TODO: implement caching when it will be necessary
- public virtual void CheckObsoleteAttribute (EmitContext ec, TypeContainer tc, Location loc)
+ public virtual void CheckObsoleteAttribute (TypeContainer tc, Location loc)
{
Constructor ctor = GetOverloadedConstructor (tc);
if (ctor == null)
return;
- ObsoleteAttribute oa = ctor.GetObsoleteAttribute (ec);
+ ObsoleteAttribute oa = ctor.GetObsoleteAttribute (tc);
if (oa == null)
return;
{
}
- public override void CheckObsoleteAttribute(EmitContext ec, TypeContainer tc, Location loc) {
+ public override void CheckObsoleteAttribute(TypeContainer tc, Location loc) {
if (parent_constructor == null)
return;
return;
}
- base.CheckObsoleteAttribute (ec, type_ds, loc);
+ base.CheckObsoleteAttribute (type_ds, loc);
}
}
}
}
if (Initializer != null) {
- Initializer.CheckObsoleteAttribute (ec, container, Location);
+ Initializer.CheckObsoleteAttribute (container, Location);
Initializer.Emit (ec);
}
Block Block { get; }
EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig);
+ ObsoleteAttribute GetObsoleteAttribute ();
}
//
// Attributes.
//
Attribute dllimport_attribute = null;
- string obsolete = null;
- bool obsolete_error = false;
public virtual bool ApplyAttributes (Attributes opt_attrs, bool is_method,
EmitContext ec)
if (attr_type == TypeManager.conditional_attribute_type) {
if (!ApplyConditionalAttribute (a))
return false;
- } else if (attr_type == TypeManager.obsolete_attribute_type) {
- if (!ApplyObsoleteAttribute (a))
- return false;
} else if (attr_type == TypeManager.dllimport_type) {
if (!is_method) {
Attribute.Error_AttributeNotValidForElement (a, method.Location);
return true;
}
- //
- // Applies the `Obsolete' attribute to the method.
- //
- protected virtual bool ApplyObsoleteAttribute (Attribute a)
- {
- if (obsolete != null) {
- Report.Error (579, method.Location, "Duplicate `Obsolete' attribute");
- return false;
- }
-
- obsolete = a.Obsolete_GetObsoleteMessage (out obsolete_error);
- return obsolete != null;
- }
-
//
// Applies the `Conditional' attribute to the method.
//
{
TypeManager.MethodFlags flags = 0;
- if (obsolete != null) {
- if (obsolete_error) {
- Report.Error (619, loc, "Method `" + member.Name +
- "' is obsolete: `" + obsolete + "'");
- return TypeManager.MethodFlags.IsObsoleteError;
- } else
- Report.Warning (618, loc, "Method `" + member.Name +
- "' is obsolete: `" + obsolete + "'");
-
- flags |= TypeManager.MethodFlags.IsObsolete;
- }
-
if (ShouldIgnore (loc))
flags |= TypeManager.MethodFlags.ShouldIgnore;
}
TypeManager.AddMethod (builder, this);
+ TypeManager.AddMethod2 (builder, method);
return true;
}
public override bool Define (TypeContainer container)
{
- Type t = container.ResolveType (Type, false, Location);
+ MemberType = container.ResolveType (Type, false, Location);
- if (t == null)
+ if (MemberType == null)
return false;
CheckBase (container);
- if (!container.AsAccessible (t, ModFlags)) {
+ if (!container.AsAccessible (MemberType, ModFlags)) {
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
- TypeManager.CSharpName (t) + "' is less " +
+ TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than field `" + Name + "'");
return false;
}
- if (t.IsPointer && !UnsafeOK (container))
+ if (MemberType.IsPointer && !UnsafeOK (container))
return false;
if (RootContext.WarningLevel > 1){
}
if ((ModFlags & Modifiers.VOLATILE) != 0){
- if (!t.IsClass){
- Type vt = t;
+ if (!MemberType.IsClass){
+ Type vt = MemberType;
if (TypeManager.IsEnumType (vt))
- vt = TypeManager.EnumToUnderlying (t);
+ vt = TypeManager.EnumToUnderlying (MemberType);
if (!((vt == TypeManager.bool_type) ||
(vt == TypeManager.sbyte_type) ||
if (container is Struct &&
((fa & FieldAttributes.Static) == 0) &&
- t == container.TypeBuilder &&
- !TypeManager.IsBuiltinType (t)){
+ MemberType == container.TypeBuilder &&
+ !TypeManager.IsBuiltinType (MemberType)){
Report.Error (523, Location, "Struct member `" + container.Name + "." + Name +
"' causes a cycle in the structure layout");
return false;
try {
FieldBuilder = container.TypeBuilder.DefineField (
- Name, t, Modifiers.FieldAttr (ModFlags));
+ Name, MemberType, Modifiers.FieldAttr (ModFlags));
TypeManager.RegisterFieldBase (FieldBuilder, this);
}
return new EmitContext (tc, method.ds, method.Location, ig, ReturnType, method.ModFlags, false);
}
+ public ObsoleteAttribute GetObsoleteAttribute ()
+ {
+ return method.GetObsoleteAttribute (method.ds);
+ }
#endregion
}
return new EmitContext (tc, method.ds, Location, ig, ReturnType, method.ModFlags, false);
}
+ public ObsoleteAttribute GetObsoleteAttribute ()
+ {
+ return method.GetObsoleteAttribute (method.ds);
+ }
+
public abstract string MethodName { get; }
#endregion