source: src/SynTree/Declaration.cc@ 4ab9536

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 4ab9536 was 3906301, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

change constructor warnings into errors and update the test output

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[0dd3a2f]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//
[f9cebb5]7// Declaration.cc --
[0dd3a2f]8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
[8b7ee09]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 18 23:49:57 2016
13// Update Count : 13
[0dd3a2f]14//
[51b73452]15
16#include <string>
17#include <map>
18#include "Declaration.h"
19#include "Expression.h"
20#include "Initializer.h"
21#include "Type.h"
[f9cebb5]22#include "Attribute.h"
[d3b7937]23#include "Common/utility.h"
[51b73452]24
25static UniqueId lastUniqueId = 0;
26typedef std::map< UniqueId, Declaration* > IdMapType;
27static IdMapType idMap;
28
[8b7ee09]29Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage )
[1db21619]30 : name( name ), storageClass( sc ), linkage( linkage ), isInline( false ), isNoreturn( false ), uniqueId( 0 ) {
[51b73452]31}
32
33Declaration::Declaration( const Declaration &other )
[1db21619]34 : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn ), uniqueId( other.uniqueId ) {
[51b73452]35}
36
[0dd3a2f]37Declaration::~Declaration() {
[51b73452]38}
39
[0dd3a2f]40void Declaration::fixUniqueId() {
41 uniqueId = ++lastUniqueId;
42 idMap[ uniqueId ] = this;
[51b73452]43}
44
[0dd3a2f]45Declaration *Declaration::declFromId( UniqueId id ) {
46 IdMapType::const_iterator i = idMap.find( id );
[68cd1ce]47 return i != idMap.end() ? i->second : 0;
[51b73452]48}
49
[0dd3a2f]50void 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
[51b73452]56}
57
[3906301]58std::ostream & operator<<( std::ostream & out, const Declaration * decl ) {
[baf7fee]59 decl->print( out );
60 return out;
61}
62
63
[0dd3a2f]64// Local Variables: //
65// tab-width: 4 //
66// mode: c++ //
67// compile-command: "make install" //
68// End: //
Note: See TracBrowser for help on using the repository browser.