Changes in src/CodeGen/CodeGenerator.cc [486341f:3c13c03]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r486341f r3c13c03 309 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 310 newExpr->get_args().push_back( *arg ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 311 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 313 312 assert( type ); 314 newExpr-> get_results().push_back( type->clone() );313 newExpr->set_result( type->clone() ); 315 314 *arg = newExpr; 316 315 } // if … … 527 526 extension( castExpr ); 528 527 output << "("; 529 if ( castExpr->get_result s().empty() ) {528 if ( castExpr->get_result()->isVoid() ) { 530 529 output << "(void)" ; 531 } else if ( ! castExpr->get_result s().front()->get_isLvalue() ) {530 } else if ( ! castExpr->get_result()->get_isLvalue() ) { 532 531 // at least one result type of cast, but not an lvalue 533 532 output << "("; 534 output << genType( castExpr->get_result s().front(), "" );533 output << genType( castExpr->get_result(), "" ); 535 534 output << ")"; 536 535 } else { … … 640 639 } 641 640 642 void CodeGenerator::visit( TupleExpr * tupleExpr ) { }641 void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); } 643 642 644 643 void CodeGenerator::visit( TypeExpr * typeExpr ) {} … … 654 653 asmExpr->get_operand()->accept( *this ); 655 654 output << " )"; 655 } 656 657 void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) { 658 assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) ); 659 output << "(" << genType( compLitExpr->get_type(), "" ) << ")"; 660 compLitExpr->get_initializer()->accept( *this ); 661 } 662 663 void CodeGenerator::visit( StmtExpr * stmtExpr ) { 664 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 665 output << "({" << std::endl; 666 cur_indent += CodeGenerator::tabsize; 667 unsigned int numStmts = stmts.size(); 668 unsigned int i = 0; 669 for ( Statement * stmt : stmts ) { 670 output << indent << printLabels( stmt->get_labels() ); 671 if ( i+1 == numStmts ) { 672 // last statement in a statement expression needs to be handled specially - 673 // cannot cast to void, otherwise the expression statement has no value 674 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) { 675 exprStmt->get_expr()->accept( *this ); 676 output << ";" << endl; 677 ++i; 678 break; 679 } 680 } 681 stmt->accept( *this ); 682 output << endl; 683 if ( wantSpacing( stmt ) ) { 684 output << endl; 685 } // if 686 ++i; 687 } 688 cur_indent -= CodeGenerator::tabsize; 689 output << indent << "})"; 656 690 } 657 691
Note:
See TracChangeset
for help on using the changeset viewer.