source: translator/SynTree/NamedTypeDecl.cc @ c11e31c

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since c11e31c was 17cd4eb, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

fixed restrict, fixed parameter copy, introduced name table for types, changed variable after to string

  • Property mode set to 100644
File size: 1.8 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
10NamedTypeDecl::NamedTypeDecl( const TypeDecl &other )
11    : Parent( other ), base( maybeClone( other.base ) )
12{
13    cloneAll( other.parameters, parameters );
14    cloneAll( other.assertions, assertions );
15}
16
17NamedTypeDecl::~NamedTypeDecl() {
18    delete base;
19    deleteAll( parameters );
20    deleteAll( assertions );
21}
22
23void NamedTypeDecl::print( std::ostream &os, int indent ) const {
24    using namespace std;
25   
26    if ( get_name() != "" ) {
27        os << get_name() << ": a ";
28    } // if
29    if ( get_storageClass() != NoStorageClass ) {
30        os << storageClassName[ get_storageClass() ] << ' ';
31    } // if
32    os << typeString();
33    if ( base ) {
34        os << " for ";
35        base->print( os, indent );
36    } // if
37    if ( !parameters.empty() ) {
38        os << endl << string( indent, ' ' ) << "with parameters" << endl;
39        printAll( parameters, os, indent+2 );
40    } // if
41    if ( !assertions.empty() ) {
42        os << endl << string( indent, ' ' ) << "with assertions" << endl;
43        printAll( assertions, os, indent+2 );
44    } // if
45}
46
47void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
48    using namespace std;
49   
50    if ( get_name() != "" ) {
51        os << get_name() << ": a ";
52    } // if
53    if ( get_storageClass() != NoStorageClass ) {
54        os << storageClassName[ get_storageClass() ] << ' ';
55    } // if
56    os << typeString();
57    if ( base ) {
58        os << " for ";
59        base->print( os, indent );
60    } // if
61    if ( !parameters.empty() ) {
62        os << endl << string( indent, ' ' ) << "with parameters" << endl;
63        printAll( parameters, os, indent+2 );
64    } // if
65}
66
67std::string TypedefDecl::typeString() const { return "typedef"; }
Note: See TracBrowser for help on using the repository browser.