source: src/SynTree/NamedTypeDecl.cc @ e994912

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since e994912 was 46f6134, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Implemented owning scoped map for typedef elimination phase

  • Property mode set to 100644
File size: 2.3 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
11// Last Modified By : Peter A. Buhr
[68cd1ce]12// Last Modified On : Sat Jun 13 08:13:55 2015
13// Update Count     : 3
[0dd3a2f]14//
15
[51b7345]16#include "Declaration.h"
17#include "Type.h"
[d3b7937]18#include "Common/utility.h"
[51b7345]19
[68cd1ce]20NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *base )
[0dd3a2f]21        : Parent( name, sc, LinkageSpec::Cforall ), base( base ) {}
[51b7345]22
[46f6134]23NamedTypeDecl::NamedTypeDecl( const NamedTypeDecl &other )
[0dd3a2f]24        : Parent( other ), base( maybeClone( other.base ) ) {
25        cloneAll( other.parameters, parameters );
26        cloneAll( other.assertions, assertions );
[51b7345]27}
28
[17cd4eb]29NamedTypeDecl::~NamedTypeDecl() {
[0dd3a2f]30        delete base;
31        deleteAll( parameters );
32        deleteAll( assertions );
[51b7345]33}
34
[17cd4eb]35void NamedTypeDecl::print( std::ostream &os, int indent ) const {
[0dd3a2f]36        using namespace std;
[46f6134]37
[0dd3a2f]38        if ( get_name() != "" ) {
[5f2f2d7]39                os << get_name() << ": ";
[0dd3a2f]40        } // if
[68cd1ce]41        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
42                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]43        } // if
44        os << typeString();
45        if ( base ) {
46                os << " for ";
47                base->print( os, indent );
48        } // if
49        if ( ! parameters.empty() ) {
50                os << endl << string( indent, ' ' ) << "with parameters" << endl;
51                printAll( parameters, os, indent+2 );
52        } // if
53        if ( ! assertions.empty() ) {
54                os << endl << string( indent, ' ' ) << "with assertions" << endl;
55                printAll( assertions, os, indent+2 );
56        } // if
[51b7345]57}
58
[17cd4eb]59void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
[0dd3a2f]60        using namespace std;
[46f6134]61
[0dd3a2f]62        if ( get_name() != "" ) {
[5f2f2d7]63                os << get_name() << ": ";
[0dd3a2f]64        } // if
[68cd1ce]65        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
66                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]67        } // if
68        os << typeString();
69        if ( base ) {
70                os << " for ";
71                base->print( os, indent );
72        } // if
73        if ( ! parameters.empty() ) {
74                os << endl << string( indent, ' ' ) << "with parameters" << endl;
75                printAll( parameters, os, indent+2 );
76        } // if
[51b7345]77}
78
79std::string TypedefDecl::typeString() const { return "typedef"; }
[0dd3a2f]80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.