source: src/SynTree/ObjectDecl.cc @ ddfd945

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

move type FuncSpecifiers? from DeclarationNode? to Type

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[0dd3a2f]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//
[974906e2]7// ObjectDecl.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[8b7ee09]11// Last Modified By : Peter A. Buhr
[ddfd945]12// Last Modified On : Thu Mar 16 08:34:27 2017
13// Update Count     : 59
[0dd3a2f]14//
15
[51b7345]16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
[f9cebb5]20#include "Attribute.h"
[d3b7937]21#include "Common/utility.h"
[974906e2]22#include "Statement.h"
[51b7345]23
[ddfd945]24ObjectDecl::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 )
[a7c90d4]25        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
[51b7345]26}
27
28ObjectDecl::ObjectDecl( const ObjectDecl &other )
[71f4e4f]29        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
[51b7345]30}
31
[d9a0e76]32ObjectDecl::~ObjectDecl() {
[0dd3a2f]33        delete type;
34        delete init;
35        delete bitfieldWidth;
[51b7345]36}
37
[d9a0e76]38void ObjectDecl::print( std::ostream &os, int indent ) const {
[0dd3a2f]39        if ( get_name() != "" ) {
[cf0941d]40                os << get_name() << ": ";
[0dd3a2f]41        } // if
[d9a0e76]42
[0dd3a2f]43        if ( get_linkage() != LinkageSpec::Cforall ) {
[faddbd8]44                os << LinkageSpec::linkageName( get_linkage() ) << " ";
[0dd3a2f]45        } // if
[d9a0e76]46
[f9cebb5]47        printAll( get_attributes(), os, indent );
48
[6e8bd43]49        get_storageClasses().print( os );
[d9a0e76]50
[0dd3a2f]51        if ( get_type() ) {
52                get_type()->print( os, indent );
53        } else {
[1cbca6e]54                os << " untyped entity ";
[0dd3a2f]55        } // if
[d9a0e76]56
[0dd3a2f]57        if ( init ) {
[1cbca6e]58                os << " with initializer ";
[0dd3a2f]59                init->print( os, indent );
[d668182]60                os << std::endl << std::string(indent, ' ');
61                os << "maybeConstructed? " << init->get_maybeConstructed();
[0dd3a2f]62        } // if
[d9a0e76]63
[0dd3a2f]64        if ( bitfieldWidth ) {
[9243a501]65                os << std::string(indent, ' ');
[1cbca6e]66                os << " with bitfield width ";
[0dd3a2f]67                bitfieldWidth->print( os );
68        } // if
[51b7345]69}
70
[d9a0e76]71void ObjectDecl::printShort( std::ostream &os, int indent ) const {
[d939274]72#if 0
73        if ( get_mangleName() != "") {
[974906e2]74                os << get_mangleName() << ": ";
75        } else
[d939274]76#endif
[0dd3a2f]77        if ( get_name() != "" ) {
[cf0941d]78                os << get_name() << ": ";
[0dd3a2f]79        } // if
[d9a0e76]80
[f9cebb5]81        // xxx - should printShort print attributes?
82
[6e8bd43]83        get_storageClasses().print( os );
[d9a0e76]84
[0dd3a2f]85        if ( get_type() ) {
86                get_type()->print( os, indent );
87        } else {
88                os << "untyped entity ";
89        } // if
[d9a0e76]90
[0dd3a2f]91        if ( bitfieldWidth ) {
92                os << "with bitfield width ";
93                bitfieldWidth->print( os );
94        } // if
[51b7345]95}
[0dd3a2f]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.