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 | // AggregateDecl.cc -- |
---|
8 | // |
---|
9 | // Author : Richard C. Bilson |
---|
10 | // Created On : Sun May 17 23:56:39 2015 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Fri Aug 4 14:22:00 2017 |
---|
13 | // Update Count : 22 |
---|
14 | // |
---|
15 | |
---|
16 | #include "Declaration.h" |
---|
17 | #include "Attribute.h" |
---|
18 | #include "Type.h" |
---|
19 | #include "Common/utility.h" |
---|
20 | |
---|
21 | |
---|
22 | AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) { |
---|
23 | } |
---|
24 | |
---|
25 | AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) { |
---|
26 | cloneAll( other.members, members ); |
---|
27 | cloneAll( other.parameters, parameters ); |
---|
28 | cloneAll( other.attributes, attributes ); |
---|
29 | body = other.body; |
---|
30 | } |
---|
31 | |
---|
32 | AggregateDecl::~AggregateDecl() { |
---|
33 | deleteAll( attributes ); |
---|
34 | deleteAll( parameters ); |
---|
35 | deleteAll( members ); |
---|
36 | } |
---|
37 | |
---|
38 | void AggregateDecl::print( std::ostream &os, int indent ) const { |
---|
39 | using std::string; |
---|
40 | using std::endl; |
---|
41 | |
---|
42 | os << typeString() << " " << get_name() << ":"; |
---|
43 | if ( get_linkage() != LinkageSpec::Cforall ) { |
---|
44 | os << " " << LinkageSpec::linkageName( get_linkage() ); |
---|
45 | } // if |
---|
46 | os << " with body " << has_body() << endl; |
---|
47 | |
---|
48 | if ( ! parameters.empty() ) { |
---|
49 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl; |
---|
50 | printAll( parameters, os, indent+4 ); |
---|
51 | } // if |
---|
52 | if ( ! members.empty() ) { |
---|
53 | os << endl << string( indent+2, ' ' ) << "with members" << endl; |
---|
54 | printAll( members, os, indent+4 ); |
---|
55 | } // if |
---|
56 | if ( ! attributes.empty() ) { |
---|
57 | os << endl << string( indent+2, ' ' ) << "with attributes" << endl; |
---|
58 | printAll( attributes, os, indent+4 ); |
---|
59 | } // if |
---|
60 | } |
---|
61 | |
---|
62 | void AggregateDecl::printShort( std::ostream &os, int indent ) const { |
---|
63 | using std::string; |
---|
64 | using std::endl; |
---|
65 | |
---|
66 | os << typeString() << " " << get_name(); |
---|
67 | os << string( indent+2, ' ' ) << "with body " << has_body() << endl; |
---|
68 | |
---|
69 | if ( ! parameters.empty() ) { |
---|
70 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl; |
---|
71 | printAll( parameters, os, indent+4 ); |
---|
72 | } // if |
---|
73 | } |
---|
74 | |
---|
75 | std::string StructDecl::typeString() const { return "struct"; } |
---|
76 | |
---|
77 | std::string UnionDecl::typeString() const { return "union"; } |
---|
78 | |
---|
79 | std::string EnumDecl::typeString() const { return "enum"; } |
---|
80 | |
---|
81 | std::string TraitDecl::typeString() const { return "trait"; } |
---|
82 | |
---|
83 | // Local Variables: // |
---|
84 | // tab-width: 4 // |
---|
85 | // mode: c++ // |
---|
86 | // compile-command: "make install" // |
---|
87 | // End: // |
---|