2006-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / mbas / namespace.cs
1 //
2 // namespace.cs: Tracks namespaces
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.
8 //
9 using System;
10 using System.Collections;
11 using Mono.Languages;
12
13 namespace Mono.MonoBASIC {
14
15         /// <summary>
16         ///   Keeps track of the namespaces defined in the C# code.
17         /// </summary>
18         public class Namespace {
19                 static ArrayList all_namespaces = new ArrayList ();
20                 
21                 Namespace parent;
22                 string name;
23                                 
24                 /// <summary>
25                 ///   Constructor Takes the current namespace and the
26                 ///   name.  This is bootstrapped with parent == null
27                 ///   and name = ""
28                 /// </summary>
29                 public Namespace (Namespace parent, string name)
30                 {
31                         this.name = name;
32                         this.parent = parent;
33
34                         all_namespaces.Add (this);
35                 }
36
37                 /// <summary>
38                 ///   The qualified name of the current namespace
39                 /// </summary>
40                 public string Name {
41                         get {
42                                 string pname = parent != null ? parent.Name : "";
43                                 
44                                 if (pname == "")
45                                         return name;
46                                 else
47                                         return parent.Name + "." + name;
48                         }
49                 }
50
51                 /// <summary>
52                 ///   The parent of this namespace, used by the parser to "Pop"
53                 ///   the current namespace declaration
54                 /// </summary>
55                 public Namespace Parent {
56                         get {
57                                 return parent;
58                         }
59                 }
60                 
61                 /// <summary>
62                 ///   Show the qualified name of the namespace contained here
63                 /// </summary>
64                 public override string ToString() {
65                         return Name;
66                 }
67                 
68         }
69 }