source: src/SynTree/ObjectDecl.cc@ 4ffdd63

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 with_gc
Last change on this file since 4ffdd63 was 668edd6b, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

Merge branch 'fix-tree-printing' into ctor

Conflicts:

src/SynTree/Expression.cc
src/SynTree/Initializer.cc
src/SynTree/ObjectDecl.cc

  • Property mode set to 100644
File size: 2.6 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
[1cbca6e]11// Last Modified By : Rob Schluntz
[668edd6b]12// Last Modified On : Tue Apr 26 12:56:27 2016
[d63eeb0]13// Update Count : 30
[0dd3a2f]14//
15
[51b73452]16#include "Declaration.h"
17#include "Type.h"
18#include "Initializer.h"
19#include "Expression.h"
[d3b7937]20#include "Common/utility.h"
[974906e2]21#include "Statement.h"
[51b73452]22
[1db21619]23ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )
[0dd3a2f]24 : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
[1db21619]25 set_isInline( isInline );
26 set_isNoreturn( isNoreturn );
[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 ) {
45 os << LinkageSpec::toString( get_linkage() ) << " ";
46 } // if
[d9a0e76]47
[68cd1ce]48 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
49 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]50 } // if
[d9a0e76]51
[0dd3a2f]52 if ( get_type() ) {
53 get_type()->print( os, indent );
54 } else {
[1cbca6e]55 os << " untyped entity ";
[0dd3a2f]56 } // if
[d9a0e76]57
[0dd3a2f]58 if ( init ) {
[1cbca6e]59 os << " with initializer ";
[0dd3a2f]60 init->print( os, indent );
[974906e2]61 os << std::string(indent, ' ') << "maybeConstructed? " << init->get_maybeConstructed();
[0dd3a2f]62 } // if
[d9a0e76]63
[0dd3a2f]64 if ( bitfieldWidth ) {
[1cbca6e]65 os << " with bitfield width ";
[0dd3a2f]66 bitfieldWidth->print( os );
67 } // if
[51b73452]68}
69
[d9a0e76]70void ObjectDecl::printShort( std::ostream &os, int indent ) const {
[d939274]71#if 0
72 if ( get_mangleName() != "") {
[974906e2]73 os << get_mangleName() << ": ";
74 } else
[d939274]75#endif
[0dd3a2f]76 if ( get_name() != "" ) {
[cf0941d]77 os << get_name() << ": ";
[0dd3a2f]78 } // if
[d9a0e76]79
[68cd1ce]80 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
81 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
[0dd3a2f]82 } // if
[d9a0e76]83
[0dd3a2f]84 if ( get_type() ) {
85 get_type()->print( os, indent );
86 } else {
87 os << "untyped entity ";
88 } // if
[d9a0e76]89
[0dd3a2f]90 if ( bitfieldWidth ) {
91 os << "with bitfield width ";
92 bitfieldWidth->print( os );
93 } // if
[51b73452]94}
[0dd3a2f]95
96// Local Variables: //
97// tab-width: 4 //
98// mode: c++ //
99// compile-command: "make install" //
100// End: //
Note: See TracBrowser for help on using the repository browser.