1 | /*
|
---|
2 | * This file is part of the Cforall project
|
---|
3 | *
|
---|
4 | * $Id: AggregateDecl.cc,v 1.7 2005/08/29 20:59:25 rcbilson Exp $
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Declaration.h"
|
---|
9 | #include "Type.h"
|
---|
10 | #include "utility.h"
|
---|
11 |
|
---|
12 |
|
---|
13 | AggregateDecl::AggregateDecl( const std::string &name )
|
---|
14 | : Parent( name, Declaration::NoStorageClass, LinkageSpec::Cforall )
|
---|
15 | {
|
---|
16 | }
|
---|
17 |
|
---|
18 | AggregateDecl::AggregateDecl( const AggregateDecl &other )
|
---|
19 | : Parent( other )
|
---|
20 | {
|
---|
21 | cloneAll( other.members, members );
|
---|
22 | cloneAll( other.parameters, parameters );
|
---|
23 | }
|
---|
24 |
|
---|
25 | AggregateDecl::~AggregateDecl()
|
---|
26 | {
|
---|
27 | deleteAll( members );
|
---|
28 | deleteAll( parameters );
|
---|
29 | }
|
---|
30 |
|
---|
31 | void
|
---|
32 | AggregateDecl::print( std::ostream &os, int indent ) const
|
---|
33 | {
|
---|
34 | using std::string;
|
---|
35 | using std::endl;
|
---|
36 |
|
---|
37 | os << typeString() << " " << get_name();
|
---|
38 | if( !parameters.empty() ) {
|
---|
39 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
---|
40 | printAll( parameters, os, indent+4 );
|
---|
41 | }
|
---|
42 | if( !members.empty() ) {
|
---|
43 | os << endl << string( indent+2, ' ' ) << "with members" << endl;
|
---|
44 | printAll( members, os, indent+4 );
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | void
|
---|
49 | AggregateDecl::printShort( std::ostream &os, int indent ) const
|
---|
50 | {
|
---|
51 | using std::string;
|
---|
52 | using std::endl;
|
---|
53 |
|
---|
54 | os << typeString() << " " << get_name();
|
---|
55 | if( !parameters.empty() ) {
|
---|
56 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
---|
57 | printAll( parameters, os, indent+4 );
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | std::string StructDecl::typeString() const { return "struct"; }
|
---|
62 |
|
---|
63 | std::string UnionDecl::typeString() const { return "union"; }
|
---|
64 |
|
---|
65 | std::string EnumDecl::typeString() const { return "enum"; }
|
---|
66 |
|
---|
67 | std::string ContextDecl::typeString() const { return "context"; }
|
---|
68 |
|
---|