X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fdecl.cs;h=8d91613059a961981826e760e136194f2d430440;hb=083d1cfe2c89639d2ad660cec019de89c77b6f10;hp=62ea805dabc82a04dea00b8075ba08388a5f5a6e;hpb=56751f1743ac607de97aaf901e94aaf69d8e1986;p=mono.git diff --git a/mcs/mcs/decl.cs b/mcs/mcs/decl.cs index 62ea805dabc..8d91613059a 100644 --- a/mcs/mcs/decl.cs +++ b/mcs/mcs/decl.cs @@ -8,11 +8,13 @@ // // Copyright 2001 Ximian, Inc (http://www.ximian.com) // Copyright 2004-2008 Novell, Inc +// Copyright 2011 Xamarin Inc // // using System; using System.Collections.Generic; +using System.Diagnostics; #if NET_2_1 using XmlElement = System.Object; @@ -33,6 +35,7 @@ namespace Mono.CSharp { // // Better name would be DottenName // + [DebuggerDisplay ("{GetSignatureForError()}")] public class MemberName { public readonly string Name; public TypeArguments TypeArguments; @@ -684,9 +687,9 @@ namespace Mono.CSharp { return true; } - public virtual IList LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope) + public virtual ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity) { - return Parent.LookupExtensionMethod (extensionType, name, arity, ref scope); + return Parent.LookupExtensionMethod (extensionType, name, arity); } public virtual FullNamedExpression LookupNamespaceAlias (string name) @@ -694,9 +697,9 @@ namespace Mono.CSharp { return Parent.NamespaceEntry.LookupNamespaceAlias (name); } - public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104) + public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) { - return Parent.LookupNamespaceOrType (name, arity, loc, ignore_cs0104); + return Parent.LookupNamespaceOrType (name, arity, mode, loc); } /// @@ -807,34 +810,31 @@ namespace Mono.CSharp { return true; } - // - // Raised (and passed an XmlElement that contains the comment) - // when GenerateDocComment is writing documentation expectedly. - // - internal virtual void OnGenerateDocComment (XmlElement intermediateNode) - { - } - // // Returns a string that represents the signature for this // member which should be used in XML documentation. // - public virtual string GetDocCommentName (DeclSpace ds) - { - if (ds == null || this is DeclSpace) - return DocCommentHeader + Name; - else - return String.Concat (DocCommentHeader, ds.Name, ".", Name); - } + public abstract string GetSignatureForDocumentation (); // // Generates xml doc comments (if any), and if required, // handle warning report. // - internal virtual void GenerateDocComment (DeclSpace ds) + internal virtual void GenerateDocComment (DocumentationBuilder builder) { + if (DocComment == null) { + if (IsExposedFromAssembly ()) { + Constructor c = this as Constructor; + if (c == null || !c.IsDefault ()) + Report.Warning (1591, 4, Location, + "Missing XML comment for publicly visible type or member `{0}'", GetSignatureForError ()); + } + + return; + } + try { - DocUtil.GenerateDocComment (this, ds, Report); + builder.GenerateDocumentationForMember (this); } catch (Exception e) { throw new InternalErrorException (this, e); } @@ -858,10 +858,6 @@ namespace Mono.CSharp { get { return null; } } - public virtual bool HasUnresolvedConstraints { - get { return false; } - } - public bool IsObsolete { get { if (GetAttributeObsolete () != null) @@ -905,6 +901,7 @@ namespace Mono.CSharp { MissingDependency_Undetected = 1 << 4, MissingDependency = 1 << 5, HasDynamicElement = 1 << 6, + ConstraintsChecked = 1 << 7, IsAccessor = 1 << 9, // Method is an accessor IsGeneric = 1 << 10, // Member contains type arguments @@ -914,10 +911,12 @@ namespace Mono.CSharp { PendingMemberCacheMembers = 1 << 14, PendingBaseTypeInflate = 1 << 15, InterfacesExpanded = 1 << 16, - IsNotRealProperty = 1 << 17, + IsNotCSharpCompatible = 1 << 17, SpecialRuntimeType = 1 << 18, InflatedExpressionType = 1 << 19, InflatedNullableType = 1 << 20, + GenericIterateInterface = 1 << 21, + GenericTask = 1 << 22 } protected Modifiers modifiers; @@ -1005,6 +1004,18 @@ namespace Mono.CSharp { } } + // + // Returns true for imported members which are not compatible with C# language + // + public bool IsNotCSharpCompatible { + get { + return (state & StateFlags.IsNotCSharpCompatible) != 0; + } + set { + state = value ? state | StateFlags.IsNotCSharpCompatible : state & ~StateFlags.IsNotCSharpCompatible; + } + } + public bool IsPrivate { get { return (modifiers & Modifiers.PRIVATE) != 0; } } @@ -1073,6 +1084,11 @@ namespace Mono.CSharp { return cls == false; } + public virtual string GetSignatureForDocumentation () + { + return DeclaringType.GetSignatureForDocumentation () + "." + Name; + } + public virtual string GetSignatureForError () { var bf = MemberDefinition as Property.BackingField; @@ -1093,32 +1109,32 @@ namespace Mono.CSharp { } // - // Is this member accessible from invocationType + // Is this member accessible from invocation context // - public bool IsAccessible (TypeSpec invocationType) + public bool IsAccessible (IMemberContext ctx) { var ma = Modifiers & Modifiers.AccessibilityMask; if (ma == Modifiers.PUBLIC) return true; var parentType = /* this as TypeSpec ?? */ DeclaringType; + var ctype = ctx.CurrentType; - // It's null for module context - if (invocationType == null) - invocationType = InternalType.FakeInternalType; - - // - // If only accessible to the current class or children - // - if (ma == Modifiers.PRIVATE) - return invocationType.MemberDefinition == parentType.MemberDefinition || - TypeManager.IsNestedChildOf (invocationType, parentType.MemberDefinition); + if (ma == Modifiers.PRIVATE) { + if (ctype == null) + return false; + // + // It's only accessible to the current class or children + // + if (parentType.MemberDefinition == ctype.MemberDefinition) + return true; + + return TypeManager.IsNestedChildOf (ctype, parentType.MemberDefinition); + } if ((ma & Modifiers.INTERNAL) != 0) { bool b; - var assembly = invocationType == InternalType.FakeInternalType ? - RootContext.ToplevelTypes.DeclaringAssembly : - invocationType.MemberDefinition.DeclaringAssembly; + var assembly = ctype == null ? ctx.Module.DeclaringAssembly : ctype.MemberDefinition.DeclaringAssembly; if (parentType == null) { b = ((ITypeDefinition) MemberDefinition).IsInternalAsPublic (assembly); @@ -1130,11 +1146,18 @@ namespace Mono.CSharp { return b; } - // PROTECTED - if (!TypeManager.IsNestedFamilyAccessible (invocationType, parentType)) - return false; + // + // Checks whether `ctype' is a subclass or nested child of `parentType'. + // + while (ctype != null) { + if (TypeManager.IsFamilyAccessible (ctype, parentType)) + return true; - return true; + // Handle nested types. + ctype = ctype.DeclaringType; // TODO: Untested ??? + } + + return false; } // @@ -1164,7 +1187,7 @@ namespace Mono.CSharp { return (state & StateFlags.CLSCompliant) != 0; } - public bool IsConditionallyExcluded (Location loc) + public bool IsConditionallyExcluded (CompilerContext ctx, Location loc) { if ((Kind & (MemberKind.Class | MemberKind.Method)) == 0) return false; @@ -1174,7 +1197,7 @@ namespace Mono.CSharp { return false; foreach (var condition in conditions) { - if (loc.CompilationUnit.IsConditionalDefined (condition)) + if (loc.CompilationUnit.IsConditionalDefined (ctx, condition)) return false; } @@ -1229,7 +1252,7 @@ namespace Mono.CSharp { // This is the namespace in which this typecontainer // was declared. We use this to resolve names. // - public NamespaceEntry NamespaceEntry; + public NamespaceContainer NamespaceEntry; public readonly string Basename; @@ -1256,9 +1279,9 @@ namespace Mono.CSharp { } } - static string[] attribute_targets = new string [] { "type" }; + static readonly string[] attribute_targets = new string [] { "type" }; - public DeclSpace (NamespaceEntry ns, DeclSpace parent, MemberName name, + public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name, Attributes attrs) : base (parent, name, attrs) { @@ -1301,17 +1324,13 @@ namespace Mono.CSharp { return false; } - if (this is ModuleContainer) { - Report.Error (101, symbol.Location, - "The namespace `{0}' already contains a definition for `{1}'", - ((DeclSpace)symbol).NamespaceEntry.GetSignatureForError (), symbol.MemberName.Name); - } else if (symbol is TypeParameter) { + if (symbol is TypeParameter) { Report.Error (692, symbol.Location, "Duplicate type parameter `{0}'", symbol.GetSignatureForError ()); } else { Report.Error (102, symbol.Location, - "The type `{0}' already contains a definition for `{1}'", - GetSignatureForError (), symbol.MemberName.Name); + "The type `{0}' already contains a definition for `{1}'", + GetSignatureForError (), name); } return false; @@ -1362,6 +1381,11 @@ namespace Mono.CSharp { type.GetSignatureForError ()); } + public override string GetSignatureForDocumentation () + { + return Name; + } + public override string GetSignatureForError () { return MemberName.GetSignatureForError ();