コード例 #1
0
ファイル: DType.cs プロジェクト: windygu/DSharp
 public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td,
                                 AbstractType baseType = null, InterfaceType[] baseInterfaces = null,
                                 ReadOnlyCollection <TemplateParameterSymbol> deducedTypes = null)
     : base(dc, baseType, deducedTypes, td)
 {
     this.BaseInterfaces = baseInterfaces;
 }
コード例 #2
0
        public static Range GetNameRange(this ISyntaxRegion reference)
        {
            CodeLocation startLocation;
            CodeLocation endLocation;

            switch (reference)
            {
            case AbstractTypeDeclaration abstractTypeDeclaration:
                startLocation = abstractTypeDeclaration.NonInnerTypeDependendLocation;
                endLocation   = abstractTypeDeclaration.EndLocation;
                break;

            case IExpression _:
                startLocation = reference.Location;
                endLocation   = reference.EndLocation;
                break;

            case TemplateParameter templateParameter:
                startLocation = templateParameter.NameLocation;
                endLocation   = new CodeLocation(templateParameter.NameLocation.Column + templateParameter.Name.Length,
                                                 templateParameter.NameLocation.Line);
                break;

            case INode n:
                startLocation = n.NameLocation;
                endLocation   = new CodeLocation(n.NameLocation.Column + n.Name.Length, n.NameLocation.Line);
                break;

            default:
                return(default);
            }

            return(new Range(new Position(startLocation.Line - 1, startLocation.Column - 1),
                             new Position(endLocation.Line - 1, endLocation.Column - 1)));
        }
コード例 #3
0
        public bool TryGet(ResolutionContext ctxt, ISyntaxRegion element, out T resolvedElement)
        {
            resolvedElement = null;
            var parameters = GetParameters(ctxt, GetRelatedNode(element));

            if (parameters.Count == 0)
            {
                lock (paramLessCache)
                    return(paramLessCache.TryGetValue(element, out resolvedElement));
            }

            lock (paramBoundCache)
            {
                Dictionary <TemplateParameterSymbol[], T> dict;
                if (!paramBoundCache.TryGetValue(element, out dict))
                {
                    return(false);
                }

                foreach (var kv in dict)
                {
                    if (CompareParameterEquality(parameters, kv.Key))
                    {
                        resolvedElement = kv.Value;
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #4
0
ファイル: DType.cs プロジェクト: windygu/DSharp
 public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td,
                                 AbstractType baseType, InterfaceType[] baseInterfaces,
                                 IEnumerable <TemplateParameterSymbol> deducedTypes)
     : this(dc, td, baseType, baseInterfaces,
            deducedTypes != null ? new ReadOnlyCollection <TemplateParameterSymbol>(deducedTypes.ToArray()) : null)
 {
 }
コード例 #5
0
        static ISyntaxRegion GetLastBlockAstChild(DBlockNode n)
        {
            ISyntaxRegion lastChild = null;
            ISyntaxRegion t         = null;

            if (n.Count != 0)
            {
                lastChild = n.Children[n.Count - 1];
            }

            if (n.MetaBlocks.Count != 0)
            {
                t = n.MetaBlocks[n.MetaBlocks.Count - 1];

                if (lastChild == null || t.EndLocation > lastChild.EndLocation)
                {
                    lastChild = t;
                }
            }

            if (n.StaticStatements.Count != 0)
            {
                t = n.StaticStatements[n.StaticStatements.Count - 1];

                if (lastChild == null || t.EndLocation > lastChild.EndLocation)
                {
                    lastChild = t;
                }
            }

            return(lastChild);
        }
コード例 #6
0
        /// <summary>
        /// Adds a result to the cache.
        /// Warning: Does not check for double occurences of the same set of surrounding template parameters -
        ///          so call TryGet first to ensure that the element hasn't been enlisted yet under these specific circumstances.
        /// </summary>
        public void Add(ResolutionContext ctxt, ISyntaxRegion element, T resolvedElement)
        {
            var parameters = GetParameters(ctxt, GetRelatedNode(element));

            if (resolvedElement is AbstractType &&
                (resolvedElement as AbstractType).DeclarationOrExpressionBase == element)
            {
                (resolvedElement as AbstractType).DeclarationOrExpressionBase = null;
            }

            if (parameters.Count == 0)
            {
                try{
                    lock (paramLessCache)
                        paramLessCache.Add(element, resolvedElement);
                }catch (Exception)
                {
                }
                return;
            }

            lock (paramBoundCache)
            {
                Dictionary <TemplateParameterSymbol[], T> dict;
                if (!paramBoundCache.TryGetValue(element, out dict))
                {
                    dict = new Dictionary <TemplateParameterSymbol[], T>();
                    paramBoundCache.Add(element, dict);
                }

                dict.Add(parameters.ToArray(), resolvedElement);
            }
        }
コード例 #7
0
 public static Range ToRange(this ISyntaxRegion syntaxRegion)
 {
     return(syntaxRegion == null ? null
         : new Range(
                new Position(syntaxRegion.Location.Line - 1, syntaxRegion.Location.Column - 1),
                new Position(syntaxRegion.EndLocation.Line - 1, syntaxRegion.EndLocation.Column - 1)));
 }
コード例 #8
0
            private bool PushSelectionRange(ISyntaxRegion syntaxRegion)
            {
                if (syntaxRegion is DModule)
                {
                    return(true);
                }

                if (syntaxRegion.Location > caret || syntaxRegion.EndLocation < caret)
                {
                    return(false);
                }

                if (narrowestSelectionRange == null)
                {
                    narrowestSelectionRange = new SelectionRange {
                        Range = syntaxRegion.ToRange()
                    };
                }
                else if (syntaxRegion.IsWithinRange(narrowestSelectionRange.Range))
                {
                    narrowestSelectionRange = new SelectionRange
                    {
                        Range  = syntaxRegion.ToRange(),
                        Parent = narrowestSelectionRange
                    };
                }

                return(true);
            }
コード例 #9
0
 public static AbstractType[] ResolveFurtherTypeIdentifier(string nextIdentifier,
                                                           IEnumerable <AbstractType> resultBases,
                                                           ResolutionContext ctxt,
                                                           ISyntaxRegion typeIdObject = null)
 {
     return(ResolveFurtherTypeIdentifier(nextIdentifier.GetHashCode(), resultBases, ctxt, typeIdObject));
 }
コード例 #10
0
        /// <summary>
        /// Used to extract the adequate code location + the identifier length
        /// </summary>
        public static CodeLocation ExtractIdLocation(ISyntaxRegion sr, out int idLength)
        {
            if (sr is IdentifierDeclaration)
            {
                var id = (IdentifierDeclaration)sr;

                idLength = id.Id.Length;
                return(id.Location);
            }
            else if (sr is IdentifierExpression)
            {
                var id = (IdentifierExpression)sr;
                idLength = ((string)id.Value).Length;
                return(id.Location);
            }
            else if (sr is TemplateInstanceExpression)
            {
                var tix = (TemplateInstanceExpression)sr;
                idLength = tix.TemplateIdentifier.Id.Length;
                return(tix.TemplateIdentifier.Location);
            }
            else if (sr is PostfixExpression_Access)
            {
                return(ExtractIdLocation(((PostfixExpression_Access)sr).AccessExpression, out idLength));
            }
            else if (sr is NewExpression)
            {
                return(ExtractIdLocation(((NewExpression)sr).Type, out idLength));
            }

            idLength = 0;
            return(CodeLocation.Empty);
        }
コード例 #11
0
        public ulong Accept(ISyntaxRegion sr)
        {
            if (sr is INode)
            {
                return((sr as INode).Accept(this));
            }
            if (sr is IExpression)
            {
                return((ulong)sr.ToString().GetHashCode());                // Temporary bypass
                //return (sr as IExpression).Accept(this);
            }
            if (sr is IStatement)
            {
                return((sr as IStatement).Accept(this));
            }
            if (sr is ITypeDeclaration)
            {
                return((sr as ITypeDeclaration).Accept(this));
            }
            if (sr is DAttribute)
            {
                return((sr as DAttribute).Accept(this));
            }

            throw new InvalidOperationException();
        }
コード例 #12
0
        static string GetIdentifier(ISyntaxRegion sr)
        {
            switch (sr)
            {
            case INode n:
                return(n.Name);

            case TemplateInstanceExpression templateInstanceExpression:
                return(templateInstanceExpression.TemplateId);                        // Identifier.ToString(false);

            case NewExpression newExpression:
                return(newExpression.Type.ToString(false));

            case TemplateParameter templateParameter:
                return(templateParameter.Name);

            case IdentifierDeclaration identifierDeclaration:
                return(identifierDeclaration.Id);

            case IdentifierExpression identifierExp:
                return(identifierExp.StringValue);

            default:
                return("");
            }
        }
コード例 #13
0
ファイル: UFCSResolver.cs プロジェクト: rainers/D_Parser
 UFCSResolver(ResolutionContext ctxt, ISemantic firstArg, int nameHash = 0, ISyntaxRegion sr = null)
     : base(ctxt)
 {
     this.firstArgument = firstArg;
     this.nameFilterHash = nameHash;
     this.sr = sr;
 }
コード例 #14
0
ファイル: ReferencesFinder.cs プロジェクト: Orvid/D_Parser
        bool TryAdd(AbstractType resolvedSymbol, ISyntaxRegion sr)
        {
            if (resolvedSymbol != null)
            {
                INode n;
                var   aliasTag = resolvedSymbol.Tag as D_Parser.Resolver.TypeResolution.TypeDeclarationResolver.AliasTag;
                if (aliasTag != null)
                {
                    n = aliasTag.aliasDefinition;
                }
                else if (resolvedSymbol is DSymbol)
                {
                    n = (resolvedSymbol as DSymbol).Definition;
                }
                else
                {
                    n = null;
                }

                if (n == symbol)
                {
                    l.Add(sr);
                    return(true);
                }
            }
            return(false);
        }
コード例 #15
0
        AbstractType TryPretendMethodExecution(AbstractType b, ISyntaxRegion typeBase = null, AbstractType[] args = null)
        {
            if (!TryReturnMethodReturnType || (ctxt.Options & ResolutionOptions.ReturnMethodReferencesOnly) != 0)
            {
                return(b);
            }

            if (b is AmbiguousType)
            {
                AbstractType first = null;

                foreach (var ov in (b as AmbiguousType).Overloads)
                {
                    if (ov is MemberSymbol)
                    {
                        var next = TryPretendMethodExecution_(ov as MemberSymbol, args);
                        if (first == null && next != ov)
                        {
                            first = next;
                            continue;
                        }
                        // Error - ambiguous parameter configurations
                    }

                    // Error
                }

                return(first ?? b);
            }

            var mr = b as MemberSymbol;

            return(mr == null ? b : TryPretendMethodExecution_(mr, args));
        }
コード例 #16
0
 void HandleResult(ISyntaxRegion sr, AbstractType t)
 {
     if (t is UserDefinedType)
     {
         result.TypeMatches.Add(sr);
     }
 }
コード例 #17
0
ファイル: DeepASTVisitor.cs プロジェクト: DinrusGroup/DRC
        /// <summary>
        /// Used to extract the adequate code location + the identifier length
        /// </summary>
        public static CodeLocation ExtractIdLocation(ISyntaxRegion sr, out int idLength)
        {
            if (sr is IdentifierDeclaration)
            {
                var id = (IdentifierDeclaration)sr;

                idLength = id.Id.Length;
                return id.Location;
            }
            else if (sr is IdentifierExpression)
            {
                var id = (IdentifierExpression)sr;
                idLength = id.StringValue.Length;
                return id.Location;
            }
            else if (sr is TemplateInstanceExpression)
            {
                var tix = (TemplateInstanceExpression)sr;
                idLength = tix.TemplateId.Length;
                return tix.Identifier.Location;
            }
            else if (sr is PostfixExpression_Access)
                return ExtractIdLocation(((PostfixExpression_Access)sr).AccessExpression, out idLength);
            else if (sr is NewExpression)
                return ExtractIdLocation(((NewExpression)sr).Type, out idLength);

            idLength = 0;
            return CodeLocation.Empty;
        }
コード例 #18
0
ファイル: DType.cs プロジェクト: Orvid/D_Parser
 public TemplateParameterSymbol(TemplateParameter tpn, ISemantic typeOrValue, ISyntaxRegion paramIdentifier = null)
     : base(tpn != null ? tpn.Representation : null, AbstractType.Get(typeOrValue), paramIdentifier)
 {
     IsKnowinglyUndetermined = TemplateInstanceHandler.IsNonFinalArgument(typeOrValue);
     this.Parameter          = tpn;
     this.ParameterValue     = typeOrValue as ISymbolValue;
 }
コード例 #19
0
ファイル: DType.cs プロジェクト: michaelc37/Mono-D
 public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td,
                                 AbstractType baseType, InterfaceType[] baseInterfaces,
                                 Dictionary <string, TemplateParameterSymbol> deducedTypes)
     : this(dc, td, baseType, baseInterfaces,
            deducedTypes != null && deducedTypes.Count != 0 ? new ReadOnlyCollection <KeyValuePair <string, TemplateParameterSymbol> >(deducedTypes.ToArray()) : null)
 {
 }
コード例 #20
0
		/// <summary>
		/// http://dlang.org/operatoroverloading.html#Dispatch
		/// Check for the existence of an opDispatch overload.
		/// Important: Because static opDispatches are allowed as well, do check whether we can access non-static overloads from non-instance expressions or such
		/// </summary>
		public static IEnumerable<AbstractType> TryResolveFurtherIdViaOpDispatch (ResolutionContext ctxt, int nextIdentifierHash, UserDefinedType b, ISyntaxRegion typeBase = null)
		{
			// The usual SO prevention
			if (nextIdentifierHash == opDispatchId || b == null)
				yield break;

			AbstractType[] overloads;

			var opt = ctxt.CurrentContext.ContextDependentOptions;
			// Look for opDispatch-Members inside b's Definition
			using (ctxt.Push(b))
			{
				ctxt.CurrentContext.ContextDependentOptions = opt; // Mainly required for not resolving opDispatch's return type, as this will be performed later on in higher levels
				overloads = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(opDispatchId, b, ctxt, typeBase, false);
			}

			if (overloads == null || overloads.Length < 0)
				yield break;

			var av = new ArrayValue (Evaluation.GetStringType(ctxt), Strings.TryGet(nextIdentifierHash));

			foreach (DSymbol o in overloads) {
				var dn = o.Definition;
				if (dn.TemplateParameters != null && dn.TemplateParameters.Length > 0 && 
					dn.TemplateParameters[0] is TemplateValueParameter)
				{
					//TODO: Test parameter types for being a string value
					o.SetDeducedTypes(new[]{ new TemplateParameterSymbol(dn.TemplateParameters[0], av) });
					yield return o;
				}
			}
		}
コード例 #21
0
 public MemberCompletionProvider(ICompletionDataGenerator cdg, ISyntaxRegion sr, IBlockNode b, IStatement stmt)
     : base(cdg)
 {
     AccessExpression = sr;
     ScopedBlock = b;
     ScopedStatement = stmt;
 }
コード例 #22
0
        public void GetDefinition(string filename, int startLine, int startIndex, int endLine, int endIndex)
        {
            filename = normalizePath(filename);
            var ast = GetModule(filename);

            if (ast == null)
            {
                throw new COMException("module not found", 1);
            }

            _tipStart = new CodeLocation(startIndex + 1, startLine);
            _tipEnd   = new CodeLocation(endIndex + 1, endLine);
            _tipText.Clear();

            _setupEditorData();
            _editorData.CaretLocation = _tipEnd;
            _editorData.SyntaxTree    = ast as DModule;
            _editorData.ModuleCode    = _sources[filename];
            // codeOffset+1 because otherwise it does not work on the first character
            _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, _tipStart) + 2;

            ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData);

            LooseResolution.NodeResolutionAttempt attempt;
            var rr = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt, true) : null;

            _tipText.Clear();
            if (rr != null)
            {
                var n = DResolver.GetResultMember(rr, true);

                if (n == null)
                {
                    return;
                }

                bool decl = false;
                var  mthd = n as DMethod;
                if (mthd != null)
                {
                    decl = mthd.Body == null;
                }
                else if (n.ContainsAttribute(DTokens.Extern))
                {
                    decl = true;
                }
                if (decl)
                {
                    _tipText.Append("EXTERN:");
                }

                _tipStart = n.Location;
                _tipEnd   = n.EndLocation;
                INode node = n.NodeRoot;
                if (node is DModule)
                {
                    _tipText.Append((node as DModule).FileName);
                }
            }
        }
コード例 #23
0
ファイル: NameScan.cs プロジェクト: rainers/D_Parser
        public static List<AbstractType> SearchAndResolve(ResolutionContext ctxt, CodeLocation caret, int nameHash, ISyntaxRegion idObject=null)
        {
            var scan = new NameScan(ctxt, nameHash, idObject);

            scan.IterateThroughScopeLayers(caret);

            return scan.matches_types;
        }
コード例 #24
0
ファイル: DReferencesHandler.cs プロジェクト: aBothe/lsp4d
 static Location ToLocation(ISyntaxRegion reference, DModule module)
 {
     return(new Location
     {
         Range = reference.GetNameRange(),
         Uri = new Uri(module.FileName)
     });
 }
コード例 #25
0
ファイル: DType.cs プロジェクト: Orvid/D_Parser
 public AliasedType(DVariable AliasDefinition, AbstractType Type, ISyntaxRegion td, IEnumerable <TemplateParameterSymbol> deducedTypes)
     : base(AliasDefinition, Type, td, deducedTypes)
 {
     if (Type != null)
     {
         Type.NonStaticAccess = false;
     }
 }
コード例 #26
0
ファイル: Resolver.cs プロジェクト: rainers/D_Parser
 public override void Visit(PostfixExpression_MethodCall x)
 {
     base.Visit(x);
     if (IdNearCaret == x.PostfixForeExpression)
     {
         IdNearCaret = x;
     }
 }
コード例 #27
0
 static DocumentHighlight ToDocumentHighlight(ISyntaxRegion syntaxRegion)
 {
     return(new DocumentHighlight
     {
         Range = syntaxRegion.GetNameRange(),
         Kind = DocumentHighlightKind.Text
     });
 }
コード例 #28
0
ファイル: ResolutionError.cs プロジェクト: DinrusGroup/DRC
 public AmbiguityError(ISyntaxRegion syntaxObj, IEnumerable<ISemantic> results)
     : base(syntaxObj, "Resolution returned too many results")
 {
     if (results is ISemantic[])
         this.DetectedOverloads = (ISemantic[])results;
     else if(results!=null)
         this.DetectedOverloads = results.ToArray();
 }
コード例 #29
0
        /// <summary>
        /// See <see cref="ResolveIdentifier"/>
        /// </summary>
        public static AbstractType ResolveSingle(string id, ResolutionContext ctxt, ISyntaxRegion idObject, bool ModuleScope = false)
        {
            var r = ResolveIdentifier(id, ctxt, idObject, ModuleScope);

            ctxt.CheckForSingleResult(r, idObject as ISyntaxRegion);

            return(r != null && r.Length != 0 ? r[0] : null);
        }
コード例 #30
0
		static string GetMixinContent(MixinStatement mx, ResolutionContext ctxt, bool takeStmtCache ,out ISyntaxRegion cachedContent)
		{
			cachedContent = null;
			
			if(!CheckAndPushAnalysisStack(mx))
				return null;
			
			bool pop;
			if(pop = (ctxt.ScopedBlock != mx.ParentNode && mx.ParentNode != null))
				ctxt.PushNewScope(mx.ParentNode as IBlockNode, mx);
			
			bool hadCachedItem;
			if(takeStmtCache)
			{
				BlockStatement stmt;
				hadCachedItem = mixinStmtCache.TryGet(ctxt, mx, out stmt);
				cachedContent = stmt;
			}
			else
			{
				DModule mod;
				hadCachedItem = mixinDeclCache.TryGet(ctxt, mx, out mod);
				cachedContent = mod;
			}
			
			if(hadCachedItem)
			{
				stmtsBeingAnalysed.Remove(mx);
				if(pop)
					ctxt.Pop();
				return null;
			}
			
			var x = mx.MixinExpression;
			ISemantic v = null;
			try // 'try' because there is always a risk of e.g. not having something implemented or having an evaluation exception...
			{
				// Evaluate the mixin expression
				v = Evaluation.EvaluateValue(x, ctxt);
			}
			catch{}
			
			stmtsBeingAnalysed.Remove(mx);
			if(pop) 
				ctxt.Pop();
			
			// Ensure it's a string literal
			var av = v as ArrayValue;
			if(av != null && av.IsString)
				return av.StringValue;
			
			if(takeStmtCache)
				mixinStmtCache.Add(ctxt, mx, null);
			else
				mixinDeclCache.Add(ctxt, mx, null);
			return null;
		}
コード例 #31
0
ファイル: VDServer.cs プロジェクト: bleskodev/visuald
        public void GetReferences(string filename, string tok, uint line, uint idx, string expr)
        {
            filename = normalizePath(filename);
            var ast = GetModule(filename);

            if (ast == null)
            {
                throw new COMException("module not found", 1);
            }

            _request = Request.References;
            _result  = "__pending__";

            Action dg = () =>
            {
                _setupEditorData();
                CodeLocation loc = new CodeLocation((int)idx + 1, (int)line);
                _editorData.CaretLocation = loc;
                _editorData.SyntaxTree    = ast as DModule;
                _editorData.ModuleCode    = _sources[filename];
                _editorData.CaretOffset   = getCodeOffset(_editorData.ModuleCode, loc);

                ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData);
                LooseResolution.NodeResolutionAttempt attempt;
                var rr = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt, true) : null;

                StringBuilder refs = new StringBuilder();
                if (rr != null)
                {
                    var n = DResolver.GetResultMember(rr, true);

                    if (n != null)
                    {
                        var ctxt = ResolutionContext.Create(_editorData, true);
                        if (n.ContainsAttribute(DTokens.Private) || ((n is DVariable) && (n as DVariable).IsLocal))
                        {
                            GetReferencesInModule(ast, refs, n, ctxt);
                        }
                        else
                        {
                            foreach (var basePath in _imports.Split(nlSeparator, StringSplitOptions.RemoveEmptyEntries))
                            {
                                foreach (var mod in GlobalParseCache.EnumModulesRecursively(basePath))
                                {
                                    GetReferencesInModule(mod, refs, n, ctxt);
                                }
                            }
                        }
                    }
                    //var res = TypeReferenceFinder.Scan(_editorData, System.Threading.CancellationToken.None, null);
                }
                if (!_editorData.CancelToken.IsCancellationRequested && _request == Request.References)
                {
                    _result = refs.ToString();
                }
            };
        }
コード例 #32
0
ファイル: DType.cs プロジェクト: Orvid/D_Parser
 public AssocArrayType(AbstractType ValueType, AbstractType KeyType, ISyntaxRegion td)
     : base(ValueType, td)
 {
     if (ValueType != null)
     {
         ValueType.NonStaticAccess = true;
     }
     this.KeyType = KeyType;
 }
コード例 #33
0
ファイル: DType.cs プロジェクト: Orvid/D_Parser
 public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
                     ReadOnlyCollection <TemplateParameterSymbol> deducedTypes = null)
     : base(member, memberType, deducedTypes, td)
 {
     if (memberType != null)
     {
         memberType.NonStaticAccess = true;
     }
 }
コード例 #34
0
ファイル: DType.cs プロジェクト: Orvid/D_Parser
 public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
                     IEnumerable <TemplateParameterSymbol> deducedTypes)
     : base(member, memberType, deducedTypes, td)
 {
     if (memberType != null)
     {
         memberType.NonStaticAccess = true;
     }
 }
コード例 #35
0
        void _th(object pcl_shared)
        {
            var pcl  = (ParseCacheList)pcl_shared;
            var ctxt = new ResolverContextStack(pcl, new ResolverContext {
                ScopedBlock = ast
            });

            // Make it as most performing as possible by avoiding unnecessary base types.
            // Aliases should be analyzed deeper though.
            ctxt.CurrentContext.ContextDependentOptions |=
                ResolutionOptions.StopAfterFirstOverloads |
                ResolutionOptions.DontResolveBaseTypes |                 //TODO: Exactly find out which option can be enabled here. Resolving variables' types is needed sometimes - but only, when highlighting a variable reference is wanted explicitly.
                ResolutionOptions.NoTemplateParameterDeduction |
                ResolutionOptions.ReturnMethodReferencesOnly;

            ISyntaxRegion sr = null;
            int           i  = 0;

            while (curQueueOffset < queueCount)
            {
                // Avoid race condition runtime errors
                lock (_lockObject)
                {
                    i = curQueueOffset;
                    curQueueOffset++;
                }

                // Resolve gotten syntax object
                sr = q[i];
                var sb = ctxt.CurrentContext.ScopedBlock;
                ctxt.CurrentContext.ScopedBlock = DResolver.SearchBlockAt(
                    sb == null || sr.Location <sb.BlockStartLocation || sr.EndLocation> sb.EndLocation ? ast : sb,
                    sr.Location,
                    out ctxt.CurrentContext.ScopedStatement);

                if (sr is PostfixExpression_Access)
                {
                    HandleAccessExpressions((PostfixExpression_Access)sr, ctxt);
                }
                else
                {
                    AbstractType t = null;
                    if (sr is IExpression)
                    {
                        t = DResolver.StripAliasSymbol(Evaluation.EvaluateType((IExpression)sr, ctxt));
                    }
                    else if (sr is ITypeDeclaration)
                    {
                        t = DResolver.StripAliasSymbol(TypeDeclarationResolver.ResolveSingle((ITypeDeclaration)sr, ctxt));
                    }

                    // Enter into the result list
                    HandleResult(sr, t);
                }
            }
        }
コード例 #36
0
 public TemplateParameterSymbol(ITemplateParameter tp,
                                ISemantic representedTypeOrValue,
                                ISyntaxRegion originalParameterIdentifier = null,
                                DNode parentNode = null)
     : base(new TemplateParameterNode(tp) { Parent = parentNode },
            AbstractType.Get(representedTypeOrValue), originalParameterIdentifier ?? tp)
 {
     this.Parameter      = tp;
     this.ParameterValue = representedTypeOrValue as ISymbolValue;
 }
コード例 #37
0
ファイル: UFCSResolver.cs プロジェクト: rainers/D_Parser
        public static List<AbstractType> TryResolveUFCS(
			ISemantic firstArgument,int nameHash,CodeLocation nameLoc,
			ResolutionContext ctxt, ISyntaxRegion nameSr = null)
        {
            if (firstArgument == null || ctxt == null)
                return new List<AbstractType>();

            var us = new UFCSResolver (ctxt, firstArgument, nameHash, nameSr);
            us.IterateThroughScopeLayers (nameLoc, MemberFilter.Methods | MemberFilter.Templates);
            return us.matches;
        }
コード例 #38
0
        void AddResult(ISyntaxRegion sr, byte type)
        {
            Dictionary <ISyntaxRegion, byte> l;

            if (!Matches.TryGetValue(sr.Location.Line, out l))
            {
                Matches[sr.Location.Line] = l = new Dictionary <ISyntaxRegion, byte>();
            }

            l[sr] = type;
        }
コード例 #39
0
 public static string ExtractId(ISyntaxRegion o)
 {
     if (o is IdentifierDeclaration)
         return ((IdentifierDeclaration)o).Id;
     else if (o is IdentifierExpression && ((IdentifierExpression)o).IsIdentifier)
         return (string)((IdentifierExpression)o).Value;
     else if (o is PostfixExpression_Access)
         return ExtractId(((PostfixExpression_Access)o).AccessExpression);
     else if (o is TemplateInstanceExpression)
         return ((TemplateInstanceExpression)o).TemplateIdentifier.Id;
     else if (o is NewExpression)
         return ExtractId(((NewExpression)o).Type);
     return null;
 }
コード例 #40
0
 protected override void Handle(ISyntaxRegion o)
 {
     if (o is IdentifierDeclaration || o is TemplateInstanceExpression)
     {
         if (DoPrimaryIdCheck(ExtractId(o)))
             result.TypeMatches.Add(o);
     }
     /* Though type resolution is very fast now it's still kinda slow - 300 ms for all expressions in std.stdio
     else if (o is IdentifierExpression)
     {
         if (DoPrimaryIdCheck((string)((IdentifierExpression)o).Value))
             q.Add(o);
     }
     else if (o is PostfixExpression_Access)
         q.AddRange(DoPrimaryIdCheck((PostfixExpression_Access)o));*/
 }
コード例 #41
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public TemplateParameterSymbol(TemplateParameter tpn, ISemantic typeOrValue, ISyntaxRegion paramIdentifier = null)
     : base(tpn != null ? tpn.Representation : null, AbstractType.Get(typeOrValue), paramIdentifier)
 {
     this.Parameter = tpn;
     this.ParameterValue = typeOrValue as ISymbolValue;
 }
コード例 #42
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td, 
			AbstractType baseType = null, InterfaceType[] baseInterfaces = null,
			ReadOnlyCollection<TemplateParameterSymbol> deducedTypes = null)
            : base(dc, baseType, deducedTypes, td)
        {
            this.BaseInterfaces = baseInterfaces;
        }
コード例 #43
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td, 
			AbstractType baseType, InterfaceType[] baseInterfaces,
			IEnumerable<TemplateParameterSymbol> deducedTypes)
            : this(dc,td, baseType,baseInterfaces,
			deducedTypes != null ? new ReadOnlyCollection<TemplateParameterSymbol>(deducedTypes.ToArray()) : null)
        {
        }
コード例 #44
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public PointerType(AbstractType Base, ISyntaxRegion td)
     : base(Base, td)
 {
 }
コード例 #45
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public PrimitiveType(byte TypeToken, byte Modifier, ISyntaxRegion td)
     : base(td)
 {
     this.TypeToken = TypeToken;
     this.modifier = Modifier;
 }
コード例 #46
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public UnionType(DClassLike dc, ISyntaxRegion td, IEnumerable<TemplateParameterSymbol> deducedTypes = null)
     : base(dc, td, null, null, deducedTypes)
 {
 }
コード例 #47
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public DTuple(ISyntaxRegion td,IEnumerable<ISemantic> items)
     : base(td)
 {
     if (items is ISemantic[])
         Items = (ISemantic[])items;
     else if (items != null)
         Items = items.ToArray();
 }
コード例 #48
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
			ReadOnlyCollection<TemplateParameterSymbol> deducedTypes = null)
            : base(member, memberType, deducedTypes, td)
        {
        }
コード例 #49
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public MemberSymbol(DNode member, AbstractType memberType, ISyntaxRegion td,
			IEnumerable<TemplateParameterSymbol> deducedTypes)
            : base(member, memberType, deducedTypes, td)
        {
        }
コード例 #50
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public InterfaceType(DClassLike dc, ISyntaxRegion td, 
			InterfaceType[] baseInterfaces=null,
			IEnumerable<TemplateParameterSymbol> deducedTypes = null)
            : base(dc, td, null, baseInterfaces, deducedTypes)
        {
        }
コード例 #51
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public InterfaceType(DClassLike dc, ISyntaxRegion td,
			InterfaceType[] baseInterfaces,
			ReadOnlyCollection<TemplateParameterSymbol> deducedTypes)
            : base(dc, td, null, baseInterfaces, deducedTypes)
        {
        }
コード例 #52
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
        public EponymousTemplateType(EponymousTemplate ep,
			ReadOnlyCollection<TemplateParameterSymbol> deducedTypes = null, ISyntaxRegion td = null)
            : base(ep, null, deducedTypes, td)
        {
        }
コード例 #53
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public EnumType(DEnum Enum, ISyntaxRegion td)
     : base(Enum, new PrimitiveType(DTokens.Int, 0), null, td)
 {
 }
コード例 #54
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public EnumType(DEnum Enum, AbstractType BaseType, ISyntaxRegion td)
     : base(Enum, BaseType, null, td)
 {
 }
コード例 #55
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public TemplateType(DClassLike dc, ISyntaxRegion td, IEnumerable<TemplateParameterSymbol> inheritedTypeParams = null)
     : base(dc, td, null, null, inheritedTypeParams)
 {
 }
コード例 #56
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public DerivedDataType(AbstractType Base, ISyntaxRegion td)
     : base(td)
 {
     this.Base = Base;
 }
コード例 #57
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public TemplateType(DClassLike dc, ISyntaxRegion td, ReadOnlyCollection<TemplateParameterSymbol> inheritedTypeParams = null)
     : base(dc, td, null, null, inheritedTypeParams)
 {
 }
コード例 #58
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public PackageSymbol(ModulePackage pack,ISyntaxRegion td)
     : base(td)
 {
     this.Package = pack;
 }
コード例 #59
0
ファイル: DType.cs プロジェクト: DinrusGroup/DRC
 public ModuleSymbol(DModule mod, ISyntaxRegion td, PackageSymbol packageBase = null)
     : base(mod, packageBase, (IEnumerable<TemplateParameterSymbol>)null, td)
 {
 }
コード例 #60
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;
        }