source: src/SynTree/ObjectDecl.cc @ 75a17f1

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 75a17f1 was a7c90d4, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

change StorageClass? to bitset, support _Thread_local as separate storage-class

  • 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 : Peter A. Buhr
12// Last Modified On : Tue Mar  7 07:55:24 2017
13// Update Count     : 54
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::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::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        DeclarationNode::print_StorageClass( os, get_storageClasses() );
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 ";
59                init->print( os, indent );
60                os << std::endl << std::string(indent, ' ');
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        DeclarationNode::print_StorageClass( os, get_storageClasses() );
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.