Changes in src/SynTree/Expression.cc [5e2c348:0690350]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r5e2c348 r0690350 597 597 598 598 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) { 599 computeResult(); 599 assert( statements ); 600 std::list< Statement * > & body = statements->get_kids(); 601 if ( ! body.empty() ) { 602 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 603 result = maybeClone( exprStmt->expr->result ); 604 } 605 } 606 // ensure that StmtExpr has a result type 607 if ( ! result ) { 608 result = new VoidType( Type::Qualifiers() ); 609 } 600 610 } 601 611 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) { … … 607 617 deleteAll( dtors ); 608 618 deleteAll( returnDecls ); 609 }610 void StmtExpr::computeResult() {611 assert( statements );612 std::list< Statement * > & body = statements->kids;613 delete result;614 result = nullptr;615 if ( ! body.empty() ) {616 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {617 result = maybeClone( exprStmt->expr->result );618 }619 }620 // ensure that StmtExpr has a result type621 if ( ! result ) {622 result = new VoidType( Type::Qualifiers() );623 }624 619 } 625 620 void StmtExpr::print( std::ostream &os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.