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