source: src/SynTree/ObjectDecl.cc @ faddbd8

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since faddbd8 was faddbd8, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

more refactoring of parser code, new tuple syntax

  • Property mode set to 100644
File size: 2.8 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//
[974906e2]7// ObjectDecl.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[8b7ee09]11// Last Modified By : Peter A. Buhr
[faddbd8]12// Last Modified On : Sat Oct  1 23:05:56 2016
13// Update Count     : 32
[0dd3a2f]14//
15
[51b7345]16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
[f9cebb5]20#include "Attribute.h"
[d3b7937]21#include "Common/utility.h"
[974906e2]22#include "Statement.h"
[51b7345]23
[8b7ee09]24ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn )
[f9cebb5]25        : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
[1db21619]26        set_isInline( isInline );
27        set_isNoreturn( isNoreturn );
[51b7345]28}
29
30ObjectDecl::ObjectDecl( const ObjectDecl &other )
[71f4e4f]31        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
[51b7345]32}
33
[d9a0e76]34ObjectDecl::~ObjectDecl() {
[0dd3a2f]35        delete type;
36        delete init;
37        delete bitfieldWidth;
[51b7345]38}
39
[d9a0e76]40void ObjectDecl::print( std::ostream &os, int indent ) const {
[0dd3a2f]41        if ( get_name() != "" ) {
[cf0941d]42                os << get_name() << ": ";
[0dd3a2f]43        } // if
[d9a0e76]44
[0dd3a2f]45        if ( get_linkage() != LinkageSpec::Cforall ) {
[faddbd8]46                os << LinkageSpec::linkageName( get_linkage() ) << " ";
[0dd3a2f]47        } // if
[d9a0e76]48
[f9cebb5]49        printAll( get_attributes(), os, indent );
50
[68cd1ce]51        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
52                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]53        } // if
[d9a0e76]54
[0dd3a2f]55        if ( get_type() ) {
56                get_type()->print( os, indent );
57        } else {
[1cbca6e]58                os << " untyped entity ";
[0dd3a2f]59        } // if
[d9a0e76]60
[0dd3a2f]61        if ( init ) {
[1cbca6e]62                os << " with initializer ";
[0dd3a2f]63                init->print( os, indent );
[d668182]64                os << std::endl << std::string(indent, ' ');
65                os << "maybeConstructed? " << init->get_maybeConstructed();
[0dd3a2f]66        } // if
[d9a0e76]67
[0dd3a2f]68        if ( bitfieldWidth ) {
[9243a501]69                os << std::string(indent, ' ');
[1cbca6e]70                os << " with bitfield width ";
[0dd3a2f]71                bitfieldWidth->print( os );
72        } // if
[51b7345]73}
74
[d9a0e76]75void ObjectDecl::printShort( std::ostream &os, int indent ) const {
[d939274]76#if 0
77        if ( get_mangleName() != "") {
[974906e2]78                os << get_mangleName() << ": ";
79        } else
[d939274]80#endif
[0dd3a2f]81        if ( get_name() != "" ) {
[cf0941d]82                os << get_name() << ": ";
[0dd3a2f]83        } // if
[d9a0e76]84
[f9cebb5]85        // xxx - should printShort print attributes?
86
[68cd1ce]87        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
88                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]89        } // if
[d9a0e76]90
[0dd3a2f]91        if ( get_type() ) {
92                get_type()->print( os, indent );
93        } else {
94                os << "untyped entity ";
95        } // if
[d9a0e76]96
[0dd3a2f]97        if ( bitfieldWidth ) {
98                os << "with bitfield width ";
99                bitfieldWidth->print( os );
100        } // if
[51b7345]101}
[0dd3a2f]102
103// Local Variables: //
104// tab-width: 4 //
105// mode: c++ //
106// compile-command: "make install" //
107// End: //
Note: See TracBrowser for help on using the repository browser.