source: src/SynTree/ObjectDecl.cc @ dd020c0

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

first attempt to create function specifiers

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