X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSymbolTable.h;h=7e13402064971e37310eecf4789c8d5089345509;hb=d5d96b9fcd779806555cf5db602f80d5a308a471;hp=ee53f6d5a34f7371d022c73eb656ce5ac47beaf3;hpb=e638c10cb0fd3e5e50e0eec226367eba861eba0f;p=oota-llvm.git diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index ee53f6d5a34..7e134020649 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -1,4 +1,4 @@ -//===-- llvm/SymbolTable.h - Implement a type planned 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 @@ -9,7 +9,7 @@ // searched. // // This chaining behavior does NOT affect iterators though: only the lookup -// method +// method. // //===----------------------------------------------------------------------===// @@ -19,39 +19,21 @@ #include "llvm/Value.h" #include -#ifndef NDEBUG // Only for assertions -#include "llvm/Type.h" -#include "llvm/ConstPoolVals.h" -#endif - -class Type; - class SymbolTable : public AbstractTypeUser, - public map > { + public std::map > { public: - typedef map VarMap; - typedef map super; -private: - - SymbolTable *ParentSymTab; + typedef std::map VarMap; + typedef std::map super; - 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 string &name); + Value *lookup(const Type *Ty, const std::string &name); // insert - Add named definition to the symbol table... inline void insert(Value *N) { @@ -59,26 +41,33 @@ public: 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. // - inline void insert(const string &Name, Value *V) { - assert((isa(V) || isa(V)) && + inline void insert(const std::string &Name, Value *V) { + assert((isa(V) || isa(V)) && "Can only insert types and constants here!"); 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 // it (or derived from it) that does not already occur in the symbol table for // the specified type. // - string getUniqueName(const Type *Ty, const string &BaseName); + std::string getUniqueName(const Type *Ty, const std::string &BaseName); inline unsigned type_size(const Type *TypeID) const { return find(TypeID)->second.size(); @@ -121,7 +110,7 @@ private: // insertEntry - Insert a value into the symbol table with the specified // name... // - void insertEntry(const string &Name, const Type *Ty, Value *V); + void insertEntry(const std::string &Name, const Type *Ty, Value *V); // removeEntry - Remove a value from the symbol table... // @@ -129,6 +118,7 @@ private: // 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