Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r9e7236f4 rf6e6a55  
    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
     
    427427                        // enumerator initializers should not use the enum type to initialize, since
    428428                        // the enum type is still incomplete at this point. Use signed int instead.
    429                         // TODO: BasicType::SignedInt may not longer be true
    430429                        currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    431430                }
     
    14781477                        // enum type is still incomplete at this point. Use `int` instead.
    14791478
    1480                         if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) {
     1479                        if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { // const ast::PointerType &
     1480                                // const ast::Type * enumBase =  (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get());
     1481                                // const ast::PointerType * enumBaseAsPtr = dynamic_cast<const ast::PointerType *>(enumBase);
     1482
     1483                                // if ( enumBaseAsPtr ) {
     1484                                //      const ast::Type * pointerBase = enumBaseAsPtr->base.get();
     1485                                //      if ( dynamic_cast<const ast::BasicType *>(pointerBase) ) {
     1486                                //              objectDecl = fixObjectType(objectDecl, context);
     1487                                //              if (dynamic_cast<const ast::BasicType *>(pointerBase)->kind == ast::BasicType::Char)
     1488                                //              currentObject = ast::CurrentObject{
     1489                                //                      objectDecl->location,  new ast::PointerType{
     1490                                //                              new ast::BasicType{ ast::BasicType::Char }
     1491                                //                      } };
     1492                                //      } else {
     1493                                //              objectDecl = fixObjectType(objectDecl, context);
     1494                                //              currentObject = ast::CurrentObject{objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } };
     1495                                //      }
     1496                                // }
    14811497                                objectDecl = fixObjectType( objectDecl, context );
    14821498                                const ast::Type * enumBase =  (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get());
     
    17221738                // Resolve all clauses first
    17231739                for ( unsigned i = 0; i < stmt->clauses.size(); ++i ) {
    1724                         const ast::WaitForStmt::Clause & clause = stmt->clauses[i];
     1740                        const ast::WaitForClause & clause = *stmt->clauses[i];
    17251741
    17261742                        ast::TypeEnvironment env;
     
    17281744
    17291745                        // Find all candidates for a function in canonical form
    1730                         funcFinder.find( clause.target.func, ResolvMode::withAdjustment() );
     1746                        funcFinder.find( clause.target_func, ResolvMode::withAdjustment() );
    17311747
    17321748                        if ( funcFinder.candidates.empty() ) {
    17331749                                stringstream ss;
    17341750                                ss << "Use of undeclared indentifier '";
    1735                                 ss << clause.target.func.strict_as< ast::NameExpr >()->name;
     1751                                ss << clause.target_func.strict_as< ast::NameExpr >()->name;
    17361752                                ss << "' in call to waitfor";
    17371753                                SemanticError( stmt->location, ss.str() );
    17381754                        }
    17391755
    1740                         if ( clause.target.args.empty() ) {
     1756                        if ( clause.target_args.empty() ) {
    17411757                                SemanticError( stmt->location,
    17421758                                        "Waitfor clause must have at least one mutex parameter");
     
    17451761                        // Find all alternatives for all arguments in canonical form
    17461762                        std::vector< CandidateFinder > argFinders =
    1747                                 funcFinder.findSubExprs( clause.target.args );
     1763                                funcFinder.findSubExprs( clause.target_args );
    17481764
    17491765                        // List all combinations of arguments
     
    19181934
    19191935                        // 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() );
     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() );
    19251941                        const ast::StructDecl * decl_monitor = symtab.lookupStruct( "monitor$" );
    19261942                        for ( auto arg : argsCandidates.front() ) {
     
    19391955                                );
    19401956
    1941                                 clause2.target.args.emplace_back( findSingleExpression( init, context ) );
     1957                                clause2->target_args.emplace_back( findSingleExpression( init, context ) );
    19421958                        }
    19431959
    19441960                        // 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 );
     1961                        clause2->cond = findSingleExpression( clause.cond, context );
     1962                        clause2->stmt = clause.stmt->accept( *visitor );
    19471963
    19481964                        // set results into stmt
    19491965                        auto n = mutate( stmt );
    1950                         n->clauses[i] = std::move( clause2 );
     1966                        n->clauses[i] = clause2;
    19511967                        stmt = n;
    19521968                }
    19531969
    1954                 if ( stmt->timeout.stmt ) {
     1970                if ( stmt->timeout_stmt ) {
    19551971                        // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
    1956                         ast::WaitForStmt::Timeout timeout2;
    1957 
    19581972                        ast::ptr< ast::Type > target =
    19591973                                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 );
     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 );
    19631977
    19641978                        // set results into stmt
    19651979                        auto n = mutate( stmt );
    1966                         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 );
    19671983                        stmt = n;
    19681984                }
    19691985
    1970                 if ( stmt->orElse.stmt ) {
     1986                if ( stmt->else_stmt ) {
    19711987                        // 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 );
     1988                        auto else_cond = findSingleExpression( stmt->else_cond, context );
     1989                        auto else_stmt = stmt->else_stmt->accept( *visitor );
    19761990
    19771991                        // set results into stmt
    19781992                        auto n = mutate( stmt );
    1979                         n->orElse = std::move( orElse2 );
     1993                        n->else_cond = std::move( else_cond );
     1994                        n->else_stmt = std::move( else_stmt );
    19801995                        stmt = n;
    19811996                }
Note: See TracChangeset for help on using the changeset viewer.