Author: raja
Date: 2005-03-22 05:30:18 -0500 (Tue, 22 Mar 2005)
New Revision: 42089
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/attribute.cs
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/cs-parser.jay
trunk/mcs/mcs/decl.cs
trunk/mcs/mcs/driver.cs
trunk/mcs/mcs/enum.cs
trunk/mcs/mcs/namespace.cs
trunk/mcs/mcs/report.cs
trunk/mcs/mcs/tree.cs
Log:
* cs-parser.jay: Pass MemberName to RootContext.Tree.RecordDecl.
(using_alias_directive, using_namespace_directive): Pass
MemberName, not an expression to Namespace.UsingAlias and
Namespace.Using.
(MakeName): Use the MemberName of the namespace.
* namespace.cs (Namespace.MemberName): New.
(UsingEntry.UsingEntry): Take a MemberName, not an expression.
(AliasEntry.AliasEntry, Namespace.Using, Namespace.UsingAlias):
Likewise.
* decl.cs (MemberName.Name): Make readonly.
(MemberName.FromDotted): New "constructor".
(MemberName.Equals, MemberName.GetHashCode): Implement overrides.
(MemberCore.Name): Compute from MemberName on demand.
(MemberCore.SetMemberName): Provide a way to change the
MemberName.
(MemberCore.AddToContainer): Don't take a fullname parameter.
* class.cs (TypeContainer.AddToMemberContainer): Don't add the
fully qualified name of the container to the member name.
(TypeContainer.AddToTypeContainer): Use a fully qualified name
only if the type is a member of the root container.
(TypeContainer.AddMethod, TypeContainer.AddProperty): Use
MemberName.Left rather than searching for an embedded ".".
(PartialContainer.CreatePart): Update to changes in RootContext.
(MemberBase.ShortName): Turn into a property. Use
MemberCore.SetMemberName.
(MemberBase.ExplicitInterfaceName): Remove.
(MemberBase.UpdateMemberName): Remove.
(AbstractPropertyEventMethod.UpdateName): Use SetMemberName.
(PropertyBase.SetMemberName): New override.
* tree.cs (Tree.RecordDecl): Take a MemberName and use it as hash key.
(Tree.GetDecl): New.
(Tree.AllDecls): Rename from Decls.
* attribute.cs, enum.cs, report.cs: Update to changes.
* driver.cs (MainDriver): Use MemberName.FromDotted on
RootContext.MainClass.
This patch uses MemberName more pervasively, and avoids allocating a
lot of memory to string concats.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/ChangeLog 2005-03-22 10:30:18 UTC (rev 42089)
@@ -1,3 +1,41 @@
+2005-03-22 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * cs-parser.jay: Pass MemberName to RootContext.Tree.RecordDecl.
+ (using_alias_directive, using_namespace_directive): Pass
+ MemberName, not an expression to Namespace.UsingAlias and
+ Namespace.Using.
+ (MakeName): Use the MemberName of the namespace.
+ * namespace.cs (Namespace.MemberName): New.
+ (UsingEntry.UsingEntry): Take a MemberName, not an expression.
+ (AliasEntry.AliasEntry, Namespace.Using, Namespace.UsingAlias):
+ Likewise.
+ * decl.cs (MemberName.Name): Make readonly.
+ (MemberName.FromDotted): New "constructor".
+ (MemberName.Equals, MemberName.GetHashCode): Implement overrides.
+ (MemberCore.Name): Compute from MemberName on demand.
+ (MemberCore.SetMemberName): Provide a way to change the
+ MemberName.
+ (MemberCore.AddToContainer): Don't take a fullname parameter.
+ * class.cs (TypeContainer.AddToMemberContainer): Don't add the
+ fully qualified name of the container to the member name.
+ (TypeContainer.AddToTypeContainer): Use a fully qualified name
+ only if the type is a member of the root container.
+ (TypeContainer.AddMethod, TypeContainer.AddProperty): Use
+ MemberName.Left rather than searching for an embedded ".".
+ (PartialContainer.CreatePart): Update to changes in RootContext.
+ (MemberBase.ShortName): Turn into a property. Use
+ MemberCore.SetMemberName.
+ (MemberBase.ExplicitInterfaceName): Remove.
+ (MemberBase.UpdateMemberName): Remove.
+ (AbstractPropertyEventMethod.UpdateName): Use SetMemberName.
+ (PropertyBase.SetMemberName): New override.
+ * tree.cs (Tree.RecordDecl): Take a MemberName and use it as hash key.
+ (Tree.GetDecl): New.
+ (Tree.AllDecls): Rename from Decls.
+ * attribute.cs, enum.cs, report.cs: Update to changes.
+ * driver.cs (MainDriver): Use MemberName.FromDotted on
+ RootContext.MainClass.
+
2005-03-21 Marek Safar <[EMAIL PROTECTED]>
* class.cs (FixedField.Define): Check for CS1664 and more sanity
@@ -4,7 +42,7 @@
checks.
* expression.cs (ElementAccess.DoResolveLValue): Check for CS1708.
-
+
2005-03-18 Marek Safar <[EMAIL PROTECTED]>
* modifiers.cs (Modifiers.PROPERTY_CUSTOM): New constant for
@@ -72,7 +110,7 @@
* expression.cs (ComposedCast.DoResolveAsTypeStep): Use
TypeManager.GetConstructedType.
* tree.cs (decl_ns_hash, LookupByNamespace): Remove.
-
+
2005-03-15 Marek Safar <[EMAIL PROTECTED]>
* class.cs (TypeContainer.CircularDepException) New nested
Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/attribute.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -189,24 +189,21 @@
ResolvePossibleAttributeTypes (ec, out t1, out t2);
- string NameAttribute = Name + "Attribute";
-
String err0616 = null;
if (t1 != null && ! t1.IsSubclassOf
(TypeManager.attribute_type)) {
t1 = null;
- err0616 = "'" + Name + "': is not an attribute
class";
+ err0616 = "'{0}' is not an attribute class";
}
if (t2 != null && ! t2.IsSubclassOf
(TypeManager.attribute_type)) {
t2 = null;
err0616 = (err0616 != null)
- ? "Neither '" + Name + "' nor '" +
NameAttribute +"' is an attribute class"
- : "'" + Name + "Attribute': is not an
attribute class";
+ ? "Neither '{0}' nor '{0}Attribute' is
an attribute class"
+ : "'{0}Attribute': is not an attribute
class";
}
if (t1 != null && t2 != null) {
- Report.Error(1614, Location, "'" + Name + "':
is ambiguous; "
- + " use either '@" + Name + "' or
'" + NameAttribute + "'");
+ Report.Error (1614, Location, "'{0}' is
ambiguous; use either '@{0}' or '{0}Attribute'", Name);
return null;
}
if (t1 != null)
@@ -215,13 +212,13 @@
return t2;
if (err0616 != null) {
- Report.Error (616, Location, err0616);
+ Report.Error (616, Location, err0616, Name);
return null;
}
Report.Error (246, Location,
- "Could not find attribute '" + Name
- + "' (are you missing a using directive
or an assembly reference ?)");
+ "Could not find attribute '{0}' (are you
missing a using directive or an assembly reference ?)",
+ Name);
resolve_error = true;
return null;
@@ -1506,8 +1503,10 @@
locase_table.Add (((string)de.Key).ToLower
(System.Globalization.CultureInfo.InvariantCulture), t);
}
- foreach (DictionaryEntry de in RootContext.Tree.Decls) {
- DeclSpace decl = (DeclSpace)de.Value;
+ foreach (DictionaryEntry de in
RootContext.Tree.AllDecls) {
+ if (!(de.Key is MemberName))
+ throw new InternalErrorException ("");
+ DeclSpace decl = (DeclSpace) de.Value;
if (!decl.IsClsCompliaceRequired (decl))
continue;
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/class.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -477,12 +477,13 @@
public bool AddToMemberContainer (MemberCore symbol)
{
- return AddToContainer (symbol, String.Concat (Name,
".", symbol.Name), symbol.Name);
+ return AddToContainer (symbol, symbol.Name);
}
bool AddToTypeContainer (DeclSpace ds)
{
- return AddToContainer (ds, ds.Name, ds.Basename);
+ // Parent == null ==> this == RootContext.Tree.Types
+ return AddToContainer (ds, (Parent == null) ? ds.Name :
ds.Basename);
}
public void AddConstant (Const constant)
@@ -534,7 +535,7 @@
if (methods == null)
methods = new MethodArrayList (this);
- if (method.Name.IndexOf ('.') != -1)
+ if (method.MemberName.Left != null)
methods.Insert (0, method);
else
methods.Add (method);
@@ -628,7 +629,7 @@
if (properties == null)
properties = new MemberCoreArrayList ();
- if (prop.Name.IndexOf ('.') != -1)
+ if (prop.MemberName.Left != null)
properties.Insert (0, prop);
else
properties.Add (prop);
@@ -2446,8 +2447,7 @@
Location loc)
{
PartialContainer pc;
- string full_name = member_name.GetName (true);
- DeclSpace ds = (DeclSpace) RootContext.Tree.Decls
[full_name];
+ DeclSpace ds = RootContext.Tree.GetDecl (member_name);
if (ds != null) {
pc = ds as PartialContainer;
@@ -2485,7 +2485,7 @@
parent = ((ClassPart) parent).PartialContainer;
pc = new PartialContainer (ns.NS, parent, member_name,
mod_flags, kind, loc);
- RootContext.Tree.RecordDecl (full_name, pc);
+ RootContext.Tree.RecordDecl (member_name, pc);
if (kind == Kind.Interface)
parent.AddInterface (pc);
@@ -4515,7 +4515,7 @@
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.ExplicitInterfaceName);
+
method.GetSignatureForError (container), member.Name);
} else {
Report.Error (539,
method.Location,
@@ -4824,7 +4824,12 @@
// The "short" name of this property / indexer / event. This
is the
// name without the explicit interface.
//
- public string ShortName;
+ public string ShortName {
+ get { return MemberName.Name; }
+ set {
+ SetMemberName (new MemberName (MemberName.Left,
value));
+ }
+ }
//
// The type of this property / indexer / event
@@ -4832,23 +4837,18 @@
public Type MemberType;
//
- // If true, this is an explicit interface implementation
+ // Whether this is an interface member.
//
- public bool IsExplicitImpl = false;
+ public bool IsInterface;
//
- // The name of the interface we are explicitly implementing
+ // If true, this is an explicit interface implementation
//
- public MemberName ExplicitInterfaceName = null;
+ public bool IsExplicitImpl;
//
- // Whether this is an interface member.
+ // The interface type we are explicitly implementing
//
- public bool IsInterface;
-
- //
- // If true, the interface type we are explicitly implementing
- //
public Type InterfaceType = null;
//
@@ -4862,14 +4862,7 @@
explicit_mod_flags = mod;
Type = type;
ModFlags = Modifiers.Check (allowed_mod, mod, def_mod,
loc);
-
- // Check for explicit interface implementation
- if (MemberName.Left != null) {
- ExplicitInterfaceName = MemberName.Left;
- ShortName = MemberName.Name;
- IsExplicitImpl = true;
- } else
- ShortName = Name;
+ IsExplicitImpl = (MemberName.Left != null);
}
protected virtual bool CheckBase ()
@@ -5012,7 +5005,7 @@
return false;
if (IsExplicitImpl) {
- Expression expr =
ExplicitInterfaceName.GetTypeExpression (Location);
+ Expression expr =
MemberName.Left.GetTypeExpression (Location);
TypeExpr texpr = expr.ResolveAsTypeTerminal
(ec, false);
if (texpr == null)
return false;
@@ -5023,14 +5016,6 @@
Report.Error (538, Location, "'{0}' in
explicit interface declaration is not an interface", TypeManager.CSharpName
(InterfaceType));
return false;
}
-
-#if FIXME
- // Compute the full name that we need to export.
- if (InterfaceType.FullName !=
ExplicitInterfaceName) {
- ExplicitInterfaceName =
InterfaceType.FullName;
- UpdateMemberName ();
- }
-#endif
if (!Parent.VerifyImplements (InterfaceType,
ShortName, Name, Location))
return false;
@@ -5041,14 +5026,6 @@
return true;
}
- /// <summary>
- /// The name of the member can be changed during definition
(see IndexerName attribute)
- /// </summary>
- protected virtual void UpdateMemberName ()
- {
- MemberName.Name = ShortName;
- }
-
public override string GetSignatureForError (TypeContainer tc)
{
return String.Concat (tc.Name, '.',
base.GetSignatureForError (tc));
@@ -5685,14 +5662,12 @@
static MemberName SetupName (string prefix, MemberBase member)
{
- MemberName name = member.MemberName.Clone ();
- name.Name = prefix + member.ShortName;
- return name;
+ return new MemberName (member.MemberName.Left, prefix +
member.ShortName);
}
public void UpdateName (MemberBase member)
{
- MemberName.Name = prefix + member.ShortName;
+ SetMemberName (SetupName (prefix, member));
}
#region IMethodData Members
@@ -6276,9 +6251,9 @@
return Get.IsDuplicateImplementation (mc) ||
Set.IsDuplicateImplementation (mc);
}
- protected override void UpdateMemberName ()
+ protected override void SetMemberName (MemberName new_name)
{
- base.UpdateMemberName ();
+ base.SetMemberName (new_name);
Get.UpdateName (this);
Set.UpdateName (this);
@@ -7124,8 +7099,6 @@
"The argument to
the 'IndexerName' attribute must be a valid identifier");
return false;
}
-
- UpdateMemberName ();
}
}
@@ -7133,7 +7106,6 @@
string base_IndexerName =
TypeManager.IndexerPropertyName (InterfaceType);
if (base_IndexerName != Name)
ShortName = base_IndexerName;
- UpdateMemberName ();
}
if (!Parent.AddToMemberContainer (this) ||
Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/cs-parser.jay 2005-03-22 10:30:18 UTC (rev 42089)
@@ -334,8 +334,7 @@
: USING IDENTIFIER ASSIGN
namespace_or_type_name SEMICOLON
{
- MemberName name = (MemberName) $4;
- current_namespace.UsingAlias ((string) $2,
name.GetTypeExpression (lexer.Location), lexer.Location);
+ current_namespace.UsingAlias ((string) $2, (MemberName) $4,
lexer.Location);
}
| USING error {
CheckIdentifierToken (yyToken);
@@ -345,8 +344,7 @@
using_namespace_directive
: USING namespace_name SEMICOLON
{
- MemberName ns_name = (MemberName) $2;
- current_namespace.Using (ns_name.GetTypeExpression
(lexer.Location), lexer.Location);
+ current_namespace.Using ((MemberName) $2, lexer.Location);
}
;
@@ -756,7 +754,7 @@
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
}
opt_class_base
@@ -1437,7 +1435,7 @@
current_container.AddInterface (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
}
opt_class_base
@@ -2287,9 +2285,9 @@
{
Location enum_location = lexer.Location;
- MemberName full_name = MakeName (new MemberName ((string) $4));
+ MemberName name = MakeName (new MemberName ((string) $4));
Enum e = new Enum (current_namespace, current_class,
(Expression) $5, (int) $2,
- full_name, (Attributes) $1, enum_location);
+ name, (Attributes) $1, enum_location);
if (RootContext.Documentation != null)
e.DocComment = enumTypeComment;
@@ -2301,7 +2299,6 @@
ev.DocComment);
}
- string name = full_name.GetName ();
current_container.AddEnum (e);
RootContext.Tree.RecordDecl (name, e);
$$ = e;
@@ -2404,7 +2401,7 @@
}
current_container.AddDelegate (del);
- RootContext.Tree.RecordDecl (name.GetName (true), del);
+ RootContext.Tree.RecordDecl (name, del);
$$ = del;
}
;
@@ -3415,7 +3412,7 @@
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
}
opt_class_base
@@ -4632,11 +4629,11 @@
MemberName
MakeName (MemberName class_name)
{
- string ns = current_namespace.FullName;
+ Namespace ns = current_namespace.NS;
if (current_container.Name == ""){
- if (ns != "")
- return new MemberName (new MemberName (ns), class_name);
+ if (ns.Name != "")
+ return new MemberName (ns.MemberName, class_name);
else
return class_name;
} else {
Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/decl.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -27,7 +27,7 @@
namespace Mono.CSharp {
public class MemberName {
- public string Name;
+ public readonly string Name;
public readonly MemberName Left;
public static readonly MemberName Null = new MemberName ("");
@@ -44,10 +44,24 @@
}
public MemberName (MemberName left, MemberName right)
- : this (left, right.Name)
{
+ Name = right.Name;
+ Left = (right.Left == null) ? left : new MemberName
(left, right.Left);
}
+ static readonly char [] dot_array = { '.' };
+
+ public static MemberName FromDotted (string name)
+ {
+ string [] elements = name.Split (dot_array);
+ int count = elements.Length;
+ int i = 0;
+ MemberName n = new MemberName (elements [i++]);
+ while (i < count)
+ n = new MemberName (n, elements [i++]);
+ return n;
+ }
+
public string GetName ()
{
return GetName (false);
@@ -114,6 +128,44 @@
else
return Name;
}
+
+ public override bool Equals (object other)
+ {
+ return Equals (other as MemberName);
+ }
+
+ public bool Equals (MemberName other)
+ {
+ if (this == other)
+ return true;
+ if (other == null || Name != other.Name)
+ return false;
+#if NET_2_0
+ if (TypeArguments == null)
+ return other.TypeArguments == null;
+
+ if (other.TypeArguments == null || TypeArguments.Count
!= other.TypeArguments.Count)
+ return false;
+#endif
+ if (Left == null)
+ return other.Left == null;
+
+ return Left.Equals (other.Left);
+ }
+
+ public override int GetHashCode ()
+ {
+ int hash = Name.GetHashCode ();
+ for (MemberName n = Left; n != null; n = n.Left)
+ hash ^= n.Name.GetHashCode ();
+
+#if NET_2_0
+ if (TypeArguments != null)
+ hash ^= TypeArguments.Count << 5;
+#endif
+
+ return hash & 0x7FFFFFFF;
+ }
}
/// <summary>
@@ -124,15 +176,21 @@
/// <summary>
/// Public name
/// </summary>
+
+ protected string cached_name;
public string Name {
get {
- // !(this is GenericMethod) && !(this is Method)
- return MemberName.GetName (false);
+ if (cached_name == null)
+ cached_name = MemberName.GetName
(false);
+ return cached_name;
}
}
// Is not readonly because of IndexerName attribute
- public MemberName MemberName;
+ private MemberName member_name;
+ public MemberName MemberName {
+ get { return member_name; }
+ }
/// <summary>
/// Modifier flags that the user specified in the source code
@@ -185,11 +243,17 @@
throw new InternalErrorException ("A
PartialContainer cannot be the direct parent of a member");
Parent = parent;
- MemberName = name;
+ member_name = name;
Location = loc;
caching_flags = Flags.Obsolete_Undetected |
Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected |
Flags.Excluded_Undetected;
}
+ protected virtual void SetMemberName (MemberName new_name)
+ {
+ member_name = new_name;
+ cached_name = null;
+ }
+
/// <summary>
/// Tests presence of ObsoleteAttribute and report proper error
/// </summary>
@@ -470,18 +534,18 @@
/// <summary>
/// Adds the member to defined_names table. It tests for
duplications and enclosing name conflicts
/// </summary>
- protected bool AddToContainer (MemberCore symbol, string
fullname, string basename)
+ protected bool AddToContainer (MemberCore symbol, string name)
{
- if (basename == Basename && !(this is Interface)) {
+ if (name == Basename && !(this is Interface) && !(this
is Enum)) {
Report.SymbolRelatedToPreviousError (this);
Report.Error (542, symbol.Location, "'{0}':
member names cannot be the same as their enclosing type",
symbol.GetSignatureForError ());
return false;
}
- MemberCore mc = (MemberCore)defined_names [fullname];
+ MemberCore mc = (MemberCore) defined_names [name];
if (mc == null) {
- defined_names.Add (fullname, symbol);
+ defined_names.Add (name, symbol);
return true;
}
@@ -489,7 +553,7 @@
return true;
Report.SymbolRelatedToPreviousError (mc);
- Report.Error (102, symbol.Location, "The type '{0}'
already contains a definition for '{1}'", GetSignatureForError (), basename);
+ Report.Error (102, symbol.Location, "The type '{0}'
already contains a definition for '{1}'", GetSignatureForError (), name);
return false;
}
Modified: trunk/mcs/mcs/driver.cs
===================================================================
--- trunk/mcs/mcs/driver.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/driver.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -1605,7 +1605,7 @@
if (ep == null) {
if (RootContext.MainClass != null) {
- DeclSpace main_cont =
RootContext.Tree.Decls [RootContext.MainClass] as DeclSpace;
+ DeclSpace main_cont =
RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass));
if (main_cont == null) {
Report.Error (1555,
output_file, "Could not find '{0}' specified for Main method",
RootContext.MainClass);
return false;
Modified: trunk/mcs/mcs/enum.cs
===================================================================
--- trunk/mcs/mcs/enum.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/enum.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -165,7 +165,7 @@
EnumMember em = new EnumMember (this, expr, name, loc,
opt_attrs);
em.DocComment = documentation;
- if (!AddToContainer (em, name, ""))
+ if (!AddToContainer (em, name))
return;
Modified: trunk/mcs/mcs/namespace.cs
===================================================================
--- trunk/mcs/mcs/namespace.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/namespace.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -28,6 +28,8 @@
Hashtable defined_names;
Hashtable cached_types;
+ public readonly MemberName MemberName;
+
public static Namespace Root;
static Namespace ()
@@ -64,6 +66,13 @@
else
fullname = parent.Name + "." + name;
+ if (parent != null && parent.MemberName !=
MemberName.Null)
+ MemberName = new MemberName (parent.MemberName,
name);
+ else if (name == "")
+ MemberName = MemberName.Null;
+ else
+ MemberName = new MemberName (name);
+
entries = new ArrayList ();
namespaces = new Hashtable ();
defined_names = new Hashtable ();
@@ -146,7 +155,7 @@
tdecl.DefineType ();
t = tdecl.TypeBuilder;
} else {
- string lookup = this == Namespace.Root
? name : FullName + "." + name;
+ string lookup = this == Namespace.Root
? name : fullname + "." + name;
t = TypeManager.LookupTypeReflection
(lookup);
}
te = t == null ? null : new TypeExpression (t,
Location.Null);
@@ -256,13 +265,15 @@
// exist.
//
public class UsingEntry {
- public Expression Name;
+ public MemberName Name;
+ public Expression Expr;
public readonly NamespaceEntry NamespaceEntry;
public readonly Location Location;
- public UsingEntry (NamespaceEntry entry, Expression
name, Location loc)
+ public UsingEntry (NamespaceEntry entry, MemberName
name, Location loc)
{
Name = name;
+ Expr = name.GetTypeExpression (loc);
NamespaceEntry = entry;
Location = loc;
}
@@ -276,7 +287,7 @@
DeclSpace root = RootContext.Tree.Types;
root.NamespaceEntry = NamespaceEntry;
- resolved = Name.ResolveAsTypeStep
(root.EmitContext);
+ resolved = Expr.ResolveAsTypeStep
(root.EmitContext);
root.NamespaceEntry = null;
return resolved as Namespace;
@@ -289,10 +300,10 @@
public readonly NamespaceEntry NamespaceEntry;
public readonly Location Location;
- public AliasEntry (NamespaceEntry entry, string name,
Expression alias, Location loc)
+ public AliasEntry (NamespaceEntry entry, string name,
MemberName alias, Location loc)
{
Name = name;
- Alias = alias;
+ Alias = alias.GetTypeExpression (loc);
NamespaceEntry = entry;
Location = loc;
}
@@ -327,7 +338,6 @@
else
ns = Namespace.Root;
ns.AddNamespaceEntry (this);
- this.FullName = ns.Name;
}
@@ -338,7 +348,6 @@
this.IsImplicit = true;
this.ID = ++next_id;
this.ns = ns;
- this.FullName = ns.Name;
}
//
@@ -361,7 +370,6 @@
}
static int next_id = 0;
- public readonly string FullName;
public readonly int ID;
public readonly bool IsImplicit;
@@ -398,22 +406,21 @@
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
- public void Using (Expression ns, Location loc)
+ public void Using (MemberName name, Location loc)
{
- string name = ns.ToString ();
if (DeclarationFound){
Report.Error (1529, loc, "A using clause must
precede all other namespace elements");
return;
}
- if (name == FullName)
+ if (name.Equals (ns.MemberName))
return;
if (using_clauses == null)
using_clauses = new ArrayList ();
foreach (UsingEntry old_entry in using_clauses) {
- if (old_entry.Name.ToString () == name) {
+ if (name.Equals (old_entry.Name)) {
if (RootContext.WarningLevel >= 3)
Report.Warning (105, loc, "The
using directive for '{0}' appeared previously in this namespace", name);
return;
@@ -421,11 +428,11 @@
}
- UsingEntry ue = new UsingEntry (Doppelganger, ns, loc);
+ UsingEntry ue = new UsingEntry (Doppelganger, name,
loc);
using_clauses.Add (ue);
}
- public void UsingAlias (string name, Expression alias, Location
loc)
+ public void UsingAlias (string name, MemberName alias, Location
loc)
{
if (DeclarationFound){
Report.Error (1529, loc, "A using clause must
precede all other namespace elements");
@@ -676,7 +683,7 @@
if (NS == Namespace.Root)
return "NamespaceEntry (<root>)";
else
- return String.Format ("NamespaceEntry
({0},{1},{2})", FullName, IsImplicit, ID);
+ return String.Format ("NamespaceEntry
({0},{1},{2})", ns.Name, IsImplicit, ID);
}
}
}
Modified: trunk/mcs/mcs/report.cs
===================================================================
--- trunk/mcs/mcs/report.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/report.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -308,8 +308,7 @@
return;
}
- string name = String.Concat (temp_ds.Name, ".",
mi.Name);
- MemberCore mc = temp_ds.GetDefinition (name);
+ MemberCore mc = temp_ds.GetDefinition (mi.Name);
SymbolRelatedToPreviousError (mc);
}
}
Modified: trunk/mcs/mcs/tree.cs
===================================================================
--- trunk/mcs/mcs/tree.cs 2005-03-22 10:27:54 UTC (rev 42088)
+++ trunk/mcs/mcs/tree.cs 2005-03-22 10:30:18 UTC (rev 42089)
@@ -45,7 +45,7 @@
decls = new Hashtable ();
}
- public void RecordDecl (string name, DeclSpace ds)
+ public void RecordDecl (MemberName name, DeclSpace ds)
{
DeclSpace other = (DeclSpace) decls [name];
if (other != null){
@@ -84,7 +84,12 @@
}
}
- public Hashtable Decls {
+ public DeclSpace GetDecl (MemberName name)
+ {
+ return (DeclSpace) decls [name];
+ }
+
+ public Hashtable AllDecls {
get {
return decls;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches