Keep track of the returned value type as well.
[oota-llvm.git] / include / llvm / SymbolTable.h
index b8fd2e9d691c7af8a1eae06e3d06b53aba4473e3..7e6efe892441fc09a77508227e119971e45c6f20 100644 (file)
@@ -34,7 +34,7 @@ namespace llvm {
 /// There is a TypeMap typedef that is the mapping of names to Types. 
 /// Similarly there is a ValueMap typedef that is the mapping of 
 /// names to Values. Finally, there is a PlaneMap typedef that is the
-/// mapping of types to planes of ValueMap. THis is the basic structure
+/// mapping of types to planes of ValueMap. This is the basic structure
 /// of the symbol table. When you call type_begin() you're asking
 /// for an iterator at the start of the TypeMap. When you call
 /// plane_begin(), you're asking for an iterator at the start of 
@@ -48,7 +48,7 @@ class SymbolTable : public AbstractTypeUser {
 public:
 
   /// @brief A mapping of names to types.
-  typedef std::map<const std::string, Type*> TypeMap;
+  typedef std::map<const std::string, const Type*> TypeMap;
 
   /// @brief An iterator over the TypeMap.
   typedef TypeMap::iterator type_iterator;
@@ -119,7 +119,7 @@ public:
   unsigned type_size(const Type *TypeID) const;
 
   /// @brief The number of name/type pairs is returned.
-  inline unsigned num_types() const { return tmap.size(); }
+  inline unsigned num_types() const { return (unsigned)tmap.size(); }
 
   /// Finds the value \p val in the symbol table and returns its
   /// name. Only the type plane associated with the type of \p val
@@ -159,14 +159,13 @@ public:
     insertEntry(Val->getName(), Val->getType(), Val);
   }
 
-  /// Inserts a constant or type into the symbol table with the specified
-  /// name. There can be a many to one mapping between names and constants
-  /// or types.
+  /// Inserts a constant into the symbol table with the specified
+  /// name. There can be a many to one mapping between names and constants.
   /// @brief Insert a constant or type.
   inline void insert(const std::string &Name, Value *Val) {
     assert(Val && "Can't insert null type into symbol table!");
-    assert((isa<Type>(Val) || isa<Constant>(Val)) &&
-           "Can only insert types and constants into a symbol table!");
+    assert(isa<Constant>(Val) &&
+           "Can only insert constants into a symbol table!");
     insertEntry(Name, Val->getType(), Val);
   }
 
@@ -175,7 +174,7 @@ public:
   /// allows a type with an existing entry in the symbol table to get
   /// a new name.
   /// @brief Insert a type under a new name.
-  inline void insert(const std::string &Name, Type *Typ) {
+  inline void insert(const std::string &Name, const Type *Typ) {
     assert(Typ && "Can't insert null type into symbol table!");
     insertEntry(Name, Typ );
   }
@@ -189,11 +188,11 @@ public:
   void remove(Value* Val);
 
   /// This method removes a named type from the symbol table. The
-  /// name of the type is extracted from \P T and used to look up
+  /// name of the type is extracted from \p T and used to look up
   /// the Type in the type map. If the Type is not in the symbol
   /// table, this method silently ignores the request.
   /// @brief Remove a named type from the symbol table.
-  void remove(Type* Typ );
+  void remove(const Type* Typ );
 
   /// Remove a constant or type with the specified name from the 
   /// symbol table.
@@ -205,11 +204,10 @@ public:
     return removeEntry(PI, PI->second.find(Name));
   }
 
-  /// Remove a type with the specified name from the symbol table.
+  /// Remove a type at the specified position in the symbol table.
   /// @returns the removed Type.
-  /// @brief Remove a named tyep from the symbol table.
-  inline Type* remove(const std::string& Name, Type* T ) {
-    return removeEntry( tmap.find(Name) );
+  inline Type* remove(type_iterator TI) {
+    return removeEntry(TI);
   }
 
   /// Removes a specific value from the symbol table. 
@@ -331,7 +329,7 @@ private:
   void insertEntry(const std::string &Name, const Type *Ty, Value *V);
 
   /// @brief Insert a type into the symbol table with the specified name.
-  void insertEntry(const std::string &Name, Type *T);
+  void insertEntry(const std::string &Name, const Type *T);
 
   /// Remove a specific value from a specific plane in the SymbolTable.
   /// @returns the removed Value.
@@ -357,12 +355,11 @@ private:
   /// separate type planes for named values. That is, each named
   /// value is organized into a separate dictionary based on 
   /// Type. This means that the same name can be used for different
-  /// types without conflict. Note that the Type::TypeTy plane is
-  /// not stored in this map but is in tmap.
+  /// types without conflict. 
   /// @brief The mapping of types to names to values.
   PlaneMap pmap;
 
-  /// This is the Type::TypeTy plane. It is separated from the pmap
+  /// This is the type plane. It is separated from the pmap
   /// because the elements of the map are name/Type pairs not 
   /// name/Value pairs and Type is not a Value.
   TypeMap tmap;