Changeset 30d91e4 for src/CodeGen
- Timestamp:
- Apr 14, 2022, 2:59:16 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 365c8dcb
- Parents:
- d8c4fab
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rd8c4fab r30d91e4 276 276 std::list< Declaration* > &memb = enumDecl->get_members(); 277 277 if (enumDecl->base && ! memb.empty()) { 278 ObjectDecl * last = nullptr;278 unsigned long long last_val = -1; 279 279 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 280 280 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); … … 284 284 output << mangleName( obj ) << " "; 285 285 output << " = "; 286 output << "(" << genType(enumDecl->base, "", options) << ")";; 287 if ( obj->get_init() ) { 288 obj->get_init()->accept( *visitor ); 286 output << "(" << genType(enumDecl->base, "", options) << ")"; 287 if ( (BasicType *)(enumDecl->base) && ((BasicType *)(enumDecl->base))->isWholeNumber() ) { 288 if ( obj->get_init() ) { 289 obj->get_init()->accept( *visitor ); 290 last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival(); 291 } else { 292 output << ++last_val; 293 } // if 289 294 } else { 290 if ( last == nullptr) {291 o utput << 0;295 if ( obj->get_init() ) { 296 obj->get_init()->accept( *visitor ); 292 297 } else { 293 output << mangleName(last) << " + 1";298 // Should not reach here! 294 299 } 295 } // if—300 } 296 301 output << ";" << endl; 297 last = obj;298 302 } // for 299 303 } else {
Note: See TracChangeset
for help on using the changeset viewer.