source: src/SynTree/ObjectDecl.cc@ 982f95d

new-env
Last change on this file since 982f95d was 68f9c43, checked in by Aaron Moss <a3moss@…>, 8 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 3.0 KB
Line 
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 : Thu Mar 16 08:34:27 2017
13// Update Count : 59
14//
15
16#include <list> // for list
17#include <ostream> // for operator<<, ostream, basic_ostream
18#include <string> // for operator<<, string, char_traits, ope...
19
20#include "Attribute.h" // for Attribute
21#include "Common/utility.h" // for maybeClone, printAll
22#include "Declaration.h" // for ObjectDecl, ObjectDecl::Parent
23#include "Expression.h" // for Expression
24#include "Initializer.h" // for Initializer
25#include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall
26#include "Type.h" // for Type, Type::StorageClasses, Type::Fu...
27
28ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, Type::FuncSpecifiers fs )
29 : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
30}
31
32ObjectDecl::ObjectDecl( const ObjectDecl &other )
33 : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
34}
35
36ObjectDecl * ObjectDecl::newObject( const std::string & name, Type * type, Initializer * init ) {
37 return new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, 0, type, init );
38}
39
40void ObjectDecl::print( std::ostream &os, Indenter indent ) const {
41 if ( name != "" ) os << name << ": ";
42
43 if ( linkage != LinkageSpec::Cforall ) {
44 os << LinkageSpec::linkageName( linkage ) << " ";
45 } // if
46
47 get_storageClasses().print( os );
48
49 if ( type ) {
50 type->print( os, indent );
51 } else {
52 os << " untyped entity ";
53 } // if
54
55 if ( init ) {
56 os << " with initializer (" << (init->get_maybeConstructed() ? "maybe constructed" : "not constructed") << ")" << std::endl << indent+1;
57 init->print( os, indent+1 );
58 os << std::endl;
59 } // if
60
61 if ( ! attributes.empty() ) {
62 os << std::endl << indent << "... with attributes: " << std::endl;
63 printAll( attributes, os, indent+1 );
64 }
65
66 if ( bitfieldWidth ) {
67 os << indent << " with bitfield width ";
68 bitfieldWidth->print( os );
69 } // if
70}
71
72void ObjectDecl::printShort( std::ostream &os, Indenter indent ) const {
73#if 0
74 if ( get_mangleName() != "") {
75 os << get_mangleName() << ": ";
76 } else
77#endif
78 if ( name != "" ) os << name << ": ";
79
80 get_storageClasses().print( os );
81
82 if ( type ) {
83 type->print( os, indent );
84 } else {
85 os << "untyped entity ";
86 } // if
87
88 if ( bitfieldWidth ) {
89 os << "with bitfield width ";
90 bitfieldWidth->print( os );
91 } // if
92}
93
94// Local Variables: //
95// tab-width: 4 //
96// mode: c++ //
97// compile-command: "make install" //
98// End: //
Note: See TracBrowser for help on using the repository browser.