Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/FunctionDecl.cc

    r03e5d14 r7baed7d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 15:41:05 2016
     12// Last Modified On : Fri May 06 15:59:48 2016
    1313// Update Count     : 19
    1414//
     
    1919#include "Statement.h"
    2020#include "Type.h"
     21#include "Attribute.h"
    2122#include "Common/utility.h"
    2223
    23 FunctionDecl::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 ) {
     24FunctionDecl::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 ) {
    2526        set_isInline( isInline );
    2627        set_isNoreturn( isNoreturn );
     
    3233
    3334FunctionDecl::FunctionDecl( const FunctionDecl &other )
    34         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
     35        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     36                cloneAll( other.attributes, attributes );
    3537}
    3638
     
    3840        delete type;
    3941        delete statements;
     42        deleteAll( attributes );
    4043}
    4144
     
    6568                os << "_Noreturn ";
    6669        } // if
    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         }
     70
     71        printAll( attributes, os, indent );
     72
    8073        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    8174                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    10093        if ( statements ) {
    10194                os << string( indent + 2, ' ' ) << "with body " << endl;
     95                os << string( indent + 4, ' ' );
    10296                statements->print( os, indent + 4 );
    10397        } // if
     
    117111                os << "_Noreturn ";
    118112        } // if
    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         }
     113
     114        // xxx - should printShort print attributes?
     115
    132116        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    133117                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
Note: See TracChangeset for help on using the changeset viewer.