[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 | // |
---|
[46f6134] | 7 | // NamedTypeDecl.cc -- |
---|
[0dd3a2f] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[312029a] | 11 | // Last Modified By : Peter A. Buhr |
---|
[d912bed] | 12 | // Last Modified On : Mon Dec 16 15:11:40 2019 |
---|
| 13 | // Update Count : 17 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[ea6332d] | 16 | #include <list> // for list |
---|
| 17 | #include <ostream> // for operator<<, ostream, basic_ostream |
---|
| 18 | #include <string> // for operator<<, string, char_traits, ope... |
---|
| 19 | |
---|
| 20 | #include "Common/utility.h" // for printAll, cloneAll, deleteAll, maybe... |
---|
| 21 | #include "Declaration.h" // for NamedTypeDecl, DeclarationWithType |
---|
[07de76b] | 22 | #include "LinkageSpec.h" // for Spec, Cforall, linkageName |
---|
[ea6332d] | 23 | #include "Type.h" // for Type, Type::StorageClasses |
---|
[51b7345] | 24 | |
---|
[68fe077a] | 25 | NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base ) |
---|
[a7c90d4] | 26 | : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} |
---|
[51b7345] | 27 | |
---|
[46f6134] | 28 | NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other ) |
---|
[0dd3a2f] | 29 | : Parent( other ), base( maybeClone( other.base ) ) { |
---|
| 30 | cloneAll( other.parameters, parameters ); |
---|
| 31 | cloneAll( other.assertions, assertions ); |
---|
[51b7345] | 32 | } |
---|
| 33 | |
---|
[17cd4eb] | 34 | NamedTypeDecl::~NamedTypeDecl() { |
---|
[0dd3a2f] | 35 | delete base; |
---|
| 36 | deleteAll( parameters ); |
---|
| 37 | deleteAll( assertions ); |
---|
[51b7345] | 38 | } |
---|
| 39 | |
---|
[50377a4] | 40 | void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 41 | using namespace std; |
---|
[46f6134] | 42 | |
---|
[50377a4] | 43 | if ( name != "" ) os << name << ": "; |
---|
| 44 | |
---|
| 45 | if ( linkage != LinkageSpec::Cforall ) { |
---|
[d912bed] | 46 | os << LinkageSpec::name( linkage ) << " "; |
---|
[cbce272] | 47 | } // if |
---|
[6e8bd43] | 48 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 49 | os << typeString(); |
---|
| 50 | if ( base ) { |
---|
| 51 | os << " for "; |
---|
[50377a4] | 52 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 53 | } // if |
---|
| 54 | if ( ! parameters.empty() ) { |
---|
[50377a4] | 55 | os << endl << indent << "... with parameters" << endl; |
---|
| 56 | printAll( parameters, os, indent+1 ); |
---|
[0dd3a2f] | 57 | } // if |
---|
| 58 | if ( ! assertions.empty() ) { |
---|
[50377a4] | 59 | os << endl << indent << "... with assertions" << endl; |
---|
| 60 | printAll( assertions, os, indent+1 ); |
---|
[0dd3a2f] | 61 | } // if |
---|
[51b7345] | 62 | } |
---|
| 63 | |
---|
[50377a4] | 64 | void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 65 | using namespace std; |
---|
[46f6134] | 66 | |
---|
[50377a4] | 67 | if ( name != "" ) os << name << ": "; |
---|
[6e8bd43] | 68 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 69 | os << typeString(); |
---|
| 70 | if ( base ) { |
---|
| 71 | os << " for "; |
---|
[50377a4] | 72 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 73 | } // if |
---|
| 74 | if ( ! parameters.empty() ) { |
---|
[50377a4] | 75 | os << endl << indent << "... with parameters" << endl; |
---|
| 76 | printAll( parameters, os, indent+1 ); |
---|
[0dd3a2f] | 77 | } // if |
---|
[51b7345] | 78 | } |
---|
| 79 | |
---|
[312029a] | 80 | const char * TypedefDecl::typeString() const { return "typedef"; } |
---|
[0dd3a2f] | 81 | |
---|
| 82 | // Local Variables: // |
---|
| 83 | // tab-width: 4 // |
---|
| 84 | // mode: c++ // |
---|
| 85 | // compile-command: "make install" // |
---|
| 86 | // End: // |
---|