source: translator/SynTree/ObjectDecl.cc @ 9df2dd5

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 9df2dd5 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
Line 
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 )
9    : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
10}
11
12ObjectDecl::ObjectDecl( const ObjectDecl &other )
13    : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
14}
15
16ObjectDecl::~ObjectDecl() {
17    delete type;
18    delete init;
19    delete bitfieldWidth;
20}
21
22void ObjectDecl::print( std::ostream &os, int indent ) const {
23    if ( get_name() != "" ) {
24        os << get_name() << ": a ";
25    }
26
27    if ( get_linkage() != LinkageSpec::Cforall ) {
28        os << LinkageSpec::toString( get_linkage() ) << " ";
29    }
30
31    if ( get_storageClass() != NoStorageClass ) {
32        os << storageClassName[ get_storageClass() ] << ' ';
33    }
34
35    if ( get_type() ) {
36        get_type()->print( os, indent );
37    } else {
38        os << "untyped entity ";
39    }
40
41    if ( init ) {
42        os << "with initializer ";
43        init->print( os, indent );
44    }
45
46    if ( bitfieldWidth ) {
47        os << "with bitfield width ";
48        bitfieldWidth->print( os );
49    }
50}
51
52void ObjectDecl::printShort( std::ostream &os, int indent ) const {
53    if ( get_name() != "" ) {
54        os << get_name() << ": a ";
55    }
56
57    if ( get_storageClass() != NoStorageClass ) {
58        os << storageClassName[ get_storageClass() ] << ' ';
59    }
60
61    if ( get_type() ) {
62        get_type()->print( os, indent );
63    } else {
64        os << "untyped entity ";
65    }
66
67    if ( bitfieldWidth ) {
68        os << "with bitfield width ";
69        bitfieldWidth->print( os );
70    }
71}
Note: See TracBrowser for help on using the repository browser.