**** Merged from MCS ****
[mono.git] / mcs / gmcs / location.cs
index 556ada1fc47c34edef90354e44059224a48e1e75..035de4841e5ea438a8ccd4ce92ae87430738153a 100644 (file)
@@ -10,7 +10,7 @@
 using System;
 using System.IO;
 using System.Collections;
-using System.Diagnostics.SymbolStore;
+using Mono.CompilerServices.SymbolWriter;
 
 namespace Mono.CSharp {
        /// <summary>
@@ -20,11 +20,11 @@ namespace Mono.CSharp {
        ///   This is intentionally a class and not a struct since we need
        ///   to pass this by reference.
        /// </remarks>
-       public sealed class SourceFile {
+       public sealed class SourceFile : ISourceFile {
                public readonly string Name;
                public readonly string Path;
                public readonly int Index;
-               public ISymbolDocumentWriter SymbolDocument;
+               public SourceFileEntry SourceFileEntry;
                public bool HasLineDirective;
 
                public SourceFile (string name, string path, int index)
@@ -33,6 +33,16 @@ namespace Mono.CSharp {
                        this.Name = name;
                        this.Path = path;
                }
+
+               SourceFileEntry ISourceFile.Entry {
+                       get { return SourceFileEntry; }
+               }
+
+               public override string ToString ()
+               {
+                       return String.Format ("SourceFile ({0}:{1}:{2}:{3})",
+                                             Name, Path, Index, SourceFileEntry);
+               }
        }
 
        /// <summary>
@@ -74,10 +84,8 @@ namespace Mono.CSharp {
                        string path = Path.GetFullPath (name);
 
                        if (source_files.Contains (path)){
-                               Report.Error (
-                                       1516,
-                                       "Source file `" + name + "' specified multiple times");
-                               Environment.Exit (1);
+                               Report.Warning (2002, name, "Source file '{0}' specified multiple times");
+                               return;
                        }
 
                        source_files.Add (path, ++source_count);
@@ -142,15 +150,14 @@ namespace Mono.CSharp {
                }
 
                // <remarks>
-               //   If we're compiling with debugging support, this is called between parsing and
-               //   code generation to register all the source files with the symbol writer.           //
+               //   If we're compiling with debugging support, this is called between parsing
+               //   and code generation to register all the source files with the
+               //   symbol writer.
                // </remarks>
                static public void DefineSymbolDocuments (SymbolWriter symwriter)
                {
                        foreach (SourceFile file in source_list) {
-                               if (file.HasLineDirective)
-                                       continue;
-                               file.SymbolDocument = symwriter.DefineDocument (file.Path);
+                               file.SourceFileEntry = symwriter.DefineDocument (file.Path);
                        }
                }
                
@@ -213,13 +220,12 @@ namespace Mono.CSharp {
                // to the location's source file.
                //
                // If we don't have a symbol writer, this property is always null.
-               public ISymbolDocumentWriter SymbolDocument {
+               public SourceFile SourceFile {
                        get {
                                int index = token & source_mask;
                                if (index == 0)
                                        return null;
-                               SourceFile file = (SourceFile) source_list [index - 1];
-                               return file.SymbolDocument;
+                               return (SourceFile) source_list [index - 1];
                        }
                }
        }