Polaris: DefLocMap.h Source File

DefLocMap.h

Go to the documentation of this file.
00001 ///
00002 ///
00003 /// file DefLocMap.h
00004 ///
00005 #ifndef DEF_LOC_MAP_H
00006 #define DEF_LOC_MAP_H
00007 ///
00008 /// \class DefLocMap 
00009 /// \brief Map of DefLocs
00010 /// \defgroup Polaris
00011 /// \ingroup Polaris
00012 ///  C++ VDL
00013 /// \see DefLocMap.h
00014 /// \see DefLocMap.h
00015 /// \see DefLocMap.cc
00016 ///
00017 /// \endcode
00018 /// \section Description Description
00019 /// DefLocMap is a map for DefLocs which includes
00020 /// code to support ProgramUnit cloning
00021 ///
00022 #ifdef POLARIS_GNU_PRAGMAS
00023 #pragma interface
00024 #endif
00025 ///
00026 #include "ClassNames.h"
00027 #include "DefLoc.h"
00028 #include "Collection/Map.h"
00029 #include "Symbol/Symbol.h"
00030 ///
00031 class DefLocMap : public Listable {
00032 
00033   friend ostream & operator << (ostream & o, DefLocMap & map);
00034   friend DefLocMap * MakeDefMap(ProgramUnit & pgm);
00035   
00036 
00037 private:
00038   Map<Symbol,DefLoc> _map;
00039 
00040 public:
00041   inline DefLocMap();
00042 
00043   inline DefLocMap(const DefLocMap & map);
00044   DefLocMap(const DefLocMap & map, const ProgramUnit & new_main_pgm);
00045   virtual inline ~DefLocMap();
00046 
00047   inline DefLocMap & operator = (const DefLocMap & map);
00048   
00049   inline const DefLoc *find_ref(const Symbol & key) const;
00050   inline DefLoc *find_ref(const Symbol & key);
00051 
00052   inline const DefLoc & operator[] (const Symbol & key) const;
00053   inline DefLoc & operator[] (const Symbol & key);
00054 
00055   void remove_invalid_defloc(Symbol& sym);
00056 
00057   inline KeyIterator<Symbol,DefLoc> iterator() const;
00058 
00059   virtual DefLocMap *clone() const;
00060   virtual Listable  *listable_clone() const;
00061   virtual int structures_OK() const;
00062   virtual void print(ostream & o) const;
00063 };
00064 
00065 inline 
00066 DefLocMap::DefLocMap()
00067 {
00068     #ifdef CLASS_INSTANCE_REGISTRY
00069     register_instance(DEFLOC_MAP, sizeof(DefLocMap), this);
00070     #endif
00071 }
00072 
00073 inline
00074 DefLocMap::~DefLocMap()
00075 {
00076     #ifdef CLASS_INSTANCE_REGISTRY
00077     unregister_instance(DEFLOC_MAP, this);
00078     #endif
00079 }
00080 
00081 inline
00082 DefLocMap::DefLocMap(const DefLocMap & map)
00083   : _map(map._map)
00084 {
00085     #ifdef CLASS_INSTANCE_REGISTRY
00086     register_instance(DEFLOC_MAP, sizeof(DefLocMap), this);
00087     #endif
00088 }
00089 
00090 inline DefLocMap &
00091 DefLocMap::operator = (const DefLocMap & map)
00092 {
00093   _map.clear();
00094   _map = map._map;
00095   return *this;
00096 }
00097 
00098 inline const DefLoc *
00099 DefLocMap::find_ref(const Symbol & key) const
00100 {
00101   return _map.find_ref(key);
00102 }
00103 
00104 inline DefLoc *
00105 DefLocMap::find_ref(const Symbol & key)
00106 {
00107   return _map.find_ref(key);
00108 }
00109 
00110 inline const DefLoc &
00111 DefLocMap::operator[] (const Symbol & key) const
00112 {
00113   return _map[key];
00114 }
00115 
00116 inline DefLoc &
00117 DefLocMap::operator[] (const Symbol & key)
00118 {
00119   return _map[key];
00120 }
00121 
00122 inline KeyIterator<Symbol,DefLoc>
00123 DefLocMap::iterator() const
00124 {
00125   return (KeyIterator<Symbol,DefLoc>) _map;
00126 }
00127 
00128 inline void DefLocMap::
00129 remove_invalid_defloc(Symbol& sym)
00130 {
00131   _map.del(sym);
00132 }
00133 
00134 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:44 2005