source: src/SynTree/ObjectDecl.cc @ b3f252a

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 b3f252a was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 3

  • Property mode set to 100644
File size: 3.0 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 <list>                  // for list
17#include <ostream>               // for operator<<, ostream, basic_ostream
18#include <string>                // for operator<<, string, char_traits, ope...
19
20#include "Attribute.h"           // for Attribute
21#include "Common/utility.h"      // for maybeClone, printAll
22#include "Declaration.h"         // for ObjectDecl, ObjectDecl::Parent
23#include "Expression.h"          // for Expression
24#include "Initializer.h"         // for Initializer
25#include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
26#include "Type.h"                // for Type, Type::StorageClasses, Type::Fu...
27
28ObjectDecl::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 )
29        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
30}
31
32ObjectDecl::ObjectDecl( const ObjectDecl &other )
33        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
34}
35
36ObjectDecl::~ObjectDecl() {
37        delete type;
38        delete init;
39        delete bitfieldWidth;
40}
41
42void ObjectDecl::print( std::ostream &os, int indent ) const {
43        if ( get_name() != "" ) {
44                os << get_name() << ": ";
45        } // if
46
47        if ( get_linkage() != LinkageSpec::Cforall ) {
48                os << LinkageSpec::linkageName( get_linkage() ) << " ";
49        } // if
50
51        printAll( get_attributes(), os, indent );
52
53        get_storageClasses().print( os );
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 " << std::endl;
63                init->print( os, indent+2 );
64                os << std::endl << std::string(indent+2, ' ');
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        get_storageClasses().print( os );
88
89        if ( get_type() ) {
90                get_type()->print( os, indent );
91        } else {
92                os << "untyped entity ";
93        } // if
94
95        if ( bitfieldWidth ) {
96                os << "with bitfield width ";
97                bitfieldWidth->print( os );
98        } // if
99}
100
101// Local Variables: //
102// tab-width: 4 //
103// mode: c++ //
104// compile-command: "make install" //
105// End: //
Note: See TracBrowser for help on using the repository browser.