**** Merged from MCS ****
authorMartin Baulig <martin@novell.com>
Tue, 14 Sep 2004 05:14:19 +0000 (05:14 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 14 Sep 2004 05:14:19 +0000 (05:14 -0000)
svn path=/trunk/mcs/; revision=33849

18 files changed:
mcs/gmcs/ChangeLog
mcs/gmcs/attribute.cs
mcs/gmcs/class.cs
mcs/gmcs/const.cs
mcs/gmcs/cs-parser.jay
mcs/gmcs/cs-tokenizer.cs
mcs/gmcs/decl.cs
mcs/gmcs/ecore.cs
mcs/gmcs/enum.cs
mcs/gmcs/expression.cs
mcs/gmcs/generic.cs
mcs/gmcs/iterators.cs
mcs/gmcs/literal.cs
mcs/gmcs/namespace.cs
mcs/gmcs/parameter.cs
mcs/gmcs/report.cs
mcs/gmcs/rootcontext.cs
mcs/gmcs/typemanager.cs

index ad149636e27f1b14341b91de3c3eb27ce7029857..c3f086c8f30a8d8ae310ef41532fae500d872b3f 100755 (executable)
@@ -1,3 +1,184 @@
+2004-09-13  Marek Safar  <marek.safar@seznam.cz>
+
+       * class.cs (MethodCore.CheckBase): Fix bug #65757.
+
+2004-09-12  Marek Safar  <marek.safar@seznam.cz>
+
+       * attribute.cs (Attribute.Resolve): Add error 653 report.
+
+       * class.cs (Class.ApplyAttributeBuilder): Add error 641
+       report.
+       (Method.ApplyAttributeBuilder): Add error 685 report.
+       (Operator.Define): Add error 564 report.
+
+       * cs-tokenizer.cs (handle_hex): Add error 1013 report.
+
+       * expression.cs (Invocation.DoResolve): Add error
+       245 and 250 report.
+
+       * parameter.cs (Parameter.ApplyAttributeBuilder): Add
+       error 674 report.
+
+2004-09-11  Marek Safar  <marek.safar@seznam.cz>
+
+       * class.cs (ConstructorInitializer.Resolve):
+       Wrong error number (515->516).
+
+2004-09-11  Marek Safar  <marek.safar@seznam.cz>
+
+       * class.cs (Indexer.Define): Add error 631 report.
+
+2004-09-11  Marek Safar  <marek.safar@seznam.cz>
+
+       * ecore.cs (Error_NegativeArrayIndex): Fix 248 error.
+
+2004-09-11  Marek Safar  <marek.safar@seznam.cz>
+
+       * expression.cs (Probe.DoResolve): Add error CS0241 report.
+
+2004-09-10  Marek Safar  <marek.safar@seznam.cz>
+
+       * cs-parser.jay: Added error CS0241 report.
+
+2004-09-10  Raja R Harinath  <rharinath@novell.com>
+
+       * cs-parser.jay (fixed_statement): Introduce a scope for the
+       declaration in the 'fixed' statement.
+
+2004-09-09  Marek Safar  <marek.safar@seznam.cz>
+
+       * cs-parser.jay: Added CS0230 error report.
+
+2004-09-09  Marek Safar  <marek.safar@seznam.cz>
+
+       * cs-parser.jay: Added errors CS0231 and CS0257 report.
+
+2004-09-09  Marek Safar  <marek.safar@seznam.cz>
+
+       * expression.cs (Argument.Resolve): Added error CS0192 and
+       CS0199 report.
+
+2004-09-09  Marek Safar  <marek.safar@seznam.cz>
+
+       C# 2.0 #pragma warning feature
+
+       * cs-tokenizer.cs (PreProcessPragma): New method; 
+       Handles #pragma directive.
+
+       * report.cs (WarningRegions): New class; Support
+       class for #pragma warning directive. It tests whether
+       warning is enabled for a given line.
+
+2004-09-08  Miguel de Icaza  <miguel@ximian.com>
+
+       * const.cs: Add more descriptive error report, tahnks to
+       Sebastien. 
+
+2004-09-08  Marek Safar  <marek.safar@seznam.cz>
+
+       * ecore.cs (FieldExpr.DoResolveLValue): Fixed CS0198 report.
+
+2004-09-07  Miguel de Icaza  <miguel@ximian.com>
+
+       * expression.cs: Apply patch from Ben: Remove dead code from
+       ArrayCreation, and remove the TurnintoConstant call in const.cs,
+       as that code just threw an exception anwyays.
+
+       * const.cs: Remove the call to the turnintoconstant, for details
+       see bug: #63144
+       
+       * literal.cs: The type of the null-literal is the null type;  So
+       we use a placeholder type (literal.cs:System.Null, defined here)
+       for it.
+
+       * expression.cs (Conditional.DoResolve): Remove some old code that
+       is no longer needed, conversions have been fixed.
+
+       (ArrayCreationExpression.DoResolve): Return false if we fail to
+       resolve the inner expression.
+
+2004-09-07  Raja R Harinath  <rharinath@novell.com>
+
+       Fix test-290.cs.
+       * cs-parser.jay (delegate_declaration): Record a delegate
+       declaration as a type declaration.
+       Reported by Jo Vermeulen <jo@lumumba.luc.ac.be>.
+
+2004-09-06  Miguel de Icaza  <miguel@ximian.com>
+
+       * parameter.cs: Do not crash if the type can not be resolved. 
+
+       * expression.cs: Report errors with unsafe pointers, fixes #64896
+
+2004-09-06 Ben Maurer  <bmaurer@users.sourceforge.net>
+
+       * expression.cs: Pointer arith always needs to do a conv.i
+       if the operand is a long. fix 65320
+
+2004-09-04  Marek Safar  <marek.safar@seznam.cz>
+
+       Fixed cs0619-37.cs, cs0619-38.cs
+
+       * enum.cs (GetObsoleteAttribute): Removed.
+
+       * expression.cs (MemberAccess.DoResolve): Test for [Obsolete]
+       on Enum member is double staged. The first is tested member
+       and then enum.
+
+2004-09-04  Marek Safar  <marek.safar@seznam.cz>
+
+       Fixed #56986, #63631, #65231
+
+       * class.cs: (TypeContainer.AddToMemberContainer): New method,
+       adds member to name container.
+       (TypeContainer.AddToTypeContainer): New method, adds type to
+       name container.
+       (AddConstant, AddEnum, AddClassOrStruct, AddDelegate, AddMethod,
+       AddConstructor, AddInterface, AddField, AddProperty, AddEvent,
+       AddOperator): Simplified by reusing AddToMemberContainer.
+       (TypeContainer.UserDefinedStaticConstructor): Changed to property
+       instead of field.
+       (Method.CheckForDuplications): Fixed implementation to test all
+       possibilities.
+       (MemberBase): Detection whether member is explicit interface
+       implementation is now in constructor.
+       (MemberBase.UpdateMemberName): Handles IndexerName.
+       (Accessor): Changed to keep also location information.
+       (AbstractPropertyEventMethod): Is derived from MemberCore.
+       (AbstractPropertyEventMethod.IsDummy): Says whether accessor
+       will be emited or not.
+       (PropertyBase.AreAccessorsDuplicateImplementation):
+       Tests whether accessors are not in collision with some method.
+       (Operator): Is derived from MethodCore to simplify common
+       operations.
+
+       * decl.cs (Flags.TestMethodDuplication): Test for duplication
+       must be performed.
+       (DeclSpace.AddToContainer): Adds the member to defined_names
+       table. It tests for duplications and enclosing name conflicts.
+
+       * enum.cs (EnumMember): Clean up to reuse the base structures
+
+2004-09-03  Martin Baulig  <martin@ximian.com>
+
+       Merged latest changes into gmcs.  Please keep this comment in
+       here, it makes it easier for me to see what changed in MCS since
+       the last time I merged.
+
+2004-09-03  Martin Baulig  <martin@ximian.com>
+
+       * class.cs (TypeContainer.DefineDefaultConstructor): Put this back
+       into TypeContainer, to make partial classes work again.
+
+2004-09-03  Martin Baulig  <martin@ximian.com>
+
+       * rootcontext.cs (RootContext.V2): Removed.
+
+2004-03-23  Martin Baulig  <martin@ximian.com>
+
+       * expression.cs (Invocation.OverloadResolve): Added `bool
+       may_fail' argument and use it instead of the Location.IsNull() hack.
+
 2004-09-09  Martin Baulig  <martin@ximian.com>
 
        * cs-parser.jay (namespace_declaration): Fixed CS0134 reporting.
index 9a7244d1a62fa390853bf064de54cfcf1e830a27..c3f65f232f99b6b80209c5c7a3b387a4c7cb874c 100644 (file)
@@ -256,6 +256,11 @@ namespace Mono.CSharp {
                                return null;
                        }
 
+                       if (Type.IsAbstract) {
+                               Report.Error (653, Location, "Cannot apply attribute class '{0}' because it is abstract", Name);
+                               return null;
+                       }
+
                        bool MethodImplAttr = false;
                        bool MarshalAsAttr = false;
                        bool GuidAttr = false;
index 5a582cb2123a8d8d88878e2d8028f0f895955f01..eb1c3cfcfbbffc67a468032482591935727aca69 100755 (executable)
@@ -174,11 +174,11 @@ namespace Mono.CSharp {
                                        seen_normal_indexers = true;
 
                                        if (class_indexer_name == null) {
-                                               class_indexer_name = i.IndexerName;
+                                               class_indexer_name = i.ShortName;
                                                continue;
                                        }
 
-                                       if (i.IndexerName != class_indexer_name)
+                                       if (i.ShortName != class_indexer_name)
                                                Report.Error (668, i.Location, "Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type");
                                }
 
@@ -350,11 +350,11 @@ namespace Mono.CSharp {
                                                        "The operator `" + oe.op + "' requires a matching operator `" + s + "' to also be defined");
                                }
 
-                               if (has_equality_or_inequality && container.Methods != null && (RootContext.WarningLevel > 2)) {
-                                       if (!container.Methods.HasEquals)
+                               if (has_equality_or_inequality && (RootContext.WarningLevel > 2)) {
+                                       if (container.Methods == null || !container.Methods.HasEquals)
                                                Report.Warning (660, container.Location, "'{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
  
-                                       if (!container.Methods.HasGetHashCode)
+                                       if (container.Methods == null || !container.Methods.HasGetHashCode)
                                                Report.Warning (661, container.Location, "'{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
                                }
                        }
@@ -427,11 +427,6 @@ namespace Mono.CSharp {
                protected Constructor default_constructor;
                protected Constructor default_static_constructor;
 
-               //
-               // Whether we have seen a static constructor for this class or not
-               //
-               public bool UserDefinedStaticConstructor = false;
-
                //
                // Whether we have at least one non-static field
                //
@@ -461,8 +456,8 @@ namespace Mono.CSharp {
 
                Type GenericType;
 
-               public TypeContainer (NamespaceEntry ns, TypeContainer parent,
-                                     MemberName name, Attributes attrs, Kind kind, Location l)
+               public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
+                                     Attributes attrs, Kind kind, Location l)
                        : base (ns, parent, name, attrs, l)
                {
                        this.Kind = kind;
@@ -472,140 +467,61 @@ namespace Mono.CSharp {
                        base_class_name = null;
                }
 
-               // <summary>
-               //   Used to report back to the user the result of a declaration
-               //   in the current declaration space
-               // </summary>
-               public void CheckDef (AdditionResult result, string name, Location loc)
+               public bool AddToMemberContainer (MemberCore symbol, bool is_method)
                {
-                       if (result == AdditionResult.Success)
-                               return;
-
-                       switch (result){
-                       case AdditionResult.NameExists:
-                               Report.Error (102, loc, "The container `{0}' already " +
-                                             "contains a definition for `{1}'",
-                                             Name, name);
-                               break;
-
-                               //
-                               // This is handled only for static Constructors, because
-                               // in reality we handle these by the semantic analysis later
-                               //
-                       case AdditionResult.MethodExists:
-                               Report.Error (111, loc, "Class `{0}' already defines a " +
-                                             "member called '{1}' with the same parameter " +
-                                             "types (more than one default constructor)",
-                                             Name, name);
-                               break;
-
-                       case AdditionResult.EnclosingClash:
-                               Report.Error (542, loc, "Member names cannot be the same " +
-                                             "as their enclosing type");
-                               break;
-               
-                       case AdditionResult.NotAConstructor:
-                               Report.Error (1520, loc, "Class, struct, or interface method " +
-                                             "must have a return type");
-                               break;
+                       return AddToContainer (symbol, is_method, String.Concat (Name, '.', symbol.Name), symbol.Name);
+               }
 
-                       case AdditionResult.Error:
-                               // Error has already been reported.
-                               break;
-                       }
+               bool AddToTypeContainer (DeclSpace ds)
+               {
+                       return AddToContainer (ds, false, ds.Name, ds.Basename);
                }
 
-               public AdditionResult AddConstant (Const constant)
+               public void AddConstant (Const constant)
                {
-                       AdditionResult res;
-                       string basename = constant.Name;
-                       string fullname = Name + "." + basename;
+                       if (!AddToMemberContainer (constant, false))
+                               return;
 
-                       if ((res = IsValid (basename, fullname)) != AdditionResult.Success)
-                               return res;
-                       
                        if (constants == null)
                                constants = new MemberCoreArrayList ();
 
                        constants.Add (constant);
-                       DefineName (fullname, constant);
-
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddEnum (Mono.CSharp.Enum e)
+               public void AddEnum (Mono.CSharp.Enum e)
                {
-                       AdditionResult res;
-
-                       if ((res = IsValid (e.Basename, e.Name)) != AdditionResult.Success)
-                               return res;
+                       if (!AddToTypeContainer (e))
+                               return;
 
                        if (enums == null)
                                enums = new MemberCoreArrayList ();
 
                        enums.Add (e);
-                       DefineName (e.Name, e);
-
-                       return AdditionResult.Success;
                }
                
-               public AdditionResult AddClass (TypeContainer c)
+               public void AddClassOrStruct (TypeContainer c)
                {
-                       AdditionResult res;
-                       string name = c.Basename;
-                       
-                       if ((res = IsValid (name, c.Name)) != AdditionResult.Success)
-                               return res;
+                       if (!AddToTypeContainer (c))
+                               return;
 
-                       DefineName (c.Name, c);
                        types.Add (c);
-
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddStruct (TypeContainer s)
+               public void AddDelegate (Delegate d)
                {
-                       AdditionResult res;
-                       string name = s.Basename;
-                       
-                       if ((res = IsValid (name, s.Name)) != AdditionResult.Success)
-                               return res;
-
-                       DefineName (s.Name, s);
-                       types.Add (s);
-
-                       return AdditionResult.Success;
-               }
-
-               public AdditionResult AddDelegate (Delegate d)
-               {
-                       AdditionResult res;
-                       string name = d.Basename;
-                       
-                       if ((res = IsValid (name, d.Name)) != AdditionResult.Success)
-                               return res;
+                       if (!AddToTypeContainer (d))
+                               return;
 
                        if (delegates == null)
                                delegates = new MemberCoreArrayList ();
                        
-                       DefineName (d.Name, d);
                        delegates.Add (d);
-
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddMethod (Method method)
+               public void AddMethod (Method method)
                {
-                       string basename = method.Name;
-                       string fullname = Name + "." + basename;
-
-                       Object value = defined_names [fullname];
-
-                       if (value != null && (!(value is Method)))
-                               return AdditionResult.NameExists;
-
-                       if (basename == Basename)
-                               return AdditionResult.EnclosingClash;
+                       if (!AddToMemberContainer (method, true))
+                               return;
 
                        if (methods == null)
                                methods = new MethodArrayList (this);
@@ -614,30 +530,33 @@ namespace Mono.CSharp {
                                methods.Insert (0, method);
                        else 
                                methods.Add (method);
-                       
-                       if (value == null)
-                               DefineName (fullname, method);
-
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddConstructor (Constructor c)
+               public void AddConstructor (Constructor c)
                {
-                       if (c.Name != Basename) 
-                               return AdditionResult.NotAConstructor;
+                       if (c.Name != Basename) {
+                               Report.Error (1520, Location, "Class, struct, or interface method must have a return type");
+                       }
 
                        bool is_static = (c.ModFlags & Modifiers.STATIC) != 0;
                        
                        if (is_static){
-                               UserDefinedStaticConstructor = true;
-                               if (default_static_constructor != null)
-                                       return AdditionResult.MethodExists;
+                               if (default_static_constructor != null) {
+                                       Report.SymbolRelatedToPreviousError (default_static_constructor);
+                                       Report.Error (111, c.Location, "Type '{0}' already defines a member " +
+                                                     "called '{1}' with the same parameter types", Name, c.Name);
+                                       return;
+                               }
 
                                default_static_constructor = c;
                        } else {
                                if (c.IsDefault ()){
-                                       if (default_constructor != null)
-                                               return AdditionResult.MethodExists;
+                                       if (default_constructor != null) {
+                                               Report.SymbolRelatedToPreviousError (default_constructor);
+                                               Report.Error (111, c.Location, "Type '{0}' already defines a member " +
+                                                     "called '{1}' with the same parameter types", Name, c.Name);
+                                               return;
+                                       }
                                        default_constructor = c;
                                }
                                
@@ -646,35 +565,25 @@ namespace Mono.CSharp {
                                
                                instance_constructors.Add (c);
                        }
-                       
-                       return AdditionResult.Success;
                }
                
-               public AdditionResult AddInterface (TypeContainer iface)
+               public void AddInterface (TypeContainer iface)
                {
-                       AdditionResult res;
-                       string name = iface.Basename;
-                       
-                       if ((res = IsValid (name, iface.Name)) != AdditionResult.Success)
-                               return res;
-                       
-                       if (interfaces == null)
+                       if (!AddToTypeContainer (iface))
+                               return;
+
+                       if (interfaces == null) {
                                interfaces = new MemberCoreArrayList ();
+                       }
+
                        interfaces.Add (iface);
-                       DefineName (iface.Name, iface);
-                       
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddField (Field field)
+               public void AddField (Field field)
                {
-                       AdditionResult res;
-                       string basename = field.Name;
-                       string fullname = Name + "." + basename;
+                       if (!AddToMemberContainer (field, false))
+                               return;
 
-                       if ((res = IsValid (basename, fullname)) != AdditionResult.Success)
-                               return res;
-                       
                        if (fields == null)
                                fields = new MemberCoreArrayList ();
                        
@@ -697,27 +606,13 @@ namespace Mono.CSharp {
 
                        if ((field.ModFlags & Modifiers.STATIC) == 0)
                                have_nonstatic_fields = true;
-
-                       DefineName (fullname, field);
-                       return AdditionResult.Success;
                }
 
-               public AdditionResult AddProperty (Property prop)
+               public void AddProperty (Property prop)
                {
-                       AdditionResult res;
-
-                       if ((res = AddProperty (prop, prop.Name)) != AdditionResult.Success)
-                               return res;
-
-                       if (prop.Get != null) {
-                               if ((res = AddProperty (prop, "get_" + prop.Name)) != AdditionResult.Success)
-                                       return res;
-                       }
-
-                       if (prop.Set != null) {
-                               if ((res = AddProperty (prop, "set_" + prop.Name)) != AdditionResult.Success)
-                               return res;
-                       }
+                       if (!AddToMemberContainer (prop, false) || 
+                           !AddToMemberContainer (prop.Get, true) || !AddToMemberContainer (prop.Set, true))
+                               return;
 
                        if (properties == null)
                                properties = new MemberCoreArrayList ();
@@ -726,66 +621,50 @@ namespace Mono.CSharp {
                                properties.Insert (0, prop);
                        else
                                properties.Add (prop);
-
-                       return AdditionResult.Success;
                }
 
-               AdditionResult AddProperty (Property prop, string basename)
+               public void AddEvent (Event e)
                {
-                       AdditionResult res;
-                       string fullname = Name + "." + basename;
-
-                       if ((res = IsValid (basename, fullname)) != AdditionResult.Success)
-                               return res;
-
-                       DefineName (fullname, prop);
-
-                       return AdditionResult.Success;
-               }
+                       if (!AddToMemberContainer (e, false))
+                               return;
 
-               public AdditionResult AddEvent (Event e)
-               {
-                       AdditionResult res;
-                       string basename = e.Name;
-                       string fullname = Name + "." + basename;
+                       if (e is EventProperty) {
+                               if (!AddToMemberContainer (e.Add, true))
+                                       return;
 
-                       if ((res = IsValid (basename, fullname)) != AdditionResult.Success)
-                               return res;
+                               if (!AddToMemberContainer (e.Remove, true))
+                                       return;
+                       }
 
                        if (events == null)
                                events = new MemberCoreArrayList ();
-                       
-                       events.Add (e);
-                       DefineName (fullname, e);
 
-                       return AdditionResult.Success;
+                       events.Add (e);
                }
 
+               /// <summary>
+               /// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
+               /// </summary>
                public void AddIndexer (Indexer i)
                {
                        if (indexers == null)
                                indexers = new IndexerArrayList (this);
 
-                       if (i.MemberName.Left != null)
+                       if (i.IsExplicitImpl)
                                indexers.Insert (0, i);
                        else
                                indexers.Add (i);
                }
 
-               public AdditionResult AddOperator (Operator op)
+               public void AddOperator (Operator op)
                {
+                       if (!AddToMemberContainer (op, true))
+                               return;
+
                        if (operators == null)
                                operators = new OperatorArrayList (this);
 
                        operators.Add (op);
-
-                       string basename = op.Name;
-                       string fullname = Name + "." + basename;
-                       if (!defined_names.Contains (fullname))
-                       {
-                               DefineName (fullname, op);
-                       }
-                       return AdditionResult.Success;
                }
 
                public void AddIterator (Iterator i)
@@ -1591,7 +1470,7 @@ namespace Mono.CSharp {
                        DefineContainerMembers (constants);
                        DefineContainerMembers (fields);
 
-                       if ((Kind == Kind.Class) && !(this is ClassPart)){
+                       if ((Kind == Kind.Class) && !(this is ClassPart) && !(this is StaticClass)){
                                if ((instance_constructors == null) &&
                                    !(this is StaticClass)) {
                                        if (default_constructor == null)
@@ -1633,10 +1512,10 @@ namespace Mono.CSharp {
                        if (default_static_constructor != null)
                                default_static_constructor.Define ();
 
-                       DefineContainerMembers (methods);
                        DefineContainerMembers (properties);
                        DefineContainerMembers (events);
                        DefineContainerMembers (indexers);
+                       DefineContainerMembers (methods);
                        DefineContainerMembers (operators);
                        DefineContainerMembers (enums);
                        DefineContainerMembers (delegates);
@@ -2503,13 +2382,10 @@ namespace Mono.CSharp {
                        return ok;
                }
 
-               Hashtable builder_and_args;
-               
-               public bool RegisterMethod (MethodBuilder mb, InternalParameters ip, Type [] args)
-               {
-                       if (builder_and_args == null)
-                               builder_and_args = new Hashtable ();
-                       return true;
+               public bool UserDefinedStaticConstructor {
+                       get {
+                               return default_static_constructor != null;
+                       }
                }
 
                protected override bool VerifyClsCompliance (DeclSpace ds)
@@ -2766,10 +2642,8 @@ namespace Mono.CSharp {
                {
                        if (Kind == Kind.Interface)
                                Parent.AddInterface (this);
-                       else if (Kind == Kind.Class)
-                               Parent.AddClass (this);
-                       else if (Kind == Kind.Struct)
-                               Parent.AddStruct (this);
+                       else if (Kind == Kind.Class || Kind == Kind.Struct)
+                               Parent.AddClassOrStruct (this);
                        else
                                throw new InvalidOperationException ();
                }
@@ -2889,18 +2763,23 @@ namespace Mono.CSharp {
 
                        base.ApplyAttributeBuilder (a, cb);
                }
+
+               public override void Register ()
+               {
+                       Parent.AddClassOrStruct (this);
+               }
        }
 
        /// <summary>
        /// Class handles static classes declaration
        /// </summary>
        public sealed class StaticClass: Class {
-               public StaticClass (NamespaceEntry ns, TypeContainer parent, MemberName name,
-                                   int mod, Attributes attrs, Location l)
+               public StaticClass (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
+                                   Attributes attrs, Location l)
                        : base (ns, parent, name, mod & ~Modifiers.STATIC, attrs, l)
                {
                        if (RootContext.Version == LanguageVersion.ISO_1) {
-                               Report.FeatureIsNotStandardized ("static classes");
+                               Report.FeatureIsNotStandardized (l, "static classes");
                                Environment.Exit (1);
                        }
                }
@@ -2984,8 +2863,8 @@ namespace Mono.CSharp {
                // Information in the case we are an attribute type
                AttributeUsageAttribute attribute_usage;
 
-               public Class (NamespaceEntry ns, TypeContainer parent, MemberName name,
-                             int mod, Attributes attrs, Location l)
+               public Class (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
+                             Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, Kind.Class, l)
                {
                        int accmods;
@@ -3011,8 +2890,14 @@ namespace Mono.CSharp {
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
                {
-                       if (a.UsageAttribute != null)
+                       if (a.UsageAttribute != null) {
+                               if (ptype != TypeManager.attribute_type &&
+                                   !ptype.IsSubclassOf (TypeManager.attribute_type) &&
+                                   TypeBuilder.FullName != "System.Attribute") {
+                                       Report.Error (641, a.Location, "Attribute '{0}' is only valid on classes derived from System.Attribute", a.Name);
+                               }
                                attribute_usage = a.UsageAttribute;
+                       }
 
                        base.ApplyAttributeBuilder (a, cb);
                }
@@ -3023,11 +2908,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override void Register ()
-               {
-                       CheckDef (Parent.AddClass (this), Name, Location);
-               }
-
                public const TypeAttributes DefaultTypeAttributes =
                        TypeAttributes.AutoLayout | TypeAttributes.Class;
 
@@ -3076,11 +2956,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override void Register ()
-               {
-                       CheckDef (Parent.AddStruct (this), Name, Location);
-               }
-
                public const TypeAttributes DefaultTypeAttributes =
                        TypeAttributes.SequentialLayout |
                        TypeAttributes.Sealed |
@@ -3129,7 +3004,7 @@ namespace Mono.CSharp {
 
                public override void Register ()
                {
-                       CheckDef (Parent.AddInterface (this), Name, Location);
+                       Parent.AddInterface (this);
                }
 
                public override PendingImplementation GetPendingImplementations ()
@@ -3229,15 +3104,12 @@ namespace Mono.CSharp {
                        if (!DoDefineParameters ())
                                return false;
 
+                       if ((caching_flags & Flags.TestMethodDuplication) != 0 && !CheckForDuplications ())
+                               return false;
+
                        if (IsExplicitImpl)
                                return true;
 
-                       // TODO: Is it correct ?
-                       if (!IsOperator) {
-                               if (!CheckForDuplications ())
-                                       return false;
-                       }
-
                        // Is null for System.Object while compiling corlib and base interfaces
                        if (Parent.ParentContainer == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
@@ -3412,7 +3284,7 @@ namespace Mono.CSharp {
                                        if (RootContext.WarningLevel >= 2)
                                                Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), parent_method);
                                } else
-                                       Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member `{1}'", GetSignatureForError (Parent), parent_method);
+                                       Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
                        }
 
                        return ok;
@@ -3560,7 +3432,8 @@ namespace Mono.CSharp {
 
                protected bool IsDuplicateImplementation (MethodCore method)
                {
-                       if ((method == this) || (method.Name != Name))
+                       if ((method == this) ||
+                           (method.MemberName.GetTypeName () != MemberName.GetTypeName ()))
                                return false;
 
                        Type[] param_types = method.ParameterTypes;
@@ -3604,10 +3477,13 @@ namespace Mono.CSharp {
                        }
 
                        for (int i = 0; i < param_types.Length; i++) {
-                               Type a = param_types [i];
-                               Type b = ParameterTypes [i];
+                               if (param_types [i] != ParameterTypes [i])
+                                       equal = false;
+                       }
 
-                               if (a != b)
+                       // TODO: make operator compatible with MethodCore to avoid this
+                       if (this is Operator && method is Operator) {
+                               if (MemberType != method.MemberType)
                                        equal = false;
                        }
 
@@ -3765,6 +3641,9 @@ namespace Mono.CSharp {
                
                public override string GetSignatureForError()
                {
+                       if (MethodBuilder == null) {
+                               return GetSignatureForError (Parent);
+                       }
                        return TypeManager.CSharpSignature (MethodBuilder);
                }
 
@@ -3773,6 +3652,10 @@ namespace Mono.CSharp {
                /// </summary>
                public override string GetSignatureForError (TypeContainer tc)
                {
+                       // TODO: get params from somewhere
+                       if (parameter_info == null)
+                               return base.GetSignatureForError (tc);
+
                        // TODO: move to parameters
                        System.Text.StringBuilder args = new System.Text.StringBuilder ();
                        if (parameter_info.Parameters.FixedParameters != null) {
@@ -3867,6 +3750,13 @@ namespace Mono.CSharp {
                                        Report.Error (629, Location, "Conditional member '{0}' cannot implement interface member", GetSignatureForError ());
                                        return;
                                }
+
+                               for (int i = 0; i < parameter_info.Count; ++i) {
+                                       if ((parameter_info.ParameterModifier (i) & Parameter.Modifier.OUT) != 0) {
+                                               Report.Error (685, Location, "Conditional method '{0}' cannot have an out parameter", GetSignatureForError ());
+                                               return;
+                                       }
+                               }
                        }
 
                        MethodBuilder.SetCustomAttribute (cb);
@@ -3875,19 +3765,41 @@ namespace Mono.CSharp {
                protected override bool CheckForDuplications ()
                {
                        ArrayList ar = Parent.Methods;
+                       if (ar != null) {
+                               int arLen = ar.Count;
+                                       
+                               for (int i = 0; i < arLen; i++) {
+                                       Method m = (Method) ar [i];
+                                       if (IsDuplicateImplementation (m))
+                                               return false;
+                               }
+                       }
+
+                       ar = Parent.Properties;
                        if (ar != null) {
-                               int arLen = ar.Count;
+                               for (int i = 0; i < ar.Count; ++i) {
+                                       PropertyBase pb = (PropertyBase) ar [i];
+                                       if (pb.AreAccessorsDuplicateImplementation (this))
+                                               return false;
+                               }
+                       }
 
-                               for (int i = 0; i < arLen; i++) {
-                                       Method m = (Method) ar [i];
-                                       if (IsDuplicateImplementation (m))
+                       ar = Parent.Indexers;
+                       if (ar != null) {
+                               for (int i = 0; i < ar.Count; ++i) {
+                                       PropertyBase pb = (PropertyBase) ar [i];
+                                       if (pb.AreAccessorsDuplicateImplementation (this))
                                                return false;
                                }
                        }
 
-                       if (MemberType.IsAbstract && MemberType.IsSealed) {
-                               Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
-                               return false;
+                       ar = Parent.Events;
+                       if (ar != null) {
+                               for (int i = 0; i < ar.Count; ++i) {
+                                       Event ev = (Event) ar [i];
+                                       if (ev.AreAccessorsDuplicateImplementation (this))
+                                               return false;
+                               }
                        }
 
                        return true;
@@ -3966,6 +3878,11 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       if (MemberType.IsAbstract && MemberType.IsSealed) {
+                               Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
+                               return false;
+                       }
+
                        return true;
                }
 
@@ -4030,9 +3947,15 @@ namespace Mono.CSharp {
                        }
                }
 
-               public string MethodName {
+               public Type ReturnType {
+                       get {
+                               return MemberType;
+                       }
+               }
+
+               public MemberName MethodName {
                        get {
-                               return ShortName;
+                               return MemberName;
                        }
                }
 
@@ -4104,12 +4027,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public Type ReturnType {
-                       get {
-                               return MemberType;
-                       }
-               }
-
                #endregion
        }
 
@@ -4194,7 +4111,7 @@ namespace Mono.CSharp {
                        }
                        
                        if (parent_constructor == caller_builder){
-                               Report.Error (515, String.Format ("Constructor `{0}' can not call itself", TypeManager.CSharpSignature (caller_builder)));
+                               Report.Error (516, String.Format ("Constructor `{0}' can not call itself", TypeManager.CSharpSignature (caller_builder)));
                                return false;
                        }
                        
@@ -4336,6 +4253,9 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError()
                {
+                       if (ConstructorBuilder == null)
+                               return GetSignatureForError (Parent);
+
                        return TypeManager.CSharpSignature (ConstructorBuilder);
                }
 
@@ -4610,9 +4530,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               public string MethodName {
+               public MemberName MethodName {
                        get {
-                               return ShortName;
+                               return MemberName;
                        }
                }
                        
@@ -4654,7 +4574,7 @@ namespace Mono.CSharp {
        {
                CallingConventions CallingConventions { get; }
                Location Location { get; }
-               string MethodName { get; }
+               MemberName MethodName { get; }
                Type[] ParameterTypes { get; }
                Type ReturnType { get; }
                GenericMethod GenericMethod { get; }
@@ -4757,15 +4677,16 @@ namespace Mono.CSharp {
                public bool Define (TypeContainer container)
                {
                        MethodInfo implementing = null;
-                       string prefix;
 
+                       string prefix;
                        if (member.IsExplicitImpl)
                                prefix = RemoveArity (member.InterfaceType.FullName) + ".";
                        else
                                prefix = "";
 
-                       string name = method.MethodName;
+                       string name = method.MethodName.Name;
                        string method_name = prefix + name;
+  
                        Type[] ParameterTypes = method.ParameterTypes;
 
                        if (container.Pending != null){
@@ -4846,12 +4767,6 @@ namespace Mono.CSharp {
                                if ((modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT | Modifiers.OVERRIDE)) == 0)
                                        flags |= MethodAttributes.Final;
 
-                               // Get the method name from the explicit interface.
-                               if (member.InterfaceType != null) {
-                                       name = implementing.Name;
-                                       method_name = prefix + name;
-                               }
-
                                IsImplementing = true;
                        }
 
@@ -4889,15 +4804,7 @@ namespace Mono.CSharp {
 
                        }
 
-                       if (!TypeManager.RegisterMethod (builder, ParameterInfo, ParameterTypes)) {
-                               Report.Error (111, method.Location,
-                                             "Class `" + container.Name +
-                                             "' already contains a definition with the " +
-                                             "same return value and parameter types as the " +
-                                             "'get' method of property `" + member.Name + "'");
-                               return false;
-                       }
-
+                       TypeManager.RegisterMethod (builder, ParameterInfo, ParameterTypes);
                        TypeManager.AddMethod (builder, method);
 
                        if (GenericMethod != null) {
@@ -5110,7 +5017,7 @@ namespace Mono.CSharp {
                //
                // The name of the interface we are explicitly implementing
                //
-               public Expression ExplicitInterfaceName = null;
+               public MemberName ExplicitInterfaceName = null;
 
                //
                // Whether this is an interface member.
@@ -5133,6 +5040,14 @@ namespace Mono.CSharp {
                        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;
                }
 
                protected virtual bool CheckBase ()
@@ -5200,7 +5115,7 @@ namespace Mono.CSharp {
                protected virtual bool DoDefineBase ()
                {
                        if (Name == null)
-                               Name = "this";
+                               throw new InternalErrorException ();
 
                        if (IsInterface) {
                                ModFlags = Modifiers.PUBLIC |
@@ -5270,18 +5185,9 @@ namespace Mono.CSharp {
                        if (MemberType.IsPointer && !UnsafeOK (Parent))
                                return false;
 
-                       //
-                       // Check for explicit interface implementation
-                       //
-                       if (MemberName.Left != null) {
-                               ExplicitInterfaceName = MemberName.Left.GetTypeExpression (Location);
-                               ShortName = MemberName.Name;
-                       } else
-                               ShortName = Name;
-
-                       if (ExplicitInterfaceName != null) {
+                       if (IsExplicitImpl) {
                                InterfaceType = Parent.ResolveType (
-                                       ExplicitInterfaceName, false, Location);
+                                       ExplicitInterfaceName.GetTypeExpression (Location), false, Location);
                                if (InterfaceType == null)
                                        return false;
 
@@ -5290,21 +5196,23 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               // Compute the full name that we need to export.
-                               Name = InterfaceType.FullName + "." + ShortName;
-                               
                                if (!Parent.VerifyImplements (InterfaceType, ShortName, Name, Location))
                                        return false;
                                
                                Modifiers.Check (Modifiers.AllowedExplicitImplFlags, explicit_mod_flags, 0, Location);
-                               
-                               IsExplicitImpl = true;
-                       } else
-                               IsExplicitImpl = false;
+                       }
 
                        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));
@@ -5469,6 +5377,9 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError ()
                {
+                       if (FieldBuilder == null) {
+                               return base.GetSignatureForError (Parent);
+                       }
                        return TypeManager.GetFullNameSignature (FieldBuilder);
                }
 
@@ -5638,35 +5549,60 @@ namespace Mono.CSharp {
                //
                public Block Block;
                public Attributes Attributes;
+               public Location Location;
                
-               public Accessor (Block b, Attributes attrs)
+               public Accessor (Block b, Attributes attrs, Location loc)
                {
                        Block = b;
                        Attributes = attrs;
+                       Location = loc;
                }
        }
 
 
        // Ooouh Martin, templates are missing here.
        // When it will be possible move here a lot of child code and template method type.
-       public abstract class AbstractPropertyEventMethod: Attributable, IMethodData
-       {
+       public abstract class AbstractPropertyEventMethod: MemberCore, IMethodData {
                protected MethodData method_data;
                protected Block block;
 
+               // The accessor are created event if they are not wanted.
+               // But we need them because their names are reserved.
+               // Field says whether accessor will be emited or not
+               public readonly bool IsDummy;
+
+               protected readonly string prefix;
+
                ReturnParameter return_attributes;
 
-               public AbstractPropertyEventMethod ():
-                       base (null)
+               public AbstractPropertyEventMethod (MemberBase member, string prefix)
+                       : base (null, SetupName (prefix, member), null, member.Location)
                {
+                       this.prefix = prefix;
+                       IsDummy = true;
                }
 
-               public AbstractPropertyEventMethod (Accessor accessor):
-                       base (accessor.Attributes)
+               public AbstractPropertyEventMethod (MemberBase member, Accessor accessor,
+                                                   string prefix)
+                       : base (null, SetupName (prefix, member),
+                               accessor.Attributes, accessor.Location)
                {
+                       this.prefix = prefix;
                        this.block = accessor.Block;
                }
 
+               static MemberName SetupName (string prefix, MemberBase member)
+               {
+                       MemberName name = member.MemberName.Clone ();
+                       name.Name = prefix + member.ShortName;
+                       return name;
+               }
+
+               public void UpdateName (MemberBase member)
+               {
+                       MemberName.Name = prefix + member.ShortName;
+               }
+
                #region IMethodData Members
 
                public Block Block {
@@ -5696,10 +5632,13 @@ namespace Mono.CSharp {
                        }
                }
 
+               public MemberName MethodName {
+                       get {
+                               return MemberName;
+                       }
+               }
+
                public abstract ObsoleteAttribute GetObsoleteAttribute ();
-               public abstract string GetSignatureForError (TypeContainer tc);
-               public abstract Location Location { get; }
-               public abstract string MethodName { get; }
                public abstract Type[] ParameterTypes { get; }
                public abstract Type ReturnType { get; }
                public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
@@ -5735,11 +5674,52 @@ namespace Mono.CSharp {
                        System.Diagnostics.Debug.Fail ("You forgot to define special attribute target handling");
                }
 
+               public override bool Define()
+               {
+                       return false;
+               }
+
                public virtual void Emit (TypeContainer container)
                {
                        method_data.Emit (container, this);
                        block = null;
                }
+
+               public override bool IsClsCompliaceRequired(DeclSpace ds)
+               {
+                       return false;
+               }
+
+               public bool IsDuplicateImplementation (MethodCore method)
+               {
+                       if (Name != method.Name)
+                               return false;
+
+                       Type[] param_types = method.ParameterTypes;
+
+                       if (param_types.Length != ParameterTypes.Length)
+                               return false;
+
+                       for (int i = 0; i < param_types.Length; i++)
+                               if (param_types [i] != ParameterTypes [i])
+                                       return false;
+
+                       Report.SymbolRelatedToPreviousError (method);
+                       Report.Error (111, Location, "Type '{0}' already defines a member called '{1}' with " +
+                                     "the same parameter types", Parent.Name, Name);
+                       return true;
+               }
+
+               public new Location Location { 
+                       get {
+                               return base.Location;
+                       }
+               }
+
+               protected override void VerifyObsoleteAttribute()
+               {
+               }
+
        }
 
        //
@@ -5752,8 +5732,13 @@ namespace Mono.CSharp {
                {
                        static string[] attribute_targets = new string [] { "method", "return" };
 
+                       public GetMethod (MethodCore method):
+                               base (method, "get_")
+                       {
+                       }
+
                        public GetMethod (MethodCore method, Accessor accessor):
-                               base (method, accessor)
+                               base (method, accessor, "get_")
                        {
                        }
 
@@ -5772,13 +5757,6 @@ namespace Mono.CSharp {
                                return String.Concat (base.GetSignatureForError (tc), ".get");
                        }
 
-                       public override string MethodName 
-                       {
-                               get {
-                                       return "get_" + method.ShortName;
-                               }
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return method.MemberType;
@@ -5797,8 +5775,13 @@ namespace Mono.CSharp {
                        static string[] attribute_targets = new string [] { "method", "param", "return" };
                        ImplicitParameter param_attr;
 
+                       public SetMethod (MethodCore method):
+                               base (method, "set_")
+                       {
+                       }
+
                        public SetMethod (MethodCore method, Accessor accessor):
-                               base (method, accessor)
+                               base (method, accessor, "set_")
                        {
                        }
 
@@ -5838,12 +5821,6 @@ namespace Mono.CSharp {
                                return String.Concat (base.GetSignatureForError (tc), ".set");
                        }
 
-                       public override string MethodName {
-                               get {
-                                       return "set_" + method.ShortName;
-                               }
-                       }
-
                        public override Type[] ParameterTypes {
                                get {
                                        return new Type[] { method.MemberType };
@@ -5868,8 +5845,14 @@ namespace Mono.CSharp {
                public abstract class PropertyMethod: AbstractPropertyEventMethod {
                        protected readonly MethodCore method;
 
-                       public PropertyMethod (MethodCore method, Accessor accessor):
-                               base (accessor)
+                       public PropertyMethod (MethodCore method, string prefix)
+                               : base (method, prefix)
+                       {
+                               this.method = method;
+                       }
+
+                       public PropertyMethod (MethodCore method, Accessor accessor, string prefix)
+                               : base (method, accessor, prefix)
                        {
                                this.method = method;
                        }
@@ -5900,12 +5883,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override Location Location {
-                               get {
-                                       return method.Location;
-                               }
-                       }
-
                        public override EmitContext CreateEmitContext (TypeContainer tc,
                                                                       ILGenerator ig)
                        {
@@ -5972,25 +5949,40 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError()
                {
+                       if (PropertyBuilder == null)
+                               return GetSignatureForError (Parent);
+
                        return TypeManager.CSharpSignature (PropertyBuilder, false);
                }
 
 
                protected override bool CheckForDuplications ()
                {
-                       ArrayList ar = Parent.Properties;
+                       ArrayList ar = Parent.Indexers;
                        if (ar != null) {
                                int arLen = ar.Count;
                                        
                                for (int i = 0; i < arLen; i++) {
-                                       Property m = (Property) ar [i];
+                                       Indexer m = (Indexer) ar [i];
                                        if (IsDuplicateImplementation (m))
                                                return false;
                                }
                        }
-                               return true;
+
+                       ar = Parent.Properties;
+                       if (ar != null) {
+                               int arLen = ar.Count;
+                                       
+                               for (int i = 0; i < arLen; i++) {
+                                       Property m = (Property) ar [i];
+                                       if (IsDuplicateImplementation (m))
+                                               return false;
+                               }
                        }
 
+                       return true;
+               }
+
                protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
                {
                        PropertyInfo parent_property = container.ParentContainer.MemberCache.FindMemberToOverride (
@@ -6020,15 +6012,32 @@ namespace Mono.CSharp {
                        if (PropertyBuilder != null && OptAttributes != null)
                                OptAttributes.Emit (ec, this);
 
-                       if (Get != null)
+                       if (!Get.IsDummy)
                                Get.Emit (Parent);
 
-                       if (Set != null)
+                       if (!Set.IsDummy)
                                Set.Emit (Parent);
 
                        base.Emit ();
                }
 
+               /// <summary>
+               /// Tests whether accessors are not in collision with some method (CS0111)
+               /// </summary>
+               public bool AreAccessorsDuplicateImplementation (MethodCore mc)
+               {
+                       return Get.IsDuplicateImplementation (mc) || Set.IsDuplicateImplementation (mc);
+               }
+
+               protected override void UpdateMemberName ()
+               {
+                       base.UpdateMemberName ();
+
+                       Get.UpdateName (this);
+                       Set.UpdateName (this);
+               }
+
+
                public override string[] ValidAttributeTargets {
                        get {
                                return attribute_targets;
@@ -6063,10 +6072,14 @@ namespace Mono.CSharp {
                                is_iface, name, Parameters.EmptyReadOnlyParameters, attrs,
                                loc)
                {
-                       if (get_block != null)
+                       if (get_block == null)
+                               Get = new GetMethod (this);
+                       else
                                Get = new GetMethod (this, get_block);
 
-                       if (set_block != null)
+                       if (set_block == null)
+                               Set = new SetMethod (this);
+                       else
                                Set = new SetMethod (this, set_block);
                }
 
@@ -6083,7 +6096,7 @@ namespace Mono.CSharp {
 
                        flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
 
-                       if (Get != null) {
+                       if (!Get.IsDummy) {
 
                                GetBuilder = Get.Define (Parent);
                                if (GetBuilder == null)
@@ -6104,7 +6117,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (Set != null) {
+                       if (!Set.IsDummy) {
                                SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
@@ -6123,23 +6136,13 @@ namespace Mono.CSharp {
                                PropertyBuilder = Parent.TypeBuilder.DefineProperty (
                                        Name, prop_attr, MemberType, null);
                                
-                               if (Get != null)
+                               if (!Get.IsDummy)
                                        PropertyBuilder.SetGetMethod (GetBuilder);
                                
-                               if (Set != null)
+                               if (!Set.IsDummy)
                                        PropertyBuilder.SetSetMethod (SetBuilder);
 
-                               //
-                               // HACK for the reasons exposed above
-                               //
-                               if (!TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder)) {
-                                       Report.Error (
-                                               111, Location,
-                                               "Class `" + Parent.Name +
-                                               "' already contains a definition for the property `" +
-                                               Name + "'");
-                                       return false;
-                               }
+                               TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder);
                        }
                        return true;
                }
@@ -6361,22 +6364,17 @@ namespace Mono.CSharp {
 
                protected sealed class AddDelegateMethod: DelegateMethod
                {
+
                        public AddDelegateMethod (Event method):
-                               base (method)
+                               base (method, "add_")
                        {
                        }
 
                        public AddDelegateMethod (Event method, Accessor accessor):
-                               base (method, accessor)
+                               base (method, accessor, "add_")
                        {
                        }
 
-                       public override string MethodName {
-                               get {
-                                       return "add_" + method.ShortName;
-                               }
-                       }
-
                        protected override MethodInfo DelegateMethodInfo {
                                get {
                                        return TypeManager.delegate_combine_delegate_delegate;
@@ -6388,21 +6386,15 @@ namespace Mono.CSharp {
                protected sealed class RemoveDelegateMethod: DelegateMethod
                {
                        public RemoveDelegateMethod (Event method):
-                               base (method)
+                               base (method, "remove_")
                        {
                        }
 
                        public RemoveDelegateMethod (Event method, Accessor accessor):
-                               base (method, accessor)
+                               base (method, accessor, "remove_")
                        {
                        }
 
-                       public override string MethodName {
-                               get {
-                                       return "remove_" + method.ShortName;
-                               }
-                       }
-
                        protected override MethodInfo DelegateMethodInfo {
                                get {
                                        return TypeManager.delegate_remove_delegate_delegate;
@@ -6418,13 +6410,14 @@ namespace Mono.CSharp {
 
                        static string[] attribute_targets = new string [] { "method", "param", "return" };
 
-                       public DelegateMethod (Event method)
+                       public DelegateMethod (Event method, string prefix)
+                               : base (method, prefix)
                        {
                                this.method = method;
                        }
 
-                       public DelegateMethod (Event method, Accessor accessor):
-                               base (accessor)
+                       public DelegateMethod (Event method, Accessor accessor, string prefix)
+                               : base (method, accessor, prefix)
                        {
                                this.method = method;
                        }
@@ -6511,12 +6504,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override Location Location {
-                               get {
-                                       return method.Location;
-                               }
-                       }
-
                        public override EmitContext CreateEmitContext (TypeContainer tc,
                                                                       ILGenerator ig)
                        {
@@ -6559,7 +6546,7 @@ namespace Mono.CSharp {
                const int AllowedInterfaceModifiers =
                        Modifiers.NEW;
 
-               protected DelegateMethod Add, Remove;
+               public DelegateMethod Add, Remove;
                public MyEventBuilder     EventBuilder;
                public MethodBuilder AddBuilder, RemoveBuilder;
 
@@ -6580,6 +6567,11 @@ namespace Mono.CSharp {
                        EventBuilder.SetCustomAttribute (cb);
                }
 
+               public bool AreAccessorsDuplicateImplementation (MethodCore mc)
+               {
+                       return Add.IsDuplicateImplementation (mc) || Remove.IsDuplicateImplementation (mc);
+               }
+
                public override AttributeTargets AttributeTargets {
                        get {
                                return AttributeTargets.Event;
@@ -6646,13 +6638,7 @@ namespace Mono.CSharp {
                                EventBuilder.SetAddOnMethod (AddBuilder);
                                EventBuilder.SetRemoveOnMethod (RemoveBuilder);
 
-                               if (!TypeManager.RegisterEvent (EventBuilder, AddBuilder, RemoveBuilder)) {
-                                       Report.Error (111, Location,
-                                                     "Class `" + Parent.Name +
-                                                     "' already contains a definition for the event `" +
-                                                     Name + "'");
-                                       return false;
-                               }
+                               TypeManager.RegisterEvent (EventBuilder, AddBuilder, RemoveBuilder);
                        }
                        
                        return true;
@@ -6692,24 +6678,23 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError ()
                {
+                       if (EventBuilder == null)
+                               return base.GetSignatureForError (Parent);
+
                        return TypeManager.GetFullNameSignature (EventBuilder);
                }
        }
 
-       //
-       // FIXME: This does not handle:
-       //
-       //   int INTERFACENAME [ args ]
-       //   Does not 
-       //
-       // Only:
-       // 
-       // int this [ args ]
  
        public class Indexer : PropertyBase {
 
                class GetIndexerMethod: GetMethod
                {
+                       public GetIndexerMethod (MethodCore method):
+                               base (method)
+                       {
+                       }
+
                        public GetIndexerMethod (MethodCore method, Accessor accessor):
                                base (method, accessor)
                        {
@@ -6726,6 +6711,11 @@ namespace Mono.CSharp {
                {
                        readonly Parameters parameters;
 
+                       public SetIndexerMethod (MethodCore method):
+                               base (method)
+                       {
+                       }
+
                        public SetIndexerMethod (MethodCore method, Parameters parameters, Accessor accessor):
                                base (method, accessor)
                        {
@@ -6792,24 +6782,24 @@ namespace Mono.CSharp {
                const int AllowedInterfaceModifiers =
                        Modifiers.NEW;
 
-               public string IndexerName = TypeContainer.DefaultIndexerName;
-               public string InterfaceIndexerName;
-
                //
                // Are we implementing an interface ?
                //
-               public Indexer (TypeContainer parent, Expression type, int mod_flags,
-                               bool is_iface, MemberName name, Parameters parameters,
-                               Attributes attrs, Accessor get_block, Accessor set_block,
-                               Location loc)
-                       : base (parent, type, mod_flags,
+               public Indexer (TypeContainer parent, Expression type, MemberName name, int mod,
+                               bool is_iface, Parameters parameters, Attributes attrs,
+                               Accessor get_block, Accessor set_block, Location loc)
+                       : base (parent, type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
                                is_iface, name, parameters, attrs, loc)
                {
-                       if (get_block != null)
+                       if (get_block == null)
+                               Get = new GetIndexerMethod (this);
+                       else
                                Get = new GetIndexerMethod (this, get_block);
 
-                       if (set_block != null)
+                       if (set_block == null)
+                               Set = new SetIndexerMethod (this);
+                       else
                                Set = new SetIndexerMethod (this, parameters, set_block);
                }
 
@@ -6828,9 +6818,9 @@ namespace Mono.CSharp {
                        if (OptAttributes != null) {
                                Attribute indexer_attr = OptAttributes.GetIndexerNameAttribute (ec);
                                if (indexer_attr != null) {
-                                       IndexerName = indexer_attr.GetIndexerAttributeValue (ec);
+                                       ShortName = indexer_attr.GetIndexerAttributeValue (ec);
+
                                        if (IsExplicitImpl) {
-                                               // The 'IndexerName' attribute is valid only on an indexer that is not an explicit interface member declaration
                                                Report.Error (415, indexer_attr.Location, "The 'IndexerName' attribute is valid only on an indexer that is not an explicit interface member declaration");
                                                return false;
                                        }
@@ -6840,37 +6830,37 @@ namespace Mono.CSharp {
                                                return false;
                                        }
 
-                                       if (!Tokenizer.IsValidIdentifier (IndexerName)) {
-                                               // The argument to the 'IndexerName' attribute must be a valid identifier
+                                       if (!Tokenizer.IsValidIdentifier (ShortName)) {
                                                Report.Error (633, indexer_attr.Location, "The argument to the 'IndexerName' attribute must be a valid identifier");
                                                return false;
                                        }
+
+                                       UpdateMemberName ();
                                }
                        }
 
-                       ShortName = IndexerName;
-                       if (IsExplicitImpl) {
-                               InterfaceIndexerName = TypeManager.IndexerPropertyName (InterfaceType);
-                               Name = InterfaceType.FullName + "." + IndexerName;
-                       } else {
-                               InterfaceIndexerName = IndexerName;
-                               Name = ShortName;
+                       if (InterfaceType != null) {
+                               string parent_IndexerName = TypeManager.IndexerPropertyName (InterfaceType);
+                               if (parent_IndexerName != Name)
+                                       ShortName = parent_IndexerName;
+                               UpdateMemberName ();
                        }
 
-                       if (!CheckNameCollision (Parent))
+                       if (!Parent.AddToMemberContainer (this, true) ||
+                           !Parent.AddToMemberContainer (Get, true) || !Parent.AddToMemberContainer (Set, true))
                                return false;
 
                        if (!CheckBase ())
                                return false;
 
                        flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
-                       if (Get != null){
+                       if (!Get.IsDummy){
                                GetBuilder = Get.Define (Parent);
                                if (GetBuilder == null)
                                        return false;
                        }
                        
-                       if (Set != null){
+                       if (!Set.IsDummy){
                                SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
@@ -6881,19 +6871,24 @@ namespace Mono.CSharp {
                        //
                        Parameter [] p = Parameters.FixedParameters;
                        if (p != null) {
+                               if ((p [0].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
+                                       Report.Error (631, Location, "ref and out are not valid in this context");
+                                       return false;
+                               }
+
                                int i;
                                
                                for (i = 0; i < p.Length; ++i) {
-                                       if (Get != null)
+                                       if (!Get.IsDummy)
                                                GetBuilder.DefineParameter (
                                                        i + 1, p [i].Attributes, p [i].Name);
 
-                                       if (Set != null)
+                                       if (!Set.IsDummy)
                                                SetBuilder.DefineParameter (
                                                        i + 1, p [i].Attributes, p [i].Name);
                                }
 
-                               if (Set != null)
+                               if (!Set.IsDummy)
                                        SetBuilder.DefineParameter (
                                                i + 1, ParameterAttributes.None, "value");
                                        
@@ -6913,12 +6908,12 @@ namespace Mono.CSharp {
                        //
                        if (!IsExplicitImpl) {
                                PropertyBuilder = Parent.TypeBuilder.DefineProperty (
-                                       IndexerName, prop_attr, MemberType, ParameterTypes);
+                                       ShortName, prop_attr, MemberType, ParameterTypes);
 
-                               if (Get != null)
+                               if (!Get.IsDummy)
                                        PropertyBuilder.SetGetMethod (GetBuilder);
 
-                               if (Set != null)
+                               if (!Set.IsDummy)
                                        PropertyBuilder.SetSetMethod (SetBuilder);
                                
                                TypeManager.RegisterIndexer (PropertyBuilder, GetBuilder, SetBuilder,
@@ -6928,48 +6923,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               bool CheckNameCollision (TypeContainer container) {
-                       switch (VerifyName (container)){
-                               case DeclSpace.AdditionResult.NameExists:
-                                       Report.Error (102, Location, "The container '{0}' already contains a definition for '{1}'", container.GetSignatureForError (), Name);
-                                       return false;
-
-                               case DeclSpace.AdditionResult.Success:
-                                       return true;
-                       }
-                       throw new NotImplementedException ();
-               }
-
-               DeclSpace.AdditionResult VerifyName (TypeContainer container) {
-                       if (!AddIndexer (container, container.Name + "." + Name))
-                               return DeclSpace.AdditionResult.NameExists;
-
-                       if (Get != null) {
-                               if (!AddIndexer (container, container.Name + ".get_" + Name))
-                                       return DeclSpace.AdditionResult.NameExists;
-                       }
-
-                       if (Set != null) {
-                               if (!AddIndexer (container, container.Name + ".set_" + Name))
-                                       return DeclSpace.AdditionResult.NameExists;
-                       }
-                       return DeclSpace.AdditionResult.Success;
-               }
-
-               bool AddIndexer (TypeContainer container, string fullname)
-               {
-                       object value = container.GetDefinition (fullname);
-
-                       if (value != null) {
-                               return value.GetType () != GetType () ? false : true;
-                       }
-
-                       container.DefineName (fullname, this);
-                       return true;
-               }
-
                public override string GetSignatureForError ()
                {
+                       if (PropertyBuilder == null)
+                               return GetSignatureForError (Parent);
+
                        return TypeManager.CSharpSignature (PropertyBuilder, true);
                }
 
@@ -6979,7 +6937,7 @@ namespace Mono.CSharp {
                }
        }
 
-       public class Operator : MemberBase, IIteratorContainer {
+       public class Operator : MethodCore, IIteratorContainer {
 
                const int AllowedModifiers =
                        Modifiers.PUBLIC |
@@ -7030,31 +6988,19 @@ namespace Mono.CSharp {
                };
 
                public readonly OpType OperatorType;
-               public readonly Expression ReturnType;
-               public readonly Expression FirstArgType, SecondArgType;
-               public readonly string FirstArgName, SecondArgName;
-               public Block           Block;
                public MethodBuilder   OperatorMethodBuilder;
                
-               public string MethodName;
                public Method OperatorMethod;
 
                static string[] attribute_targets = new string [] { "method", "return" };
 
                public Operator (TypeContainer parent, OpType type, Expression ret_type,
-                                int mod_flags, Expression arg1type, string arg1name,
-                                Expression arg2type, string arg2name,
+                                int mod_flags, Parameters parameters,
                                 Block block, Attributes attrs, Location loc)
-                       : base (parent, ret_type, mod_flags, AllowedModifiers,
-                               Modifiers.PUBLIC, MemberName.Null, attrs, loc)
+                       : base (parent, null, ret_type, mod_flags, AllowedModifiers, false,
+                               new MemberName ("op_" + type), attrs, parameters, loc)
                {
                        OperatorType = type;
-                       Name = "op_" + OperatorType;
-                       ReturnType = ret_type;
-                       FirstArgType = arg1type;
-                       FirstArgName = arg1name;
-                       SecondArgType = arg2type;
-                       SecondArgName = arg2name;
                        Block = block;
                }
 
@@ -7074,16 +7020,35 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override bool Define ()
+               protected override bool CheckForDuplications()
                {
-                       int length = 1;
-                       MethodName = "op_" + OperatorType;
-                       
-                       if (SecondArgType != null)
-                               length = 2;
-                       
-                       Parameter [] param_list = new Parameter [length];
+                       ArrayList ar = Parent.Operators;
+                       if (ar != null) {
+                               int arLen = ar.Count;
+
+                               for (int i = 0; i < arLen; i++) {
+                                       Operator o = (Operator) ar [i];
+                                       if (IsDuplicateImplementation (o))
+                                               return false;
+                               }
+                       }
+
+                       ar = Parent.Methods;
+                       if (ar != null) {
+                               int arLen = ar.Count;
+
+                               for (int i = 0; i < arLen; i++) {
+                                       Method m = (Method) ar [i];
+                                       if (IsDuplicateImplementation (m))
+                                               return false;
+                               }
+                       }
 
+                       return true;
+               }
+
+               public override bool Define ()
+               {
                        if ((ModFlags & RequiredModifiers) != RequiredModifiers){
                                Report.Error (
                                        558, Location, 
@@ -7093,17 +7058,12 @@ namespace Mono.CSharp {
                                return false;
                        }
 
-                       param_list[0] = new Parameter (FirstArgType, FirstArgName,
-                                                      Parameter.Modifier.NONE, null);
-                       if (SecondArgType != null)
-                               param_list[1] = new Parameter (SecondArgType, SecondArgName,
-                                                              Parameter.Modifier.NONE, null);
-                       
+                       if (!DoDefine (ds))
+                               return false;
+
                        OperatorMethod = new Method (
-                               Parent, null, ReturnType, ModFlags, false,
-                               new MemberName (MethodName),
-                               new Parameters (param_list, null, Location),
-                               OptAttributes, Location);
+                               Parent, null, Type, ModFlags, false, MemberName,
+                               Parameters, OptAttributes, Location);
 
                        OperatorMethod.Block = Block;
                        OperatorMethod.IsOperator = true;                       
@@ -7115,10 +7075,13 @@ namespace Mono.CSharp {
                        
                        OperatorMethodBuilder = OperatorMethod.MethodBuilder;
 
-                       Type [] param_types = OperatorMethod.ParameterTypes;
+                       parameter_types = OperatorMethod.ParameterTypes;
                        Type declaring_type = OperatorMethod.MethodData.DeclaringType;
                        Type return_type = OperatorMethod.ReturnType;
-                       Type first_arg_type = param_types [0];
+                       Type first_arg_type = parameter_types [0];
+
+                       if (!CheckBase ())
+                               return false;
 
                        // Rules for conversion operators
                        
@@ -7166,7 +7129,12 @@ namespace Mono.CSharp {
                                        Report.Error (554, Location, "'{0}' : user defined conversion to/from derived class", GetSignatureForError ());
                                        return false;
                                }
-                       } else if (SecondArgType == null) {
+                       } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) {
+                               if (first_arg_type != declaring_type || parameter_types [1] != TypeManager.int32_type) {
+                                       Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int");
+                                       return false;
+                               }
+                       } else if (Parameters.FixedParameters.Length == 1) {
                                // Checks for Unary operators
                                
                                if (first_arg_type != declaring_type){
@@ -7202,7 +7170,7 @@ namespace Mono.CSharp {
                                // Checks for Binary operators
                                
                                if (first_arg_type != declaring_type &&
-                                   param_types [1] != declaring_type){
+                                   parameter_types [1] != declaring_type){
                                        Report.Error (
                                                563, Location,
                                                "One of the parameters of a binary operator must " +
@@ -7226,6 +7194,12 @@ namespace Mono.CSharp {
                        Block = null;
                }
 
+               // Operator cannot be override
+               protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
+               {
+                       return null;
+               }
+
                public static string GetName (OpType ot)
                {
                        switch (ot){
@@ -7288,11 +7262,11 @@ namespace Mono.CSharp {
                public override string GetSignatureForError (TypeContainer tc)
                {
                        StringBuilder sb = new StringBuilder ();
-                       sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), ReturnType.ToString (), TypeManager.CSharpName (FirstArgType.Type));
+                       sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), Type.ToString (), Parameters.FixedParameters [0].GetSignatureForError ());
                        
-                       if (SecondArgType != null) {
+                       if (Parameters.FixedParameters.Length > 1) {
                                sb.Append (",");
-                               sb.Append (TypeManager.CSharpName (SecondArgType.Type));
+                               sb.Append (Parameters.FixedParameters [1].GetSignatureForError ());
                        }
                        sb.Append (")");
                        return sb.ToString ();
@@ -7305,10 +7279,13 @@ namespace Mono.CSharp {
                
                public override string ToString ()
                {
+                       if (OperatorMethod == null)
+                               return Name;
+
                        Type return_type = OperatorMethod.ReturnType;
                        Type [] param_types = OperatorMethod.ParameterTypes;
                        
-                       if (SecondArgType == null)
+                       if (Parameters.FixedParameters.Length == 1)
                                return String.Format (
                                        "{0} operator {1}({2})",
                                        TypeManager.CSharpName (return_type),
index 693f1ebf1fa51d8bd00689b561a2991c0ecce404..e74283d6e22f71cf8786000744d7c199800973ee 100755 (executable)
@@ -79,7 +79,7 @@ namespace Mono.CSharp {
                                return false;
 
                        const_ec = new EmitContext (Parent, Location, null, type, ModFlags);
-                       
+
                        Type ttype = type;
                        while (ttype.IsArray)
                            ttype = TypeManager.GetElementType (ttype);
@@ -196,7 +196,7 @@ namespace Mono.CSharp {
                                value = null;
                                return false;
                        }
-                       
+
                        Expr = Expr.Resolve (const_ec);
 
                        in_transit = false;
@@ -222,15 +222,8 @@ namespace Mono.CSharp {
                                        Expr = ch_expr.Expr;
                                else if ((ec_expr != null) && (ec_expr.Child is Constant))
                                        Expr = ec_expr.Child;
-                               else if (Expr is ArrayCreation) {
-                                       ArrayCreation ac = (ArrayCreation) Expr;
-
-                                       Expr = ac.TurnIntoConstant ();
-                                       if (Expr == null){
-                                               Report.Error (150, Location, "A constant value is expected");
-                                               value = null;
-                                               return false;
-                                       }
+                               else if (Expr is ArrayCreation){
+                                       Report.Error (133, Location, "Arrays can not be constant");
                                } else {
                                        if (errors == Report.Errors)
                                                Report.Error (150, Location, "A constant value is expected");
index 432dfc071049d2199555076d926a225db6ce9642..32ff1816cd2ec943263a0785601dba0a0fcd39e1 100755 (executable)
@@ -770,8 +770,7 @@ struct_declaration
                if ($7 != null)
                        current_class.Bases = (ArrayList) $7;
 
-               CheckDef (current_class.SetParameterInfo ((ArrayList) $8), current_class.Name,
-                         current_class.Location);
+               current_class.SetParameterInfo ((ArrayList) $8);
 
                current_class.Register ();
          }
@@ -836,7 +835,7 @@ constant_declaration
                                (Expression) constant.expression_or_array_initializer, (int) $2, 
                                (Attributes) $1, l);
 
-                       CheckDef (current_container.AddConstant (c), c.Name, l);
+                       current_container.AddConstant (c);
                }
          }
        ;
@@ -888,7 +887,7 @@ field_declaration
                                                 var.expression_or_array_initializer, 
                                                 (Attributes) $1, l);
 
-                       CheckDef (current_container.AddField (field), field.Name, l);
+                       current_container.AddField (field);
                }
          }
        | opt_attributes
@@ -966,7 +965,7 @@ method_declaration
                }
 
                method.Block = (Block) $3;
-               CheckDef (current_container.AddMethod (method), method.Name, method.Location);
+               current_container.AddMethod (method);
 
                current_local_parameters = null;
                iterator_container = null;
@@ -1017,7 +1016,7 @@ method_header
                        generic = new GenericMethod (current_namespace, current_class,
                                                     name, lexer.Location);
 
-                       CheckDef (generic.SetParameterInfo ((ArrayList) $9), name.Name, lexer.Location);
+                       generic.SetParameterInfo ((ArrayList) $9);
                }
 
                method = new Method (current_class, generic, (Expression) $3, (int) $2, false,
@@ -1050,8 +1049,7 @@ method_header
                        generic = new GenericMethod (current_namespace, current_class,
                                                     name, lexer.Location);
 
-
-                       CheckDef (generic.SetParameterInfo ((ArrayList) $9), name.Name, lexer.Location);
+                       generic.SetParameterInfo ((ArrayList) $9);
                }
 
                method = new Method (current_class, generic, TypeManager.system_void_expr,
@@ -1220,7 +1218,7 @@ property_declaration
                if (SimpleIteratorContainer.Simple.Yields)
                        prop.SetYields ();
                
-               CheckDef (current_container.AddProperty (prop), prop.Name, loc);
+               current_container.AddProperty (prop);
                implicit_value_parameter_type = null;
                iterator_container = null;
          }
@@ -1260,7 +1258,7 @@ get_accessor_declaration
          }
           accessor_body
          {
-               $$ = new Accessor ((Block) $4, (Attributes) $1);
+               $$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
                current_local_parameters = null;
                lexer.PropertyParsing = true;
          }
@@ -1297,7 +1295,7 @@ set_accessor_declaration
          }
          accessor_body
          {
-               $$ = new Accessor ((Block) $4, (Attributes) $1);
+               $$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
                current_local_parameters = null;
                lexer.PropertyParsing = true;
          }
@@ -1343,8 +1341,7 @@ interface_declaration
                if ($7 != null)
                        current_class.Bases = (ArrayList) $7;
 
-               CheckDef (current_class.SetParameterInfo ((ArrayList) $8),
-                         current_class.Name, current_class.Location);
+               current_class.SetParameterInfo ((ArrayList) $8);
 
                current_class.Register ();
          }
@@ -1381,19 +1378,19 @@ interface_member_declaration
          { 
                Method m = (Method) $1;
 
-               CheckDef (current_container.AddMethod (m), m.Name, m.Location);
+               current_container.AddMethod (m);
          }
        | interface_property_declaration        
          { 
                Property p = (Property) $1;
 
-               CheckDef (current_container.AddProperty (p), p.Name, p.Location);
+               current_container.AddProperty (p);
           }
        | interface_event_declaration 
           { 
                if ($1 != null){
                        Event e = (Event) $1;
-                       CheckDef (current_container.AddEvent (e), e.Name, lexer.Location);
+                       current_container.AddEvent (e);
                }
          }
        | interface_indexer_declaration
@@ -1435,7 +1432,7 @@ interface_method_declaration
                        generic = new GenericMethod (current_namespace, current_class,
                                                     name, lexer.Location);
 
-                       CheckDef (generic.SetParameterInfo ((ArrayList) $9), name.Name, lexer.Location);
+                       generic.SetParameterInfo ((ArrayList) $9);
                }
 
                $$ = new Method (current_class, generic, (Expression) $3, (int) $2, true, name,
@@ -1462,7 +1459,7 @@ interface_method_declaration
                        generic = new GenericMethod (current_namespace, current_class,
                                                     name, lexer.Location);
 
-                       CheckDef (generic.SetParameterInfo ((ArrayList) $9), name.Name, lexer.Location);
+                       generic.SetParameterInfo ((ArrayList) $9);
                }
 
                $$ = new Method (current_class, generic, TypeManager.system_void_expr, (int) $2,
@@ -1495,12 +1492,12 @@ interface_property_declaration
        ;
 
 interface_accessors
-       : opt_attributes GET SEMICOLON          { $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null); }
-       | opt_attributes SET SEMICOLON          { $$ = new InterfaceAccessorInfo (false, true, null, (Attributes) $1); }
+       : opt_attributes GET SEMICOLON          { $$ = new InterfaceAccessorInfo (true, false, (Attributes) $1, null, lexer.Location, lexer.Location); }
+       | opt_attributes SET SEMICOLON          { $$ = new InterfaceAccessorInfo (false, true, null, (Attributes) $1, lexer.Location, lexer.Location); }
        | opt_attributes GET SEMICOLON opt_attributes SET SEMICOLON 
-         { $$ = new InterfaceAccessorInfo (true, true, (Attributes) $1, (Attributes) $3); }
+         { $$ = new InterfaceAccessorInfo (true, true, (Attributes) $1, (Attributes) $3, lexer.Location, lexer.Location); }
        | opt_attributes SET SEMICOLON opt_attributes GET SEMICOLON
-         { $$ = new InterfaceAccessorInfo (true, true, (Attributes) $3, (Attributes) $1); }
+         { $$ = new InterfaceAccessorInfo (true, true, (Attributes) $3, (Attributes) $1, lexer.Location, lexer.Location); }
        ;
 
 interface_event_declaration
@@ -1535,8 +1532,9 @@ interface_indexer_declaration
          {
                InterfaceAccessorInfo info = (InterfaceAccessorInfo) $10;
 
-               $$ = new Indexer (current_class, (Expression) $3, (int) $2, true,
-                                 MemberName.Null, (Parameters) $6, (Attributes) $1,
+               $$ = new Indexer (current_class, (Expression) $3,
+                                 new MemberName (TypeContainer.DefaultIndexerName),
+                                 (int) $2, true, (Parameters) $6, (Attributes) $1,
                                  info.Get, info.Set, lexer.Location);
          }
        ;
@@ -1550,10 +1548,16 @@ operator_declaration
          {
                OperatorDeclaration decl = (OperatorDeclaration) $3;
                
+               Parameter [] param_list = new Parameter [decl.arg2type != null ? 2 : 1];
+
+               param_list[0] = new Parameter (decl.arg1type, decl.arg1name, Parameter.Modifier.NONE, null);
+               if (decl.arg2type != null)
+                       param_list[1] = new Parameter (decl.arg2type, decl.arg2name, Parameter.Modifier.NONE, null);
+
                Operator op = new Operator (
-                       current_class, decl.optype, decl.ret_type, (int) $2, decl.arg1type,
-                       decl.arg1name, decl.arg2type, decl.arg2name, (Block) $5,
-                       (Attributes) $1, decl.location);
+                       current_class, decl.optype, decl.ret_type, (int) $2,
+                       new Parameters (param_list, null, decl.location),
+                       (Block) $5, (Attributes) $1, decl.location);
 
                if (SimpleIteratorContainer.Simple.Yields)
                        op.SetYields ();
@@ -1716,7 +1720,7 @@ constructor_declaration
                        Console.WriteLine ("{0} and {1}", c.Name, current_container.Basename);
                }
 
-               CheckDef (current_container.AddConstructor (c), c.Name, c.Location);
+               current_container.AddConstructor (c);
 
                current_local_parameters = null;
          }
@@ -1798,7 +1802,7 @@ destructor_declaration
                                new Parameters (null, null, l), (Attributes) $1, l);
                  
                        d.Block = (Block) $7;
-                       CheckDef (current_container.AddMethod (d), d.Name, d.Location);
+                       current_container.AddMethod (d);
                }
          }
        | opt_attributes opt_modifiers EVENT type member_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS block {
@@ -1825,7 +1829,7 @@ event_declaration
                                                  var.expression_or_array_initializer,
                                                  (Attributes) $1, lexer.Location);
 
-                       CheckDef (current_container.AddEvent (e), e.Name, e.Location);
+                       current_container.AddEvent (e);
                                       
                }
          }
@@ -1861,7 +1865,7 @@ event_declaration
                                             (Accessor) pair.First, (Accessor) pair.Second,
                                             loc);
                
-               CheckDef (current_container.AddEvent (e), e.Name, loc);
+               current_container.AddEvent (e);
                implicit_value_parameter_type = null;
          }
          }
@@ -1895,7 +1899,7 @@ add_accessor_declaration
          }
           block
          {
-               $$ = new Accessor ((Block) $4, (Attributes) $1);
+               $$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
                lexer.EventParsing = true;
          }
        | opt_attributes ADD error {
@@ -1919,7 +1923,7 @@ remove_accessor_declaration
          }
           block
          {
-               $$ = new Accessor ((Block) $4, (Attributes) $1);
+               $$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
                lexer.EventParsing = true;
          }
        | opt_attributes REMOVE error {
@@ -1962,15 +1966,12 @@ indexer_declaration
                if (decl.interface_type != null)
                        name = new MemberName (decl.interface_type, "", null);
                else
-                       name = MemberName.Null;
+                       name = new MemberName (TypeContainer.DefaultIndexerName);
 
-               indexer = new Indexer (current_class, decl.type, (int) $2, false,
-                                      name, decl.param_list, (Attributes) $1,
+               indexer = new Indexer (current_class, decl.type, name,
+                                      (int) $2, false, decl.param_list, (Attributes) $1,
                                       get_block, set_block, loc);
 
-               // Note that there is no equivalent of CheckDef for this case
-               // We shall handle this in semantic analysis
-               
                current_container.AddIndexer (indexer);
                
                current_local_parameters = null;
@@ -2027,14 +2028,13 @@ enum_declaration
                foreach (VariableDeclaration ev in (ArrayList) $6) {
                        Location loc = (Location) ev.Location;
 
-                       CheckDef (e.AddEnumMember (ev.identifier, 
-                                                  (Expression) ev.expression_or_array_initializer,
-                                                  loc, ev.OptAttributes),
-                                 ev.identifier, loc);
+                       e.AddEnumMember (ev.identifier, 
+                                        (Expression) ev.expression_or_array_initializer,
+                                        loc, ev.OptAttributes);
                }
 
                string name = full_name.GetName (false);
-               CheckDef (current_container.AddEnum (e), name, enum_location);
+               current_container.AddEnum (e);
                RootContext.Tree.RecordDecl (name, e);
 
          }
@@ -2101,7 +2101,7 @@ delegate_declaration
                        current_namespace, current_container, (Expression) $4, (int) $2,
                        MakeName ((MemberName) $5), (Parameters) $7, (Attributes) $1, l);
                  
-               CheckDef (current_container.AddDelegate (del), del.Name, l);
+               current_container.AddDelegate (del);
 
                current_delegate = del;
 
@@ -2113,7 +2113,7 @@ delegate_declaration
          }
          SEMICOLON
          {
-               CheckDef (current_delegate.SetParameterInfo ((ArrayList) $9), current_delegate.Name, current_delegate.Location);
+               current_delegate.SetParameterInfo ((ArrayList) $9);
 
                current_delegate = null;
          }
@@ -2128,7 +2128,7 @@ delegate_declaration
                        TypeManager.system_void_expr, (int) $2, MakeName ((MemberName) $5), 
                        (Parameters) $7, (Attributes) $1, l);
 
-               CheckDef (current_container.AddDelegate (del), del.Name, l);
+               current_container.AddDelegate (del);
 
                current_delegate = del;
 
@@ -2140,7 +2140,7 @@ delegate_declaration
          }
          SEMICOLON
          {
-               CheckDef (current_delegate.SetParameterInfo ((ArrayList) $9), current_delegate.Name, current_delegate.Location);
+               current_delegate.SetParameterInfo ((ArrayList) $9);
 
                current_delegate = null;
          }
@@ -2742,7 +2742,7 @@ anonymous_method_expression
                } else {
                        create_toplevel_block = false;
                        if (RootContext.Version == LanguageVersion.ISO_1){
-                               Report.FeatureIsNotStandardized ("anonymous methods");
+                               Report.FeatureIsNotStandardized (lexer.Location, "anonymous methods");
                                $$ = null;
                        } else 
                                $$ = new AnonymousMethod ((Parameters) $2, (Block) $4, lexer.Location);
@@ -3172,8 +3172,7 @@ class_declaration
                        current_class.Bases = (ArrayList) $7;
                }
 
-               CheckDef (current_class.SetParameterInfo ((ArrayList) $8),
-                         current_class.Name, current_class.Location);
+               current_class.SetParameterInfo ((ArrayList) $8);
 
                current_class.Register ();
          }
@@ -3943,7 +3942,7 @@ yield_statement
                        $$ = null;
                }
                if (RootContext.Version == LanguageVersion.ISO_1){
-                       Report.FeatureIsNotStandardized ("yield statement");
+                       Report.FeatureIsNotStandardized (lexer.Location, "yield statement");
                        $$ = null;
                }
                if (iterator_container == null){
@@ -3962,7 +3961,7 @@ yield_statement
                        $$ = null;
                }
                if (RootContext.Version == LanguageVersion.ISO_1){
-                       Report.FeatureIsNotStandardized ("yield statement");
+                       Report.FeatureIsNotStandardized (lexer.Location, "yield statement");
                        $$ = null;
                }
                if (iterator_container == null){
@@ -4311,12 +4310,12 @@ public class InterfaceAccessorInfo {
         public readonly Accessor Get, Set;
 
         public InterfaceAccessorInfo (bool has_get, bool has_set,
-                                      Attributes get_attrs, Attributes set_attrs)
+                                      Attributes get_attrs, Attributes set_attrs, Location get_loc, Location set_loc)
         {
                if (has_get)
-                       Get = new Accessor (null, get_attrs);
+                       Get = new Accessor (null, get_attrs, get_loc);
                if (has_set)
-                       Set = new Accessor (null, set_attrs);
+                       Set = new Accessor (null, set_attrs, set_loc);
         }
 }
 
@@ -4409,24 +4408,6 @@ MakeName (MemberName class_name)
        }
 }
 
-// <summary>
-//   Used to report back to the user the result of a declaration
-//   in the current declaration space
-// </summary>
-void 
-CheckDef (DeclSpace.AdditionResult result, string name, Location l)
-{
-       current_container.CheckDef (result, name, l);
-}
-
-void 
-CheckDef (bool result, string name, Location l)
-{
-       if (result)
-               return;
-       CheckDef (DeclSpace.AdditionResult.NameExists, name, l);
-}
-
 Block declare_local_variables (Expression type, ArrayList variable_declarators, Location loc)
 {
        Block implicit_block;
index d75db57e1b66d0967dda5f5072b680bdabaaa442..4eb5bcbafd2ec413d122996754c69fd987f3c382 100755 (executable)
@@ -887,6 +887,11 @@ namespace Mono.CSharp
                                val = 0ul;\r
                                return Token.LITERAL_INTEGER;\r
                        }\r
+                       catch (FormatException) {\r
+                               Report.Error (1013, Location, "Invalid number");\r
+                               val = 0ul;\r
+                               return Token.LITERAL_INTEGER;\r
+                       }\r
                }\r
                \r
                int adjust_real (int t)\r
@@ -1393,6 +1398,60 @@ namespace Mono.CSharp
                        }\r
                }\r
 \r
+               /// <summary>\r
+               /// Handles #pragma directive\r
+               /// </summary>\r
+               void PreProcessPragma (string arg)\r
+               {\r
+                       const string disable = "warning disable";\r
+                       const string restore = "warning restore";\r
+\r
+                       if (arg == disable) {\r
+                               Report.RegisterWarningRegion (Location).WarningDisable (line);\r
+                               return;\r
+                       }\r
+\r
+                       if (arg == restore) {\r
+                               Report.RegisterWarningRegion (Location).WarningEnable (line);\r
+                               return;\r
+                       }\r
+\r
+                       if (arg.StartsWith (disable)) {\r
+                               int[] codes = ParseNumbers (arg.Substring (disable.Length));\r
+                               foreach (int code in codes) {\r
+                                       if (code != 0)\r
+                                               Report.RegisterWarningRegion (Location).WarningDisable (Location, code);\r
+                               }\r
+                               return;\r
+                       }\r
+\r
+                       if (arg.StartsWith (restore)) {\r
+                               int[] codes = ParseNumbers (arg.Substring (restore.Length));\r
+                               foreach (int code in codes) {\r
+                                       Report.RegisterWarningRegion (Location).WarningEnable (Location, code);\r
+                               }\r
+                               return;\r
+                       }\r
+\r
+                       return;\r
+               }\r
+\r
+               int[] ParseNumbers (string text)\r
+               {\r
+                       string[] string_array = text.Split (',');\r
+                       int[] values = new int [string_array.Length];\r
+                       int index = 0;\r
+                       foreach (string string_code in string_array) {\r
+                               try {\r
+                                       values[index++] = int.Parse (string_code, System.Globalization.CultureInfo.InvariantCulture);\r
+                               }\r
+                               catch (FormatException) {\r
+                                       Report.Warning (1692, Location, "Invalid number");\r
+                               }\r
+                       }\r
+                       return values;\r
+               }\r
+\r
                bool eval_val (string s)\r
                {\r
                        if (s == "true")\r
@@ -1596,9 +1655,13 @@ namespace Mono.CSharp
                        //\r
                        switch (cmd){\r
                        case "pragma":\r
-                               if (RootContext.Version != LanguageVersion.ISO_1)\r
+                               if (RootContext.Version == LanguageVersion.ISO_1) {\r
+                                       Report.FeatureIsNotStandardized (Location, "#pragma");\r
                                        return caller_is_taking;\r
-                               break;\r
+                               }\r
+\r
+                               PreProcessPragma (arg);\r
+                               return caller_is_taking;\r
                                \r
                        case "line":\r
                                if (!PreProcessLine (arg))\r
index 8192a97f7c8fafac8b9bd163ac4a8f6be883cf14..bf28a2e3472da261074142729ffdd1ff04b1b99f 100755 (executable)
@@ -21,7 +21,7 @@ using System.Reflection;
 namespace Mono.CSharp {
 
        public class MemberName {
-               public readonly string Name;
+               public string Name;
                public readonly TypeArguments TypeArguments;
 
                public readonly MemberName Left;
@@ -175,6 +175,14 @@ namespace Mono.CSharp {
                        }
                }
 
+               public MemberName Clone ()
+               {
+                       if (Left != null)
+                               return new MemberName (Left.Clone (), Name, TypeArguments);
+                       else
+                               return new MemberName (Name, TypeArguments);
+               }
+
                public string Basename {
                        get {
                                if (TypeArguments != null)
@@ -207,7 +215,11 @@ namespace Mono.CSharp {
                /// <summary>
                ///   Public name
                /// </summary>
-               public string Name;
+               public string Name {
+                       get {
+                               return MemberName.GetName (!(this is GenericMethod) && !(this is Method));
+                       }
+               }
 
                public readonly MemberName MemberName;
 
@@ -234,21 +246,20 @@ namespace Mono.CSharp {
                        HasClsCompliantAttribute = 1 << 6,                      // Type has CLSCompliantAttribute
                        ClsCompliantAttributeTrue = 1 << 7,                     // Type has CLSCompliant (true)
                        Excluded_Undetected = 1 << 8,           // Conditional attribute has not been detected yet
-                       Excluded = 1 << 9                                       // Method is conditional
-
+                       Excluded = 1 << 9,                                      // Method is conditional
+                       TestMethodDuplication = 1 << 10         // Test for duplication must be performed
                }
   
                /// <summary>
                ///   MemberCore flags at first detected then cached
                /// </summary>
-               protected Flags caching_flags;
+               internal Flags caching_flags;
 
                public MemberCore (TypeContainer parent, MemberName name, Attributes attrs,
                                   Location loc)
                        : base (attrs)
                {
                        Parent = parent;
-                       Name = name.GetName (!(this is GenericMethod) && !(this is Method));
                        MemberName = name;
                        Location = loc;
                        caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
@@ -475,9 +486,6 @@ namespace Mono.CSharp {
                
                public string Basename;
                
-               /// <summary>
-               ///   defined_names is used for toplevel objects
-               /// </summary>
                protected Hashtable defined_names;
 
                readonly bool is_generic;
@@ -514,101 +522,51 @@ namespace Mono.CSharp {
                                count_type_params += parent.count_type_params;
                }
 
-               public void RecordDecl ()
-               {
-                       if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
-                               NamespaceEntry.DefineName (MemberName.Basename, this);
-               }
-
-               /// <summary>
-               ///   The result value from adding an declaration into
-               ///   a struct or a class
-               /// </summary>
-               public enum AdditionResult {
-                       /// <summary>
-                       /// The declaration has been successfully
-                       /// added to the declation space.
-                       /// </summary>
-                       Success,
-
-                       /// <summary>
-                       ///   The symbol has already been defined.
-                       /// </summary>
-                       NameExists,
-
-                       /// <summary>
-                       ///   Returned if the declation being added to the
-                       ///   name space clashes with its container name.
-                       ///
-                       ///   The only exceptions for this are constructors
-                       ///   and static constructors
-                       /// </summary>
-                       EnclosingClash,
-
-                       /// <summary>
-                       ///   Returned if a constructor was created (because syntactically
-                       ///   it looked like a constructor) but was not (because the name
-                       ///   of the method is not the same as the container class
-                       /// </summary>
-                       NotAConstructor,
-
-                       /// <summary>
-                       ///   This is only used by static constructors to emit the
-                       ///   error 111, but this error for other things really
-                       ///   happens at another level for other functions.
-                       /// </summary>
-                       MethodExists,
-
-                       /// <summary>
-                       ///   Some other error.
-                       /// </summary>
-                       Error
-               }
-
                /// <summary>
-               ///   Returns a status code based purely on the name
-               ///   of the member being added
+               /// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
                /// </summary>
-               protected AdditionResult IsValid (string basename, string name)
+               protected bool AddToContainer (MemberCore symbol, bool is_method, string fullname, string basename)
                {
-                       if (basename == Basename)
-                               return AdditionResult.EnclosingClash;
+                       if (basename == Basename) {
+                               Report.SymbolRelatedToPreviousError (this);
+                               Report.Error (542, "'{0}': member names cannot be the same as their enclosing type", symbol.Location, symbol.GetSignatureForError ());
+                               return false;
+                       }
+
+                       MemberCore mc = (MemberCore)defined_names [fullname];
+
+                       if (is_method && (mc is MethodCore || mc is IMethodData)) {
+                               symbol.caching_flags |= Flags.TestMethodDuplication;
+                               mc.caching_flags |= Flags.TestMethodDuplication;
+                               return true;
+                       }
 
-                       if (defined_names.Contains (name))
-                               return AdditionResult.NameExists;
+                       if (mc != null) {
+                               Report.SymbolRelatedToPreviousError (mc);
+                               Report.Error (102, symbol.Location, "The type '{0}' already contains a definition for '{1}'", GetSignatureForError (), basename);
+                               return false;
+                       }
 
-                       return AdditionResult.Success;
+                       defined_names.Add (fullname, symbol);
+                       return true;
                }
 
-               public static int length;
-               public static int small;
-               
-               /// <summary>
-               ///   Introduce @name into this declaration space and
-               ///   associates it with the object @o.  Note that for
-               ///   methods this will just point to the first method. o
-               /// </summary>
-               public void DefineName (string name, object o)
+               public void RecordDecl ()
                {
-                       defined_names.Add (name, o);
-
-#if DEBUGME
-                       int p = name.LastIndexOf ('.');
-                       int l = name.Length;
-                       length += l;
-                       small += l -p;
-#endif
+                       if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
+                               NamespaceEntry.DefineName (MemberName.Basename, this);
                }
 
                /// <summary>
-               ///   Returns the object associated with a given name in the declaration
-               ///   space.  This is the inverse operation of `DefineName'
+               ///   Returns the MemberCore associated with a given name in the declaration
+               ///   space. It doesn't return method based symbols !!
                /// </summary>
-               public object GetDefinition (string name)
+               /// 
+               public MemberCore GetDefinition (string name)
                {
-                       return defined_names [name];
+                       return (MemberCore)defined_names [name];
                }
-               
+
                bool in_transit = false;
                
                /// <summary>
@@ -1383,17 +1341,16 @@ namespace Mono.CSharp {
                        return type_param_list;
                }
 
-               public AdditionResult SetParameterInfo (ArrayList constraints_list)
+               public void SetParameterInfo (ArrayList constraints_list)
                {
                        if (!is_generic) {
                                if (constraints_list != null) {
                                        Report.Error (
                                                80, Location, "Contraints are not allowed " +
                                                "on non-generic declarations");
-                                       return AdditionResult.Error;
                                }
 
-                               return AdditionResult.Success;
+                               return;
                        }
 
                        string[] names = MemberName.TypeArguments.GetDeclarations ();
@@ -1405,11 +1362,6 @@ namespace Mono.CSharp {
                        for (int i = 0; i < type_params.Length; i++) {
                                string name = names [i];
 
-                               AdditionResult res = IsValid (name, name);
-
-                               if (res != AdditionResult.Success)
-                                       return res;
-
                                Constraints constraints = null;
                                if (constraints_list != null) {
                                        foreach (Constraints constraint in constraints_list) {
@@ -1420,12 +1372,11 @@ namespace Mono.CSharp {
                                        }
                                }
 
-                               type_params [i] = new TypeParameter (name, constraints, Location);
+                               type_params [i] = new TypeParameter (Parent, name, constraints, Location);
 
-                               DefineName (name, type_params [i]);
+                               string full_name = Name + "." + name;
+                               AddToContainer (type_params [i], false, full_name, name);
                        }
-
-                       return AdditionResult.Success;
                }
 
                public TypeParameter[] TypeParameters {
index 7e05d0c68003229ee798ea968b82dbbc83d3063b..ae8e44dc0fc19b09eb3d9d9e3d763c52c2c0bd08 100755 (executable)
@@ -1267,9 +1267,9 @@ namespace Mono.CSharp {
                                return 0;
                }
 
-               static void Error_NegativeArrayIndex (Location loc)
+               public static void Error_NegativeArrayIndex (Location loc)
                {
-                       Report.Error (284, loc, "Can not create array with a negative size");
+                       Report.Error (248, loc, "Cannot create an array with a negative size");
                }
                
                //
@@ -2985,7 +2985,7 @@ namespace Mono.CSharp {
                                        return this;
                        }
 
-                       Report_AssignToReadonly (true);
+                       Report_AssignToReadonly (!IsStatic);
                        
                        return null;
                }
index 04d20c1a07cda55983fc283fb5b82f6cc9a4d95a..2511ec62312131e71875431bda272fb6e66bf154 100755 (executable)
@@ -22,12 +22,15 @@ namespace Mono.CSharp {
 
                Enum parent_enum;
                public FieldBuilder builder;
+               internal readonly Expression Type;
 
-               public EnumMember (Enum parent_enum, string name, Location loc, Attributes attrs):
+               public EnumMember (Enum parent_enum, Expression expr, string name,
+                                  Location loc, Attributes attrs):
                        base (null, new MemberName (name), attrs, loc)
                {
                        this.parent_enum = parent_enum;
                        this.ModFlags = parent_enum.ModFlags;
+                       this.Type = expr;
                }
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
@@ -66,29 +69,14 @@ namespace Mono.CSharp {
 
                public void Emit (EmitContext ec)
                {
+                       base.Emit ();
+
                        if (OptAttributes != null)
                                OptAttributes.Emit (ec, this); 
 
                        Emit ();
                }
 
-               // TODO: caching would be usefull
-               public ObsoleteAttribute GetObsoleteAttribute (EmitContext ec)
-               {
-                       if (OptAttributes == null)
-                               return null;
-
-                       Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
-                       if (obsolete_attr == null)
-                               return null;
-
-                       ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ec.DeclSpace);
-                       if (obsolete == null)
-                               return null;
-
-                       return obsolete;
-               }
-
                public override string GetSignatureForError()
                {
                        return String.Concat (parent_enum.GetSignatureForError (), '.', base.GetSignatureForError ());
@@ -124,7 +112,6 @@ namespace Mono.CSharp {
                public Type UnderlyingType;
 
                Hashtable member_to_location;
-               Hashtable member_to_attributes;
 
                //
                // This is for members that have been defined
@@ -138,9 +125,6 @@ namespace Mono.CSharp {
                
                ArrayList field_builders;
                
-
-               Hashtable name_to_member;
-               
                public const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -161,38 +145,27 @@ namespace Mono.CSharp {
                        member_to_value = new Hashtable ();
                        in_transit = new Hashtable ();
                        field_builders = new ArrayList ();
-
-                       name_to_member = new Hashtable ();
                }
 
                /// <summary>
                ///   Adds @name to the enumeration space, with @expr
                ///   being its definition.  
                /// </summary>
-               public AdditionResult AddEnumMember (string name, Expression expr, Location loc,
-                                                    Attributes opt_attrs)
+               public void AddEnumMember (string name, Expression expr, Location loc, Attributes opt_attrs)
                {
-                       if (defined_names.Contains (name))
-                               return AdditionResult.NameExists;
-
                        if (name == "value__") {
                                Report.Error (76, loc, "An item in an enumeration can't have an identifier `value__'");
-                               return AdditionResult.Error;
+                               return;
                        }
 
-                       DefineName (name, expr);
+                       EnumMember em = new EnumMember (this, expr, name, loc, opt_attrs);
+                       if (!AddToContainer (em, false, name, ""))
+                               return;
 
+
+                       // TODO: can be almost deleted
                        ordered_enums.Add (name);
                        member_to_location.Add (name, loc);
-
-                       if (member_to_attributes == null)
-                               member_to_attributes = new Hashtable ();
-
-                       member_to_attributes.Add (name, opt_attrs);
-                       
-                       name_to_member.Add (name, new EnumMember (this, name, loc, opt_attrs));
-
-                       return AdditionResult.Success;
                }
 
                //
@@ -611,7 +584,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       EnumMember em = name_to_member [name] as EnumMember;
+                       EnumMember em = (EnumMember) defined_names [name];
                        em.DefineMember (TypeBuilder);
 
                        bool fail;
@@ -643,14 +616,14 @@ namespace Mono.CSharp {
                        //
                        if (TypeBuilder == null)
                                return false;
-                       
+
                        EmitContext ec = new EmitContext (this, this, Location, null,
                                                          UnderlyingType, ModFlags, false);
 
                        
                        object default_value = 0;
                        
-                       
+               
                        foreach (string name in ordered_enums) {
                                //
                                // Have we already been defined, thanks to some cross-referencing ?
@@ -671,7 +644,7 @@ namespace Mono.CSharp {
                                                return false;
                                        }
 
-                                       EnumMember em = name_to_member [name] as EnumMember;
+                                       EnumMember em = (EnumMember) defined_names [name];
 
                                        em.DefineMember (TypeBuilder);
                                        FieldBuilder fb = em.builder;
@@ -702,7 +675,7 @@ namespace Mono.CSharp {
 
                        return true;
                }
-                       
+
                public override void Emit ()
                {
                        EmitContext ec = new EmitContext (
@@ -712,7 +685,7 @@ namespace Mono.CSharp {
                                OptAttributes.Emit (ec, this);
                        }
 
-                       foreach (EnumMember em in name_to_member.Values) {
+                       foreach (EnumMember em in defined_names.Values) {
                                em.Emit (ec);
                        }
 
@@ -720,21 +693,21 @@ namespace Mono.CSharp {
                }
                
                void VerifyClsName ()
-               {
+               {
                        Hashtable ht = new Hashtable ();
                        foreach (string name in ordered_enums) {
                                string locase = name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
                                if (!ht.Contains (locase)) {
-                                       ht.Add (locase, name_to_member [name]);
-                                               continue;
-                               }
+                                       ht.Add (locase, defined_names [name]);
+                                       continue;
+                               }
  
-                               EnumMember conflict = (EnumMember)ht [locase];
+                               MemberCore conflict = (MemberCore)ht [locase];
                                Report.SymbolRelatedToPreviousError (conflict);
-                               conflict = (EnumMember)name_to_member [name];
+                               conflict = GetDefinition (name);
                                Report.Error (3005, conflict.Location, "Identifier '{0}' differing only in case is not CLS-compliant", conflict.GetSignatureForError ());
-                       }
-               }
+                       }
+               }
 
                protected override bool VerifyClsCompliance (DeclSpace ds)
                {
@@ -796,7 +769,7 @@ namespace Mono.CSharp {
                // indexer
                public Expression this [string name] {
                        get {
-                               return (Expression) defined_names [name];
+                               return ((EnumMember) defined_names [name]).Type;
                        }
                }
 
@@ -810,28 +783,5 @@ namespace Mono.CSharp {
                {
                        // UnderlyingType is never obsolete
                }
-
-               /// <summary>
-               /// Returns ObsoleteAttribute for both enum type and enum member
-               /// </summary>
-               public ObsoleteAttribute GetObsoleteAttribute (EmitContext ec, string identifier)
-               {
-                       if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
-                               return null;
-                       }
-
-                       ObsoleteAttribute oa = GetObsoleteAttribute (ec.DeclSpace);
-                       if (oa != null)
-                               return oa;
-
-                       EnumMember em = (EnumMember)name_to_member [identifier];
-                       oa = em.GetObsoleteAttribute (ec);
-
-                       if (oa == null)
-                               return null;
-
-                       caching_flags |= Flags.Obsolete;
-                       return oa;
-               }
        }
 }
index 9988c98f61774b68b3005c5a41856f1a110b942c..0b763e3d532193f1e71ba4d41c3520d8620f0ff0 100755 (executable)
@@ -1042,6 +1042,10 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return null;
                        
+                       if (expr.Type.IsPointer) {
+                               Report.Error (244, loc, "\"is\" or \"as\" are not valid on pointer types");
+                               return null;
+                       }
                        return this;
                }
        }
@@ -3414,8 +3418,11 @@ namespace Mono.CSharp {
                                        else if (rtype == TypeManager.uint64_type)
                                                ig.Emit (OpCodes.Conv_U8);
                                        ig.Emit (OpCodes.Mul);
-                                       ig.Emit (OpCodes.Conv_I);
                                }
+                               
+                               if (rtype == TypeManager.int64_type || rtype == TypeManager.uint64_type)
+                                       ig.Emit (OpCodes.Conv_I);
+                               
                                if (is_add)
                                        ig.Emit (OpCodes.Add);
                                else
@@ -3485,14 +3492,6 @@ namespace Mono.CSharp {
                                Type true_type = trueExpr.Type;
                                Type false_type = falseExpr.Type;
 
-                               if (trueExpr is NullLiteral){
-                                       type = false_type;
-                                       return this;
-                               } else if (falseExpr is NullLiteral){
-                                       type = true_type;
-                                       return this;
-                               }
-                               
                                //
                                // First, if an implicit conversion exists from trueExpr
                                // to falseExpr, then the result type is of type falseExpr.Type
@@ -4020,6 +4019,16 @@ namespace Mono.CSharp {
                                if (Expr == null)
                                        return false;
 
+                               if (!ec.IsConstructor) {
+                                       FieldExpr fe = Expr as FieldExpr;
+                                       if (fe != null && fe.FieldInfo.IsInitOnly) {
+                                               if (fe.FieldInfo.IsStatic)
+                                                       Report.Error (199, loc, "A static readonly field cannot be passed ref or out (except in a static constructor)");
+                                               else
+                                                       Report.Error (192, loc, "A readonly field cannot be passed ref or out (except in a constructor)");
+                                               return false;
+                                       }
+                               }
                                Expr = Expr.ResolveLValue (ec, Expr);
                        } else if (ArgType == AType.Out)
                                Expr = Expr.ResolveLValue (ec, new EmptyExpression ());
@@ -5291,6 +5300,14 @@ namespace Mono.CSharp {
                                return null;
                        }
 
+                       if (method.Name == "Finalize" && Arguments == null) {
+                               if (is_base)
+                                       Report.Error (250, loc, "Do not directly call your base class Finalize method. It is called automatically from your destructor");
+                               else
+                                       Report.Error (245, loc, "Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available");
+                               return null;
+                       }
+
                        if ((method.Attributes & MethodAttributes.SpecialName) != 0){
                                if (TypeManager.IsSpecialMethod (method))
                                        Report.Error (571, loc, method.Name + ": can not call operator or accessor");
@@ -6219,7 +6236,7 @@ namespace Mono.CSharp {
                                        Expression tmp = (Expression) o;
                                        tmp = tmp.Resolve (ec);
                                        if (tmp == null)
-                                               continue;
+                                               return false;
 
                                        // Console.WriteLine ("I got: " + tmp);
                                        // Handle initialization from vars, fields etc.
@@ -6314,11 +6331,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               void Error_NegativeArrayIndex ()
-               {
-                       Error (284, "Can not create array with a negative size");
-               }
-               
                //
                // Converts `source' to an int, uint, long or ulong.
                //
@@ -6349,14 +6361,14 @@ namespace Mono.CSharp {
                        if (target is Constant){
                                if (target is IntConstant){
                                        if (((IntConstant) target).Value < 0){
-                                               Error_NegativeArrayIndex ();
+                                               Expression.Error_NegativeArrayIndex (loc);
                                                return null;
                                        }
                                }
 
                                if (target is LongConstant){
                                        if (((LongConstant) target).Value < 0){
-                                               Error_NegativeArrayIndex ();
+                                               Expression.Error_NegativeArrayIndex (loc);
                                                return null;
                                        }
                                }
@@ -6854,16 +6866,6 @@ namespace Mono.CSharp {
                        }
                        return ret;
                }
-
-               public Expression TurnIntoConstant ()
-               {
-                       //
-                       // Should use something like the above attribute thing.
-                       // It should return a subclass of Constant that just returns
-                       // the computed value of the array
-                       //
-                       throw new Exception ("Does not support yet Turning array into a Constant");
-               }
        }
        
        /// <summary>
@@ -7128,6 +7130,10 @@ namespace Mono.CSharp {
                                return null;
                        }
 
+                       if (typearg.IsPointer && !ec.InUnsafe){
+                               UnsafeError (loc);
+                               return null;
+                       }
                        CheckObsoleteAttribute (typearg);
 
                        type = TypeManager.type_type;
@@ -7508,7 +7514,12 @@ namespace Mono.CSharp {
                                                object value = en.LookupEnumValue (ec, Identifier, loc);
                                                
                                                if (value != null){
-                                                       ObsoleteAttribute oa = en.GetObsoleteAttribute (ec, Identifier);
+                                                       MemberCore mc = en.GetDefinition (Identifier);
+                                                       ObsoleteAttribute oa = mc.GetObsoleteAttribute (en);
+                                                       if (oa != null) {
+                                                               AttributeTester.Report_ObsoleteMessage (oa, mc.GetSignatureForError (), Location);
+                                                       }
+                                                       oa = en.GetObsoleteAttribute (en);
                                                        if (oa != null) {
                                                                AttributeTester.Report_ObsoleteMessage (oa, en.GetSignatureForError (), Location);
                                                        }
index 636147e5ea7be04bc4b3815f47e0ed125f2e064d..a46bcb2bc6d2a6225098f6c7b5e4c38d9e5704ad 100644 (file)
@@ -397,31 +397,21 @@ namespace Mono.CSharp {
        //
        // This type represents a generic type parameter
        //
-       public class TypeParameter : IMemberContainer {
+       public class TypeParameter : MemberCore, IMemberContainer {
                string name;
                Constraints constraints;
                Location loc;
                GenericTypeParameterBuilder type;
 
-               public TypeParameter (string name, Constraints constraints, Location loc)
+               public TypeParameter (TypeContainer parent, string name,
+                                     Constraints constraints, Location loc)
+                       : base (parent, new MemberName (name), null, loc)
                {
                        this.name = name;
                        this.constraints = constraints;
                        this.loc = loc;
                }
 
-               public string Name {
-                       get {
-                               return name;
-                       }
-               }
-
-               public Location Location {
-                       get {
-                               return loc;
-                       }
-               }
-
                public Constraints Constraints {
                        get {
                                return constraints;
@@ -542,10 +532,42 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               //
+               // MemberContainer
+               //
+
+               public override bool Define ()
+               {
+                       return true;
+               }
+
+               protected override void VerifyObsoleteAttribute ()
+               { }
+
+               public override void ApplyAttributeBuilder (Attribute a,
+                                                           CustomAttributeBuilder cb)
+               { }
+
+               public override AttributeTargets AttributeTargets {
+                       get {
+                               return (AttributeTargets) 0;
+                       }
+               }
+
+               public override string[] ValidAttributeTargets {
+                       get {
+                               return new string [0];
+                       }
+               }
+
                //
                // IMemberContainer
                //
 
+               string IMemberContainer.Name {
+                       get { return Name; }
+               }
+
                IMemberContainer IMemberContainer.ParentContainer {
                        get { return null; }
                }
index bcf063369782967a30c8cfdeaebe8436d01f1729..998073f76543f371ae72ac03900262b42fef5fba 100644 (file)
@@ -629,7 +629,7 @@ namespace Mono.CSharp {
                                        new FieldExpression (current_field), Location),
                                Location));
 
-                       Accessor getter = new Accessor (get_block, null);
+                       Accessor getter = new Accessor (get_block, null, Location);
 
                        Property current = new Property (
                                this, type, 0, false, name, null, getter, null, Location);
index 39c2648bcc895c3c7c1671a521093c2a653e42d6..0446b8ab0add2d4de7bb43707787912a61921534 100755 (executable)
@@ -22,6 +22,18 @@ using System;
 using System.Reflection;
 using System.Reflection.Emit;
 
+//
+// I put System.Null just so we do not have to special case it on 
+// TypeManager.CSharpName
+//
+namespace System {
+       //
+       // Represents the Null Type, just used as a placeholder for the type in NullLiteral
+       //
+       public class Null {
+       }
+}
+       
 namespace Mono.CSharp {
 
        public class NullLiteral : Constant {
@@ -49,7 +61,7 @@ namespace Mono.CSharp {
 
                public override Expression DoResolve (EmitContext ec)
                {
-                       type = TypeManager.object_type;
+                       type = typeof (System.Null); 
                        return this;
                }
 
index 11c5a7ec736053e066a75455da764b9949e81fb4..bdc2eb4f4b0e67f0ac6fe59bc99e128d796875ed 100755 (executable)
@@ -260,18 +260,24 @@ namespace Mono.CSharp {
                                if (resolved != null)
                                        return resolved;
 
-                               NamespaceEntry curr_ns = NamespaceEntry;
-
                                //
                                // GENERICS: Cope with the expression and not with the string
                                // this will fail with `using A = Stack<int>'
                                //
                                
                                string alias = Alias.GetTypeName ();
+
+                               // According to section 16.3.1, the namespace-or-type-name is resolved
+                               // as if the immediately containing namespace body has no using-directives.
+                               resolved = NamespaceEntry.Lookup (
+                                       null, alias, Alias.CountTypeArguments, true, false, Location);
+
+                               NamespaceEntry curr_ns = NamespaceEntry.Parent;
+
                                while ((curr_ns != null) && (resolved == null)) {
                                        resolved = curr_ns.Lookup (
                                                null, alias, Alias.CountTypeArguments,
-                                               false, Location);
+                                               false, false, Location);
 
                                        if (resolved == null)
                                                curr_ns = curr_ns.Parent;
@@ -414,7 +420,7 @@ namespace Mono.CSharp {
                }
 
                public IAlias Lookup (DeclSpace ds, string name, int num_type_params,
-                                     bool silent, Location loc)
+                                     bool ignore_using, bool silent, Location loc)
                {
                        IAlias o;
                        Namespace ns;
@@ -427,7 +433,7 @@ namespace Mono.CSharp {
                                string first = name.Substring (0, pos);
                                string last = name.Substring (pos + 1);
 
-                               o = Lookup (ds, first, 0, silent, loc);
+                               o = Lookup (ds, first, 0, ignore_using, silent, loc);
                                if (o == null)
                                        return null;
 
@@ -451,6 +457,9 @@ namespace Mono.CSharp {
                        if (o != null)
                                return o;
 
+                       if (ignore_using)
+                               return null;
+
                        //
                        // Check aliases.
                        //
index 232155c0fdd392391185b29468b7fa4c8f59f335..fd3446b0f2c04423f10c6d88d42158118ab64744 100755 (executable)
@@ -150,6 +150,15 @@ namespace Mono.CSharp {
                        TypeName = type;
                }
 
+               public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+               {
+                       if (a.Type == TypeManager.param_array_type) {
+                               Report.Error (674, a.Location, "Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead");
+                               return;
+                       }
+                       base.ApplyAttributeBuilder (a, cb);
+               }
+
                // <summary>
                //   Resolve is used in method definitions
                // </summary>
index fc7bb7df7edb5f373d6b001eb9834127f8dea460..3e1721bba47524f4233f59512b00a06719987a59 100644 (file)
@@ -60,24 +60,139 @@ namespace Mono.CSharp {
                //
                static Hashtable warning_ignore_table;
 
+               static Hashtable warning_regions_table;
+
                /// <summary>
                /// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
                /// </summary>
                static StringCollection related_symbols = new StringCollection ();
-               
-               static void Check (int code)
-               {
-                       if (code == expected_error){
+
+               abstract class AbstractMessage {
+
+                       static void Check (int code)
+                       {
+                               if (code == expected_error) {
+                                       Environment.Exit (0);
+                               }
+                       }
+
+                       public abstract string MessageType { get; }
+
+                       public virtual void Print (int code, string location, string text)
+                       {
+                               if (code < 0)
+                                       code = 8000-code;
+
+                               StringBuilder msg = new StringBuilder ();
+                               if (location.Length != 0) {
+                                       msg.Append (location);
+                                       msg.Append (' ');
+                               }
+                               msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
+                               Console.WriteLine (msg.ToString ());
+
+                               foreach (string s in related_symbols) {
+                                       Console.WriteLine (String.Concat (s, MessageType, ')'));
+                               }
+                               related_symbols.Clear ();
+
+                               if (Stacktrace)
+                                       Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
+
                                if (Fatal)
-                                       throw new Exception ();
-                               
-                               Environment.Exit (0);
+                                       throw new Exception (text);
+
+                               Check (code);
+                       }
+
+                       public virtual void Print (int code, Location location, string text)
+                       {
+                               if (location.Equals (Location.Null)) {
+                                       Print (code, "", text);
+                                       return;
+                               }
+                               Print (code, String.Format ("{0}({1})", location.Name, location.Row), text);
                        }
                }
-               
-               public static void FeatureIsNotStandardized (string feature)
+
+               sealed class WarningMessage: AbstractMessage {
+                       Location loc = Location.Null;
+                       readonly int Level;
+
+                       public WarningMessage ():
+                               this (-1) {}
+
+                       public WarningMessage (int level)
+                       {
+                               Level = level;
+                       }
+
+                       bool IsEnabled (int code)
+                       {
+                               if (RootContext.WarningLevel < Level)
+                                       return false;
+
+                               if (warning_ignore_table != null) {
+                                       if (warning_ignore_table.Contains (code)) {
+                                               return false;
+                                       }
+                               }
+
+                               if (warning_regions_table == null || loc.Equals (Location.Null))
+                                       return true;
+
+                               WarningRegions regions = (WarningRegions)warning_regions_table [loc.Name];
+                               return regions.IsWarningEnabled (code, loc.Row);
+                       }
+
+                       public override void Print(int code, string location, string text)
+                       {
+                               if (!IsEnabled (code)) {
+                                       related_symbols.Clear ();
+                                       return;
+                               }
+
+                               if (WarningsAreErrors) {
+                                       new ErrorMessage ().Print (code, location, text);
+                                       return;
+                               }
+
+                               Warnings++;
+                               base.Print (code, location, text);
+                       }
+
+                       public override void Print(int code, Location location, string text)
+                       {
+                               loc = location;
+                               base.Print (code, location, text);
+                       }
+
+                       public override string MessageType {
+                               get {
+                                       return "warning";
+                               }
+                       }
+               }
+
+               sealed class ErrorMessage: AbstractMessage {
+
+                       public override void Print(int code, string location, string text)
+                       {
+                               Errors++;
+                               base.Print (code, location, text);
+                       }
+
+                       public override string MessageType {
+                               get {
+                                       return "error";
+                               }
+                       }
+
+               }
+
+               public static void FeatureIsNotStandardized (Location loc, string feature)
                {
-                       Report.Error (1644, "Feature '{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature);
+                       Report.Error (1644, loc, "Feature '{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature);
                }
                
                public static string FriendlyStackTrace (Exception e)
@@ -120,20 +235,34 @@ namespace Mono.CSharp {
        
                        return sb.ToString ();
                }
+
+               // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+               // IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE
+               public static bool IsValidWarning (int code)
+               {
+                       int[] all_warnings = new int[] { 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
+                                                                                        659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
+                                                                                  };
+                       foreach (int i in all_warnings) {
+                               if (i == code)
+                                       return true;
+                       }
+                       return false;
+               }
                
                static public void LocationOfPreviousError (Location loc)
                {
                        Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
-               }                
-
+               }    
+        
                static public void RuntimeMissingSupport (string feature) 
                {
                        Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.");
                }
 
                /// <summary>
-                /// In most error cases is very useful to have information about symbol that caused the error.
-                /// Call this method before you call Report.Error when it makes sense.
+               /// In most error cases is very useful to have information about symbol that caused the error.
+               /// Call this method before you call Report.Error when it makes sense.
                /// </summary>
                static public void SymbolRelatedToPreviousError (Location loc, string symbol)
                {
@@ -142,27 +271,19 @@ namespace Mono.CSharp {
 
                static public void SymbolRelatedToPreviousError (MemberInfo mi)
                {
-                       Type decl = mi.DeclaringType;
-                       if (decl.IsGenericInstance)
-                               decl = decl.GetGenericTypeDefinition ();
-
-                       TypeContainer temp_ds = TypeManager.LookupTypeContainer (decl);
+                       TypeContainer temp_ds = TypeManager.LookupTypeContainer (mi.DeclaringType);
                        if (temp_ds == null) {
-                               SymbolRelatedToPreviousError (decl.Assembly.Location, TypeManager.GetFullNameSignature (mi));
+                               SymbolRelatedToPreviousError (mi.DeclaringType.Assembly.Location, TypeManager.GetFullNameSignature (mi));
                        } else {
                                if (mi is MethodBase) {
-                                       MethodBase mb = (MethodBase) mi;
-                                       if (mb.Mono_IsInflatedMethod)
-                                               mb = mb.GetGenericMethodDefinition ();
-
-                                       IMethodData md = TypeManager.GetMethod (mb);
+                                       IMethodData md = TypeManager.GetMethod ((MethodBase)mi);
                                        SymbolRelatedToPreviousError (md.Location, md.GetSignatureForError (temp_ds));
                                        return;
                                }
 
                                string name = String.Concat (temp_ds.Name, ".", mi.Name);
-                               MemberCore mc = temp_ds.GetDefinition (name) as MemberCore;
-                               SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
+                               MemberCore mc = temp_ds.GetDefinition (name);
+                               SymbolRelatedToPreviousError (mc);
                        }
                }
 
@@ -175,7 +296,7 @@ namespace Mono.CSharp {
                {
                        DeclSpace temp_ds = TypeManager.LookupDeclSpace (type);
                        if (temp_ds == null)
-                       SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
+                               SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
                        else 
                                SymbolRelatedToPreviousError (temp_ds.Location, TypeManager.CSharpName (type));
                }
@@ -185,89 +306,42 @@ namespace Mono.CSharp {
                        related_symbols.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
                }
 
-               static public void RealError (string msg)
+               public static WarningRegions RegisterWarningRegion (Location location)
                {
-                       Errors++;
-                       Console.WriteLine (msg);
+                       if (warning_regions_table == null)
+                               warning_regions_table = new Hashtable ();
 
-                       foreach (string s in related_symbols)
-                               Console.WriteLine (s + "error)");
-                       related_symbols.Clear ();
-
-                       if (Stacktrace)
-                               Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
-                       
-                       if (Fatal)
-                               throw new Exception (msg);
+                       WarningRegions regions = (WarningRegions)warning_regions_table [location.Name];
+                       if (regions == null) {
+                               regions = new WarningRegions ();
+                               warning_regions_table.Add (location.Name, regions);
+                       }
+                       return regions;
                }
 
-
-               static public void Error (int code, Location l, string text)
+               static public void Warning (int code, int level, Location loc, string format, params object[] args)
                {
-                       if (code < 0)
-                               code = 8000-code;
-                       
-                       string msg = String.Format (
-                               "{0}({1}) error CS{2:0000}: {3}", l.Name, l.Row, code, text);
-//                             "{0}({1}) error CS{2}: {3}", l.Name, l.Row, code, text);
-                       
-                       RealError (msg);
-                       Check (code);
+                       WarningMessage w = new WarningMessage (level);
+                       w.Print (code, loc, String.Format (format, args));
                }
 
-               static public void Warning (int code, Location l, string text)
+               static public void Warning (int code, Location loc, string format, params object[] args)
                {
-                       if (code < 0)
-                               code = 8000-code;
-                       
-                       if (warning_ignore_table != null){
-                               if (warning_ignore_table.Contains (code)) {
-                                       related_symbols.Clear ();
-                                       return;
-                               }
-                       }
-                       
-                       if (WarningsAreErrors)
-                               Error (code, l, text);
-                       else {
-                               string row;
-                               
-                               if (Location.IsNull (l))
-                                       row = "";
-                               else
-                                       row = l.Row.ToString ();
-                               
-                               Console.WriteLine (String.Format (
-                                       "{0}({1}) warning CS{2:0000}: {3}",
-//                                     "{0}({1}) warning CS{2}: {3}",
-                                       l.Name,  row, code, text));
-                               Warnings++;
-
-                               foreach (string s in related_symbols)
-                                       Console.WriteLine (s + "warning)");
-                               related_symbols.Clear ();
-
-                               Check (code);
-
-                               if (Stacktrace)
-                                       Console.WriteLine (new StackTrace ().ToString ());
-                       }
+                       WarningMessage w = new WarningMessage ();
+                       w.Print (code, loc, String.Format (format, args));
                }
-               
-               static public void Warning (int code, string text)
+
+               static public void Warning (int code, string format, params object[] args)
                {
-                       Warning (code, Location.Null, text);
+                       Warning (code, Location.Null, String.Format (format, args));
                }
 
-               static public void Error (int code, string text)
+               /// <summary>
+               /// Did you test your WarningLevel, that you use this method
+               /// </summary>
+               static public void Warning (int code, string text)
                {
-                       if (code < 0)
-                               code = 8000-code;
-                       
-                       string msg = String.Format ("error CS{0:0000}: {1}", code, text);
-                       
-                       RealError (msg);
-                       Check (code);
+                       Warning (code, Location.Null, text);
                }
 
                static public void Error (int code, string format, params object[] args)
@@ -277,17 +351,8 @@ namespace Mono.CSharp {
 
                static public void Error (int code, Location loc, string format, params object[] args)
                {
-                       Error (code, loc, String.Format (format, args));
-               }
-
-               static public void Warning (int code, string format, params object[] args)
-               {
-                       Warning (code, Location.Null, String.Format (format, args));
-               }
-
-               static public void Warning (int code, Location loc, string format, params object[] args)
-               {
-                       Warning (code, loc, String.Format (format, args));
+                       ErrorMessage e = new ErrorMessage ();
+                       e.Print (code, loc, String.Format (format, args));
                }
 
                static public void SetIgnoreWarning (int code)
@@ -298,14 +363,14 @@ namespace Mono.CSharp {
                        warning_ignore_table [code] = true;
                }
                
-                static public int ExpectedError {
-                        set {
-                                expected_error = value;
-                        }
-                        get {
-                                return expected_error;
-                        }
-                }
+               static public int ExpectedError {
+                       set {
+                               expected_error = value;
+                       }
+                       get {
+                               return expected_error;
+                       }
+               }
 
                public static int DebugFlags = 0;
 
@@ -336,8 +401,6 @@ namespace Mono.CSharp {
                                                sb.Append ("null");
                                        else if (arg is ICollection)
                                                sb.Append (PrintCollection ((ICollection) arg));
-                                       else if (arg is IntPtr)
-                                               sb.Append (String.Format ("IntPtr(0x{0:x})", ((IntPtr) arg).ToInt32 ()));
                                        else
                                                sb.Append (arg);
                                }
@@ -463,9 +526,121 @@ namespace Mono.CSharp {
                        : base (message)
                {
                }
+       }
+
+       /// <summary>
+       /// Handles #pragma warning
+       /// </summary>
+       public class WarningRegions {
+
+               abstract class PragmaCmd
+               {
+                       public int Line;
+
+                       protected PragmaCmd (int line)
+                       {
+                               Line = line;
+                       }
+
+                       public abstract bool IsEnabled (int code, bool previous);
+               }
+               
+               class Disable: PragmaCmd
+               {
+                       int code;
+                       public Disable (int line, int code)
+                               : base (line)
+                       {
+                               this.code = code;
+                       }
+
+                       public override bool IsEnabled (int code, bool previous)
+                       {
+                               return this.code == code ? false : previous;
+                       }
+               }
+
+               class DisableAll: PragmaCmd
+               {
+                       public DisableAll (int line)
+                               : base (line) {}
+
+                       public override bool IsEnabled(int code, bool previous)
+                       {
+                               return false;
+                       }
+               }
+
+               class Enable: PragmaCmd
+               {
+                       int code;
+                       public Enable (int line, int code)
+                               : base (line)
+                       {
+                               this.code = code;
+                       }
+
+                       public override bool IsEnabled(int code, bool previous)
+                       {
+                               return this.code == code ? true : previous;
+                       }
+               }
+
+               class EnableAll: PragmaCmd
+               {
+                       public EnableAll (int line)
+                               : base (line) {}
+
+                       public override bool IsEnabled(int code, bool previous)
+                       {
+                               return true;
+                       }
+               }
+
+
+               ArrayList regions = new ArrayList ();
+
+               public void WarningDisable (int line)
+               {
+                       regions.Add (new DisableAll (line));
+               }
 
-               public InternalErrorException (string format, params object[] args)
-                       : this (String.Format (format, args))
-               { }
+               public void WarningDisable (Location location, int code)
+               {
+                       if (CheckWarningCode (code, location))
+                               regions.Add (new Disable (location.Row, code));
+               }
+
+               public void WarningEnable (int line)
+               {
+                       regions.Add (new EnableAll (line));
+               }
+
+               public void WarningEnable (Location location, int code)
+               {
+                       if (CheckWarningCode (code, location))
+                               regions.Add (new Enable (location.Row, code));
+               }
+
+               public bool IsWarningEnabled (int code, int src_line)
+               {
+                       bool result = true;
+                       foreach (PragmaCmd pragma in regions) {
+                               if (src_line < pragma.Line)
+                                       break;
+
+                               result = pragma.IsEnabled (code, result);
+                       }
+                       return result;
+               }
+
+               bool CheckWarningCode (int code, Location loc)
+               {
+                       if (Report.IsValidWarning (code))
+                               return true;
+
+                       Report.Warning (1691, 1, loc, "'{0}' is not a valid warning number", code);
+                       return false;
+               }
        }
 }
index ef89a3ef262d243ab835e1b10fc4596bade2169b..e30bfa3642a78e651d7fc1ec6d70f8cc580dee91 100755 (executable)
@@ -493,7 +493,7 @@ namespace Mono.CSharp {
                        // Try in the current namespace and all its implicit parents
                        //
                        for (NamespaceEntry ns = ds.NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
-                               IAlias result = ns.Lookup (ds, name, num_type_args, silent, loc);
+                               IAlias result = ns.Lookup (ds, name, num_type_args, false, silent, loc);
 
                                if (result == null)
                                        continue;
index c4492a6e3478b1c0580045eb15f52324466585de..00e763f5c5f6030a503f9ae461501d9208d72061 100755 (executable)
@@ -848,7 +848,7 @@ public class TypeManager {
                        @"^System\." +
                        @"(Int32|UInt32|Int16|UInt16|Int64|UInt64|" +
                        @"Single|Double|Char|Decimal|Byte|SByte|Object|" +
-                       @"Boolean|String|Void)" +
+                       @"Boolean|String|Void|Null)" +
                        @"(\W+|\b)", 
                        new MatchEvaluator (CSharpNameMatch));
        }       
@@ -963,7 +963,7 @@ public class TypeManager {
                        iparams = new ReflectionParameters (mb);
                
                // Is property
-               if (mb.IsSpecialName && iparams.Count == 0)
+               if (mb.IsSpecialName && iparams.Count == 0 && !mb.IsConstructor)
                        return GetFullNameSignature (mb);
                
                 for (int i = 0; i < iparams.Count; i++) {
@@ -2014,15 +2014,13 @@ public class TypeManager {
        ///   for anything which is dynamic, and we need this in a number of places,
        ///   we register this information here, and use it afterwards.
        /// </remarks>
-       static public bool RegisterMethod (MethodBase mb, InternalParameters ip, Type [] args)
+       static public void RegisterMethod (MethodBase mb, InternalParameters ip, Type [] args)
        {
                if (args == null)
                        args = NoTypes;
                                
                method_arguments.Add (mb, args);
                method_internal_params.Add (mb, ip);
-               
-               return true;
        }
        
        static public InternalParameters LookupParametersByBuilder (MethodBase mb)
@@ -2138,17 +2136,14 @@ public class TypeManager {
        
        static Hashtable events;
 
-       static public bool RegisterEvent (MyEventBuilder eb, MethodBase add, MethodBase remove)
+       static public void RegisterEvent (MyEventBuilder eb, MethodBase add, MethodBase remove)
        {
                if (events == null)
                        events = new Hashtable ();
 
-               if (events.Contains (eb))
-                       return false;
-
+               if (!events.Contains (eb)) {
                events.Add (eb, new Pair (add, remove));
-
-               return true;
+               }
        }
 
        static public MethodInfo GetAddMethod (EventInfo ei)