Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b7c89aa
Parents:
f9feab8 (diff), 305581d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rf9feab8 r90152a4  
    3434Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    36 void Statement::print( std::ostream & os, Indenter ) const {
     36void Statement::print( std::ostream & os, Indenter indent ) const {
    3737        if ( ! labels.empty() ) {
    38                 os << "Labels: {";
     38                os << indent << "... Labels: {";
    3939                for ( const Label & l : labels ) {
    4040                        os << l << ",";
     
    9494
    9595
     96DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
     97
     98void DirectiveStmt::print( std::ostream &os, Indenter ) const {
     99        os << "GCC Directive:" << directive << endl;
     100}
     101
     102
    96103const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    97104
    98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) :
     105BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
    99106        Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
    100107        //actually this is a syntactic error signaled by the parser
    101108        if ( type == BranchStmt::Goto && target.empty() ) {
    102                 throw SemanticError("goto without target");
    103         }
    104 }
    105 
    106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) :
     109                SemanticError( target.get_statement()->location, "goto without target");
     110        }
     111}
     112
     113BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) :
    107114        Statement(), computedTarget( computedTarget ), type( type ) {
    108115        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    109                 throw SemanticError("Computed target not valid in branch statement");
     116                SemanticError( computedTarget->location, "Computed target not valid in branch statement");
    110117        }
    111118}
     
    201208}
    202209
    203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
     210CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :
    204211        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    205         if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
     212        if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " );
    206213}
    207214
     
    223230
    224231void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    225         if ( isDefault() ) os << "Default ";
     232        if ( isDefault() ) os << indent << "Default ";
    226233        else {
    227                 os << "Case ";
     234                os << indent << "Case ";
    228235                condition->print( os, indent );
    229236        } // if
     
    231238
    232239        for ( Statement * stmt : stmts ) {
     240                os << indent+1;
    233241                stmt->print( os, indent+1 );
    234242        }
    235243}
    236244
    237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):
    238         Statement(), condition( condition), body( body), isDoWhile( isDoWhile) {
     245WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
     246        Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
    239247}
    240248
     
    452460void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    453461        os << "Waitfor Statement" << endl;
    454         os << indent << "... with block:" << endl << indent+1;
    455         // block->print( os, indent + 4 );
     462        indent += 1;
     463        for( auto & clause : clauses ) {
     464                os << indent << "target function :";
     465                if(clause.target.function) { clause.target.function->print(os, indent + 1); }
     466                os << endl << indent << "with arguments :" << endl;
     467                for( auto & thing : clause.target.arguments) {
     468                        if(thing) { thing->print(os, indent + 1); }
     469                }
     470                os << indent << " with statment :" << endl;
     471                if(clause.statement) { clause.statement->print(os, indent + 1); }
     472
     473                os << indent << " with condition :" << endl;
     474                if(clause.condition) { clause.condition->print(os, indent + 1); }
     475        }
     476
     477        os << indent << " timeout of :" << endl;
     478        if(timeout.time) { timeout.time->print(os, indent + 1); }
     479
     480        os << indent << " with statment :" << endl;
     481        if(timeout.statement) { timeout.statement->print(os, indent + 1); }
     482
     483        os << indent << " with condition :" << endl;
     484        if(timeout.condition) { timeout.condition->print(os, indent + 1); }
     485
     486
     487        os << indent << " else :" << endl;
     488        if(orelse.statement) { orelse.statement->print(os, indent + 1); }
     489
     490        os << indent << " with condition :" << endl;
     491        if(orelse.condition) { orelse.condition->print(os, indent + 1); }
    456492}
    457493
     
    468504void WithStmt::print( std::ostream & os, Indenter indent ) const {
    469505        os << "With statement" << endl;
     506        os << indent << "... with expressions: " << endl;
     507        printAll( exprs, os, indent+1 );
    470508        os << indent << "... with statement:" << endl << indent+1;
    471509        stmt->print( os, indent+1 );
     
    476514}
    477515
    478 void NullStmt::print( std::ostream &os, Indenter ) const {
     516void NullStmt::print( std::ostream &os, Indenter indent ) const {
    479517        os << "Null Statement" << endl;
     518        Statement::print( os, indent );
    480519}
    481520
Note: See TracChangeset for help on using the changeset viewer.