From 2fd312426f8bdd14ae62e4a80681be757162fd19 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Wed, 11 Mar 2009 16:44:06 +0100
Subject: [PATCH] Fix a bug in the node expanser: node params were nor
 substituted when expressions.

---
 src/nodesExpand.ml                    | 14 +++++++++-----
 src/test/should_work/lionel/clock.lus |  3 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/nodesExpand.ml b/src/nodesExpand.ml
index f8fc956d..ed69ae72 100644
--- a/src/nodesExpand.ml
+++ b/src/nodesExpand.ml
@@ -1,4 +1,4 @@
-(** Time-stamp: <modified the 11/03/2009 (at 16:18) by Erwan Jahier> *)
+(** Time-stamp: <modified the 11/03/2009 (at 16:41) by Erwan Jahier> *)
 
 (** 
    nb : only user nodes are expanded.
@@ -108,8 +108,8 @@ let (get_node_body : Eff.local_env -> Eff.node_exp -> Eff.node_body option) =
 
 (********************************************************************************)
 type subst = (var_info * var_info) list 
-let rec (substitute : subst -> Eff.eq_info Lxm.srcflagged -> 
-          Eff.eq_info Lxm.srcflagged) =
+let rec (substitute : 
+           subst -> Eff.eq_info Lxm.srcflagged -> Eff.eq_info Lxm.srcflagged) =
   fun s { it = (lhs,ve) ; src = lxm } -> 
     let lhs = List.map (subst_in_left s) lhs in
     let newve = subst_in_val_exp s ve in
@@ -148,8 +148,12 @@ and (subst_in_val_exp : subst -> val_exp -> val_exp) =
                 | WITH(ve) -> WITH(subst_in_val_exp s ve)
                 | HAT(i,ve) -> HAT(i, subst_in_val_exp s ve)
                 | ARRAY(vel) -> ARRAY(List.map (subst_in_val_exp s) vel)
-                    
-                | Predef _| CALL _ | PRE | ARROW | FBY | CURRENT | WHEN _ | TUPLE
+                | WHEN(SyntaxTreeCore.Base) ->  WHEN(SyntaxTreeCore.Base)
+                | WHEN(SyntaxTreeCore.NamedClock {src=lxm;it=(cc,cv)}) -> 
+                    let var = snd(List.find (fun (v,_) -> v.var_name_eff = cv) s) in
+                    let cv = var.var_name_eff in
+                      WHEN(SyntaxTreeCore.NamedClock  {src=lxm;it=(cc,cv)})
+                | Predef _| CALL _ | PRE | ARROW | FBY | CURRENT  | TUPLE
                 | CONCAT | STRUCT_ACCESS _ | ARRAY_ACCES _ | ARRAY_SLICE _  | MERGE _ 
                       (*               | CONST _ *)
                     -> by_pos_op
diff --git a/src/test/should_work/lionel/clock.lus b/src/test/should_work/lionel/clock.lus
index 0a6ef6e0..9db63116 100644
--- a/src/test/should_work/lionel/clock.lus
+++ b/src/test/should_work/lionel/clock.lus
@@ -1,3 +1,4 @@
+
 node  n1(ck : bool) returns (out : int when ck; ckout : bool);
 var cpt : int;
 let
@@ -6,7 +7,6 @@ let
   ckout = ck;
 tel
 
-
 node system(ck1 : bool) returns (out : int);
 var
   ckout : bool;
@@ -17,6 +17,7 @@ let
 tel
 
 
+
 node n2(ck : bool; in : int) returns (out : int when ck);
 let
   out = in when ck;
-- 
GitLab