[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 |
---|
[cd6a6ff] | 24 | #include "CompilationState.h" |
---|
[51b7345] | 25 | |
---|
[68fe077a] | 26 | NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base ) |
---|
[a7c90d4] | 27 | : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} |
---|
[51b7345] | 28 | |
---|
[46f6134] | 29 | NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other ) |
---|
[0dd3a2f] | 30 | : Parent( other ), base( maybeClone( other.base ) ) { |
---|
| 31 | cloneAll( other.assertions, assertions ); |
---|
[51b7345] | 32 | } |
---|
| 33 | |
---|
[17cd4eb] | 34 | NamedTypeDecl::~NamedTypeDecl() { |
---|
[0dd3a2f] | 35 | delete base; |
---|
| 36 | deleteAll( assertions ); |
---|
[51b7345] | 37 | } |
---|
| 38 | |
---|
[50377a4] | 39 | void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 40 | using namespace std; |
---|
[46f6134] | 41 | |
---|
[cd6a6ff] | 42 | if ( ! name.empty() ) { |
---|
| 43 | if( deterministic_output && isUnboundType(name) ) os << "[unbound]:"; |
---|
| 44 | else os << name << ": "; |
---|
| 45 | } |
---|
[50377a4] | 46 | |
---|
| 47 | if ( linkage != LinkageSpec::Cforall ) { |
---|
[d912bed] | 48 | os << LinkageSpec::name( linkage ) << " "; |
---|
[cbce272] | 49 | } // if |
---|
[6e8bd43] | 50 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 51 | os << typeString(); |
---|
| 52 | if ( base ) { |
---|
| 53 | os << " for "; |
---|
[50377a4] | 54 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 55 | } // if |
---|
| 56 | if ( ! assertions.empty() ) { |
---|
[50377a4] | 57 | os << endl << indent << "... with assertions" << endl; |
---|
| 58 | printAll( assertions, os, indent+1 ); |
---|
[0dd3a2f] | 59 | } // if |
---|
[51b7345] | 60 | } |
---|
| 61 | |
---|
[50377a4] | 62 | void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 63 | using namespace std; |
---|
[46f6134] | 64 | |
---|
[50377a4] | 65 | if ( name != "" ) os << name << ": "; |
---|
[6e8bd43] | 66 | get_storageClasses().print( os ); |
---|
[0dd3a2f] | 67 | os << typeString(); |
---|
| 68 | if ( base ) { |
---|
| 69 | os << " for "; |
---|
[50377a4] | 70 | base->print( os, indent+1 ); |
---|
[0dd3a2f] | 71 | } // if |
---|
[51b7345] | 72 | } |
---|
| 73 | |
---|
[312029a] | 74 | const char * TypedefDecl::typeString() const { return "typedef"; } |
---|
[0dd3a2f] | 75 | |
---|
| 76 | // Local Variables: // |
---|
| 77 | // tab-width: 4 // |
---|
| 78 | // mode: c++ // |
---|
| 79 | // compile-command: "make install" // |
---|
| 80 | // End: // |
---|