PageRenderTime 34ms CodeModel.GetById 16ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

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