2 // location.cs: Keeps track of the location of source code entity
7 // (C) 2001 Ximian, Inc.
11 using System.Collections;
13 namespace Mono.CSharp {
15 /// Keeps track of the location in the program
19 /// This uses a compact representation and a couple of auxiliary
20 /// structures to keep track of tokens to (file,line) mappings.
22 /// We could probably also keep track of columns by storing those
23 /// in 8 bits (and say, map anything after char 255 to be `255+').
25 public struct Location {
29 static ArrayList list;
30 static int global_count;
31 static int module_base;
35 map = new Hashtable ();
36 list = new ArrayList ();
41 static public void Push (string name)
43 map.Remove (global_count);
44 map.Add (global_count, name);
45 list.Add (global_count);
46 module_base = global_count;
49 public Location (int row)
54 token = module_base + row;
55 if (global_count < token)
60 public override string ToString ()
62 return Name + ": (" + Row + ")";
66 /// Whether the Location is Null
68 static public bool IsNull (Location l)
73 static public Location Null {
75 return new Location (-1);
86 foreach (int b in list){
90 return (string) map [best];
101 foreach (int b in list){