#include "llvm/Module.h"
#include "Support/StringExtras.h"
#include <algorithm>
+#include <iostream>
using namespace llvm;
Type* SymbolTable::lookupType( const std::string& Name ) const {
type_const_iterator TI = tmap.find( Name );
if ( TI != tmap.end() )
- return TI->second;
+ return const_cast<Type*>(TI->second);
return 0;
}
// Remove a value
void SymbolTable::remove(Value *N) {
assert(N->hasName() && "Value doesn't have name!");
- assert(!isa<Type>(N) && "Can't remove types through this interface.");
if (InternallyInconsistent) return;
plane_iterator PI = pmap.find(N->getType());
Entry != Plane->second.end() && "Invalid entry to remove!");
Value *Result = Entry->second;
- assert(!isa<Type>(Result) && "Can't remove types through this interface.");
#if DEBUG_SYMBOL_TABLE
dump();
std::cerr << " Removing Value: " << Result->getName() << "\n";
// remove - Remove a type
-void SymbolTable::remove(Type* Ty ) {
+void SymbolTable::remove(const Type* Ty ) {
type_iterator TI = this->type_begin();
type_iterator TE = this->type_end();
if (InternallyInconsistent) return 0;
assert( Entry != tmap.end() && "Invalid entry to remove!");
- Type* Result = Entry->second;
+ const Type* Result = Entry->second;
#if DEBUG_SYMBOL_TABLE
dump();
cast<DerivedType>(Result)->removeAbstractTypeUser(this);
}
- return Result;
+ return const_cast<Type*>(Result);
}
// insertEntry - Insert a value into the symbol table with the specified name.
void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
Value *V) {
- assert(!isa<Type>(V) && "Can't insert types through this interface.");
// Check to see if there is a naming conflict. If so, rename this value!
if (lookup(VTy, Name)) {
std::string UniqueName = getUniqueName(VTy, Name);
// insertEntry - Insert a value into the symbol table with the specified
// name...
//
-void SymbolTable::insertEntry(const std::string& Name, Type* T) {
+void SymbolTable::insertEntry(const std::string& Name, const Type* T) {
// Check to see if there is a naming conflict. If so, rename this type!
std::string UniqueName = Name;
// Get the name of a value
std::string SymbolTable::get_name( const Value* V ) const {
- assert(!isa<Type>(V) && "Can't get name of types through this interface.");
value_const_iterator VI = this->value_begin( V->getType() );
value_const_iterator VE = this->value_end( V->getType() );
}
for (type_iterator TI = tmap.begin(); TI != tmap.end(); ) {
- Type* T = (TI++)->second;
+ const Type* T = (TI++)->second;
remove(T);
RemovedSymbol = true;
}
for_each(P.second.begin(), P.second.end(), DumpVal);
}
-static void DumpTypes(const std::pair<const std::string, Type*>& T ) {
+static void DumpTypes(const std::pair<const std::string, const Type*>& T ) {
std::cerr << " '" << T.first << "' = ";
T.second->dump();
std::cerr << "\n";