Changeset ba3706f for src/SynTree


Ignore:
Timestamp:
Nov 30, 2017, 4:43:59 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
c50d54d
Parents:
4429b04
Message:

Remove label lists from various Statement constructors

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/CompoundStmt.cc

    r4429b04 rba3706f  
    2828using std::endl;
    2929
    30 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) {
     30CompoundStmt::CompoundStmt() : Statement() {
    3131}
    3232
    33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement( noLabels ), kids( stmts ) {
     33CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement(), kids( stmts ) {
    3434}
    3535
  • src/SynTree/DeclStmt.cc

    r4429b04 rba3706f  
    2323#include "SynTree/Label.h"   // for Label
    2424
    25 DeclStmt::DeclStmt( std::list<Label> labels, Declaration *decl ) : Statement( labels ), decl( decl ) {
     25DeclStmt::DeclStmt( Declaration *decl ) : Statement(), decl( decl ) {
    2626}
    2727
  • src/SynTree/Statement.cc

    r4429b04 rba3706f  
    3232using std::endl;
    3333
    34 Statement::Statement( std::list<Label> labels ) : labels( labels ) {}
     34Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    3636void Statement::print( std::ostream & os, Indenter ) const {
     
    4646Statement::~Statement() {}
    4747
    48 ExprStmt::ExprStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {}
     48ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
    4949
    5050ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    6060
    6161
    62 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
     62AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
    6363
    6464AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {
     
    9696const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    9797
    98 BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) :
    99         Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
     98BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) :
     99        Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
    100100        //actually this is a syntactic error signaled by the parser
    101101        if ( type == BranchStmt::Goto && target.empty() ) {
     
    104104}
    105105
    106 BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) :
    107         Statement( labels ), computedTarget( computedTarget ), type( type ) {
     106BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) :
     107        Statement(), computedTarget( computedTarget ), type( type ) {
    108108        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    109109                throw SemanticError("Computed target not valid in branch statement");
     
    118118}
    119119
    120 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {}
     120ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {}
    121121
    122122ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    135135}
    136136
    137 IfStmt::IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
    138         Statement( labels ), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
     137IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
     138        Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
    139139
    140140IfStmt::IfStmt( const IfStmt & other ) :
     
    176176}
    177177
    178 SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, const std::list<Statement *> &statements ):
    179         Statement( labels ), condition( condition ), statements( statements ) {
     178SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):
     179        Statement(), condition( condition ), statements( statements ) {
    180180}
    181181
     
    201201}
    202202
    203 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    204         Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) {
     203CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
     204        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    205205        if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
    206206}
     
    216216}
    217217
    218 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {
    219         return new CaseStmt( labels, 0, stmts, true );
     218CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) {
     219        CaseStmt * stmt = new CaseStmt( nullptr, stmts, true );
     220        stmt->labels = labels;
     221        return stmt;
    220222}
    221223
     
    233235}
    234236
    235 WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition, Statement *body, bool isDoWhile ):
    236         Statement( labels ), condition( condition), body( body), isDoWhile( isDoWhile) {
     237WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):
     238        Statement(), condition( condition), body( body), isDoWhile( isDoWhile) {
    237239}
    238240
     
    255257}
    256258
    257 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
    258         Statement( labels ), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
     259ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
     260        Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
    259261}
    260262
     
    302304}
    303305
    304 ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) :
    305                 Statement( labels ), kind(kind), expr(expr), target(target)     {
     306ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) :
     307                Statement(), kind(kind), expr(expr), target(target)     {
    306308        assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." );
    307309}
     
    326328}
    327329
    328 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
    329         Statement( labels ), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
     330TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
     331        Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    330332}
    331333
     
    359361}
    360362
    361 CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
    362         Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
     363CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
     364        Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
    363365                assertf( decl, "Catch clause must have a declaration." );
    364366}
     
    391393
    392394
    393 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *block ) : Statement( labels ), block( block ) {
    394         assert( labels.empty() ); // finally statement cannot be labeled
     395FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) {
    395396}
    396397
     
    408409}
    409410
    410 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) {
     411WaitForStmt::WaitForStmt() : Statement() {
    411412        timeout.time      = nullptr;
    412413        timeout.statement = nullptr;
     
    455456}
    456457
    457 NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {}
    458 NullStmt::NullStmt() : Statement( std::list<Label>() ) {}
     458NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) {
     459}
    459460
    460461void NullStmt::print( std::ostream &os, Indenter ) const {
     
    462463}
    463464
    464 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>() ), callStmt( callStmt ) {
     465ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement(), callStmt( callStmt ) {
    465466        assert( callStmt );
    466467}
  • src/SynTree/Statement.h

    r4429b04 rba3706f  
    3737        std::list<Label> labels;
    3838
    39         Statement( std::list<Label> labels );
     39        Statement( const std::list<Label> & labels = {} );
    4040        virtual ~Statement();
    4141
     
    5353        std::list<Statement*> kids;
    5454
    55         CompoundStmt( std::list<Label> labels );
     55        CompoundStmt();
    5656        CompoundStmt( std::list<Statement *> stmts );
    5757        CompoundStmt( const CompoundStmt &other );
     
    7070class NullStmt : public Statement {
    7171  public:
    72         NullStmt();
    73         NullStmt( std::list<Label> labels );
     72        NullStmt( const std::list<Label> & labels = {} );
    7473
    7574        virtual NullStmt *clone() const override { return new NullStmt( *this ); }
     
    8382        Expression *expr;
    8483
    85         ExprStmt( std::list<Label> labels, Expression *expr );
     84        ExprStmt( Expression *expr );
    8685        ExprStmt( const ExprStmt &other );
    8786        virtual ~ExprStmt();
     
    104103        std::list<Label> gotolabels;
    105104
    106         AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
     105        AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    107106        AsmStmt( const AsmStmt &other );
    108107        virtual ~AsmStmt();
     
    134133        std::list<Statement *> initialization;
    135134
    136         IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart,
     135        IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart,
    137136                        std::list<Statement *> initialization = std::list<Statement *>() );
    138137        IfStmt( const IfStmt &other );
     
    158157        std::list<Statement *> statements;
    159158
    160         SwitchStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements );
     159        SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
    161160        SwitchStmt( const SwitchStmt &other );
    162161        virtual ~SwitchStmt();
     
    180179        std::list<Statement *> stmts;
    181180
    182         CaseStmt( std::list<Label> labels, Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     181        CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    183182        CaseStmt( const CaseStmt &other );
    184183        virtual ~CaseStmt();
    185184
    186         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
     185        static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
    187186
    188187        bool isDefault() const { return _isDefault; }
     
    210209        bool isDoWhile;
    211210
    212         WhileStmt( std::list<Label> labels, Expression *condition,
     211        WhileStmt( Expression *condition,
    213212               Statement *body, bool isDoWhile = false );
    214213        WhileStmt( const WhileStmt &other );
     
    235234        Statement *body;
    236235
    237         ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
     236        ForStmt( std::list<Statement *> initialization,
    238237             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
    239238        ForStmt( const ForStmt &other );
     
    264263        Type type;
    265264
    266         BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    267         BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
     265        BranchStmt( Label target, Type ) throw (SemanticError);
     266        BranchStmt( Expression *computedTarget, Type ) throw (SemanticError);
    268267
    269268        Label get_originalTarget() { return originalTarget; }
     
    289288        Expression *expr;
    290289
    291         ReturnStmt( std::list<Label> labels, Expression *expr );
     290        ReturnStmt( Expression *expr );
    292291        ReturnStmt( const ReturnStmt &other );
    293292        virtual ~ReturnStmt();
     
    310309        Expression * target;
    311310
    312         ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     311        ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
    313312        ThrowStmt( const ThrowStmt &other );
    314313        virtual ~ThrowStmt();
     
    332331        FinallyStmt * finallyBlock;
    333332
    334         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
     333        TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    335334        TryStmt( const TryStmt &other );
    336335        virtual ~TryStmt();
     
    358357        Statement *body;
    359358
    360         CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     359        CatchStmt( Kind kind, Declaration *decl,
    361360                   Expression *cond, Statement *body );
    362361        CatchStmt( const CatchStmt &other );
     
    381380        CompoundStmt *block;
    382381
    383         FinallyStmt( std::list<Label> labels, CompoundStmt *block );
     382        FinallyStmt( CompoundStmt *block );
    384383        FinallyStmt( const FinallyStmt &other );
    385384        virtual ~FinallyStmt();
     
    408407        };
    409408
    410         WaitForStmt( std::list<Label> labels = noLabels );
     409        WaitForStmt();
    411410        WaitForStmt( const WaitForStmt & );
    412411        virtual ~WaitForStmt();
     
    438437        Declaration *decl;
    439438
    440         DeclStmt( std::list<Label> labels, Declaration *decl );
     439        DeclStmt( Declaration *decl );
    441440        DeclStmt( const DeclStmt &other );
    442441        virtual ~DeclStmt();
  • src/SynTree/TupleExpr.cc

    r4429b04 rba3706f  
    2323#include "Declaration.h"        // for ObjectDecl
    2424#include "Expression.h"         // for Expression, TupleExpr, TupleIndexExpr
    25 #include "SynTree/Label.h"      // for Label, noLabels
     25#include "SynTree/Label.h"      // for Label
    2626#include "SynTree/Statement.h"  // for CompoundStmt, DeclStmt, ExprStmt, Sta...
    2727#include "Tuples/Tuples.h"      // for makeTupleType
     
    8989        // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments
    9090        set_result( Tuples::makeTupleType( assigns ) );
    91         CompoundStmt * compoundStmt = new CompoundStmt( noLabels );
     91        CompoundStmt * compoundStmt = new CompoundStmt();
    9292        std::list< Statement * > & stmts = compoundStmt->get_kids();
    9393        for ( ObjectDecl * obj : tempDecls ) {
    94                 stmts.push_back( new DeclStmt( noLabels, obj ) );
     94                stmts.push_back( new DeclStmt( obj ) );
    9595        }
    9696        TupleExpr * tupleExpr = new TupleExpr( assigns );
    9797        assert( tupleExpr->get_result() );
    98         stmts.push_back( new ExprStmt( noLabels, tupleExpr ) );
     98        stmts.push_back( new ExprStmt( tupleExpr ) );
    9999        stmtExpr = new StmtExpr( compoundStmt );
    100100}
Note: See TracChangeset for help on using the changeset viewer.