// Author: Miguel de Icaza (miguel@gnu.org)
// Marek Safar (marek.safar@seznam.cz)
//
-// Licensed under the terms of the GNU GPL
+// Dual licensed under the terms of the MIT X11 or GNU GPL
//
-// (C) 2001 Ximian, Inc (http://www.ximian.com)
-// (C) 2004 Novell, Inc
+// Copyright 2001 Ximian, Inc (http://www.ximian.com)
+// Copyright 2004-2008 Novell, Inc
//
// TODO: Move the method verification stuff from the class.cs and interface.cs here
//
return MakeName (Name, TypeArguments);
}
- public Expression GetTypeExpression ()
+ public ATypeNameExpression GetTypeExpression ()
{
if (Left == null) {
if (TypeArguments != null)
if (is_double_colon) {
if (Left.Left != null)
throw new InternalErrorException ("The left side of a :: should be an identifier");
- return new QualifiedAliasMember (Left.Name, Basename, Location);
+ return new QualifiedAliasMember (Left.Name, Name, TypeArguments, Location);
}
Expression lexpr = Left.GetTypeExpression ();
}
}
- public string FullName {
- get {
- if (TypeArguments != null)
- return Name + "<" + TypeArguments.ToString () + ">";
- else
- return Name;
- }
- }
-
public string MethodName {
get {
string connect = is_double_colon ? "::" : ".";
if (Left != null)
- return Left.FullName + connect + Name;
+ return Left.FullyQualifiedName + connect + Name;
else
return Name;
}
}
-
+
+ // Please use this only for error reporting. For normal uses, just use the Equals and GetHashCode methods that make
+ // MemberName a proper hash key, and avoid tons of memory allocations
+ string FullyQualifiedName {
+ get { return TypeArguments == null ? MethodName : MethodName + "<" + TypeArguments.GetSignatureForError () + ">"; }
+ }
+
public string GetSignatureForError ()
{
- if (TypeArguments != null)
- return MethodName + "<" + TypeArguments.GetSignatureForError () + ">";
-
- return MethodName;
+ string append = TypeArguments == null ? "" : "<" + TypeArguments.GetSignatureForError () + ">";
+ if (Left == null)
+ return Name + append;
+ string connect = is_double_colon ? "::" : ".";
+ return Left.GetSignatureForError () + connect + Name + append;
}
public override bool Equals (object other)
public TypeContainer PartialContainer;
- readonly bool is_generic;
+ protected readonly bool is_generic;
readonly int count_type_params;
- readonly int count_current_type_params;
//
// Whether we are Generic
PartialContainer = null;
if (name.TypeArguments != null) {
is_generic = true;
- count_type_params = count_current_type_params = name.TypeArguments.Count;
+ count_type_params = name.TypeArguments.Count;
}
if (parent != null)
count_type_params += parent.count_type_params;
type.GetSignatureForError ());
}
+ public override void Emit ()
+ {
+#if GMCS_SOURCE
+ if (type_params != null) {
+ int offset = count_type_params - type_params.Length;
+ for (int i = offset; i < type_params.Length; i++)
+ CurrentTypeParameters [i - offset].Emit ();
+ }
+#endif
+
+ base.Emit ();
+ }
+
public override string GetSignatureForError ()
{
if (IsGeneric) {
- return SimpleName.RemoveGenericArity (Name) + TypeParameter.GetSignatureForError (CurrentTypeParameters);
+ return SimpleName.RemoveGenericArity (Name) + TypeParameter.GetSignatureForError (type_params);
}
// Parent.GetSignatureForError
return Name;
return null;
}
- public virtual ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name)
+ public virtual ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
{
return null;
}
//
// Extensions for generics
//
- TypeParameter[] type_params;
+ protected TypeParameter[] type_params;
TypeParameter[] type_param_list;
- protected string GetInstantiationName ()
- {
- StringBuilder sb = new StringBuilder (Name);
- sb.Append ("<");
- for (int i = 0; i < type_param_list.Length; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (type_param_list [i].Name);
- }
- sb.Append (">");
- return sb.ToString ();
- }
-
bool check_type_parameter (ArrayList list, int start, string name)
{
for (int i = 0; i < start; i++) {
get {
if (!IsGeneric)
throw new InvalidOperationException ();
- if ((PartialContainer != null) && (PartialContainer != this))
- return PartialContainer.CurrentTypeParameters;
- if (type_params != null)
- return type_params;
- else
+
+ // TODO: Something is seriously broken here
+ if (type_params == null)
return new TypeParameter [0];
+
+ return type_params;
}
}
}
}
- public int CountCurrentTypeParameters {
- get {
- return count_current_type_params;
- }
- }
-
public TypeParameterExpr LookupGeneric (string name, Location loc)
{
if (!IsGeneric)