Changeset 74bba15 for src/CodeGen/CodeGenerator.cc
- Timestamp:
- Sep 26, 2017, 5:19:32 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 5dc26f5
- Parents:
- af58ee0 (diff), a7d151f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
raf58ee0 r74bba15 443 443 void CodeGenerator::postvisit( UntypedExpr * untypedExpr ) { 444 444 extension( untypedExpr ); 445 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr-> get_function()) ) {445 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->function ) ) { 446 446 OperatorInfo opInfo; 447 if ( operatorLookup( nameExpr-> get_name(), opInfo ) ) {448 std::list< Expression* >::iterator arg = untypedExpr-> get_args().begin();447 if ( operatorLookup( nameExpr->name, opInfo ) ) { 448 std::list< Expression* >::iterator arg = untypedExpr->args.begin(); 449 449 switch ( opInfo.type ) { 450 450 case OT_INDEX: 451 assert( untypedExpr-> get_args().size() == 2 );451 assert( untypedExpr->args.size() == 2 ); 452 452 (*arg++)->accept( *visitor ); 453 453 output << "["; … … 461 461 case OT_CTOR: 462 462 case OT_DTOR: 463 if ( untypedExpr-> get_args().size() == 1 ) {463 if ( untypedExpr->args.size() == 1 ) { 464 464 // the expression fed into a single parameter constructor or destructor may contain side 465 465 // effects, so must still output this expression … … 480 480 (*arg++)->accept( *visitor ); 481 481 output << opInfo.symbol << "{ "; 482 genCommaList( arg, untypedExpr-> get_args().end() );482 genCommaList( arg, untypedExpr->args.end() ); 483 483 output << "}) /* " << opInfo.inputName << " */"; 484 484 } // if … … 488 488 case OT_PREFIXASSIGN: 489 489 case OT_LABELADDRESS: 490 assert( untypedExpr-> get_args().size() == 1 );490 assert( untypedExpr->args.size() == 1 ); 491 491 output << "("; 492 492 output << opInfo.symbol; … … 497 497 case OT_POSTFIX: 498 498 case OT_POSTFIXASSIGN: 499 assert( untypedExpr-> get_args().size() == 1 );499 assert( untypedExpr->args.size() == 1 ); 500 500 (*arg)->accept( *visitor ); 501 501 output << opInfo.symbol; … … 504 504 case OT_INFIX: 505 505 case OT_INFIXASSIGN: 506 assert( untypedExpr-> get_args().size() == 2 );506 assert( untypedExpr->args.size() == 2 ); 507 507 output << "("; 508 508 (*arg++)->accept( *visitor ); … … 517 517 } // switch 518 518 } else { 519 if ( nameExpr->get_name() == "..." ) { // case V1 ... V2 or case V1~V2 520 assert( untypedExpr->get_args().size() == 2 ); 521 (*untypedExpr->get_args().begin())->accept( *visitor ); 522 output << " ... "; 523 (*--untypedExpr->get_args().end())->accept( *visitor ); 524 } else { // builtin routines 525 nameExpr->accept( *visitor ); 526 output << "("; 527 genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() ); 528 output << ")"; 529 } // if 519 // builtin routines 520 nameExpr->accept( *visitor ); 521 output << "("; 522 genCommaList( untypedExpr->args.begin(), untypedExpr->args.end() ); 523 output << ")"; 530 524 } // if 531 525 } else { 532 untypedExpr-> get_function()->accept( *visitor );526 untypedExpr->function->accept( *visitor ); 533 527 output << "("; 534 genCommaList( untypedExpr-> get_args().begin(), untypedExpr->get_args().end() );528 genCommaList( untypedExpr->args.begin(), untypedExpr->args.end() ); 535 529 output << ")"; 536 530 } // if … … 538 532 539 533 void CodeGenerator::postvisit( RangeExpr * rangeExpr ) { 540 rangeExpr-> get_low()->accept( *visitor );534 rangeExpr->low->accept( *visitor ); 541 535 output << " ... "; 542 rangeExpr-> get_high()->accept( *visitor );536 rangeExpr->high->accept( *visitor ); 543 537 } 544 538 … … 885 879 886 880 void CodeGenerator::postvisit( CaseStmt * caseStmt ) { 881 updateLocation( caseStmt ); 882 output << indent; 887 883 if ( caseStmt->isDefault()) { 888 884 output << "default"; … … 1026 1022 } // namespace CodeGen 1027 1023 1024 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) { 1025 if ( node ) { 1026 node->print( out ); 1027 } else { 1028 out << "nullptr"; 1029 } 1030 return out; 1031 } 1032 1028 1033 // Local Variables: // 1029 1034 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.