From 4a11df0a5938faf6312f208aa1d1cfc0cb6ad6ed Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Fri, 6 Feb 2009 16:53:59 +0100
Subject: [PATCH] fixing the ec backend (cont):  unfold operators on tuples.

i.e., transform

      x,y = (0,1) -> (a,b);

into

      x = 0 -> a;
      y = 1 -> b;
---
 src/structArrayExpand.ml | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/structArrayExpand.ml b/src/structArrayExpand.ml
index 8ed8894c..f78b2113 100644
--- a/src/structArrayExpand.ml
+++ b/src/structArrayExpand.ml
@@ -290,13 +290,27 @@ and (break_tuple : Lxm.t -> left list -> val_exp -> Eff.eq_info srcflagged list)
     if not !Global.ec then
       [{ src = lxm ; it = (left_list, ve) }] 
     else
-      (* we only need to break tuple in this mode ...
+      (* we only need to break tuples in this mode ...
 	 Note that this work only if the node expansion has already been done!
+	 (otherwise, we would not have the same number of items in the left and 
+	 in the rigth part)
       *)
       let rec aux ve = (* flatten val exp*)
 	match ve with 
-	  | CallByPosEff ({it=TUPLE}, OperEff vel) -> List.flatten (List.map aux vel)
-	  | _  -> [ve]
+	  | CallByPosEff ({it= TUPLE}, OperEff vel) -> List.flatten (List.map aux vel)
+	  | CallByPosEff (unop, OperEff [ve1]) ->
+	      let ve1l = aux ve1 in
+		List.map
+		  (fun ve1 -> CallByPosEff (unop, OperEff [ve1])) 
+		  ve1l 
+	  | CallByPosEff (binop, OperEff [ve1;ve2]) ->
+	      let ve1l, ve2l = aux ve1, aux ve2 in
+		List.map2 
+		  (fun ve1 ve2 -> CallByPosEff (binop, OperEff [ve1;ve2])) 
+		  ve1l 
+		  ve2l
+
+	  |  _ -> [ve]
       in
       let vel = aux ve in
 	if (List.length vel <> List.length left_list) then
-- 
GitLab