using System.Reflection;
using System.Reflection.Emit;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
struct TypeAndMethods {
public Type type;
Type current_type = t;
do {
- MemberInfo [] mi;
+ MemberList mi;
mi = TypeContainer.FindMembers (
current_type, MemberTypes.Method,
searching = false;
}
- if (mi == null)
+ if (mi.Count == 0)
continue;
- int count = mi.Length;
- if (count == 0)
- continue;
-
- if (count == 1 && !(mi [0] is MethodBase))
+ if (mi.Count == 1 && !(mi [0] is MethodBase))
searching = false;
else
list = TypeManager.CopyNewMethods (list, mi);
foreach (Type t in ifaces){
MethodInfo [] mi;
- if (t is TypeBuilder){
+ /*if (t is TypeBuilder){
Interface iface;
iface = TypeManager.LookupInterface (t);
- mi = iface.GetMethods ();
- } else
- mi = t.GetMethods ();
+ mi = iface.GetMethods (container);
+ } else*/
+ mi = t.GetMethods ();
int count = mi.Length;
pending_implementations [i].type = t;
// TypeBuilder.
//
ifaces = type_builder.GetInterfaces ();
+
#if DEBUG
{
Type x = type_builder;
foreach (TypeAndMethods tm in pending_implementations){
if (!(t == null || tm.type == t))
continue;
-
+
int i = 0;
foreach (MethodInfo m in tm.methods){
if (m == null){
container.TypeBuilder.DefineMethodOverride (proxy, iface_method);
}
+ static bool IsPropertyGetMethod (string m)
+ {
+ return (m.Substring (0, 4) == "get_");
+ }
+
+ static bool IsPropertySetMethod (string m)
+ {
+ return (m.Substring (0, 4) == "set_");
+ }
+
+ MethodInfo FindExplicitImplementation (string iface_name, string method_name)
+ {
+ if (container.Properties != null) {
+ foreach (Property p in container.Properties)
+ {
+ if (p.Implements != null) {
+ if (IsPropertyGetMethod (method_name) && (container.Namespace.Name + "." + p.Implements.ToString() == iface_name + "." + method_name.Substring(4)))
+ return p.PropertyBuilder.GetGetMethod(true);
+
+ if (IsPropertySetMethod (method_name) && (container.Namespace.Name + "." + p.Implements.ToString() == iface_name + "." + method_name.Substring(4)))
+ return p.PropertyBuilder.GetSetMethod(true);
+ }
+ }
+ }
+
+ if (container.Methods != null)
+ {
+ foreach (Method m in container.Methods)
+ {
+ if (m.Implements != null)
+ {
+ if (container.Namespace.Name + "." + m.Implements.ToString() == iface_name + "." + method_name)
+ return (MethodInfo) m.MethodBuilder;
+ }
+ }
+ }
+ return null;
+ }
+
/// <summary>
/// This function tells whether one of our parent classes implements
/// the given method (which turns out, it is valid to have an interface
bool ParentImplements (Type iface_type, MethodInfo mi)
{
MethodSignature ms;
+ MethodInfo mr;
Type [] args = TypeManager.GetArgumentTypes (mi);
+
ms = new MethodSignature (mi.Name, mi.ReturnType, args);
- MemberInfo [] list = TypeContainer.FindMembers (
+ MemberList list = TypeContainer.FindMembers (
container.TypeBuilder.BaseType, MemberTypes.Method | MemberTypes.Property,
BindingFlags.Public | BindingFlags.Instance,
MethodSignature.method_signature_filter, ms);
- if (list == null || list.Length == 0)
- return false;
+ if (list.Count == 0)
+ {
+ mr = FindExplicitImplementation (iface_type.ToString(), mi.Name);
+ if (mr == null)
+ return false;
+ }
+ else
+ mr = (MethodInfo) list[0];
- DefineProxy (iface_type, (MethodInfo) list [0], mi, args);
- return true;
+ DefineProxy (iface_type, mr, mi, args);
+ return true;
}
/// <summary>
type.FullName + "." + mi.Name + "'" + extra);
} else {
Report.Error (
- 534, container.Location,
+ 30610, container.Location,
"`" + container.Name + "' does not implement " +
- "inherited abstract member `" +
+ "inherited 'MustOverride' member `" +
type.FullName + "." + mi.Name + "'");
}
errors = true;