Author: martin
Date: 2005-04-18 03:07:01 -0400 (Mon, 18 Apr 2005)
New Revision: 43194
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/attribute.cs
trunk/mcs/gmcs/class.cs
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/gmcs/decl.cs
trunk/mcs/gmcs/driver.cs
trunk/mcs/gmcs/enum.cs
trunk/mcs/gmcs/namespace.cs
trunk/mcs/gmcs/report.cs
trunk/mcs/gmcs/tree.cs
Log:
**** Merged r42089 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-18 07:07:01 UTC (rev 43194)
@@ -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-04-16 Zoltan Varga <[EMAIL PROTECTED]>
* cs-parser.jay: Fix build.
Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/attribute.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -193,23 +193,20 @@
Type t1, t2;
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)
@@ -217,13 +214,13 @@
if (t2 != null)
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;
@@ -1510,8 +1507,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/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/class.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -474,12 +474,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)
@@ -531,7 +532,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);
@@ -539,7 +540,7 @@
public void AddConstructor (Constructor c)
{
- if (c.Name != Basename) {
+ if (c.Name != MemberName.Name) {
Report.Error (1520, c.Location, "Class, struct,
or interface method must have a return type");
}
@@ -622,7 +623,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);
@@ -904,7 +905,7 @@
if (Parts != null)
constructor_parent = (TypeContainer) Parts [0];
- c = new Constructor (constructor_parent, Basename, mods,
+ c = new Constructor (constructor_parent,
MemberName.Name, mods,
Parameters.EmptyReadOnlyParameters,
new ConstructorBaseInitializer (
null,
Parameters.EmptyReadOnlyParameters,
@@ -1733,7 +1734,7 @@
int len = list.Count;
for (int i = 0; i < len; ++i) {
DeclSpace ds = (DeclSpace) list [i];
- if (ds.Basename_with_arity == name) {
+ if (ds.Basename == name) {
ds.DefineType ();
return ds.TypeBuilder;
}
@@ -2607,8 +2608,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;
@@ -2670,7 +2670,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);
@@ -4939,7 +4939,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,
@@ -5267,7 +5267,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
@@ -5275,23 +5280,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;
//
@@ -5305,14 +5305,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 ()
@@ -5469,7 +5462,7 @@
return false;
if (IsExplicitImpl) {
- Expression expr =
ExplicitInterfaceName.GetTypeExpression (Location);
+ Expression expr =
MemberName.Left.GetTypeExpression (Location);
TypeExpr iface_texpr =
expr.ResolveAsTypeTerminal (ec);
if (iface_texpr == null)
return false;
@@ -5490,14 +5483,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));
@@ -6145,14 +6130,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
@@ -6740,9 +6723,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);
@@ -7600,8 +7583,6 @@
"The argument to
the 'IndexerName' attribute must be a valid identifier");
return false;
}
-
- UpdateMemberName ();
}
}
@@ -7609,7 +7590,6 @@
string base_IndexerName =
TypeManager.IndexerPropertyName (InterfaceType);
if (base_IndexerName != Name)
ShortName = base_IndexerName;
- UpdateMemberName ();
}
if (!Parent.AddToMemberContainer (this) ||
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/cs-parser.jay 2005-04-18 07:07:01 UTC (rev 43194)
@@ -340,8 +340,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);
@@ -351,8 +350,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);
}
;
@@ -777,7 +775,7 @@
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
lexer.ConstraintsParsing = true;
@@ -1477,7 +1475,7 @@
current_container.AddInterface (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
lexer.ConstraintsParsing = true;
@@ -2103,7 +2101,7 @@
}
IDENTIFIER OPEN_PARENS CLOSE_PARENS block
{
- if ((string) $5 != current_container.Basename){
+ if ((string) $5 != current_container.MemberName.Name){
Report.Error (574, lexer.Location, "Name of destructor
must match name of class");
} else if (current_container.Kind != Kind.Class){
Report.Error (575, lexer.Location, "Destructors are
only allowed in class types");
@@ -2392,9 +2390,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;
@@ -2406,7 +2404,6 @@
ev.DocComment);
}
- string name = full_name.GetName ();
current_container.AddEnum (e);
RootContext.Tree.RecordDecl (name, e);
$$ = e;
@@ -2508,7 +2505,7 @@
}
current_container.AddDelegate (del);
- RootContext.Tree.RecordDecl (name.GetName (true), del);
+ RootContext.Tree.RecordDecl (name, del);
current_delegate = del;
@@ -3670,7 +3667,7 @@
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ RootContext.Tree.RecordDecl (name, current_class);
}
lexer.ConstraintsParsing = true;
@@ -4947,11 +4944,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/gmcs/decl.cs
===================================================================
--- trunk/mcs/gmcs/decl.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/decl.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -23,7 +23,7 @@
namespace Mono.CSharp {
public class MemberName {
- public string Name;
+ public readonly string Name;
public readonly TypeArguments TypeArguments;
public readonly MemberName Left;
@@ -41,6 +41,11 @@
this.TypeArguments = args;
}
+ public MemberName (MemberName left, string name)
+ : this (left, name, null)
+ {
+ }
+
public MemberName (MemberName left, string name, TypeArguments
args)
: this (name, args)
{
@@ -50,8 +55,24 @@
public MemberName (MemberName left, MemberName right)
: this (left, right.Name, right.TypeArguments)
{
+ Name = right.Name;
+ Left = (right.Left == null) ? left : new MemberName
(left, right.Left);
+ TypeArguments = right.TypeArguments;
}
+ 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 ()
{
if (Left != null)
@@ -193,6 +214,43 @@
else
return full_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 ((TypeArguments != null) &&
+ (other.TypeArguments == null || TypeArguments.Count
!= other.TypeArguments.Count))
+ return false;
+
+ if ((TypeArguments == null) && (other.TypeArguments !=
null))
+ return false;
+
+ 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 (TypeArguments != null)
+ hash ^= TypeArguments.Count << 5;
+
+ return hash & 0x7FFFFFFF;
+ }
}
/// <summary>
@@ -203,14 +261,21 @@
/// <summary>
/// Public name
/// </summary>
+
+ protected string cached_name;
public string Name {
get {
- return MemberName.GetName (!(this is
GenericMethod) && !(this is Method));
+ if (cached_name == null)
+ cached_name = MemberName.GetName
(!(this is GenericMethod) && !(this is Method));
+ 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
@@ -263,11 +328,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>
@@ -531,7 +602,6 @@
private Hashtable Cache = new Hashtable ();
public readonly string Basename;
- public readonly string Basename_with_arity;
protected Hashtable defined_names;
@@ -567,8 +637,7 @@
: base (parent, name, attrs, l)
{
NamespaceEntry = ns;
- Basename = name.Name;
- Basename_with_arity = name.Basename;
+ Basename = name.Basename;
defined_names = new Hashtable ();
if (name.TypeArguments != null) {
is_generic = true;
@@ -581,12 +650,12 @@
/// <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)) {
if (symbol is TypeParameter)
Report.Error (694, "Type parameter
`{0}' has same name as " +
- "containing type or
method", basename);
+ "containing type or
method", name);
else {
Report.SymbolRelatedToPreviousError
(this);
Report.Error (542, "'{0}': member names
cannot be the same as their " +
@@ -595,10 +664,10 @@
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;
}
@@ -606,12 +675,12 @@
return true;
if (symbol is TypeParameter)
- Report.Error (692, symbol.Location, "Duplicate
type parameter `{0}'", basename);
+ Report.Error (692, symbol.Location, "Duplicate
type parameter `{0}'", name);
else {
Report.SymbolRelatedToPreviousError (mc);
Report.Error (102, symbol.Location,
"The type '{0}' already contains
a definition for '{1}'",
- GetSignatureForError (),
basename);
+ GetSignatureForError (), name);
}
return false;
}
@@ -1173,8 +1242,7 @@
type_params [i] = new TypeParameter (Parent,
name, constraints, Location);
- string full_name = Name + "." + name;
- AddToContainer (type_params [i], full_name,
name);
+ AddToContainer (type_params [i], name);
}
}
Modified: trunk/mcs/gmcs/driver.cs
===================================================================
--- trunk/mcs/gmcs/driver.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/driver.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -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/gmcs/enum.cs
===================================================================
--- trunk/mcs/gmcs/enum.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/enum.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -166,7 +166,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/gmcs/namespace.cs
===================================================================
--- trunk/mcs/gmcs/namespace.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/namespace.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -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/gmcs/report.cs
===================================================================
--- trunk/mcs/gmcs/report.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/report.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -311,8 +311,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/gmcs/tree.cs
===================================================================
--- trunk/mcs/gmcs/tree.cs 2005-04-18 06:08:42 UTC (rev 43193)
+++ trunk/mcs/gmcs/tree.cs 2005-04-18 07:07:01 UTC (rev 43194)
@@ -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