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