source: src/SynTree/ObjectDecl.cc @ 974906e2

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 974906e2 was 974906e2, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

propagate maybeConstructed flag through system, begin create constructor/destructor statements for further processing by Resolver

  • Property mode set to 100644
File size: 2.7 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 Jan 08 15:29:10 2016
13// Update Count     : 27
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
20#include "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        set_ctor( NULL );
28}
29
30ObjectDecl::ObjectDecl( const ObjectDecl &other )
31        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ), ctor( maybeClone( other.ctor ) ) {
32}
33
34ObjectDecl::~ObjectDecl() {
35        delete type;
36        delete init;
37        delete bitfieldWidth;
38        delete ctor;
39}
40
41void ObjectDecl::print( std::ostream &os, int indent ) const {
42        if ( get_name() != "" ) {
43                os << get_name() << ": ";
44        } // if
45
46        if ( get_linkage() != LinkageSpec::Cforall ) {
47                os << LinkageSpec::toString( get_linkage() ) << " ";
48        } // if
49
50        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
51                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
52        } // if
53
54        if ( get_type() ) {
55                get_type()->print( os, indent );
56        } else {
57                os << " untyped entity ";
58        } // if
59
60        if ( init ) {
61                os << " with initializer ";
62                init->print( os, indent );
63                os << std::string(indent, ' ') << "maybeConstructed? " << init->get_maybeConstructed();
64        } // if
65
66        if ( bitfieldWidth ) {
67                os << " with bitfield width ";
68                bitfieldWidth->print( os );
69        } // if
70
71        if ( ctor ) {
72                os << " initially constructed with ";
73                ctor->print( os, indent );
74        } // if
75}
76
77void ObjectDecl::printShort( std::ostream &os, int indent ) const {
78#if 0
79        if ( get_mangleName() != "") {
80                os << get_mangleName() << ": ";
81        } else
82#endif
83        if ( get_name() != "" ) {
84                os << get_name() << ": ";
85        } // if
86
87        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
88                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
89        } // if
90
91        if ( get_type() ) {
92                get_type()->print( os, indent );
93        } else {
94                os << "untyped entity ";
95        } // if
96
97        if ( bitfieldWidth ) {
98                os << "with bitfield width ";
99                bitfieldWidth->print( os );
100        } // if
101}
102
103// Local Variables: //
104// tab-width: 4 //
105// mode: c++ //
106// compile-command: "make install" //
107// End: //
Note: See TracBrowser for help on using the repository browser.