[fa2e183] | 1 | #include <list> // for list |
---|
| 2 | #include <ostream> // for operator<<, ostream, basic_ostream |
---|
| 3 | #include <string> // for operator<<, string, char_traits, ope... |
---|
| 4 | |
---|
| 5 | #include "Attribute.h" // for Attribute |
---|
| 6 | #include "Declaration.h" |
---|
| 7 | #include "Common/utility.h" // for maybeClone, printAll |
---|
| 8 | #include "LinkageSpec.h" // for Spec, linkageName, Cforall |
---|
| 9 | #include "Type.h" // for Type, Type::StorageClasses, Type::Fu... |
---|
| 10 | |
---|
| 11 | InlineValueDecl::InlineValueDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, |
---|
| 12 | Type * type, const std::list< Attribute * >attributes, Type::FuncSpecifiers fs) |
---|
| 13 | : Parent( name, scs, linkage, attributes, fs ), type( type ) {} |
---|
| 14 | |
---|
| 15 | InlineValueDecl::InlineValueDecl( const InlineValueDecl &other) |
---|
| 16 | : Parent( other), type( maybeClone( other.type ) ) {} |
---|
| 17 | |
---|
| 18 | InlineValueDecl::~InlineValueDecl() { delete type; } |
---|
| 19 | |
---|
| 20 | InlineValueDecl * InlineValueDecl::newInlineValueDecl( const std::string &name, Type * type ) { |
---|
| 21 | return new InlineValueDecl( name, Type::StorageClasses(), LinkageSpec::C, type ); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | void InlineValueDecl::print( std::ostream &os, Indenter indent ) const { |
---|
| 25 | if ( name != "" ) os << name << ": "; |
---|
| 26 | |
---|
| 27 | if ( linkage != LinkageSpec::Cforall ) { |
---|
| 28 | os << LinkageSpec::name( linkage ) << " "; |
---|
| 29 | } // if |
---|
| 30 | |
---|
| 31 | get_storageClasses().print( os ); |
---|
| 32 | |
---|
| 33 | if ( type ) { |
---|
| 34 | type->print( os, indent ); |
---|
| 35 | } else { |
---|
| 36 | os << " untyped entity "; |
---|
| 37 | } // if |
---|
| 38 | |
---|
| 39 | if ( ! attributes.empty() ) { |
---|
| 40 | os << std::endl << indent << "... with attributes:" << std::endl; |
---|
| 41 | printAll( attributes, os, indent+1 ); |
---|
| 42 | } // if |
---|
| 43 | |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | void InlineValueDecl::printShort( std::ostream &os, Indenter indent ) const { |
---|
| 47 | if ( name != "" ) os << name << ": "; |
---|
| 48 | |
---|
| 49 | get_storageClasses().print( os ); |
---|
| 50 | |
---|
| 51 | if ( type ) { |
---|
| 52 | type->print( os, indent ); |
---|
| 53 | } else { |
---|
| 54 | os << "untyped entity "; |
---|
| 55 | } // if |
---|
| 56 | |
---|
| 57 | } |
---|