Changeset 85521c7 for src/SynTree
- Timestamp:
- Feb 1, 2018, 5:40:01 PM (8 years ago)
- 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, stuck-waitfor-destruct, with_gc
- Children:
- 0188a0bc
- Parents:
- d0a045c7 (diff), 33c0ce8 (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. - Location:
- src/SynTree
- Files:
-
- 4 edited
-
Declaration.h (modified) (1 diff)
-
Expression.cc (modified) (2 diffs)
-
Expression.h (modified) (1 diff)
-
FunctionDecl.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
rd0a045c7 r85521c7 151 151 FunctionType *type; 152 152 CompoundStmt *statements; 153 std::list< Expression * > withExprs; 153 154 154 155 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, -
src/SynTree/Expression.cc
rd0a045c7 r85521c7 597 597 598 598 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) { 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 } 599 computeResult(); 610 600 } 611 601 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) { … … 617 607 deleteAll( dtors ); 618 608 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 ( ! returnDecls.empty() ) { 616 // prioritize return decl for result type, since if a return decl exists, then 617 // the StmtExpr is currently in an intermediate state where the body will always 618 // give a void result type. 619 result = returnDecls.front()->get_type()->clone(); 620 } else if ( ! body.empty() ) { 621 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 622 result = maybeClone( exprStmt->expr->result ); 623 } 624 } 625 // ensure that StmtExpr has a result type 626 if ( ! result ) { 627 result = new VoidType( Type::Qualifiers() ); 628 } 619 629 } 620 630 void StmtExpr::print( std::ostream &os, Indenter indent ) const { -
src/SynTree/Expression.h
rd0a045c7 r85521c7 728 728 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 729 729 730 // call to set the result type of this StmtExpr based on its body 731 void computeResult(); 732 730 733 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 731 734 std::list< Expression * > & get_dtors() { return dtors; } -
src/SynTree/FunctionDecl.cc
rd0a045c7 r85521c7 51 51 VarExprReplacer::replace( this, declMap ); 52 52 } 53 cloneAll( other.withExprs, withExprs ); 53 54 } 54 55 … … 56 57 delete type; 57 58 delete statements; 59 deleteAll( withExprs ); 58 60 } 59 61
Note:
See TracChangeset
for help on using the changeset viewer.