Changeset 41e16b1 for src/ResolvExpr
- Timestamp:
- May 31, 2018, 10:22:19 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 00ac42e, 2a08c25, 7de7b52
- Parents:
- 597c34a3 (diff), 518e97d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/ResolvExpr
- Files:
-
- 3 edited
-
Alternative.cc (modified) (3 diffs)
-
AlternativeFinder.cc (modified) (5 diffs)
-
TypeEnvironment.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Alternative.cc
r597c34a3 r41e16b1 27 27 28 28 namespace ResolvExpr { 29 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0) {}29 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( nullptr ) {} 30 30 31 31 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost ) … … 48 48 } 49 49 50 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env) {50 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( std::move( other.env ) ) { 51 51 other.expr = nullptr; 52 52 } … … 58 58 cvtCost = other.cvtCost; 59 59 expr = other.expr; 60 env = other.env;60 env = std::move( other.env ); 61 61 other.expr = nullptr; 62 62 return *this; -
src/ResolvExpr/AlternativeFinder.cc
r597c34a3 r41e16b1 299 299 // it's okay for the aggregate expression to have reference type -- cast it to the base type to treat the aggregate as the referenced value 300 300 std::unique_ptr<Expression> aggrExpr( alt.expr->clone() ); 301 alt.env.apply( aggrExpr-> get_result());302 Type * aggrType = aggrExpr-> get_result();301 alt.env.apply( aggrExpr->result ); 302 Type * aggrType = aggrExpr->result; 303 303 if ( dynamic_cast< ReferenceType * >( aggrType ) ) { 304 304 aggrType = aggrType->stripReferences(); … … 306 306 } 307 307 308 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr-> get_result()) ) {308 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->result ) ) { 309 309 NameExpr nameExpr( "" ); 310 310 addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr ); 311 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr-> get_result()) ) {311 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->result ) ) { 312 312 NameExpr nameExpr( "" ); 313 313 addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr ); … … 320 320 NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ); 321 321 if ( ! nameExpr ) return; 322 const std::string & name = nameExpr-> get_name();322 const std::string & name = nameExpr->name; 323 323 std::list< Declaration* > members; 324 324 aggInst->lookup( name, members ); 325 325 326 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) { 327 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) { 328 alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) ); 329 renameTypes( alternatives.back().expr ); 330 addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression. 326 for ( Declaration * decl : members ) { 327 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( decl ) ) { 328 // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so 329 // can't construct in place and use vector::back 330 Alternative newAlt( new MemberExpr( dwt, expr->clone() ), env, newCost ); 331 renameTypes( newAlt.expr ); 332 addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression. 333 alternatives.push_back( std::move(newAlt) ); 331 334 } else { 332 335 assert( false ); … … 1379 1382 Cost cost = Cost::zero; 1380 1383 Expression * newExpr = data.combine( cost ); 1381 alternatives.push_back( Alternative( newExpr, env, Cost::zero, cost ) ); 1384 1385 // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so 1386 // can't construct in place and use vector::back 1387 Alternative newAlt( newExpr, env, Cost::zero, cost ); 1382 1388 PRINT( 1383 1389 std::cerr << "decl is "; … … 1388 1394 std::cerr << std::endl; 1389 1395 ) 1390 renameTypes( alternatives.back().expr ); 1391 addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression. 1396 renameTypes( newAlt.expr ); 1397 addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression. 1398 alternatives.push_back( std::move(newAlt) ); 1392 1399 } // for 1393 1400 } -
src/ResolvExpr/TypeEnvironment.cc
r597c34a3 r41e16b1 50 50 } 51 51 52 EqvClass::EqvClass() : type( 0), allowWidening( true ) {52 EqvClass::EqvClass() : type( nullptr ), allowWidening( true ) { 53 53 } 54 54 … … 159 159 160 160 void TypeEnvironment::print( std::ostream &os, Indenter indent ) const { 161 for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i) {162 i->print( os, indent );161 for ( const EqvClass & theClass : env ) { 162 theClass.print( os, indent ); 163 163 } // for 164 164 }
Note:
See TracChangeset
for help on using the changeset viewer.