From 5c33810e44cf6afe5286cac1c6386392a57e50c6 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Mon, 2 Jun 2008 14:21:26 +0200
Subject: [PATCH] Fix a bug in the way array expressions such as "0^5" were
 represented. Indeed, it was represented by "HAT_eff of int * type_eff"
 instead of "HAT_eff of int * val_exp_eff"

---
 src/TODO                                  |  2 +
 src/compiledData.ml                       |  4 +-
 src/compiledDataDump.ml                   |  2 +-
 src/evalType.ml                           |  7 ++-
 src/getEff.ml                             | 20 ++++---
 src/test/should_work/lionel/testSilus.lus |  4 +-
 src/test/test.res.exp                     | 64 +++++++++++------------
 7 files changed, 56 insertions(+), 47 deletions(-)

diff --git a/src/TODO b/src/TODO
index cab1af36..a270b25f 100644
--- a/src/TODO
+++ b/src/TODO
@@ -145,6 +145,8 @@ index de slice
 	- rajouter modele, package, etc.
 	- l'indentation est vraiment à chier
 
+* verifier que tous les "assert false" sont vraiment innateingnables.
+
 * finir de rédiger le manuel
 
 + verifier que j'y parle bien de la priorite des operateurs
diff --git a/src/compiledData.ml b/src/compiledData.ml
index edd6395e..65def6c7 100644
--- a/src/compiledData.ml
+++ b/src/compiledData.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 29/05/2008 (at 10:24) by Erwan Jahier> *)
+(** Time-stamp: <modified the 02/06/2008 (at 14:01) by Erwan Jahier> *)
 
 (** 
 
@@ -198,7 +198,7 @@ and by_pos_op_eff =
   | WITH_eff
 
   | CONCAT_eff
-  | HAT_eff of int * type_eff
+  | HAT_eff of int * val_exp_eff
   | ARRAY_eff
   | STRUCT_ACCESS_eff of Ident.t
 
diff --git a/src/compiledDataDump.ml b/src/compiledDataDump.ml
index 3320043d..ec0ee858 100644
--- a/src/compiledDataDump.ml
+++ b/src/compiledDataDump.ml
@@ -184,7 +184,7 @@ and (string_of_by_pos_op_eff : by_pos_op_eff -> val_exp_eff list -> string) =
 	| WITH_eff,_ -> "with " ^ (tuple vel)
 	| CONCAT_eff, [ve1; ve2] ->  
 	    (string_of_val_exp_eff ve1) ^ " | " ^ (string_of_val_exp_eff ve2)
-	| HAT_eff (i, teff), _ -> (string_of_type_eff teff) ^ "^" ^ (string_of_int i)
+	| HAT_eff (i, ve), _ -> (string_of_val_exp_eff ve) ^ "^" ^ (string_of_int i)
 	| ARRAY_eff, _ -> tuple_square vel
 	| STRUCT_ACCESS_eff(id), [ve1] ->
 	    (string_of_val_exp_eff ve1) ^ "." ^ (Ident.to_string id)
diff --git a/src/evalType.ml b/src/evalType.ml
index 77786427..96963056 100644
--- a/src/evalType.ml
+++ b/src/evalType.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 30/05/2008 (at 17:46) by Erwan Jahier> *)
+(** Time-stamp: <modified the 02/06/2008 (at 14:14) by Erwan Jahier> *)
  
   
 open Predef
@@ -96,7 +96,10 @@ and (eval_by_pos_type :
       | ARRAY_SLICE_eff  (sieff,teff) -> 
 	    [Array_type_eff(teff, sieff.se_width)]
 
-      | HAT_eff(size,teff) -> [Array_type_eff(teff,size)]
+      | HAT_eff(size,ceff) -> 
+	  let teff_list = f id_solver ceff in
+	    List.map (fun teff -> Array_type_eff(teff, size)) teff_list
+	  
       | ARRAY_eff ->
 	  (* check that args are of the same type *)
 	  let type_args_eff = (List.map (f id_solver) args) in
diff --git a/src/getEff.ml b/src/getEff.ml
index 3339e371..a6fce3dc 100644
--- a/src/getEff.ml
+++ b/src/getEff.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 27/05/2008 (at 10:24) by Erwan Jahier> *)
+(** Time-stamp: <modified the 02/06/2008 (at 14:16) by Erwan Jahier> *)
 
 
 open Lxm
@@ -327,7 +327,11 @@ and (translate_by_pos_op : id_solver -> by_pos_op -> Lxm.t -> val_exp list ->
 	  let size, teff_elt =
 	    match teff with
 	      | [Array_type_eff(teff_elt, size)] -> size, teff_elt
-	      | _ -> assert false
+	      | _ ->
+		  raise (Compile_error(
+			   lxm, "\n*** Type error: '" ^ 
+			     (CompiledDataDump.string_of_type_eff_list teff) ^ 
+			     "' was expected to be an array"))
 	  in
 	    ARRAY_ACCES_eff(
 	      EvalConst.eval_array_index id_solver ve_index size lxm, 
@@ -342,7 +346,11 @@ and (translate_by_pos_op : id_solver -> by_pos_op -> Lxm.t -> val_exp list ->
 	  let size, teff_elt =
 	    match teff with
 	      | [Array_type_eff(teff_elt, size)] -> size, teff_elt
-	      | _ -> assert false
+	      | _ ->
+		  raise (Compile_error(
+			   lxm, "\n*** Type error: '" ^ 
+			     (CompiledDataDump.string_of_type_eff_list teff) ^ 
+			     "' was expected to be an array"))
 	  in
 	    ARRAY_SLICE_eff(EvalConst.eval_array_slice id_solver si size lxm, 
 			    teff_elt)
@@ -351,9 +359,9 @@ and (translate_by_pos_op : id_solver -> by_pos_op -> Lxm.t -> val_exp list ->
 	  match args with
 	    | [exp; ve_size] -> 
 		let size_const_eff = EvalConst.f id_solver ve_size 
-		and teff_elt = EvalType.f id_solver (translate_val_exp id_solver exp) in
-		  (match size_const_eff,teff_elt with
-		     | [Int_const_eff size],[teff_elt] ->  HAT_eff(size, teff_elt)
+		and exp_eff = translate_val_exp id_solver exp in 
+		  (match size_const_eff with
+		     | [Int_const_eff size] -> HAT_eff(size, exp_eff)
 		     | _ -> assert false)
 	    | _ -> assert false
 	)
diff --git a/src/test/should_work/lionel/testSilus.lus b/src/test/should_work/lionel/testSilus.lus
index e0727829..2fef5f9c 100644
--- a/src/test/should_work/lionel/testSilus.lus
+++ b/src/test/should_work/lionel/testSilus.lus
@@ -202,8 +202,8 @@ node fusion_com (AllTabComChg : T_ComChgNBC^NBG ;    -- OK
 let
 	Vide = COM_ERR^NBC;
 	TabComChg = red<<fusion_tab_com; NBG>>(Vide,            --acc d'entree
-										   AllTabComChg,
-										   AllTabComVal);	
+                                        AllTabComChg,
+                                        AllTabComVal);	
 tel
 
 
diff --git a/src/test/test.res.exp b/src/test/test.res.exp
index 0c4bc6d3..95e7fa8b 100644
--- a/src/test/test.res.exp
+++ b/src/test/test.res.exp
@@ -5042,13 +5042,13 @@ type left__truc = left::truc {a : bool^100; b : int};
 	Exported nodes:
 node left__toto(x:bool) returns (t:left::truc {a : bool^100; b : int}^3);
 let
-   t[0].[0..98 step 2][48..0 step -2] = bool^25;
-   t[0].[0..98 step 2][1..49 step 2] = bool^25;
+   t[0].[0..98 step 2][48..0 step -2] = true^25;
+   t[0].[0..98 step 2][1..49 step 2] = false^25;
    t[0].[1..99 step 2][0] = true;
    t[0].[1..99 step 2][1] = true;
-   t[0].[5..99 step 2] = bool^48;
+   t[0].[5..99 step 2] = false^48;
    t[0]. = 42;
-   t[1..2] = left::truc {a : bool^100; b : int}^2;
+   t[1..2] = truc{a=true^100;b=0}^2;
 tel
 -- end of node left__toto
 
@@ -6595,8 +6595,8 @@ returns (
 var
    NbToFar:int;
 let
-    NbToFar = red<<node Gyroscope2__TooFar, const 4>>(0, channels, real^4,
-	 real^4);
+    NbToFar = red<<node Gyroscope2__TooFar, const 4>>(0, channels, god^4,
+	 delta_to_god^4);
    assumeOK = (NbToFar <= 1);
 tel
 -- end of node Gyroscope2__assumeEvaluateAxis
@@ -6746,8 +6746,8 @@ var
 let
    localtabToFill = Valid_ChannelT{local_failure=false;local_value=0.0};
     acc_out = red<<node Gyroscope2__CFC_iter, const
-	4>>(CFF_struct{indx=0;indx_toChange=currentChannelIndx;tabToFill=Gyroscope2::Valid_ChannelT
-	 {local_failure : bool; local_value : real}^3}, allChannels);
+	4>>(CFF_struct{indx=0;indx_toChange=currentChannelIndx;tabToFill=localtabToFill^3},
+	 allChannels);
    foreignChannels = acc_out.tabToFill;
 tel
 -- end of node Gyroscope2__ComputeForeignChannels
@@ -6929,10 +6929,9 @@ var
    initChannels:Gyroscope2::Valid_ChannelT {local_failure : bool; local_value : real}^4;
    fillredInit:Gyroscope2::Valid_ChannelT {local_failure : bool; local_value : real}^4;
 let
-    initChannels = Gyroscope2::Valid_ChannelT {local_failure : bool;
-	 local_value : real}^4;
+   initChannels = Valid_ChannelT{local_failure=false;local_value=0.0}^4;
     (dumbChannel, resChannels) = fillred<<node Gyroscope2__Channel, const
-	 4>>(fillredInit, [0, 1, 2, 3], channels, real^4, real^4, real^4);
+	 4>>(fillredInit, [0, 1, 2, 3], channels, delta^4, god^4, delta_to_god^4);
    AxisValue = Gyroscope2__Voter(resChannels, god, delta_to_god);
    fillredInit = initChannels -> pre(resChannels);
 tel
@@ -6965,7 +6964,7 @@ returns (
 	guaranteeOK:bool);
 let
     guaranteeOK = red<<node Gyroscope2__iteratedVoter, const 4>>(true,
-	 channels, real^4, real^4, real^4);
+	 channels, god^4, delta_to_god^4, vote^4);
 tel
 -- end of node Gyroscope2__guaranteeVoter
 
@@ -7030,8 +7029,7 @@ tel
 node alias__alias(a:bool) returns (b:bool; c:int);
 let
    b = alias__aliasPredefNot(a);
-    c = alias__aliasGivenNode(0, map<<node Lustre__+, const 3>>(int^3,
-	 int^3));
+   c = alias__aliasGivenNode(0, map<<node Lustre__+, const 3>>(0^3, SIZE^3));
 tel
 -- end of node alias__alias
 
@@ -7900,7 +7898,7 @@ node plus__plus(a:int; b:int) returns (c:int; d:int; e:int; f:int);
 let
    c = (a + b);
    d = (a + b);
-   e =  if (boolred<<const 0, const 1, const 2>>(bool^2)) then (a) else (b);
+   e =  if (boolred<<const 0, const 1, const 2>>(true^2)) then (a) else (b);
     f =  if (nor((c < b), (c <= b))) then (a) else ((b +  if (boolred<<const
 	 0, const 0, const 2>>([(c < b), (c <= b)])) then (a) else (b)));
 tel
@@ -10499,8 +10497,8 @@ returns (
 var
    NbToFar:int;
 let
-    NbToFar = red<<node Gyroscope__TooFar, const 4>>(0, channels, real^4,
-	 real^4);
+    NbToFar = red<<node Gyroscope__TooFar, const 4>>(0, channels, god^4,
+	 delta_to_god^4);
    assumeOK = (NbToFar <= 1);
 tel
 -- end of node Gyroscope__assumeEvaluateAxis
@@ -10639,8 +10637,8 @@ var
    resChannels:Gyroscope::Valid_ChannelT {local_failure : bool; local_value : real}^4;
    AxisValue2:real;
 let
-    resChannels = map<<node Gyroscope__Channel, const 4>>(channels, real^4,
-	 real^4, real^4);
+    resChannels = map<<node Gyroscope__Channel, const 4>>(channels, delta^4,
+	 god^4, delta_to_god^4);
    AxisValue = Gyroscope__Voter(resChannels, god, delta_to_god);
    AxisValue2 = Gyroscope__Voter2(resChannels, god, delta_to_god);
 tel
@@ -10756,7 +10754,7 @@ returns (
 	guaranteeOK:bool);
 let
     guaranteeOK = red<<node Gyroscope__iteratedVoter, const 4>>(true,
-	 channels, real^4, real^4, real^4);
+	 channels, god^4, delta_to_god^4, vote^4);
 tel
 -- end of node Gyroscope__guaranteeVoter
 
@@ -10902,7 +10900,7 @@ node produitBool__produitBool(
 returns (
 	matrice:bool^20^10);
 let
-   matrice = bool^20^10;
+   matrice = true^20^10;
 tel
 -- end of node produitBool__produitBool
 
@@ -10915,7 +10913,7 @@ returns (
 	rank : int};
 	ligne:bool^20);
 let
-    ligne =  if ((multiplicande = false)) then (bool^20) else
+    ligne =  if ((multiplicande = false)) then (multiplicande^20) else
 	 (produitBool__shift(acc_in));
 tel
 -- end of node produitBool__PLC
@@ -11644,7 +11642,7 @@ const matrice2__n = 2;
 node matrice2__matrice2(a:int) returns (res:int);
 let
     res = red<<node Lustre__red<<node Lustre__+, const 2>>, const 2>>(0,
-	 int^2^2);
+	 1^2^2);
 tel
 -- end of node matrice2__matrice2
 
@@ -11944,7 +11942,7 @@ returns (
 var
    Vide:int^20;
 let
-   Vide = int^20;
+   Vide = COM_ERR^20;
     TabComChg = red<<node normal__fusion_tab_com, const 4>>(Vide,
 	 AllTabComChg, AllTabComVal);
 tel
@@ -12000,7 +11998,7 @@ returns (
 	TabInfoChgGlob:normal::T_InfoChgGlob {chg2gen : int^20}^20);
 let
    TabInfoChgIndiv = normal__extract_tab_info_chg_indiv(EntreeGlob);
-   TabInfoChgGlob = normal::T_InfoChgGlob {chg2gen : int^20}^20;
+   TabInfoChgGlob = normal__extract_info_chg_glob(EntreeGlob)^20;
 tel
 -- end of node normal__extrCharge
 node normal__trChItere(acc_in:int; elt:int) returns (acc_out:int);
@@ -12105,8 +12103,7 @@ var
    bid:int;
 let
    TabInfoGenIndiv = normal__extract_tab_info_gen_indiv(EntreeGlob);
-    TabInfoGenGlob = normal::T_InfoGenGlob {elt_bidon : int; chg2gen :
-	 int^20}^4;
+   TabInfoGenGlob = normal__extract_info_gen_glob(EntreeGlob)^4;
    (bid, TabIndiceGen) = fill<<node normal__incr_acc, const 4>>(0);
 tel
 -- end of node normal__extrGen
@@ -12122,7 +12119,7 @@ returns (
 	AllTabComVal:bool^20^4);
 let
     (AllTabComChg, AllTabComVal) = map<<node normal__traite_gen, const
-	 4>>(TabIndiceGen, TabInfoGenIndiv, TabInfoGenGlob, int^20^4);
+	 4>>(TabIndiceGen, TabInfoGenIndiv, TabInfoGenGlob, TabEtatCharge^4);
 tel
 -- end of node normal__traiteGen
 
@@ -12435,7 +12432,7 @@ const simpleRed__n = 2;
 	Exported nodes:
 node simpleRed__simpleRed(a:int) returns (res:int);
 let
-   res = red<<node Lustre__+, const 3>>(0, int^3);
+   res = red<<node Lustre__+, const 3>>(0, a^3);
 tel
 -- end of node simpleRed__simpleRed
 
@@ -12611,7 +12608,7 @@ returns (
 var
    Vide:int^20;
 let
-   Vide = int^20;
+   Vide = COM_ERR^20;
     TabComChg = red<<node testSilus__fusion_tab_com, const 4>>(Vide,
 	 AllTabComChg, AllTabComVal);
 tel
@@ -12656,7 +12653,7 @@ returns (
 	TabInfoChgGlob:testSilus::T_InfoChgGlob {chg2gen : int^20}^20);
 let
    TabInfoChgIndiv = testSilus__extract_tab_info_chg_indiv(EntreeGlob);
-   TabInfoChgGlob = testSilus::T_InfoChgGlob {chg2gen : int^20}^20;
+   TabInfoChgGlob = testSilus__extract_info_chg_glob(EntreeGlob)^20;
 tel
 -- end of node testSilus__extrCharge
 node testSilus__trChItere(acc_in:int; elt:int) returns (acc_out:int);
@@ -12758,8 +12755,7 @@ var
    bidon:int;
 let
    TabInfoGenIndiv = testSilus__extract_tab_info_gen_indiv(EntreeGlob);
-    TabInfoGenGlob = testSilus::T_InfoGenGlob {elt_bidon : int; chg2gen :
-	 int^20}^4;
+   TabInfoGenGlob = testSilus__extract_info_gen_glob(EntreeGlob)^4;
    (bidon, TabIndiceGen) = fill<<node testSilus__incr_acc, const 4>>(0);
 tel
 -- end of node testSilus__extrGen
@@ -12775,7 +12771,7 @@ returns (
 	AllTabComVal:bool^20^4);
 let
     (AllTabComChg, AllTabComVal) = map<<node testSilus__traite_gen, const
-	 4>>(TabIndiceGen, TabInfoGenIndiv, TabInfoGenGlob, int^20^4);
+	 4>>(TabIndiceGen, TabInfoGenIndiv, TabInfoGenGlob, TabEtatCharge^4);
 tel
 -- end of node testSilus__traiteGen
 
-- 
GitLab