Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rba3706f r61255ad  
    3232using std::endl;
    3333
    34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
     34Statement::Statement( std::list<Label> labels ) : labels( labels ) {}
    3535
    3636void Statement::print( std::ostream & os, Indenter ) const {
     
    4646Statement::~Statement() {}
    4747
    48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
     48ExprStmt::ExprStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {}
    4949
    5050ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    6060
    6161
    62 AsmStmt::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 ) {}
     62AsmStmt::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 ) {}
    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( Label target, Type type ) throw ( SemanticError ) :
    99         Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
     98BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) :
     99        Statement( labels ), 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( Expression *computedTarget, Type type ) throw ( SemanticError ) :
    107         Statement(), computedTarget( computedTarget ), type( type ) {
     106BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) :
     107        Statement( labels ), 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( Expression *expr ) : Statement(), expr( expr ) {}
     120ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {}
    121121
    122122ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    135135}
    136136
    137 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
    138         Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
     137IfStmt::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 ) {}
    139139
    140140IfStmt::IfStmt( const IfStmt & other ) :
     
    176176}
    177177
    178 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):
    179         Statement(), condition( condition ), statements( statements ) {
     178SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, const std::list<Statement *> &statements ):
     179        Statement( labels ), condition( condition ), statements( statements ) {
    180180}
    181181
     
    201201}
    202202
    203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    204         Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
     203CaseStmt::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 ) {
    205205        if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
    206206}
     
    216216}
    217217
    218 CaseStmt * 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;
     218CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {
     219        return new CaseStmt( labels, 0, stmts, true );
    222220}
    223221
     
    235233}
    236234
    237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):
    238         Statement(), condition( condition), body( body), isDoWhile( isDoWhile) {
     235WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition, Statement *body, bool isDoWhile ):
     236        Statement( labels ), condition( condition), body( body), isDoWhile( isDoWhile) {
    239237}
    240238
     
    257255}
    258256
    259 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
    260         Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
     257ForStmt::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 ) {
    261259}
    262260
     
    304302}
    305303
    306 ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) :
    307                 Statement(), kind(kind), expr(expr), target(target)     {
     304ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) :
     305                Statement( labels ), kind(kind), expr(expr), target(target)     {
    308306        assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." );
    309307}
     
    328326}
    329327
    330 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
    331         Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
     328TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
     329        Statement( labels ), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    332330}
    333331
     
    361359}
    362360
    363 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
    364         Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
     361CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
     362        Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
    365363                assertf( decl, "Catch clause must have a declaration." );
    366364}
     
    393391
    394392
    395 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) {
     393FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *block ) : Statement( labels ), block( block ) {
     394        assert( labels.empty() ); // finally statement cannot be labeled
    396395}
    397396
     
    409408}
    410409
    411 WaitForStmt::WaitForStmt() : Statement() {
     410WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) {
    412411        timeout.time      = nullptr;
    413412        timeout.statement = nullptr;
     
    456455}
    457456
    458 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) {
    459 }
     457
     458WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Statement( std::list<Label>() ), exprs( exprs ), stmt( stmt ) {}
     459WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
     460        cloneAll( other.exprs, exprs );
     461}
     462WithStmt::~WithStmt() {
     463        deleteAll( exprs );
     464        delete stmt;
     465}
     466
     467void WithStmt::print( std::ostream & os, Indenter indent ) const {
     468        os << "With statement" << endl;
     469        os << indent << "... with statement:" << endl << indent+1;
     470        stmt->print( os, indent+1 );
     471}
     472
     473
     474NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {}
     475NullStmt::NullStmt() : Statement( std::list<Label>() ) {}
    460476
    461477void NullStmt::print( std::ostream &os, Indenter ) const {
     
    463479}
    464480
    465 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement(), callStmt( callStmt ) {
     481ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>() ), callStmt( callStmt ) {
    466482        assert( callStmt );
    467483}
Note: See TracChangeset for help on using the changeset viewer.