コード例 #1
0
        public LexicalSortKey GetLexicalSortKey(CSharpCompilation compilation)
        {
            LexicalSortKey sortKey = new LexicalSortKey(_declarations[0].NameLocation, compilation);
            for (var i = 1; i < _declarations.Length; i++)
            {
                sortKey = LexicalSortKey.First(sortKey, new LexicalSortKey(_declarations[i].NameLocation, compilation));
            }

            return sortKey;
        }
コード例 #2
0
        /// <summary>
        /// Compare two lexical sort keys in a compilation.
        /// </summary>
        public static int Compare(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison;

            if (xSortKey.TreeOrdinal != ySortKey.TreeOrdinal)
            {
                if (xSortKey.TreeOrdinal < 0)
                {
                    return(1);
                }
                else if (ySortKey.TreeOrdinal < 0)
                {
                    return(-1);
                }

                comparison = xSortKey.TreeOrdinal - ySortKey.TreeOrdinal;
                Debug.Assert(comparison != 0);
                return(comparison);
            }

            return(xSortKey.Position - ySortKey.Position);
        }
コード例 #3
0
 internal override LexicalSortKey GetLexicalSortKey() => LexicalSortKey.GetSynthesizedMemberKey(_memberOffset);
コード例 #4
0
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     _treeOrdinal = other._treeOrdinal;
     Volatile.Write(ref _position, other._position);
 }
コード例 #5
0
        public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison = Compare(xSortKey, ySortKey);

            return(comparison > 0 ? ySortKey : xSortKey);
        }
コード例 #6
0
ファイル: LexicalSortKey.cs プロジェクト: EkardNT/Roslyn
        /// <summary>
        /// Compare two lexical sort keys in a compilation.
        /// </summary>
        public static int Compare(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison;

            if (xSortKey.TreeOrdinal != ySortKey.TreeOrdinal)
            {
                if (xSortKey.TreeOrdinal < 0)
                {
                    return 1;
                }
                else if (ySortKey.TreeOrdinal < 0)
                {
                    return -1;
                }

                comparison = xSortKey.TreeOrdinal - ySortKey.TreeOrdinal;
                Debug.Assert(comparison != 0);
                return comparison;
            }

            return xSortKey.Position - ySortKey.Position;
        }
コード例 #7
0
ファイル: LexicalSortKey.cs プロジェクト: EkardNT/Roslyn
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     this.treeOrdinal = other.treeOrdinal;
     Volatile.Write(ref this.position, other.position);
 }
コード例 #8
0
ファイル: LexicalSortKey.cs プロジェクト: EkardNT/Roslyn
 public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
 {
     int comparison = Compare(xSortKey, ySortKey);
     return comparison > 0 ? ySortKey : xSortKey;
 }