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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 internal override LexicalSortKey GetLexicalSortKey() => LexicalSortKey.GetSynthesizedMemberKey(_memberOffset);
Exemplo n.º 4
0
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     _treeOrdinal = other._treeOrdinal;
     Volatile.Write(ref _position, other._position);
 }
Exemplo n.º 5
0
        public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
        {
            int comparison = Compare(xSortKey, ySortKey);

            return(comparison > 0 ? ySortKey : xSortKey);
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 public void SetFrom(LexicalSortKey other)
 {
     Debug.Assert(other.IsInitialized);
     this.treeOrdinal = other.treeOrdinal;
     Volatile.Write(ref this.position, other.position);
 }
Exemplo n.º 8
0
 public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey)
 {
     int comparison = Compare(xSortKey, ySortKey);
     return comparison > 0 ? ySortKey : xSortKey;
 }