Changeset f6e6a55 for src/ResolvExpr/Resolver.cc
- Timestamp:
- Apr 20, 2022, 3:00:11 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 4c530a5
- Parents:
- 2686bc7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r2686bc7 rf6e6a55 10 10 // Created On : Sun May 17 12:17:01 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 1810:41:00 202213 // Update Count : 24 712 // Last Modified On : Wed Apr 20 10:41:00 2022 13 // Update Count : 248 14 14 // 15 15 … … 1738 1738 // Resolve all clauses first 1739 1739 for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) { 1740 const ast::WaitFor Stmt::Clause & clause =stmt->clauses[i];1740 const ast::WaitForClause & clause = *stmt->clauses[i]; 1741 1741 1742 1742 ast::TypeEnvironment env; … … 1744 1744 1745 1745 // Find all candidates for a function in canonical form 1746 funcFinder.find( clause.target .func, ResolvMode::withAdjustment() );1746 funcFinder.find( clause.target_func, ResolvMode::withAdjustment() ); 1747 1747 1748 1748 if ( funcFinder.candidates.empty() ) { 1749 1749 stringstream ss; 1750 1750 ss << "Use of undeclared indentifier '"; 1751 ss << clause.target .func.strict_as< ast::NameExpr >()->name;1751 ss << clause.target_func.strict_as< ast::NameExpr >()->name; 1752 1752 ss << "' in call to waitfor"; 1753 1753 SemanticError( stmt->location, ss.str() ); 1754 1754 } 1755 1755 1756 if ( clause.target .args.empty() ) {1756 if ( clause.target_args.empty() ) { 1757 1757 SemanticError( stmt->location, 1758 1758 "Waitfor clause must have at least one mutex parameter"); … … 1761 1761 // Find all alternatives for all arguments in canonical form 1762 1762 std::vector< CandidateFinder > argFinders = 1763 funcFinder.findSubExprs( clause.target .args );1763 funcFinder.findSubExprs( clause.target_args ); 1764 1764 1765 1765 // List all combinations of arguments … … 1934 1934 1935 1935 // build new clause 1936 a st::WaitForStmt::Clause clause2;1937 1938 clause2 .target.func = funcCandidates.front()->expr;1939 1940 clause2 .target.args.reserve( clause.target.args.size() );1936 auto clause2 = new ast::WaitForClause( clause.location ); 1937 1938 clause2->target_func = funcCandidates.front()->expr; 1939 1940 clause2->target_args.reserve( clause.target_args.size() ); 1941 1941 const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" ); 1942 1942 for ( auto arg : argsCandidates.front() ) { … … 1955 1955 ); 1956 1956 1957 clause2 .target.args.emplace_back( findSingleExpression( init, context ) );1957 clause2->target_args.emplace_back( findSingleExpression( init, context ) ); 1958 1958 } 1959 1959 1960 1960 // Resolve the conditions as if it were an IfStmt, statements normally 1961 clause2 .cond = findSingleExpression( clause.cond, context );1962 clause2 .stmt = clause.stmt->accept( *visitor );1961 clause2->cond = findSingleExpression( clause.cond, context ); 1962 clause2->stmt = clause.stmt->accept( *visitor ); 1963 1963 1964 1964 // set results into stmt 1965 1965 auto n = mutate( stmt ); 1966 n->clauses[i] = std::move( clause2 );1966 n->clauses[i] = clause2; 1967 1967 stmt = n; 1968 1968 } 1969 1969 1970 if ( stmt->timeout .stmt ) {1970 if ( stmt->timeout_stmt ) { 1971 1971 // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally 1972 ast::WaitForStmt::Timeout timeout2;1973 1974 1972 ast::ptr< ast::Type > target = 1975 1973 new ast::BasicType{ ast::BasicType::LongLongUnsignedInt }; 1976 timeout2.time = findSingleExpression( stmt->timeout.time, target, context );1977 timeout2.cond = findSingleExpression( stmt->timeout.cond, context );1978 timeout2.stmt = stmt->timeout.stmt->accept( *visitor );1974 auto timeout_time = findSingleExpression( stmt->timeout_time, target, context ); 1975 auto timeout_cond = findSingleExpression( stmt->timeout_cond, context ); 1976 auto timeout_stmt = stmt->timeout_stmt->accept( *visitor ); 1979 1977 1980 1978 // set results into stmt 1981 1979 auto n = mutate( stmt ); 1982 n->timeout = std::move( timeout2 ); 1980 n->timeout_time = std::move( timeout_time ); 1981 n->timeout_cond = std::move( timeout_cond ); 1982 n->timeout_stmt = std::move( timeout_stmt ); 1983 1983 stmt = n; 1984 1984 } 1985 1985 1986 if ( stmt-> orElse.stmt ) {1986 if ( stmt->else_stmt ) { 1987 1987 // resolve the condition like IfStmt, stmts normally 1988 ast::WaitForStmt::OrElse orElse2; 1989 1990 orElse2.cond = findSingleExpression( stmt->orElse.cond, context ); 1991 orElse2.stmt = stmt->orElse.stmt->accept( *visitor ); 1988 auto else_cond = findSingleExpression( stmt->else_cond, context ); 1989 auto else_stmt = stmt->else_stmt->accept( *visitor ); 1992 1990 1993 1991 // set results into stmt 1994 1992 auto n = mutate( stmt ); 1995 n->orElse = std::move( orElse2 ); 1993 n->else_cond = std::move( else_cond ); 1994 n->else_stmt = std::move( else_stmt ); 1996 1995 stmt = n; 1997 1996 }
Note: See TracChangeset
for help on using the changeset viewer.