Ignore:
Timestamp:
Mar 28, 2022, 10:41:45 AM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
8e819a9
Parents:
f5bace8
Message:

Added StmtClause? and converted the existing nodes that should be clauses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rf5bace8 r400b8be  
    12811281                const ast::ForStmt *         previsit( const ast::ForStmt * );
    12821282                const ast::SwitchStmt *      previsit( const ast::SwitchStmt * );
    1283                 const ast::CaseStmt *        previsit( const ast::CaseStmt * );
     1283                const ast::CaseClause *      previsit( const ast::CaseClause * );
    12841284                const ast::BranchStmt *      previsit( const ast::BranchStmt * );
    12851285                const ast::ReturnStmt *      previsit( const ast::ReturnStmt * );
    12861286                const ast::ThrowStmt *       previsit( const ast::ThrowStmt * );
    1287                 const ast::CatchStmt *       previsit( const ast::CatchStmt * );
    1288                 const ast::CatchStmt *       postvisit( const ast::CatchStmt * );
     1287                const ast::CatchClause *     previsit( const ast::CatchClause * );
     1288                const ast::CatchClause *     postvisit( const ast::CatchClause * );
    12891289                const ast::WaitForStmt *     previsit( const ast::WaitForStmt * );
    12901290                const ast::WithStmt *        previsit( const ast::WithStmt * );
     
    16151615        }
    16161616
    1617         const ast::CaseStmt * Resolver_new::previsit( const ast::CaseStmt * caseStmt ) {
     1617        const ast::CaseClause * Resolver_new::previsit( const ast::CaseClause * caseStmt ) {
    16181618                if ( caseStmt->cond ) {
    16191619                        std::deque< ast::InitAlternative > initAlts = currentObject.getOptions();
     
    16311631                        }
    16321632
    1633                         caseStmt = ast::mutate_field( caseStmt, &ast::CaseStmt::cond, newExpr );
     1633                        caseStmt = ast::mutate_field( caseStmt, &ast::CaseClause::cond, newExpr );
    16341634                }
    16351635                return caseStmt;
     
    16741674        }
    16751675
    1676         const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) {
     1676        const ast::CatchClause * Resolver_new::previsit( const ast::CatchClause * catchClause ) {
    16771677                // Until we are very sure this invarent (ifs that move between passes have then)
    16781678                // holds, check it. This allows a check for when to decode the mangling.
    1679                 if ( auto ifStmt = catchStmt->body.as<ast::IfStmt>() ) {
     1679                if ( auto ifStmt = catchClause->body.as<ast::IfStmt>() ) {
    16801680                        assert( ifStmt->then );
    16811681                }
    16821682                // Encode the catchStmt so the condition can see the declaration.
    1683                 if ( catchStmt->cond ) {
    1684                         ast::CatchStmt * stmt = mutate( catchStmt );
    1685                         stmt->body = new ast::IfStmt( stmt->location, stmt->cond, nullptr, stmt->body );
    1686                         stmt->cond = nullptr;
    1687                         return stmt;
    1688                 }
    1689                 return catchStmt;
    1690         }
    1691 
    1692         const ast::CatchStmt * Resolver_new::postvisit( const ast::CatchStmt * catchStmt ) {
     1683                if ( catchClause->cond ) {
     1684                        ast::CatchClause * clause = mutate( catchClause );
     1685                        clause->body = new ast::IfStmt( clause->location, clause->cond, nullptr, clause->body );
     1686                        clause->cond = nullptr;
     1687                        return clause;
     1688                }
     1689                return catchClause;
     1690        }
     1691
     1692        const ast::CatchClause * Resolver_new::postvisit( const ast::CatchClause * catchClause ) {
    16931693                // Decode the catchStmt so everything is stored properly.
    1694                 const ast::IfStmt * ifStmt = catchStmt->body.as<ast::IfStmt>();
     1694                const ast::IfStmt * ifStmt = catchClause->body.as<ast::IfStmt>();
    16951695                if ( nullptr != ifStmt && nullptr == ifStmt->then ) {
    16961696                        assert( ifStmt->cond );
    16971697                        assert( ifStmt->else_ );
    1698                         ast::CatchStmt * stmt = ast::mutate( catchStmt );
    1699                         stmt->cond = ifStmt->cond;
    1700                         stmt->body = ifStmt->else_;
     1698                        ast::CatchClause * clause = ast::mutate( catchClause );
     1699                        clause->cond = ifStmt->cond;
     1700                        clause->body = ifStmt->else_;
    17011701                        // ifStmt should be implicately deleted here.
    1702                         return stmt;
    1703                 }
    1704                 return catchStmt;
     1702                        return clause;
     1703                }
     1704                return catchClause;
    17051705        }
    17061706
Note: See TracChangeset for help on using the changeset viewer.