Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
2472a19
Parents:
f6f0cca3 (diff), c7d8100c (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 remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    rf6f0cca3 rff29f08  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 14:31:32 2018
    13 // Update Count     : 348
     12// Last Modified On : Mon Apr 30 09:21:16 2018
     13// Update Count     : 354
    1414//
    1515
    1616#include <cassert>                 // for assert, strict_dynamic_cast, assertf
    1717#include <list>                    // for list
     18#include <memory>                  // for unique_ptr
    1819#include <string>                  // for string
    1920
     
    3233
    3334
    34 StatementNode::StatementNode( DeclarationNode *decl ) {
     35StatementNode::StatementNode( DeclarationNode * decl ) {
    3536        assert( decl );
    36         DeclarationNode *agg = decl->extractAggregate();
     37        DeclarationNode * agg = decl->extractAggregate();
    3738        if ( agg ) {
    38                 StatementNode *nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
     39                StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
    3940                set_next( nextStmt );
    4041                if ( decl->get_next() ) {
     
    5253} // StatementNode::StatementNode
    5354
    54 StatementNode *StatementNode::append_last_case( StatementNode *stmt ) {
    55         StatementNode *prev = this;
     55StatementNode * StatementNode::append_last_case( StatementNode * stmt ) {
     56        StatementNode * prev = this;
    5657        // find end of list and maintain previous pointer
    5758        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    58                 StatementNode *node = strict_dynamic_cast< StatementNode * >(curr);
     59                StatementNode * node = strict_dynamic_cast< StatementNode * >(curr);
    5960                assert( dynamic_cast< CaseStmt * >(node->stmt) );
    6061                prev = curr;
    6162        } // for
    6263        // convert from StatementNode list to Statement list
    63         StatementNode *node = dynamic_cast< StatementNode * >(prev);
     64        StatementNode * node = dynamic_cast< StatementNode * >(prev);
    6465        std::list< Statement * > stmts;
    6566        buildMoveList( stmt, stmts );
     
    7071}
    7172
    72 Statement *build_expr( ExpressionNode *ctl ) {
    73         Expression *e = maybeMoveBuild< Expression >( ctl );
     73Statement * build_expr( ExpressionNode * ctl ) {
     74        Expression * e = maybeMoveBuild< Expression >( ctl );
    7475
    7576        if ( e )
     
    7980}
    8081
    81 Statement *build_if( IfCtl * ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {
    82         Statement *thenb, *elseb = 0;
     82Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     83        Statement * thenb, * elseb = 0;
    8384        std::list< Statement * > branches;
    8485        buildMoveList< Statement, StatementNode >( then_stmt, branches );
     
    115116}
    116117
    117 Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
     118Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
    118119        std::list< Statement * > branches;
    119120        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    130131        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
    131132}
    132 Statement *build_case( ExpressionNode *ctl ) {
     133Statement * build_case( ExpressionNode * ctl ) {
    133134        std::list< Statement * > branches;
    134135        return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );
    135136}
    136 Statement *build_default() {
     137Statement * build_default() {
    137138        std::list< Statement * > branches;
    138139        return new CaseStmt( nullptr, branches, true );
    139140}
    140141
    141 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
     142Statement * build_while( ExpressionNode * ctl, StatementNode * stmt, bool kind ) {
    142143        std::list< Statement * > branches;
    143144        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    146147}
    147148
    148 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
     149Statement * build_for( ForCtl * forctl, StatementNode * stmt ) {
    149150        std::list< Statement * > branches;
    150151        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    156157        } // if
    157158
    158         Expression *cond = 0;
     159        Expression * cond = 0;
    159160        if ( forctl->condition != 0 )
    160161                cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
    161162
    162         Expression *incr = 0;
     163        Expression * incr = 0;
    163164        if ( forctl->change != 0 )
    164165                incr = maybeMoveBuild< Expression >(forctl->change);
     
    168169}
    169170
    170 Statement *build_branch( BranchStmt::Type kind ) {
     171Statement * build_branch( BranchStmt::Type kind ) {
    171172        Statement * ret = new BranchStmt( "", kind );
    172173        return ret;
    173174}
    174 Statement *build_branch( std::string *identifier, BranchStmt::Type kind ) {
    175         Statement * ret = new BranchStmt( *identifier, kind );
     175Statement * build_branch( std::string * identifier, BranchStmt::Type kind ) {
     176        Statement * ret = new BranchStmt( * identifier, kind );
    176177        delete identifier;                                                                      // allocated by lexer
    177178        return ret;
    178179}
    179 Statement *build_computedgoto( ExpressionNode *ctl ) {
     180Statement * build_computedgoto( ExpressionNode * ctl ) {
    180181        return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
    181182}
    182183
    183 Statement *build_return( ExpressionNode *ctl ) {
     184Statement * build_return( ExpressionNode * ctl ) {
    184185        std::list< Expression * > exps;
    185186        buildMoveList( ctl, exps );
     
    187188}
    188189
    189 Statement *build_throw( ExpressionNode *ctl ) {
     190Statement * build_throw( ExpressionNode * ctl ) {
    190191        std::list< Expression * > exps;
    191192        buildMoveList( ctl, exps );
     
    194195}
    195196
    196 Statement *build_resume( ExpressionNode *ctl ) {
     197Statement * build_resume( ExpressionNode * ctl ) {
    197198        std::list< Expression * > exps;
    198199        buildMoveList( ctl, exps );
     
    201202}
    202203
    203 Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) {
     204Statement * build_resume_at( ExpressionNode * ctl, ExpressionNode * target ) {
    204205        (void)ctl;
    205206        (void)target;
     
    207208}
    208209
    209 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
     210Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ) {
    210211        std::list< CatchStmt * > branches;
    211212        buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
    212         CompoundStmt *tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    213         FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
     213        CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
     214        FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
    214215        return new TryStmt( tryBlock, branches, finallyBlock );
    215216}
    216 Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) {
     217Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
    217218        std::list< Statement * > branches;
    218219        buildMoveList< Statement, StatementNode >( body, branches );
     
    220221        return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
    221222}
    222 Statement *build_finally( StatementNode *stmt ) {
     223Statement * build_finally( StatementNode * stmt ) {
    223224        std::list< Statement * > branches;
    224225        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    303304}
    304305
    305 Statement *build_compound( StatementNode *first ) {
    306         CompoundStmt *cs = new CompoundStmt();
     306Statement * build_compound( StatementNode * first ) {
     307        CompoundStmt * cs = new CompoundStmt();
    307308        buildMoveList( first, cs->get_kids() );
    308309        return cs;
    309310}
    310311
    311 Statement *build_asmstmt( bool voltile, Expression *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) {
     312Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {
    312313        std::list< Expression * > out, in;
    313314        std::list< ConstantExpr * > clob;
     
    317318        buildMoveList( clobber, clob );
    318319        return new AsmStmt( voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
     320}
     321
     322Statement * build_directive( string * directive ) {
     323        return new DirectiveStmt( *directive );
    319324}
    320325
Note: See TracChangeset for help on using the changeset viewer.