Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/FunctionDecl.cc

    r7baed7d r03e5d14  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 15:59:48 2016
     12// Last Modified On : Fri May 06 15:41:05 2016
    1313// Update Count     : 19
    1414//
     
    1919#include "Statement.h"
    2020#include "Type.h"
    21 #include "Attribute.h"
    2221#include "Common/utility.h"
    2322
    24 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes )
    25                 : Parent( name, sc, linkage ), type( type ), statements( statements ), attributes( attributes ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) {
    2625        set_isInline( isInline );
    2726        set_isNoreturn( isNoreturn );
     
    3332
    3433FunctionDecl::FunctionDecl( const FunctionDecl &other )
    35         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
    36                 cloneAll( other.attributes, attributes );
     34        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
    3735}
    3836
     
    4038        delete type;
    4139        delete statements;
    42         deleteAll( attributes );
    4340}
    4441
     
    6865                os << "_Noreturn ";
    6966        } // if
    70 
    71         printAll( attributes, os, indent );
    72 
     67        switch ( attribute.type ) {
     68                case Attribute::Constructor:
     69                        os << "Global Constructor ";
     70                        break;
     71                case Attribute::Destructor:
     72                        os << "Global Destructor ";
     73                        break;
     74                default:
     75                        break;
     76        }
     77        if ( attribute.priority != Attribute::Default ) {
     78                os << "with priority " << attribute.priority << " ";
     79        }
    7380        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    7481                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    93100        if ( statements ) {
    94101                os << string( indent + 2, ' ' ) << "with body " << endl;
    95                 os << string( indent + 4, ' ' );
    96102                statements->print( os, indent + 4 );
    97103        } // if
     
    111117                os << "_Noreturn ";
    112118        } // if
    113 
    114         // xxx - should printShort print attributes?
    115 
     119        switch ( attribute.type ) {
     120                case Attribute::Constructor:
     121                        os << " Global Constructor ";
     122                        break;
     123                case Attribute::Destructor:
     124                        os << " Global Destructor ";
     125                        break;
     126                default:
     127                        break;
     128        }
     129        if ( attribute.priority != Attribute::Default ) {
     130                os << "with priority " << attribute.priority << " ";
     131        }
    116132        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    117133                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
Note: See TracChangeset for help on using the changeset viewer.