Changeset a9ae5ca
- Timestamp:
- Aug 3, 2024, 1:10:11 AM (3 months ago)
- Branches:
- master
- Children:
- 4e107bf
- Parents:
- c141c09
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/TranslateEnumRange.cpp
rc141c09 ra9ae5ca 5 5 6 6 namespace ControlStruct { 7 8 struct addInitType {9 const ast::Stmt * postvisit( const ast::ForStmt * stmt );10 };11 7 12 8 struct addInit { … … 17 13 const ast::Stmt * postvisit( const ast::ForStmt * stmt ); 18 14 }; 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 }41 15 42 16 const ast::Stmt* addInit::postvisit( const ast::ForStmt * stmt ) { … … 87 61 mut = ast::mutate_field(stmt, &ast::ForStmt::inc, assig ); 88 62 return mut; 89 } 63 } 90 64 91 65 void translateEnumRange( ast::TranslationUnit & translationUnit ) {
Note: See TracChangeset
for help on using the changeset viewer.