/// 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
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;
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
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);
}
/// 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 );
}
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.
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.
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.
/// 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;