2 // ExecutionContext.cs: The stack of possible executions environments.
7 // (C) 2003, Cesar Lopez Nataren
10 using System.Collections;
13 namespace Microsoft.JScript {
15 internal class IdentificationTable {
19 internal IdentificationTable ()
22 stack.Push (new SymbolTable (null));
25 internal void OpenBlock ()
27 System.Console.WriteLine ("IdTable::OpenBlock");
29 SymbolTable parent = (SymbolTable) stack.Peek ();
30 stack.Push (new SymbolTable (parent));
33 internal void CloseBlock ()
35 System.Console.WriteLine ("IdTable::CloseBlock");
39 internal void Enter (string id, object decl)
41 ((SymbolTable) stack.Peek ()).Add (id , decl);
42 System.Console.WriteLine ("IdentificationTable::Enter::{0}", id);
45 internal AST Retrieve (string id)
47 return ((SymbolTable) stack.Peek ()).Retrieve (id);
50 internal bool Contains (string id)
52 SymbolTable parent, current_scope = (SymbolTable) stack.Peek ();
53 bool found = current_scope.Contains (id);
58 parent = current_scope.parent;
61 found = parent.Contains (id);
66 public override string ToString ()
68 StringBuilder sb = new StringBuilder ();
70 int i, size = stack.Count;
72 for (i = 0; i < size; i++)
73 sb.Append (stack.Pop ().ToString ());
75 return sb.ToString ();