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 : Peter A. Buhr |
---|
12 | // Last Modified On : Tue May 19 16:52:08 2015 |
---|
13 | // Update Count : 5 |
---|
14 | // |
---|
15 | |
---|
16 | #include "Declaration.h" |
---|
17 | #include "Type.h" |
---|
18 | #include "utility.h" |
---|
19 | |
---|
20 | |
---|
21 | AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, Declaration::NoStorageClass, LinkageSpec::Cforall ) { |
---|
22 | } |
---|
23 | |
---|
24 | AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) { |
---|
25 | cloneAll( other.members, members ); |
---|
26 | cloneAll( other.parameters, parameters ); |
---|
27 | } |
---|
28 | |
---|
29 | AggregateDecl::~AggregateDecl() { |
---|
30 | deleteAll( members ); |
---|
31 | deleteAll( parameters ); |
---|
32 | } |
---|
33 | |
---|
34 | void AggregateDecl::print( std::ostream &os, int indent ) const { |
---|
35 | using std::string; |
---|
36 | using std::endl; |
---|
37 | |
---|
38 | os << typeString() << " " << get_name(); |
---|
39 | if ( ! parameters.empty() ) { |
---|
40 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl; |
---|
41 | printAll( parameters, os, indent+4 ); |
---|
42 | } // if |
---|
43 | if ( ! members.empty() ) { |
---|
44 | os << endl << string( indent+2, ' ' ) << "with members" << endl; |
---|
45 | printAll( members, os, indent+4 ); |
---|
46 | } // if |
---|
47 | } |
---|
48 | |
---|
49 | void AggregateDecl::printShort( std::ostream &os, int indent ) const { |
---|
50 | using std::string; |
---|
51 | using std::endl; |
---|
52 | |
---|
53 | os << typeString() << " " << get_name(); |
---|
54 | if ( ! parameters.empty() ) { |
---|
55 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl; |
---|
56 | printAll( parameters, os, indent+4 ); |
---|
57 | } // if |
---|
58 | } |
---|
59 | |
---|
60 | std::string StructDecl::typeString() const { return "struct"; } |
---|
61 | |
---|
62 | std::string UnionDecl::typeString() const { return "union"; } |
---|
63 | |
---|
64 | std::string EnumDecl::typeString() const { return "enum"; } |
---|
65 | |
---|
66 | std::string ContextDecl::typeString() const { return "context"; } |
---|
67 | |
---|
68 | // Local Variables: // |
---|
69 | // tab-width: 4 // |
---|
70 | // mode: c++ // |
---|
71 | // compile-command: "make install" // |
---|
72 | // End: // |
---|