source: src/SynTree/NamedTypeDecl.cc @ 312029a

arm-ehjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since 312029a was 312029a, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago

move enum Aggregate from DeclarationNode? to AggregateDecl?, add control-keyword field-dereference to replace control-keyword cast

  • Property mode set to 100644
File size: 2.5 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 Dec 11 08:26:17 2019
13// Update Count     : 15
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
34NamedTypeDecl::~NamedTypeDecl() {
35        delete base;
36        deleteAll( parameters );
37        deleteAll( assertions );
38}
39
40void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
41        using namespace std;
42
43        if ( name != "" ) os << name << ": ";
44
45        if ( linkage != LinkageSpec::Cforall ) {
46                os << LinkageSpec::linkageName( linkage ) << " ";
47        } // if
48        get_storageClasses().print( os );
49        os << typeString();
50        if ( base ) {
51                os << " for ";
52                base->print( os, indent+1 );
53        } // if
54        if ( ! parameters.empty() ) {
55                os << endl << indent << "... with parameters" << endl;
56                printAll( parameters, os, indent+1 );
57        } // if
58        if ( ! assertions.empty() ) {
59                os << endl << indent << "... with assertions" << endl;
60                printAll( assertions, os, indent+1 );
61        } // if
62}
63
64void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
65        using namespace std;
66
67        if ( name != "" ) os << name << ": ";
68        get_storageClasses().print( os );
69        os << typeString();
70        if ( base ) {
71                os << " for ";
72                base->print( os, indent+1 );
73        } // if
74        if ( ! parameters.empty() ) {
75                os << endl << indent << "... with parameters" << endl;
76                printAll( parameters, os, indent+1 );
77        } // if
78}
79
80const char * TypedefDecl::typeString() const { return "typedef"; }
81
82// Local Variables: //
83// tab-width: 4 //
84// mode: c++ //
85// compile-command: "make install" //
86// End: //
Note: See TracBrowser for help on using the repository browser.