//
// Whether it is optional, this is used to allow the explicit/implicit
- // implementation when a parent class already implements an interface.
+ // implementation when a base class already implements an interface.
//
// For example:
//
/// <summary>
/// This is the array of TypeAndMethods that describes the pending implementations
- /// (both interfaces and abstract methods in parent class)
+ /// (both interfaces and abstract methods in base class)
/// </summary>
TypeAndMethods [] pending_implementations;
// <remarks>
// Returns a list of the abstract methods that are exposed by all of our
- // parents that we must implement. Notice that this `flattens' the
+ // bases that we must implement. Notice that this `flattens' the
// method search space, and takes into account overrides.
// </remarks>
static ArrayList GetAbstractMethods (Type t)
MethodInfo [] mi;
Type t = missing.Type;
+ if (!t.IsInterface)
+ continue;
+
if (t is TypeBuilder){
TypeContainer iface;
if (type_builder.BaseType == null)
return ret;
- Type [] parent_impls = TypeManager.GetInterfaces (type_builder.BaseType);
+ Type [] base_impls = TypeManager.GetInterfaces (type_builder.BaseType);
- foreach (Type t in parent_impls) {
+ foreach (Type t in base_impls) {
for (int i = 0; i < ret.Length; i ++) {
if (t == ret [i].Type) {
ret [i].Optional = true;
/// For that case, we create an explicit implementation function
/// I.M in Y.
/// </summary>
- void DefineProxy (Type iface, MethodInfo parent_method, MethodInfo iface_method,
+ void DefineProxy (Type iface, MethodInfo base_method, MethodInfo iface_method,
Type [] args)
{
MethodBuilder proxy;
MethodAttributes.NewSlot |
MethodAttributes.Virtual,
CallingConventions.Standard | CallingConventions.HasThis,
- parent_method.ReturnType, args);
+ base_method.ReturnType, args);
int top = args.Length;
ILGenerator ig = proxy.GetILGenerator ();
- ig.Emit (OpCodes.Ldarg_0);
- for (int i = 0; i < top; i++){
- switch (i){
- case 0:
- ig.Emit (OpCodes.Ldarg_1); break;
- case 1:
- ig.Emit (OpCodes.Ldarg_2); break;
- case 2:
- ig.Emit (OpCodes.Ldarg_3); break;
- default:
- ig.Emit (OpCodes.Ldarg, i - 1); break;
- }
- }
- ig.Emit (OpCodes.Call, parent_method);
+ for (int i = 0; i <= top; i++)
+ ParameterReference.EmitLdArg (ig, i);
+
+ ig.Emit (OpCodes.Call, base_method);
ig.Emit (OpCodes.Ret);
container.TypeBuilder.DefineMethodOverride (proxy, iface_method);
}
/// <summary>
- /// This function tells whether one of our parent classes implements
+ /// This function tells whether one of our base classes implements
/// the given method (which turns out, it is valid to have an interface
- /// implementation in a parent
+ /// implementation in a base
/// </summary>
- bool ParentImplements (Type iface_type, MethodInfo mi)
+ bool BaseImplements (Type iface_type, MethodInfo mi)
{
MethodSignature ms;
if (list.Count == 0)
return false;
- MethodInfo parent = (MethodInfo) list [0];
- if (!parent.IsAbstract)
- DefineProxy (iface_type, parent, mi, args);
+ MethodInfo base_method = (MethodInfo) list [0];
+ if (!base_method.IsAbstract)
+ DefineProxy (iface_type, base_method, mi, args);
return true;
}
for (i = 0; i < top; i++){
Type type = pending_implementations [i].type;
int j = 0;
-
+
foreach (MethodInfo mi in pending_implementations [i].methods){
if (mi == null)
continue;
continue;
}
- if (ParentImplements (type, mi))
+ if (BaseImplements (type, mi))
continue;
if (pending_implementations [i].optional)
if (pending_implementations [i].found [j]) {
string[] methodLabel = TypeManager.CSharpSignature (mi).Split ('.');
- Report.Error (536, container.Location, "'{0}' does not implement interface member '{1}'. '{2}.{3}' is either static, not public, or has the wrong return type",
- container.Name, TypeManager.CSharpSignature (mi), container.Name, methodLabel[methodLabel.Length - 1]);
+ Report.Error (536, container.Location,
+ "'{0}' does not implement interface member '{1}'. '{2}.{3}' " +
+ "is either static, not public, or has the wrong return type",
+ container.Name, TypeManager.CSharpSignature (mi),
+ container.Name, methodLabel[methodLabel.Length - 1]);
}
else {
Report.Error (535, container.Location, "'{0}' does not implement interface member '{1}'",