From e6d689e4e6beee85f8bad7da508abc86bd1498d3 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Tue, 27 May 2008 11:22:58 +0200
Subject: [PATCH] Add support to be able to iterate on predef op. iter<<iter>>
 does not work yet though (returns the wrong type).

Also add the struct printer, and fix a bug in the static argument printing.
---
 src/TODO                                |  11 --
 src/compiledDataDump.ml                 |  39 ++++---
 src/expandPack.ml                       |  11 +-
 src/getEff.ml                           |  27 ++++-
 src/parser.mly                          |   6 +-
 src/predefSemantics.ml                  |   9 +-
 src/syntaxTreeCore.ml                   |   8 +-
 src/syntaxTreeDump.ml                   |   4 +-
 src/test/should_work/lionel/matrice.lus |   2 +-
 src/test/test.res.exp                   | 142 ++++++++++++++++++------
 10 files changed, 181 insertions(+), 78 deletions(-)

diff --git a/src/TODO b/src/TODO
index 684aa528..5f7e5c5c 100644
--- a/src/TODO
+++ b/src/TODO
@@ -93,8 +93,6 @@ lazycompiler.ml:
 * Evaluer  statiquement  les  iterateurs  quand  c'est  possible  (cf
   evalConst.ml) ?
 
-* autoriser les iterateurs imbriqués ?
-
 * rajouter  la notion  de  variables polymorphes  et sur-chargées  au
   niveau noeud utilisateur  ? Ce devrait etre peanuts  maintenant que
   je les ai en interne...
@@ -118,15 +116,6 @@ lazycompiler.ml:
 *** facile
 
 
-   
-
-* iterateur sur  des operateur  predefinis : ca  ne peut  pas marcher
-  tant que StaticParamNode (cd SyntaxTreeCore.static_param) stocke un
-  Ident.t. il faudrait un long ou un idref.
-  
-node aliasIterOp = red<<Lustre::iplus; SIZE>>;
-
-
 * Verifier que les test de map_red couvre les cas tordus.
 
 * "1..2" ne marche pas car le lexer renvoie 
diff --git a/src/compiledDataDump.ml b/src/compiledDataDump.ml
index b1a62f93..67ff13cb 100644
--- a/src/compiledDataDump.ml
+++ b/src/compiledDataDump.ml
@@ -135,18 +135,20 @@ let rec (string_of_by_pos_op_eff : by_pos_op_eff -> val_exp_eff list -> string)
 	    ") then (" ^ (string_of_val_exp_eff ve2) ^ 
 	    ") else (" ^ (string_of_val_exp_eff ve3) ^ ")"
 
-	| Predef_eff(op,sargs), [ve1; ve2] -> 
-	    if Predef.is_infix op then ("("^
-	      (string_of_val_exp_eff ve1) ^ " " ^ (Predef.op2string op) ^ " " ^
-		(string_of_val_exp_eff ve2) ^ ")"
-	    ) else (
-	      (Predef.op2string op) ^ (tuple vel)
-	     )
-	| Predef_eff(op,sargs), _ -> (Predef.op2string op) ^
-	    (if sargs = [] then "" else 
-	       "<<" ^ (String.concat ", " (List.map static_arg2string sargs))
-	       ^ ">>") ^ (tuple vel)
-
+	| Predef_eff(op,sargs), vel -> 
+	    if Predef.is_infix op then (
+	      match vel with 
+		| [ve1; ve2] -> 
+		    "("^(string_of_val_exp_eff ve1) ^ " " ^ (Predef.op2string op) ^ 
+		      " " ^ (string_of_val_exp_eff ve2) ^ ")"
+		| _ -> assert false
+	    ) 
+	    else 
+	      ((Predef.op2string op) ^
+		 (if sargs = [] then "" else 
+		    "<<" ^ (String.concat ", " (List.map static_arg2string sargs))
+		    ^ ">>") ^ (tuple vel))
+		
 	| CALL_eff nee, _  -> (
 	    string_of_node_key nee.it.node_key_eff) ^ (tuple vel)
 	| IDENT_eff idref, _ -> Ident.string_of_idref idref
@@ -190,7 +192,18 @@ and string_of_val_exp_eff = function
   | CallByPosEff (by_pos_op_eff, OperEff vel) ->
       (string_of_by_pos_op_eff by_pos_op_eff.it vel) 
 
-  | CallByNameEff(by_name_op_eff, l) -> "xxx todo "
+  | CallByNameEff(by_name_op_eff, fl) -> 
+      (match by_name_op_eff.it with
+	 | STRUCT_eff idref -> Ident.string_of_idref idref 
+	 | STRUCT_anonymous_eff -> "") ^
+	"{" ^ (String.concat ";" 
+		 (List.map 
+		    (fun (id,veff) -> 
+		       (Ident.to_string id.it) ^ "=" ^ (string_of_val_exp_eff veff)
+		    )
+		    fl)) ^
+	"}"
+
 
 
 let wrap_long_line str = 
diff --git a/src/expandPack.ml b/src/expandPack.ml
index 165eab65..22176024 100644
--- a/src/expandPack.ml
+++ b/src/expandPack.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 21/05/2008 (at 16:48) by Erwan Jahier> *)
+(** Time-stamp: <modified the 27/05/2008 (at 10:06) by Erwan Jahier> *)
 
 open Lxm
 open SyntaxTree
@@ -79,9 +79,10 @@ let (doit:
 			newdefs := (ConstItem s)::!newdefs
 		  ) 
 		| StaticParamNode (s, inl, outl, has_memory) -> (
-		    let ne = match (a.it) with
-		      | StaticArgIdent idr -> Lxm.flagit ((idr,[])) a.src
-		      | StaticArgNode x -> Lxm.flagit x a.src
+		    let by_pos_op = match (a.it) with
+		      | StaticArgIdent idr -> 
+			  ParserUtils.call_or_predef(Lxm.flagit ((idr,[])) a.src)
+		      | StaticArgNode by_pos_op -> by_pos_op 
 		      | _ -> instance_error () 
 		    in
 		    let sparams = [] in
@@ -89,7 +90,7 @@ let (doit:
 		      name = s;
 		      static_params = sparams;
 		      vars = Some (ParserUtils.build_node_var inl outl None);
-		      def = Alias  (flagit (ParserUtils.call_or_predef ne) ne.src);
+		      def = Alias (flagit by_pos_op a.src);
 		      has_mem = has_memory;
 		      is_safe = true;
 		    } 
diff --git a/src/getEff.ml b/src/getEff.ml
index f4089829..3339e371 100644
--- a/src/getEff.ml
+++ b/src/getEff.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 26/05/2008 (at 15:09) by Erwan Jahier> *)
+(** Time-stamp: <modified the 27/05/2008 (at 10:24) by Erwan Jahier> *)
 
 
 open Lxm
@@ -94,10 +94,21 @@ and (check_static_arg : CompiledData.id_solver ->
 	    let teff = typ node_id_solver te in
 	      TypeStaticArgEff (id, teff)
 
-	| StaticArgNode(ne), StaticParamNode(id,_,_,_) ->
-	    let neff = node node_id_solver {src=sa.src; it=ne } in
+	| StaticArgNode(CALL_n ne), StaticParamNode(id,_,_,_) ->
+	    let neff = node node_id_solver ne in
 	      NodeStaticArgEff (id, neff)
 
+	| StaticArgNode(Predef (op,sargs)), StaticParamNode(id,_,_,_) ->
+	    let sargs_eff = 
+	      translate_predef_static_args node_id_solver sargs sa.src
+	    in
+	    let opeff = PredefSemantics.make_node_exp_eff op sa.src sargs_eff in
+	      NodeStaticArgEff (id, opeff)
+
+	| StaticArgNode(      
+	    (MERGE_n _|ARRAY_SLICE_n _|ARRAY_ACCES_n _|STRUCT_ACCESS_n _|IDENT_n _
+	    |ARRAY_n|HAT_n|CONCAT_n|WITH_n|TUPLE_n|WHEN_n|CURRENT_n|FBY_n
+	    |ARROW_n|PRE_n)), _ -> assert false
 
 	| StaticArgType _, StaticParamNode(id,_,_,_) 
 	| StaticArgType _, StaticParamConst(id,_) 
@@ -117,7 +128,7 @@ and (check_static_arg : CompiledData.id_solver ->
 (******************************************************************************)
 
 (* exported *)
-let rec (eq : id_solver -> eq_info srcflagged -> eq_info_eff srcflagged) =
+and (eq : id_solver -> eq_info srcflagged -> eq_info_eff srcflagged) =
   fun id_solver eq_info -> 
     let (lpl, ve) = eq_info.it in
     let lpl_eff = List.map (translate_left_part id_solver) lpl
@@ -238,7 +249,13 @@ and get_node id_solver node_or_node_ident lxm =
 	let sargs = [] in (* I should do something more clever here to support 
 			     imbricated use of iterators (e.g., "map<<map<<..." *)
 	  id_solver.id2node id sargs lxm 
-    | StaticArgNode(ne)  -> node id_solver {src=lxm; it=ne }
+
+    | StaticArgNode(CALL_n ne) -> node id_solver ne
+    | StaticArgNode(Predef (op,sargs)) ->
+	let sargs_eff = translate_predef_static_args id_solver sargs lxm in
+	  PredefSemantics.make_node_exp_eff op lxm sargs_eff 
+    | StaticArgNode(_) -> assert false
+
     | StaticArgType _ 
     | StaticArgConst _ -> raise (Compile_error(lxm, "a node was expected"))
 
diff --git a/src/parser.mly b/src/parser.mly
index 933577f4..d086fd3e 100644
--- a/src/parser.mly
+++ b/src/parser.mly
@@ -1173,9 +1173,9 @@ sxStaticArgList:
 	| TK_CONST sxExpression
 	    { {src=$1 ; it=StaticArgConst $2 } }
 	| TK_NODE sxEffectiveNode
-	    { {src=$1 ; it=StaticArgNode $2.it } }
+	    { {src=$1 ; it=StaticArgNode (call_or_predef $2) } }
 	| TK_FUNCTION sxEffectiveNode
-	    { {src=$1 ; it=StaticArgNode $2.it } }
+	    { {src=$1 ; it=StaticArgNode (call_or_predef $2) } }
 	  /* un ident OU une expression simple (à résoudre) */
 	  /* c'est au retour qu'on choisit */
 	| sxSimpleExp
@@ -1195,7 +1195,7 @@ sxStaticArgList:
 			{ {src=$1.src; it=StaticArgType $1} }
 		/* un node sans ambiguite */
 	|	sxSurelyNode
-			{ {src=$1.src; it=StaticArgNode $1.it} }
+			{ {src=$1.src; it=StaticArgNode (call_or_predef $1)} }
 ;
 
 sxSurelyNode:
diff --git a/src/predefSemantics.ml b/src/predefSemantics.ml
index b8a13ae6..cfed9660 100644
--- a/src/predefSemantics.ml
+++ b/src/predefSemantics.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 26/05/2008 (at 16:51) by Erwan Jahier> *)
+(** Time-stamp: <modified the 27/05/2008 (at 11:14) by Erwan Jahier> *)
 
 
 open Predef
@@ -111,9 +111,12 @@ let (unify : var_type list -> var_type list -> unify_result) =
 	   | Unif ts, Any, Atype t2 -> if ts = t2 then acc else
 	       Ko((type_eff2str ts) ^ " <> " ^ (type_eff2str t2))
 	   | Unif ts, Overload, Atype t2 -> 
-	       if ts = t2 && is_overloadable t2 then acc else
+	       if ts <> t2 then 
 		 Ko((type_eff2str ts) ^ " <> " ^ (type_eff2str t2))
-
+	       else if (not (is_overloadable t2)) then 
+		 Ko((type_eff2str ts) ^ "should be an int or a real")
+	       else
+		 acc
 	   | _,_, (Overload|Any) -> assert false (* cannot occur *)
       )
       Equal
diff --git a/src/syntaxTreeCore.ml b/src/syntaxTreeCore.ml
index c790f87c..75a6940d 100644
--- a/src/syntaxTreeCore.ml
+++ b/src/syntaxTreeCore.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 21/05/2008 (at 16:46) by Erwan Jahier> *)
+(** Time-stamp: <modified the 27/05/2008 (at 09:42) by Erwan Jahier> *)
 
 
 (** (Raw) Abstract syntax tree of source programs. *)
@@ -33,8 +33,8 @@ and node_info = {
 }
 
 and static_param =
-  | StaticParamType  of Ident.t (* long ??? *)
-  | StaticParamConst of (Ident.t(* long ??? *) * type_exp)
+  | StaticParamType  of Ident.t
+  | StaticParamConst of Ident.t * type_exp
   | StaticParamNode  of
       (Ident.t * var_info srcflagged list * var_info srcflagged list * has_mem_flag)
 
@@ -146,7 +146,7 @@ and static_arg =
   | StaticArgIdent of Ident.idref
   | StaticArgConst of val_exp
   | StaticArgType  of type_exp
-  | StaticArgNode  of node_exp
+  | StaticArgNode  of by_pos_op
 (*   | StaticArgFunc  of node_exp *)
 
 
diff --git a/src/syntaxTreeDump.ml b/src/syntaxTreeDump.ml
index f8ec8d26..bb750d72 100644
--- a/src/syntaxTreeDump.ml
+++ b/src/syntaxTreeDump.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 21/05/2008 (at 16:47) by Erwan Jahier> *)
+(** Time-stamp: <modified the 27/05/2008 (at 10:28) by Erwan Jahier> *)
 
 
 open Lxm
@@ -517,7 +517,7 @@ and dump_static_arg
 	| StaticArgIdent id -> fprintf os "%s" (Ident.string_of_idref id) 
 	| StaticArgConst ve -> fprintf os "const %a"    dump_val_exp ve
 	| StaticArgType  te -> fprintf os "type %a"     dump_type_exp te 
-	| StaticArgNode  ne -> fprintf os "node %a"     dump_node_exp ne
+	| StaticArgNode  op -> fprintf os "node %s"     (op2string op)
 (* 	| StaticArgFunc  ne -> fprintf os "function %a" dump_node_exp ne *)
 		      
 and dump_slice_info 
diff --git a/src/test/should_work/lionel/matrice.lus b/src/test/should_work/lionel/matrice.lus
index f9e0df35..46ebb8e5 100644
--- a/src/test/should_work/lionel/matrice.lus
+++ b/src/test/should_work/lionel/matrice.lus
@@ -12,7 +12,7 @@ tel
 node matrice ( a : int ) returns ( sum: int; bid: T_fibo; T: int^m^n); 
 let 
 	bid, T = fill << fill << fibo ; m >> ; n >> ([a, a]);	
-	sum = red << red << + ; m >> ; n >> (0, T ); 
+	sum = red << red <<node plus ; m >> ; n >> (0, T ); 
 tel
 
 
diff --git a/src/test/test.res.exp b/src/test/test.res.exp
index 2e87ab39..006cdef1 100644
--- a/src/test/test.res.exp
+++ b/src/test/test.res.exp
@@ -5902,7 +5902,7 @@ type struct0__Toto =  {x : int (1); y : int (2)};
 	Exported nodes:
 node struct0__bibi(dummy:int) returns (z: {x : int (1); y : int (2)});
 let
-   z = xxx todo ;
+   z = Toto{x=3};
 tel
 -- end of node struct0__bibi
 
@@ -7141,13 +7141,17 @@ End of Syntax table dump. 
 	Exported types:
 	Exported constants:
 	Exported nodes:
-*** Error in file "should_work/demo/mapiter.lus", line 9, col 19 to 21, token 'map': unknown node (map)
-
 node mapiter__incr_tab(a:int) returns (b:int);
 let
    b = (a + 1);
 tel
 -- end of node mapiter__incr_tab
+node mapiter__mapiter(i1:int^7^3) returns (s1:int^7^3);
+let
+    s1 = map<<node Lustre__map<<node mapiter__incr_tab, const 7>>, const
+	 3>>(i1);
+tel
+-- end of node mapiter__mapiter
 
 ----------------------------------------------------------------------
 ====> ../lus2lic -vl 3 --compile-all-items should_work/demo/mapiter_lv4.lus
@@ -7300,13 +7304,16 @@ End of Syntax table dump. 
 	Exported types:
 	Exported constants:
 	Exported nodes:
-*** Error in file "should_work/demo/rediter.lus", line 8, col 12 to 14, token 'red': unknown node (red)
-
 node rediter__max(init:int; a:int) returns (b:int);
 let
    b =  if ((init > a)) then (init) else (a);
 tel
 -- end of node rediter__max
+node rediter__rediter(a:int^5^3) returns (b:int);
+let
+   b = red<<node Lustre__red<<node rediter__max, const 5>>, const 3>>(0, a);
+tel
+-- end of node rediter__rediter
 
 ----------------------------------------------------------------------
 ====> ../lus2lic -vl 3 --compile-all-items should_work/demo/redoptest.lus
@@ -7601,8 +7608,9 @@ var
 let
    (bidon, T_inter) = fill<<node iter__filled, const 5>>(init);
    Tab_out = map<<node iter__mapped, const 5>>(T_inter);
-   Red_plus = red(-(100), Tab_out);
-   (zorroAcc, zorroTab) = fillred(0, [0, 0, 0, 0, 0]);
+   Red_plus = red<<node iter__plus, const 5>>(-(100), Tab_out);
+    (zorroAcc, zorroTab) = fillred<<node iter__garcia, const 5>>(0, [0, 0, 0,
+	 0, 0]);
 tel
 -- end of node iter__iter
 
@@ -7704,7 +7712,7 @@ returns (
 var
    bidon:int;
 let
-   (out_map1, out_map2) = map(IN1, IN2);
+   (out_map1, out_map2) = map<<node iterate__mapped, const 10>>(IN1, IN2);
    out_red1 = red<<node iterate__redduced, const 10>>(0, IN1, IN2);
    (bidon, out_fill1, out_fill2) = fill<<node iterate__filled, const 10>>(0);
     (out_fillred1, out_fillred2, out_fillred3, OUT) = fillred<<node
@@ -9649,7 +9657,7 @@ var
 let
     (bidon, TabOutFill) = fill<<node FillFollowedByRed__filled, const
 	 10>>(initFill);
-   ok = red(true, TabOutFill);
+   ok = red<<node FillFollowedByRed__reduced, const 10>>(true, TabOutFill);
 tel
 -- end of node FillFollowedByRed__FillFollowedByRed
 
@@ -9769,7 +9777,10 @@ returns (
 	rankToSelect : int;
 	elementSelected : bool});
 let
-   o_acc_out = xxx todo ;
+    o_acc_out = T3_STRUCT{currentRank=(i_acc_in.currentRank +
+	1);rankToSelect=i_acc_in.rankToSelect;elementSelected= if
+	((i_acc_in.currentRank = i_acc_in.rankToSelect)) then (i_currentElt) else
+	 (i_acc_in.elementSelected)};
 tel
 -- end of node shiftFill_ludic__n_selectOneStage
 
@@ -9781,7 +9792,9 @@ returns (
 var
    v_iterationResult: {currentRank : int; rankToSelect : int; elementSelected : bool};
 let
-   v_iterationResult = red(xxx todo , i_array);
+    v_iterationResult = red<<node shiftFill_ludic__n_selectOneStage, const
+	10>>(T3_STRUCT{currentRank=0;rankToSelect=i_rankToSelect;elementSelected=i_array[0]},
+	 i_array);
    o_elementSelected = v_iterationResult.elementSelected;
 tel
 -- end of node shiftFill_ludic__n_selectElementOfRank_inArray_
@@ -9796,7 +9809,9 @@ returns (
 	actual_rank : int};
 	o_elt_out:bool);
 let
-   o_acc_out = xxx todo ;
+    o_acc_out =
+	T2_STRUCT{multiplieur=i_acc_in.multiplieur;rank=i_acc_in.rank;actual_rank=(i_acc_in.actual_rank
+	 + 1)};
     o_elt_out =  if (((i_acc_in.actual_rank >= i_acc_in.rank) and
 	(i_acc_in.actual_rank < (i_acc_in.rank + c_size)))) then
 	(shiftFill_ludic__n_selectElementOfRank_inArray_(i_acc_in.actual_rank,
@@ -9868,7 +9883,10 @@ returns (
 	rankToSelect : int;
 	elementSelected : bool});
 let
-   o_acc_out = xxx todo ;
+    o_acc_out = T4_STRUCT{currentRank=(i_acc_in.currentRank +
+	1);rankToSelect=i_acc_in.rankToSelect;elementSelected= if
+	((i_acc_in.currentRank = i_acc_in.rankToSelect)) then (i_currentElt) else
+	 (i_acc_in.elementSelected)};
 tel
 -- end of node shift_ludic__n_selectOneStage
 
@@ -9880,7 +9898,9 @@ returns (
 var
    v_iterationResult: {currentRank : int; rankToSelect : int; elementSelected : bool};
 let
-   v_iterationResult = red(xxx todo , i_array);
+    v_iterationResult = red<<node shift_ludic__n_selectOneStage, const
+	10>>(T4_STRUCT{currentRank=0;rankToSelect=i_rankToSelect;elementSelected=i_array[0]},
+	 i_array);
    o_elementSelected = v_iterationResult.elementSelected;
 tel
 -- end of node shift_ludic__n_selectElementOfRank_inArray_
@@ -9895,7 +9915,9 @@ returns (
 	actual_rank : int};
 	o_elt_out:bool);
 let
-   o_acc_out = xxx todo ;
+    o_acc_out =
+	T2_STRUCT{multiplieur=i_acc_in.multiplieur;rank=i_acc_in.rank;actual_rank=(i_acc_in.actual_rank
+	 + 1)};
     o_elt_out =  if (((i_acc_in.actual_rank >= i_acc_in.rank) and
 	(i_acc_in.actual_rank < (i_acc_in.rank + c_size)))) then
 	(shift_ludic__n_selectElementOfRank_inArray_(i_acc_in.actual_rank,
@@ -9911,8 +9933,8 @@ returns (
 var
    v_bidon: {multiplieur : bool^10; rank : int; actual_rank : int};
 let
-    (v_bidon, o_ligne) = fill<<node shift_ludic__n_shiftFill, const 20>>(xxx
-	 todo );
+    (v_bidon, o_ligne) = fill<<node shift_ludic__n_shiftFill, const
+	 20>>(T2_STRUCT{multiplieur=i_acc_in.multiplieur;rank=i_acc_in.rank;actual_rank=0});
 tel
 -- end of node shift_ludic__n_shift
 
@@ -10098,8 +10120,45 @@ tel
 ----------------------------------------------------------------------
 ====> ../lus2lic -vl 3 --compile-all-items should_work/lionel/matrice.lus
 Opening file should_work/lionel/matrice.lus
-*** Error in file "should_work/lionel/matrice.lus", line 15, col 22 to 22, token '+': syntax error
+*** SyntaxTab.create pass 1
+*** SyntaxTab.create pass 2
+    init pack matrice
+       export type T_fibo
+       export const m
+       export const n
+       export node matrice
+       export node fibo
+*** SyntaxTab.create pass 3
+   init symbol tables for pack matrice
+*** SyntaxTab.create done
+*** « Syntax table dump:
+ 	 - Package or model list:
+		matrice (pack) 
+		
+	 - Raw model table: 
+	 - Raw Package table: matrice 
+	 - Package manager table: matrice 
+End of Syntax table dump. »
+-- MAIN NODE: "matrice__matrice"
+*** Dump the exported items of the packages.
+ * package matrice
+	Exported types:
+type matrice__T_fibo = int^2;
+	Exported constants:
+const matrice__m = 3;
+const matrice__n = 2;
+	Exported nodes:
+*** Error in file "should_work/lionel/matrice.lus", line 15, col 8 to 10, token 'red': type error: 
+*** type 'int*int^3^2' was provided whereas
+*** type 'o*o' was expected
+*** and int <> int^3^2
 
+node matrice__fibo(accu_in:int^2) returns (accu_out:int^2; elt:int);
+let
+   accu_out = [(accu_in[0] + accu_in[1]), accu_in[0]];
+   elt = (accu_in[0] + accu_in[1]);
+tel
+-- end of node matrice__fibo
 
 ----------------------------------------------------------------------
 ====> ../lus2lic -vl 3 --compile-all-items should_work/lionel/matrice2.lus
@@ -10285,7 +10344,8 @@ node pipeline__pipeline(in:bool^10) returns (out:bool^10);
 var
    accu_out:bool;
 let
-   (accu_out, out) = fillred(true -> pre(accu_out), in);
+    (accu_out, out) = fillred<<node pipeline__oneStep_pipe, const 10>>(true ->
+	 pre(accu_out), in);
 tel
 -- end of node pipeline__pipeline
 
@@ -10599,7 +10659,12 @@ returns (
 	RankFrom : int;
 	Rank : int});
 let
-   accu_out = xxx todo ;
+    accu_out = MinFR_accu{MinVal= if ((accu_in.Rank <= accu_in.RankFrom)) then
+	(TabEltIn) else ( if ((accu_in.Rank >= accu_in.RankFrom)) then ( if
+	((TabEltIn < accu_in.MinVal)) then (TabEltIn) else (accu_in.MinVal)) else
+	(accu_in.MinVal));MinRank= if ((accu_in.Rank > accu_in.RankFrom)) then ( if
+	((TabEltIn < accu_in.MinVal)) then (accu_in.Rank) else (accu_in.MinRank))
+	 else (accu_in.MinRank);RankFrom=accu_in.RankFrom;Rank=(accu_in.Rank + 1)};
 tel
 -- end of node tri__minFromRank
 
@@ -10613,7 +10678,10 @@ returns (
 	CurrentRank : int;
 	Val : int});
 let
-   accu_out = xxx todo ;
+    accu_out =
+	Select_accu{RankToFind=accu_in.RankToFind;CurrentRank=(accu_in.CurrentRank
+	+ 1);Val= if ((accu_in.RankToFind = accu_in.CurrentRank)) then (elt) else
+	 (accu_in.Val)};
 tel
 -- end of node tri__select
 
@@ -10632,7 +10700,9 @@ returns (
 	Rank : int};
 	eltOut:int);
 let
-   accu_out = xxx todo ;
+    accu_out =
+	Exchange_accu{MinVal=accu_in.MinVal;MinRank=accu_in.MinRank;RankFrom=accu_in.RankFrom;CurrentVal=accu_in.CurrentVal;Rank=(accu_in.Rank
+	 + 1)};
     eltOut =  if ((accu_in.Rank = accu_in.MinRank)) then (accu_in.CurrentVal)
 	else ( if ((accu_in.Rank = accu_in.RankFrom)) then (accu_in.MinVal) else
 	 (eltIn));
@@ -10652,17 +10722,25 @@ var
    accu_out_exchange: {MinVal : int; MinRank : int; RankFrom : int; CurrentVal : int; Rank : int};
    localTab:int^10;
 let
-   accu_out_min = red(xxx todo , accu_in.Tab);
-   accu_out_select = red(xxx todo , accu_in.Tab);
-   (accu_out_exchange, localTab) = fillred(xxx todo , accu_in.Tab);
-   accu_out = xxx todo ;
+    accu_out_min = red<<node tri__minFromRank, const
+	10>>(MinFR_accu{MinVal=0;MinRank=accu_in.CurrentRank;RankFrom=accu_in.CurrentRank;Rank=0},
+	 accu_in.Tab);
+    accu_out_select = red<<node tri__select, const
+	10>>(Select_accu{RankToFind=accu_in.CurrentRank;CurrentRank=0;Val=0},
+	 accu_in.Tab);
+    (accu_out_exchange, localTab) = fillred<<node tri__Exchange_i_j, const
+	10>>(Exchange_accu{MinVal=accu_out_min.MinVal;MinRank=accu_out_min.MinRank;RankFrom=accu_out_select.RankToFind;CurrentVal=accu_out_select.Val;Rank=0},
+	 accu_in.Tab);
+   accu_out = Sort_accu{CurrentRank=(accu_in.CurrentRank + 1);Tab=localTab};
 tel
 -- end of node tri__UnarySort
 node tri__main(TIn:int^10) returns (TSorted:int^10);
 var
    UnarySort_accu_out: {CurrentRank : int; Tab : int^10};
 let
-   UnarySort_accu_out = red(xxx todo , [7, 8, 4, 3, 2, 9, 1, 10, 2, 7]);
+    UnarySort_accu_out = red<<node tri__UnarySort, const
+	10>>(Sort_accu{CurrentRank=0;Tab=[7, 8, 4, 3, 2, 9, 1, 10, 2, 7]}, [7, 8,
+	 4, 3, 2, 9, 1, 10, 2, 7]);
    TSorted = UnarySort_accu_out.Tab;
 tel
 -- end of node tri__main
@@ -10675,7 +10753,8 @@ returns (
 	accu_out: {prev_elt : int;
 	prop_is_tt : bool});
 let
-   accu_out = xxx todo ;
+    accu_out = sorted_iter_accu{prev_elt=elt;prop_is_tt=((accu_in.prev_elt <=
+	 elt) and accu_in.prop_is_tt)};
 tel
 -- end of node tri__sorted_iter
 node tri__Sorted(TIn:int^10) returns (res:bool);
@@ -10684,7 +10763,8 @@ var
    TSorted:int^10;
 let
    TSorted = tri__main(TIn);
-   accu_out = red(xxx todo , TSorted);
+    accu_out = red<<node tri__sorted_iter, const
+	 10>>(sorted_iter_accu{prev_elt=0;prop_is_tt=true}, TSorted);
    res = accu_out.prop_is_tt;
 tel
 -- end of node tri__Sorted
@@ -10785,7 +10865,7 @@ returns (
 	b : bool;
 	r : real});
 let
-   out2 = xxx todo ;
+   out2 = selType{i=0;b=true;r=0.};
    out. = pint__fby1(out2.i, in.i);
    out. = pbool__fby1(out2.b, in.b);
    out. = preal__fby1(out2.r, in.r);
@@ -10895,7 +10975,7 @@ returns (
 	b : bool;
 	r : real});
 let
-   out2 = xxx todo ;
+   out2 = selType{i=0;b=true;r=0.};
    out. = pint__fby1(out2.i, in.i);
    out. = pbool__fby1(out2.b, in.b);
    out. = preal__fby1(out2.r, in.r);
-- 
GitLab