CodeBlockEntry.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. namespace Mono.CompilerServices.SymbolWriter
  3. {
  4. public class CodeBlockEntry
  5. {
  6. public enum Type
  7. {
  8. Lexical = 1,
  9. CompilerGenerated,
  10. IteratorBody,
  11. IteratorDispatcher
  12. }
  13. public int Index;
  14. public int Parent;
  15. public CodeBlockEntry.Type BlockType;
  16. public int StartOffset;
  17. public int EndOffset;
  18. public CodeBlockEntry(int index, int parent, CodeBlockEntry.Type type, int start_offset)
  19. {
  20. this.Index = index;
  21. this.Parent = parent;
  22. this.BlockType = type;
  23. this.StartOffset = start_offset;
  24. }
  25. internal CodeBlockEntry(int index, MyBinaryReader reader)
  26. {
  27. this.Index = index;
  28. int type_flag = reader.ReadLeb128();
  29. this.BlockType = (CodeBlockEntry.Type)(type_flag & 63);
  30. this.Parent = reader.ReadLeb128();
  31. this.StartOffset = reader.ReadLeb128();
  32. this.EndOffset = reader.ReadLeb128();
  33. if ((type_flag & 64) != 0)
  34. {
  35. int data_size = (int)reader.ReadInt16();
  36. reader.BaseStream.Position += (long)data_size;
  37. }
  38. }
  39. public void Close(int end_offset)
  40. {
  41. this.EndOffset = end_offset;
  42. }
  43. //internal void Write(MyBinaryWriter bw)
  44. //{
  45. // bw.WriteLeb128((int)this.BlockType);
  46. // bw.WriteLeb128(this.Parent);
  47. // bw.WriteLeb128(this.StartOffset);
  48. // bw.WriteLeb128(this.EndOffset);
  49. //}
  50. public override string ToString()
  51. {
  52. return string.Format("[CodeBlock {0}:{1}:{2}:{3}:{4}]", new object[]
  53. {
  54. this.Index,
  55. this.Parent,
  56. this.BlockType,
  57. this.StartOffset,
  58. this.EndOffset
  59. });
  60. }
  61. }
  62. }