Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r971ae89 r7f5566b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Sep 17 15:24:08 2015
    13 // Update Count     : 231
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jul 27 14:40:06 2015
     13// Update Count     : 218
    1414//
    1515
     
    186186        }
    187187
    188         void CodeGenerator::printDesignators( std::list< Expression * > & designators ) {
    189                 typedef std::list< Expression * > DesignatorList;
    190                 if ( designators.size() == 0 ) return;
    191                 for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) {
    192                         if ( dynamic_cast< NameExpr * >( *iter ) ) {
    193                                 // if expression is a name, then initializing aggregate member
    194                                 output << ".";
    195                                 (*iter)->accept( *this );
    196                         } else {
    197                                 // if not a simple name, it has to be a constant expression, i.e. an array designator
    198                                 output << "[";
    199                                 (*iter)->accept( *this );
    200                                 output << "]";
    201                         }
    202                 }
    203                 output << " = ";
    204         }
    205 
    206188        void CodeGenerator::visit( SingleInit *init ) {
    207                 printDesignators( init->get_designators() );
    208189                init->get_value()->accept( *this );
    209190        }
    210191
    211192        void CodeGenerator::visit( ListInit *init ) {
    212                 printDesignators( init->get_designators() );
    213193                output << "{ ";
    214194                genCommaList( init->begin_initializers(), init->end_initializers() );
     
    392372
    393373        void CodeGenerator::visit( CastExpr *castExpr ) {
    394                 // if the cast is to an lvalue type, then the cast
    395                 // should be dropped, since the result of a cast is
    396                 // never an lvalue in C
    397                 if ( castExpr->get_results().front()->get_isLvalue() ) {
    398                         castExpr->get_arg()->accept( *this );
    399                 } else {
    400                         output << "((";
    401                         if ( castExpr->get_results().empty() ) {
    402                                 output << "void" ;
    403                         } else {
    404                                 output << genType( castExpr->get_results().front(), "" );
    405                         } // if
    406                         output << ")";
    407                         castExpr->get_arg()->accept( *this );
    408                         output << ")";                 
    409                 }
     374                output << "((";
     375                if ( castExpr->get_results().empty() ) {
     376                        output << "void" ;
     377                } else {
     378                        output << genType( castExpr->get_results().front(), "" );
     379                } // if
     380                output << ")";
     381                castExpr->get_arg()->accept( *this );
     382                output << ")";
    410383        }
    411384 
Note: See TracChangeset for help on using the changeset viewer.