- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/TranslateEnumRange.cpp
ra9ae5ca r0c327ce 5 5 6 6 namespace ControlStruct { 7 8 struct addInitType { 9 const ast::Stmt * postvisit( const ast::ForStmt * stmt ); 10 }; 7 11 8 12 struct addInit { … … 13 17 const ast::Stmt * postvisit( const ast::ForStmt * stmt ); 14 18 }; 19 20 const ast::Stmt* addInitType::postvisit( const ast::ForStmt * stmt ) { 21 if ( stmt->range_over ) { 22 auto typeExpr = stmt->range_over.strict_as<ast::TypeExpr>(); 23 auto type = typeExpr->type; 24 25 auto objInit = stmt->inits.front(); 26 assert( stmt->inits.size() == 1 ); 27 28 if (auto declStmt = objInit.as<ast::DeclStmt>()) { 29 auto decl = declStmt->decl; 30 if ( auto objDecl = decl.as<ast::ObjectDecl>()) { 31 if ( !objDecl->type && type ) { 32 auto objDeclWithType = ast::mutate_field( objDecl, &ast::ObjectDecl::type, type ); 33 auto declWithType = ast::mutate_field( declStmt, &ast::DeclStmt::decl, objDeclWithType ); 34 stmt = ast::mutate_field_index( stmt, &ast::ForStmt::inits, 0, declWithType ); 35 } 36 } 37 } 38 } 39 return stmt; 40 } 15 41 16 42 const ast::Stmt* addInit::postvisit( const ast::ForStmt * stmt ) { … … 61 87 mut = ast::mutate_field(stmt, &ast::ForStmt::inc, assig ); 62 88 return mut; 63 } 89 } 64 90 65 91 void translateEnumRange( ast::TranslationUnit & translationUnit ) {
Note: See TracChangeset
for help on using the changeset viewer.