source: src/SynTree/NamedTypeDecl.cc @ 6b1c4f2

ast-experimental
Last change on this file since 6b1c4f2 was 6a45bd78, checked in by Fangren Yu <f37yu@…>, 4 years ago

cleanup: remove params in TypeDecl? (never used)

  • Property mode set to 100644
File size: 2.3 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.assertions, assertions );
32}
33
34NamedTypeDecl::~NamedTypeDecl() {
35        delete base;
36        deleteAll( assertions );
37}
38
39void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const {
40        using namespace std;
41
42        if ( ! name.empty() ) {
43                if( deterministic_output && isUnboundType(name) ) os << "[unbound]:";
44                else os << name << ": ";
45        }
46
47        if ( linkage != LinkageSpec::Cforall ) {
48                os << LinkageSpec::name( linkage ) << " ";
49        } // if
50        get_storageClasses().print( os );
51        os << typeString();
52        if ( base ) {
53                os << " for ";
54                base->print( os, indent+1 );
55        } // if
56        if ( ! assertions.empty() ) {
57                os << endl << indent << "... with assertions" << endl;
58                printAll( assertions, os, indent+1 );
59        } // if
60}
61
62void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const {
63        using namespace std;
64
65        if ( name != "" ) os << name << ": ";
66        get_storageClasses().print( os );
67        os << typeString();
68        if ( base ) {
69                os << " for ";
70                base->print( os, indent+1 );
71        } // if
72}
73
74const char * 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.