Changes in src/ResolvExpr/Resolver.cc [954c954:7ff3e522]
- File:
-
- 1 edited
-
src/ResolvExpr/Resolver.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r954c954 r7ff3e522 38 38 #include "Common/PassVisitor.h" // for PassVisitor 39 39 #include "Common/SemanticError.h" // for SemanticError 40 #include "Common/Stats/ResolveTime.h" // for ResolveTime::start(), ResolveTime::stop()41 40 #include "Common/utility.h" // for ValueGuard, group_iterate 42 41 #include "InitTweak/GenInit.h" … … 966 965 /// Finds deleted expressions in an expression tree 967 966 struct DeleteFinder_new final : public ast::WithShortCircuiting { 968 const ast::DeletedExpr * result= nullptr;967 const ast::DeletedExpr * delExpr = nullptr; 969 968 970 969 void previsit( const ast::DeletedExpr * expr ) { 971 if ( result) { visit_children = false; }972 else { result= expr; }970 if ( delExpr ) { visit_children = false; } 971 else { delExpr = expr; } 973 972 } 974 973 975 974 void previsit( const ast::Expr * ) { 976 if ( result) { visit_children = false; }975 if ( delExpr ) { visit_children = false; } 977 976 } 978 977 }; … … 981 980 /// Check if this expression is or includes a deleted expression 982 981 const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) { 983 return ast::Pass<DeleteFinder_new>::read( expr ); 982 ast::Pass<DeleteFinder_new> finder; 983 expr->accept( finder ); 984 return finder.core.delExpr; 984 985 } 985 986 … … 1170 1171 const ast::Expr * untyped, const ast::SymbolTable & symtab 1171 1172 ) { 1172 Stats::ResolveTime::start( untyped ); 1173 auto res = findKindExpression( untyped, symtab ); 1174 Stats::ResolveTime::stop(); 1175 return res; 1173 return findKindExpression( untyped, symtab ); 1176 1174 } 1177 1175 } // anonymous namespace … … 1223 1221 template<typename Iter> 1224 1222 inline bool nextMutex( Iter & it, const Iter & end ) { 1225 while ( it != end && ! (*it)-> is_mutex() ) { ++it; }1223 while ( it != end && ! (*it)->get_type()->is_mutex() ) { ++it; } 1226 1224 return it != end; 1227 1225 } … … 1263 1261 const ast::ThrowStmt * previsit( const ast::ThrowStmt * ); 1264 1262 const ast::CatchStmt * previsit( const ast::CatchStmt * ); 1265 const ast::CatchStmt * postvisit( const ast::CatchStmt * );1266 1263 const ast::WaitForStmt * previsit( const ast::WaitForStmt * ); 1267 1264 … … 1496 1493 1497 1494 const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) { 1498 // Until we are very sure this invarent (ifs that move between passes have thenPart) 1499 // holds, check it. This allows a check for when to decode the mangling. 1500 if ( auto ifStmt = catchStmt->body.as<ast::IfStmt>() ) { 1501 assert( ifStmt->thenPart ); 1502 } 1503 // Encode the catchStmt so the condition can see the declaration. 1495 // TODO: This will need a fix for the decl/cond scoping problem. 1504 1496 if ( catchStmt->cond ) { 1505 ast::CatchStmt * stmt = mutate( catchStmt ); 1506 stmt->body = new ast::IfStmt( stmt->location, stmt->cond, nullptr, stmt->body ); 1507 stmt->cond = nullptr; 1508 return stmt; 1509 } 1510 return catchStmt; 1511 } 1512 1513 const ast::CatchStmt * Resolver_new::postvisit( const ast::CatchStmt * catchStmt ) { 1514 // Decode the catchStmt so everything is stored properly. 1515 const ast::IfStmt * ifStmt = catchStmt->body.as<ast::IfStmt>(); 1516 if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) { 1517 assert( ifStmt->cond ); 1518 assert( ifStmt->elsePart ); 1519 ast::CatchStmt * stmt = ast::mutate( catchStmt ); 1520 stmt->cond = ifStmt->cond; 1521 stmt->body = ifStmt->elsePart; 1522 // ifStmt should be implicately deleted here. 1523 return stmt; 1497 ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool }; 1498 catchStmt = ast::mutate_field( 1499 catchStmt, &ast::CatchStmt::cond, 1500 findSingleExpression( catchStmt->cond, boolType, symtab ) ); 1524 1501 } 1525 1502 return catchStmt; … … 1638 1615 // Check if the argument matches the parameter type in the current 1639 1616 // scope 1640 //ast::ptr< ast::Type > paramType = (*param)->get_type();1617 ast::ptr< ast::Type > paramType = (*param)->get_type(); 1641 1618 if ( 1642 1619 ! unify( 1643 arg->expr->result, *param, resultEnv, need, have, open,1620 arg->expr->result, paramType, resultEnv, need, have, open, 1644 1621 symtab ) 1645 1622 ) { … … 1648 1625 ss << "candidate function not viable: no known conversion " 1649 1626 "from '"; 1650 ast::print( ss, *param);1627 ast::print( ss, (*param)->get_type() ); 1651 1628 ss << "' to '"; 1652 1629 ast::print( ss, arg->expr->result );
Note:
See TracChangeset
for help on using the changeset viewer.