From 26416abd0fbd9794d79ac7122f1300ea1c988cfd Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Mon, 16 Jun 2014 11:28:43 +0200
Subject: [PATCH] SocExec : Fix a bug affecting iterators on nodes with memory

---
 src/socExec.ml    | 14 ++++++++------
 test/lus2lic.sum  | 14 +++++++-------
 test/lus2lic.time |  2 +-
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/socExec.ml b/src/socExec.ml
index b6dafe18..23741a18 100644
--- a/src/socExec.ml
+++ b/src/socExec.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 10/06/2014 (at 10:47) by Erwan Jahier> *)
+(* Time-stamp: <modified the 16/06/2014 (at 11:48) by Erwan Jahier> *)
 
 open Soc
 open Data
@@ -114,10 +114,11 @@ let rec (soc_step : Soc.step_method -> Soc.tbl -> Soc.t -> SocExecValue.ctx
               | _ -> assert false (* should not occur *)
           in
           rctx := do_step inst_name.(i) node_step !rctx soc_tbl node_soc vel_in vel_out;
+          rctx := { !rctx with s = sadd !rctx.s ("$first_step"::!rctx.cpath) (B false) };
           rctx := { !rctx with cpath = List.tl !rctx.cpath };
         done;
         if iter <> "map" then (
-          let a_in = Var (List.hd iter_inputs) in
+          let a_in  = Var (List.hd iter_inputs) in
           let a_out = Var (List.hd iter_outputs) in
           rctx := assign_expr !rctx a_in a_out);  (* a_out=a_n *)
         !rctx;
@@ -147,7 +148,9 @@ and (do_gao :  Lxm.t -> Soc.tbl -> SocExecValue.ctx -> gao -> SocExecValue.ctx)
         let soc = SocUtils.find lxm sk soc_tbl in
         let step = match soc.step with [step] -> step | _ ->  assert false in
         let ctx = do_step proc_name step ctx soc_tbl soc vel_in vel_out in
-        { ctx with cpath = path_saved } 
+        { ctx with 
+          cpath = path_saved 
+        } 
       )
       | Call(vel_out, Method((inst_name,sk),step_name), vel_in) -> (
         let path_saved = ctx.cpath in
@@ -157,9 +160,7 @@ and (do_gao :  Lxm.t -> Soc.tbl -> SocExecValue.ctx -> gao -> SocExecValue.ctx)
           with Not_found -> assert false
         in
         let ctx = do_step inst_name step ctx soc_tbl soc vel_in vel_out in
-        let ctx = { s = sadd ctx.s ("$first_step"::ctx.cpath) (B false);
-                    cpath = path_saved } 
-        in
+        let ctx = { ctx with cpath = path_saved } in
         ctx
       )
 and (do_step : Ident.t -> step_method -> SocExecValue.ctx -> Soc.tbl -> Soc.t -> 
@@ -171,6 +172,7 @@ and (do_step : Ident.t -> step_method -> SocExecValue.ctx -> Soc.tbl -> Soc.t ->
     let new_s = substitute_args_and_params vel_in step_in_vars ctx in
     let ctx = soc_step step soc_tbl soc { ctx with s=new_s } in
     let s_out = substitute_params_and_args step_out_vars vel_out ctx in
+    let s_out = sadd s_out ("$first_step"::ctx.cpath) (B false) in
     { ctx with s = s_out }
 
 (* get the step params from its soc params *)
diff --git a/test/lus2lic.sum b/test/lus2lic.sum
index f2e434dc..7a7e0d4f 100644
--- a/test/lus2lic.sum
+++ b/test/lus2lic.sum
@@ -1,4 +1,4 @@
-Test Run By jahier on Fri Jun 13 17:01:22 2014
+Test Run By jahier on Mon Jun 16 16:08:25 2014
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic tests ===
@@ -157,7 +157,7 @@ FAIL: Generate c code  : ./lus2lic {-2c should_work/call06.lus -n call06}
 PASS: ./lus2lic {-o /tmp/deSimone.lic should_work/deSimone.lus}
 PASS: ./lus2lic {-ec -o /tmp/deSimone.ec should_work/deSimone.lus}
 PASS: ./myec2c {-o /tmp/deSimone.c /tmp/deSimone.ec}
-FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/deSimone.lus
+PASS: ../utils/test_lus2lic_no_node should_work/deSimone.lus
 PASS: ./lus2lic {-2c should_work/deSimone.lus -n deSimone}
 FAIL: Check that the generated C code compiles  : gcc deSimone_deSimone.c deSimone_deSimone_loop.c 
 PASS: ./lus2lic {-o /tmp/bug2.lic should_work/bug2.lus}
@@ -280,7 +280,7 @@ PASS: gcc test_node_expand2_test_node_expand2.c test_node_expand2_test_node_expa
 PASS: ./lus2lic {-o /tmp/test.lic should_work/test.lus}
 PASS: ./lus2lic {-ec -o /tmp/test.ec should_work/test.lus}
 PASS: ./myec2c {-o /tmp/test.c /tmp/test.ec}
-FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/test.lus
+PASS: ../utils/test_lus2lic_no_node should_work/test.lus
 PASS: ./lus2lic {-2c should_work/test.lus -n test}
 PASS: gcc test_test.c test_test_loop.c 
 PASS: ./lus2lic {-o /tmp/FALLING_EDGE.lic should_work/FALLING_EDGE.lus}
@@ -618,7 +618,7 @@ PASS: gcc param_node3_param_node3.c param_node3_param_node3_loop.c
 PASS: ./lus2lic {-o /tmp/pipeline.lic should_work/pipeline.lus}
 PASS: ./lus2lic {-ec -o /tmp/pipeline.ec should_work/pipeline.lus}
 PASS: ./myec2c {-o /tmp/pipeline.c /tmp/pipeline.ec}
-FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/pipeline.lus
+PASS: ../utils/test_lus2lic_no_node should_work/pipeline.lus
 PASS: ./lus2lic {-2c should_work/pipeline.lus -n pipeline}
 FAIL: Check that the generated C code compiles  : gcc pipeline_pipeline.c pipeline_pipeline_loop.c 
 PASS: ./lus2lic {-o /tmp/mapinf.lic should_work/mapinf.lus}
@@ -1479,9 +1479,9 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman
 
 		=== lus2lic Summary ===
 
-# of expected passes		1211
-# of unexpected failures	198
+# of expected passes		1214
+# of unexpected failures	195
 # of unexpected successes	21
 # of expected failures		37
-testcase ./lus2lic.tests/non-reg.exp completed in 118 seconds
+testcase ./lus2lic.tests/non-reg.exp completed in 133 seconds
 testcase ./lus2lic.tests/progression.exp completed in 0 seconds
diff --git a/test/lus2lic.time b/test/lus2lic.time
index 8501891b..e21759fc 100644
--- a/test/lus2lic.time
+++ b/test/lus2lic.time
@@ -1,2 +1,2 @@
-testcase ./lus2lic.tests/non-reg.exp completed in 118 seconds
+testcase ./lus2lic.tests/non-reg.exp completed in 133 seconds
 testcase ./lus2lic.tests/progression.exp completed in 0 seconds
-- 
GitLab