コード例 #1
0
ファイル: TooltipInfoGen.cs プロジェクト: DinrusGroup/Mono-D
		static void CreateTooltipBody(TooltipMarkupGen markupGen, DNode dn, TooltipInformation tti)
		{
			string summary;
			Dictionary<string,string> categories;

			markupGen.GenToolTipBody (dn, out summary, out categories);

			tti.SummaryMarkup = summary;
			if (categories != null)
				foreach (var kv in categories)
					tti.AddCategory (kv.Key, kv.Value);
		}
コード例 #2
0
ファイル: TooltipInfoGen.cs プロジェクト: DinrusGroup/Mono-D
		public static TooltipInformation Create(DNode dn, ColorScheme st, bool templateParamCompletion = false, int currentMethodParam = -1)
		{
			var markupGen = new TooltipMarkupGen (st);

			var tti = new TooltipInformation { 
				SignatureMarkup = markupGen.GenTooltipSignature(dn, templateParamCompletion, currentMethodParam)
			};

			CreateTooltipBody (markupGen, dn, tti);

			return tti;
		}
コード例 #3
0
        /// <summary>
        /// Returns true if both template instance identifiers are matching each other or if the parameterSpeci
        /// </summary>
        bool CheckForTixIdentifierEquality(
			DNode[] expectedTemplateTypes, 
			INode controllee)
        {
            /*
             * Note: This implementation is not 100% correct or defined in the D spec:
             * class A(T){}
             * class A(S:string) {}
             * class C(U: A!W, W){ W item; }
             *
             * C!(A!int) -- is possible
             * C!(A!string) -- is not allowed somehow - because there are probably two 'matching' template types.
             * (dmd version 2.060, August 2012)
             */
            return expectedTemplateTypes != null && expectedTemplateTypes.Contains(controllee);
        }
コード例 #4
0
        public string GenTooltipSignature(DNode dn, bool templateParamCompletion = false, 
			int currentMethodParam = -1, ITypeDeclaration baseType=null, DeducedTypeDictionary deducedType = null)
        {
            var sb = new StringBuilder();

            if (dn is DMethod)
                S (dn as DMethod, sb, templateParamCompletion, currentMethodParam, baseType, deducedType);
            else if (dn is DModule) {
                sb.Append ("<i>(Module)</i> ").Append ((dn as DModule).ModuleName);
            } else if (dn is DClassLike)
                S (dn as DClassLike, sb, deducedType);
            else if(dn != null)
                AttributesTypeAndName (dn, sb, baseType, -1, deducedType);

            return sb.ToString ();
        }
コード例 #5
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="summary">The overall summary for the given node</param>
		/// <param name="categories">Keys: Category name, Values: Categories' contents</param>
		public void GenToolTipBody(DNode n, out string summary, out Dictionary<string, string> categories)
		{
			categories = null;
			summary = null;

			var desc = n.Description;
			if (!string.IsNullOrWhiteSpace(desc))
			{
				categories = new Dictionary<string, string>();

				var match = ddocSectionRegex.Match(desc);

				if (!match.Success)
				{
					summary = HandleSummary(desc);
					return;
				}

				if (match.Index < 1)
					summary = null;
				else
					summary = HandleSummary (desc.Substring (0, match.Index - 1));

				int k = 0;
				while ((k = match.Index + match.Length) < desc.Length)
				{
					var nextMatch = ddocSectionRegex.Match(desc, k);
					if (nextMatch.Success)
					{
						AssignToCategories(categories, match.Groups["cat"].Value, desc.Substring(k, nextMatch.Index - k));
						match = nextMatch;
					}
					else
						break;
				}

				// Handle last match
				AssignToCategories(categories, match.Groups["cat"].Value, desc.Substring(k));
			}
		}
コード例 #6
0
 public TemplateTypeParameter(int nameHash, CodeLocation nameLoc, DNode parent) : base(nameHash, nameLoc, parent)
 {
 }
コード例 #7
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        void TemplateParameterList(DNode dn)
        {
            if (!Expect(OpenParenthesis))
            {
                SynErr(OpenParenthesis, "Template parameter list expected");
                dn.TemplateParameters = new TemplateParameter[0];
                return;
            }

            if (laKind == (CloseParenthesis))
            {
                Step();
                return;
            }

            var ret = new List<TemplateParameter>();

            bool init = true;
            while (init || laKind == (Comma))
            {
                if (init) init = false;
                else Step();

                if (laKind == CloseParenthesis)
                    break;

                ret.Add(TemplateParameter(dn));
            }

            Expect(CloseParenthesis);

            dn.TemplateParameters = ret.ToArray();
        }
コード例 #8
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
			ReadOnlyCollection<TemplateParameterSymbol> deducedTypes = null)
            : base(member, memberType, deducedTypes, td)
        {
        }
コード例 #9
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public StaticProperty(DNode n, AbstractType bt, StaticProperties.ValueGetterHandler valueGetter)
     : base(n, bt, null)
 {
     this.n = n;
     this.ValueGetter = valueGetter;
 }
コード例 #10
0
ファイル: Parser.cs プロジェクト: gavin-norman/Mono-D
        void ApplyAttributes(DNode n)
        {
            foreach (var attr in BlockAttributes.ToArray())
                n.Attributes.Add(attr);

            while (DeclarationAttributes.Count > 0)
            {
                var attr = DeclarationAttributes.Pop();

                // If accessor already in attribute array, remove it
                if (DTokens.VisModifiers[attr.Token])
                    DAttribute.CleanupAccessorAttributes(n.Attributes);

                if (attr.IsProperty || !DAttribute.ContainsAttribute(n.Attributes.ToArray(),attr.Token))
                    n.Attributes.Add(attr);
            }
        }
コード例 #11
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public UserDefinedType(DNode Node, AbstractType baseType, ReadOnlyCollection<TemplateParameterSymbol> deducedTypes, ISyntaxRegion td)
     : base(Node, baseType, deducedTypes, td)
 {
 }
コード例 #12
0
        private static bool DeduceParams(IEnumerable<ISemantic> givenTemplateArguments, 
			bool isMethodCall, 
			ResolutionContext ctxt, 
			DSymbol overload, 
			DNode tplNode, 
			DeducedTypeDictionary deducedTypes)
        {
            bool isLegitOverload = true;

            var paramEnum = tplNode.TemplateParameters.GetEnumerator();

            var args = givenTemplateArguments ?? new List<ISemantic> ();

            var argEnum = args.GetEnumerator();
            foreach (var expectedParam in tplNode.TemplateParameters)
                if (!DeduceParam(ctxt, overload, deducedTypes, argEnum, expectedParam))
                {
                    isLegitOverload = false;
                    break; // Don't check further params if mismatch has been found
                }

            if (!isMethodCall && argEnum.MoveNext())
            {
                // There are too many arguments passed - discard this overload
                isLegitOverload = false;
            }
            return isLegitOverload;
        }
コード例 #13
0
            static bool TryCompareNodeEquality(DNode orig, DNode copy)
            {
                var dm1 = orig as DMethod;
                var dm2 = copy as DMethod;
                if(dm1 != null && dm2 != null)
                {
                    if(dm1.Parameters.Count == dm2.Parameters.Count)
                        return true;
                    // TODO: Don't check parameter details for now
                    return false;
                }

                return true;
            }
コード例 #14
0
			public override void VisitDNode(DNode n)
			{
				if (n.Attributes != null && caret >= n.Location && caret <= n.EndLocation)
				{
					foreach (var attr in n.Attributes)
						if (attr is DeclarationCondition)
							l.Add(((DeclarationCondition)attr));
				}
			}
コード例 #15
0
ファイル: ParsedDModule.cs プロジェクト: nazriel/Mono-D
 /// <summary>
 /// Converts D template parameters to Dom type parameters
 /// </summary>
 public static IEnumerable<ITypeParameter> GetTypeParameters(DNode n)
 {
     if (n.TemplateParameters != null)
         foreach (var tpar in n.TemplateParameters)
             yield return new TypeParameter(tpar.Name); //TODO: Constraints'n'Stuff
 }
コード例 #16
0
 public TemplateThisParameter(TemplateParameter followParam, DNode parent)
     : base(followParam != null ? followParam.Name : string.Empty,
            followParam != null ? followParam.NameLocation : new CodeLocation(), parent)
 {
     FollowParameter = followParam;
 }
コード例 #17
0
 public TemplateAliasParameter(int name, CodeLocation nameLoc, DNode parent) : base(name, nameLoc, parent)
 {
 }
コード例 #18
0
 protected TemplateParameter(int nameHash, CodeLocation nameLoc, DNode par)
 {
     NameHash     = nameHash;
     NameLocation = nameLoc;
     Parent       = par;
 }
コード例 #19
0
 protected TemplateParameter(string name, CodeLocation nameLoc, DNode par) : this(name != null ? name.GetHashCode() : 0, nameLoc, par)
 {
     Strings.Add(name);
 }
コード例 #20
0
 public TemplateTupleParameter(string name, CodeLocation nameLoc, DNode parent) : base(name, nameLoc, parent)
 {
 }
コード例 #21
0
ファイル: ParsedDModule.cs プロジェクト: nazriel/Mono-D
        public static Modifiers GetNodeModifiers(DNode dn)
        {
            Modifiers m = Modifiers.None;

            if (dn.ContainsAttribute(DTokens.Abstract)) m |= Modifiers.Abstract;
            if (dn.ContainsAttribute(DTokens.Const)) m |= Modifiers.Const;
            if (dn.ContainsAttribute(DTokens.Extern)) m |= Modifiers.Extern;
            if (dn.ContainsAttribute(DTokens.Package)) m |= Modifiers.Internal;
            if (dn.ContainsAttribute(DTokens.Override)) m |= Modifiers.Override;
            if (dn.ContainsAttribute(DTokens.Private)) m |= Modifiers.Private;
            if (dn.ContainsAttribute(DTokens.Protected)) m |= Modifiers.Protected;
            if (dn.ContainsAttribute(DTokens.Public)) m |= Modifiers.Public;
            if (dn.ContainsAttribute(DTokens.Final)) m |= Modifiers.Sealed;
            if (dn.ContainsAttribute(DTokens.Static)) m |= Modifiers.Static;
            if (dn.ContainsAttribute(DTokens.Volatile)) m |= Modifiers.Volatile;

            return m;
        }
コード例 #22
0
ファイル: DType.cs プロジェクト: gavin-norman/Mono-D
 public DSymbol(DNode Node, AbstractType BaseType, Dictionary<string, TemplateParameterSymbol> deducedTypes, ISyntaxRegion td)
     : base(BaseType, td)
 {
     if(deducedTypes!=null)
         this.DeducedTypes = new ReadOnlyCollection<KeyValuePair<string, TemplateParameterSymbol>>(deducedTypes.ToArray());
     this.Definition = Node;
 }
コード例 #23
0
ファイル: ParsedDModule.cs プロジェクト: nazriel/Mono-D
 public static IEnumerable<IAttribute> TransferAttributes(DNode n)
 {
     foreach (var attr in n.Attributes)
         yield return new DomAttribute() { Role = DomAttribute.Roles.Attribute, Name = DTokens.GetTokenString(attr.Token) };
 }
コード例 #24
0
ファイル: DType.cs プロジェクト: gavin-norman/Mono-D
        public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
			Dictionary<string, TemplateParameterSymbol> deducedTypes)
            : base(member, memberType, deducedTypes, td)
        {
        }
コード例 #25
0
            public override void VisitDNode(DNode n)
            {
                if (n.NameHash == 0 || n.NameHash == DTokens.IncompleteIdHash)
                    return;

                if(!secondRun)
                {
                    originalDeclarations.Add(n);
                    return;
                }

                foreach(var decl in originalDeclarations)
                {
                    if (decl.NameHash == n.NameHash &&
                        decl.GetType() == n.GetType() &&
                        TryCompareNodeEquality(decl as DNode, n))
                    {
                        n.NameHash = -1; // Don't even risk referencing issues and just hide parsed stuff
                        return;
                    }
                }
            }
コード例 #26
0
        public virtual void VisitDNode(DNode n)
        {
            if (n.TemplateParameters != null)
                foreach (var tp in n.TemplateParameters)
                    tp.Accept(this);

            if (n.TemplateConstraint != null)
                n.TemplateConstraint.Accept(this);

            if (n.Attributes != null && n.Attributes.Count != 0)
                foreach (var attr in n.Attributes)
                    attr.Accept(this);

            if (n.Type != null)
                n.Type.Accept(this);
        }
コード例 #27
0
ファイル: Parser.cs プロジェクト: EnergonV/D_Parser
 void ApplyAttributes(DNode n)
 {
     n.Attributes = GetCurrentAttributeSet();
 }
コード例 #28
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        bool Constraint(DNode dn)
        {
            if (laKind == If) {
                Step ();
                Expect (OpenParenthesis);

                dn.TemplateConstraint = Expression ();

                Expect (CloseParenthesis);

                return true;
            }
            return false;
        }
コード例 #29
0
ファイル: VDServer.cs プロジェクト: thedeemon/visuald
        private static void GetReferencesInModule(DModule ast, StringBuilder refs, DNode n, ResolutionContext ctxt)
        {
            var res = ReferencesFinder.SearchModuleForASTNodeReferences(ast, n, ctxt);

            int cnt = res.Count();
            foreach (var r in res)
            {
                var rfilename = ast.FileName;
                var rloc = r.Location;
                var ln = String.Format("{0},{1},{2},{3}:{4}\n", rloc.Line, rloc.Column - 1, rloc.Line, rloc.Column, rfilename);
                refs.Append(ln);
            }
        }
コード例 #30
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        /// <summary>
        /// Note:
        /// http://www.digitalmars.com/d/2.0/declaration.html#DeclaratorSuffix
        /// The definition of a sequence of declarator suffixes is buggy here! Theoretically template parameters can be declared without a surrounding ( and )!
        /// Also, more than one parameter sequences are possible!
        /// 
        /// TemplateParameterList[opt] Parameters MemberFunctionAttributes[opt]
        /// </summary>
        void DeclaratorSuffixes(DNode dn)
        {
            FunctionAttributes(ref dn.Attributes);

            while (laKind == (OpenSquareBracket))
            {
                Step();
                var ad = new ArrayDecl() { Location=t.Location,InnerDeclaration = dn.Type };

                if (laKind != (CloseSquareBracket))
                {
                    ad.ClampsEmpty = false;
                    ITypeDeclaration keyType=null;
                    Lexer.PushLookAheadBackup();
                    if (!IsAssignExpression())
                    {
                        var weakType = AllowWeakTypeParsing;
                        AllowWeakTypeParsing = true;

                        keyType= ad.KeyType = Type();

                        AllowWeakTypeParsing = weakType;
                    }
                    if (keyType == null || laKind != CloseSquareBracket)
                    {
                        Lexer.RestoreLookAheadBackup();
                        keyType = ad.KeyType = null;
                        ad.KeyExpression = AssignExpression();
                    }
                    else
                        Lexer.PopLookAheadBackup();
                }
                Expect(CloseSquareBracket);
                ad.EndLocation = t.EndLocation;
                dn.Type = ad;
            }

            if (laKind == (OpenParenthesis))
            {
                if (IsTemplateParameterList())
                {
                    TemplateParameterList(dn);
                }
                var dm = dn as DMethod;
                if(dm != null)
                    dm.Parameters = Parameters(dm);
            }

            FunctionAttributes(ref dn.Attributes);
        }
コード例 #31
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public DSymbol(DNode Node, AbstractType BaseType, IEnumerable<TemplateParameterSymbol> deducedTypes, ISyntaxRegion td)
            : base(BaseType, td)
        {
            if(deducedTypes!=null)
                this.DeducedTypes = new ReadOnlyCollection<TemplateParameterSymbol>(deducedTypes.ToArray());

            if (Node == null)
                throw new ArgumentNullException ("Node");

            this.definition = new WeakReference(Node);
            NameHash = Node.NameHash;
        }
コード例 #32
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
 void FunctionAttributes(DNode n)
 {
     FunctionAttributes(ref n.Attributes);
 }
コード例 #33
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
			IEnumerable<TemplateParameterSymbol> deducedTypes)
            : base(member, memberType, deducedTypes, td)
        {
        }
コード例 #34
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        /// <summary>
        /// Add some syntax possibilities here
        /// int (x);
        /// int(*foo);
        /// This way of declaring function pointers is deprecated
        /// </summary>
        void OldCStyleFunctionPointer(DNode ret, bool IsParam)
        {
            Step();
            //SynErr(OpenParenthesis,"C-style function pointers are deprecated. Use the function() syntax instead."); // Only deprecated in D2
            var cd = new DelegateDeclaration() as ITypeDeclaration;
            ret.Type = cd;
            var deleg = cd as DelegateDeclaration;

            /*
             * Parse all basictype2's that are following the initial '('
             */
            while (IsBasicType2())
            {
                var ttd = BasicType2();

                if (deleg.ReturnType == null)
                    deleg.ReturnType = ttd;
                else
                {
                    if(ttd!=null)
                        ttd.InnerDeclaration = deleg.ReturnType;
                    deleg.ReturnType = ttd;
                }
            }

            /*
             * Here can be an identifier with some optional DeclaratorSuffixes
             */
            if (laKind != (CloseParenthesis))
            {
                if (IsParam && laKind != (Identifier))
                {
                    /* If this Declarator is a parameter of a function, don't expect anything here
                     * except a '*' that means that here's an anonymous function pointer
                     */
                    if (t.Kind != (Times))
                        SynErr(Times);
                }
                else
                {
                    if(Expect(Identifier))
                        ret.Name = t.Value;

                    /*
                     * Just here suffixes can follow!
                     */
                    if (laKind != (CloseParenthesis))
                    {
                        DeclaratorSuffixes(ret);
                    }
                }
            }
            ret.Type = cd;
            Expect(CloseParenthesis);
        }
コード例 #35
0
ファイル: ProfilerPadWidget.cs プロジェクト: foerdi/Mono-D
 public void AddTracedFunction(long numCalls, long treeTime, long funcTime, long perCall, DNode symbol)
 {
     traceFunctionsStore.AppendValues(numCalls, treeTime, funcTime, perCall, symbol.ToString(false, true), symbol);
 }
コード例 #36
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        TemplateParameter TemplateParameter(DNode parent)
        {
            CodeLocation startLoc;

            // TemplateThisParameter
            if (laKind == (This))
            {
                Step();

                startLoc = t.Location;
                var end = t.EndLocation;

                return new TemplateThisParameter(TemplateParameter(parent), parent) { Location=startLoc, EndLocation=end };
            }

            // TemplateTupleParameter
            else if (laKind == (Identifier) && Lexer.CurrentPeekToken.Kind == TripleDot)
            {
                Step();
                startLoc = t.Location;
                var id = t.Value;
                Step();

                return new TemplateTupleParameter(id, startLoc, parent) { Location=startLoc, EndLocation=t.EndLocation	};
            }

            // TemplateAliasParameter
            else if (laKind == (Alias))
            {
                Step();

                startLoc = t.Location;
                TemplateAliasParameter al;

                if(Expect(Identifier))
                    al = new TemplateAliasParameter(t.Value, t.Location, parent);
                else
                    al = new TemplateAliasParameter(IsEOF ? DTokens.IncompleteIdHash : 0 , CodeLocation.Empty, parent);
                al.Location = startLoc;

                // TODO?:
                // alias BasicType Declarator TemplateAliasParameterSpecialization_opt TemplateAliasParameterDefault_opt

                // TemplateAliasParameterSpecialization
                if (laKind == (Colon))
                {
                    Step();

                    AllowWeakTypeParsing=true;
                    al.SpecializationType = Type();
                    AllowWeakTypeParsing=false;

                    if (al.SpecializationType==null)
                        al.SpecializationExpression = ConditionalExpression();
                }

                // TemplateAliasParameterDefault
                if (laKind == (Assign))
                {
                    Step();

                    if (IsAssignExpression ())
                        al.DefaultExpression = ConditionalExpression ();
                    else
                        al.DefaultType = Type ();
                }
                al.EndLocation = t.EndLocation;
                return al;
            }

            // TemplateTypeParameter
            else if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Colon) || Lexer.CurrentPeekToken.Kind == (Assign) || Lexer.CurrentPeekToken.Kind == (Comma) || Lexer.CurrentPeekToken.Kind == (CloseParenthesis)))
            {
                Expect(Identifier);
                var tt = new TemplateTypeParameter(t.Value, t.Location, parent) { Location = t.Location };

                if (laKind == Colon)
                {
                    Step();
                    tt.Specialization = Type();
                }

                if (laKind == Assign)
                {
                    Step();
                    tt.Default = Type();
                }
                tt.EndLocation = t.EndLocation;
                return tt;
            }

            // TemplateValueParameter
            startLoc = la.Location;
            var bt = BasicType();
            var dv = Declarator(bt,false, null);

            if (dv == null) {
                SynErr (t.Kind, "Declarator expected for parsing template parameter");
                return new TemplateTypeParameter (DTokens.IncompleteIdHash, t.Location, parent) { Location = t.Location };
            }

            var tv = new TemplateValueParameter(dv.NameHash, dv.NameLocation, parent) {
                Location=la.Location,
                Type = dv.Type
            };

            if (laKind == (Colon))
            {
                Step();
                tv.SpecializationExpression = ConditionalExpression();
            }

            if (laKind == (Assign))
            {
                Step();
                tv.DefaultExpression = AssignExpression();
            }
            tv.EndLocation = t.EndLocation;
            return tv;
        }