Changeset e67a82d for src/Tuples
- Timestamp:
- Aug 20, 2020, 11:48:15 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d685cb0
- Parents:
- 67ca73e (diff), 013b028 (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/Tuples
- Files:
-
- 5 edited
-
Explode.cc (modified) (4 diffs)
-
Explode.h (modified) (2 diffs)
-
TupleAssignment.cc (modified) (8 diffs)
-
TupleExpansion.cc (modified) (1 diff)
-
Tuples.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/Explode.cc
r67ca73e re67a82d 129 129 for ( const ast::Expr * expr : tupleExpr->exprs ) { 130 130 exprs.emplace_back( applyCast( expr, false ) ); 131 //exprs.emplace_back( ast::ptr< ast::Expr >( applyCast( expr, false ) ) );132 131 } 133 132 if ( first ) { … … 148 147 } 149 148 150 const ast::Expr * post mutate( const ast::UniqueExpr * node ) {149 const ast::Expr * postvisit( const ast::UniqueExpr * node ) { 151 150 // move cast into unique expr so that the unique expr has type T& rather than 152 151 // type T. In particular, this transformation helps with generating the … … 162 161 castAdded = false; 163 162 const ast::Type * newType = getReferenceBase( newNode->result ); 164 return new ast::CastExpr{ newNode->location, n ode, newType };163 return new ast::CastExpr{ newNode->location, newNode, newType }; 165 164 } 166 165 return newNode; 167 166 } 168 167 169 const ast::Expr * post mutate( const ast::TupleIndexExpr * tupleExpr ) {168 const ast::Expr * postvisit( const ast::TupleIndexExpr * tupleExpr ) { 170 169 // tuple index expr needs to be rebuilt to ensure that the type of the 171 170 // field is consistent with the type of the tuple expr, since the field … … 180 179 ast::Pass<CastExploderCore> exploder; 181 180 expr = expr->accept( exploder ); 182 if ( ! exploder. pass.foundUniqueExpr ) {181 if ( ! exploder.core.foundUniqueExpr ) { 183 182 expr = new ast::CastExpr{ expr, new ast::ReferenceType{ expr->result } }; 184 183 } -
src/Tuples/Explode.h
r67ca73e re67a82d 210 210 } 211 211 // Cast a reference away to a value-type to allow further explosion. 212 if ( dynamic_cast< const ast::ReferenceType *>( local->result.get()) ) {212 if ( local->result.as< ast::ReferenceType >() ) { 213 213 local = new ast::CastExpr{ local, tupleType }; 214 214 } … … 220 220 // delete idx; 221 221 } 222 // delete local;223 222 } 224 223 } else { -
src/Tuples/TupleAssignment.cc
r67ca73e re67a82d 465 465 // resolve ctor/dtor for the new object 466 466 ast::ptr< ast::Init > ctorInit = ResolvExpr::resolveCtorInit( 467 InitTweak::genCtorInit( location, ret ), spotter.crntFinder. symtab);467 InitTweak::genCtorInit( location, ret ), spotter.crntFinder.localSyms ); 468 468 // remove environments from subexpressions of stmtExpr 469 469 ast::Pass< EnvRemover > rm{ env }; … … 504 504 505 505 std::vector< ast::ptr< ast::Expr > > match() override { 506 static UniqueName lhsNamer( "__massassign_L" ); 507 static UniqueName rhsNamer( "__massassign_R" ); 506 // temporary workaround for new and old ast to coexist and avoid name collision 507 static UniqueName lhsNamer( "__massassign_Ln" ); 508 static UniqueName rhsNamer( "__massassign_Rn" ); 508 509 // empty tuple case falls into this matcher 509 510 assert( lhs.empty() ? rhs.empty() : rhs.size() <= 1 ); … … 534 535 535 536 std::vector< ast::ptr< ast::Expr > > match() override { 536 static UniqueName lhsNamer( "__multassign_L" ); 537 static UniqueName rhsNamer( "__multassign_R" ); 537 // temporary workaround for new and old ast to coexist and avoid name collision 538 static UniqueName lhsNamer( "__multassign_Ln" ); 539 static UniqueName rhsNamer( "__multassign_Rn" ); 538 540 539 541 if ( lhs.size() != rhs.size() ) return {}; … … 560 562 // resolve the cast expression so that rhsCand return type is bound by the cast 561 563 // type as needed, and transfer the resulting environment 562 ResolvExpr::CandidateFinder finder{ spotter.crntFinder. symtab, env };564 ResolvExpr::CandidateFinder finder{ spotter.crntFinder.localSyms, env }; 563 565 finder.find( rhsCand->expr, ResolvExpr::ResolvMode::withAdjustment() ); 564 566 assert( finder.candidates.size() == 1 ); … … 609 611 // explode the LHS so that each field of a tuple-valued expr is assigned 610 612 ResolvExpr::CandidateList lhs; 611 explode( *lhsCand, crntFinder. symtab, back_inserter(lhs), true );613 explode( *lhsCand, crntFinder.localSyms, back_inserter(lhs), true ); 612 614 for ( ResolvExpr::CandidateRef & cand : lhs ) { 613 615 // each LHS value must be a reference - some come in with a cast, if not … … 629 631 if ( isTuple( rhsCand->expr ) ) { 630 632 // multiple assignment 631 explode( *rhsCand, crntFinder. symtab, back_inserter(rhs), true );633 explode( *rhsCand, crntFinder.localSyms, back_inserter(rhs), true ); 632 634 matcher.reset( 633 635 new MultipleAssignMatcher{ *this, expr->location, lhs, rhs } ); … … 648 650 // multiple assignment 649 651 ResolvExpr::CandidateList rhs; 650 explode( rhsCand, crntFinder. symtab, back_inserter(rhs), true );652 explode( rhsCand, crntFinder.localSyms, back_inserter(rhs), true ); 651 653 matcher.reset( 652 654 new MultipleAssignMatcher{ *this, expr->location, lhs, rhs } ); … … 678 680 ) 679 681 680 ResolvExpr::CandidateFinder finder{ crntFinder. symtab, matcher->env };682 ResolvExpr::CandidateFinder finder{ crntFinder.localSyms, matcher->env }; 681 683 682 684 try { -
src/Tuples/TupleExpansion.cc
r67ca73e re67a82d 323 323 std::vector<ast::ptr<ast::Type>> types; 324 324 ast::CV::Qualifiers quals{ 325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | 326 326 ast::CV::Atomic | ast::CV::Mutex }; 327 327 -
src/Tuples/Tuples.cc
r67ca73e re67a82d 43 43 }; 44 44 struct ImpurityDetectorIgnoreUnique : public ImpurityDetector { 45 using ImpurityDetector::previsit; 45 46 void previsit( ast::UniqueExpr const * ) { 46 47 visit_children = false; … … 52 53 ast::Pass<Detector> detector; 53 54 expr->accept( detector ); 54 return detector. pass.maybeImpure;55 return detector.core.maybeImpure; 55 56 } 56 57 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.