source: src/SynTree/ObjectDecl.cc @ 08fc48f

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 08fc48f was 2873b737, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

virtual destructor in BaseSyntaxNode?, fix ObjectDecl? print

  • Property mode set to 100644
File size: 2.5 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 Mar 16 08:34:27 2017
13// Update Count     : 59
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, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, Type::FuncSpecifiers fs )
25        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
26}
27
28ObjectDecl::ObjectDecl( const ObjectDecl &other )
29        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
30}
31
32ObjectDecl::~ObjectDecl() {
33        delete type;
34        delete init;
35        delete bitfieldWidth;
36}
37
38void ObjectDecl::print( std::ostream &os, int indent ) const {
39        if ( get_name() != "" ) {
40                os << get_name() << ": ";
41        } // if
42
43        if ( get_linkage() != LinkageSpec::Cforall ) {
44                os << LinkageSpec::linkageName( get_linkage() ) << " ";
45        } // if
46
47        printAll( get_attributes(), os, indent );
48
49        get_storageClasses().print( os );
50
51        if ( get_type() ) {
52                get_type()->print( os, indent );
53        } else {
54                os << " untyped entity ";
55        } // if
56
57        if ( init ) {
58                os << " with initializer " << std::endl;
59                init->print( os, indent+2 );
60                os << std::endl << std::string(indent+2, ' ');
61                os << "maybeConstructed? " << init->get_maybeConstructed();
62        } // if
63
64        if ( bitfieldWidth ) {
65                os << std::string(indent, ' ');
66                os << " with bitfield width ";
67                bitfieldWidth->print( os );
68        } // if
69}
70
71void ObjectDecl::printShort( std::ostream &os, int indent ) const {
72#if 0
73        if ( get_mangleName() != "") {
74                os << get_mangleName() << ": ";
75        } else
76#endif
77        if ( get_name() != "" ) {
78                os << get_name() << ": ";
79        } // if
80
81        // xxx - should printShort print attributes?
82
83        get_storageClasses().print( os );
84
85        if ( get_type() ) {
86                get_type()->print( os, indent );
87        } else {
88                os << "untyped entity ";
89        } // if
90
91        if ( bitfieldWidth ) {
92                os << "with bitfield width ";
93                bitfieldWidth->print( os );
94        } // if
95}
96
97// Local Variables: //
98// tab-width: 4 //
99// mode: c++ //
100// compile-command: "make install" //
101// End: //
Note: See TracBrowser for help on using the repository browser.