[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 |
---|
[1cbca6e] | 11 | // Last Modified By : Rob Schluntz |
---|
[d668182] | 12 | // Last Modified On : Fri May 13 13:23:32 2016 |
---|
[d63eeb0] | 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" |
---|
[974906e2] | 21 | #include "Statement.h" |
---|
[51b7345] | 22 | |
---|
[1db21619] | 23 | ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn ) |
---|
[0dd3a2f] | 24 | : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { |
---|
[1db21619] | 25 | set_isInline( isInline ); |
---|
| 26 | set_isNoreturn( isNoreturn ); |
---|
[51b7345] | 27 | } |
---|
| 28 | |
---|
| 29 | ObjectDecl::ObjectDecl( const ObjectDecl &other ) |
---|
[71f4e4f] | 30 | : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) { |
---|
[51b7345] | 31 | } |
---|
| 32 | |
---|
[d9a0e76] | 33 | ObjectDecl::~ObjectDecl() { |
---|
[0dd3a2f] | 34 | delete type; |
---|
| 35 | delete init; |
---|
| 36 | delete bitfieldWidth; |
---|
[51b7345] | 37 | } |
---|
| 38 | |
---|
[d9a0e76] | 39 | void ObjectDecl::print( std::ostream &os, int indent ) const { |
---|
[0dd3a2f] | 40 | if ( get_name() != "" ) { |
---|
[cf0941d] | 41 | os << get_name() << ": "; |
---|
[0dd3a2f] | 42 | } // if |
---|
[d9a0e76] | 43 | |
---|
[0dd3a2f] | 44 | if ( get_linkage() != LinkageSpec::Cforall ) { |
---|
| 45 | os << LinkageSpec::toString( get_linkage() ) << " "; |
---|
| 46 | } // if |
---|
[d9a0e76] | 47 | |
---|
[68cd1ce] | 48 | if ( get_storageClass() != DeclarationNode::NoStorageClass ) { |
---|
| 49 | os << DeclarationNode::storageName[ get_storageClass() ] << ' '; |
---|
[0dd3a2f] | 50 | } // if |
---|
[d9a0e76] | 51 | |
---|
[0dd3a2f] | 52 | if ( get_type() ) { |
---|
| 53 | get_type()->print( os, indent ); |
---|
| 54 | } else { |
---|
[1cbca6e] | 55 | os << " untyped entity "; |
---|
[0dd3a2f] | 56 | } // if |
---|
[d9a0e76] | 57 | |
---|
[0dd3a2f] | 58 | if ( init ) { |
---|
[1cbca6e] | 59 | os << " with initializer "; |
---|
[0dd3a2f] | 60 | init->print( os, indent ); |
---|
[d668182] | 61 | os << std::endl << std::string(indent, ' '); |
---|
| 62 | os << "maybeConstructed? " << init->get_maybeConstructed(); |
---|
[0dd3a2f] | 63 | } // if |
---|
[d9a0e76] | 64 | |
---|
[0dd3a2f] | 65 | if ( bitfieldWidth ) { |
---|
[9243a501] | 66 | os << std::string(indent, ' '); |
---|
[1cbca6e] | 67 | os << " with bitfield width "; |
---|
[0dd3a2f] | 68 | bitfieldWidth->print( os ); |
---|
| 69 | } // if |
---|
[51b7345] | 70 | } |
---|
| 71 | |
---|
[d9a0e76] | 72 | void ObjectDecl::printShort( std::ostream &os, int indent ) const { |
---|
[d939274] | 73 | #if 0 |
---|
| 74 | if ( get_mangleName() != "") { |
---|
[974906e2] | 75 | os << get_mangleName() << ": "; |
---|
| 76 | } else |
---|
[d939274] | 77 | #endif |
---|
[0dd3a2f] | 78 | if ( get_name() != "" ) { |
---|
[cf0941d] | 79 | os << get_name() << ": "; |
---|
[0dd3a2f] | 80 | } // if |
---|
[d9a0e76] | 81 | |
---|
[68cd1ce] | 82 | if ( get_storageClass() != DeclarationNode::NoStorageClass ) { |
---|
| 83 | os << DeclarationNode::storageName[ get_storageClass() ] << ' '; |
---|
[0dd3a2f] | 84 | } // if |
---|
[d9a0e76] | 85 | |
---|
[0dd3a2f] | 86 | if ( get_type() ) { |
---|
| 87 | get_type()->print( os, indent ); |
---|
| 88 | } else { |
---|
| 89 | os << "untyped entity "; |
---|
| 90 | } // if |
---|
[d9a0e76] | 91 | |
---|
[0dd3a2f] | 92 | if ( bitfieldWidth ) { |
---|
| 93 | os << "with bitfield width "; |
---|
| 94 | bitfieldWidth->print( os ); |
---|
| 95 | } // if |
---|
[51b7345] | 96 | } |
---|
[0dd3a2f] | 97 | |
---|
| 98 | // Local Variables: // |
---|
| 99 | // tab-width: 4 // |
---|
| 100 | // mode: c++ // |
---|
| 101 | // compile-command: "make install" // |
---|
| 102 | // End: // |
---|