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