Remove unneeded #include
[oota-llvm.git] / include / llvm / SymbolTable.h
index 8085101204be1cea4adb9d8a04cdb19100eacce6..22a9acd438ce9a2c177f29d7b14dda2907b5cdc3 100644 (file)
@@ -1,6 +1,13 @@
-//===-- llvm/SymbolTable.h - Implement a type plane'd symtab ------*- C++ -*-=//
+//===-- llvm/SymbolTable.h - Implement a type plane'd symtab ----*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
 //
-// This file implements a symbol table that has planed broken up by type.  
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
+//
+// This file implements a symbol table that has planes broken up by type.  
 // Identical types may have overlapping symbol names as long as they are 
 // distinct.
 //
@@ -9,7 +16,7 @@
 // searched.
 //
 // This chaining behavior does NOT affect iterators though: only the lookup 
-// method
+// method.
 //
 //===----------------------------------------------------------------------===//
 
 #define LLVM_SYMBOL_TABLE_H
 
 #include "llvm/Value.h"
-#include "llvm/Type.h"              // FIXME: Remove
-#include "llvm/ConstantVals.h"      // FIXME: Remove
 #include <map>
 
+namespace llvm {
+
 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), LastUnique(0) {}
   ~SymbolTable();
 
-  SymbolTable *getParentSymTab() { return ParentSymTab; }
-
   // lookup - Returns null on failure...
-  Value *lookup(const Type *Ty, const std::string &name);
-
-  // localLookup - Look in this symbol table without falling back on parent,
-  // if non-existing.  Returns null on failure...
-  //
-  Value *localLookup(const Type *Ty, const std::string &name);
+  Value *lookup(const Type *Ty, const std::string &name) const;
 
   // insert - Add named definition to the symbol table...
   inline void insert(Value *N) {
@@ -60,6 +50,11 @@ 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.
@@ -70,9 +65,11 @@ public:
     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
@@ -114,6 +111,10 @@ private:
   //
   bool InternallyInconsistent;
 
+  // LastUnique - This value is used to retain the last unique value used
+  // by getUniqueName to generate unique names.
+  unsigned long LastUnique;
+
   inline super::value_type operator[](const Type *Ty) {
     assert(0 && "Should not use this operator to access symbol table!");
     return super::value_type();
@@ -130,6 +131,9 @@ 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);
 };
 
+} // End llvm namespace
+
 #endif