/* * This file is part of the Cforall project * * $Id: Declaration.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $ * */ #include #include #include "Declaration.h" #include "Expression.h" #include "Initializer.h" #include "Type.h" #include "utility.h" const char* Declaration::storageClassName[] = { "", "auto", "static", "extern", "register" }; static UniqueId lastUniqueId = 0; typedef std::map< UniqueId, Declaration* > IdMapType; static IdMapType idMap; Declaration::Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage ) : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 ) { } Declaration::Declaration( const Declaration &other ) : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId ) { } Declaration::~Declaration() { } void Declaration::fixUniqueId() { uniqueId = ++lastUniqueId; idMap[ uniqueId ] = this; } /* static class method */ Declaration * Declaration::declFromId( UniqueId id ) { IdMapType::const_iterator i = idMap.find( id ); if ( i != idMap.end() ) { return i->second; } else { return 0; } } /* static class method */ void Declaration::dumpIds( std::ostream &os ) { for ( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) { os << i->first << " -> "; i->second->printShort( os ); os << std::endl; } }