/Mono.Cecil.Metadata/TableHeap.cs

http://github.com/jbevain/cecil · C# · 104 lines · 83 code · 12 blank · 9 comment · 1 complexity · 98463bba1ed5619218a19ff5b99b1086 MD5 · raw file

  1. //
  2. // Author:
  3. // Jb Evain (jbevain@gmail.com)
  4. //
  5. // Copyright (c) 2008 - 2015 Jb Evain
  6. // Copyright (c) 2008 - 2011 Novell, Inc.
  7. //
  8. // Licensed under the MIT/X11 license.
  9. //
  10. using System;
  11. using Mono.Cecil.PE;
  12. namespace Mono.Cecil.Metadata {
  13. enum Table : byte {
  14. Module = 0x00,
  15. TypeRef = 0x01,
  16. TypeDef = 0x02,
  17. FieldPtr = 0x03,
  18. Field = 0x04,
  19. MethodPtr = 0x05,
  20. Method = 0x06,
  21. ParamPtr = 0x07,
  22. Param = 0x08,
  23. InterfaceImpl = 0x09,
  24. MemberRef = 0x0a,
  25. Constant = 0x0b,
  26. CustomAttribute = 0x0c,
  27. FieldMarshal = 0x0d,
  28. DeclSecurity = 0x0e,
  29. ClassLayout = 0x0f,
  30. FieldLayout = 0x10,
  31. StandAloneSig = 0x11,
  32. EventMap = 0x12,
  33. EventPtr = 0x13,
  34. Event = 0x14,
  35. PropertyMap = 0x15,
  36. PropertyPtr = 0x16,
  37. Property = 0x17,
  38. MethodSemantics = 0x18,
  39. MethodImpl = 0x19,
  40. ModuleRef = 0x1a,
  41. TypeSpec = 0x1b,
  42. ImplMap = 0x1c,
  43. FieldRVA = 0x1d,
  44. EncLog = 0x1e,
  45. EncMap = 0x1f,
  46. Assembly = 0x20,
  47. AssemblyProcessor = 0x21,
  48. AssemblyOS = 0x22,
  49. AssemblyRef = 0x23,
  50. AssemblyRefProcessor = 0x24,
  51. AssemblyRefOS = 0x25,
  52. File = 0x26,
  53. ExportedType = 0x27,
  54. ManifestResource = 0x28,
  55. NestedClass = 0x29,
  56. GenericParam = 0x2a,
  57. MethodSpec = 0x2b,
  58. GenericParamConstraint = 0x2c,
  59. Document = 0x30,
  60. MethodDebugInformation = 0x31,
  61. LocalScope = 0x32,
  62. LocalVariable = 0x33,
  63. LocalConstant = 0x34,
  64. ImportScope = 0x35,
  65. StateMachineMethod = 0x36,
  66. CustomDebugInformation = 0x37,
  67. }
  68. struct TableInformation {
  69. public uint Offset;
  70. public uint Length;
  71. public uint RowSize;
  72. public bool IsLarge {
  73. get { return Length > ushort.MaxValue; }
  74. }
  75. }
  76. sealed class TableHeap : Heap {
  77. public long Valid;
  78. public long Sorted;
  79. public readonly TableInformation [] Tables = new TableInformation [Mixin.TableCount];
  80. public TableInformation this [Table table] {
  81. get { return Tables [(int) table]; }
  82. }
  83. public TableHeap (byte [] data)
  84. : base (data)
  85. {
  86. }
  87. public bool HasTable (Table table)
  88. {
  89. return (Valid & (1L << (int) table)) != 0;
  90. }
  91. }
  92. }