Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r9e7236f4 r9e23b446  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Mar 18 10:41:00 2022
    13 // Update Count     : 247
     12// Last Modified On : Wed Apr 20 10:41:00 2022
     13// Update Count     : 248
    1414//
    1515
     
    15551555                if ( type->dimension ) {
    15561556                        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;
    15571560                        ast::mutate_field(
    15581561                                type, &PtrType::dimension,
    1559                                 findSingleExpression( type->dimension, sizeType, context ) );
     1562                                dimension);
    15601563                }
    15611564                return type;
     
    17221725                // Resolve all clauses first
    17231726                for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) {
    1724                         const ast::WaitForStmt::Clause & clause = stmt->clauses[i];
     1727                        const ast::WaitForClause & clause = *stmt->clauses[i];
    17251728
    17261729                        ast::TypeEnvironment env;
     
    17281731
    17291732                        // 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() );
    17311734
    17321735                        if ( funcFinder.candidates.empty() ) {
    17331736                                stringstream ss;
    17341737                                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;
    17361739                                ss << "' in call to waitfor";
    17371740                                SemanticError( stmt->location, ss.str() );
    17381741                        }
    17391742
    1740                         if ( clause.target.args.empty() ) {
     1743                        if ( clause.target_args.empty() ) {
    17411744                                SemanticError( stmt->location,
    17421745                                        "Waitfor clause must have at least one mutex parameter");
     
    17451748                        // Find all alternatives for all arguments in canonical form
    17461749                        std::vector< CandidateFinder > argFinders =
    1747                                 funcFinder.findSubExprs( clause.target.args );
     1750                                funcFinder.findSubExprs( clause.target_args );
    17481751
    17491752                        // List all combinations of arguments
     
    19181921
    19191922                        // build new clause
    1920                         ast::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() );
    19251928                        const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" );
    19261929                        for ( auto arg : argsCandidates.front() ) {
     
    19391942                                );
    19401943
    1941                                 clause2.target.args.emplace_back( findSingleExpression( init, context ) );
     1944                                clause2->target_args.emplace_back( findSingleExpression( init, context ) );
    19421945                        }
    19431946
    19441947                        // 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 );
    19471950
    19481951                        // set results into stmt
    19491952                        auto n = mutate( stmt );
    1950                         n->clauses[i] = std::move( clause2 );
     1953                        n->clauses[i] = clause2;
    19511954                        stmt = n;
    19521955                }
    19531956
    1954                 if ( stmt->timeout.stmt ) {
     1957                if ( stmt->timeout_stmt ) {
    19551958                        // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
    1956                         ast::WaitForStmt::Timeout timeout2;
    1957 
    19581959                        ast::ptr< ast::Type > target =
    19591960                                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 );
    19631964
    19641965                        // set results into stmt
    19651966                        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 );
    19671970                        stmt = n;
    19681971                }
    19691972
    1970                 if ( stmt->orElse.stmt ) {
     1973                if ( stmt->else_stmt ) {
    19711974                        // 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 );
    19761977
    19771978                        // set results into stmt
    19781979                        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 );
    19801982                        stmt = n;
    19811983                }
     
    20092011                                tmp->accept( *visitor );
    20102012                        }
     2013                        else if (expr->env && expr->env->empty()) {
     2014                                expr = ast::mutate_field(expr.get(), &ast::Expr::env, nullptr);
     2015                        }
    20112016                }
    20122017        }
Note: See TracChangeset for help on using the changeset viewer.