[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 |
---|
[cbce272] | 11 | // Last Modified By : Andrew Beach |
---|
| 12 | // Last Modified On : Wed Aug 9 13:28:00 2017 |
---|
| 13 | // Update Count : 14 |
---|
[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 |
---|
| 22 | #include "Parser/LinkageSpec.h" // for Spec, Cforall, linkageName |
---|
| 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 | |
---|
[50377a4] | 34 | void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 35 | using namespace std; |
---|
[46f6134] | 36 | |
---|
[50377a4] | 37 | if ( name != "" ) os << name << ": "; |
---|
| 38 | |
---|
| 39 | if ( linkage != LinkageSpec::Cforall ) { |
---|
| 40 | os << LinkageSpec::linkageName( linkage ) << " "; |
---|
[cbce272] | 41 | } // if |
---|
[6e8bd43] | 42 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 43 | os << typeString(); |
---|
| 44 | if ( base ) { |
---|
| 45 | os << " for "; |
---|
[50377a4] | 46 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 47 | } // if |
---|
| 48 | if ( ! parameters.empty() ) { |
---|
[50377a4] | 49 | os << endl << indent << "... with parameters" << endl; |
---|
| 50 | printAll( parameters, os, indent+1 ); |
---|
[0dd3a2f] | 51 | } // if |
---|
| 52 | if ( ! assertions.empty() ) { |
---|
[50377a4] | 53 | os << endl << indent << "... with assertions" << endl; |
---|
| 54 | printAll( assertions, os, indent+1 ); |
---|
[0dd3a2f] | 55 | } // if |
---|
[51b7345] | 56 | } |
---|
| 57 | |
---|
[50377a4] | 58 | void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 59 | using namespace std; |
---|
[46f6134] | 60 | |
---|
[50377a4] | 61 | if ( name != "" ) os << name << ": "; |
---|
[6e8bd43] | 62 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 63 | os << typeString(); |
---|
| 64 | if ( base ) { |
---|
| 65 | os << " for "; |
---|
[50377a4] | 66 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 67 | } // if |
---|
| 68 | if ( ! parameters.empty() ) { |
---|
[50377a4] | 69 | os << endl << indent << "... with parameters" << endl; |
---|
| 70 | printAll( parameters, os, indent+1 ); |
---|
[0dd3a2f] | 71 | } // if |
---|
[51b7345] | 72 | } |
---|
| 73 | |
---|
| 74 | std::string TypedefDecl::typeString() const { return "typedef"; } |
---|
[0dd3a2f] | 75 | |
---|
| 76 | // Local Variables: // |
---|
| 77 | // tab-width: 4 // |
---|
| 78 | // mode: c++ // |
---|
| 79 | // compile-command: "make install" // |
---|
| 80 | // End: // |
---|