source: translator/SynTree/Declaration.cc @ 42dcae7

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 42dcae7 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: Declaration.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
5 *
6 */
7
8#include <string>
9#include <map>
10#include "Declaration.h"
11#include "Expression.h"
12#include "Initializer.h"
13#include "Type.h"
14#include "utility.h"
15
16
17const char* Declaration::storageClassName[] = { "", "auto", "static", "extern", "register" }; 
18
19static UniqueId lastUniqueId = 0;
20typedef std::map< UniqueId, Declaration* > IdMapType;
21static IdMapType idMap;
22
23Declaration::Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage )
24    : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 )
25{
26}
27
28Declaration::Declaration( const Declaration &other )
29    : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId )
30{
31}
32
33Declaration::~Declaration()
34{
35}
36
37void
38Declaration::fixUniqueId()
39{
40    uniqueId = ++lastUniqueId;
41    idMap[ uniqueId ] = this;
42}
43
44/* static class method */
45Declaration *
46Declaration::declFromId( UniqueId id )
47{
48    IdMapType::const_iterator i = idMap.find( id );
49    if( i != idMap.end() ) {
50        return i->second;
51    } else {
52        return 0;
53    }
54}
55
56/* static class method */
57void 
58Declaration::dumpIds( std::ostream &os )
59{
60    for( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) {
61        os << i->first << " -> ";
62        i->second->printShort( os );
63        os << std::endl;
64    }
65}
66
Note: See TracBrowser for help on using the repository browser.