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 : Andrew Beach
|
---|
12 | // Last Modified On : Wed Aug 9 13:28:00 2017
|
---|
13 | // Update Count : 14
|
---|
14 | //
|
---|
15 |
|
---|
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
|
---|
24 |
|
---|
25 | NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
|
---|
26 | : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
|
---|
27 |
|
---|
28 | NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
|
---|
29 | : Parent( other ), base( maybeClone( other.base ) ) {
|
---|
30 | cloneAll( other.parameters, parameters );
|
---|
31 | cloneAll( other.assertions, assertions );
|
---|
32 | }
|
---|
33 |
|
---|
34 | NamedTypeDecl::~NamedTypeDecl() {
|
---|
35 | delete base;
|
---|
36 | deleteAll( parameters );
|
---|
37 | deleteAll( assertions );
|
---|
38 | }
|
---|
39 |
|
---|
40 | void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
|
---|
41 | using namespace std;
|
---|
42 |
|
---|
43 | if ( name != "" ) os << name << ": ";
|
---|
44 |
|
---|
45 | if ( linkage != LinkageSpec::Cforall ) {
|
---|
46 | os << LinkageSpec::linkageName( linkage ) << " ";
|
---|
47 | } // if
|
---|
48 | get_storageClasses().print( os );
|
---|
49 | os << typeString();
|
---|
50 | if ( base ) {
|
---|
51 | os << " for ";
|
---|
52 | base->print( os, indent+1 );
|
---|
53 | } // if
|
---|
54 | if ( ! parameters.empty() ) {
|
---|
55 | os << endl << indent << "... with parameters" << endl;
|
---|
56 | printAll( parameters, os, indent+1 );
|
---|
57 | } // if
|
---|
58 | if ( ! assertions.empty() ) {
|
---|
59 | os << endl << indent << "... with assertions" << endl;
|
---|
60 | printAll( assertions, os, indent+1 );
|
---|
61 | } // if
|
---|
62 | }
|
---|
63 |
|
---|
64 | void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
|
---|
65 | using namespace std;
|
---|
66 |
|
---|
67 | if ( name != "" ) os << name << ": ";
|
---|
68 | get_storageClasses().print( os );
|
---|
69 | os << typeString();
|
---|
70 | if ( base ) {
|
---|
71 | os << " for ";
|
---|
72 | base->print( os, indent+1 );
|
---|
73 | } // if
|
---|
74 | if ( ! parameters.empty() ) {
|
---|
75 | os << endl << indent << "... with parameters" << endl;
|
---|
76 | printAll( parameters, os, indent+1 );
|
---|
77 | } // if
|
---|
78 | }
|
---|
79 |
|
---|
80 | std::string TypedefDecl::typeString() const { return "typedef"; }
|
---|
81 |
|
---|
82 | // Local Variables: //
|
---|
83 | // tab-width: 4 //
|
---|
84 | // mode: c++ //
|
---|
85 | // compile-command: "make install" //
|
---|
86 | // End: //
|
---|