source: translator/SynTree/ObjectDecl.cc @ 17cd4eb

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 17cd4eb was d9a0e76, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[51b7345]1#include "Declaration.h"
2#include "Type.h"
3#include "Initializer.h"
4#include "Expression.h"
5#include "utility.h"
6
7
8ObjectDecl::ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init )
[d9a0e76]9    : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
[51b7345]10}
11
12ObjectDecl::ObjectDecl( const ObjectDecl &other )
[d9a0e76]13    : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
[51b7345]14}
15
[d9a0e76]16ObjectDecl::~ObjectDecl() {
[51b7345]17    delete type;
18    delete init;
19    delete bitfieldWidth;
20}
21
[d9a0e76]22void ObjectDecl::print( std::ostream &os, int indent ) const {
23    if ( get_name() != "" ) {
[51b7345]24        os << get_name() << ": a ";
25    }
[d9a0e76]26
27    if ( get_linkage() != LinkageSpec::Cforall ) {
[51b7345]28        os << LinkageSpec::toString( get_linkage() ) << " ";
29    }
[d9a0e76]30
31    if ( get_storageClass() != NoStorageClass ) {
[51b7345]32        os << storageClassName[ get_storageClass() ] << ' ';
33    }
[d9a0e76]34
35    if ( get_type() ) {
[51b7345]36        get_type()->print( os, indent );
37    } else {
38        os << "untyped entity ";
39    }
[d9a0e76]40
41    if ( init ) {
[51b7345]42        os << "with initializer ";
43        init->print( os, indent );
44    }
[d9a0e76]45
46    if ( bitfieldWidth ) {
[51b7345]47        os << "with bitfield width ";
48        bitfieldWidth->print( os );
49    }
50}
51
[d9a0e76]52void ObjectDecl::printShort( std::ostream &os, int indent ) const {
53    if ( get_name() != "" ) {
[51b7345]54        os << get_name() << ": a ";
55    }
[d9a0e76]56
57    if ( get_storageClass() != NoStorageClass ) {
[51b7345]58        os << storageClassName[ get_storageClass() ] << ' ';
59    }
[d9a0e76]60
61    if ( get_type() ) {
[51b7345]62        get_type()->print( os, indent );
63    } else {
64        os << "untyped entity ";
65    }
[d9a0e76]66
67    if ( bitfieldWidth ) {
[51b7345]68        os << "with bitfield width ";
69        bitfieldWidth->print( os );
70    }
71}
Note: See TracBrowser for help on using the repository browser.