LineNumberEntry.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Mono.CompilerServices.SymbolWriter
  4. {
  5. public class LineNumberEntry
  6. {
  7. private class OffsetComparerClass : IComparer<LineNumberEntry>
  8. {
  9. public int Compare(LineNumberEntry l1, LineNumberEntry l2)
  10. {
  11. int result;
  12. if (l1.Offset < l2.Offset)
  13. {
  14. result = -1;
  15. }
  16. else
  17. {
  18. if (l1.Offset > l2.Offset)
  19. {
  20. result = 1;
  21. }
  22. else
  23. {
  24. result = 0;
  25. }
  26. }
  27. return result;
  28. }
  29. }
  30. private class RowComparerClass : IComparer<LineNumberEntry>
  31. {
  32. public int Compare(LineNumberEntry l1, LineNumberEntry l2)
  33. {
  34. int result;
  35. if (l1.Row < l2.Row)
  36. {
  37. result = -1;
  38. }
  39. else
  40. {
  41. if (l1.Row > l2.Row)
  42. {
  43. result = 1;
  44. }
  45. else
  46. {
  47. result = 0;
  48. }
  49. }
  50. return result;
  51. }
  52. }
  53. public readonly int Row;
  54. public readonly int File;
  55. public readonly int Offset;
  56. public readonly bool IsHidden;
  57. public static LineNumberEntry Null = new LineNumberEntry(0, 0, 0);
  58. public static readonly IComparer<LineNumberEntry> OffsetComparer = new LineNumberEntry.OffsetComparerClass();
  59. public static readonly IComparer<LineNumberEntry> RowComparer = new LineNumberEntry.RowComparerClass();
  60. public LineNumberEntry(int file, int row, int offset) : this(file, row, offset, false)
  61. {
  62. }
  63. public LineNumberEntry(int file, int row, int offset, bool is_hidden)
  64. {
  65. this.File = file;
  66. this.Row = row;
  67. this.Offset = offset;
  68. this.IsHidden = is_hidden;
  69. }
  70. public override string ToString()
  71. {
  72. return string.Format("[Line {0}:{1}:{2}]", this.File, this.Row, this.Offset);
  73. }
  74. }
  75. }