Ignore:
Timestamp:
Apr 29, 2018, 8:58:08 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
5e5dbc2
Parents:
db98cd5
Message:

start for cpp directive-statement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    rdb98cd5 r61fc4f6  
    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 : Sun Apr 29 14:21:45 2018
     13// Update Count     : 353
    1414//
    1515
     
    3333
    3434
    35 StatementNode::StatementNode( DeclarationNode *decl ) {
     35StatementNode::StatementNode( DeclarationNode * decl ) {
    3636        assert( decl );
    37         DeclarationNode *agg = decl->extractAggregate();
     37        DeclarationNode * agg = decl->extractAggregate();
    3838        if ( agg ) {
    39                 StatementNode *nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
     39                StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
    4040                set_next( nextStmt );
    4141                if ( decl->get_next() ) {
     
    5353} // StatementNode::StatementNode
    5454
    55 StatementNode *StatementNode::append_last_case( StatementNode *stmt ) {
    56         StatementNode *prev = this;
     55StatementNode * StatementNode::append_last_case( StatementNode * stmt ) {
     56        StatementNode * prev = this;
    5757        // find end of list and maintain previous pointer
    5858        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    59                 StatementNode *node = strict_dynamic_cast< StatementNode * >(curr);
     59                StatementNode * node = strict_dynamic_cast< StatementNode * >(curr);
    6060                assert( dynamic_cast< CaseStmt * >(node->stmt.get()) );
    6161                prev = curr;
    6262        } // for
    6363        // convert from StatementNode list to Statement list
    64         StatementNode *node = dynamic_cast< StatementNode * >(prev);
     64        StatementNode * node = dynamic_cast< StatementNode * >(prev);
    6565        std::list< Statement * > stmts;
    6666        buildMoveList( stmt, stmts );
     
    7171}
    7272
    73 Statement *build_expr( ExpressionNode *ctl ) {
    74         Expression *e = maybeMoveBuild< Expression >( ctl );
     73Statement * build_expr( ExpressionNode * ctl ) {
     74        Expression * e = maybeMoveBuild< Expression >( ctl );
    7575
    7676        if ( e )
     
    8080}
    8181
    82 Statement *build_if( IfCtl * ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {
    83         Statement *thenb, *elseb = 0;
     82Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     83        Statement * thenb, * elseb = 0;
    8484        std::list< Statement * > branches;
    8585        buildMoveList< Statement, StatementNode >( then_stmt, branches );
     
    116116}
    117117
    118 Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
     118Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
    119119        std::list< Statement * > branches;
    120120        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    131131        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
    132132}
    133 Statement *build_case( ExpressionNode *ctl ) {
     133Statement * build_case( ExpressionNode * ctl ) {
    134134        std::list< Statement * > branches;
    135135        return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );
    136136}
    137 Statement *build_default() {
     137Statement * build_default() {
    138138        std::list< Statement * > branches;
    139139        return new CaseStmt( nullptr, branches, true );
    140140}
    141141
    142 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
     142Statement * build_while( ExpressionNode * ctl, StatementNode * stmt, bool kind ) {
    143143        std::list< Statement * > branches;
    144144        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    147147}
    148148
    149 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
     149Statement * build_for( ForCtl * forctl, StatementNode * stmt ) {
    150150        std::list< Statement * > branches;
    151151        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    157157        } // if
    158158
    159         Expression *cond = 0;
     159        Expression * cond = 0;
    160160        if ( forctl->condition != 0 )
    161161                cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
    162162
    163         Expression *incr = 0;
     163        Expression * incr = 0;
    164164        if ( forctl->change != 0 )
    165165                incr = maybeMoveBuild< Expression >(forctl->change);
     
    169169}
    170170
    171 Statement *build_branch( BranchStmt::Type kind ) {
     171Statement * build_branch( BranchStmt::Type kind ) {
    172172        Statement * ret = new BranchStmt( "", kind );
    173173        return ret;
    174174}
    175 Statement *build_branch( std::string *identifier, BranchStmt::Type kind ) {
    176         Statement * ret = new BranchStmt( *identifier, kind );
     175Statement * build_branch( std::string * identifier, BranchStmt::Type kind ) {
     176        Statement * ret = new BranchStmt( * identifier, kind );
    177177        delete identifier;                                                                      // allocated by lexer
    178178        return ret;
    179179}
    180 Statement *build_computedgoto( ExpressionNode *ctl ) {
     180Statement * build_computedgoto( ExpressionNode * ctl ) {
    181181        return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
    182182}
    183183
    184 Statement *build_return( ExpressionNode *ctl ) {
     184Statement * build_return( ExpressionNode * ctl ) {
    185185        std::list< Expression * > exps;
    186186        buildMoveList( ctl, exps );
     
    188188}
    189189
    190 Statement *build_throw( ExpressionNode *ctl ) {
     190Statement * build_throw( ExpressionNode * ctl ) {
    191191        std::list< Expression * > exps;
    192192        buildMoveList( ctl, exps );
     
    195195}
    196196
    197 Statement *build_resume( ExpressionNode *ctl ) {
     197Statement * build_resume( ExpressionNode * ctl ) {
    198198        std::list< Expression * > exps;
    199199        buildMoveList( ctl, exps );
     
    202202}
    203203
    204 Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) {
     204Statement * build_resume_at( ExpressionNode * ctl, ExpressionNode * target ) {
    205205        (void)ctl;
    206206        (void)target;
     
    208208}
    209209
    210 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
     210Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ) {
    211211        std::list< CatchStmt * > branches;
    212212        buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
    213         CompoundStmt *tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    214         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) );
    215215        return new TryStmt( tryBlock, branches, finallyBlock );
    216216}
    217 Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) {
     217Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
    218218        std::list< Statement * > branches;
    219219        buildMoveList< Statement, StatementNode >( body, branches );
     
    221221        return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
    222222}
    223 Statement *build_finally( StatementNode *stmt ) {
     223Statement * build_finally( StatementNode * stmt ) {
    224224        std::list< Statement * > branches;
    225225        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    304304}
    305305
    306 Statement *build_compound( StatementNode *first ) {
    307         CompoundStmt *cs = new CompoundStmt();
     306Statement * build_compound( StatementNode * first ) {
     307        CompoundStmt * cs = new CompoundStmt();
    308308        buildMoveList( first, cs->get_kids() );
    309309        return cs;
    310310}
    311311
    312 Statement *build_asmstmt( bool voltile, Expression *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) {
     312Statement * build_asmstmt( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {
    313313        std::list< Expression * > out, in;
    314314        std::list< ConstantExpr * > clob;
     
    318318        buildMoveList( clobber, clob );
    319319        return new AsmStmt( voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
     320}
     321
     322Statement * build_dirstmt( string * directive ) {
     323        cout << *directive << endl;
     324        return nullptr;
    320325}
    321326
Note: See TracChangeset for help on using the changeset viewer.