source: src/SynTree/NamedTypeDecl.cc @ 8217e8f

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 8217e8f was cbce272, checked in by Andrew Beach <ajbeach@…>, 7 years ago

Structure based exception handling.

  • Property mode set to 100644
File size: 2.2 KB
Line 
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 : Andrew Beach
12// Last Modified On : Wed Aug  9 13:28:00 2017
13// Update Count     : 14
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Common/utility.h"
19
20NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
21        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
22
23NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
24        : Parent( other ), base( maybeClone( other.base ) ) {
25        cloneAll( other.parameters, parameters );
26        cloneAll( other.assertions, assertions );
27}
28
29NamedTypeDecl::~NamedTypeDecl() {
30        delete base;
31        deleteAll( parameters );
32        deleteAll( assertions );
33}
34
35void NamedTypeDecl::print( std::ostream &os, int indent ) const {
36        using namespace std;
37
38        if ( get_name() != "" ) {
39                os << get_name() << ": ";
40        } // if
41        if ( get_linkage() != LinkageSpec::Cforall ) {
42                os << LinkageSpec::linkageName( get_linkage() ) << " ";
43        } // if
44        get_storageClasses().print( os );
45        os << typeString();
46        if ( base ) {
47                os << " for ";
48                base->print( os, indent );
49        } // if
50        if ( ! parameters.empty() ) {
51                os << endl << string( indent, ' ' ) << "with parameters" << endl;
52                printAll( parameters, os, indent+2 );
53        } // if
54        if ( ! assertions.empty() ) {
55                os << endl << string( indent, ' ' ) << "with assertions" << endl;
56                printAll( assertions, os, indent+2 );
57        } // if
58}
59
60void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
61        using namespace std;
62
63        if ( get_name() != "" ) {
64                os << get_name() << ": ";
65        } // if
66        get_storageClasses().print( os );
67        os << typeString();
68        if ( base ) {
69                os << " for ";
70                base->print( os, indent );
71        } // if
72        if ( ! parameters.empty() ) {
73                os << endl << string( indent, ' ' ) << "with parameters" << endl;
74                printAll( parameters, os, indent+2 );
75        } // if
76}
77
78std::string TypedefDecl::typeString() const { return "typedef"; }
79
80// Local Variables: //
81// tab-width: 4 //
82// mode: c++ //
83// compile-command: "make install" //
84// End: //
Note: See TracBrowser for help on using the repository browser.