source: src/SynTree/ObjectDecl.cc @ 4f147cc

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 4f147cc was 8b7ee09, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

rename type LinkageSpec::Type to LinkageSpec::Spec, which affects many files

  • Property mode set to 100644
File size: 2.8 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// ObjectDecl.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 : Thu Aug 18 23:50:33 2016
13// Update Count     : 31
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
20#include "Attribute.h"
21#include "Common/utility.h"
22#include "Statement.h"
23
24ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn )
25        : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
26        set_isInline( isInline );
27        set_isNoreturn( isNoreturn );
28}
29
30ObjectDecl::ObjectDecl( const ObjectDecl &other )
31        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
32}
33
34ObjectDecl::~ObjectDecl() {
35        delete type;
36        delete init;
37        delete bitfieldWidth;
38}
39
40void ObjectDecl::print( std::ostream &os, int indent ) const {
41        if ( get_name() != "" ) {
42                os << get_name() << ": ";
43        } // if
44
45        if ( get_linkage() != LinkageSpec::Cforall ) {
46                os << LinkageSpec::toString( get_linkage() ) << " ";
47        } // if
48
49        printAll( get_attributes(), os, indent );
50
51        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
52                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
53        } // if
54
55        if ( get_type() ) {
56                get_type()->print( os, indent );
57        } else {
58                os << " untyped entity ";
59        } // if
60
61        if ( init ) {
62                os << " with initializer ";
63                init->print( os, indent );
64                os << std::endl << std::string(indent, ' ');
65                os << "maybeConstructed? " << init->get_maybeConstructed();
66        } // if
67
68        if ( bitfieldWidth ) {
69                os << std::string(indent, ' ');
70                os << " with bitfield width ";
71                bitfieldWidth->print( os );
72        } // if
73}
74
75void ObjectDecl::printShort( std::ostream &os, int indent ) const {
76#if 0
77        if ( get_mangleName() != "") {
78                os << get_mangleName() << ": ";
79        } else
80#endif
81        if ( get_name() != "" ) {
82                os << get_name() << ": ";
83        } // if
84
85        // xxx - should printShort print attributes?
86
87        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
88                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
89        } // if
90
91        if ( get_type() ) {
92                get_type()->print( os, indent );
93        } else {
94                os << "untyped entity ";
95        } // if
96
97        if ( bitfieldWidth ) {
98                os << "with bitfield width ";
99                bitfieldWidth->print( os );
100        } // if
101}
102
103// Local Variables: //
104// tab-width: 4 //
105// mode: c++ //
106// compile-command: "make install" //
107// End: //
Note: See TracBrowser for help on using the repository browser.