From a533b0b3f4b2a2c7fc2e1c1927a704d6a6e1851c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Fri, 29 Apr 2011 15:11:21 +0200 Subject: [PATCH] Proper fix for init of outputs with last --- compiler/heptagon/analysis/initialization.ml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/heptagon/analysis/initialization.ml b/compiler/heptagon/analysis/initialization.ml index afc9bd8..cc23707 100644 --- a/compiler/heptagon/analysis/initialization.ml +++ b/compiler/heptagon/analysis/initialization.ml @@ -95,16 +95,17 @@ struct let add_var x v h = add (Var x) v h let add_last x v h = add (Last x) v h - let add_var_dec h vd = - let x = vd.v_ident in + let _add_var_dec def h vd = + let h = add_var vd.v_ident def h in match vd.v_last with - | Heptagon.Var -> add_var x (new_var ()) h + | Heptagon.Var -> h | Heptagon.Last None -> - let h = add_var x (new_var ()) h in - add_last x (ione (RLast_none x)) h (* last is not initialized *) + add_last vd.v_ident (ione (RLast_none vd.v_ident)) h (* last is not initialized *) | Heptagon.Last (Some _) -> - let h = add_var x (new_var ()) h in - add_last x izero h (* last is initialized *) + add_last vd.v_ident izero h (* last is initialized *) + + let add_initd_var_dec h vd = _add_var_dec izero h vd + let add_var_dec h vd = _add_var_dec (new_var ()) h vd end (** return the representent of a [typ] ( the max ) *) @@ -363,7 +364,7 @@ and build h vdecs = (* add var_decs as initialized to a typing environement *) let build_initialized h vdecs = - List.fold_left (fun h { v_ident = x } -> IEnv.add_var x izero h) h vdecs + List.fold_left IEnv.add_initd_var_dec h vdecs let typing_contract h contract = match contract with @@ -383,7 +384,7 @@ let typing_contract h contract = let typing_node { n_input = i_list; n_output = o_list; n_contract = contract; n_block = b } = let h = build_initialized IEnv.empty i_list in - let h = build h o_list in + let h = build_initialized h o_list in let h = typing_contract h contract in ignore (typing_block h b)