Index: translator/Tuples/TupleAssignment.cc
===================================================================
--- translator/Tuples/TupleAssignment.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/Tuples/TupleAssignment.cc	(revision a32b204359041ff1f6ef505a929495bcfe7a54f3)
@@ -19,6 +19,6 @@
   bool TupleAssignSpotter::pointsToTuple( Expression *expr ) {
     // also check for function returning tuple of reference types
-    if(AddressExpr *addr = dynamic_cast<AddressExpr *>(expr) )
-      if( isTuple(addr->get_arg() ) )
+    if (AddressExpr *addr = dynamic_cast<AddressExpr *>(expr) )
+      if ( isTuple(addr->get_arg() ) )
 	return true;
     return false;
@@ -26,5 +26,5 @@
 
   bool TupleAssignSpotter::isTupleVar( DeclarationWithType *decl ) {
-    if( dynamic_cast<TupleType *>(decl->get_type()) )
+    if ( dynamic_cast<TupleType *>(decl->get_type()) )
       return true;
     return false;
@@ -33,10 +33,10 @@
   bool TupleAssignSpotter::isTuple( Expression *expr, bool isRight ) {
     // true if `expr' is an expression returning a tuple: tuple, tuple variable or MRV function
-    if ( !expr ) return false;
-
-    if( dynamic_cast<TupleExpr *>(expr) )
-      return true;
-    else if( VariableExpr *var = dynamic_cast<VariableExpr *>(expr) ) {
-      if( isTupleVar(var->get_var()) )
+    if ( ! expr ) return false;
+
+    if ( dynamic_cast<TupleExpr *>(expr) )
+      return true;
+    else if ( VariableExpr *var = dynamic_cast<VariableExpr *>(expr) ) {
+      if ( isTupleVar(var->get_var()) )
 	return true;
     }
@@ -52,7 +52,7 @@
       return false;
 
-    if( new_assigns.empty() ) return false;
+    if ( new_assigns.empty() ) return false;
     /*return */matcher->solve( new_assigns );
-    if( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
+    if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
       // now resolve new assignments
       std::list< Expression * > solved_assigns;
@@ -61,5 +61,5 @@
 
       ResolvExpr::AltList current;
-      for( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
+      for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
 	//try {
 	ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
@@ -80,5 +80,5 @@
       return true;
     } else { // mass assignment
-      //if( new_assigns.empty() ) return false;
+      //if ( new_assigns.empty() ) return false;
       std::list< Expression * > solved_assigns;
       ResolvExpr::AltList solved_alts;
@@ -87,9 +87,9 @@
       ResolvExpr::AltList current;
       if ( optMass.empty() ) {
-	for( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
+	for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
 	  optMass.push_back( ResolvExpr::AltList() );
       }
       int cnt = 0;
-      for( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
+      for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
 
 	ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
@@ -110,5 +110,5 @@
 
   bool TupleAssignSpotter::isMVR( Expression *expr ) {
-    if( expr->get_results().size() > 1 ) {
+    if ( expr->get_results().size() > 1 ) {
       // MVR processing
       return true;
@@ -118,17 +118,17 @@
 
   bool TupleAssignSpotter::isTupleAssignment( UntypedExpr * expr, std::list<ResolvExpr::AltList> &possibilities ) {
-    if(  NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) {
-
-      if( assgnop->get_name() == std::string("?=?") ) {
-
-	for( std::list<ResolvExpr::AltList>::iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
+    if (  NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) {
+
+      if ( assgnop->get_name() == std::string("?=?") ) {
+
+	for ( std::list<ResolvExpr::AltList>::iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
 	  assert( ali->size() == 2 );
 	  ResolvExpr::AltList::iterator opit = ali->begin();
 	  ResolvExpr::Alternative op1 = *opit, op2 = *(++opit);
 
-	  if( pointsToTuple(op1.expr) ) { // also handles tuple vars
+	  if ( pointsToTuple(op1.expr) ) { // also handles tuple vars
 	    if ( isTuple( op2.expr, true ) )
 	      matcher = new MultipleAssignMatcher(op1.expr, op2.expr);
-	    else if( isMVR( op2.expr ) ) {
+	    else if ( isMVR( op2.expr ) ) {
 	      // handle MVR differently
 	    } else
@@ -137,7 +137,7 @@
 
 	    std::list< ResolvExpr::AltList > options;
-	    if( match() )
+	    if ( match() )
 	      /*
-	      if( hasMatched ) {
+	      if ( hasMatched ) {
 		// throw SemanticError("Ambiguous tuple assignment");
 	      } else {*/
@@ -150,11 +150,11 @@
 	}
 
-	if( hasMatched ) {
-	  if( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
+	if ( hasMatched ) {
+	  if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) {
 	    //options.print( std::cerr );
 	    std::list< ResolvExpr::AltList >best = options.get_best();
-	    if( best.size() == 1 ) {
+	    if ( best.size() == 1 ) {
 	      std::list<Expression *> solved_assigns;
-	      for( ResolvExpr::AltList::iterator i = best.front().begin(); i != best.front().end(); ++i ){
+	      for ( ResolvExpr::AltList::iterator i = best.front().begin(); i != best.front().end(); ++i ){
 		solved_assigns.push_back( i->expr );
 	      }
@@ -165,9 +165,9 @@
 	    assert(! optMass.empty() );
 	    ResolvExpr::AltList winners;
-	    for( std::vector< ResolvExpr::AltList >::iterator i = optMass.begin(); i != optMass.end(); ++i )
+	    for ( std::vector< ResolvExpr::AltList >::iterator i = optMass.begin(); i != optMass.end(); ++i )
 	      findMinCostAlt( i->begin(), i->end(), back_inserter(winners) );
 
 	    std::list< Expression *> solved_assigns;
-	    for( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i )
+	    for ( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i )
 	      solved_assigns.push_back( i->expr );
 	    currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MASS*/), currentFinder->get_environ(), ResolvExpr::Cost() ) );
@@ -181,6 +181,6 @@
   void TupleAssignSpotter::Matcher::init( Expression *_lhs, Expression *_rhs ) {
     lhs.clear();
-    if(AddressExpr *addr = dynamic_cast<AddressExpr *>(_lhs) )
-      if( TupleExpr *tuple = dynamic_cast<TupleExpr *>(addr->get_arg()) )
+    if (AddressExpr *addr = dynamic_cast<AddressExpr *>(_lhs) )
+      if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(addr->get_arg()) )
 	std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(lhs) );
 
@@ -195,5 +195,5 @@
     init(_lhs,_rhs);
 
-    if( TupleExpr *tuple = dynamic_cast<TupleExpr *>(_rhs) )
+    if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(_rhs) )
       std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(rhs) );
   }
@@ -211,5 +211,5 @@
     if ( lhs.empty() || (rhs.size() != 1) ) return false;
 
-    for( std::list< Expression * >::iterator l = lhs.begin(); l != lhs.end(); l++ ) {
+    for ( std::list< Expression * >::iterator l = lhs.begin(); l != lhs.end(); l++ ) {
       std::list< Expression * > args;
       args.push_back( new AddressExpr(*l) );
@@ -229,9 +229,9 @@
     ResolvExpr::AltList current;
     if ( optMass.empty() ) {
-      for( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
+      for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i )
 	optMass.push_back( ResolvExpr::AltList() );
     }
     int cnt = 0;
-    for( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
+    for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) {
 
       ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
@@ -250,5 +250,5 @@
   bool TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) {
     // need more complicated matching
-    if( lhs.size() == rhs.size() ) {
+    if ( lhs.size() == rhs.size() ) {
       zipWith( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), back_inserter(out), TupleAssignSpotter::Matcher::createAssgn );
       return true;
@@ -265,5 +265,5 @@
 
     ResolvExpr::AltList current;
-    for( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
+    for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
       //try {
       ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() );
@@ -297,9 +297,9 @@
     // transpose matrix
     if ( costMatrix.empty() )
-      for( unsigned int i = 0; i< opt.size(); ++i)
+      for ( unsigned int i = 0; i< opt.size(); ++i)
 	costMatrix.push_back( vector<ResolvExpr::Cost>() );
 
     int cnt = 0;
-    for( ResolvExpr::AltList::iterator i = opt.begin(); i != opt.end(); ++i, cnt++ )
+    for ( ResolvExpr::AltList::iterator i = opt.begin(); i != opt.end(); ++i, cnt++ )
       costMatrix[cnt].push_back( i->cost );
 
@@ -312,5 +312,5 @@
     list< ResolvExpr::AltList > ret;
     list< multiset<int> > solns;
-    for( vector< vector<Cost> >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
+    for ( vector< vector<Cost> >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
       list<int> current;
       findMinCost( i->begin(), i->end(), back_inserter(current) );
@@ -320,5 +320,5 @@
     multiset<int> result;
     lift_intersection( solns.begin(), solns.end(), inserter( result, result.begin() ) );
-    if( result.size() != 1 )
+    if ( result.size() != 1 )
       throw SemanticError("Ambiguous tuple expression");
     ret.push_back(get_option( *(result.begin() )));
@@ -329,6 +329,6 @@
     using namespace std;
 
-    for( vector< vector < ResolvExpr::Cost > >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
-      for( vector < ResolvExpr::Cost >::iterator j = i->begin(); j != i->end(); ++j )
+    for ( vector< vector < ResolvExpr::Cost > >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) {
+      for ( vector < ResolvExpr::Cost >::iterator j = i->begin(); j != i->end(); ++j )
 	ostr << *j << " " ;
       ostr << std::endl;
@@ -352,10 +352,10 @@
     Cost minCost = Cost::infinity;
     unsigned int index = 0;
-    for( InputIterator i = begin; i != end; ++i, index++ ) {
-      if( *i < minCost ) {
+    for ( InputIterator i = begin; i != end; ++i, index++ ) {
+      if ( *i < minCost ) {
         minCost = *i;
         alternatives.clear();
         alternatives.push_back( index );
-      } else if( *i == minCost ) {
+      } else if ( *i == minCost ) {
         alternatives.push_back( index );
       }
@@ -366,8 +366,8 @@
   template< class InputIterator, class OutputIterator >
   void TupleAssignSpotter::Options::lift_intersection( InputIterator begin, InputIterator end, OutputIterator out ){
-    if( begin == end ) return;
+    if ( begin == end ) return;
     InputIterator test = begin;
 
-    if(++test == end)
+    if (++test == end)
       { copy(begin->begin(), begin->end(), out); return; }
 
@@ -376,5 +376,5 @@
     copy( begin->begin(), begin->end(), inserter( cur, cur.begin() ) );
 
-    while( test != end ) {
+    while ( test != end ) {
       std::multiset<int> temp;
       set_intersection( cur.begin(), cur.end(), test->begin(), test->end(), inserter(temp,temp.begin()) );
@@ -390,8 +390,8 @@
 
   ResolvExpr::AltList TupleAssignSpotter::Options::get_option( std::list< ResolvExpr::AltList >::size_type index ) {
-    if( index >= options.size() )
+    if ( index >= options.size() )
       throw 0; // XXX
     std::list< ResolvExpr::AltList >::iterator it = options.begin();
-    for( std::list< ResolvExpr::AltList >::size_type i = 0; i < index; ++i, ++it );
+    for ( std::list< ResolvExpr::AltList >::size_type i = 0; i < index; ++i, ++it );
     return *it;
   }
