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 : Tue Mar 7 07:39:41 2017 |
---|
13 | // Update Count : 10 |
---|
14 | // |
---|
15 | |
---|
16 | #include "Declaration.h" |
---|
17 | #include "Type.h" |
---|
18 | #include "Common/utility.h" |
---|
19 | |
---|
20 | NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base ) |
---|
21 | : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} |
---|
22 | |
---|
23 | NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other ) |
---|
24 | : Parent( other ), base( maybeClone( other.base ) ) { |
---|
25 | cloneAll( other.parameters, parameters ); |
---|
26 | cloneAll( other.assertions, assertions ); |
---|
27 | } |
---|
28 | |
---|
29 | NamedTypeDecl::~NamedTypeDecl() { |
---|
30 | delete base; |
---|
31 | deleteAll( parameters ); |
---|
32 | deleteAll( assertions ); |
---|
33 | } |
---|
34 | |
---|
35 | void NamedTypeDecl::print( std::ostream &os, int indent ) const { |
---|
36 | using namespace std; |
---|
37 | |
---|
38 | if ( get_name() != "" ) { |
---|
39 | os << get_name() << ": "; |
---|
40 | } // if |
---|
41 | DeclarationNode::print_StorageClass( os, get_storageClasses() ); |
---|
42 | os << typeString(); |
---|
43 | if ( base ) { |
---|
44 | os << " for "; |
---|
45 | base->print( os, indent ); |
---|
46 | } // if |
---|
47 | if ( ! parameters.empty() ) { |
---|
48 | os << endl << string( indent, ' ' ) << "with parameters" << endl; |
---|
49 | printAll( parameters, os, indent+2 ); |
---|
50 | } // if |
---|
51 | if ( ! assertions.empty() ) { |
---|
52 | os << endl << string( indent, ' ' ) << "with assertions" << endl; |
---|
53 | printAll( assertions, os, indent+2 ); |
---|
54 | } // if |
---|
55 | } |
---|
56 | |
---|
57 | void NamedTypeDecl::printShort( std::ostream &os, int indent ) const { |
---|
58 | using namespace std; |
---|
59 | |
---|
60 | if ( get_name() != "" ) { |
---|
61 | os << get_name() << ": "; |
---|
62 | } // if |
---|
63 | DeclarationNode::print_StorageClass( os, get_storageClasses() ); |
---|
64 | os << typeString(); |
---|
65 | if ( base ) { |
---|
66 | os << " for "; |
---|
67 | base->print( os, indent ); |
---|
68 | } // if |
---|
69 | if ( ! parameters.empty() ) { |
---|
70 | os << endl << string( indent, ' ' ) << "with parameters" << endl; |
---|
71 | printAll( parameters, os, indent+2 ); |
---|
72 | } // if |
---|
73 | } |
---|
74 | |
---|
75 | std::string TypedefDecl::typeString() const { return "typedef"; } |
---|
76 | |
---|
77 | // Local Variables: // |
---|
78 | // tab-width: 4 // |
---|
79 | // mode: c++ // |
---|
80 | // compile-command: "make install" // |
---|
81 | // End: // |
---|