2 using System.Collections;
7 // Keeps track of the namespaces defined in the C# code.
9 public class Namespace {
12 ArrayList using_clauses;
13 bool decl_found = false;
16 // Constructor Takes the current namespace and the
17 // name. This is bootstrapped with parent == null
20 public Namespace (Namespace parent, string name)
27 // The qualified name of the current namespace
31 string pname = parent != null ? parent.Name : "";
36 return parent.Name + "." + name;
41 // The parent of this namespace, used by the parser to "Pop"
42 // the current namespace declaration
44 public Namespace Parent {
51 // When a declaration is found in a namespace,
52 // we call this function, to emit an error if the
53 // program attempts to use a using clause afterwards
55 public void DeclarationFound ()
61 // Records a new namespace for resolving name references
63 public void Using (string ns)
66 CSharpParser.error (1529, "A using clause must precede all other namespace elements");
70 if (using_clauses == null)
71 using_clauses = new ArrayList ();
73 using_clauses.Add (ns);
76 public ArrayList UsingTable {
83 // Used to validate that all the using clauses are correct
84 // after we are finished parsing all the files
86 public void VerifyUsing ()
88 foreach (DictionaryEntry de in using_clauses){
89 if (de.Value == null){
90 string name = (string) de.Key;
92 CSharpParser.error (234, "The type or namespace `" +
93 name + "' does not exist in the " +
94 "class or namespace `" + name + "'");