1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // Declaration.cc -- |
---|
8 | // |
---|
9 | // Author : Richard C. Bilson |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Rob Schluntz |
---|
12 | // Last Modified On : Wed Dec 09 14:08:29 2015 |
---|
13 | // Update Count : 12 |
---|
14 | // |
---|
15 | |
---|
16 | #include <string> |
---|
17 | #include <map> |
---|
18 | #include "Declaration.h" |
---|
19 | #include "Expression.h" |
---|
20 | #include "Initializer.h" |
---|
21 | #include "Type.h" |
---|
22 | #include "Attribute.h" |
---|
23 | #include "Common/utility.h" |
---|
24 | |
---|
25 | static UniqueId lastUniqueId = 0; |
---|
26 | typedef std::map< UniqueId, Declaration* > IdMapType; |
---|
27 | static IdMapType idMap; |
---|
28 | |
---|
29 | Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage ) |
---|
30 | : name( name ), storageClass( sc ), linkage( linkage ), isInline( false ), isNoreturn( false ), uniqueId( 0 ) { |
---|
31 | } |
---|
32 | |
---|
33 | Declaration::Declaration( const Declaration &other ) |
---|
34 | : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn ), uniqueId( other.uniqueId ) { |
---|
35 | } |
---|
36 | |
---|
37 | Declaration::~Declaration() { |
---|
38 | } |
---|
39 | |
---|
40 | void Declaration::fixUniqueId() { |
---|
41 | uniqueId = ++lastUniqueId; |
---|
42 | idMap[ uniqueId ] = this; |
---|
43 | } |
---|
44 | |
---|
45 | Declaration *Declaration::declFromId( UniqueId id ) { |
---|
46 | IdMapType::const_iterator i = idMap.find( id ); |
---|
47 | return i != idMap.end() ? i->second : 0; |
---|
48 | } |
---|
49 | |
---|
50 | void Declaration::dumpIds( std::ostream &os ) { |
---|
51 | for ( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) { |
---|
52 | os << i->first << " -> "; |
---|
53 | i->second->printShort( os ); |
---|
54 | os << std::endl; |
---|
55 | } // for |
---|
56 | } |
---|
57 | |
---|
58 | std::ostream & operator<<( std::ostream & out, Declaration * decl ) { |
---|
59 | decl->print( out ); |
---|
60 | return out; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | // Local Variables: // |
---|
65 | // tab-width: 4 // |
---|
66 | // mode: c++ // |
---|
67 | // compile-command: "make install" // |
---|
68 | // End: // |
---|