Changeset 67fa9f9 for src/CodeGen/CodeGenerator.cc
- Timestamp:
- Jul 5, 2017, 10:50:22 AM (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:
- 0614d14
- Parents:
- 11dbfe1 (diff), 307a732 (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
r11dbfe1 r67fa9f9 288 288 } 289 289 290 void CodeGenerator:: printDesignators( std::list< Expression * > & designators) {291 typedef std::list< Expression * > DesignatorList;290 void CodeGenerator::visit( Designation * designation ) { 291 std::list< Expression * > designators = designation->get_designators(); 292 292 if ( designators.size() == 0 ) return; 293 for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter) {294 if ( dynamic_cast< NameExpr * >( *iter) ) {295 // if expression is a name, then initializing aggregate member293 for ( Expression * des : designators ) { 294 if ( dynamic_cast< NameExpr * >( des ) || dynamic_cast< VariableExpr * >( des ) ) { 295 // if expression is a NameExpr or VariableExpr, then initializing aggregate member 296 296 output << "."; 297 (*iter)->accept( *this );297 des->accept( *this ); 298 298 } else { 299 // if not a simple name, it has to be a constant expression, i.e. an array designator299 // otherwise, it has to be a ConstantExpr or CastExpr, initializing array eleemnt 300 300 output << "["; 301 (*iter)->accept( *this );301 des->accept( *this ); 302 302 output << "]"; 303 303 } // if … … 307 307 308 308 void CodeGenerator::visit( SingleInit * init ) { 309 printDesignators( init->get_designators() );310 309 init->get_value()->accept( *this ); 311 310 } 312 311 313 312 void CodeGenerator::visit( ListInit * init ) { 314 printDesignators( init->get_designators() ); 313 auto initBegin = init->begin(); 314 auto initEnd = init->end(); 315 auto desigBegin = init->get_designations().begin(); 316 auto desigEnd = init->get_designations().end(); 317 315 318 output << "{ "; 316 genCommaList( init->begin(), init->end() ); 319 for ( ; initBegin != initEnd && desigBegin != desigEnd; ) { 320 (*desigBegin)->accept( *this ); 321 (*initBegin)->accept( *this ); 322 ++initBegin, ++desigBegin; 323 if ( initBegin != initEnd ) { 324 output << ", "; 325 } 326 } 317 327 output << " }"; 328 assertf( initBegin == initEnd && desigBegin == desigEnd, "Initializers and designators not the same length. %s", toString( init ).c_str() ); 318 329 } 319 330 … … 716 727 717 728 void CodeGenerator::visit( TypeExpr * typeExpr ) { 718 assertf( ! genC, "TypeExpr should not reach code generation." ); 719 output<< genType( typeExpr->get_type(), "", pretty, genC ); 729 // if ( genC ) std::cerr << "typeexpr still exists: " << typeExpr << std::endl; 730 // assertf( ! genC, "TypeExpr should not reach code generation." ); 731 if ( ! genC ) { 732 output<< genType( typeExpr->get_type(), "", pretty, genC ); 733 } 720 734 } 721 735
Note: See TracChangeset
for help on using the changeset viewer.