Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rca78437 rb3c36f4  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 10:37:00 2017
    13 // Update Count     : 64
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Aug 12 13:58:48 2016
     13// Update Count     : 62
    1414//
    1515
     
    101101}
    102102
    103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {}
    104 
    105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     103ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
     104
     105ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
    106106
    107107ReturnStmt::~ReturnStmt() {
     
    110110
    111111void ReturnStmt::print( std::ostream &os, int indent ) const {
    112         os <<  "Return Statement, returning: ";
     112        os << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
    113113        if ( expr != 0 ) {
    114114                os << endl << string( indent+2, ' ' );
     
    287287}
    288288
    289 ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) :
    290                 Statement( labels ), kind(kind), expr(expr), target(target)     {
    291         assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." );
    292 }
    293 
    294 ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
    295         Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    296 }
    297 
    298 ThrowStmt::~ThrowStmt() {
    299         delete expr;
    300         delete target;
    301 }
    302 
    303 void ThrowStmt::print( std::ostream &os, int indent) const {
    304         if ( target ) {
    305                 os << "Non-Local ";
    306         }
    307         os << "Throw Statement, raising: ";
    308         expr->print(os, indent + 4);
    309         if ( target ) {
    310                 os << "At: ";
    311                 target->print(os, indent + 4);
    312         }
    313 }
    314 
    315289TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
    316290        Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock ) {
     
    344318}
    345319
    346 CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) :
    347         Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) {
     320CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :
     321        Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {
    348322}
    349323
    350324CatchStmt::CatchStmt( const CatchStmt & other ) :
    351         Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) {
     325        Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
    352326}
    353327
     
    358332
    359333void CatchStmt::print( std::ostream &os, int indent ) const {
    360         os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
     334        os << "Catch Statement" << endl;
    361335
    362336        os << string( indent, ' ' ) << "... catching" << endl;
     
    364338                decl->printShort( os, indent + 4 );
    365339                os << endl;
    366         }
     340        } else if ( catchRest )
     341                os << string( indent + 4 , ' ' ) << "the rest" << endl;
    367342        else
    368343                os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
Note: See TracChangeset for help on using the changeset viewer.