| 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
|
|---|
| 11 | // Last Modified By : Rob Schluntz
|
|---|
| 12 | // Last Modified On : Thu May 28 14:10:02 2015
|
|---|
| 13 | // Update Count : 8
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #include "Declaration.h"
|
|---|
| 17 | #include "Type.h"
|
|---|
| 18 | #include "Initializer.h"
|
|---|
| 19 | #include "Expression.h"
|
|---|
| 20 | #include "utility.h"
|
|---|
| 21 |
|
|---|
| 22 | ObjectDecl::ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init )
|
|---|
| 23 | : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | ObjectDecl::ObjectDecl( const ObjectDecl &other )
|
|---|
| 27 | : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | ObjectDecl::~ObjectDecl() {
|
|---|
| 31 | delete type;
|
|---|
| 32 | delete init;
|
|---|
| 33 | delete bitfieldWidth;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void ObjectDecl::print( std::ostream &os, int indent ) const {
|
|---|
| 37 | if ( get_name() != "" ) {
|
|---|
| 38 | os << get_name() << ": a ";
|
|---|
| 39 | } // if
|
|---|
| 40 |
|
|---|
| 41 | if ( get_linkage() != LinkageSpec::Cforall ) {
|
|---|
| 42 | os << LinkageSpec::toString( get_linkage() ) << " ";
|
|---|
| 43 | } // if
|
|---|
| 44 |
|
|---|
| 45 | if ( get_storageClass() != NoStorageClass ) {
|
|---|
| 46 | os << storageClassName[ get_storageClass() ] << ' ';
|
|---|
| 47 | } // if
|
|---|
| 48 |
|
|---|
| 49 | if ( get_type() ) {
|
|---|
| 50 | get_type()->print( os, indent );
|
|---|
| 51 | } else {
|
|---|
| 52 | os << "untyped entity ";
|
|---|
| 53 | } // if
|
|---|
| 54 |
|
|---|
| 55 | if ( init ) {
|
|---|
| 56 | os << "with initializer ";
|
|---|
| 57 | init->print( os, indent );
|
|---|
| 58 | } // if
|
|---|
| 59 |
|
|---|
| 60 | if ( bitfieldWidth ) {
|
|---|
| 61 | os << "with bitfield width ";
|
|---|
| 62 | bitfieldWidth->print( os );
|
|---|
| 63 | } // if
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | void ObjectDecl::printShort( std::ostream &os, int indent ) const {
|
|---|
| 67 | #if 0
|
|---|
| 68 | if ( get_mangleName() != "") {
|
|---|
| 69 | os << get_mangleName() << ": a ";
|
|---|
| 70 | } else
|
|---|
| 71 | #endif
|
|---|
| 72 | if ( get_name() != "" ) {
|
|---|
| 73 | os << get_name() << ": a ";
|
|---|
| 74 | } // if
|
|---|
| 75 |
|
|---|
| 76 | if ( get_storageClass() != NoStorageClass ) {
|
|---|
| 77 | os << storageClassName[ get_storageClass() ] << ' ';
|
|---|
| 78 | } // if
|
|---|
| 79 |
|
|---|
| 80 | if ( get_type() ) {
|
|---|
| 81 | get_type()->print( os, indent );
|
|---|
| 82 | } else {
|
|---|
| 83 | os << "untyped entity ";
|
|---|
| 84 | } // if
|
|---|
| 85 |
|
|---|
| 86 | if ( bitfieldWidth ) {
|
|---|
| 87 | os << "with bitfield width ";
|
|---|
| 88 | bitfieldWidth->print( os );
|
|---|
| 89 | } // if
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // Local Variables: //
|
|---|
| 93 | // tab-width: 4 //
|
|---|
| 94 | // mode: c++ //
|
|---|
| 95 | // compile-command: "make install" //
|
|---|
| 96 | // End: //
|
|---|