Changes in src/ResolvExpr/Resolver.cc [9e7236f4:9e23b446]
- File:
-
- 1 edited
-
src/ResolvExpr/Resolver.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r9e7236f4 r9e23b446 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 … … 1555 1555 if ( type->dimension ) { 1556 1556 ast::ptr< ast::Type > sizeType = context.global.sizeType; 1557 ast::ptr< ast::Expr > dimension = findSingleExpression( type->dimension, sizeType, context ); 1558 assertf(dimension->env->empty(), "array dimension expr has nonempty env"); 1559 dimension.get_and_mutate()->env = nullptr; 1557 1560 ast::mutate_field( 1558 1561 type, &PtrType::dimension, 1559 findSingleExpression( type->dimension, sizeType, context ));1562 dimension); 1560 1563 } 1561 1564 return type; … … 1722 1725 // Resolve all clauses first 1723 1726 for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) { 1724 const ast::WaitFor Stmt::Clause & clause =stmt->clauses[i];1727 const ast::WaitForClause & clause = *stmt->clauses[i]; 1725 1728 1726 1729 ast::TypeEnvironment env; … … 1728 1731 1729 1732 // Find all candidates for a function in canonical form 1730 funcFinder.find( clause.target .func, ResolvMode::withAdjustment() );1733 funcFinder.find( clause.target_func, ResolvMode::withAdjustment() ); 1731 1734 1732 1735 if ( funcFinder.candidates.empty() ) { 1733 1736 stringstream ss; 1734 1737 ss << "Use of undeclared indentifier '"; 1735 ss << clause.target .func.strict_as< ast::NameExpr >()->name;1738 ss << clause.target_func.strict_as< ast::NameExpr >()->name; 1736 1739 ss << "' in call to waitfor"; 1737 1740 SemanticError( stmt->location, ss.str() ); 1738 1741 } 1739 1742 1740 if ( clause.target .args.empty() ) {1743 if ( clause.target_args.empty() ) { 1741 1744 SemanticError( stmt->location, 1742 1745 "Waitfor clause must have at least one mutex parameter"); … … 1745 1748 // Find all alternatives for all arguments in canonical form 1746 1749 std::vector< CandidateFinder > argFinders = 1747 funcFinder.findSubExprs( clause.target .args );1750 funcFinder.findSubExprs( clause.target_args ); 1748 1751 1749 1752 // List all combinations of arguments … … 1918 1921 1919 1922 // build new clause 1920 a st::WaitForStmt::Clause clause2;1921 1922 clause2 .target.func = funcCandidates.front()->expr;1923 1924 clause2 .target.args.reserve( clause.target.args.size() );1923 auto clause2 = new ast::WaitForClause( clause.location ); 1924 1925 clause2->target_func = funcCandidates.front()->expr; 1926 1927 clause2->target_args.reserve( clause.target_args.size() ); 1925 1928 const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" ); 1926 1929 for ( auto arg : argsCandidates.front() ) { … … 1939 1942 ); 1940 1943 1941 clause2 .target.args.emplace_back( findSingleExpression( init, context ) );1944 clause2->target_args.emplace_back( findSingleExpression( init, context ) ); 1942 1945 } 1943 1946 1944 1947 // Resolve the conditions as if it were an IfStmt, statements normally 1945 clause2 .cond = findSingleExpression( clause.cond, context );1946 clause2 .stmt = clause.stmt->accept( *visitor );1948 clause2->cond = findSingleExpression( clause.cond, context ); 1949 clause2->stmt = clause.stmt->accept( *visitor ); 1947 1950 1948 1951 // set results into stmt 1949 1952 auto n = mutate( stmt ); 1950 n->clauses[i] = std::move( clause2 );1953 n->clauses[i] = clause2; 1951 1954 stmt = n; 1952 1955 } 1953 1956 1954 if ( stmt->timeout .stmt ) {1957 if ( stmt->timeout_stmt ) { 1955 1958 // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally 1956 ast::WaitForStmt::Timeout timeout2;1957 1958 1959 ast::ptr< ast::Type > target = 1959 1960 new ast::BasicType{ ast::BasicType::LongLongUnsignedInt }; 1960 timeout2.time = findSingleExpression( stmt->timeout.time, target, context );1961 timeout2.cond = findSingleExpression( stmt->timeout.cond, context );1962 timeout2.stmt = stmt->timeout.stmt->accept( *visitor );1961 auto timeout_time = findSingleExpression( stmt->timeout_time, target, context ); 1962 auto timeout_cond = findSingleExpression( stmt->timeout_cond, context ); 1963 auto timeout_stmt = stmt->timeout_stmt->accept( *visitor ); 1963 1964 1964 1965 // set results into stmt 1965 1966 auto n = mutate( stmt ); 1966 n->timeout = std::move( timeout2 ); 1967 n->timeout_time = std::move( timeout_time ); 1968 n->timeout_cond = std::move( timeout_cond ); 1969 n->timeout_stmt = std::move( timeout_stmt ); 1967 1970 stmt = n; 1968 1971 } 1969 1972 1970 if ( stmt-> orElse.stmt ) {1973 if ( stmt->else_stmt ) { 1971 1974 // resolve the condition like IfStmt, stmts normally 1972 ast::WaitForStmt::OrElse orElse2; 1973 1974 orElse2.cond = findSingleExpression( stmt->orElse.cond, context ); 1975 orElse2.stmt = stmt->orElse.stmt->accept( *visitor ); 1975 auto else_cond = findSingleExpression( stmt->else_cond, context ); 1976 auto else_stmt = stmt->else_stmt->accept( *visitor ); 1976 1977 1977 1978 // set results into stmt 1978 1979 auto n = mutate( stmt ); 1979 n->orElse = std::move( orElse2 ); 1980 n->else_cond = std::move( else_cond ); 1981 n->else_stmt = std::move( else_stmt ); 1980 1982 stmt = n; 1981 1983 } … … 2009 2011 tmp->accept( *visitor ); 2010 2012 } 2013 else if (expr->env && expr->env->empty()) { 2014 expr = ast::mutate_field(expr.get(), &ast::Expr::env, nullptr); 2015 } 2011 2016 } 2012 2017 }
Note:
See TracChangeset
for help on using the changeset viewer.