[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 | // |
---|
| 7 | // ObjectDecl.cc -- |
---|
| 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[1cbca6e] | 11 | // Last Modified By : Rob Schluntz |
---|
| 12 | // Last Modified On : Tue Sep 29 14:13:01 2015 |
---|
| 13 | // Update Count : 18 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #include "Declaration.h" |
---|
| 17 | #include "Type.h" |
---|
| 18 | #include "Initializer.h" |
---|
| 19 | #include "Expression.h" |
---|
| 20 | #include "utility.h" |
---|
| 21 | |
---|
[1db21619] | 22 | ObjectDecl::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 | |
---|
| 28 | ObjectDecl::ObjectDecl( const ObjectDecl &other ) |
---|
[0dd3a2f] | 29 | : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) { |
---|
[51b7345] | 30 | } |
---|
| 31 | |
---|
[d9a0e76] | 32 | ObjectDecl::~ObjectDecl() { |
---|
[0dd3a2f] | 33 | delete type; |
---|
| 34 | delete init; |
---|
| 35 | delete bitfieldWidth; |
---|
[51b7345] | 36 | } |
---|
| 37 | |
---|
[d9a0e76] | 38 | void 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 ) { |
---|
[1cbca6e] | 58 | os << " with initializer "; |
---|
[0dd3a2f] | 59 | init->print( os, indent ); |
---|
| 60 | } // if |
---|
[d9a0e76] | 61 | |
---|
[0dd3a2f] | 62 | if ( bitfieldWidth ) { |
---|
[1cbca6e] | 63 | os << " with bitfield width "; |
---|
[0dd3a2f] | 64 | bitfieldWidth->print( os ); |
---|
| 65 | } // if |
---|
[51b7345] | 66 | } |
---|
| 67 | |
---|
[d9a0e76] | 68 | void ObjectDecl::printShort( std::ostream &os, int indent ) const { |
---|
[d939274] | 69 | #if 0 |
---|
| 70 | if ( get_mangleName() != "") { |
---|
[cf0941d] | 71 | os << get_mangleName() << ": "; |
---|
[d939274] | 72 | } else |
---|
| 73 | #endif |
---|
[0dd3a2f] | 74 | if ( get_name() != "" ) { |
---|
[cf0941d] | 75 | os << get_name() << ": "; |
---|
[0dd3a2f] | 76 | } // if |
---|
[d9a0e76] | 77 | |
---|
[68cd1ce] | 78 | if ( get_storageClass() != DeclarationNode::NoStorageClass ) { |
---|
| 79 | os << DeclarationNode::storageName[ get_storageClass() ] << ' '; |
---|
[0dd3a2f] | 80 | } // if |
---|
[d9a0e76] | 81 | |
---|
[0dd3a2f] | 82 | if ( get_type() ) { |
---|
| 83 | get_type()->print( os, indent ); |
---|
| 84 | } else { |
---|
| 85 | os << "untyped entity "; |
---|
| 86 | } // if |
---|
[d9a0e76] | 87 | |
---|
[0dd3a2f] | 88 | if ( bitfieldWidth ) { |
---|
| 89 | os << "with bitfield width "; |
---|
| 90 | bitfieldWidth->print( os ); |
---|
| 91 | } // if |
---|
[51b7345] | 92 | } |
---|
[0dd3a2f] | 93 | |
---|
| 94 | // Local Variables: // |
---|
| 95 | // tab-width: 4 // |
---|
| 96 | // mode: c++ // |
---|
| 97 | // compile-command: "make install" // |
---|
| 98 | // End: // |
---|