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; }
/// <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); }
internal override LexicalSortKey GetLexicalSortKey() => LexicalSortKey.GetSynthesizedMemberKey(_memberOffset);
public void SetFrom(LexicalSortKey other) { Debug.Assert(other.IsInitialized); _treeOrdinal = other._treeOrdinal; Volatile.Write(ref _position, other._position); }
public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey) { int comparison = Compare(xSortKey, ySortKey); return(comparison > 0 ? ySortKey : xSortKey); }
/// <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; }
public void SetFrom(LexicalSortKey other) { Debug.Assert(other.IsInitialized); this.treeOrdinal = other.treeOrdinal; Volatile.Write(ref this.position, other.position); }
public static LexicalSortKey First(LexicalSortKey xSortKey, LexicalSortKey ySortKey) { int comparison = Compare(xSortKey, ySortKey); return comparison > 0 ? ySortKey : xSortKey; }