Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r803deb1 rf1e012b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 20 12:54:50 2016
    13 // Update Count     : 241
     12// Last Modified On : Tue Jan 19 13:15:44 2016
     13// Update Count     : 251
    1414//
    1515
     
    258258
    259259                                  case OT_CALL:
    260                                         // there are no intrinsic definitions of the function call operator
     260                                        // there are no intrinsic definitions of the function call operator or constructors or destructors
    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;
    263273
    264274                                  case OT_PREFIX:
     
    277287                                        output << opInfo.symbol;
    278288                                        break;
     289
    279290
    280291                                  case OT_INFIX:
     
    323334                                  case OT_CALL:
    324335                                        assert( false );
     336
     337                                        case OT_CTOR:
     338                                        case OT_DTOR:
     339                                        // intrinsic constructors should never be called
     340                                        // intrinsic destructors do nothing
    325341                                        break;
    326342
     
    392408
    393409        void CodeGenerator::visit( CastExpr *castExpr ) {
    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(), "" );
     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
    401422                        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
     423                        castExpr->get_arg()->accept( *this );
     424                        output << ")";
    406425                }
    407                 castExpr->get_arg()->accept( *this );
    408                 output << ")";
    409426        }
    410427
Note: See TracChangeset for help on using the changeset viewer.