source: src/SynTree/NamedTypeDecl.cc @ 68f9c43

new-envwith_gc
Last change on this file since 68f9c43 was 68f9c43, checked in by Aaron Moss <a3moss@…>, 6 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 2.4 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 <list>                  // for list
17#include <ostream>               // for operator<<, ostream, basic_ostream
18#include <string>                // for operator<<, string, char_traits, ope...
19
20#include "Common/utility.h"      // for printAll, cloneAll, deleteAll, maybe...
21#include "Declaration.h"         // for NamedTypeDecl, DeclarationWithType
22#include "Parser/LinkageSpec.h"  // for Spec, Cforall, linkageName
23#include "Type.h"                // for Type, Type::StorageClasses
24
25NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
26        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
27
28NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
29        : Parent( other ), base( maybeClone( other.base ) ) {
30        cloneAll( other.parameters, parameters );
31        cloneAll( other.assertions, assertions );
32}
33
34void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
35        using namespace std;
36
37        if ( name != "" ) os << name << ": ";
38
39        if ( linkage != LinkageSpec::Cforall ) {
40                os << LinkageSpec::linkageName( linkage ) << " ";
41        } // if
42        get_storageClasses().print( os );
43        os << typeString();
44        if ( base ) {
45                os << " for ";
46                base->print( os, indent+1 );
47        } // if
48        if ( ! parameters.empty() ) {
49                os << endl << indent << "... with parameters" << endl;
50                printAll( parameters, os, indent+1 );
51        } // if
52        if ( ! assertions.empty() ) {
53                os << endl << indent << "... with assertions" << endl;
54                printAll( assertions, os, indent+1 );
55        } // if
56}
57
58void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
59        using namespace std;
60
61        if ( name != "" ) os << name << ": ";
62        get_storageClasses().print( os );
63        os << typeString();
64        if ( base ) {
65                os << " for ";
66                base->print( os, indent+1 );
67        } // if
68        if ( ! parameters.empty() ) {
69                os << endl << indent << "... with parameters" << endl;
70                printAll( parameters, os, indent+1 );
71        } // if
72}
73
74std::string TypedefDecl::typeString() const { return "typedef"; }
75
76// Local Variables: //
77// tab-width: 4 //
78// mode: c++ //
79// compile-command: "make install" //
80// End: //
Note: See TracBrowser for help on using the repository browser.