source: src/SynTree/ObjectDecl.cc @ d5f1cfc

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d5f1cfc was d668182, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Merge branch 'fix-tree-printing' into ctor

Conflicts:

src/SynTree/Expression.cc
src/SynTree/Initializer.cc
src/SynTree/ObjectDecl.cc

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