source: translator/SynTree/NamedTypeDecl.cc@ d0e8cfe4

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since d0e8cfe4 was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#include "Declaration.h"
2#include "Type.h"
3#include "utility.h"
4
5
6NamedTypeDecl::NamedTypeDecl( const std::string &name, StorageClass sc, Type *base )
7 : Parent( name, sc, LinkageSpec::Cforall ), base( base )
8{
9}
10
11NamedTypeDecl::NamedTypeDecl( const TypeDecl &other )
12 : Parent( other ), base( maybeClone( other.base ) )
13{
14 cloneAll( other.parameters, parameters );
15 cloneAll( other.assertions, assertions );
16}
17
18NamedTypeDecl::~NamedTypeDecl()
19{
20 delete base;
21 deleteAll( parameters );
22 deleteAll( assertions );
23}
24
25void
26NamedTypeDecl::print( std::ostream &os, int indent ) const
27{
28 using namespace std;
29
30 if( get_name() != "" ) {
31 os << get_name() << ": a ";
32 }
33 if( get_storageClass() != NoStorageClass ) {
34 os << storageClassName[ get_storageClass() ] << ' ';
35 }
36 os << typeString();
37 if( base ) {
38 os << " for ";
39 base->print( os, indent );
40 }
41 if( !parameters.empty() ) {
42 os << endl << string( indent, ' ' ) << "with parameters" << endl;
43 printAll( parameters, os, indent+2 );
44 }
45 if( !assertions.empty() ) {
46 os << endl << string( indent, ' ' ) << "with assertions" << endl;
47 printAll( assertions, os, indent+2 );
48 }
49}
50
51void
52NamedTypeDecl::printShort( std::ostream &os, int indent ) const
53{
54 using namespace std;
55
56 if( get_name() != "" ) {
57 os << get_name() << ": a ";
58 }
59 if( get_storageClass() != NoStorageClass ) {
60 os << storageClassName[ get_storageClass() ] << ' ';
61 }
62 os << typeString();
63 if( base ) {
64 os << " for ";
65 base->print( os, indent );
66 }
67 if( !parameters.empty() ) {
68 os << endl << string( indent, ' ' ) << "with parameters" << endl;
69 printAll( parameters, os, indent+2 );
70 }
71}
72
73std::string TypedefDecl::typeString() const { return "typedef"; }
74
Note: See TracBrowser for help on using the repository browser.