Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r9e23b446 r9e7236f4  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 20 10:41:00 2022
    13 // Update Count     : 248
     12// Last Modified On : Fri Mar 18 10:41:00 2022
     13// Update Count     : 247
    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;
    15601557                        ast::mutate_field(
    15611558                                type, &PtrType::dimension,
    1562                                 dimension);
     1559                                findSingleExpression( type->dimension, sizeType, context ) );
    15631560                }
    15641561                return type;
     
    17251722                // Resolve all clauses first
    17261723                for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) {
    1727                         const ast::WaitForClause & clause = *stmt->clauses[i];
     1724                        const ast::WaitForStmt::Clause & clause = stmt->clauses[i];
    17281725
    17291726                        ast::TypeEnvironment env;
     
    17311728
    17321729                        // 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() );
    17341731
    17351732                        if ( funcFinder.candidates.empty() ) {
    17361733                                stringstream ss;
    17371734                                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;
    17391736                                ss << "' in call to waitfor";
    17401737                                SemanticError( stmt->location, ss.str() );
    17411738                        }
    17421739
    1743                         if ( clause.target_args.empty() ) {
     1740                        if ( clause.target.args.empty() ) {
    17441741                                SemanticError( stmt->location,
    17451742                                        "Waitfor clause must have at least one mutex parameter");
     
    17481745                        // Find all alternatives for all arguments in canonical form
    17491746                        std::vector< CandidateFinder > argFinders =
    1750                                 funcFinder.findSubExprs( clause.target_args );
     1747                                funcFinder.findSubExprs( clause.target.args );
    17511748
    17521749                        // List all combinations of arguments
     
    19211918
    19221919                        // build new clause
    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() );
     1920                        ast::WaitForStmt::Clause clause2;
     1921
     1922                        clause2.target.func = funcCandidates.front()->expr;
     1923
     1924                        clause2.target.args.reserve( clause.target.args.size() );
    19281925                        const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" );
    19291926                        for ( auto arg : argsCandidates.front() ) {
     
    19421939                                );
    19431940
    1944                                 clause2->target_args.emplace_back( findSingleExpression( init, context ) );
     1941                                clause2.target.args.emplace_back( findSingleExpression( init, context ) );
    19451942                        }
    19461943
    19471944                        // 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 );
    19501947
    19511948                        // set results into stmt
    19521949                        auto n = mutate( stmt );
    1953                         n->clauses[i] = clause2;
     1950                        n->clauses[i] = std::move( clause2 );
    19541951                        stmt = n;
    19551952                }
    19561953
    1957                 if ( stmt->timeout_stmt ) {
     1954                if ( stmt->timeout.stmt ) {
    19581955                        // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
     1956                        ast::WaitForStmt::Timeout timeout2;
     1957
    19591958                        ast::ptr< ast::Type > target =
    19601959                                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 );
    19641963
    19651964                        // set results into stmt
    19661965                        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 );
    19701967                        stmt = n;
    19711968                }
    19721969
    1973                 if ( stmt->else_stmt ) {
     1970                if ( stmt->orElse.stmt ) {
    19741971                        // 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 );
    19771976
    19781977                        // set results into stmt
    19791978                        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 );
    19821980                        stmt = n;
    19831981                }
     
    20112009                                tmp->accept( *visitor );
    20122010                        }
    2013                         else if (expr->env && expr->env->empty()) {
    2014                                 expr = ast::mutate_field(expr.get(), &ast::Expr::env, nullptr);
    2015                         }
    20162011                }
    20172012        }
Note: See TracChangeset for help on using the changeset viewer.