Changeset 73d0e3f4 for src/ControlStruct
- Timestamp:
- Jun 29, 2024, 5:22:36 PM (6 months ago)
- Branches:
- master
- Children:
- 011c29e
- Parents:
- 115ac1ce
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/TranslateEnumRange.cpp
r115ac1ce r73d0e3f4 27 27 28 28 auto objInit = stmt->inits.front(); 29 30 29 auto initLocation = objInit->location; 31 30 auto rangeLocation = stmt->range_over->location; … … 61 60 if ( !objDecl->init ) { 62 61 auto location = stmt->location; 63 ast::SingleInit * newInit;64 newInit = new ast::SingleInit( location,62 // auto newInit = new ast::SingleInit( location, new ast::NameExpr( location, enumDecl->members.front()->name ) ); 63 ast::SingleInit * newInit = new ast::SingleInit( location, 65 64 new ast::NameExpr( location, 66 stmt->is_inc? enumDecl->members.front()->name: enumDecl->members.back()->name ) );65 stmt->is_inc? enumDecl->members.front()->name: enumDecl->members.back()->name ) ); 67 66 auto objDeclWithInit = ast::mutate_field( objDecl, &ast::ObjectDecl::init, newInit ); 68 67 auto declWithInit = ast::mutate_field( declStmt, &ast::DeclStmt::decl, objDeclWithInit ); … … 85 84 auto enumInst = typeExpr->type.strict_as<ast::EnumInstType>(); 86 85 auto enumDecl = enumInst->base; 87 86 88 87 // Both inc and dec check if the current posn less than the number of enumerator 89 88 // for dec, it keeps call pred until it passes 0 (the first enumerator) and underflow, … … 93 92 {new ast::CastExpr(location, 94 93 new ast::NameExpr( location, indexName ), 95 new ast::BasicType( ast::BasicKind::UnsignedInt ),96 94 new ast::BasicType( ast::BasicKind::UnsignedInt 95 ),ast::GeneratedFlag::ExplicitCast), 97 96 ast::ConstantExpr::from_ulong( location, enumDecl->members.size()-1 ) }); 98 99 97 auto increment = ast::UntypedExpr::createCall( location, 100 stmt->is_inc? " ?++": "?--",101 { new ast::NameExpr( location, indexName ) });102 98 stmt->is_inc? "succ": "pred",{ 99 new ast::NameExpr( location, indexName ) 100 }); 103 101 auto assig = ast::UntypedExpr::createAssign( location, new ast::NameExpr( location, indexName ), increment ); 104 102 auto mut = ast::mutate_field( stmt, &ast::ForStmt::cond, condition );
Note: See TracChangeset
for help on using the changeset viewer.