[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 | //
|
---|
[79970ed] | 7 | // AggregateDecl.cc --
|
---|
[0dd3a2f] | 8 | //
|
---|
| 9 | // Author : Richard C. Bilson
|
---|
| 10 | // Created On : Sun May 17 23:56:39 2015
|
---|
| 11 | // Last Modified By : Peter A. Buhr
|
---|
[5d125e4] | 12 | // Last Modified On : Wed Jul 13 18:03:30 2016
|
---|
| 13 | // Update Count : 10
|
---|
[0dd3a2f] | 14 | //
|
---|
[51b73452] | 15 |
|
---|
| 16 | #include "Declaration.h"
|
---|
| 17 | #include "Type.h"
|
---|
[d3b7937] | 18 | #include "Common/utility.h"
|
---|
[51b73452] | 19 |
|
---|
| 20 |
|
---|
[5d125e4] | 21 | AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ), body( false ) {
|
---|
[51b73452] | 22 | }
|
---|
| 23 |
|
---|
[0dd3a2f] | 24 | AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) {
|
---|
[a08ba92] | 25 | cloneAll( other.members, members );
|
---|
| 26 | cloneAll( other.parameters, parameters );
|
---|
[5d125e4] | 27 | body = other.body;
|
---|
[51b73452] | 28 | }
|
---|
| 29 |
|
---|
[0dd3a2f] | 30 | AggregateDecl::~AggregateDecl() {
|
---|
[a08ba92] | 31 | deleteAll( members );
|
---|
| 32 | deleteAll( parameters );
|
---|
[51b73452] | 33 | }
|
---|
| 34 |
|
---|
[0dd3a2f] | 35 | void AggregateDecl::print( std::ostream &os, int indent ) const {
|
---|
[a08ba92] | 36 | using std::string;
|
---|
| 37 | using std::endl;
|
---|
[51b73452] | 38 |
|
---|
[a08ba92] | 39 | os << typeString() << " " << get_name();
|
---|
[5d125e4] | 40 | os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
|
---|
| 41 |
|
---|
[a08ba92] | 42 | if ( ! parameters.empty() ) {
|
---|
[0dd3a2f] | 43 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
---|
| 44 | printAll( parameters, os, indent+4 );
|
---|
[a08ba92] | 45 | } // if
|
---|
| 46 | if ( ! members.empty() ) {
|
---|
[0dd3a2f] | 47 | os << endl << string( indent+2, ' ' ) << "with members" << endl;
|
---|
| 48 | printAll( members, os, indent+4 );
|
---|
[a08ba92] | 49 | } // if
|
---|
[51b73452] | 50 | }
|
---|
| 51 |
|
---|
[0dd3a2f] | 52 | void AggregateDecl::printShort( std::ostream &os, int indent ) const {
|
---|
[a08ba92] | 53 | using std::string;
|
---|
| 54 | using std::endl;
|
---|
[51b73452] | 55 |
|
---|
[a08ba92] | 56 | os << typeString() << " " << get_name();
|
---|
[5d125e4] | 57 | os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
|
---|
| 58 |
|
---|
[a08ba92] | 59 | if ( ! parameters.empty() ) {
|
---|
[0dd3a2f] | 60 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
---|
| 61 | printAll( parameters, os, indent+4 );
|
---|
[a08ba92] | 62 | } // if
|
---|
[51b73452] | 63 | }
|
---|
| 64 |
|
---|
| 65 | std::string StructDecl::typeString() const { return "struct"; }
|
---|
| 66 |
|
---|
| 67 | std::string UnionDecl::typeString() const { return "union"; }
|
---|
| 68 |
|
---|
| 69 | std::string EnumDecl::typeString() const { return "enum"; }
|
---|
| 70 |
|
---|
[4040425] | 71 | std::string TraitDecl::typeString() const { return "context"; }
|
---|
[51b73452] | 72 |
|
---|
[0dd3a2f] | 73 | // Local Variables: //
|
---|
| 74 | // tab-width: 4 //
|
---|
| 75 | // mode: c++ //
|
---|
| 76 | // compile-command: "make install" //
|
---|
| 77 | // End: //
|
---|