source: src/SynTree/ObjectDecl.cc @ 6c4ff37

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 6c4ff37 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: seventh groups of files

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