Ignore:
Timestamp:
Aug 12, 2016, 11:24:15 AM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
9903ebb
Parents:
71b5d4d3 (diff), 1ca15c1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    r71b5d4d3 rdac593fd  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 10 22:08:38 2016
    13 // Update Count     : 173
     12// Last Modified On : Thu Aug 11 16:19:45 2016
     13// Update Count     : 210
    1414//
    1515
     
    118118
    119119StatementNode *StatementNode::append_last_case( StatementNode *stmt ) {
     120        assert( false );
    120121        if ( stmt != 0 ) {
    121122                StatementNode *next = ( StatementNode *)get_link();
    122123                if ( next && ( next->get_type() == StatementNode::Case || next->get_type() == StatementNode::Default ) )
    123                         next->append_last_case ( stmt );
     124                        next->append_last_case( stmt );
    124125                else
    125126                        if ( block == 0 )
     
    128129                                block->set_link( stmt );
    129130        } // if
     131        return this;
     132}
     133
     134StatementNode *StatementNode2::append_last_case( StatementNode *stmt ) {
     135        StatementNode *prev = this;
     136        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_link() ) {
     137                StatementNode2 *node = dynamic_cast<StatementNode2 *>(curr);
     138                assert( node );
     139                assert( dynamic_cast<CaseStmt *>(node->stmt) );
     140                prev = curr;
     141        } // for
     142        StatementNode2 *node = dynamic_cast<StatementNode2 *>(prev);
     143        std::list<Statement *> stmts;
     144        buildList( stmt, stmts );
     145        CaseStmt * caseStmt;
     146        caseStmt = dynamic_cast<CaseStmt *>(node->stmt);
     147        caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts );
    130148        return this;
    131149}
     
    205223                                return new NullStmt( labs );
    206224                }
     225                assert( false );
    207226          case If:
    208227                // {
     
    220239                assert( false );
    221240          case Switch:
    222                 //return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches );
     241                // return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches );
    223242                assert( false );
    224243          case Case:
    225                 return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches );
     244                //return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches );
    226245                assert( false );
    227246          case Default:
    228                 return new CaseStmt( labs, 0, branches, true );
     247                //return new CaseStmt( labs, 0, branches, true );
    229248                assert( false );
    230249          case While:
     
    260279                assert( false );
    261280          case Goto:
    262                 {
    263                         if ( get_target() == "" ) {                                     // computed goto
    264                                 assert( get_control() != 0 );
    265                                 return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto );
    266                         } // if
    267 
    268                         return new BranchStmt( labs, get_target(), BranchStmt::Goto );
    269                 }
     281                // {
     282                //      if ( get_target() == "" ) {                                     // computed goto
     283                //              assert( get_control() != 0 );
     284                //              return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto );
     285                //      } // if
     286
     287                //      return new BranchStmt( labs, get_target(), BranchStmt::Goto );
     288                // }
     289                assert( false );
    270290          case Break:
    271                 return new BranchStmt( labs, get_target(), BranchStmt::Break );
     291                // return new BranchStmt( labs, get_target(), BranchStmt::Break );
    272292                assert( false );
    273293          case Continue:
    274                 return new BranchStmt( labs, get_target(), BranchStmt::Continue );
     294                // return new BranchStmt( labs, get_target(), BranchStmt::Continue );
    275295                assert( false );
    276296          case Return:
    277297          case Throw :
    278                 buildList( get_control(), exps );
    279                 if ( exps.size() ==0 )
    280                         return new ReturnStmt( labs, 0, type == Throw );
    281                 if ( exps.size() > 0 )
    282                         return new ReturnStmt( labs, exps.back(), type == Throw );
     298                // buildList( get_control(), exps );
     299                // if ( exps.size() ==0 )
     300                //      return new ReturnStmt( labs, 0, type == Throw );
     301                // if ( exps.size() > 0 )
     302                //      return new ReturnStmt( labs, exps.back(), type == Throw );
     303                assert( false );
    283304          case Try:
    284305                {
     
    314335}
    315336
     337Statement *build_expr( ExpressionNode *ctl ) {
     338        Expression *e = maybeBuild< Expression >( ctl );
     339
     340        if ( e )
     341                return new ExprStmt( noLabels, e );
     342        else
     343                return new NullStmt( noLabels );
     344}
     345
    316346Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {
    317347        Statement *thenb, *elseb = 0;
     
    338368Statement *build_case( ExpressionNode *ctl ) {
    339369        std::list<Statement *> branches;
    340         buildList<Statement, StatementNode>( nullptr, branches );
    341370        return new CaseStmt( noLabels, maybeBuild<Expression>(ctl), branches );
    342371}
     
    377406Statement *build_branch( std::string identifier, BranchStmt::Type kind ) {
    378407        return new BranchStmt( noLabels, identifier, kind );
     408}
     409Statement *build_computedgoto( ExpressionNode *ctl ) {
     410        return new BranchStmt( noLabels, maybeBuild<Expression>(ctl), BranchStmt::Goto );
     411}
     412
     413Statement *build_return( ExpressionNode *ctl ) {
     414        std::list<Expression *> exps;
     415        buildList( ctl, exps );
     416        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr );
     417}
     418Statement *build_throw( ExpressionNode *ctl ) {
     419        std::list<Expression *> exps;
     420        buildList( ctl, exps );
     421        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true );
    379422}
    380423
Note: See TracChangeset for help on using the changeset viewer.