source: translator/SynTree/NamedTypeDecl.cc @ ad8e062

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