-//===-- llvm/SymbolTable.h - Implement a type plane'd symtab ------*- C++ -*-=//
+//===-- llvm/SymbolTable.h - Implement a type plane'd symtab ----*- C++ -*-===//
//
// This file implements a symbol table that has planed broken up by type.
// Identical types may have overlapping symbol names as long as they are
// searched.
//
// This chaining behavior does NOT affect iterators though: only the lookup
-// method
+// method.
//
//===----------------------------------------------------------------------===//
#include "llvm/Value.h"
#include <map>
-#ifndef NDEBUG // Only for assertions
-#include "llvm/Type.h"
-#include "llvm/ConstantVals.h"
-#endif
-
-class Type;
-
class SymbolTable : public AbstractTypeUser,
public std::map<const Type *,
std::map<const std::string, Value *> > {
public:
typedef std::map<const std::string, Value *> VarMap;
typedef std::map<const Type *, VarMap> super;
-private:
-
- SymbolTable *ParentSymTab;
- friend class SymTabValue;
- inline void setParentSymTab(SymbolTable *P) { ParentSymTab = P; }
-
-public:
typedef VarMap::iterator type_iterator;
typedef VarMap::const_iterator type_const_iterator;
- inline SymbolTable(SymbolTable *P = 0) {
- ParentSymTab = P;
- InternallyInconsistent = false;
- }
+ inline SymbolTable() : InternallyInconsistent(false) {}
~SymbolTable();
- SymbolTable *getParentSymTab() { return ParentSymTab; }
-
// lookup - Returns null on failure...
Value *lookup(const Type *Ty, const std::string &name);
insertEntry(N->getName(), N->getType(), N);
}
+ void remove(Value *N);
+ Value *type_remove(const type_iterator &It) {
+ return removeEntry(find(It->second->getType()), It);
+ }
+
// insert - Insert a constant or type into the symbol table with the specified
// name... There can be a many to one mapping between names and
// (constant/type)s.
insertEntry(Name, V->getType(), V);
}
- void remove(Value *N);
- Value *type_remove(const type_iterator &It) {
- return removeEntry(find(It->second->getType()), It);
+ /// remove - Remove a constant or type from the symbol table with the
+ /// specified name.
+ Value *remove(const std::string &Name, Value *V) {
+ iterator TI = find(V->getType());
+ return removeEntry(TI, TI->second.find(Name));
}
// getUniqueName - Given a base name, return a string that is either equal to
// This function is called when one of the types in the type plane are refined
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
+ virtual void typeBecameConcrete(const DerivedType *AbsTy);
};
#endif