source: src/SynTree/AggregateDecl.cc @ b0dfbc4

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since b0dfbc4 was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 3

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[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
[fa4805f]11// Last Modified By : Andrew Beach
[cbce272]12// Last Modified On : Fri Aug  4 14:22:00 2017
13// Update Count     : 22
[0dd3a2f]14//
[51b7345]15
[ea6332d]16#include <list>                  // for list
17#include <ostream>               // for operator<<, basic_ostream, ostream
18#include <string>                // for operator<<, string, char_traits
19
20#include "Attribute.h"           // for Attribute
21#include "Common/utility.h"      // for printAll, cloneAll, deleteAll
22#include "Declaration.h"         // for AggregateDecl, TypeDecl, Declaration
23#include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
24#include "Type.h"                // for Type, Type::StorageClasses
[51b7345]25
26
[fa4805f]27AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) {
[51b7345]28}
29
[0dd3a2f]30AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) {
[a08ba92]31        cloneAll( other.members, members );
32        cloneAll( other.parameters, parameters );
[c0aa336]33        cloneAll( other.attributes, attributes );
[5d125e4]34        body = other.body;
[51b7345]35}
36
[0dd3a2f]37AggregateDecl::~AggregateDecl() {
[c0aa336]38        deleteAll( attributes );
[a08ba92]39        deleteAll( parameters );
[c0aa336]40        deleteAll( members );
[51b7345]41}
42
[0dd3a2f]43void AggregateDecl::print( std::ostream &os, int indent ) const {
[a08ba92]44        using std::string;
45        using std::endl;
[51b7345]46
[cbce272]47        os << typeString() << " " << get_name() << ":";
48        if ( get_linkage() != LinkageSpec::Cforall ) {
49                os << " " << LinkageSpec::linkageName( get_linkage() );
50        } // if
51        os << " with body " << has_body() << endl;
[5d125e4]52
[a08ba92]53        if ( ! parameters.empty() ) {
[0dd3a2f]54                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
55                printAll( parameters, os, indent+4 );
[a08ba92]56        } // if
57        if ( ! members.empty() ) {
[0dd3a2f]58                os << endl << string( indent+2, ' ' ) << "with members" << endl;
59                printAll( members, os, indent+4 );
[a08ba92]60        } // if
[c0aa336]61        if ( ! attributes.empty() ) {
62                os << endl << string( indent+2, ' ' ) << "with attributes" << endl;
63                printAll( attributes, os, indent+4 );
64        } // if
[51b7345]65}
66
[0dd3a2f]67void AggregateDecl::printShort( std::ostream &os, int indent ) const {
[a08ba92]68        using std::string;
69        using std::endl;
[51b7345]70
[a08ba92]71        os << typeString() << " " << get_name();
[5d125e4]72        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
73
[a08ba92]74        if ( ! parameters.empty() ) {
[0dd3a2f]75                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
76                printAll( parameters, os, indent+4 );
[a08ba92]77        } // if
[51b7345]78}
79
80std::string StructDecl::typeString() const { return "struct"; }
81
82std::string UnionDecl::typeString() const { return "union"; }
83
84std::string EnumDecl::typeString() const { return "enum"; }
85
[4a9ccc3]86std::string TraitDecl::typeString() const { return "trait"; }
[51b7345]87
[0dd3a2f]88// Local Variables: //
89// tab-width: 4 //
90// mode: c++ //
91// compile-command: "make install" //
92// End: //
Note: See TracBrowser for help on using the repository browser.