Changeset 4e7171f


Ignore:
Timestamp:
Feb 2, 2022, 1:45:19 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
17cb385, 6180274, 8cb149f
Parents:
ff3b0249
Message:

more cleanup of build_* functions, make init parameter const for WhileDoStmt?

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    rff3b0249 r4e7171f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // StatementNode.cc --
     7// StatementNode.cc -- Transform from parse data-structures to AST data-structures, usually deleting the parse
     8//     data-structure after the transformation.
    89//
    910// Author           : Rodolfo G. Esteves
    1011// Created On       : Sat May 16 14:59:41 2015
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 09:45:28 2022
    13 // Update Count     : 415
     13// Last Modified On : Wed Feb  2 12:27:58 2022
     14// Update Count     : 424
    1415//
    1516
     
    137138
    138139Statement * build_case( ExpressionNode * ctl ) {
    139         return new CaseStmt( maybeMoveBuild< Expression >(ctl), list< Statement * >{} );
     140        return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // no init
    140141} // build_case
    141142
    142143Statement * build_default() {
    143         return new CaseStmt( nullptr, list< Statement * >{}, true );
     144        return new CaseStmt( nullptr, {}, true );                       // no init
    144145} // build_default
    145146
     
    159160
    160161Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) {
    161         // do-while cannot have declarations in the contitional, so always empty
    162         list< Statement * > astinit;
    163 
    164162        list< Statement * > aststmt;                                            // loop body, compound created if empty
    165163        buildMoveList< Statement, StatementNode >( stmt, aststmt );
     
    169167        buildMoveList< Statement, StatementNode >( else_, astelse );
    170168
    171         return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), astinit, true );
     169        // do-while cannot have declarations in the contitional, so init is always empty
     170        return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), {}, true );
    172171} // build_do_while
    173172
  • src/SynTree/Statement.cc

    rff3b0249 r4e7171f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 17:55:29 2022
    13 // Update Count     : 79
     12// Last Modified On : Wed Feb  2 11:55:19 2022
     13// Update Count     : 80
    1414//
    1515
     
    246246}
    247247
    248 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ):
     248WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const std::list< Statement * > & initialization, bool isDoWhile ):
    249249        Statement(), condition( condition ), body( body ), else_( nullptr ), initialization( initialization ), isDoWhile( isDoWhile) {
    250250}
    251251
    252 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, std::list< Statement * > & initialization, bool isDoWhile ):
     252WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list< Statement * > & initialization, bool isDoWhile ):
    253253        Statement(), condition( condition), body( body ), else_( else_ ), initialization( initialization ), isDoWhile( isDoWhile) {
    254254}
  • src/SynTree/Statement.h

    rff3b0249 r4e7171f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 17:07:32 2022
    13 // Update Count     : 93
     12// Last Modified On : Wed Feb  2 11:49:17 2022
     13// Update Count     : 94
    1414//
    1515
     
    233233        bool isDoWhile;
    234234
    235         WhileDoStmt( Expression * condition, Statement * body, std::list<Statement *> & initialization, bool isDoWhile = false );
    236         WhileDoStmt( Expression * condition, Statement * body, Statement * els, std::list<Statement *> & initialization, bool isDoWhile = false );
     235        WhileDoStmt( Expression * condition, Statement * body, const std::list<Statement *> & initialization, bool isDoWhile = false );
     236        WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list<Statement *> & initialization, bool isDoWhile = false );
    237237        WhileDoStmt( const WhileDoStmt & other );
    238238        virtual ~WhileDoStmt();
Note: See TracChangeset for help on using the changeset viewer.