Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rf1e012b r803deb1  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jan 19 13:15:44 2016
    13 // Update Count     : 251
     12// Last Modified On : Wed Jan 20 12:54:50 2016
     13// Update Count     : 241
    1414//
    1515
     
    258258
    259259                                  case OT_CALL:
    260                                         // there are no intrinsic definitions of the function call operator or constructors or destructors
     260                                        // there are no intrinsic definitions of the function call operator
    261261                                        assert( false );
    262262                                        break;
    263 
    264                                   case OT_CTOR:
    265                                   // intrinsic constructors should never be called directly - they should be transformed back into Initializer nodes
    266                                   assert(false);
    267                                   break;
    268 
    269                                   case OT_DTOR:
    270                                   // intrinsic destructors do nothing - don't generate any code
    271                                   output << " // " << dynamic_cast<VariableExpr*>(applicationExpr->get_function())->get_var()->get_name() << endl;
    272                                   break;
    273263
    274264                                  case OT_PREFIX:
     
    287277                                        output << opInfo.symbol;
    288278                                        break;
    289 
    290279
    291280                                  case OT_INFIX:
     
    334323                                  case OT_CALL:
    335324                                        assert( false );
    336 
    337                                         case OT_CTOR:
    338                                         case OT_DTOR:
    339                                         // intrinsic constructors should never be called
    340                                         // intrinsic destructors do nothing
    341325                                        break;
    342326
     
    408392
    409393        void CodeGenerator::visit( CastExpr *castExpr ) {
    410                 // if the cast is to an lvalue type, then the cast
    411                 // should be dropped, since the result of a cast is
    412                 // never an lvalue in C
    413                 if ( castExpr->get_results().front()->get_isLvalue() ) {
    414                         castExpr->get_arg()->accept( *this );
    415                 } else {
    416                         output << "((";
    417                         if ( castExpr->get_results().empty() ) {
    418                                 output << "void" ;
    419                         } else {
    420                                 output << genType( castExpr->get_results().front(), "" );
    421                         } // if
     394                output << "(";
     395                if ( castExpr->get_results().empty() ) {
     396                        output << "(void)" ;
     397                } else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
     398                        // at least one result type of cast, but not an lvalue
     399                        output << "(";
     400                        output << genType( castExpr->get_results().front(), "" );
    422401                        output << ")";
    423                         castExpr->get_arg()->accept( *this );
    424                         output << ")";
     402                } else {
     403                        // otherwise, the cast is to an lvalue type, so the cast
     404                        // should be dropped, since the result of a cast is
     405                        // never an lvalue in C
    425406                }
     407                castExpr->get_arg()->accept( *this );
     408                output << ")";
    426409        }
    427410
Note: See TracChangeset for help on using the changeset viewer.