source: src/SynTree/ObjectDecl.cc @ bb8ea30

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since bb8ea30 was bb8ea30, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

fix printing for ArrayType?, Expression, Initializer, etc.

  • 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 : Rob Schluntz
12// Last Modified On : Fri May 13 13:20:17 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
22ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )
23        : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
24        set_isInline( isInline );
25        set_isNoreturn( isNoreturn );
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::toString( get_linkage() ) << " ";
45        } // if
46
47        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
48                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
49        } // if
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        } // if
61
62        if ( bitfieldWidth ) {
63                os << std::string(indent, ' ');
64                os << " with bitfield width ";
65                bitfieldWidth->print( os );
66        } // if
67}
68
69void ObjectDecl::printShort( std::ostream &os, int indent ) const {
70#if 0
71        if ( get_mangleName() != "") {
72                os << get_mangleName() << ": ";
73        } else
74#endif
75        if ( get_name() != "" ) {
76                os << get_name() << ": ";
77        } // if
78
79        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
80                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
81        } // if
82
83        if ( get_type() ) {
84                get_type()->print( os, indent );
85        } else {
86                os << "untyped entity ";
87        } // if
88
89        if ( bitfieldWidth ) {
90                os << "with bitfield width ";
91                bitfieldWidth->print( os );
92        } // if
93}
94
95// Local Variables: //
96// tab-width: 4 //
97// mode: c++ //
98// compile-command: "make install" //
99// End: //
Note: See TracBrowser for help on using the repository browser.