SymbolWriterImpl.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //using System;
  2. //using System.Collections;
  3. //using System.Diagnostics.SymbolStore;
  4. //using System.Reflection;
  5. //using System.Text;
  6. //namespace Mono.CompilerServices.SymbolWriter
  7. //{
  8. // public class SymbolWriterImpl : ISymbolWriter
  9. // {
  10. // private MonoSymbolWriter msw;
  11. // private int nextLocalIndex;
  12. // private int currentToken;
  13. // private string methodName;
  14. // private Stack namespaceStack = new Stack();
  15. // private bool methodOpened;
  16. // private Hashtable documents = new Hashtable();
  17. // private Guid guid;
  18. // public SymbolWriterImpl(Guid guid)
  19. // {
  20. // this.guid = guid;
  21. // }
  22. // public void Close()
  23. // {
  24. // this.msw.WriteSymbolFile(this.guid);
  25. // }
  26. // public void CloseMethod()
  27. // {
  28. // if (this.methodOpened)
  29. // {
  30. // this.methodOpened = false;
  31. // this.nextLocalIndex = 0;
  32. // this.msw.CloseMethod();
  33. // }
  34. // }
  35. // public void CloseNamespace()
  36. // {
  37. // this.namespaceStack.Pop();
  38. // this.msw.CloseNamespace();
  39. // }
  40. // public void CloseScope(int endOffset)
  41. // {
  42. // this.msw.CloseScope(endOffset);
  43. // }
  44. // public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType)
  45. // {
  46. // SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl)this.documents[url];
  47. // if (doc == null)
  48. // {
  49. // SourceFileEntry entry = this.msw.DefineDocument(url);
  50. // CompileUnitEntry comp_unit = this.msw.DefineCompilationUnit(entry);
  51. // doc = new SymbolDocumentWriterImpl(comp_unit);
  52. // this.documents[url] = doc;
  53. // }
  54. // return doc;
  55. // }
  56. // public void DefineField(SymbolToken parent, string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
  57. // {
  58. // }
  59. // public void DefineGlobalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3)
  60. // {
  61. // }
  62. // public void DefineLocalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset)
  63. // {
  64. // this.msw.DefineLocalVariable(this.nextLocalIndex++, name);
  65. // }
  66. // public void DefineParameter(string name, ParameterAttributes attributes, int sequence, SymAddressKind addrKind, int addr1, int addr2, int addr3)
  67. // {
  68. // }
  69. // public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns)
  70. // {
  71. // SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl)document;
  72. // SourceFileEntry file = (doc != null) ? doc.Entry.SourceFile : null;
  73. // for (int i = 0; i < offsets.Length; i++)
  74. // {
  75. // if (i <= 0 || offsets[i] != offsets[i - 1] || lines[i] != lines[i - 1] || columns[i] != columns[i - 1])
  76. // {
  77. // this.msw.MarkSequencePoint(offsets[i], file, lines[i], columns[i], false);
  78. // }
  79. // }
  80. // }
  81. // public void Initialize(IntPtr emitter, string filename, bool fFullBuild)
  82. // {
  83. // this.msw = new MonoSymbolWriter(filename);
  84. // }
  85. // public void OpenMethod(SymbolToken method)
  86. // {
  87. // this.currentToken = method.GetToken();
  88. // }
  89. // public void OpenNamespace(string name)
  90. // {
  91. // NamespaceInfo i = new NamespaceInfo();
  92. // i.NamespaceID = -1;
  93. // i.Name = name;
  94. // this.namespaceStack.Push(i);
  95. // }
  96. // public int OpenScope(int startOffset)
  97. // {
  98. // return this.msw.OpenScope(startOffset);
  99. // }
  100. // public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn)
  101. // {
  102. // int nsId = this.GetCurrentNamespace(startDoc);
  103. // SourceMethodImpl sm = new SourceMethodImpl(this.methodName, this.currentToken, nsId);
  104. // this.msw.OpenMethod(((ICompileUnit)startDoc).Entry, nsId, sm);
  105. // this.methodOpened = true;
  106. // }
  107. // public void SetScopeRange(int scopeID, int startOffset, int endOffset)
  108. // {
  109. // }
  110. // public void SetSymAttribute(SymbolToken parent, string name, byte[] data)
  111. // {
  112. // if (name == "__name")
  113. // {
  114. // this.methodName = Encoding.UTF8.GetString(data);
  115. // }
  116. // }
  117. // public void SetUnderlyingWriter(IntPtr underlyingWriter)
  118. // {
  119. // }
  120. // public void SetUserEntryPoint(SymbolToken entryMethod)
  121. // {
  122. // }
  123. // public void UsingNamespace(string fullName)
  124. // {
  125. // if (this.namespaceStack.Count == 0)
  126. // {
  127. // this.OpenNamespace("");
  128. // }
  129. // NamespaceInfo ni = (NamespaceInfo)this.namespaceStack.Peek();
  130. // if (ni.NamespaceID != -1)
  131. // {
  132. // NamespaceInfo old = ni;
  133. // this.CloseNamespace();
  134. // this.OpenNamespace(old.Name);
  135. // ni = (NamespaceInfo)this.namespaceStack.Peek();
  136. // ni.UsingClauses = old.UsingClauses;
  137. // }
  138. // ni.UsingClauses.Add(fullName);
  139. // }
  140. // private int GetCurrentNamespace(ISymbolDocumentWriter doc)
  141. // {
  142. // if (this.namespaceStack.Count == 0)
  143. // {
  144. // this.OpenNamespace("");
  145. // }
  146. // NamespaceInfo ni = (NamespaceInfo)this.namespaceStack.Peek();
  147. // if (ni.NamespaceID == -1)
  148. // {
  149. // string[] usings = (string[])ni.UsingClauses.ToArray(typeof(string));
  150. // int parentId = 0;
  151. // if (this.namespaceStack.Count > 1)
  152. // {
  153. // this.namespaceStack.Pop();
  154. // parentId = ((NamespaceInfo)this.namespaceStack.Peek()).NamespaceID;
  155. // this.namespaceStack.Push(ni);
  156. // }
  157. // ni.NamespaceID = this.msw.DefineNamespace(ni.Name, ((ICompileUnit)doc).Entry, usings, parentId);
  158. // }
  159. // return ni.NamespaceID;
  160. // }
  161. // }
  162. //}