* 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
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
{
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;
Namespace parent;
string name;
+ SourceFile file;
+ int symfile_id;
ArrayList using_clauses;
Hashtable aliases;
public bool DeclarationFound = false;
/// 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);
}
}
+ public int SymbolFileID {
+ get {
+ return symfile_id;
+ }
+ }
+
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
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.
namespace Mono.CSharp {
public class SymbolWriter {
ISymbolWriter symwriter;
+ MethodInfo define_namespace;
+ MethodInfo open_method;
protected SymbolWriter (ISymbolWriter symwriter)
{
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;
}
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 ()
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];