/* * This file is part of the Cforall project * * $Id: ObjectDecl.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $ * */ #include "Declaration.h" #include "Type.h" #include "Initializer.h" #include "Expression.h" #include "utility.h" ObjectDecl::ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init ) : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { } ObjectDecl::ObjectDecl( const ObjectDecl &other ) : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) { } ObjectDecl::~ObjectDecl() { delete type; delete init; delete bitfieldWidth; } void ObjectDecl::print( std::ostream &os, int indent ) const { if( get_name() != "" ) { os << get_name() << ": a "; } if( get_linkage() != LinkageSpec::Cforall ) { os << LinkageSpec::toString( get_linkage() ) << " "; } if( get_storageClass() != NoStorageClass ) { os << storageClassName[ get_storageClass() ] << ' '; } if( get_type() ) { get_type()->print( os, indent ); } else { os << "untyped entity "; } if( init ) { os << "with initializer "; init->print( os, indent ); } if( bitfieldWidth ) { os << "with bitfield width "; bitfieldWidth->print( os ); } } void ObjectDecl::printShort( std::ostream &os, int indent ) const { if( get_name() != "" ) { os << get_name() << ": a "; } if( get_storageClass() != NoStorageClass ) { os << storageClassName[ get_storageClass() ] << ' '; } if( get_type() ) { get_type()->print( os, indent ); } else { os << "untyped entity "; } if( bitfieldWidth ) { os << "with bitfield width "; bitfieldWidth->print( os ); } }