Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r486341f r3c13c03  
    309309                                                        UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    310310                                                        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() );
    313312                                                        assert( type );
    314                                                         newExpr->get_results().push_back( type->clone() );
     313                                                        newExpr->set_result( type->clone() );
    315314                                                        *arg = newExpr;
    316315                                                } // if
     
    527526                extension( castExpr );
    528527                output << "(";
    529                 if ( castExpr->get_results().empty() ) {
     528                if ( castExpr->get_result()->isVoid() ) {
    530529                        output << "(void)" ;
    531                 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
     530                } else if ( ! castExpr->get_result()->get_isLvalue() ) {
    532531                        // at least one result type of cast, but not an lvalue
    533532                        output << "(";
    534                         output << genType( castExpr->get_results().front(), "" );
     533                        output << genType( castExpr->get_result(), "" );
    535534                        output << ")";
    536535                } else {
     
    640639        }
    641640
    642         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
     641        void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); }
    643642
    644643        void CodeGenerator::visit( TypeExpr * typeExpr ) {}
     
    654653                asmExpr->get_operand()->accept( *this );
    655654                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 << "})";
    656690        }
    657691
Note: See TracChangeset for help on using the changeset viewer.