source: src/SynTree/ObjectDecl.cc @ 9243a501

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 9243a501 was 9243a501, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

fixed printing in MemberExpr?, FunctionDecl?, ObjectDecl?, etc.

  • 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//
[89231bc]7// ObjectDecl.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[1cbca6e]11// Last Modified By : Rob Schluntz
[9243a501]12// Last Modified On : Wed May 04 12:11:56 2016
[89231bc]13// Update Count     : 30
[0dd3a2f]14//
15
[51b7345]16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
[d3b7937]20#include "Common/utility.h"
[51b7345]21
[1db21619]22ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )
[0dd3a2f]23        : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
[1db21619]24        set_isInline( isInline );
25        set_isNoreturn( isNoreturn );
[51b7345]26}
27
28ObjectDecl::ObjectDecl( const ObjectDecl &other )
[0dd3a2f]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 ) {
44                os << LinkageSpec::toString( get_linkage() ) << " ";
45        } // if
[d9a0e76]46
[68cd1ce]47        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
48                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]49        } // if
[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 ) {
[9243a501]58                os << std::string(indent, ' ');
[1cbca6e]59                os << " with initializer ";
[0dd3a2f]60                init->print( os, indent );
61        } // if
[d9a0e76]62
[0dd3a2f]63        if ( bitfieldWidth ) {
[9243a501]64                os << std::string(indent, ' ');
[1cbca6e]65                os << " with bitfield width ";
[0dd3a2f]66                bitfieldWidth->print( os );
67        } // if
[51b7345]68}
69
[d9a0e76]70void ObjectDecl::printShort( std::ostream &os, int indent ) const {
[d939274]71#if 0
72        if ( get_mangleName() != "") {
[89231bc]73                os << get_mangleName() << ": ";
74        } else
[d939274]75#endif
[0dd3a2f]76        if ( get_name() != "" ) {
[cf0941d]77                os << get_name() << ": ";
[0dd3a2f]78        } // if
[d9a0e76]79
[68cd1ce]80        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
81                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]82        } // if
[d9a0e76]83
[0dd3a2f]84        if ( get_type() ) {
85                get_type()->print( os, indent );
86        } else {
87                os << "untyped entity ";
88        } // if
[d9a0e76]89
[0dd3a2f]90        if ( bitfieldWidth ) {
91                os << "with bitfield width ";
92                bitfieldWidth->print( os );
93        } // if
[51b7345]94}
[0dd3a2f]95
96// Local Variables: //
97// tab-width: 4 //
98// mode: c++ //
99// compile-command: "make install" //
100// End: //
Note: See TracBrowser for help on using the repository browser.