source: src/SynTree/NamedTypeDecl.cc @ cd6a6ff

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since cd6a6ff was cd6a6ff, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Improved coverage of deterministic_output to be much finer grain.

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[0dd3a2f]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//
[46f6134]7// NamedTypeDecl.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[312029a]11// Last Modified By : Peter A. Buhr
[d912bed]12// Last Modified On : Mon Dec 16 15:11:40 2019
13// Update Count     : 17
[0dd3a2f]14//
15
[ea6332d]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
[07de76b]22#include "LinkageSpec.h"         // for Spec, Cforall, linkageName
[ea6332d]23#include "Type.h"                // for Type, Type::StorageClasses
[cd6a6ff]24#include "CompilationState.h"
[51b7345]25
[68fe077a]26NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
[a7c90d4]27        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
[51b7345]28
[46f6134]29NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
[0dd3a2f]30        : Parent( other ), base( maybeClone( other.base ) ) {
31        cloneAll( other.parameters, parameters );
32        cloneAll( other.assertions, assertions );
[51b7345]33}
34
[17cd4eb]35NamedTypeDecl::~NamedTypeDecl() {
[0dd3a2f]36        delete base;
37        deleteAll( parameters );
38        deleteAll( assertions );
[51b7345]39}
40
[50377a4]41void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
[0dd3a2f]42        using namespace std;
[46f6134]43
[cd6a6ff]44        if ( ! name.empty() ) {
45                if( deterministic_output && isUnboundType(name) ) os << "[unbound]:";
46                else os << name << ": ";
47        }
[50377a4]48
49        if ( linkage != LinkageSpec::Cforall ) {
[d912bed]50                os << LinkageSpec::name( linkage ) << " ";
[cbce272]51        } // if
[6e8bd43]52        get_storageClasses().print( os );
[0dd3a2f]53        os << typeString();
54        if ( base ) {
55                os << " for ";
[50377a4]56                base->print( os, indent+1 );
[0dd3a2f]57        } // if
58        if ( ! parameters.empty() ) {
[50377a4]59                os << endl << indent << "... with parameters" << endl;
60                printAll( parameters, os, indent+1 );
[0dd3a2f]61        } // if
62        if ( ! assertions.empty() ) {
[50377a4]63                os << endl << indent << "... with assertions" << endl;
64                printAll( assertions, os, indent+1 );
[0dd3a2f]65        } // if
[51b7345]66}
67
[50377a4]68void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
[0dd3a2f]69        using namespace std;
[46f6134]70
[50377a4]71        if ( name != "" ) os << name << ": ";
[6e8bd43]72        get_storageClasses().print( os );
[0dd3a2f]73        os << typeString();
74        if ( base ) {
75                os << " for ";
[50377a4]76                base->print( os, indent+1 );
[0dd3a2f]77        } // if
78        if ( ! parameters.empty() ) {
[50377a4]79                os << endl << indent << "... with parameters" << endl;
80                printAll( parameters, os, indent+1 );
[0dd3a2f]81        } // if
[51b7345]82}
83
[312029a]84const char * TypedefDecl::typeString() const { return "typedef"; }
[0dd3a2f]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.