X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Flocation.cs;h=72c4485aef9b64a36c201067ee46a134cd542dde;hb=e9e273a33bb56653d40b19455396c382a7da3e2b;hp=4b598528c9a32eb292984a0b1361848b0959b5c3;hpb=ffe4df2dfaeb0a14978ed0141a88b0ee0bfd5bd0;p=mono.git diff --git a/mcs/mcs/location.cs b/mcs/mcs/location.cs index 4b598528c9a..72c4485aef9 100644 --- a/mcs/mcs/location.cs +++ b/mcs/mcs/location.cs @@ -8,7 +8,9 @@ // using System; +using System.IO; using System.Collections; +using System.Diagnostics.SymbolStore; namespace Mono.CSharp { /// @@ -26,18 +28,23 @@ namespace Mono.CSharp { public int token; static Hashtable map; + static Hashtable sym_docs; static ArrayList list; static int global_count; static int module_base; + public readonly static Location Null; + static Location () { map = new Hashtable (); list = new ArrayList (); + sym_docs = new Hashtable (); global_count = 0; module_base = 0; + Null.token = -1; } - + static public void Push (string name) { map.Remove (global_count); @@ -70,12 +77,6 @@ namespace Mono.CSharp { return l.token == -1; } - static public Location Null { - get { - return new Location (-1); - } - } - public string Name { get { int best = 0; @@ -105,5 +106,49 @@ namespace Mono.CSharp { return token - best; } } + + // The ISymbolDocumentWriter interface is used by the symbol writer to + // describe a single source file - for each source file there's exactly + // one corresponding ISymbolDocumentWriter instance. + // + // This class has an internal hash table mapping source document names + // to such ISymbolDocumentWriter instances - so there's exactly one + // instance per document. + // + // This property returns the ISymbolDocumentWriter instance which belongs + // to the location's source file. + // + // If we don't have a symbol writer, this property is always null. + public ISymbolDocumentWriter SymbolDocument { + get { + ISymbolWriter sw = CodeGen.SymbolWriter; + ISymbolDocumentWriter doc; + + if (token < 0) + return null; + + // If we don't have a symbol writer, return null. + if (sw == null) + return null; + + string path = Path.GetFullPath (Name); + + if (sym_docs.Contains (path)) + // If we already created an ISymbolDocumentWriter + // instance for this document, return it. + doc = (ISymbolDocumentWriter) sym_docs [path]; + else { + // Create a new ISymbolDocumentWriter instance and + // store it in the hash table. + doc = sw.DefineDocument (path, SymLanguageType.CSharp, + SymLanguageVendor.Microsoft, + SymDocumentType.Text); + + sym_docs.Add (path, doc); + } + + return doc; + } + } } }