| 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 : Wed Jul 13 18:03:30 2016
|
|---|
| 13 | // Update Count : 10
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #include "Declaration.h"
|
|---|
| 17 | #include "Type.h"
|
|---|
| 18 | #include "Common/utility.h"
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ), body( false ) {
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) {
|
|---|
| 25 | cloneAll( other.members, members );
|
|---|
| 26 | cloneAll( other.parameters, parameters );
|
|---|
| 27 | body = other.body;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | AggregateDecl::~AggregateDecl() {
|
|---|
| 31 | deleteAll( members );
|
|---|
| 32 | deleteAll( parameters );
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | void AggregateDecl::print( std::ostream &os, int indent ) const {
|
|---|
| 36 | using std::string;
|
|---|
| 37 | using std::endl;
|
|---|
| 38 |
|
|---|
| 39 | os << typeString() << " " << get_name();
|
|---|
| 40 | os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
|
|---|
| 41 |
|
|---|
| 42 | if ( ! parameters.empty() ) {
|
|---|
| 43 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
|---|
| 44 | printAll( parameters, os, indent+4 );
|
|---|
| 45 | } // if
|
|---|
| 46 | if ( ! members.empty() ) {
|
|---|
| 47 | os << endl << string( indent+2, ' ' ) << "with members" << endl;
|
|---|
| 48 | printAll( members, os, indent+4 );
|
|---|
| 49 | } // if
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | void AggregateDecl::printShort( std::ostream &os, int indent ) const {
|
|---|
| 53 | using std::string;
|
|---|
| 54 | using std::endl;
|
|---|
| 55 |
|
|---|
| 56 | os << typeString() << " " << get_name();
|
|---|
| 57 | os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
|
|---|
| 58 |
|
|---|
| 59 | if ( ! parameters.empty() ) {
|
|---|
| 60 | os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
|
|---|
| 61 | printAll( parameters, os, indent+4 );
|
|---|
| 62 | } // if
|
|---|
| 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 |
|
|---|
| 71 | std::string TraitDecl::typeString() const { return "context"; }
|
|---|
| 72 |
|
|---|
| 73 | // Local Variables: //
|
|---|
| 74 | // tab-width: 4 //
|
|---|
| 75 | // mode: c++ //
|
|---|
| 76 | // compile-command: "make install" //
|
|---|
| 77 | // End: //
|
|---|