source: src/SynTree/NamedTypeDecl.cc @ 64b6913

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 64b6913 was 64b6913, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

move type StorageClasses? from DeclarationNode? to Type

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[0dd3a2f]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//
[46f6134]7// NamedTypeDecl.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
[64b6913]12// Last Modified On : Thu Mar 16 07:49:44 2017
13// Update Count     : 13
[0dd3a2f]14//
15
[51b7345]16#include "Declaration.h"
17#include "Type.h"
[d3b7937]18#include "Common/utility.h"
[51b7345]19
[64b6913]20NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
[a7c90d4]21        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
[51b7345]22
[46f6134]23NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
[0dd3a2f]24        : Parent( other ), base( maybeClone( other.base ) ) {
25        cloneAll( other.parameters, parameters );
26        cloneAll( other.assertions, assertions );
[51b7345]27}
28
[17cd4eb]29NamedTypeDecl::~NamedTypeDecl() {
[0dd3a2f]30        delete base;
31        deleteAll( parameters );
32        deleteAll( assertions );
[51b7345]33}
34
[17cd4eb]35void NamedTypeDecl::print( std::ostream &os, int indent ) const {
[0dd3a2f]36        using namespace std;
[46f6134]37
[0dd3a2f]38        if ( get_name() != "" ) {
[5f2f2d7]39                os << get_name() << ": ";
[0dd3a2f]40        } // if
[6e8bd43]41        get_storageClasses().print( os );
[0dd3a2f]42        os << typeString();
43        if ( base ) {
44                os << " for ";
45                base->print( os, indent );
46        } // if
47        if ( ! parameters.empty() ) {
48                os << endl << string( indent, ' ' ) << "with parameters" << endl;
49                printAll( parameters, os, indent+2 );
50        } // if
51        if ( ! assertions.empty() ) {
52                os << endl << string( indent, ' ' ) << "with assertions" << endl;
53                printAll( assertions, os, indent+2 );
54        } // if
[51b7345]55}
56
[17cd4eb]57void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
[0dd3a2f]58        using namespace std;
[46f6134]59
[0dd3a2f]60        if ( get_name() != "" ) {
[5f2f2d7]61                os << get_name() << ": ";
[0dd3a2f]62        } // if
[6e8bd43]63        get_storageClasses().print( os );
[0dd3a2f]64        os << typeString();
65        if ( base ) {
66                os << " for ";
67                base->print( os, indent );
68        } // if
69        if ( ! parameters.empty() ) {
70                os << endl << string( indent, ' ' ) << "with parameters" << endl;
71                printAll( parameters, os, indent+2 );
72        } // if
[51b7345]73}
74
75std::string TypedefDecl::typeString() const { return "typedef"; }
[0dd3a2f]76
77// Local Variables: //
78// tab-width: 4 //
79// mode: c++ //
80// compile-command: "make install" //
81// End: //
Note: See TracBrowser for help on using the repository browser.