source: translator/SynTree/ObjectDecl.cc@ 643a2e1

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 643a2e1 was d9a0e76, checked in by Peter A. Buhr <pabuhr@…>, 11 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 
[51b73452]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 ) {
[51b73452]10}
11
12ObjectDecl::ObjectDecl( const ObjectDecl &other )
[d9a0e76]13 : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
[51b73452]14}
15
[d9a0e76]16ObjectDecl::~ObjectDecl() {
[51b73452]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() != "" ) {
[51b73452]24 os << get_name() << ": a ";
25 }
[d9a0e76]26
27 if ( get_linkage() != LinkageSpec::Cforall ) {
[51b73452]28 os << LinkageSpec::toString( get_linkage() ) << " ";
29 }
[d9a0e76]30
31 if ( get_storageClass() != NoStorageClass ) {
[51b73452]32 os << storageClassName[ get_storageClass() ] << ' ';
33 }
[d9a0e76]34
35 if ( get_type() ) {
[51b73452]36 get_type()->print( os, indent );
37 } else {
38 os << "untyped entity ";
39 }
[d9a0e76]40
41 if ( init ) {
[51b73452]42 os << "with initializer ";
43 init->print( os, indent );
44 }
[d9a0e76]45
46 if ( bitfieldWidth ) {
[51b73452]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() != "" ) {
[51b73452]54 os << get_name() << ": a ";
55 }
[d9a0e76]56
57 if ( get_storageClass() != NoStorageClass ) {
[51b73452]58 os << storageClassName[ get_storageClass() ] << ' ';
59 }
[d9a0e76]60
61 if ( get_type() ) {
[51b73452]62 get_type()->print( os, indent );
63 } else {
64 os << "untyped entity ";
65 }
[d9a0e76]66
67 if ( bitfieldWidth ) {
[51b73452]68 os << "with bitfield width ";
69 bitfieldWidth->print( os );
70 }
71}
Note: See TracBrowser for help on using the repository browser.