source: translator/SynTree/Declaration.cc @ 0dd3a2f

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 0dd3a2f was 0dd3a2f, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: third groups of files

  • Property mode set to 100644
File size: 1.8 KB
Line 
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 : Peter A. Buhr
12// Last Modified On : Mon May 18 08:18:35 2015
13// Update Count     : 2
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 "utility.h"
23
24const char* Declaration::storageClassName[] = { "", "auto", "static", "extern", "register" }; 
25
26static UniqueId lastUniqueId = 0;
27typedef std::map< UniqueId, Declaration* > IdMapType;
28static IdMapType idMap;
29
30Declaration::Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage )
31        : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 ) {
32}
33
34Declaration::Declaration( const Declaration &other )
35        : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId ) {
36}
37
38Declaration::~Declaration() {
39}
40
41void Declaration::fixUniqueId() {
42        uniqueId = ++lastUniqueId;
43        idMap[ uniqueId ] = this;
44}
45
46/* static class method */
47Declaration *Declaration::declFromId( UniqueId id ) {
48        IdMapType::const_iterator i = idMap.find( id );
49        if ( i != idMap.end() ) {
50                return i->second;
51        } else {
52                return 0;
53        } // if
54}
55
56/* static class method */
57void Declaration::dumpIds( std::ostream &os ) {
58        for ( IdMapType::const_iterator i = idMap.begin(); i != idMap.end(); ++i ) {
59                os << i->first << " -> ";
60                i->second->printShort( os );
61                os << std::endl;
62        } // for
63}
64
65// Local Variables: //
66// tab-width: 4 //
67// mode: c++ //
68// compile-command: "make install" //
69// End: //
Note: See TracBrowser for help on using the repository browser.