VarMap.h
00001 /*
00002  * VarMap.h
00003  *
00004  *  Created on: Sep 1, 2008
00005  *      Author: tdillig
00006  */
00007 
00008 #ifndef VARMAP_H_
00009 #define VARMAP_H_
00010 
00011 #include <map>
00012 #include <unordered_map>
00013 #include <string>
00014 #include <set>
00015 using namespace std;
00016 
00017 
00018 #define NUM_BITS_RESERVED 5
00019 
00020 
00021 namespace il{
00022         class type;
00023 }
00024 namespace sail{
00025         class Variable;
00026 }
00027 
00028 class Term;
00029 class CNode;
00030 
00031 /*
00032  * Since string's can take too much space, we associate every
00033  * variable or function with a unique identifier. VarMap is needed
00034  * for pretty printing.
00035  */
00036 class VarMap {
00037 private:
00038         unordered_map<string, int> name_to_id_map;
00039         unordered_map<int, string> id_to_name_map;
00040         int cur_id;
00041 public:
00042         VarMap();
00043         int get_id(string name, bool invertible=false);
00044         int get_attrib(int id);
00045         string get_name(int id);
00046         bool contains_name(string name);
00047         void get_all_vars(set<string>& var_names);
00048         virtual ~VarMap();
00049         void clear();
00050 
00051 };
00052 
00053 #endif /* VARMAP_H_ */