2003-02-09 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Sun, 9 Feb 2003 22:32:46 +0000 (22:32 -0000)
committerMartin Baulig <martin@novell.com>
Sun, 9 Feb 2003 22:32:46 +0000 (22:32 -0000)
* namespace.cs (Namespace..ctor): Added SourceFile argument.
(Namespace.DefineNamespaces): New static public method; this is
called when we're compiling with debugging to add all namespaces
to the symbol file.

* tree.cs (Tree.RecordNamespace): Added SourceFile argument and
pass it to the Namespace's .ctor.

* symbolwriter.cs (SymbolWriter.OpenMethod): Added TypeContainer
and MethodBase arguments; pass the namespace ID to the symwriter;
pass the MethodBase instead of the token to the symwriter.
(SymbolWriter.DefineNamespace): New method to add a namespace to
the symbol file.

svn path=/trunk/mcs/; revision=11419

mcs/mcs/cs-parser.jay
mcs/mcs/namespace.cs
mcs/mcs/symbolwriter.cs
mcs/mcs/tree.cs

index 37d4e015e43de6b588720293d66986975370874b..ecb46b662ac823ad8be34ef4beb7290c310b87aa 100755 (executable)
@@ -322,7 +322,7 @@ namespace_declaration
                                        RootContext.AddGlobalAttributeSection (current_container, asec);
                }
 
-               current_namespace = RootContext.Tree.RecordNamespace (current_namespace, name, (string) $3);
+               current_namespace = RootContext.Tree.RecordNamespace (current_namespace, file, (string) $3);
        } 
          namespace_body opt_semicolon
          { 
@@ -3925,7 +3925,7 @@ public Tokenizer Lexer {
 
 public CSharpParser (StreamReader reader, SourceFile file, ArrayList defines)
 {
-       current_namespace = new Namespace (null, "");
+       current_namespace = new Namespace (null, file, "");
        this.name = file.Name;
        this.file = file;
        current_container = RootContext.Tree.Types;
index 1d2d18b4c1f463b7d84f70c99f0e3d7e24751c51..74acbf3f0a86b3e6d7dc7dbad4902334a48fa0aa 100755 (executable)
@@ -20,6 +20,8 @@ namespace Mono.CSharp {
                
                Namespace parent;
                string name;
+               SourceFile file;
+               int symfile_id;
                ArrayList using_clauses;
                Hashtable aliases;
                public bool DeclarationFound = false;
@@ -49,9 +51,10 @@ namespace Mono.CSharp {
                ///   name.  This is bootstrapped with parent == null
                ///   and name = ""
                /// </summary>
-               public Namespace (Namespace parent, string name)
+               public Namespace (Namespace parent, SourceFile file, string name)
                {
                        this.name = name;
+                       this.file = file;
                        this.parent = parent;
 
                        all_namespaces.Add (this);
@@ -81,6 +84,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public int SymbolFileID {
+                       get {
+                               return symfile_id;
+                       }
+               }
+
                /// <summary>
                ///   Records a new namespace for resolving name references
                /// </summary>
@@ -143,6 +152,32 @@ namespace Mono.CSharp {
                        return value;
                }
 
+               void DefineNamespace (SymbolWriter symwriter)
+               {
+                       if (symfile_id != 0)
+                               return;
+                       if (parent != null)
+                               parent.DefineNamespace (symwriter);
+
+                       string[] using_list;
+                       if (using_clauses != null) {
+                               using_list = new string [using_clauses.Count];
+                               for (int i = 0; i < using_clauses.Count; i++)
+                                       using_list [i] = ((UsingEntry) using_clauses [i]).Name;
+                       } else {
+                               using_list = new string [0];
+                       }                               
+
+                       int parent_id = parent != null ? parent.symfile_id : 0;
+                       symfile_id = symwriter.DefineNamespace (name, file, using_list, parent_id);
+               }
+
+               public static void DefineNamespaces (SymbolWriter symwriter)
+               {
+                       foreach (Namespace ns in all_namespaces)
+                               ns.DefineNamespace (symwriter);
+               }
+
                /// <summary>
                ///   Used to validate that all the using clauses are correct
                ///   after we are finished parsing all the files.  
index 49466b56d314e055e7d70769d9fa594336ee70bc..a6577e4013c64a5af7fa2b8294a0a766cd1cb656 100644 (file)
@@ -16,6 +16,8 @@ using System.Diagnostics.SymbolStore;
 namespace Mono.CSharp {
        public class SymbolWriter {
                ISymbolWriter symwriter;
+               MethodInfo define_namespace;
+               MethodInfo open_method;
 
                protected SymbolWriter (ISymbolWriter symwriter)
                {
@@ -24,7 +26,21 @@ namespace Mono.CSharp {
 
                bool Initialize ()
                {
+                       Type type = symwriter.GetType ();
+                       define_namespace = type.GetMethod ("DefineNamespace", new Type[] {
+                               typeof (string), typeof (ISymbolDocumentWriter),
+                               typeof (string []), typeof (int) });
+                       if (define_namespace == null)
+                               return false;
+
+                       open_method = type.GetMethod ("OpenMethod", new Type[] {
+                               typeof (ISymbolDocumentWriter), typeof (int), typeof (int),
+                               typeof (int), typeof (int), typeof (MethodBase), typeof (int) });
+                       if (open_method == null)
+                               return false;
+
                        Location.DefineSymbolDocuments (this);
+                       Namespace.DefineNamespaces (this);
 
                        return true;
                }
@@ -36,11 +52,17 @@ namespace Mono.CSharp {
                                SymDocumentType.Text);
                }
 
-               public void OpenMethod (MethodToken token, Location start, Location end)
+               public int DefineNamespace (string name, SourceFile file, string[] using_list, int parent)
+               {
+                       return (int) define_namespace.Invoke (symwriter, new object[] {
+                               name, file.SymbolDocument, using_list, parent });
+               }
+
+               public void OpenMethod (TypeContainer parent, MethodBase method, Location start, Location end)
                {
-                       symwriter.OpenMethod (new SymbolToken (token.Token));
-                       symwriter.SetMethodSourceRange (
-                               start.SymbolDocument, start.Row, 0, end.SymbolDocument, end.Row, 0);
+                       int ns_id = parent.Namespace.SymbolFileID;
+                       open_method.Invoke (symwriter, new object[] {
+                               start.SymbolDocument, start.Row, 0, end.Row, 0, method, ns_id });
                }
 
                public void CloseMethod ()
index 2cf5be8ca5ccd62f38949affa188485e8866f9b0..47b764ff096993c2f3c2aea95eb4e4d1cecf200c 100755 (executable)
@@ -65,9 +65,9 @@ namespace Mono.CSharp
                        decls.Add (name, ds);
                }
                
-               public Namespace RecordNamespace (Namespace parent, string file, string name)
+               public Namespace RecordNamespace (Namespace parent, SourceFile file, string name)
                {
-                       Namespace ns = new Namespace (parent, name);
+                       Namespace ns = new Namespace (parent, file, name);
 
                        if (namespaces.Contains (file)){
                                Hashtable ns_ns = (Hashtable) namespaces [file];