2002-09-19 Martin Baulig <martin@gnome.org>
[mono.git] / mcs / mcs / location.cs
index 7669eba633440e66e5c68f3b8f16ef14774d2ecc..72c4485aef9b64a36c201067ee46a134cd542dde 100644 (file)
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.IO;
 using System.Collections;
 using System.Diagnostics.SymbolStore;
 
@@ -32,6 +33,8 @@ namespace Mono.CSharp {
                static int global_count;
                static int module_base;
 
+               public readonly static Location Null;
+               
                static Location ()
                {
                        map = new Hashtable ();
@@ -39,9 +42,9 @@ namespace Mono.CSharp {
                        sym_docs = new Hashtable ();
                        global_count = 0;
                        module_base = 0;
-
+                       Null.token = -1;
                }
-       
+
                static public void Push (string name)
                {
                        map.Remove (global_count);
@@ -74,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;
@@ -124,25 +121,30 @@ namespace Mono.CSharp {
                // If we don't have a symbol writer, this property is always null.
                public ISymbolDocumentWriter SymbolDocument {
                        get {
-                               ISymbolWriter sw = RootContext.CodeGen.SymbolWriter;
+                               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;
 
-                               if (sym_docs.Contains (Name))
+                               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 [Name];
+                                       doc = (ISymbolDocumentWriter) sym_docs [path];
                                else {
                                        // Create a new ISymbolDocumentWriter instance and
                                        // store it in the hash table.
-                                       doc = sw.DefineDocument (Name, SymLanguageType.CSharp,
+                                       doc = sw.DefineDocument (path, SymLanguageType.CSharp,
                                                                 SymLanguageVendor.Microsoft,
                                                                 SymDocumentType.Text);
 
-                                       sym_docs.Add (Name, doc);
+                                       sym_docs.Add (path, doc);
                                }
 
                                return doc;