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/ControlStruct/ExceptTranslateNew.cpp

    rf5bace8 r400b8be  
    2626namespace {
    2727
    28         typedef std::list<ast::CatchStmt*> CatchList;
     28        typedef std::list<ast::CatchClause*> CatchList;
    2929
    3030        void appendDeclStmt( ast::CompoundStmt * block, ast::DeclWithType * item ) {
     
    4545        {}
    4646
    47         void previsit( const ast::CatchStmt * stmt );
     47        void previsit( const ast::CatchClause * stmt );
    4848        const ast::Stmt * postvisit( const ast::ThrowStmt * stmt );
    4949};
     
    8888}
    8989
    90 void TranslateThrowsCore::previsit( const ast::CatchStmt * stmt ) {
     90void TranslateThrowsCore::previsit( const ast::CatchClause * stmt ) {
    9191        // Validate the statement's form.
    9292        const ast::ObjectDecl * decl = stmt->decl.as<ast::ObjectDecl>();
     
    147147        ast::FunctionDecl * create_terminate_catch( CatchList &handlers );
    148148        ast::CompoundStmt * create_single_matcher(
    149                 const ast::DeclWithType * except_obj, ast::CatchStmt * modded_handler );
     149                const ast::DeclWithType * except_obj, ast::CatchClause * modded_handler );
    150150        ast::FunctionDecl * create_terminate_match( CatchList &handlers );
    151151        ast::CompoundStmt * create_terminate_caller( CodeLocation loc, ast::FunctionDecl * try_wrapper,
     
    338338ast::FunctionDecl * TryMutatorCore::create_terminate_catch(
    339339                CatchList &handlers ) {
    340         std::vector<ast::ptr<ast::Stmt>> handler_wrappers;
     340        std::vector<ast::ptr<ast::CaseClause>> handler_wrappers;
    341341
    342342        assert (!handlers.empty());
     
    352352        for ( ; it != handlers.end() ; ++it ) {
    353353                ++index;
    354                 ast::CatchStmt * handler = *it;
     354                ast::CatchClause * handler = *it;
    355355                const CodeLocation loc = handler->location;
    356356
     
    390390                // handler->body = nullptr;
    391391
    392                 handler_wrappers.push_back( new ast::CaseStmt(loc,
     392                handler_wrappers.push_back( new ast::CaseClause(loc,
    393393                        ast::ConstantExpr::from_int(loc, index) ,
    394394                        { block, new ast::ReturnStmt( loc, nullptr ) }
     
    410410// except_obj is referenced, modded_handler will be freed.
    411411ast::CompoundStmt * TryMutatorCore::create_single_matcher(
    412                 const ast::DeclWithType * except_obj, ast::CatchStmt * modded_handler ) {
     412                const ast::DeclWithType * except_obj, ast::CatchClause * modded_handler ) {
    413413        // {
    414414        //     `modded_handler.decl`
     
    465465        for ( it = handlers.begin() ; it != handlers.end() ; ++it ) {
    466466                ++index;
    467                 ast::CatchStmt * handler = *it;
     467                ast::CatchClause * handler = *it;
    468468
    469469                // Body should have been taken by create_terminate_catch.
     
    520520        CatchList::iterator it;
    521521        for ( it = handlers.begin() ; it != handlers.end() ; ++it ) {
    522                 ast::CatchStmt * handler = *it;
     522                ast::CatchClause * handler = *it;
    523523                const CodeLocation loc = handler->location;
    524524                // Modifiy body.
     
    587587                ast::TryStmt * tryStmt ) {
    588588        // void finally() { `finally->block` }
    589         const ast::FinallyStmt * finally = tryStmt->finally;
     589        const ast::FinallyClause * finally = tryStmt->finally;
    590590        const ast::CompoundStmt * body = finally->body;
    591591
Note: See TracChangeset for help on using the changeset viewer.