Changes in src/Tuples/TupleAssignment.cc [d20a343:938dd75]
- File:
-
- 1 edited
-
src/Tuples/TupleAssignment.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleAssignment.cc
rd20a343 r938dd75 154 154 lhsAlt.expr = new CastExpr( lhsAlt.expr, 155 155 new ReferenceType( Type::Qualifiers(), 156 lhsAlt.expr-> result->clone() ) );156 lhsAlt.expr->get_result()->clone() ) ); 157 157 } 158 158 … … 298 298 ObjectDecl * TupleAssignSpotter::Matcher::newObject( UniqueName & namer, Expression * expr ) { 299 299 assert( expr->result && ! expr->get_result()->isVoid() ); 300 ObjectDecl * ret = new ObjectDecl( namer.newName(), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, expr-> result->clone(), new SingleInit( expr->clone() ) );300 ObjectDecl * ret = new ObjectDecl( namer.newName(), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 301 301 // if expression type is a reference, don't need to construct anything, a simple initializer is sufficient. 302 if ( ! dynamic_cast< ReferenceType * >( expr-> result) ) {302 if ( ! dynamic_cast< ReferenceType * >( expr->get_result() ) ) { 303 303 ConstructorInit * ctorInit = InitTweak::genCtorInit( ret ); 304 304 ret->init = ctorInit; … … 318 318 assert( (! lhs.empty() && rhs.size() <= 1) || (lhs.empty() && rhs.empty()) ); 319 319 320 // xxx - may need to split this up into multiple declarations, because potential conversion to references321 // probably should not reference local variable - see MultipleAssignMatcher::match322 320 ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr; 323 321 for ( ResolvExpr::Alternative & lhsAlt : lhs ) { … … 338 336 std::list< ObjectDecl * > ltmp; 339 337 std::list< ObjectDecl * > rtmp; 340 for ( auto p : group_iterate( lhs, rhs ) ) { 341 ResolvExpr::Alternative & lhsAlt = std::get<0>(p); 342 ResolvExpr::Alternative & rhsAlt = std::get<1>(p); 343 // convert RHS to LHS type minus one reference -- important for the case where LHS is && and RHS is lvalue, etc. 344 ReferenceType * lhsType = strict_dynamic_cast<ReferenceType *>( lhsAlt.expr->result ); 345 rhsAlt.expr = new CastExpr( rhsAlt.expr, lhsType->base->clone() ); 346 ObjectDecl * lobj = newObject( lhsNamer, lhsAlt.expr ); 347 ObjectDecl * robj = newObject( rhsNamer, rhsAlt.expr ); 348 out.push_back( createFunc(spotter.fname, lobj, robj) ); 349 ltmp.push_back( lobj ); 350 rtmp.push_back( robj ); 351 } 338 std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), [&]( ResolvExpr::Alternative & alt ){ 339 return newObject( lhsNamer, alt.expr ); 340 }); 341 std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), [&]( ResolvExpr::Alternative & alt ){ 342 return newObject( rhsNamer, alt.expr ); 343 }); 344 zipWith( ltmp.begin(), ltmp.end(), rtmp.begin(), rtmp.end(), back_inserter(out), [&](ObjectDecl * obj1, ObjectDecl * obj2 ) { return createFunc(spotter.fname, obj1, obj2); } ); 352 345 tmpDecls.splice( tmpDecls.end(), ltmp ); 353 346 tmpDecls.splice( tmpDecls.end(), rtmp );
Note:
See TracChangeset
for help on using the changeset viewer.