Changes in src/CodeGen/CodeGenerator.cc [f1e012b:803deb1]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rf1e012b r803deb1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jan 19 13:15:44201613 // Update Count : 2 5112 // Last Modified On : Wed Jan 20 12:54:50 2016 13 // Update Count : 241 14 14 // 15 15 … … 258 258 259 259 case OT_CALL: 260 // there are no intrinsic definitions of the function call operator or constructors or destructors260 // there are no intrinsic definitions of the function call operator 261 261 assert( false ); 262 262 break; 263 264 case OT_CTOR:265 // intrinsic constructors should never be called directly - they should be transformed back into Initializer nodes266 assert(false);267 break;268 269 case OT_DTOR:270 // intrinsic destructors do nothing - don't generate any code271 output << " // " << dynamic_cast<VariableExpr*>(applicationExpr->get_function())->get_var()->get_name() << endl;272 break;273 263 274 264 case OT_PREFIX: … … 287 277 output << opInfo.symbol; 288 278 break; 289 290 279 291 280 case OT_INFIX: … … 334 323 case OT_CALL: 335 324 assert( false ); 336 337 case OT_CTOR:338 case OT_DTOR:339 // intrinsic constructors should never be called340 // intrinsic destructors do nothing341 325 break; 342 326 … … 408 392 409 393 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(), "" ); 422 401 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 425 406 } 407 castExpr->get_arg()->accept( *this ); 408 output << ")"; 426 409 } 427 410
Note:
See TracChangeset
for help on using the changeset viewer.