source: src/SynTree/NamedTypeDecl.cc @ cd6a6ff

arm-ehenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-expr
Last change on this file since cd6a6ff was cd6a6ff, checked in by Thierry Delisle <tdelisle@…>, 18 months ago

Improved coverage of deterministic_output to be much finer grain.

  • Property mode set to 100644
File size: 2.6 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 : Mon Dec 16 15:11:40 2019
13// Update Count     : 17
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 "LinkageSpec.h"         // for Spec, Cforall, linkageName
23#include "Type.h"                // for Type, Type::StorageClasses
24#include "CompilationState.h"
25
26NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
27        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
28
29NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
30        : Parent( other ), base( maybeClone( other.base ) ) {
31        cloneAll( other.parameters, parameters );
32        cloneAll( other.assertions, assertions );
33}
34
35NamedTypeDecl::~NamedTypeDecl() {
36        delete base;
37        deleteAll( parameters );
38        deleteAll( assertions );
39}
40
41void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
42        using namespace std;
43
44        if ( ! name.empty() ) {
45                if( deterministic_output && isUnboundType(name) ) os << "[unbound]:";
46                else os << name << ": ";
47        }
48
49        if ( linkage != LinkageSpec::Cforall ) {
50                os << LinkageSpec::name( linkage ) << " ";
51        } // if
52        get_storageClasses().print( os );
53        os << typeString();
54        if ( base ) {
55                os << " for ";
56                base->print( os, indent+1 );
57        } // if
58        if ( ! parameters.empty() ) {
59                os << endl << indent << "... with parameters" << endl;
60                printAll( parameters, os, indent+1 );
61        } // if
62        if ( ! assertions.empty() ) {
63                os << endl << indent << "... with assertions" << endl;
64                printAll( assertions, os, indent+1 );
65        } // if
66}
67
68void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
69        using namespace std;
70
71        if ( name != "" ) os << name << ": ";
72        get_storageClasses().print( os );
73        os << typeString();
74        if ( base ) {
75                os << " for ";
76                base->print( os, indent+1 );
77        } // if
78        if ( ! parameters.empty() ) {
79                os << endl << indent << "... with parameters" << endl;
80                printAll( parameters, os, indent+1 );
81        } // if
82}
83
84const char * TypedefDecl::typeString() const { return "typedef"; }
85
86// Local Variables: //
87// tab-width: 4 //
88// mode: c++ //
89// compile-command: "make install" //
90// End: //
Note: See TracBrowser for help on using the repository browser.