Changeset 3c13c03 for src/SynTree/TupleExpr.cc
- Timestamp:
- Sep 17, 2016, 8:27:51 AM (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, with_gc
- Children:
- 8c49c0e
- Parents:
- 12bc63a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/TupleExpr.cc
r12bc63a r3c13c03 18 18 #include "Type.h" 19 19 #include "Declaration.h" 20 #include "Tuples/Tuples.h" 20 21 21 TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) { 22 TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) { 23 if ( ! exprs.empty() ) { 24 if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) { 25 set_result( Tuples::makeTupleType( exprs ) ); 26 } 27 } 22 28 } 23 29 … … 36 42 } 37 43 38 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) {44 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index ) { 39 45 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() ); 40 assert( type->size() > =index );41 set_result( *std::next( type->get_types().begin(), index) );46 assert( type->size() > index ); 47 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 42 48 } 43 49 … … 51 57 void TupleIndexExpr::print( std::ostream &os, int indent ) const { 52 58 os << "Tuple Index Expression, with tuple:" << std::endl; 59 os << std::string( indent+2, ' ' ); 53 60 tuple->print( os, indent+2 ); 54 61 os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl; … … 70 77 void MemberTupleExpr::print( std::ostream &os, int indent ) const { 71 78 os << "Member Tuple Expression, with aggregate:" << std::endl; 79 os << std::string( indent+2, ' ' ); 72 80 aggregate->print( os, indent+2 ); 73 81 os << std::string( indent+2, ' ' ) << "with member: " << std::endl; 82 os << std::string( indent+2, ' ' ); 74 83 member->print( os, indent+2 ); 75 84 Expression::print( os, indent ); … … 97 106 98 107 void TupleAssignExpr::print( std::ostream &os, int indent ) const { 99 os << std::string( indent, ' ' ) <<"Tuple Assignment Expression, with temporaries:" << std::endl;108 os << "Tuple Assignment Expression, with temporaries:" << std::endl; 100 109 printAll( tempDecls, os, indent+4 ); 101 110 os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.