AnonymousScopeEntry.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Mono.CompilerServices.SymbolWriter
  4. {
  5. public class AnonymousScopeEntry
  6. {
  7. public readonly int ID;
  8. private List<CapturedVariable> captured_vars = new List<CapturedVariable>();
  9. private List<CapturedScope> captured_scopes = new List<CapturedScope>();
  10. public CapturedVariable[] CapturedVariables
  11. {
  12. get
  13. {
  14. CapturedVariable[] retval = new CapturedVariable[this.captured_vars.Count];
  15. this.captured_vars.CopyTo(retval, 0);
  16. return retval;
  17. }
  18. }
  19. public CapturedScope[] CapturedScopes
  20. {
  21. get
  22. {
  23. CapturedScope[] retval = new CapturedScope[this.captured_scopes.Count];
  24. this.captured_scopes.CopyTo(retval, 0);
  25. return retval;
  26. }
  27. }
  28. public AnonymousScopeEntry(int id)
  29. {
  30. this.ID = id;
  31. }
  32. internal AnonymousScopeEntry(MyBinaryReader reader)
  33. {
  34. this.ID = reader.ReadLeb128();
  35. int num_captured_vars = reader.ReadLeb128();
  36. for (int i = 0; i < num_captured_vars; i++)
  37. {
  38. this.captured_vars.Add(new CapturedVariable(reader));
  39. }
  40. int num_captured_scopes = reader.ReadLeb128();
  41. for (int i = 0; i < num_captured_scopes; i++)
  42. {
  43. this.captured_scopes.Add(new CapturedScope(reader));
  44. }
  45. }
  46. internal void AddCapturedVariable(string name, string captured_name, CapturedVariable.CapturedKind kind)
  47. {
  48. this.captured_vars.Add(new CapturedVariable(name, captured_name, kind));
  49. }
  50. internal void AddCapturedScope(int scope, string captured_name)
  51. {
  52. this.captured_scopes.Add(new CapturedScope(scope, captured_name));
  53. }
  54. //internal void Write(MyBinaryWriter bw)
  55. //{
  56. // bw.WriteLeb128(this.ID);
  57. // bw.WriteLeb128(this.captured_vars.Count);
  58. // foreach (CapturedVariable cv in this.captured_vars)
  59. // {
  60. // cv.Write(bw);
  61. // }
  62. // bw.WriteLeb128(this.captured_scopes.Count);
  63. // foreach (CapturedScope cs in this.captured_scopes)
  64. // {
  65. // cs.Write(bw);
  66. // }
  67. //}
  68. public override string ToString()
  69. {
  70. return string.Format("[AnonymousScope {0}]", this.ID);
  71. }
  72. }
  73. }