Changeset a32b204 for translator/Tuples/FunctionChecker.cc
- Timestamp:
- May 17, 2015, 1:19:35 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0dd3a2f
- Parents:
- b87a5ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/Tuples/FunctionChecker.cc
rb87a5ed ra32b204 23 23 24 24 FunctionChecker::FunctionChecker( bool _topLevel, UniqueName *_nameGen ) : topLevel( _topLevel ), nameGen( _nameGen ) { 25 if ( topLevel) {26 assert( ! nameGen );25 if ( topLevel) { 26 assert( ! nameGen ); 27 27 nameGen = new UniqueName("_MVR_"); 28 28 } else … … 31 31 32 32 FunctionChecker::~FunctionChecker() { 33 if ( topLevel) {33 if ( topLevel) { 34 34 delete nameGen; 35 35 nameGen = 0; … … 39 39 Statement* FunctionChecker::mutate(ExprStmt *exprStmt) { 40 40 exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) ); 41 if ( ! tempExpr.empty() ) {42 assert ( ! temporaries.empty() );41 if ( ! tempExpr.empty() ) { 42 assert ( ! temporaries.empty() ); 43 43 CompoundStmt *newBlock = new CompoundStmt( std::list< Label >() ); 44 44 // declarations 45 for ( std::list< ObjectDecl *>::iterator d = temporaries.begin(); d != temporaries.end(); ++d )45 for ( std::list< ObjectDecl *>::iterator d = temporaries.begin(); d != temporaries.end(); ++d ) 46 46 newBlock->get_kids().push_back( new DeclStmt( std::list<Label>(), *d ) ); 47 47 // new expression statements 48 for ( std::list< Expression *>::iterator e = tempExpr.begin(); e != tempExpr.end(); ++e )48 for ( std::list< Expression *>::iterator e = tempExpr.begin(); e != tempExpr.end(); ++e ) 49 49 newBlock->get_kids().push_back( new ExprStmt( std::list<Label>(), *e ) ); 50 50 … … 69 69 70 70 std::list< Expression * > newArgs; 71 for ( std::list< Expression *>::iterator e = applicationExpr->get_args().begin(); e != applicationExpr->get_args().end(); ++e ) {71 for ( std::list< Expression *>::iterator e = applicationExpr->get_args().begin(); e != applicationExpr->get_args().end(); ++e ) { 72 72 FunctionChecker rec( false, nameGen ); 73 73 (*e)->acceptMutator( rec ); 74 74 75 if ( ! rec.temporaries.empty() ) {75 if ( ! rec.temporaries.empty() ) { 76 76 TupleExpr *lhs = new TupleExpr; 77 77 std::list< Expression * > &tmem = lhs->get_exprs(); 78 for ( std::list<ObjectDecl *>::iterator d = rec.temporaries.begin(); d != rec.temporaries.end(); ++d ) {78 for ( std::list<ObjectDecl *>::iterator d = rec.temporaries.begin(); d != rec.temporaries.end(); ++d ) { 79 79 tmem.push_back( new VariableExpr( *d ) ); 80 80 newArgs.push_back( new VariableExpr( *d ) ); … … 100 100 101 101 Expression* TupleDistrib::mutate(UntypedExpr *expr) { 102 if ( NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) {103 if ( assgnop->get_name() == std::string("?=?") ) {102 if ( NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) { 103 if ( assgnop->get_name() == std::string("?=?") ) { 104 104 std::list<Expression *> &args = expr->get_args(); 105 105 assert(args.size() == 2); 106 106 //if args.front() points to a tuple and if args.back() is already resolved 107 if ( AddressExpr *addr = dynamic_cast<AddressExpr *>(args.front()) )108 if ( TupleExpr *lhs = dynamic_cast<TupleExpr *>(addr->get_arg()) )109 if ( ApplicationExpr *rhs = dynamic_cast<ApplicationExpr *>( args.back() ) ) {107 if ( AddressExpr *addr = dynamic_cast<AddressExpr *>(args.front()) ) 108 if ( TupleExpr *lhs = dynamic_cast<TupleExpr *>(addr->get_arg()) ) 109 if ( ApplicationExpr *rhs = dynamic_cast<ApplicationExpr *>( args.back() ) ) { 110 110 for ( std::list<Expression *>::iterator tc = lhs->get_exprs().begin(); tc != lhs->get_exprs().end(); ++tc ) 111 111 rhs->get_args().push_back( new AddressExpr( *tc ) );
Note: See TracChangeset
for help on using the changeset viewer.