source: src/SynTree/NamedTypeDecl.cc @ 6e8bd43

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 6e8bd43 was 6e8bd43, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

cleanup interface to qualifiers/specifiers

  • Property mode set to 100644
File size: 2.1 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 : Peter A. Buhr
12// Last Modified On : Wed Mar 15 23:25:41 2017
13// Update Count     : 12
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Common/utility.h"
19
20NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::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        get_storageClasses().print( os );
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
55}
56
57void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
58        using namespace std;
59
60        if ( get_name() != "" ) {
61                os << get_name() << ": ";
62        } // if
63        get_storageClasses().print( os );
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
73}
74
75std::string TypedefDecl::typeString() const { return "typedef"; }
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.