Changeset 8a443f4 for src/CodeGen
- Timestamp:
- Aug 2, 2016, 6:40:27 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 73bf8cf2
- Parents:
- 4d2434a (diff), becba789 (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. - Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4d2434a r8a443f4 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 15 15:53:15201613 // Update Count : 3 0611 // Last Modified By : 12 // Last Modified On : Sun Jul 31 08:42:18 2016 13 // Update Count : 345 14 14 // 15 15 … … 45 45 bool wantSpacing( Statement * stmt) { 46 46 return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) || 47 dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * > 47 dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * >( stmt ) || dynamic_cast< SwitchStmt *>( stmt ); 48 48 } 49 49 … … 83 83 } 84 84 85 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) { 85 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {} 86 86 87 87 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) … … 155 155 objectDecl->get_init()->accept( *this ); 156 156 } // if 157 157 158 if ( objectDecl->get_bitfieldWidth() ) { 158 159 output << ":"; … … 172 173 173 174 cur_indent += CodeGenerator::tabsize; 174 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) {175 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) { 175 176 output << indent; 176 177 (*i)->accept( *this ); 177 178 output << ";" << endl; 178 } 179 } // for 179 180 180 181 cur_indent -= CodeGenerator::tabsize; … … 257 258 (*iter)->accept( *this ); 258 259 output << "]"; 259 } 260 } 260 } // if 261 } // for 261 262 output << " = "; 262 263 } … … 317 318 // do nothing 318 319 ; 319 } 320 } // switch 320 321 321 322 switch ( opInfo.type ) { … … 385 386 // there are no intrinsic definitions of 0/1 or label addresses as functions 386 387 assert( false ); 387 } 388 } // switch 388 389 } else { 389 390 varExpr->accept( *this ); … … 417 418 case OT_CALL: 418 419 assert( false ); 419 420 420 421 421 case OT_CTOR: … … 437 437 // no constructors with 0 or more than 2 parameters 438 438 assert( false ); 439 } 439 } // if 440 440 break; 441 441 … … 470 470 // there are no intrinsic definitions of 0 or 1 as functions 471 471 assert( false ); 472 } 472 } // switch 473 473 } else { 474 nameExpr->accept( *this ); 475 output << "("; 476 genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() ); 477 output << ")"; 474 if ( nameExpr->get_name() == "Range" ) { // case V1 ... V2 or case V1~V2 475 assert( untypedExpr->get_args().size() == 2 ); 476 (*untypedExpr->get_args().begin())->accept( *this ); 477 output << " ... "; 478 (*--untypedExpr->get_args().end())->accept( *this ); 479 } else { // builtin routines 480 nameExpr->accept( *this ); 481 output << "("; 482 genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() ); 483 output << ")"; 484 } // if 478 485 } // if 479 486 } else { … … 521 528 // otherwise, the cast is to an lvalue type, so the cast should be dropped, since the result of a cast is 522 529 // never an lvalue in C 523 } 530 } // if 524 531 castExpr->get_arg()->accept( *this ); 525 532 output << ")"; … … 654 661 if ( wantSpacing( *i ) ) { 655 662 output << endl; 656 } 663 } // if 657 664 } 658 665 cur_indent -= CodeGenerator::tabsize; … … 737 744 (*i)->accept( *this ); 738 745 output << endl; 739 } 746 } // for 740 747 cur_indent -= CodeGenerator::tabsize; 741 748 } … … 759 766 output << "continue"; 760 767 break; 761 } 768 } // switch 762 769 output << ";"; 763 770 } … … 798 805 if ( forStmt->get_condition() != 0 ) { 799 806 forStmt->get_condition()->accept( *this ); 800 } 807 } // if 801 808 output << ";"; 802 809 … … 805 812 Expression * expr = new CastExpr( forStmt->get_increment() ); 806 813 expr->accept( *this ); 807 } 814 } // if 808 815 output << ") "; 809 816 -
src/CodeGen/CodeGenerator.h
r4d2434a r8a443f4 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 4 17:12:40201613 // Update Count : 3 412 // Last Modified On : Sat Jul 30 11:10:42 2016 13 // Update Count : 37 14 14 // 15 15 … … 118 118 void handleAggregate( AggregateDecl *aggDecl ); 119 119 void handleTypedef( NamedTypeDecl *namedType ); 120 }; 120 }; // CodeGenerator 121 121 122 122 template< class Iterator >
Note: See TracChangeset
for help on using the changeset viewer.