Author: martin
Date: 2005-04-29 01:52:54 -0400 (Fri, 29 Apr 2005)
New Revision: 43768
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/decl.cs
trunk/mcs/gmcs/pending.cs
trunk/mcs/gmcs/typemanager.cs
Log:
2005-04-29 Martin Baulig <[EMAIL PROTECTED]>
* typemanager.cs (TypeManager.GetFullName): Updated to the new
naming schema.
* class.cs (MethodCore.IsDuplicateImplementation): If we're an
explicit interface implementation, compare the interface types.
(MethodData.Define): Use the new naming scheme from the latest
.NET 2.x beta2.
(MemberBase.DoDefineBase): Resolve `InterfaceType' here.
* decl.cs (MemberName.GetMemberName): Removed.
(MemberName.MethodName, FullName): New properties.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-29 04:51:45 UTC (rev 43767)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-29 05:52:54 UTC (rev 43768)
@@ -1,3 +1,17 @@
+2005-04-29 Martin Baulig <[EMAIL PROTECTED]>
+
+ * typemanager.cs (TypeManager.GetFullName): Updated to the new
+ naming schema.
+
+ * class.cs (MethodCore.IsDuplicateImplementation): If we're an
+ explicit interface implementation, compare the interface types.
+ (MethodData.Define): Use the new naming scheme from the latest
+ .NET 2.x beta2.
+ (MemberBase.DoDefineBase): Resolve `InterfaceType' here.
+
+ * decl.cs (MemberName.GetMemberName): Removed.
+ (MemberName.MethodName, FullName): New properties.
+
2005-04-25 Raja R Harinath <[EMAIL PROTECTED]>
* gmcs.exe.config: Update v2.0.40607 -> v2.0.50215.
Modified: trunk/mcs/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-29 04:51:45 UTC (rev 43767)
+++ trunk/mcs/gmcs/class.cs 2005-04-29 05:52:54 UTC (rev 43768)
@@ -3748,6 +3748,9 @@
equal = false;
}
+ if (IsExplicitImpl && (method.InterfaceType !=
InterfaceType))
+ equal = may_unify = false;
+
// TODO: make operator compatible with MethodCore to
avoid this
if (this is Operator && method is Operator) {
if (MemberType != method.MemberType)
@@ -4135,8 +4138,12 @@
MethodBuilder mb = null;
if (GenericMethod != null) {
- string mname = MemberName.GetMethodName ();
- mb = Parent.TypeBuilder.DefineGenericMethod
(mname, flags);
+ string method_name = MemberName.Name;
+
+ if (IsExplicitImpl)
+ method_name = TypeManager.GetFullName
(InterfaceType) + "." + method_name;
+
+ mb = Parent.TypeBuilder.DefineGenericMethod
(method_name, flags);
if (!GenericMethod.Define (mb))
return false;
}
@@ -5037,14 +5044,8 @@
{
MethodInfo implementing = null;
- string prefix;
- if (member.IsExplicitImpl)
- prefix = member.InterfaceType.FullName + ".";
- else
- prefix = "";
-
string name = method.MethodName.Basename;
- string method_name = prefix + name;
+ string method_name = method.MethodName.FullName;
Type[] ParameterTypes = method.ParameterTypes;
@@ -5060,11 +5061,12 @@
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.Name);
+
method.GetSignatureForError (container), member.Name);
} else {
- Report.Error (539,
method.Location,
- "'{0}' in
explicit interface declaration is not a member of interface",
member.GetSignatureForError () );
+ Report.Error (539,
method.Location, "'{0}' in explicit interface " +
+
"declaration is not a member of interface",
+
member.Name);
}
return false;
}
@@ -5074,7 +5076,8 @@
member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
return false;
}
- method_name =
member.InterfaceType.FullName + "." + name;
+
+ method_name = TypeManager.GetFullName
(member.InterfaceType) + "." + method_name;
} else {
if (implementing != null && method is
AbstractPropertyEventMethod && !implementing.IsSpecialName) {
Report.SymbolRelatedToPreviousError (implementing);
@@ -5183,7 +5186,6 @@
if (member.IsExplicitImpl)
container.TypeBuilder.DefineMethodOverride (
builder, implementing);
-
}
TypeManager.RegisterMethod (builder, ParameterInfo,
ParameterTypes);
@@ -5533,6 +5535,25 @@
flags = Modifiers.MethodAttr (ModFlags);
}
+ if (IsExplicitImpl) {
+ Expression expr =
MemberName.Left.GetTypeExpression (Location);
+ TypeExpr iface_texpr =
expr.ResolveAsTypeTerminal (ec);
+ if (iface_texpr == null)
+ return false;
+
+ InterfaceType = iface_texpr.Type;
+
+ if (!InterfaceType.IsInterface) {
+ Report.Error (538, Location, "'{0}' in
explicit interface declaration is not an interface", TypeManager.CSharpName
(InterfaceType));
+ return false;
+ }
+
+ if (!Parent.VerifyImplements (InterfaceType,
ShortName, Name, Location))
+ return false;
+
+ Modifiers.Check
(Modifiers.AllowedExplicitImplFlags, explicit_mod_flags, 0, Location);
+ }
+
return true;
}
@@ -5590,25 +5611,6 @@
if (MemberType.IsPointer && !UnsafeOK (Parent))
return false;
- if (IsExplicitImpl) {
- Expression expr =
MemberName.Left.GetTypeExpression (Location);
- TypeExpr iface_texpr =
expr.ResolveAsTypeTerminal (ec);
- if (iface_texpr == null)
- return false;
-
- InterfaceType = iface_texpr.Type;
-
- if (!InterfaceType.IsInterface) {
- Report.Error (538, Location, "'{0}' in
explicit interface declaration is not an interface", TypeManager.CSharpName
(InterfaceType));
- return false;
- }
-
- if (!Parent.VerifyImplements (InterfaceType,
ShortName, Name, Location))
- return false;
-
- Modifiers.Check
(Modifiers.AllowedExplicitImplFlags, explicit_mod_flags, 0, Location);
- }
-
return true;
}
Modified: trunk/mcs/gmcs/decl.cs
===================================================================
--- trunk/mcs/gmcs/decl.cs 2005-04-29 04:51:45 UTC (rev 43767)
+++ trunk/mcs/gmcs/decl.cs 2005-04-29 05:52:54 UTC (rev 43768)
@@ -110,12 +110,13 @@
}
}
- public string GetMethodName ()
- {
- if (Left != null)
- return Left.GetTypeName () + "." + Name;
- else
- return Name;
+ public string MethodName {
+ get {
+ if (Left != null)
+ return Left.FullName + "." + Name;
+ else
+ return Name;
+ }
}
public static string MakeName (string name, TypeArguments args)
@@ -201,18 +202,21 @@
}
}
+ public string FullName {
+ get {
+ if (TypeArguments != null)
+ return Name + "<" + TypeArguments + ">";
+ else
+ return Name;
+ }
+ }
+
public override string ToString ()
{
- string full_name;
- if (TypeArguments != null)
- full_name = Name + "<" + TypeArguments + ">";
- else
- full_name = Name;
-
if (Left != null)
- return Left + "." + full_name;
+ return Left.FullName + "." + FullName;
else
- return full_name;
+ return FullName;
}
public override bool Equals (object other)
Modified: trunk/mcs/gmcs/pending.cs
===================================================================
--- trunk/mcs/gmcs/pending.cs 2005-04-29 04:51:45 UTC (rev 43767)
+++ trunk/mcs/gmcs/pending.cs 2005-04-29 05:52:54 UTC (rev 43768)
@@ -483,7 +483,7 @@
{
MethodBuilder proxy;
- string proxy_name = iface.Name + "." +
iface_method.Name;
+ string proxy_name = TypeManager.GetFullName (iface) +
"." + iface_method.Name;
proxy = container.TypeBuilder.DefineMethod (
proxy_name,
Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs 2005-04-29 04:51:45 UTC (rev 43767)
+++ trunk/mcs/gmcs/typemanager.cs 2005-04-29 05:52:54 UTC (rev 43768)
@@ -911,41 +911,45 @@
return mb.DeclaringType.FullName.Replace ('+', '.') + '.' +
name;
}
- static public string GetFullName (Type t)
+ private static void GetFullName_recursed (StringBuilder sb, Type t,
bool recursed)
{
- if (t.FullName == null)
- return t.Name;
+ if (t.IsGenericParameter) {
+ sb.Append (t.Name);
+ return;
+ }
- string name = t.FullName.Replace ('+', '.');
+ if (t.DeclaringType != null) {
+ GetFullName_recursed (sb, t.DeclaringType, true);
+ sb.Append (".");
+ }
- DeclSpace tc = LookupDeclSpace (t);
- if ((tc != null) && tc.IsGeneric) {
- TypeParameter[] tparam = tc.TypeParameters;
-
- StringBuilder sb = new StringBuilder (name);
- sb.Append ("<");
- for (int i = 0; i < tparam.Length; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (tparam [i].Name);
+ if (!recursed) {
+ string ns = t.Namespace;
+ if ((ns != null) && (ns != "")) {
+ sb.Append (ns);
+ sb.Append (".");
}
- sb.Append (">");
- return sb.ToString ();
- } else if (t.HasGenericArguments && !t.IsGenericInstance) {
- Type[] tparam = t.GetGenericArguments ();
+ }
- StringBuilder sb = new StringBuilder (name);
+ sb.Append (SimpleName.RemoveGenericArity (t.Name));
+
+ Type[] args = GetTypeArguments (t);
+ if (args.Length > 0) {
sb.Append ("<");
- for (int i = 0; i < tparam.Length; i++) {
+ for (int i = 0; i < args.Length; i++) {
if (i > 0)
sb.Append (",");
- sb.Append (tparam [i].Name);
+ sb.Append (GetFullName (args [i]));
}
sb.Append (">");
- return sb.ToString ();
}
+ }
- return name;
+ static public string GetFullName (Type t)
+ {
+ StringBuilder sb = new StringBuilder ();
+ GetFullName_recursed (sb, t, false);
+ return sb.ToString ();
}
/// <summary>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches