source: src/SynTree/ObjectDecl.cc@ 8191203

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new stuck-waitfor-destruct with_gc
Last change on this file since 8191203 was dd020c0, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

first attempt to create function specifiers

  • 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
[dd020c0]12// Last Modified On : Fri Mar 3 20:59:27 2017
13// Update Count : 45
[0dd3a2f]14//
15
[51b73452]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"
[51b73452]23
[dd020c0]24ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpec fs )
25 : Parent( name, sc, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
26 set_functionSpecifiers( fs );
[51b73452]27}
28
29ObjectDecl::ObjectDecl( const ObjectDecl &other )
[71f4e4f]30 : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
[51b73452]31}
32
[d9a0e76]33ObjectDecl::~ObjectDecl() {
[0dd3a2f]34 delete type;
35 delete init;
36 delete bitfieldWidth;
[51b73452]37}
38
[d9a0e76]39void ObjectDecl::print( std::ostream &os, int indent ) const {
[0dd3a2f]40 if ( get_name() != "" ) {
[cf0941d]41 os << get_name() << ": ";
[0dd3a2f]42 } // if
[d9a0e76]43
[0dd3a2f]44 if ( get_linkage() != LinkageSpec::Cforall ) {
[faddbd8]45 os << LinkageSpec::linkageName( get_linkage() ) << " ";
[0dd3a2f]46 } // if
[d9a0e76]47
[f9cebb5]48 printAll( get_attributes(), os, indent );
49
[68cd1ce]50 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
[dd020c0]51 os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
[0dd3a2f]52 } // if
[d9a0e76]53
[0dd3a2f]54 if ( get_type() ) {
55 get_type()->print( os, indent );
56 } else {
[1cbca6e]57 os << " untyped entity ";
[0dd3a2f]58 } // if
[d9a0e76]59
[0dd3a2f]60 if ( init ) {
[1cbca6e]61 os << " with initializer ";
[0dd3a2f]62 init->print( os, indent );
[d668182]63 os << std::endl << std::string(indent, ' ');
64 os << "maybeConstructed? " << init->get_maybeConstructed();
[0dd3a2f]65 } // if
[d9a0e76]66
[0dd3a2f]67 if ( bitfieldWidth ) {
[9243a501]68 os << std::string(indent, ' ');
[1cbca6e]69 os << " with bitfield width ";
[0dd3a2f]70 bitfieldWidth->print( os );
71 } // if
[51b73452]72}
73
[d9a0e76]74void ObjectDecl::printShort( std::ostream &os, int indent ) const {
[d939274]75#if 0
76 if ( get_mangleName() != "") {
[974906e2]77 os << get_mangleName() << ": ";
78 } else
[d939274]79#endif
[0dd3a2f]80 if ( get_name() != "" ) {
[cf0941d]81 os << get_name() << ": ";
[0dd3a2f]82 } // if
[d9a0e76]83
[f9cebb5]84 // xxx - should printShort print attributes?
85
[68cd1ce]86 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
[dd020c0]87 os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
[0dd3a2f]88 } // if
[d9a0e76]89
[0dd3a2f]90 if ( get_type() ) {
91 get_type()->print( os, indent );
92 } else {
93 os << "untyped entity ";
94 } // if
[d9a0e76]95
[0dd3a2f]96 if ( bitfieldWidth ) {
97 os << "with bitfield width ";
98 bitfieldWidth->print( os );
99 } // if
[51b73452]100}
[0dd3a2f]101
102// Local Variables: //
103// tab-width: 4 //
104// mode: c++ //
105// compile-command: "make install" //
106// End: //
Note: See TracBrowser for help on using the repository browser.