source: src/SynTree/ObjectDecl.cc@ dfee306

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 dfee306 was 68cd1ce, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

unify and fix storage class

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