Changeset 490ff5c3
- Timestamp:
- Feb 14, 2018, 1:54:14 PM (7 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, resolv-new, with_gc
- Children:
- 44b4114
- Parents:
- 54c9000
- git-author:
- Rob Schluntz <rschlunt@…> (02/14/18 12:00:25)
- git-committer:
- Rob Schluntz <rschlunt@…> (02/14/18 13:54:14)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r54c9000 r490ff5c3 1380 1380 void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) { 1381 1381 std::list< SymTab::Indexer::IdData > declList; 1382 indexer.lookupId( nameExpr-> get_name(), declList );1383 PRINT( std::cerr << "nameExpr is " << nameExpr-> get_name()<< std::endl; )1382 indexer.lookupId( nameExpr->name, declList ); 1383 PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; ) 1384 1384 for ( auto & data : declList ) { 1385 1385 Expression * newExpr = data.combine(); … … 1402 1402 // not sufficient to clone here, because variable's type may have changed 1403 1403 // since the VariableExpr was originally created. 1404 alternatives.push_back( Alternative( new VariableExpr( variableExpr-> get_var()), env, Cost::zero ) );1404 alternatives.push_back( Alternative( new VariableExpr( variableExpr->var ), env, Cost::zero ) ); 1405 1405 } 1406 1406 … … 1469 1469 // xxx - resolveTypeof? 1470 1470 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) { 1471 addOffsetof( structInst, offsetofExpr-> get_member());1471 addOffsetof( structInst, offsetofExpr->member ); 1472 1472 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) { 1473 addOffsetof( unionInst, offsetofExpr-> get_member());1473 addOffsetof( unionInst, offsetofExpr->member ); 1474 1474 } 1475 1475 } … … 1548 1548 secondFinder.findWithAdjustment( logicalExpr->get_arg2() ); 1549 1549 if ( secondFinder.alternatives.empty() ) return; 1550 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first) {1551 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second) {1550 for ( const Alternative & first : firstFinder.alternatives ) { 1551 for ( const Alternative & second : secondFinder.alternatives ) { 1552 1552 TypeEnvironment compositeEnv; 1553 compositeEnv.simpleCombine( first ->env );1554 compositeEnv.simpleCombine( second ->env );1555 1556 LogicalExpr *newExpr = new LogicalExpr( first ->expr->clone(), second->expr->clone(), logicalExpr->get_isAnd() );1557 alternatives.push_back( Alternative( newExpr, compositeEnv, first ->cost + second->cost ) );1553 compositeEnv.simpleCombine( first.env ); 1554 compositeEnv.simpleCombine( second.env ); 1555 1556 LogicalExpr *newExpr = new LogicalExpr( first.expr->clone(), second.expr->clone(), logicalExpr->get_isAnd() ); 1557 alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) ); 1558 1558 } 1559 1559 } … … 1605 1605 AlternativeFinder secondFinder( indexer, newEnv ); 1606 1606 secondFinder.findWithAdjustment( commaExpr->get_arg2() ); 1607 for ( AltList::const_iterator alt = secondFinder.alternatives.begin(); alt != secondFinder.alternatives.end(); ++alt) {1608 alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt ->expr->clone() ), alt->env, alt->cost ) );1607 for ( const Alternative & alt : secondFinder.alternatives ) { 1608 alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) ); 1609 1609 } // for 1610 1610 delete newFirstArg; … … 1614 1614 // resolve low and high, accept alternatives whose low and high types unify 1615 1615 AlternativeFinder firstFinder( indexer, env ); 1616 firstFinder.findWithAdjustment( rangeExpr-> get_low());1616 firstFinder.findWithAdjustment( rangeExpr->low ); 1617 1617 if ( firstFinder.alternatives.empty() ) return; 1618 1618 AlternativeFinder secondFinder( indexer, env ); 1619 secondFinder.findWithAdjustment( rangeExpr-> get_high());1619 secondFinder.findWithAdjustment( rangeExpr->high ); 1620 1620 if ( secondFinder.alternatives.empty() ) return; 1621 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first) {1622 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second) {1621 for ( const Alternative & first : firstFinder.alternatives ) { 1622 for ( const Alternative & second : secondFinder.alternatives ) { 1623 1623 TypeEnvironment compositeEnv; 1624 compositeEnv.simpleCombine( first ->env );1625 compositeEnv.simpleCombine( second ->env );1624 compositeEnv.simpleCombine( first.env ); 1625 compositeEnv.simpleCombine( second.env ); 1626 1626 OpenVarSet openVars; 1627 1627 AssertionSet needAssertions, haveAssertions; 1628 Alternative newAlt( 0, compositeEnv, first ->cost + second->cost );1628 Alternative newAlt( 0, compositeEnv, first.cost + second.cost ); 1629 1629 Type* commonType = nullptr; 1630 if ( unify( first ->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {1631 RangeExpr * newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() );1632 newExpr-> set_result( commonType ? commonType : first->expr->get_result()->clone());1630 if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 1631 RangeExpr * newExpr = new RangeExpr( first.expr->clone(), second.expr->clone() ); 1632 newExpr->result = commonType ? commonType : first.expr->result->clone(); 1633 1633 newAlt.expr = newExpr; 1634 1634 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); -
src/SymTab/Indexer.cc
r54c9000 r490ff5c3 434 434 } 435 435 } else { 436 // Check that a Cforall declaration doesn't over loadany C declaration436 // Check that a Cforall declaration doesn't override any C declaration 437 437 if ( hasCompatibleCDecl( name, mangleName, scope ) ) { 438 438 throw SemanticError( "Cforall declaration hides C function ", decl ); … … 654 654 655 655 void Indexer::print( std::ostream &os, int indent ) const { 656 656 using std::cerr; 657 657 658 658 if ( tables ) { -
src/SymTab/Indexer.h
r54c9000 r490ff5c3 40 40 41 41 struct IdData { 42 DeclarationWithType * id; 43 Expression * baseExpr; // WithExpr 42 DeclarationWithType * id = nullptr; 43 Expression * baseExpr = nullptr; // WithExpr 44 45 /// non-null if this declaration is deleted 46 BaseSyntaxNode * deleteStmt = nullptr; 44 47 45 48 Expression * combine() const; -
src/Tuples/Explode.h
r54c9000 r490ff5c3 43 43 /// Append alternative to an OutputIterator of Alternatives 44 44 template<typename OutputIterator> 45 void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env, 45 void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env, 46 46 const ResolvExpr::Cost& cost, const ResolvExpr::Cost& cvtCost ) { 47 47 *out++ = ResolvExpr::Alternative{ expr, env, cost, cvtCost }; … … 49 49 50 50 /// Append alternative to an ExplodedActual 51 static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr, 51 static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr, 52 52 const ResolvExpr::TypeEnvironment&, const ResolvExpr::Cost&, const ResolvExpr::Cost& ) { 53 53 ea.exprs.emplace_back( expr ); … … 57 57 /// helper function used by explode 58 58 template< typename Output > 59 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 59 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 60 60 const SymTab::Indexer & indexer, Output&& out, bool isTupleAssign ) { 61 61 if ( isTupleAssign ) { … … 63 63 if ( CastExpr * castExpr = isReferenceCast( expr ) ) { 64 64 ResolvExpr::AltList alts; 65 explodeUnique( 65 explodeUnique( 66 66 castExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign ); 67 67 for ( ResolvExpr::Alternative & alt : alts ) { 68 68 // distribute reference cast over all components 69 append( std::forward<Output>(out), distributeReference( alt.release_expr() ), 69 append( std::forward<Output>(out), distributeReference( alt.release_expr() ), 70 70 alt.env, alt.cost, alt.cvtCost ); 71 71 } … … 108 108 /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type 109 109 template< typename Output > 110 void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer, 110 void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer, 111 111 Output&& out, bool isTupleAssign = false ) { 112 112 explodeUnique( alt.expr, alt, indexer, std::forward<Output>(out), isTupleAssign ); … … 115 115 // explode list of alternatives 116 116 template< typename AltIterator, typename Output > 117 void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer, 117 void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer, 118 118 Output&& out, bool isTupleAssign = false ) { 119 119 for ( ; altBegin != altEnd; ++altBegin ) { … … 123 123 124 124 template< typename Output > 125 void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out, 125 void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out, 126 126 bool isTupleAssign = false ) { 127 127 explode( alts.begin(), alts.end(), indexer, std::forward<Output>(out), isTupleAssign );
Note: See TracChangeset
for help on using the changeset viewer.