Changeset ca78437


Ignore:
Timestamp:
Jun 12, 2017, 1:41:06 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
465ed18
Parents:
cfaabe2c
Message:

Updated the CatchStmt? node so that it may handle both termination and resumption.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    rcfaabe2c rca78437  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 17 16:23:00 2017
    13 // Update Count     : 778
     12// Last Modified On : Mon Jun 12 13:00:00 2017
     13// Update Count     : 779
    1414//
    1515
     
    396396Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
    397397Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt );
    398 Statement * build_catch( DeclarationNode * decl, StatementNode * stmt, bool catchAny = false );
     398Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body );
    399399Statement * build_finally( StatementNode * stmt );
    400400Statement * build_compound( StatementNode * first );
  • src/Parser/StatementNode.cc

    rcfaabe2c rca78437  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun  8 16:16:00 2017
    13 // Update Count     : 328
     12// Last Modified On : Mon Jun 12 13:03:00 2017
     13// Update Count     : 329
    1414//
    1515
     
    181181        return new TryStmt( noLabels, tryBlock, branches, finallyBlock );
    182182}
    183 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {
    184         std::list< Statement * > branches;
    185         buildMoveList< Statement, StatementNode >( stmt, branches );
    186         assert( branches.size() == 1 );
    187         return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny );
     183Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) {
     184        std::list< Statement * > branches;
     185        buildMoveList< Statement, StatementNode >( body, branches );
     186        assert( branches.size() == 1 );
     187        return new CatchStmt( noLabels, kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
    188188}
    189189Statement *build_finally( StatementNode *stmt ) {
  • src/Parser/parser.yy

    rcfaabe2c rca78437  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 10 07:58:44 2017
    13 // Update Count     : 2401
     12// Last Modified On : Mon Jun 12 12:59:00 2017
     13// Update Count     : 2402
    1414//
    1515
     
    960960handler_clause:
    961961        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    962                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     962                { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); }
    963963        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    964                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     964                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); }
    965965        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    966                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     966                { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); }
    967967        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    968                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     968                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); }
    969969        ;
    970970
  • src/SynTree/Statement.cc

    rcfaabe2c rca78437  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Jun 08 16:22:00 2017
    13 // Update Count     : 63
     12// Last Modified On : Mon Jun 12 10:37:00 2017
     13// Update Count     : 64
    1414//
    1515
     
    344344}
    345345
    346 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :
    347         Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {
     346CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) :
     347        Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) {
    348348}
    349349
    350350CatchStmt::CatchStmt( const CatchStmt & other ) :
    351         Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
     351        Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) {
    352352}
    353353
     
    358358
    359359void CatchStmt::print( std::ostream &os, int indent ) const {
    360         os << "Catch Statement" << endl;
     360        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    361361
    362362        os << string( indent, ' ' ) << "... catching" << endl;
     
    364364                decl->printShort( os, indent + 4 );
    365365                os << endl;
    366         } else if ( catchRest )
    367                 os << string( indent + 4 , ' ' ) << "the rest" << endl;
     366        }
    368367        else
    369368                os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
  • src/SynTree/Statement.h

    rcfaabe2c rca78437  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Jun 08 18:39:00 2017
    13 // Update Count     : 66
     12// Last Modified On : Mon Jun 12 13:35:00 2017
     13// Update Count     : 67
    1414//
    1515
     
    293293        enum Kind { Terminate, Resume };
    294294
    295         ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr,
    296                    Expression * target = nullptr );
     295        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
    297296        ThrowStmt( const ThrowStmt &other );
    298297        virtual ~ThrowStmt();
    299 
    300298
    301299        Kind get_kind() { return kind; }
     
    341339class CatchStmt : public Statement {
    342340  public:
    343         CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false );
     341        enum Kind { Terminate, Resume };
     342
     343        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     344                   Expression *cond, Statement *body );
    344345        CatchStmt( const CatchStmt &other );
    345346        virtual ~CatchStmt();
    346347
     348        Kind get_kind() { return kind; }
    347349        Declaration *get_decl() { return decl; }
    348350        void set_decl( Declaration *newValue ) { decl = newValue; }
    349 
     351        Expression *get_cond() { return cond; }
     352        void set_cond( Expression *newCond ) { cond = newCond; }
    350353        Statement *get_body() { return body; }
    351354        void set_body( Statement *newValue ) { body = newValue; }
     
    357360
    358361  private:
     362        Kind kind;
    359363        Declaration *decl;
     364        Expression *cond;
    360365        Statement *body;
    361         bool catchRest;
    362366};
    363367
  • tools/cfa.nanorc

    rcfaabe2c rca78437  
    3333## Update/Redistribute
    3434# GCC builtins
    35 ##color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
     35color cyan "__attribute__[[:space:]]*\(\([^()]*(\([^()]*\)[^()]*)*\)\)"
     36##color cyan "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
    3637
    3738# Preprocesser Directives
Note: See TracChangeset for help on using the changeset viewer.