Changeset 0dd3a2f for translator/SynTree/NamedTypeDecl.cc
- Timestamp:
- May 18, 2015, 11:20:23 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 51587aa
- Parents:
- a32b204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/NamedTypeDecl.cc
ra32b204 r0dd3a2f 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 : Mon May 18 10:13:19 2015 13 // Update Count : 1 14 // 15 1 16 #include "Declaration.h" 2 17 #include "Type.h" 3 18 #include "utility.h" 4 19 5 6 20 NamedTypeDecl::NamedTypeDecl( const std::string &name, StorageClass sc, Type *base ) 7 : Parent( name, sc, LinkageSpec::Cforall ), base( base ) 8 {} 21 : Parent( name, sc, LinkageSpec::Cforall ), base( base ) {} 9 22 10 23 NamedTypeDecl::NamedTypeDecl( const TypeDecl &other ) 11 : Parent( other ), base( maybeClone( other.base ) ) 12 { 13 cloneAll( other.parameters, parameters ); 14 cloneAll( other.assertions, assertions ); 24 : Parent( other ), base( maybeClone( other.base ) ) { 25 cloneAll( other.parameters, parameters ); 26 cloneAll( other.assertions, assertions ); 15 27 } 16 28 17 29 NamedTypeDecl::~NamedTypeDecl() { 18 19 20 30 delete base; 31 deleteAll( parameters ); 32 deleteAll( assertions ); 21 33 } 22 34 23 35 void NamedTypeDecl::print( std::ostream &os, int indent ) const { 24 25 26 27 os << get_name() << ": a ";28 29 30 os << storageClassName[ get_storageClass() ] << ' ';31 32 33 34 os << " for ";35 base->print( os, indent );36 37 38 os << endl << string( indent, ' ' ) << "with parameters" << endl;39 printAll( parameters, os, indent+2 );40 41 42 os << endl << string( indent, ' ' ) << "with assertions" << endl;43 printAll( assertions, os, indent+2 );44 36 using namespace std; 37 38 if ( get_name() != "" ) { 39 os << get_name() << ": a "; 40 } // if 41 if ( get_storageClass() != NoStorageClass ) { 42 os << storageClassName[ get_storageClass() ] << ' '; 43 } // if 44 os << typeString(); 45 if ( base ) { 46 os << " for "; 47 base->print( os, indent ); 48 } // if 49 if ( ! parameters.empty() ) { 50 os << endl << string( indent, ' ' ) << "with parameters" << endl; 51 printAll( parameters, os, indent+2 ); 52 } // if 53 if ( ! assertions.empty() ) { 54 os << endl << string( indent, ' ' ) << "with assertions" << endl; 55 printAll( assertions, os, indent+2 ); 56 } // if 45 57 } 46 58 47 59 void NamedTypeDecl::printShort( std::ostream &os, int indent ) const { 48 49 50 51 os << get_name() << ": a ";52 53 54 os << storageClassName[ get_storageClass() ] << ' ';55 56 57 58 os << " for ";59 base->print( os, indent );60 61 62 os << endl << string( indent, ' ' ) << "with parameters" << endl;63 printAll( parameters, os, indent+2 );64 60 using namespace std; 61 62 if ( get_name() != "" ) { 63 os << get_name() << ": a "; 64 } // if 65 if ( get_storageClass() != NoStorageClass ) { 66 os << storageClassName[ get_storageClass() ] << ' '; 67 } // if 68 os << typeString(); 69 if ( base ) { 70 os << " for "; 71 base->print( os, indent ); 72 } // if 73 if ( ! parameters.empty() ) { 74 os << endl << string( indent, ' ' ) << "with parameters" << endl; 75 printAll( parameters, os, indent+2 ); 76 } // if 65 77 } 66 78 67 79 std::string TypedefDecl::typeString() const { return "typedef"; } 80 81 // Local Variables: // 82 // tab-width: 4 // 83 // mode: c++ // 84 // compile-command: "make install" // 85 // End: //
Note: See TracChangeset
for help on using the changeset viewer.