Changes in src/CodeGen/CodeGenerator.cc [3c13c03:486341f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r3c13c03 r486341f 309 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 310 newExpr->get_args().push_back( *arg ); 311 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 312 313 assert( type ); 313 newExpr-> set_result( type->clone() );314 newExpr->get_results().push_back( type->clone() ); 314 315 *arg = newExpr; 315 316 } // if … … 526 527 extension( castExpr ); 527 528 output << "("; 528 if ( castExpr->get_result ()->isVoid() ) {529 if ( castExpr->get_results().empty() ) { 529 530 output << "(void)" ; 530 } else if ( ! castExpr->get_result ()->get_isLvalue() ) {531 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) { 531 532 // at least one result type of cast, but not an lvalue 532 533 output << "("; 533 output << genType( castExpr->get_result (), "" );534 output << genType( castExpr->get_results().front(), "" ); 534 535 output << ")"; 535 536 } else { … … 639 640 } 640 641 641 void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false );}642 void CodeGenerator::visit( TupleExpr * tupleExpr ) {} 642 643 643 644 void CodeGenerator::visit( TypeExpr * typeExpr ) {} … … 653 654 asmExpr->get_operand()->accept( *this ); 654 655 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 value674 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 } // if686 ++i;687 }688 cur_indent -= CodeGenerator::tabsize;689 output << indent << "})";690 656 } 691 657
Note:
See TracChangeset
for help on using the changeset viewer.