Changes in src/CodeGen/CodeGenerator.cc [971ae89:7f5566b]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r971ae89 r7f5566b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Sep 17 15:24:08201513 // Update Count : 2 3111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 27 14:40:06 2015 13 // Update Count : 218 14 14 // 15 15 … … 186 186 } 187 187 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 member194 output << ".";195 (*iter)->accept( *this );196 } else {197 // if not a simple name, it has to be a constant expression, i.e. an array designator198 output << "[";199 (*iter)->accept( *this );200 output << "]";201 }202 }203 output << " = ";204 }205 206 188 void CodeGenerator::visit( SingleInit *init ) { 207 printDesignators( init->get_designators() );208 189 init->get_value()->accept( *this ); 209 190 } 210 191 211 192 void CodeGenerator::visit( ListInit *init ) { 212 printDesignators( init->get_designators() );213 193 output << "{ "; 214 194 genCommaList( init->begin_initializers(), init->end_initializers() ); … … 392 372 393 373 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 << ")"; 410 383 } 411 384
Note:
See TracChangeset
for help on using the changeset viewer.